aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS6
-rw-r--r--Documentation/Changes2
-rw-r--r--Documentation/DocBook/kernel-api.tmpl4
-rw-r--r--Documentation/DocBook/libata.tmpl1072
-rw-r--r--Documentation/DocBook/usb.tmpl2
-rw-r--r--Documentation/DocBook/writing_usb_driver.tmpl3
-rw-r--r--Documentation/block/biodoc.txt113
-rw-r--r--Documentation/driver-model/driver.txt68
-rw-r--r--Documentation/driver-model/porting.txt2
-rw-r--r--Documentation/hwmon/it878
-rw-r--r--Documentation/hwmon/lm9047
-rw-r--r--Documentation/hwmon/smsc47b3978
-rw-r--r--Documentation/hwmon/smsc47m17
-rw-r--r--Documentation/hwmon/sysfs-interface3
-rw-r--r--Documentation/hwmon/via686a17
-rw-r--r--Documentation/i2c/busses/i2c-i8101
-rw-r--r--Documentation/i2c/busses/i2c-viapro27
-rw-r--r--Documentation/i2c/chips/x120538
-rw-r--r--Documentation/i2c/functionality7
-rw-r--r--Documentation/i2c/porting-clients2
-rw-r--r--Documentation/i2c/writing-clients27
-rw-r--r--Documentation/input/yealink.txt19
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/networking/bonding.txt5
-rw-r--r--MAINTAINERS35
-rw-r--r--Makefile6
-rw-r--r--arch/alpha/kernel/pci-noop.c2
-rw-r--r--arch/alpha/kernel/pci_iommu.c2
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/boot/compressed/head.S3
-rw-r--r--arch/arm/common/locomo.c10
-rw-r--r--arch/arm/common/sa1111.c11
-rw-r--r--arch/arm/common/scoop.c24
-rw-r--r--arch/arm/configs/mp1000_defconfig897
-rw-r--r--arch/arm/kernel/module.c1
-rw-r--r--arch/arm/kernel/traps.c4
-rw-r--r--arch/arm/lib/Makefile2
-rw-r--r--arch/arm/lib/sha1.S206
-rw-r--r--arch/arm/mach-aaec2000/Makefile2
-rw-r--r--arch/arm/mach-aaec2000/aaed2000.c50
-rw-r--r--arch/arm/mach-aaec2000/clock.c110
-rw-r--r--arch/arm/mach-aaec2000/clock.h23
-rw-r--r--arch/arm/mach-aaec2000/core.c135
-rw-r--r--arch/arm/mach-aaec2000/core.h11
-rw-r--r--arch/arm/mach-clps711x/Kconfig11
-rw-r--r--arch/arm/mach-clps711x/Makefile1
-rw-r--r--arch/arm/mach-clps711x/autcpu12.c12
-rw-r--r--arch/arm/mach-clps711x/cdb89712.c7
-rw-r--r--arch/arm/mach-clps711x/ceiva.c12
-rw-r--r--arch/arm/mach-clps711x/edb7211-mm.c30
-rw-r--r--arch/arm/mach-clps711x/mm.c8
-rw-r--r--arch/arm/mach-clps711x/mp1000-mach.c49
-rw-r--r--arch/arm/mach-clps711x/mp1000-mm.c47
-rw-r--r--arch/arm/mach-clps711x/mp1000-seprom.c195
-rw-r--r--arch/arm/mach-clps711x/p720t.c14
-rw-r--r--arch/arm/mach-clps7500/core.c25
-rw-r--r--arch/arm/mach-ebsa110/core.c38
-rw-r--r--arch/arm/mach-ebsa110/io.c1
-rw-r--r--arch/arm/mach-epxa10db/mm.c37
-rw-r--r--arch/arm/mach-footbridge/common.c57
-rw-r--r--arch/arm/mach-h720x/common.c7
-rw-r--r--arch/arm/mach-imx/generic.c8
-rw-r--r--arch/arm/mach-imx/mx1ads.c38
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c79
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c67
-rw-r--r--arch/arm/mach-iop3xx/iop321-setup.c18
-rw-r--r--arch/arm/mach-iop3xx/iop331-setup.c18
-rw-r--r--arch/arm/mach-iop3xx/iq31244-mm.c10
-rw-r--r--arch/arm/mach-iop3xx/iq80321-mm.c10
-rw-r--r--arch/arm/mach-ixp2000/core.c16
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x00.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x01.c2
-rw-r--r--arch/arm/mach-ixp4xx/common.c8
-rw-r--r--arch/arm/mach-lh7a40x/arch-kev7a400.c13
-rw-r--r--arch/arm/mach-lh7a40x/arch-lpd7a40x.c86
-rw-r--r--arch/arm/mach-omap1/board-innovator.c8
-rw-r--r--arch/arm/mach-omap1/board-perseus2.c8
-rw-r--r--arch/arm/mach-omap1/io.c46
-rw-r--r--arch/arm/mach-pxa/corgi_ssp.c24
-rw-r--r--arch/arm/mach-pxa/generic.c82
-rw-r--r--arch/arm/mach-pxa/idp.c21
-rw-r--r--arch/arm/mach-pxa/lubbock.c27
-rw-r--r--arch/arm/mach-pxa/mainstone.c32
-rw-r--r--arch/arm/mach-pxa/pxa25x.c2
-rw-r--r--arch/arm/mach-pxa/pxa27x.c2
-rw-r--r--arch/arm/mach-pxa/sleep.S7
-rw-r--r--arch/arm/mach-pxa/standby.S2
-rw-r--r--arch/arm/mach-rpc/riscpc.c19
-rw-r--r--arch/arm/mach-s3c2410/cpu.h2
-rw-r--r--arch/arm/mach-s3c2410/devs.c36
-rw-r--r--arch/arm/mach-s3c2410/gpio.c22
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c40
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c3
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2440.c70
-rw-r--r--arch/arm/mach-sa1100/assabet.c14
-rw-r--r--arch/arm/mach-sa1100/badge4.c20
-rw-r--r--arch/arm/mach-sa1100/cerf.c8
-rw-r--r--arch/arm/mach-sa1100/collie.c14
-rw-r--r--arch/arm/mach-sa1100/generic.c26
-rw-r--r--arch/arm/mach-sa1100/h3600.c20
-rw-r--r--arch/arm/mach-sa1100/hackkit.c8
-rw-r--r--arch/arm/mach-sa1100/jornada720.c20
-rw-r--r--arch/arm/mach-sa1100/lart.c14
-rw-r--r--arch/arm/mach-sa1100/neponset.c44
-rw-r--r--arch/arm/mach-sa1100/simpad.c16
-rw-r--r--arch/arm/mach-shark/core.c7
-rw-r--r--arch/arm/mach-versatile/core.c83
-rw-r--r--arch/arm/mm/consistent.c8
-rw-r--r--arch/arm/mm/init.c480
-rw-r--r--arch/arm/mm/ioremap.c1
-rw-r--r--arch/arm/mm/mm-armv.c172
-rw-r--r--arch/arm/oprofile/Makefile4
-rw-r--r--arch/arm/oprofile/common.c185
-rw-r--r--arch/arm/oprofile/init.c33
-rw-r--r--arch/arm/oprofile/op_arm_model.h4
-rw-r--r--arch/arm/plat-omap/sram.c6
-rw-r--r--arch/frv/mb93090-mb00/pci-dma-nommu.c2
-rw-r--r--arch/frv/mb93090-mb00/pci-dma.c2
-rw-r--r--arch/frv/mm/dma-alloc.c2
-rw-r--r--arch/i386/kernel/cpuid.c2
-rw-r--r--arch/i386/kernel/msr.c2
-rw-r--r--arch/i386/pci/fixup.c59
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c2
-rw-r--r--arch/ia64/hp/common/sba_iommu.c2
-rw-r--r--arch/ia64/lib/swiotlb.c2
-rw-r--r--arch/ia64/sn/kernel/xpc.h2
-rw-r--r--arch/ia64/sn/pci/pci_dma.c2
-rw-r--r--arch/mips/mm/dma-coherent.c4
-rw-r--r--arch/mips/mm/dma-ip27.c4
-rw-r--r--arch/mips/mm/dma-ip32.c4
-rw-r--r--arch/mips/mm/dma-noncoherent.c4
-rw-r--r--arch/parisc/Kconfig5
-rw-r--r--arch/parisc/Makefile13
-rw-r--r--arch/parisc/configs/712_defconfig456
-rw-r--r--arch/parisc/configs/a500_defconfig551
-rw-r--r--arch/parisc/configs/b180_defconfig309
-rw-r--r--arch/parisc/configs/c3000_defconfig676
-rw-r--r--arch/parisc/defconfig618
-rw-r--r--arch/parisc/kernel/cache.c10
-rw-r--r--arch/parisc/kernel/drivers.c273
-rw-r--r--arch/parisc/kernel/entry.S188
-rw-r--r--arch/parisc/kernel/firmware.c16
-rw-r--r--arch/parisc/kernel/head.S73
-rw-r--r--arch/parisc/kernel/ioctl32.c32
-rw-r--r--arch/parisc/kernel/pacache.S186
-rw-r--r--arch/parisc/kernel/pci-dma.c54
-rw-r--r--arch/parisc/kernel/pci.c3
-rw-r--r--arch/parisc/kernel/pdc_cons.c46
-rw-r--r--arch/parisc/kernel/perf.c12
-rw-r--r--arch/parisc/kernel/process.c34
-rw-r--r--arch/parisc/kernel/processor.c8
-rw-r--r--arch/parisc/kernel/real2.S36
-rw-r--r--arch/parisc/kernel/signal.c22
-rw-r--r--arch/parisc/kernel/smp.c2
-rw-r--r--arch/parisc/kernel/syscall.S37
-rw-r--r--arch/parisc/kernel/syscall_table.S10
-rw-r--r--arch/parisc/kernel/time.c26
-rw-r--r--arch/parisc/kernel/traps.c37
-rw-r--r--arch/parisc/kernel/unaligned.c16
-rw-r--r--arch/parisc/lib/fixup.S4
-rw-r--r--arch/parisc/lib/memcpy.c2
-rw-r--r--arch/ppc/8xx_io/cs4218.h2
-rw-r--r--arch/ppc/8xx_io/cs4218_tdm.c4
-rw-r--r--arch/ppc/kernel/dma-mapping.c4
-rw-r--r--arch/ppc/mm/pgtable.c4
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/mach.c2
-rw-r--r--arch/sh/cchips/voyagergx/consistent.c2
-rw-r--r--arch/sh/drivers/pci/dma-dreamcast.c2
-rw-r--r--arch/sh/mm/consistent.c2
-rw-r--r--arch/sparc64/solaris/socksys.c2
-rw-r--r--arch/sparc64/solaris/timod.c2
-rw-r--r--arch/um/kernel/mem.c2
-rw-r--r--arch/um/kernel/process_kern.c2
-rw-r--r--arch/x86_64/kernel/pci-gart.c4
-rw-r--r--arch/x86_64/kernel/pci-nommu.c2
-rw-r--r--arch/xtensa/kernel/pci-dma.c2
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/base/attribute_container.c2
-rw-r--r--drivers/base/base.h12
-rw-r--r--drivers/base/class.c150
-rw-r--r--drivers/base/core.c21
-rw-r--r--drivers/base/cpu.c1
-rw-r--r--drivers/base/driver.c3
-rw-r--r--drivers/base/firmware.c3
-rw-r--r--drivers/base/init.c10
-rw-r--r--drivers/base/platform.c22
-rw-r--r--drivers/base/power/main.c26
-rw-r--r--drivers/base/power/power.h13
-rw-r--r--drivers/base/power/runtime.c1
-rw-r--r--drivers/base/power/sysfs.c73
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoechr.c2
-rw-r--r--drivers/block/aoe/aoecmd.c15
-rw-r--r--drivers/block/as-iosched.c327
-rw-r--r--drivers/block/cfq-iosched.c372
-rw-r--r--drivers/block/deadline-iosched.c125
-rw-r--r--drivers/block/elevator.c345
-rw-r--r--drivers/block/genhd.c25
-rw-r--r--drivers/block/ll_rw_blk.c193
-rw-r--r--drivers/block/loop.c2
-rw-r--r--drivers/block/noop-iosched.c48
-rw-r--r--drivers/block/paride/pg.c2
-rw-r--r--drivers/block/paride/pt.c4
-rw-r--r--drivers/block/rd.c2
-rw-r--r--drivers/block/sx8.c51
-rw-r--r--drivers/block/ub.c4
-rw-r--r--drivers/bluetooth/Kconfig8
-rw-r--r--drivers/bluetooth/bpa10x.c3
-rw-r--r--drivers/bluetooth/hci_bcsp.c160
-rw-r--r--drivers/bluetooth/hci_bcsp.h70
-rw-r--r--drivers/bluetooth/hci_h4.c101
-rw-r--r--drivers/bluetooth/hci_h4.h44
-rw-r--r--drivers/bluetooth/hci_ldisc.c134
-rw-r--r--drivers/bluetooth/hci_uart.h84
-rw-r--r--drivers/char/dsp56k.c2
-rw-r--r--drivers/char/ftape/zftape/zftape-init.c12
-rw-r--r--drivers/char/ip2main.c10
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c2
-rw-r--r--drivers/char/istallion.c3
-rw-r--r--drivers/char/lp.c2
-rw-r--r--drivers/char/mem.c3
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/n_tty.c2
-rw-r--r--drivers/char/nvram.c110
-rw-r--r--drivers/char/ppdev.c2
-rw-r--r--drivers/char/raw.c4
-rw-r--r--drivers/char/s3c2410-rtc.c20
-rw-r--r--drivers/char/snsc.c2
-rw-r--r--drivers/char/sonypi.c106
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/tipar.c2
-rw-r--r--drivers/char/tty_io.c10
-rw-r--r--drivers/char/vc_screen.c10
-rw-r--r--drivers/char/viotape.c4
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c30
-rw-r--r--drivers/hwmon/adm1021.c5
-rw-r--r--drivers/hwmon/adm1025.c3
-rw-r--r--drivers/hwmon/adm1026.c22
-rw-r--r--drivers/hwmon/adm1031.c3
-rw-r--r--drivers/hwmon/adm9240.c429
-rw-r--r--drivers/hwmon/asb100.c11
-rw-r--r--drivers/hwmon/atxp1.c5
-rw-r--r--drivers/hwmon/ds1621.c9
-rw-r--r--drivers/hwmon/fscher.c3
-rw-r--r--drivers/hwmon/fscpos.c5
-rw-r--r--drivers/hwmon/gl518sm.c3
-rw-r--r--drivers/hwmon/gl520sm.c3
-rw-r--r--drivers/hwmon/hdaps.c6
-rw-r--r--drivers/hwmon/hwmon.c2
-rw-r--r--drivers/hwmon/it87.c56
-rw-r--r--drivers/hwmon/lm63.c3
-rw-r--r--drivers/hwmon/lm75.c3
-rw-r--r--drivers/hwmon/lm77.c3
-rw-r--r--drivers/hwmon/lm78.c6
-rw-r--r--drivers/hwmon/lm80.c5
-rw-r--r--drivers/hwmon/lm83.c3
-rw-r--r--drivers/hwmon/lm85.c15
-rw-r--r--drivers/hwmon/lm87.c3
-rw-r--r--drivers/hwmon/lm90.c181
-rw-r--r--drivers/hwmon/lm92.c3
-rw-r--r--drivers/hwmon/max1619.c3
-rw-r--r--drivers/hwmon/pc87360.c3
-rw-r--r--drivers/hwmon/sis5595.c3
-rw-r--r--drivers/hwmon/smsc47b397.c10
-rw-r--r--drivers/hwmon/smsc47m1.c10
-rw-r--r--drivers/hwmon/via686a.c28
-rw-r--r--drivers/hwmon/w83627ehf.c16
-rw-r--r--drivers/hwmon/w83627hf.c32
-rw-r--r--drivers/hwmon/w83781d.c11
-rw-r--r--drivers/hwmon/w83792d.c7
-rw-r--r--drivers/hwmon/w83l785ts.c42
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c2
-rw-r--r--drivers/i2c/busses/Kconfig3
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c7
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c7
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c10
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756.c8
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c16
-rw-r--r--drivers/i2c/busses/i2c-elektor.c138
-rw-r--r--drivers/i2c/busses/i2c-hydra.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c61
-rw-r--r--drivers/i2c/busses/i2c-i810.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c3
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c9
-rw-r--r--drivers/i2c/busses/i2c-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c8
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c8
-rw-r--r--drivers/i2c/busses/i2c-keywest.c5
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c6
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c16
-rw-r--r--drivers/i2c/busses/i2c-parport.c11
-rw-r--r--drivers/i2c/busses/i2c-piix4.c13
-rw-r--r--drivers/i2c/busses/i2c-pmac-smu.c3
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c10
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c10
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c10
-rw-r--r--drivers/i2c/busses/i2c-sis630.c9
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c8
-rw-r--r--drivers/i2c/busses/i2c-via.c7
-rw-r--r--drivers/i2c/busses/i2c-viapro.c271
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c1
-rw-r--r--drivers/i2c/busses/scx200_acb.c3
-rw-r--r--drivers/i2c/chips/Kconfig9
-rw-r--r--drivers/i2c/chips/Makefile1
-rw-r--r--drivers/i2c/chips/ds1337.c3
-rw-r--r--drivers/i2c/chips/ds1374.c7
-rw-r--r--drivers/i2c/chips/eeprom.c9
-rw-r--r--drivers/i2c/chips/isp1301_omap.c1
-rw-r--r--drivers/i2c/chips/m41t00.c4
-rw-r--r--drivers/i2c/chips/max6875.c6
-rw-r--r--drivers/i2c/chips/pca9539.c3
-rw-r--r--drivers/i2c/chips/pcf8574.c5
-rw-r--r--drivers/i2c/chips/pcf8591.c5
-rw-r--r--drivers/i2c/chips/rtc8564.c5
-rw-r--r--drivers/i2c/chips/tps65010.c3
-rw-r--r--drivers/i2c/chips/x1205.c698
-rw-r--r--drivers/i2c/i2c-core.c198
-rw-r--r--drivers/i2c/i2c-dev.c17
-rw-r--r--drivers/ide/ide-tape.c38
-rw-r--r--drivers/ieee1394/dv1394.c2
-rw-r--r--drivers/ieee1394/eth1394.c2
-rw-r--r--drivers/ieee1394/nodemgr.c4
-rw-r--r--drivers/ieee1394/raw1394.c2
-rw-r--r--drivers/ieee1394/video1394.c2
-rw-r--r--drivers/infiniband/core/agent.c293
-rw-r--r--drivers/infiniband/core/agent.h13
-rw-r--r--drivers/infiniband/core/agent_priv.h62
-rw-r--r--drivers/infiniband/core/cm.c217
-rw-r--r--drivers/infiniband/core/cm_msgs.h1
-rw-r--r--drivers/infiniband/core/device.c12
-rw-r--r--drivers/infiniband/core/mad.c335
-rw-r--r--drivers/infiniband/core/mad_priv.h8
-rw-r--r--drivers/infiniband/core/mad_rmpp.c114
-rw-r--r--drivers/infiniband/core/mad_rmpp.h2
-rw-r--r--drivers/infiniband/core/sa_query.c270
-rw-r--r--drivers/infiniband/core/smi.h2
-rw-r--r--drivers/infiniband/core/sysfs.c16
-rw-r--r--drivers/infiniband/core/ucm.c267
-rw-r--r--drivers/infiniband/core/ucm.h83
-rw-r--r--drivers/infiniband/core/user_mad.c399
-rw-r--r--drivers/infiniband/core/uverbs.h62
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c858
-rw-r--r--drivers/infiniband/core/uverbs_main.c503
-rw-r--r--drivers/infiniband/core/verbs.c18
-rw-r--r--drivers/infiniband/hw/mthca/Makefile3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c153
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c13
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h22
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c21
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c72
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c11
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c11
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c49
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c16
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c43
-rw-r--r--drivers/infiniband/hw/mthca/mthca_user.h6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h23
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c120
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c15
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c9
-rw-r--r--drivers/input/evdev.c16
-rw-r--r--drivers/input/input.c445
-rw-r--r--drivers/input/joydev.c16
-rw-r--r--drivers/input/joystick/adi.c93
-rw-r--r--drivers/input/joystick/amijoy.c85
-rw-r--r--drivers/input/joystick/analog.c96
-rw-r--r--drivers/input/joystick/cobra.c66
-rw-r--r--drivers/input/joystick/db9.c292
-rw-r--r--drivers/input/joystick/gamecon.c396
-rw-r--r--drivers/input/joystick/gf2k.c69
-rw-r--r--drivers/input/joystick/grip.c77
-rw-r--r--drivers/input/joystick/grip_mp.c149
-rw-r--r--drivers/input/joystick/guillemot.c51
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c106
-rw-r--r--drivers/input/joystick/iforce/iforce-packets.c5
-rw-r--r--drivers/input/joystick/iforce/iforce-serio.c10
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c22
-rw-r--r--drivers/input/joystick/iforce/iforce.h2
-rw-r--r--drivers/input/joystick/interact.c53
-rw-r--r--drivers/input/joystick/magellan.c71
-rw-r--r--drivers/input/joystick/sidewinder.c70
-rw-r--r--drivers/input/joystick/spaceball.c82
-rw-r--r--drivers/input/joystick/spaceorb.c78
-rw-r--r--drivers/input/joystick/stinger.c75
-rw-r--r--drivers/input/joystick/tmdc.c324
-rw-r--r--drivers/input/joystick/turbografx.c215
-rw-r--r--drivers/input/joystick/twidjoy.c120
-rw-r--r--drivers/input/joystick/warrior.c83
-rw-r--r--drivers/input/keyboard/amikbd.c59
-rw-r--r--drivers/input/keyboard/atkbd.c188
-rw-r--r--drivers/input/keyboard/corgikbd.c96
-rw-r--r--drivers/input/keyboard/hil_kbd.c28
-rw-r--r--drivers/input/keyboard/hilkbd.c8
-rw-r--r--drivers/input/keyboard/lkkbd.c128
-rw-r--r--drivers/input/keyboard/maple_keyb.c72
-rw-r--r--drivers/input/keyboard/newtonkbd.c83
-rw-r--r--drivers/input/keyboard/spitzkbd.c119
-rw-r--r--drivers/input/keyboard/sunkbd.c117
-rw-r--r--drivers/input/keyboard/xtkbd.c80
-rw-r--r--drivers/input/misc/m68kspkr.c36
-rw-r--r--drivers/input/misc/pcspkr.c30
-rw-r--r--drivers/input/misc/sparcspkr.c47
-rw-r--r--drivers/input/mouse/alps.c63
-rw-r--r--drivers/input/mouse/alps.h2
-rw-r--r--drivers/input/mouse/amimouse.c49
-rw-r--r--drivers/input/mouse/hil_ptr.c33
-rw-r--r--drivers/input/mouse/inport.c96
-rw-r--r--drivers/input/mouse/lifebook.c16
-rw-r--r--drivers/input/mouse/logibm.c88
-rw-r--r--drivers/input/mouse/logips2pp.c20
-rw-r--r--drivers/input/mouse/maplemouse.c10
-rw-r--r--drivers/input/mouse/pc110pad.c64
-rw-r--r--drivers/input/mouse/psmouse-base.c99
-rw-r--r--drivers/input/mouse/psmouse.h2
-rw-r--r--drivers/input/mouse/rpcmouse.c43
-rw-r--r--drivers/input/mouse/sermouse.c82
-rw-r--r--drivers/input/mouse/synaptics.c6
-rw-r--r--drivers/input/mouse/vsxxxaa.c84
-rw-r--r--drivers/input/mousedev.c25
-rw-r--r--drivers/input/serio/gscps2.c17
-rw-r--r--drivers/input/serio/hil_mlc.c14
-rw-r--r--drivers/input/serio/hp_sdc.c8
-rw-r--r--drivers/input/serio/i8042.c13
-rw-r--r--drivers/input/touchscreen/corgi_ts.c127
-rw-r--r--drivers/input/touchscreen/elo.c89
-rw-r--r--drivers/input/touchscreen/gunze.c66
-rw-r--r--drivers/input/touchscreen/h3600_ts_input.c149
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c50
-rw-r--r--drivers/input/touchscreen/mk712.c80
-rw-r--r--drivers/input/touchscreen/mtouch.c64
-rw-r--r--drivers/input/tsdev.c19
-rw-r--r--drivers/isdn/capi/capi.c2
-rw-r--r--drivers/macintosh/adb.c2
-rw-r--r--drivers/macintosh/adbhid.c222
-rw-r--r--drivers/macintosh/mac_hid.c40
-rw-r--r--drivers/md/bitmap.c2
-rw-r--r--drivers/md/dm-crypt.c2
-rw-r--r--drivers/media/common/ir-common.c1
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c108
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c50
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h3
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c37
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c24
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c51
-rw-r--r--drivers/media/video/bttvp.h2
-rw-r--r--drivers/media/video/cx88/cx88-input.c58
-rw-r--r--drivers/media/video/ir-kbd-gpio.c52
-rw-r--r--drivers/media/video/ir-kbd-i2c.c33
-rw-r--r--drivers/media/video/msp3400.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c39
-rw-r--r--drivers/media/video/saa7134/saa7134.h2
-rw-r--r--drivers/media/video/tda9887.c4
-rw-r--r--drivers/media/video/tuner-core.c4
-rw-r--r--drivers/message/i2o/core.h3
-rw-r--r--drivers/message/i2o/device.c272
-rw-r--r--drivers/message/i2o/driver.c3
-rw-r--r--drivers/message/i2o/iop.c32
-rw-r--r--drivers/mfd/mcp-sa11x0.c20
-rw-r--r--drivers/mfd/ucb1x00-ts.c43
-rw-r--r--drivers/mmc/mmci.c1
-rw-r--r--drivers/mmc/pxamci.c8
-rw-r--r--drivers/mmc/wbsd.c123
-rw-r--r--drivers/mtd/maps/sa1100-flash.c9
-rw-r--r--drivers/mtd/mtdchar.c4
-rw-r--r--drivers/net/8139cp.c5
-rw-r--r--drivers/net/8139too.c5
-rw-r--r--drivers/net/Kconfig25
-rw-r--r--drivers/net/Makefile4
-rw-r--r--drivers/net/arm/am79c961a.c1
-rw-r--r--drivers/net/au1000_eth.c13
-rw-r--r--drivers/net/b44.c136
-rw-r--r--drivers/net/b44.h2
-rw-r--r--drivers/net/bonding/bond_main.c57
-rw-r--r--drivers/net/cassini.c4
-rw-r--r--drivers/net/cs89x0.c14
-rw-r--r--drivers/net/cs89x0.h2
-rw-r--r--drivers/net/declance.c37
-rw-r--r--drivers/net/dm9000.c8
-rw-r--r--drivers/net/e100.c4
-rw-r--r--drivers/net/e1000/e1000.h74
-rw-r--r--drivers/net/e1000/e1000_ethtool.c95
-rw-r--r--drivers/net/e1000/e1000_hw.c220
-rw-r--r--drivers/net/e1000/e1000_hw.h96
-rw-r--r--drivers/net/e1000/e1000_main.c1078
-rw-r--r--drivers/net/e1000/e1000_param.c10
-rw-r--r--drivers/net/epic100.c4
-rw-r--r--drivers/net/forcedeth.c310
-rw-r--r--drivers/net/gianfar.c412
-rw-r--r--drivers/net/gianfar.h30
-rw-r--r--drivers/net/gianfar_ethtool.c100
-rw-r--r--drivers/net/gianfar_mii.c219
-rw-r--r--drivers/net/gianfar_mii.h45
-rw-r--r--drivers/net/gianfar_phy.c661
-rw-r--r--drivers/net/gianfar_phy.h213
-rw-r--r--drivers/net/hamradio/Kconfig1
-rw-r--r--drivers/net/hamradio/bpqether.c9
-rw-r--r--drivers/net/hamradio/mkiss.c182
-rw-r--r--drivers/net/hamradio/mkiss.h62
-rw-r--r--drivers/net/hp100.c48
-rw-r--r--drivers/net/irda/Kconfig10
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/pxaficp_ir.c871
-rw-r--r--drivers/net/irda/sa1100_ir.c8
-rw-r--r--drivers/net/irda/smsc-ircc2.c12
-rw-r--r--drivers/net/irda/stir4200.c7
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c8
-rw-r--r--drivers/net/ixgb/ixgb_main.c3
-rw-r--r--drivers/net/lance.c4
-rw-r--r--drivers/net/lasi_82596.c30
-rw-r--r--drivers/net/lne390.c2
-rw-r--r--drivers/net/mii.c15
-rw-r--r--drivers/net/mipsnet.c371
-rw-r--r--drivers/net/mipsnet.h127
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/myri_sbus.h2
-rw-r--r--drivers/net/ne.c15
-rw-r--r--drivers/net/ne2k-pci.c2
-rw-r--r--drivers/net/ns83820.c3
-rw-r--r--drivers/net/pcnet32.c278
-rw-r--r--drivers/net/phy/Kconfig8
-rw-r--r--drivers/net/phy/mdio_bus.c20
-rw-r--r--drivers/net/phy/phy.c8
-rw-r--r--drivers/net/phy/phy_device.c3
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/rionet.c574
-rw-r--r--drivers/net/s2io-regs.h11
-rw-r--r--drivers/net/s2io.c791
-rw-r--r--drivers/net/s2io.h50
-rw-r--r--drivers/net/sb1250-mac.c1384
-rw-r--r--drivers/net/sgiseeq.c37
-rw-r--r--drivers/net/skge.c2
-rw-r--r--drivers/net/smc91x.c8
-rw-r--r--drivers/net/sunbmac.c3
-rw-r--r--drivers/net/sunbmac.h2
-rw-r--r--drivers/net/sundance.c49
-rw-r--r--drivers/net/tokenring/ibmtr.c9
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/tokenring/tms380tr.c3
-rw-r--r--drivers/net/tulip/de2104x.c5
-rw-r--r--drivers/net/typhoon.c7
-rw-r--r--drivers/net/via-rhine.c38
-rw-r--r--drivers/net/wan/cosa.c8
-rw-r--r--drivers/net/wan/cycx_drv.c7
-rw-r--r--drivers/net/wan/cycx_main.c2
-rw-r--r--drivers/net/wan/cycx_x25.c5
-rw-r--r--drivers/net/wan/dscc4.c23
-rw-r--r--drivers/net/wan/farsync.c27
-rw-r--r--drivers/net/wan/hdlc_fr.c2
-rw-r--r--drivers/net/wan/lmc/lmc_debug.c10
-rw-r--r--drivers/net/wan/lmc/lmc_media.c8
-rw-r--r--drivers/net/wan/pc300.h16
-rw-r--r--drivers/net/wan/pc300_drv.c87
-rw-r--r--drivers/net/wan/pc300_tty.c18
-rw-r--r--drivers/net/wan/sdla.c20
-rw-r--r--drivers/net/wan/sdla_fr.c4
-rw-r--r--drivers/net/wan/sdla_x25.c8
-rw-r--r--drivers/net/wan/sdladrv.c16
-rw-r--r--drivers/net/wan/syncppp.c10
-rw-r--r--drivers/net/wireless/airo.c37
-rw-r--r--drivers/net/wireless/airport.c19
-rw-r--r--drivers/net/wireless/atmel.c24
-rw-r--r--drivers/net/wireless/hermes.c11
-rw-r--r--drivers/net/wireless/hermes.h111
-rw-r--r--drivers/net/wireless/hostap/hostap.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c43
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c28
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c80
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.h6
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c50
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c22
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c23
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c21
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c11
-rw-r--r--drivers/net/wireless/hostap/hostap_wlan.h2
-rw-r--r--drivers/net/wireless/ipw2100.c24
-rw-r--r--drivers/net/wireless/ipw2100.h2
-rw-r--r--drivers/net/wireless/ipw2200.c27
-rw-r--r--drivers/net/wireless/ipw2200.h4
-rw-r--r--drivers/net/wireless/netwave_cs.c185
-rw-r--r--drivers/net/wireless/orinoco.c235
-rw-r--r--drivers/net/wireless/orinoco.h16
-rw-r--r--drivers/net/wireless/orinoco_cs.c110
-rw-r--r--drivers/net/wireless/orinoco_nortel.c20
-rw-r--r--drivers/net/wireless/orinoco_pci.c18
-rw-r--r--drivers/net/wireless/orinoco_plx.c18
-rw-r--r--drivers/net/wireless/orinoco_tmd.c18
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c10
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c10
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.h2
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c5
-rw-r--r--drivers/net/wireless/ray_cs.c46
-rw-r--r--drivers/net/wireless/spectrum_cs.c79
-rw-r--r--drivers/net/wireless/wavelan.c8
-rw-r--r--drivers/net/wireless/wavelan.p.h4
-rw-r--r--drivers/net/wireless/wavelan_cs.c8
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h4
-rw-r--r--drivers/net/wireless/wl3501.h2
-rw-r--r--drivers/parisc/asp.c6
-rw-r--r--drivers/parisc/ccio-dma.c144
-rw-r--r--drivers/parisc/ccio-rm-dma.c2
-rw-r--r--drivers/parisc/dino.c42
-rw-r--r--drivers/parisc/eisa.c4
-rw-r--r--drivers/parisc/gsc.c11
-rw-r--r--drivers/parisc/hppb.c10
-rw-r--r--drivers/parisc/iosapic.c2
-rw-r--r--drivers/parisc/lasi.c4
-rw-r--r--drivers/parisc/lba_pci.c14
-rw-r--r--drivers/parisc/led.c225
-rw-r--r--drivers/parisc/pdc_stable.c2
-rw-r--r--drivers/parisc/sba_iommu.c166
-rw-r--r--drivers/parisc/superio.c3
-rw-r--r--drivers/parisc/wax.c2
-rw-r--r--drivers/parport/parport_gsc.c5
-rw-r--r--drivers/pci/access.c89
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c8
-rw-r--r--drivers/pci/hotplug/cpcihp_zt5550.c25
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c24
-rw-r--r--drivers/pci/hotplug/rpaphp.h3
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c5
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c11
-rw-r--r--drivers/pci/hotplug/shpchp.h122
-rw-r--r--drivers/pci/hotplug/shpchp_core.c111
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c2034
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c175
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c861
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c119
-rw-r--r--drivers/pci/hotplug/shpchprm.h55
-rw-r--r--drivers/pci/hotplug/shpchprm_acpi.c1649
-rw-r--r--drivers/pci/hotplug/shpchprm_legacy.c395
-rw-r--r--drivers/pci/hotplug/shpchprm_legacy.h113
-rw-r--r--drivers/pci/hotplug/shpchprm_nonacpi.c389
-rw-r--r--drivers/pci/hotplug/shpchprm_nonacpi.h56
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--drivers/pci/pci-driver.c17
-rw-r--r--drivers/pci/pci-sysfs.c20
-rw-r--r--drivers/pci/pci.c21
-rw-r--r--drivers/pci/pci.h7
-rw-r--r--drivers/pci/pcie/portdrv_core.c4
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pci/proc.c28
-rw-r--r--drivers/pci/quirks.c290
-rw-r--r--drivers/pci/syscall.c14
-rw-r--r--drivers/pcmcia/au1000_generic.c21
-rw-r--r--drivers/pcmcia/ds.c6
-rw-r--r--drivers/pcmcia/hd64465_ss.c20
-rw-r--r--drivers/pcmcia/i82365.c20
-rw-r--r--drivers/pcmcia/m32r_cfc.c21
-rw-r--r--drivers/pcmcia/m32r_pcc.c21
-rw-r--r--drivers/pcmcia/omap_cf.c18
-rw-r--r--drivers/pcmcia/pxa2xx_base.c26
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c6
-rw-r--r--drivers/pcmcia/sa1100_generic.c20
-rw-r--r--drivers/pcmcia/sa1111_generic.c2
-rw-r--r--drivers/pcmcia/socket_sysfs.c6
-rw-r--r--drivers/pcmcia/tcic.c20
-rw-r--r--drivers/pcmcia/vrc4171_card.c24
-rw-r--r--drivers/pcmcia/yenta_socket.c42
-rw-r--r--drivers/s390/char/tape_class.c1
-rw-r--r--drivers/s390/char/vmlogrdr.c1
-rw-r--r--drivers/s390/net/fsm.c2
-rw-r--r--drivers/s390/net/fsm.h2
-rw-r--r--drivers/s390/net/qeth.h45
-rw-r--r--drivers/s390/net/qeth_fs.h12
-rw-r--r--drivers/s390/net/qeth_main.c419
-rw-r--r--drivers/s390/net/qeth_mpc.c6
-rw-r--r--drivers/s390/net/qeth_mpc.h15
-rw-r--r--drivers/s390/net/qeth_sys.c28
-rw-r--r--drivers/scsi/Kconfig22
-rw-r--r--drivers/scsi/Makefile2
-rw-r--r--drivers/scsi/ahci.c41
-rw-r--r--drivers/scsi/ata_piix.c4
-rw-r--r--drivers/scsi/ch.c2
-rw-r--r--drivers/scsi/eata.c2
-rw-r--r--drivers/scsi/hosts.c3
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/lasi700.c6
-rw-r--r--drivers/scsi/libata-core.c874
-rw-r--r--drivers/scsi/libata-scsi.c730
-rw-r--r--drivers/scsi/libata.h19
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c10
-rw-r--r--drivers/scsi/osst.c8
-rw-r--r--drivers/scsi/pdc_adma.c739
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_rscn.c2
-rw-r--r--drivers/scsi/sata_mv.c1145
-rw-r--r--drivers/scsi/sata_nv.c8
-rw-r--r--drivers/scsi/sata_promise.c26
-rw-r--r--drivers/scsi/sata_qstor.c8
-rw-r--r--drivers/scsi/sata_sil.c6
-rw-r--r--drivers/scsi/sata_sil24.c875
-rw-r--r--drivers/scsi/sata_sis.c4
-rw-r--r--drivers/scsi/sata_svw.c4
-rw-r--r--drivers/scsi/sata_sx4.c29
-rw-r--r--drivers/scsi/sata_uli.c4
-rw-r--r--drivers/scsi/sata_via.c4
-rw-r--r--drivers/scsi/sata_vsc.c14
-rw-r--r--drivers/scsi/scsi.c8
-rw-r--r--drivers/scsi/scsi_ioctl.c3
-rw-r--r--drivers/scsi/scsi_lib.c2
-rw-r--r--drivers/scsi/sg.c12
-rw-r--r--drivers/scsi/st.c8
-rw-r--r--drivers/scsi/zalon.c4
-rw-r--r--drivers/serial/8250.c10
-rw-r--r--drivers/serial/8250_gsc.c6
-rw-r--r--drivers/serial/amba-pl010.c1
-rw-r--r--drivers/serial/amba-pl011.c1
-rw-r--r--drivers/serial/clps711x.c9
-rw-r--r--drivers/serial/imx.c8
-rw-r--r--drivers/serial/mpc52xx_uart.c8
-rw-r--r--drivers/serial/mux.c11
-rw-r--r--drivers/serial/pxa.c29
-rw-r--r--drivers/serial/s3c2410.c9
-rw-r--r--drivers/serial/sa1100.c8
-rw-r--r--drivers/serial/vr41xx_siu.c10
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/class/Kconfig23
-rw-r--r--drivers/usb/class/Makefile1
-rw-r--r--drivers/usb/class/bluetty.c1279
-rw-r--r--drivers/usb/class/cdc-acm.c5
-rw-r--r--drivers/usb/class/usblp.c3
-rw-r--r--drivers/usb/core/Kconfig11
-rw-r--r--drivers/usb/core/Makefile2
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/config.c22
-rw-r--r--drivers/usb/core/devio.c192
-rw-r--r--drivers/usb/core/file.c23
-rw-r--r--drivers/usb/core/hcd-pci.c106
-rw-r--r--drivers/usb/core/hcd.c156
-rw-r--r--drivers/usb/core/hcd.h77
-rw-r--r--drivers/usb/core/hub.c426
-rw-r--r--drivers/usb/core/hub.h2
-rw-r--r--drivers/usb/core/inode.c44
-rw-r--r--drivers/usb/core/message.c90
-rw-r--r--drivers/usb/core/notify.c120
-rw-r--r--drivers/usb/core/sysfs.c319
-rw-r--r--drivers/usb/core/urb.c7
-rw-r--r--drivers/usb/core/usb.c167
-rw-r--r--drivers/usb/core/usb.h33
-rw-r--r--drivers/usb/gadget/dummy_hcd.c54
-rw-r--r--drivers/usb/gadget/ether.c23
-rw-r--r--drivers/usb/gadget/file_storage.c52
-rw-r--r--drivers/usb/gadget/goku_udc.c7
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c13
-rw-r--r--drivers/usb/gadget/net2280.c7
-rw-r--r--drivers/usb/gadget/omap_udc.c28
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c26
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.h8
-rw-r--r--drivers/usb/gadget/serial.c16
-rw-r--r--drivers/usb/gadget/zero.c9
-rw-r--r--drivers/usb/host/Makefile5
-rw-r--r--drivers/usb/host/ehci-hcd.c545
-rw-r--r--drivers/usb/host/ehci-hub.c8
-rw-r--r--drivers/usb/host/ehci-mem.c6
-rw-r--r--drivers/usb/host/ehci-pci.c415
-rw-r--r--drivers/usb/host/ehci-q.c6
-rw-r--r--drivers/usb/host/ehci-sched.c14
-rw-r--r--drivers/usb/host/ehci.h1
-rw-r--r--drivers/usb/host/isp116x-hcd.c57
-rw-r--r--drivers/usb/host/isp116x.h1
-rw-r--r--drivers/usb/host/ohci-au1xxx.c6
-rw-r--r--drivers/usb/host/ohci-dbg.c4
-rw-r--r--drivers/usb/host/ohci-hcd.c6
-rw-r--r--drivers/usb/host/ohci-hub.c52
-rw-r--r--drivers/usb/host/ohci-lh7a404.c6
-rw-r--r--drivers/usb/host/ohci-mem.c5
-rw-r--r--drivers/usb/host/ohci-omap.c55
-rw-r--r--drivers/usb/host/ohci-pci.c47
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c9
-rw-r--r--drivers/usb/host/ohci-pxa27x.c11
-rw-r--r--drivers/usb/host/ohci-s3c2410.c9
-rw-r--r--drivers/usb/host/ohci-sa1111.c7
-rw-r--r--drivers/usb/host/ohci.h1
-rw-r--r--drivers/usb/host/pci-quirks.c296
-rw-r--r--drivers/usb/host/sl811-hcd.c29
-rw-r--r--drivers/usb/host/uhci-debug.c5
-rw-r--r--drivers/usb/host/uhci-hcd.c178
-rw-r--r--drivers/usb/host/uhci-hcd.h98
-rw-r--r--drivers/usb/host/uhci-q.c64
-rw-r--r--drivers/usb/image/mdc800.c33
-rw-r--r--drivers/usb/image/microtek.c3
-rw-r--r--drivers/usb/input/acecad.c76
-rw-r--r--drivers/usb/input/aiptek.c209
-rw-r--r--drivers/usb/input/appletouch.c130
-rw-r--r--drivers/usb/input/ati_remote.c173
-rw-r--r--drivers/usb/input/hid-core.c56
-rw-r--r--drivers/usb/input/hid-input.c56
-rw-r--r--drivers/usb/input/hid-lgff.c17
-rw-r--r--drivers/usb/input/hid-tmff.c11
-rw-r--r--drivers/usb/input/hid.h2
-rw-r--r--drivers/usb/input/hiddev.c3
-rw-r--r--drivers/usb/input/itmtouch.c70
-rw-r--r--drivers/usb/input/kbtab.c82
-rw-r--r--drivers/usb/input/keyspan_remote.c210
-rw-r--r--drivers/usb/input/map_to_7segment.h2
-rw-r--r--drivers/usb/input/mtouchusb.c111
-rw-r--r--drivers/usb/input/pid.c12
-rw-r--r--drivers/usb/input/powermate.c136
-rw-r--r--drivers/usb/input/touchkitusb.c118
-rw-r--r--drivers/usb/input/usbkbd.c105
-rw-r--r--drivers/usb/input/usbmouse.c93
-rw-r--r--drivers/usb/input/wacom.c142
-rw-r--r--drivers/usb/input/xpad.c95
-rw-r--r--drivers/usb/input/yealink.c66
-rw-r--r--drivers/usb/media/dabusb.c3
-rw-r--r--drivers/usb/media/konicawc.c89
-rw-r--r--drivers/usb/misc/auerswald.c3
-rw-r--r--drivers/usb/misc/idmouse.c5
-rw-r--r--drivers/usb/misc/legousbtower.c5
-rw-r--r--drivers/usb/misc/rio500.c3
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c7
-rw-r--r--drivers/usb/misc/usblcd.c9
-rw-r--r--drivers/usb/misc/usbtest.c11
-rw-r--r--drivers/usb/misc/uss720.c6
-rw-r--r--drivers/usb/mon/mon_main.c23
-rw-r--r--drivers/usb/net/Kconfig2
-rw-r--r--drivers/usb/net/asix.c2
-rw-r--r--drivers/usb/net/gl620a.c2
-rw-r--r--drivers/usb/net/kaweth.c8
-rw-r--r--drivers/usb/net/net1080.c2
-rw-r--r--drivers/usb/net/pegasus.c2
-rw-r--r--drivers/usb/net/pegasus.h2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/net/rtl8150.c1
-rw-r--r--drivers/usb/net/usbnet.c4
-rw-r--r--drivers/usb/net/usbnet.h2
-rw-r--r--drivers/usb/net/zaurus.c2
-rw-r--r--drivers/usb/net/zd1201.c2
-rw-r--r--drivers/usb/serial/ChangeLog.old730
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/airprime.c8
-rw-r--r--drivers/usb/serial/belkin_sa.c10
-rw-r--r--drivers/usb/serial/bus.c37
-rw-r--r--drivers/usb/serial/cp2101.c10
-rw-r--r--drivers/usb/serial/cyberjack.c10
-rw-r--r--drivers/usb/serial/cypress_m8.c20
-rw-r--r--drivers/usb/serial/digi_acceleport.c20
-rw-r--r--drivers/usb/serial/empeg.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c16
-rw-r--r--drivers/usb/serial/ftdi_sio.h16
-rw-r--r--drivers/usb/serial/garmin_gps.c15
-rw-r--r--drivers/usb/serial/generic.c9
-rw-r--r--drivers/usb/serial/hp4x.c10
-rw-r--r--drivers/usb/serial/io_edgeport.c219
-rw-r--r--drivers/usb/serial/io_tables.h30
-rw-r--r--drivers/usb/serial/io_ti.c20
-rw-r--r--drivers/usb/serial/ipaq.c247
-rw-r--r--drivers/usb/serial/ipw.c10
-rw-r--r--drivers/usb/serial/ir-usb.c9
-rw-r--r--drivers/usb/serial/keyspan.h40
-rw-r--r--drivers/usb/serial/keyspan_pda.c30
-rw-r--r--drivers/usb/serial/kl5kusb105.c10
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c10
-rw-r--r--drivers/usb/serial/nokia_dku2.c142
-rw-r--r--drivers/usb/serial/omninet.c10
-rw-r--r--drivers/usb/serial/option.c10
-rw-r--r--drivers/usb/serial/pl2303.c35
-rw-r--r--drivers/usb/serial/safe_serial.c10
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c18
-rw-r--r--drivers/usb/serial/usb-serial.c378
-rw-r--r--drivers/usb/serial/usb-serial.h81
-rw-r--r--drivers/usb/serial/visor.c170
-rw-r--r--drivers/usb/serial/whiteheat.c42
-rw-r--r--drivers/usb/storage/Kconfig3
-rw-r--r--drivers/usb/storage/onetouch.c99
-rw-r--r--drivers/usb/storage/shuttle_usbat.c314
-rw-r--r--drivers/usb/storage/shuttle_usbat.h66
-rw-r--r--drivers/usb/storage/transport.c6
-rw-r--r--drivers/usb/storage/transport.h2
-rw-r--r--drivers/usb/storage/unusual_devs.h44
-rw-r--r--drivers/usb/storage/usb.c163
-rw-r--r--drivers/usb/storage/usb.h5
-rw-r--r--drivers/usb/usb-skeleton.c3
-rw-r--r--drivers/video/amba-clcd.c1
-rw-r--r--drivers/video/backlight/corgi_bl.c10
-rw-r--r--drivers/video/cirrusfb.c24
-rw-r--r--drivers/video/console/Kconfig8
-rw-r--r--drivers/video/console/sticore.c126
-rw-r--r--drivers/video/fbmem.c2
-rw-r--r--drivers/video/imxfb.c10
-rw-r--r--drivers/video/pxafb.c10
-rw-r--r--drivers/video/s1d13xxxfb.c7
-rw-r--r--drivers/video/s3c2410fb.c27
-rw-r--r--drivers/video/sa1100fb.c10
-rw-r--r--drivers/video/w100fb.c46
-rw-r--r--fs/afs/file.c4
-rw-r--r--fs/bio.c4
-rw-r--r--fs/buffer.c4
-rw-r--r--fs/coda/psdev.c4
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/dquot.c2
-rw-r--r--fs/exec.c12
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/super.c26
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/inode.c2
-rw-r--r--fs/jbd/journal.c2
-rw-r--r--fs/jbd/transaction.c2
-rw-r--r--fs/jfs/jfs_dmap.c20
-rw-r--r--fs/jfs/jfs_imap.c10
-rw-r--r--fs/jfs/jfs_metapage.c10
-rw-r--r--fs/jfs/jfs_txnmgr.c2
-rw-r--r--fs/jfs/jfs_xtree.c18
-rw-r--r--fs/jfs/super.c1
-rw-r--r--fs/lockd/host.c4
-rw-r--r--fs/locks.c48
-rw-r--r--fs/mbcache.c6
-rw-r--r--fs/namei.c95
-rw-r--r--fs/nfs/delegation.c2
-rw-r--r--fs/nfs/delegation.h16
-rw-r--r--fs/nfs/dir.c67
-rw-r--r--fs/nfs/file.c31
-rw-r--r--fs/nfs/inode.c200
-rw-r--r--fs/nfs/nfs2xdr.c1
-rw-r--r--fs/nfs/nfs3proc.c92
-rw-r--r--fs/nfs/nfs3xdr.c1
-rw-r--r--fs/nfs/nfs4_fs.h53
-rw-r--r--fs/nfs/nfs4proc.c735
-rw-r--r--fs/nfs/nfs4state.c181
-rw-r--r--fs/nfs/nfs4xdr.c305
-rw-r--r--fs/nfs/proc.c44
-rw-r--r--fs/nfs/read.c1
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/open.c79
-rw-r--r--fs/partitions/check.c29
-rw-r--r--fs/reiserfs/fix_node.c2
-rw-r--r--fs/reiserfs/inode.c2
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/xfs/linux-2.6/kmem.c22
-rw-r--r--fs/xfs/linux-2.6/kmem.h18
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c8
-rw-r--r--include/asm-alpha/dma-mapping.h2
-rw-r--r--include/asm-arm/arch-aaec2000/aaec2000.h56
-rw-r--r--include/asm-arm/arch-aaec2000/aaed2000.h40
-rw-r--r--include/asm-arm/arch-aaec2000/hardware.h3
-rw-r--r--include/asm-arm/arch-aaec2000/io.h2
-rw-r--r--include/asm-arm/arch-cl7500/io.h2
-rw-r--r--include/asm-arm/arch-clps711x/hardware.h117
-rw-r--r--include/asm-arm/arch-clps711x/io.h2
-rw-r--r--include/asm-arm/arch-clps711x/mp1000-seprom.h77
-rw-r--r--include/asm-arm/arch-ebsa285/io.h2
-rw-r--r--include/asm-arm/arch-epxa10db/io.h2
-rw-r--r--include/asm-arm/arch-h720x/io.h2
-rw-r--r--include/asm-arm/arch-imx/io.h2
-rw-r--r--include/asm-arm/arch-integrator/hardware.h9
-rw-r--r--include/asm-arm/arch-integrator/io.h8
-rw-r--r--include/asm-arm/arch-iop3xx/io.h2
-rw-r--r--include/asm-arm/arch-ixp2000/io.h2
-rw-r--r--include/asm-arm/arch-ixp2000/ixp2000-regs.h43
-rw-r--r--include/asm-arm/arch-l7200/io.h2
-rw-r--r--include/asm-arm/arch-lh7a40x/io.h2
-rw-r--r--include/asm-arm/arch-omap/io.h2
-rw-r--r--include/asm-arm/arch-pxa/hardware.h4
-rw-r--r--include/asm-arm/arch-pxa/io.h2
-rw-r--r--include/asm-arm/arch-pxa/irda.h17
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h42
-rw-r--r--include/asm-arm/arch-pxa/uncompress.h1
-rw-r--r--include/asm-arm/arch-rpc/io.h2
-rw-r--r--include/asm-arm/arch-s3c2410/fb.h3
-rw-r--r--include/asm-arm/arch-s3c2410/io.h2
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h6
-rw-r--r--include/asm-arm/arch-sa1100/hardware.h7
-rw-r--r--include/asm-arm/arch-sa1100/io.h8
-rw-r--r--include/asm-arm/arch-sa1100/system.h1
-rw-r--r--include/asm-arm/arch-shark/io.h2
-rw-r--r--include/asm-arm/dma-mapping.h4
-rw-r--r--include/asm-arm/io.h1
-rw-r--r--include/asm-arm/mach/arch.h6
-rw-r--r--include/asm-arm/mach/map.h5
-rw-r--r--include/asm-cris/dma-mapping.h4
-rw-r--r--include/asm-frv/dma-mapping.h2
-rw-r--r--include/asm-frv/pci.h2
-rw-r--r--include/asm-generic/dma-mapping-broken.h2
-rw-r--r--include/asm-i386/mach-summit/mach_mpparse.h3
-rw-r--r--include/asm-ia64/machvec.h2
-rw-r--r--include/asm-m32r/dma-mapping.h2
-rw-r--r--include/asm-mips/dma-mapping.h4
-rw-r--r--include/asm-mips/sgi/hpc3.h40
-rw-r--r--include/asm-parisc/assembly.h71
-rw-r--r--include/asm-parisc/bitops.h290
-rw-r--r--include/asm-parisc/dma-mapping.h8
-rw-r--r--include/asm-parisc/errno.h1
-rw-r--r--include/asm-parisc/grfioctl.h2
-rw-r--r--include/asm-parisc/led.h3
-rw-r--r--include/asm-parisc/parisc-device.h7
-rw-r--r--include/asm-parisc/pci.h2
-rw-r--r--include/asm-parisc/pgtable.h2
-rw-r--r--include/asm-parisc/processor.h19
-rw-r--r--include/asm-parisc/psw.h51
-rw-r--r--include/asm-parisc/ptrace.h2
-rw-r--r--include/asm-parisc/spinlock.h5
-rw-r--r--include/asm-parisc/spinlock_types.h8
-rw-r--r--include/asm-parisc/system.h48
-rw-r--r--include/asm-parisc/tlbflush.h29
-rw-r--r--include/asm-parisc/types.h2
-rw-r--r--include/asm-parisc/unistd.h16
-rw-r--r--include/asm-ppc/dma-mapping.h2
-rw-r--r--include/asm-sh/dma-mapping.h4
-rw-r--r--include/asm-sh/machvec.h2
-rw-r--r--include/asm-sh64/dma-mapping.h2
-rw-r--r--include/asm-sparc/dma-mapping.h2
-rw-r--r--include/asm-sparc64/dma-mapping.h2
-rw-r--r--include/asm-um/dma-mapping.h2
-rw-r--r--include/asm-um/page.h2
-rw-r--r--include/asm-x86_64/dma-mapping.h2
-rw-r--r--include/asm-x86_64/swiotlb.h2
-rw-r--r--include/asm-xtensa/dma-mapping.h2
-rw-r--r--include/linux/ata.h41
-rw-r--r--include/linux/audit.h4
-rw-r--r--include/linux/bio.h2
-rw-r--r--include/linux/blkdev.h50
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/cyclomx.h2
-rw-r--r--include/linux/cycx_drv.h1
-rw-r--r--include/linux/device.h115
-rw-r--r--include/linux/elevator.h22
-rw-r--r--include/linux/ethtool.h8
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/genhd.h3
-rw-r--r--include/linux/gfp.h39
-rw-r--r--include/linux/hil.h483
-rw-r--r--include/linux/hil_mlc.h168
-rw-r--r--include/linux/hp_sdc.h300
-rw-r--r--include/linux/i2c-algo-bit.h4
-rw-r--r--include/linux/i2c-algo-pca.h2
-rw-r--r--include/linux/i2c-algo-pcf.h4
-rw-r--r--include/linux/i2c-dev.h2
-rw-r--r--include/linux/i2c-id.h3
-rw-r--r--include/linux/i2c.h38
-rw-r--r--include/linux/i2o.h8
-rw-r--r--include/linux/ibmtr.h4
-rw-r--r--include/linux/idr.h2
-rw-r--r--include/linux/if_arp.h1
-rw-r--r--include/linux/input.h27
-rw-r--r--include/linux/jbd.h4
-rw-r--r--include/linux/kobject.h2
-rw-r--r--include/linux/libata.h113
-rw-r--r--include/linux/loop.h2
-rw-r--r--include/linux/mbcache.h2
-rw-r--r--include/linux/mii.h1
-rw-r--r--include/linux/mm.h2
-rw-r--r--include/linux/mmc/mmc.h4
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/mod_devicetable.h5
-rw-r--r--include/linux/namei.h8
-rw-r--r--include/linux/netdevice.h7
-rw-r--r--include/linux/nfs_fs.h28
-rw-r--r--include/linux/nfs_xdr.h65
-rw-r--r--include/linux/pagemap.h13
-rw-r--r--include/linux/pci.h7
-rw-r--r--include/linux/pci_ids.h566
-rw-r--r--include/linux/pm.h40
-rw-r--r--include/linux/radix-tree.h2
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--include/linux/sdladrv.h4
-rw-r--r--include/linux/security.h2
-rw-r--r--include/linux/skbuff.h10
-rw-r--r--include/linux/slab.h2
-rw-r--r--include/linux/sunrpc/auth.h7
-rw-r--r--include/linux/sunrpc/debug.h3
-rw-r--r--include/linux/sunrpc/gss_api.h27
-rw-r--r--include/linux/sunrpc/gss_err.h10
-rw-r--r--include/linux/sunrpc/gss_krb5.h27
-rw-r--r--include/linux/sunrpc/gss_spkm3.h4
-rw-r--r--include/linux/sunrpc/msg_prot.h25
-rw-r--r--include/linux/sunrpc/xdr.h6
-rw-r--r--include/linux/sunrpc/xprt.h227
-rw-r--r--include/linux/suspend.h2
-rw-r--r--include/linux/swap.h4
-rw-r--r--include/linux/textsearch.h4
-rw-r--r--include/linux/types.h9
-rw-r--r--include/linux/usb.h171
-rw-r--r--include/linux/usb_gadget.h12
-rw-r--r--include/linux/usb_otg.h13
-rw-r--r--include/linux/usbdevice_fs.h7
-rw-r--r--include/linux/wanpipe.h9
-rw-r--r--include/linux/x1205.h31
-rw-r--r--include/media/ovcamchip.h14
-rw-r--r--include/net/bluetooth/bluetooth.h6
-rw-r--r--include/net/bluetooth/rfcomm.h3
-rw-r--r--include/net/dst.h1
-rw-r--r--include/net/ieee80211.h525
-rw-r--r--include/net/ieee80211_crypt.h38
-rw-r--r--include/net/ieee80211_radiotap.h231
-rw-r--r--include/net/sctp/user.h8
-rw-r--r--include/net/sock.h2
-rw-r--r--include/net/syncppp.h1
-rw-r--r--include/rdma/ib_cm.h10
-rw-r--r--include/rdma/ib_mad.h66
-rw-r--r--include/rdma/ib_user_cm.h10
-rw-r--r--include/rdma/ib_user_verbs.h222
-rw-r--r--include/rdma/ib_verbs.h6
-rw-r--r--include/scsi/scsi_cmnd.h2
-rw-r--r--include/scsi/scsi_request.h2
-rw-r--r--include/sound/memalloc.h2
-rw-r--r--kernel/audit.c6
-rw-r--r--kernel/auditsc.c2
-rw-r--r--kernel/kexec.c7
-rw-r--r--kernel/power/swsusp.c2
-rw-r--r--lib/idr.c2
-rw-r--r--lib/kobject.c2
-rw-r--r--lib/kobject_uevent.c6
-rw-r--r--lib/textsearch.c2
-rw-r--r--mm/filemap.c8
-rw-r--r--mm/highmem.c14
-rw-r--r--mm/mempolicy.c6
-rw-r--r--mm/mempool.c2
-rw-r--r--mm/page_alloc.c33
-rw-r--r--mm/shmem.c4
-rw-r--r--mm/slab.c8
-rw-r--r--mm/vmscan.c8
-rw-r--r--net/bluetooth/af_bluetooth.c6
-rw-r--r--net/bluetooth/hci_core.c4
-rw-r--r--net/bluetooth/hci_sock.c12
-rw-r--r--net/bluetooth/hidp/core.c13
-rw-r--r--net/bluetooth/rfcomm/Makefile2
-rw-r--r--net/bluetooth/rfcomm/core.c43
-rw-r--r--net/bluetooth/rfcomm/crc.c71
-rw-r--r--net/core/dev.c14
-rw-r--r--net/core/ethtool.c53
-rw-r--r--net/core/neighbour.c5
-rw-r--r--net/core/pktgen.c506
-rw-r--r--net/core/skbuff.c77
-rw-r--r--net/core/sock.c2
-rw-r--r--net/dccp/output.c2
-rw-r--r--net/decnet/af_decnet.c13
-rw-r--r--net/ieee80211/Makefile3
-rw-r--r--net/ieee80211/ieee80211_crypt.c59
-rw-r--r--net/ieee80211/ieee80211_crypt_ccmp.c75
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c150
-rw-r--r--net/ieee80211/ieee80211_crypt_wep.c26
-rw-r--r--net/ieee80211/ieee80211_geo.c141
-rw-r--r--net/ieee80211/ieee80211_module.c65
-rw-r--r--net/ieee80211/ieee80211_rx.c610
-rw-r--r--net/ieee80211/ieee80211_tx.c321
-rw-r--r--net/ieee80211/ieee80211_wx.c372
-rw-r--r--net/ipv4/devinet.c3
-rw-r--r--net/ipv4/fib_trie.c2
-rw-r--r--net/ipv4/icmp.c5
-rw-r--r--net/ipv4/ip_output.c88
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c132
-rw-r--r--net/ipv4/proc.c4
-rw-r--r--net/ipv6/icmp.c9
-rw-r--r--net/ipv6/ip6_output.c71
-rw-r--r--net/ipv6/mcast.c2
-rw-r--r--net/ipv6/proc.c4
-rw-r--r--net/netlink/af_netlink.c5
-rw-r--r--net/rose/rose_route.c2
-rw-r--r--net/sctp/proc.c4
-rw-r--r--net/sctp/sm_make_chunk.c2
-rw-r--r--net/sctp/socket.c90
-rw-r--r--net/sctp/ulpevent.c6
-rw-r--r--net/sunrpc/Makefile2
-rw-r--r--net/sunrpc/auth.c1
-rw-r--r--net/sunrpc/auth_gss/Makefile2
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c187
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c260
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c41
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c44
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_unseal.c39
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_wrap.c363
-rw-r--r--net/sunrpc/auth_gss/gss_mech_switch.c29
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_mech.c21
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_seal.c4
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_unseal.c2
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c9
-rw-r--r--net/sunrpc/auth_null.c2
-rw-r--r--net/sunrpc/auth_unix.c2
-rw-r--r--net/sunrpc/clnt.c147
-rw-r--r--net/sunrpc/pmap_clnt.c12
-rw-r--r--net/sunrpc/rpc_pipe.c29
-rw-r--r--net/sunrpc/socklib.c175
-rw-r--r--net/sunrpc/sunrpc_syms.c1
-rw-r--r--net/sunrpc/svcsock.c3
-rw-r--r--net/sunrpc/sysctl.c32
-rw-r--r--net/sunrpc/xdr.c177
-rw-r--r--net/sunrpc/xprt.c1613
-rw-r--r--net/sunrpc/xprtsock.c1252
-rw-r--r--net/xfrm/xfrm_policy.c43
-rw-r--r--net/xfrm/xfrm_state.c6
-rw-r--r--scripts/mod/file2alias.c10
-rw-r--r--security/dummy.c2
-rw-r--r--security/selinux/hooks.c4
-rw-r--r--sound/arm/aaci.c1
-rw-r--r--sound/arm/pxa2xx-ac97.c8
-rw-r--r--sound/core/init.c14
-rw-r--r--sound/core/memalloc.c4
-rw-r--r--sound/core/seq/instr/ainstr_gf1.c5
-rw-r--r--sound/core/seq/instr/ainstr_iw.c4
-rw-r--r--sound/core/seq/instr/ainstr_simple.c3
-rw-r--r--sound/core/sound.c2
-rw-r--r--sound/oss/dmasound/dmasound.h2
-rw-r--r--sound/oss/dmasound/dmasound_atari.c4
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c4
-rw-r--r--sound/oss/dmasound/dmasound_paula.c4
-rw-r--r--sound/oss/dmasound/dmasound_q40.c4
-rw-r--r--sound/oss/soundcard.c4
-rw-r--r--sound/oss/ymfpci.c17
-rw-r--r--sound/parisc/harmony.c116
-rw-r--r--sound/parisc/harmony.h17
-rw-r--r--sound/pci/ac97/ac97_bus.c6
-rw-r--r--sound/pci/bt87x.c11
-rw-r--r--sound/ppc/beep.c66
-rw-r--r--sound/sound_core.c2
-rw-r--r--sound/usb/usbmidi.c2
1220 files changed, 43751 insertions, 32019 deletions
diff --git a/CREDITS b/CREDITS
index a347520bef2d..5b1edf3a38a2 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2247,6 +2247,12 @@ S: 249 Nichols Avenue
2247S: Syracuse, New York 13206 2247S: Syracuse, New York 13206
2248S: USA 2248S: USA
2249 2249
2250N: Kyle McMartin
2251E: kyle@parisc-linux.org
2252D: Linux/PARISC hacker
2253D: AD1889 sound driver
2254S: Ottawa, Canada
2255
2250N: Dirk Melchers 2256N: Dirk Melchers
2251E: dirk@merlin.nbg.sub.org 2257E: dirk@merlin.nbg.sub.org
2252D: 8 bit XT hard disk driver for OMTI5520 2258D: 8 bit XT hard disk driver for OMTI5520
diff --git a/Documentation/Changes b/Documentation/Changes
index 27232be26e1a..783ddc3ce4e8 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -65,7 +65,7 @@ o isdn4k-utils 3.1pre1 # isdnctrl 2>&1|grep version
65o nfs-utils 1.0.5 # showmount --version 65o nfs-utils 1.0.5 # showmount --version
66o procps 3.2.0 # ps --version 66o procps 3.2.0 # ps --version
67o oprofile 0.9 # oprofiled --version 67o oprofile 0.9 # oprofiled --version
68o udev 058 # udevinfo -V 68o udev 071 # udevinfo -V
69 69
70Kernel compilation 70Kernel compilation
71================== 71==================
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index d650ce36485f..4d9b66d8b4db 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -286,7 +286,9 @@ X!Edrivers/pci/search.c
286 --> 286 -->
287!Edrivers/pci/msi.c 287!Edrivers/pci/msi.c
288!Edrivers/pci/bus.c 288!Edrivers/pci/bus.c
289!Edrivers/pci/hotplug.c 289<!-- FIXME: Removed for now since no structured comments in source
290X!Edrivers/pci/hotplug.c
291-->
290!Edrivers/pci/probe.c 292!Edrivers/pci/probe.c
291!Edrivers/pci/rom.c 293!Edrivers/pci/rom.c
292 </sect1> 294 </sect1>
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index 375ae760dc1e..d260d92089ad 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -415,6 +415,362 @@ and other resources, etc.
415 </sect1> 415 </sect1>
416 </chapter> 416 </chapter>
417 417
418 <chapter id="libataEH">
419 <title>Error handling</title>
420
421 <para>
422 This chapter describes how errors are handled under libata.
423 Readers are advised to read SCSI EH
424 (Documentation/scsi/scsi_eh.txt) and ATA exceptions doc first.
425 </para>
426
427 <sect1><title>Origins of commands</title>
428 <para>
429 In libata, a command is represented with struct ata_queued_cmd
430 or qc. qc's are preallocated during port initialization and
431 repetitively used for command executions. Currently only one
432 qc is allocated per port but yet-to-be-merged NCQ branch
433 allocates one for each tag and maps each qc to NCQ tag 1-to-1.
434 </para>
435 <para>
436 libata commands can originate from two sources - libata itself
437 and SCSI midlayer. libata internal commands are used for
438 initialization and error handling. All normal blk requests
439 and commands for SCSI emulation are passed as SCSI commands
440 through queuecommand callback of SCSI host template.
441 </para>
442 </sect1>
443
444 <sect1><title>How commands are issued</title>
445
446 <variablelist>
447
448 <varlistentry><term>Internal commands</term>
449 <listitem>
450 <para>
451 First, qc is allocated and initialized using
452 ata_qc_new_init(). Although ata_qc_new_init() doesn't
453 implement any wait or retry mechanism when qc is not
454 available, internal commands are currently issued only during
455 initialization and error recovery, so no other command is
456 active and allocation is guaranteed to succeed.
457 </para>
458 <para>
459 Once allocated qc's taskfile is initialized for the command to
460 be executed. qc currently has two mechanisms to notify
461 completion. One is via qc->complete_fn() callback and the
462 other is completion qc->waiting. qc->complete_fn() callback
463 is the asynchronous path used by normal SCSI translated
464 commands and qc->waiting is the synchronous (issuer sleeps in
465 process context) path used by internal commands.
466 </para>
467 <para>
468 Once initialization is complete, host_set lock is acquired
469 and the qc is issued.
470 </para>
471 </listitem>
472 </varlistentry>
473
474 <varlistentry><term>SCSI commands</term>
475 <listitem>
476 <para>
477 All libata drivers use ata_scsi_queuecmd() as
478 hostt->queuecommand callback. scmds can either be simulated
479 or translated. No qc is involved in processing a simulated
480 scmd. The result is computed right away and the scmd is
481 completed.
482 </para>
483 <para>
484 For a translated scmd, ata_qc_new_init() is invoked to
485 allocate a qc and the scmd is translated into the qc. SCSI
486 midlayer's completion notification function pointer is stored
487 into qc->scsidone.
488 </para>
489 <para>
490 qc->complete_fn() callback is used for completion
491 notification. ATA commands use ata_scsi_qc_complete() while
492 ATAPI commands use atapi_qc_complete(). Both functions end up
493 calling qc->scsidone to notify upper layer when the qc is
494 finished. After translation is completed, the qc is issued
495 with ata_qc_issue().
496 </para>
497 <para>
498 Note that SCSI midlayer invokes hostt->queuecommand while
499 holding host_set lock, so all above occur while holding
500 host_set lock.
501 </para>
502 </listitem>
503 </varlistentry>
504
505 </variablelist>
506 </sect1>
507
508 <sect1><title>How commands are processed</title>
509 <para>
510 Depending on which protocol and which controller are used,
511 commands are processed differently. For the purpose of
512 discussion, a controller which uses taskfile interface and all
513 standard callbacks is assumed.
514 </para>
515 <para>
516 Currently 6 ATA command protocols are used. They can be
517 sorted into the following four categories according to how
518 they are processed.
519 </para>
520
521 <variablelist>
522 <varlistentry><term>ATA NO DATA or DMA</term>
523 <listitem>
524 <para>
525 ATA_PROT_NODATA and ATA_PROT_DMA fall into this category.
526 These types of commands don't require any software
527 intervention once issued. Device will raise interrupt on
528 completion.
529 </para>
530 </listitem>
531 </varlistentry>
532
533 <varlistentry><term>ATA PIO</term>
534 <listitem>
535 <para>
536 ATA_PROT_PIO is in this category. libata currently
537 implements PIO with polling. ATA_NIEN bit is set to turn
538 off interrupt and pio_task on ata_wq performs polling and
539 IO.
540 </para>
541 </listitem>
542 </varlistentry>
543
544 <varlistentry><term>ATAPI NODATA or DMA</term>
545 <listitem>
546 <para>
547 ATA_PROT_ATAPI_NODATA and ATA_PROT_ATAPI_DMA are in this
548 category. packet_task is used to poll BSY bit after
549 issuing PACKET command. Once BSY is turned off by the
550 device, packet_task transfers CDB and hands off processing
551 to interrupt handler.
552 </para>
553 </listitem>
554 </varlistentry>
555
556 <varlistentry><term>ATAPI PIO</term>
557 <listitem>
558 <para>
559 ATA_PROT_ATAPI is in this category. ATA_NIEN bit is set
560 and, as in ATAPI NODATA or DMA, packet_task submits cdb.
561 However, after submitting cdb, further processing (data
562 transfer) is handed off to pio_task.
563 </para>
564 </listitem>
565 </varlistentry>
566 </variablelist>
567 </sect1>
568
569 <sect1><title>How commands are completed</title>
570 <para>
571 Once issued, all qc's are either completed with
572 ata_qc_complete() or time out. For commands which are handled
573 by interrupts, ata_host_intr() invokes ata_qc_complete(), and,
574 for PIO tasks, pio_task invokes ata_qc_complete(). In error
575 cases, packet_task may also complete commands.
576 </para>
577 <para>
578 ata_qc_complete() does the following.
579 </para>
580
581 <orderedlist>
582
583 <listitem>
584 <para>
585 DMA memory is unmapped.
586 </para>
587 </listitem>
588
589 <listitem>
590 <para>
591 ATA_QCFLAG_ACTIVE is clared from qc->flags.
592 </para>
593 </listitem>
594
595 <listitem>
596 <para>
597 qc->complete_fn() callback is invoked. If the return value of
598 the callback is not zero. Completion is short circuited and
599 ata_qc_complete() returns.
600 </para>
601 </listitem>
602
603 <listitem>
604 <para>
605 __ata_qc_complete() is called, which does
606 <orderedlist>
607
608 <listitem>
609 <para>
610 qc->flags is cleared to zero.
611 </para>
612 </listitem>
613
614 <listitem>
615 <para>
616 ap->active_tag and qc->tag are poisoned.
617 </para>
618 </listitem>
619
620 <listitem>
621 <para>
622 qc->waiting is claread &amp; completed (in that order).
623 </para>
624 </listitem>
625
626 <listitem>
627 <para>
628 qc is deallocated by clearing appropriate bit in ap->qactive.
629 </para>
630 </listitem>
631
632 </orderedlist>
633 </para>
634 </listitem>
635
636 </orderedlist>
637
638 <para>
639 So, it basically notifies upper layer and deallocates qc. One
640 exception is short-circuit path in #3 which is used by
641 atapi_qc_complete().
642 </para>
643 <para>
644 For all non-ATAPI commands, whether it fails or not, almost
645 the same code path is taken and very little error handling
646 takes place. A qc is completed with success status if it
647 succeeded, with failed status otherwise.
648 </para>
649 <para>
650 However, failed ATAPI commands require more handling as
651 REQUEST SENSE is needed to acquire sense data. If an ATAPI
652 command fails, ata_qc_complete() is invoked with error status,
653 which in turn invokes atapi_qc_complete() via
654 qc->complete_fn() callback.
655 </para>
656 <para>
657 This makes atapi_qc_complete() set scmd->result to
658 SAM_STAT_CHECK_CONDITION, complete the scmd and return 1. As
659 the sense data is empty but scmd->result is CHECK CONDITION,
660 SCSI midlayer will invoke EH for the scmd, and returning 1
661 makes ata_qc_complete() to return without deallocating the qc.
662 This leads us to ata_scsi_error() with partially completed qc.
663 </para>
664
665 </sect1>
666
667 <sect1><title>ata_scsi_error()</title>
668 <para>
669 ata_scsi_error() is the current hostt->eh_strategy_handler()
670 for libata. As discussed above, this will be entered in two
671 cases - timeout and ATAPI error completion. This function
672 calls low level libata driver's eng_timeout() callback, the
673 standard callback for which is ata_eng_timeout(). It checks
674 if a qc is active and calls ata_qc_timeout() on the qc if so.
675 Actual error handling occurs in ata_qc_timeout().
676 </para>
677 <para>
678 If EH is invoked for timeout, ata_qc_timeout() stops BMDMA and
679 completes the qc. Note that as we're currently in EH, we
680 cannot call scsi_done. As described in SCSI EH doc, a
681 recovered scmd should be either retried with
682 scsi_queue_insert() or finished with scsi_finish_command().
683 Here, we override qc->scsidone with scsi_finish_command() and
684 calls ata_qc_complete().
685 </para>
686 <para>
687 If EH is invoked due to a failed ATAPI qc, the qc here is
688 completed but not deallocated. The purpose of this
689 half-completion is to use the qc as place holder to make EH
690 code reach this place. This is a bit hackish, but it works.
691 </para>
692 <para>
693 Once control reaches here, the qc is deallocated by invoking
694 __ata_qc_complete() explicitly. Then, internal qc for REQUEST
695 SENSE is issued. Once sense data is acquired, scmd is
696 finished by directly invoking scsi_finish_command() on the
697 scmd. Note that as we already have completed and deallocated
698 the qc which was associated with the scmd, we don't need
699 to/cannot call ata_qc_complete() again.
700 </para>
701
702 </sect1>
703
704 <sect1><title>Problems with the current EH</title>
705
706 <itemizedlist>
707
708 <listitem>
709 <para>
710 Error representation is too crude. Currently any and all
711 error conditions are represented with ATA STATUS and ERROR
712 registers. Errors which aren't ATA device errors are treated
713 as ATA device errors by setting ATA_ERR bit. Better error
714 descriptor which can properly represent ATA and other
715 errors/exceptions is needed.
716 </para>
717 </listitem>
718
719 <listitem>
720 <para>
721 When handling timeouts, no action is taken to make device
722 forget about the timed out command and ready for new commands.
723 </para>
724 </listitem>
725
726 <listitem>
727 <para>
728 EH handling via ata_scsi_error() is not properly protected
729 from usual command processing. On EH entrance, the device is
730 not in quiescent state. Timed out commands may succeed or
731 fail any time. pio_task and atapi_task may still be running.
732 </para>
733 </listitem>
734
735 <listitem>
736 <para>
737 Too weak error recovery. Devices / controllers causing HSM
738 mismatch errors and other errors quite often require reset to
739 return to known state. Also, advanced error handling is
740 necessary to support features like NCQ and hotplug.
741 </para>
742 </listitem>
743
744 <listitem>
745 <para>
746 ATA errors are directly handled in the interrupt handler and
747 PIO errors in pio_task. This is problematic for advanced
748 error handling for the following reasons.
749 </para>
750 <para>
751 First, advanced error handling often requires context and
752 internal qc execution.
753 </para>
754 <para>
755 Second, even a simple failure (say, CRC error) needs
756 information gathering and could trigger complex error handling
757 (say, resetting &amp; reconfiguring). Having multiple code
758 paths to gather information, enter EH and trigger actions
759 makes life painful.
760 </para>
761 <para>
762 Third, scattered EH code makes implementing low level drivers
763 difficult. Low level drivers override libata callbacks. If
764 EH is scattered over several places, each affected callbacks
765 should perform its part of error handling. This can be error
766 prone and painful.
767 </para>
768 </listitem>
769
770 </itemizedlist>
771 </sect1>
772 </chapter>
773
418 <chapter id="libataExt"> 774 <chapter id="libataExt">
419 <title>libata Library</title> 775 <title>libata Library</title>
420!Edrivers/scsi/libata-core.c 776!Edrivers/scsi/libata-core.c
@@ -431,6 +787,722 @@ and other resources, etc.
431!Idrivers/scsi/libata-scsi.c 787!Idrivers/scsi/libata-scsi.c
432 </chapter> 788 </chapter>
433 789
790 <chapter id="ataExceptions">
791 <title>ATA errors &amp; exceptions</title>
792
793 <para>
794 This chapter tries to identify what error/exception conditions exist
795 for ATA/ATAPI devices and describe how they should be handled in
796 implementation-neutral way.
797 </para>
798
799 <para>
800 The term 'error' is used to describe conditions where either an
801 explicit error condition is reported from device or a command has
802 timed out.
803 </para>
804
805 <para>
806 The term 'exception' is either used to describe exceptional
807 conditions which are not errors (say, power or hotplug events), or
808 to describe both errors and non-error exceptional conditions. Where
809 explicit distinction between error and exception is necessary, the
810 term 'non-error exception' is used.
811 </para>
812
813 <sect1 id="excat">
814 <title>Exception categories</title>
815 <para>
816 Exceptions are described primarily with respect to legacy
817 taskfile + bus master IDE interface. If a controller provides
818 other better mechanism for error reporting, mapping those into
819 categories described below shouldn't be difficult.
820 </para>
821
822 <para>
823 In the following sections, two recovery actions - reset and
824 reconfiguring transport - are mentioned. These are described
825 further in <xref linkend="exrec"/>.
826 </para>
827
828 <sect2 id="excatHSMviolation">
829 <title>HSM violation</title>
830 <para>
831 This error is indicated when STATUS value doesn't match HSM
832 requirement during issuing or excution any ATA/ATAPI command.
833 </para>
834
835 <itemizedlist>
836 <title>Examples</title>
837
838 <listitem>
839 <para>
840 ATA_STATUS doesn't contain !BSY &amp;&amp; DRDY &amp;&amp; !DRQ while trying
841 to issue a command.
842 </para>
843 </listitem>
844
845 <listitem>
846 <para>
847 !BSY &amp;&amp; !DRQ during PIO data transfer.
848 </para>
849 </listitem>
850
851 <listitem>
852 <para>
853 DRQ on command completion.
854 </para>
855 </listitem>
856
857 <listitem>
858 <para>
859 !BSY &amp;&amp; ERR after CDB tranfer starts but before the
860 last byte of CDB is transferred. ATA/ATAPI standard states
861 that &quot;The device shall not terminate the PACKET command
862 with an error before the last byte of the command packet has
863 been written&quot; in the error outputs description of PACKET
864 command and the state diagram doesn't include such
865 transitions.
866 </para>
867 </listitem>
868
869 </itemizedlist>
870
871 <para>
872 In these cases, HSM is violated and not much information
873 regarding the error can be acquired from STATUS or ERROR
874 register. IOW, this error can be anything - driver bug,
875 faulty device, controller and/or cable.
876 </para>
877
878 <para>
879 As HSM is violated, reset is necessary to restore known state.
880 Reconfiguring transport for lower speed might be helpful too
881 as transmission errors sometimes cause this kind of errors.
882 </para>
883 </sect2>
884
885 <sect2 id="excatDevErr">
886 <title>ATA/ATAPI device error (non-NCQ / non-CHECK CONDITION)</title>
887
888 <para>
889 These are errors detected and reported by ATA/ATAPI devices
890 indicating device problems. For this type of errors, STATUS
891 and ERROR register values are valid and describe error
892 condition. Note that some of ATA bus errors are detected by
893 ATA/ATAPI devices and reported using the same mechanism as
894 device errors. Those cases are described later in this
895 section.
896 </para>
897
898 <para>
899 For ATA commands, this type of errors are indicated by !BSY
900 &amp;&amp; ERR during command execution and on completion.
901 </para>
902
903 <para>For ATAPI commands,</para>
904
905 <itemizedlist>
906
907 <listitem>
908 <para>
909 !BSY &amp;&amp; ERR &amp;&amp; ABRT right after issuing PACKET
910 indicates that PACKET command is not supported and falls in
911 this category.
912 </para>
913 </listitem>
914
915 <listitem>
916 <para>
917 !BSY &amp;&amp; ERR(==CHK) &amp;&amp; !ABRT after the last
918 byte of CDB is transferred indicates CHECK CONDITION and
919 doesn't fall in this category.
920 </para>
921 </listitem>
922
923 <listitem>
924 <para>
925 !BSY &amp;&amp; ERR(==CHK) &amp;&amp; ABRT after the last byte
926 of CDB is transferred *probably* indicates CHECK CONDITION and
927 doesn't fall in this category.
928 </para>
929 </listitem>
930
931 </itemizedlist>
932
933 <para>
934 Of errors detected as above, the followings are not ATA/ATAPI
935 device errors but ATA bus errors and should be handled
936 according to <xref linkend="excatATAbusErr"/>.
937 </para>
938
939 <variablelist>
940
941 <varlistentry>
942 <term>CRC error during data transfer</term>
943 <listitem>
944 <para>
945 This is indicated by ICRC bit in the ERROR register and
946 means that corruption occurred during data transfer. Upto
947 ATA/ATAPI-7, the standard specifies that this bit is only
948 applicable to UDMA transfers but ATA/ATAPI-8 draft revision
949 1f says that the bit may be applicable to multiword DMA and
950 PIO.
951 </para>
952 </listitem>
953 </varlistentry>
954
955 <varlistentry>
956 <term>ABRT error during data transfer or on completion</term>
957 <listitem>
958 <para>
959 Upto ATA/ATAPI-7, the standard specifies that ABRT could be
960 set on ICRC errors and on cases where a device is not able
961 to complete a command. Combined with the fact that MWDMA
962 and PIO transfer errors aren't allowed to use ICRC bit upto
963 ATA/ATAPI-7, it seems to imply that ABRT bit alone could
964 indicate tranfer errors.
965 </para>
966 <para>
967 However, ATA/ATAPI-8 draft revision 1f removes the part
968 that ICRC errors can turn on ABRT. So, this is kind of
969 gray area. Some heuristics are needed here.
970 </para>
971 </listitem>
972 </varlistentry>
973
974 </variablelist>
975
976 <para>
977 ATA/ATAPI device errors can be further categorized as follows.
978 </para>
979
980 <variablelist>
981
982 <varlistentry>
983 <term>Media errors</term>
984 <listitem>
985 <para>
986 This is indicated by UNC bit in the ERROR register. ATA
987 devices reports UNC error only after certain number of
988 retries cannot recover the data, so there's nothing much
989 else to do other than notifying upper layer.
990 </para>
991 <para>
992 READ and WRITE commands report CHS or LBA of the first
993 failed sector but ATA/ATAPI standard specifies that the
994 amount of transferred data on error completion is
995 indeterminate, so we cannot assume that sectors preceding
996 the failed sector have been transferred and thus cannot
997 complete those sectors successfully as SCSI does.
998 </para>
999 </listitem>
1000 </varlistentry>
1001
1002 <varlistentry>
1003 <term>Media changed / media change requested error</term>
1004 <listitem>
1005 <para>
1006 &lt;&lt;TODO: fill here&gt;&gt;
1007 </para>
1008 </listitem>
1009 </varlistentry>
1010
1011 <varlistentry><term>Address error</term>
1012 <listitem>
1013 <para>
1014 This is indicated by IDNF bit in the ERROR register.
1015 Report to upper layer.
1016 </para>
1017 </listitem>
1018 </varlistentry>
1019
1020 <varlistentry><term>Other errors</term>
1021 <listitem>
1022 <para>
1023 This can be invalid command or parameter indicated by ABRT
1024 ERROR bit or some other error condition. Note that ABRT
1025 bit can indicate a lot of things including ICRC and Address
1026 errors. Heuristics needed.
1027 </para>
1028 </listitem>
1029 </varlistentry>
1030
1031 </variablelist>
1032
1033 <para>
1034 Depending on commands, not all STATUS/ERROR bits are
1035 applicable. These non-applicable bits are marked with
1036 &quot;na&quot; in the output descriptions but upto ATA/ATAPI-7
1037 no definition of &quot;na&quot; can be found. However,
1038 ATA/ATAPI-8 draft revision 1f describes &quot;N/A&quot; as
1039 follows.
1040 </para>
1041
1042 <blockquote>
1043 <variablelist>
1044 <varlistentry><term>3.2.3.3a N/A</term>
1045 <listitem>
1046 <para>
1047 A keyword the indicates a field has no defined value in
1048 this standard and should not be checked by the host or
1049 device. N/A fields should be cleared to zero.
1050 </para>
1051 </listitem>
1052 </varlistentry>
1053 </variablelist>
1054 </blockquote>
1055
1056 <para>
1057 So, it seems reasonable to assume that &quot;na&quot; bits are
1058 cleared to zero by devices and thus need no explicit masking.
1059 </para>
1060
1061 </sect2>
1062
1063 <sect2 id="excatATAPIcc">
1064 <title>ATAPI device CHECK CONDITION</title>
1065
1066 <para>
1067 ATAPI device CHECK CONDITION error is indicated by set CHK bit
1068 (ERR bit) in the STATUS register after the last byte of CDB is
1069 transferred for a PACKET command. For this kind of errors,
1070 sense data should be acquired to gather information regarding
1071 the errors. REQUEST SENSE packet command should be used to
1072 acquire sense data.
1073 </para>
1074
1075 <para>
1076 Once sense data is acquired, this type of errors can be
1077 handled similary to other SCSI errors. Note that sense data
1078 may indicate ATA bus error (e.g. Sense Key 04h HARDWARE ERROR
1079 &amp;&amp; ASC/ASCQ 47h/00h SCSI PARITY ERROR). In such
1080 cases, the error should be considered as an ATA bus error and
1081 handled according to <xref linkend="excatATAbusErr"/>.
1082 </para>
1083
1084 </sect2>
1085
1086 <sect2 id="excatNCQerr">
1087 <title>ATA device error (NCQ)</title>
1088
1089 <para>
1090 NCQ command error is indicated by cleared BSY and set ERR bit
1091 during NCQ command phase (one or more NCQ commands
1092 outstanding). Although STATUS and ERROR registers will
1093 contain valid values describing the error, READ LOG EXT is
1094 required to clear the error condition, determine which command
1095 has failed and acquire more information.
1096 </para>
1097
1098 <para>
1099 READ LOG EXT Log Page 10h reports which tag has failed and
1100 taskfile register values describing the error. With this
1101 information the failed command can be handled as a normal ATA
1102 command error as in <xref linkend="excatDevErr"/> and all
1103 other in-flight commands must be retried. Note that this
1104 retry should not be counted - it's likely that commands
1105 retried this way would have completed normally if it were not
1106 for the failed command.
1107 </para>
1108
1109 <para>
1110 Note that ATA bus errors can be reported as ATA device NCQ
1111 errors. This should be handled as described in <xref
1112 linkend="excatATAbusErr"/>.
1113 </para>
1114
1115 <para>
1116 If READ LOG EXT Log Page 10h fails or reports NQ, we're
1117 thoroughly screwed. This condition should be treated
1118 according to <xref linkend="excatHSMviolation"/>.
1119 </para>
1120
1121 </sect2>
1122
1123 <sect2 id="excatATAbusErr">
1124 <title>ATA bus error</title>
1125
1126 <para>
1127 ATA bus error means that data corruption occurred during
1128 transmission over ATA bus (SATA or PATA). This type of errors
1129 can be indicated by
1130 </para>
1131
1132 <itemizedlist>
1133
1134 <listitem>
1135 <para>
1136 ICRC or ABRT error as described in <xref linkend="excatDevErr"/>.
1137 </para>
1138 </listitem>
1139
1140 <listitem>
1141 <para>
1142 Controller-specific error completion with error information
1143 indicating transmission error.
1144 </para>
1145 </listitem>
1146
1147 <listitem>
1148 <para>
1149 On some controllers, command timeout. In this case, there may
1150 be a mechanism to determine that the timeout is due to
1151 transmission error.
1152 </para>
1153 </listitem>
1154
1155 <listitem>
1156 <para>
1157 Unknown/random errors, timeouts and all sorts of weirdities.
1158 </para>
1159 </listitem>
1160
1161 </itemizedlist>
1162
1163 <para>
1164 As described above, transmission errors can cause wide variety
1165 of symptoms ranging from device ICRC error to random device
1166 lockup, and, for many cases, there is no way to tell if an
1167 error condition is due to transmission error or not;
1168 therefore, it's necessary to employ some kind of heuristic
1169 when dealing with errors and timeouts. For example,
1170 encountering repetitive ABRT errors for known supported
1171 command is likely to indicate ATA bus error.
1172 </para>
1173
1174 <para>
1175 Once it's determined that ATA bus errors have possibly
1176 occurred, lowering ATA bus transmission speed is one of
1177 actions which may alleviate the problem. See <xref
1178 linkend="exrecReconf"/> for more information.
1179 </para>
1180
1181 </sect2>
1182
1183 <sect2 id="excatPCIbusErr">
1184 <title>PCI bus error</title>
1185
1186 <para>
1187 Data corruption or other failures during transmission over PCI
1188 (or other system bus). For standard BMDMA, this is indicated
1189 by Error bit in the BMDMA Status register. This type of
1190 errors must be logged as it indicates something is very wrong
1191 with the system. Resetting host controller is recommended.
1192 </para>
1193
1194 </sect2>
1195
1196 <sect2 id="excatLateCompletion">
1197 <title>Late completion</title>
1198
1199 <para>
1200 This occurs when timeout occurs and the timeout handler finds
1201 out that the timed out command has completed successfully or
1202 with error. This is usually caused by lost interrupts. This
1203 type of errors must be logged. Resetting host controller is
1204 recommended.
1205 </para>
1206
1207 </sect2>
1208
1209 <sect2 id="excatUnknown">
1210 <title>Unknown error (timeout)</title>
1211
1212 <para>
1213 This is when timeout occurs and the command is still
1214 processing or the host and device are in unknown state. When
1215 this occurs, HSM could be in any valid or invalid state. To
1216 bring the device to known state and make it forget about the
1217 timed out command, resetting is necessary. The timed out
1218 command may be retried.
1219 </para>
1220
1221 <para>
1222 Timeouts can also be caused by transmission errors. Refer to
1223 <xref linkend="excatATAbusErr"/> for more details.
1224 </para>
1225
1226 </sect2>
1227
1228 <sect2 id="excatHoplugPM">
1229 <title>Hotplug and power management exceptions</title>
1230
1231 <para>
1232 &lt;&lt;TODO: fill here&gt;&gt;
1233 </para>
1234
1235 </sect2>
1236
1237 </sect1>
1238
1239 <sect1 id="exrec">
1240 <title>EH recovery actions</title>
1241
1242 <para>
1243 This section discusses several important recovery actions.
1244 </para>
1245
1246 <sect2 id="exrecClr">
1247 <title>Clearing error condition</title>
1248
1249 <para>
1250 Many controllers require its error registers to be cleared by
1251 error handler. Different controllers may have different
1252 requirements.
1253 </para>
1254
1255 <para>
1256 For SATA, it's strongly recommended to clear at least SError
1257 register during error handling.
1258 </para>
1259 </sect2>
1260
1261 <sect2 id="exrecRst">
1262 <title>Reset</title>
1263
1264 <para>
1265 During EH, resetting is necessary in the following cases.
1266 </para>
1267
1268 <itemizedlist>
1269
1270 <listitem>
1271 <para>
1272 HSM is in unknown or invalid state
1273 </para>
1274 </listitem>
1275
1276 <listitem>
1277 <para>
1278 HBA is in unknown or invalid state
1279 </para>
1280 </listitem>
1281
1282 <listitem>
1283 <para>
1284 EH needs to make HBA/device forget about in-flight commands
1285 </para>
1286 </listitem>
1287
1288 <listitem>
1289 <para>
1290 HBA/device behaves weirdly
1291 </para>
1292 </listitem>
1293
1294 </itemizedlist>
1295
1296 <para>
1297 Resetting during EH might be a good idea regardless of error
1298 condition to improve EH robustness. Whether to reset both or
1299 either one of HBA and device depends on situation but the
1300 following scheme is recommended.
1301 </para>
1302
1303 <itemizedlist>
1304
1305 <listitem>
1306 <para>
1307 When it's known that HBA is in ready state but ATA/ATAPI
1308 device in in unknown state, reset only device.
1309 </para>
1310 </listitem>
1311
1312 <listitem>
1313 <para>
1314 If HBA is in unknown state, reset both HBA and device.
1315 </para>
1316 </listitem>
1317
1318 </itemizedlist>
1319
1320 <para>
1321 HBA resetting is implementation specific. For a controller
1322 complying to taskfile/BMDMA PCI IDE, stopping active DMA
1323 transaction may be sufficient iff BMDMA state is the only HBA
1324 context. But even mostly taskfile/BMDMA PCI IDE complying
1325 controllers may have implementation specific requirements and
1326 mechanism to reset themselves. This must be addressed by
1327 specific drivers.
1328 </para>
1329
1330 <para>
1331 OTOH, ATA/ATAPI standard describes in detail ways to reset
1332 ATA/ATAPI devices.
1333 </para>
1334
1335 <variablelist>
1336
1337 <varlistentry><term>PATA hardware reset</term>
1338 <listitem>
1339 <para>
1340 This is hardware initiated device reset signalled with
1341 asserted PATA RESET- signal. There is no standard way to
1342 initiate hardware reset from software although some
1343 hardware provides registers that allow driver to directly
1344 tweak the RESET- signal.
1345 </para>
1346 </listitem>
1347 </varlistentry>
1348
1349 <varlistentry><term>Software reset</term>
1350 <listitem>
1351 <para>
1352 This is achieved by turning CONTROL SRST bit on for at
1353 least 5us. Both PATA and SATA support it but, in case of
1354 SATA, this may require controller-specific support as the
1355 second Register FIS to clear SRST should be transmitted
1356 while BSY bit is still set. Note that on PATA, this resets
1357 both master and slave devices on a channel.
1358 </para>
1359 </listitem>
1360 </varlistentry>
1361
1362 <varlistentry><term>EXECUTE DEVICE DIAGNOSTIC command</term>
1363 <listitem>
1364 <para>
1365 Although ATA/ATAPI standard doesn't describe exactly, EDD
1366 implies some level of resetting, possibly similar level
1367 with software reset. Host-side EDD protocol can be handled
1368 with normal command processing and most SATA controllers
1369 should be able to handle EDD's just like other commands.
1370 As in software reset, EDD affects both devices on a PATA
1371 bus.
1372 </para>
1373 <para>
1374 Although EDD does reset devices, this doesn't suit error
1375 handling as EDD cannot be issued while BSY is set and it's
1376 unclear how it will act when device is in unknown/weird
1377 state.
1378 </para>
1379 </listitem>
1380 </varlistentry>
1381
1382 <varlistentry><term>ATAPI DEVICE RESET command</term>
1383 <listitem>
1384 <para>
1385 This is very similar to software reset except that reset
1386 can be restricted to the selected device without affecting
1387 the other device sharing the cable.
1388 </para>
1389 </listitem>
1390 </varlistentry>
1391
1392 <varlistentry><term>SATA phy reset</term>
1393 <listitem>
1394 <para>
1395 This is the preferred way of resetting a SATA device. In
1396 effect, it's identical to PATA hardware reset. Note that
1397 this can be done with the standard SCR Control register.
1398 As such, it's usually easier to implement than software
1399 reset.
1400 </para>
1401 </listitem>
1402 </varlistentry>
1403
1404 </variablelist>
1405
1406 <para>
1407 One more thing to consider when resetting devices is that
1408 resetting clears certain configuration parameters and they
1409 need to be set to their previous or newly adjusted values
1410 after reset.
1411 </para>
1412
1413 <para>
1414 Parameters affected are.
1415 </para>
1416
1417 <itemizedlist>
1418
1419 <listitem>
1420 <para>
1421 CHS set up with INITIALIZE DEVICE PARAMETERS (seldomly used)
1422 </para>
1423 </listitem>
1424
1425 <listitem>
1426 <para>
1427 Parameters set with SET FEATURES including transfer mode setting
1428 </para>
1429 </listitem>
1430
1431 <listitem>
1432 <para>
1433 Block count set with SET MULTIPLE MODE
1434 </para>
1435 </listitem>
1436
1437 <listitem>
1438 <para>
1439 Other parameters (SET MAX, MEDIA LOCK...)
1440 </para>
1441 </listitem>
1442
1443 </itemizedlist>
1444
1445 <para>
1446 ATA/ATAPI standard specifies that some parameters must be
1447 maintained across hardware or software reset, but doesn't
1448 strictly specify all of them. Always reconfiguring needed
1449 parameters after reset is required for robustness. Note that
1450 this also applies when resuming from deep sleep (power-off).
1451 </para>
1452
1453 <para>
1454 Also, ATA/ATAPI standard requires that IDENTIFY DEVICE /
1455 IDENTIFY PACKET DEVICE is issued after any configuration
1456 parameter is updated or a hardware reset and the result used
1457 for further operation. OS driver is required to implement
1458 revalidation mechanism to support this.
1459 </para>
1460
1461 </sect2>
1462
1463 <sect2 id="exrecReconf">
1464 <title>Reconfigure transport</title>
1465
1466 <para>
1467 For both PATA and SATA, a lot of corners are cut for cheap
1468 connectors, cables or controllers and it's quite common to see
1469 high transmission error rate. This can be mitigated by
1470 lowering transmission speed.
1471 </para>
1472
1473 <para>
1474 The following is a possible scheme Jeff Garzik suggested.
1475 </para>
1476
1477 <blockquote>
1478 <para>
1479 If more than $N (3?) transmission errors happen in 15 minutes,
1480 </para>
1481 <itemizedlist>
1482 <listitem>
1483 <para>
1484 if SATA, decrease SATA PHY speed. if speed cannot be decreased,
1485 </para>
1486 </listitem>
1487 <listitem>
1488 <para>
1489 decrease UDMA xfer speed. if at UDMA0, switch to PIO4,
1490 </para>
1491 </listitem>
1492 <listitem>
1493 <para>
1494 decrease PIO xfer speed. if at PIO3, complain, but continue
1495 </para>
1496 </listitem>
1497 </itemizedlist>
1498 </blockquote>
1499
1500 </sect2>
1501
1502 </sect1>
1503
1504 </chapter>
1505
434 <chapter id="PiixInt"> 1506 <chapter id="PiixInt">
435 <title>ata_piix Internals</title> 1507 <title>ata_piix Internals</title>
436!Idrivers/scsi/ata_piix.c 1508!Idrivers/scsi/ata_piix.c
diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl
index 705c442c7bf4..15ce0f21e5e0 100644
--- a/Documentation/DocBook/usb.tmpl
+++ b/Documentation/DocBook/usb.tmpl
@@ -291,7 +291,7 @@
291 291
292!Edrivers/usb/core/hcd.c 292!Edrivers/usb/core/hcd.c
293!Edrivers/usb/core/hcd-pci.c 293!Edrivers/usb/core/hcd-pci.c
294!Edrivers/usb/core/buffer.c 294!Idrivers/usb/core/buffer.c
295 </chapter> 295 </chapter>
296 296
297 <chapter> 297 <chapter>
diff --git a/Documentation/DocBook/writing_usb_driver.tmpl b/Documentation/DocBook/writing_usb_driver.tmpl
index 51f3bfb6fb6e..008a341234d0 100644
--- a/Documentation/DocBook/writing_usb_driver.tmpl
+++ b/Documentation/DocBook/writing_usb_driver.tmpl
@@ -345,8 +345,7 @@ if (!retval) {
345 <programlisting> 345 <programlisting>
346static inline void skel_delete (struct usb_skel *dev) 346static inline void skel_delete (struct usb_skel *dev)
347{ 347{
348 if (dev->bulk_in_buffer != NULL) 348 kfree (dev->bulk_in_buffer);
349 kfree (dev->bulk_in_buffer);
350 if (dev->bulk_out_buffer != NULL) 349 if (dev->bulk_out_buffer != NULL)
351 usb_buffer_free (dev->udev, dev->bulk_out_size, 350 usb_buffer_free (dev->udev, dev->bulk_out_size,
352 dev->bulk_out_buffer, 351 dev->bulk_out_buffer,
diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
index 6dd274d7e1cf..2d65c2182161 100644
--- a/Documentation/block/biodoc.txt
+++ b/Documentation/block/biodoc.txt
@@ -906,9 +906,20 @@ Aside:
906 906
907 907
9084. The I/O scheduler 9084. The I/O scheduler
909I/O schedulers are now per queue. They should be runtime switchable and modular 909I/O scheduler, a.k.a. elevator, is implemented in two layers. Generic dispatch
910but aren't yet. Jens has most bits to do this, but the sysfs implementation is 910queue and specific I/O schedulers. Unless stated otherwise, elevator is used
911missing. 911to refer to both parts and I/O scheduler to specific I/O schedulers.
912
913Block layer implements generic dispatch queue in ll_rw_blk.c and elevator.c.
914The generic dispatch queue is responsible for properly ordering barrier
915requests, requeueing, handling non-fs requests and all other subtleties.
916
917Specific I/O schedulers are responsible for ordering normal filesystem
918requests. They can also choose to delay certain requests to improve
919throughput or whatever purpose. As the plural form indicates, there are
920multiple I/O schedulers. They can be built as modules but at least one should
921be built inside the kernel. Each queue can choose different one and can also
922change to another one dynamically.
912 923
913A block layer call to the i/o scheduler follows the convention elv_xxx(). This 924A block layer call to the i/o scheduler follows the convention elv_xxx(). This
914calls elevator_xxx_fn in the elevator switch (drivers/block/elevator.c). Oh, 925calls elevator_xxx_fn in the elevator switch (drivers/block/elevator.c). Oh,
@@ -921,44 +932,36 @@ keeping work.
921The functions an elevator may implement are: (* are mandatory) 932The functions an elevator may implement are: (* are mandatory)
922elevator_merge_fn called to query requests for merge with a bio 933elevator_merge_fn called to query requests for merge with a bio
923 934
924elevator_merge_req_fn " " " with another request 935elevator_merge_req_fn called when two requests get merged. the one
936 which gets merged into the other one will be
937 never seen by I/O scheduler again. IOW, after
938 being merged, the request is gone.
925 939
926elevator_merged_fn called when a request in the scheduler has been 940elevator_merged_fn called when a request in the scheduler has been
927 involved in a merge. It is used in the deadline 941 involved in a merge. It is used in the deadline
928 scheduler for example, to reposition the request 942 scheduler for example, to reposition the request
929 if its sorting order has changed. 943 if its sorting order has changed.
930 944
931*elevator_next_req_fn returns the next scheduled request, or NULL 945elevator_dispatch_fn fills the dispatch queue with ready requests.
932 if there are none (or none are ready). 946 I/O schedulers are free to postpone requests by
947 not filling the dispatch queue unless @force
948 is non-zero. Once dispatched, I/O schedulers
949 are not allowed to manipulate the requests -
950 they belong to generic dispatch queue.
933 951
934*elevator_add_req_fn called to add a new request into the scheduler 952elevator_add_req_fn called to add a new request into the scheduler
935 953
936elevator_queue_empty_fn returns true if the merge queue is empty. 954elevator_queue_empty_fn returns true if the merge queue is empty.
937 Drivers shouldn't use this, but rather check 955 Drivers shouldn't use this, but rather check
938 if elv_next_request is NULL (without losing the 956 if elv_next_request is NULL (without losing the
939 request if one exists!) 957 request if one exists!)
940 958
941elevator_remove_req_fn This is called when a driver claims ownership of
942 the target request - it now belongs to the
943 driver. It must not be modified or merged.
944 Drivers must not lose the request! A subsequent
945 call of elevator_next_req_fn must return the
946 _next_ request.
947
948elevator_requeue_req_fn called to add a request to the scheduler. This
949 is used when the request has alrnadebeen
950 returned by elv_next_request, but hasn't
951 completed. If this is not implemented then
952 elevator_add_req_fn is called instead.
953
954elevator_former_req_fn 959elevator_former_req_fn
955elevator_latter_req_fn These return the request before or after the 960elevator_latter_req_fn These return the request before or after the
956 one specified in disk sort order. Used by the 961 one specified in disk sort order. Used by the
957 block layer to find merge possibilities. 962 block layer to find merge possibilities.
958 963
959elevator_completed_req_fn called when a request is completed. This might 964elevator_completed_req_fn called when a request is completed.
960 come about due to being merged with another or
961 when the device completes the request.
962 965
963elevator_may_queue_fn returns true if the scheduler wants to allow the 966elevator_may_queue_fn returns true if the scheduler wants to allow the
964 current context to queue a new request even if 967 current context to queue a new request even if
@@ -967,13 +970,33 @@ elevator_may_queue_fn returns true if the scheduler wants to allow the
967 970
968elevator_set_req_fn 971elevator_set_req_fn
969elevator_put_req_fn Must be used to allocate and free any elevator 972elevator_put_req_fn Must be used to allocate and free any elevator
970 specific storate for a request. 973 specific storage for a request.
974
975elevator_activate_req_fn Called when device driver first sees a request.
976 I/O schedulers can use this callback to
977 determine when actual execution of a request
978 starts.
979elevator_deactivate_req_fn Called when device driver decides to delay
980 a request by requeueing it.
971 981
972elevator_init_fn 982elevator_init_fn
973elevator_exit_fn Allocate and free any elevator specific storage 983elevator_exit_fn Allocate and free any elevator specific storage
974 for a queue. 984 for a queue.
975 985
9764.2 I/O scheduler implementation 9864.2 Request flows seen by I/O schedulers
987All requests seens by I/O schedulers strictly follow one of the following three
988flows.
989
990 set_req_fn ->
991
992 i. add_req_fn -> (merged_fn ->)* -> dispatch_fn -> activate_req_fn ->
993 (deactivate_req_fn -> activate_req_fn ->)* -> completed_req_fn
994 ii. add_req_fn -> (merged_fn ->)* -> merge_req_fn
995 iii. [none]
996
997 -> put_req_fn
998
9994.3 I/O scheduler implementation
977The generic i/o scheduler algorithm attempts to sort/merge/batch requests for 1000The generic i/o scheduler algorithm attempts to sort/merge/batch requests for
978optimal disk scan and request servicing performance (based on generic 1001optimal disk scan and request servicing performance (based on generic
979principles and device capabilities), optimized for: 1002principles and device capabilities), optimized for:
@@ -993,18 +1016,7 @@ request in sort order to prevent binary tree lookups.
993This arrangement is not a generic block layer characteristic however, so 1016This arrangement is not a generic block layer characteristic however, so
994elevators may implement queues as they please. 1017elevators may implement queues as they please.
995 1018
996ii. Last merge hint 1019ii. Merge hash
997The last merge hint is part of the generic queue layer. I/O schedulers must do
998some management on it. For the most part, the most important thing is to make
999sure q->last_merge is cleared (set to NULL) when the request on it is no longer
1000a candidate for merging (for example if it has been sent to the driver).
1001
1002The last merge performed is cached as a hint for the subsequent request. If
1003sequential data is being submitted, the hint is used to perform merges without
1004any scanning. This is not sufficient when there are multiple processes doing
1005I/O though, so a "merge hash" is used by some schedulers.
1006
1007iii. Merge hash
1008AS and deadline use a hash table indexed by the last sector of a request. This 1020AS and deadline use a hash table indexed by the last sector of a request. This
1009enables merging code to quickly look up "back merge" candidates, even when 1021enables merging code to quickly look up "back merge" candidates, even when
1010multiple I/O streams are being performed at once on one disk. 1022multiple I/O streams are being performed at once on one disk.
@@ -1013,29 +1025,8 @@ multiple I/O streams are being performed at once on one disk.
1013are far less common than "back merges" due to the nature of most I/O patterns. 1025are far less common than "back merges" due to the nature of most I/O patterns.
1014Front merges are handled by the binary trees in AS and deadline schedulers. 1026Front merges are handled by the binary trees in AS and deadline schedulers.
1015 1027
1016iv. Handling barrier cases 1028iii. Plugging the queue to batch requests in anticipation of opportunities for
1017A request with flags REQ_HARDBARRIER or REQ_SOFTBARRIER must not be ordered 1029 merge/sort optimizations
1018around. That is, they must be processed after all older requests, and before
1019any newer ones. This includes merges!
1020
1021In AS and deadline schedulers, barriers have the effect of flushing the reorder
1022queue. The performance cost of this will vary from nothing to a lot depending
1023on i/o patterns and device characteristics. Obviously they won't improve
1024performance, so their use should be kept to a minimum.
1025
1026v. Handling insertion position directives
1027A request may be inserted with a position directive. The directives are one of
1028ELEVATOR_INSERT_BACK, ELEVATOR_INSERT_FRONT, ELEVATOR_INSERT_SORT.
1029
1030ELEVATOR_INSERT_SORT is a general directive for non-barrier requests.
1031ELEVATOR_INSERT_BACK is used to insert a barrier to the back of the queue.
1032ELEVATOR_INSERT_FRONT is used to insert a barrier to the front of the queue, and
1033overrides the ordering requested by any previous barriers. In practice this is
1034harmless and required, because it is used for SCSI requeueing. This does not
1035require flushing the reorder queue, so does not impose a performance penalty.
1036
1037vi. Plugging the queue to batch requests in anticipation of opportunities for
1038 merge/sort optimizations
1039 1030
1040This is just the same as in 2.4 so far, though per-device unplugging 1031This is just the same as in 2.4 so far, though per-device unplugging
1041support is anticipated for 2.5. Also with a priority-based i/o scheduler, 1032support is anticipated for 2.5. Also with a priority-based i/o scheduler,
@@ -1069,7 +1060,7 @@ Aside:
1069 blk_kick_queue() to unplug a specific queue (right away ?) 1060 blk_kick_queue() to unplug a specific queue (right away ?)
1070 or optionally, all queues, is in the plan. 1061 or optionally, all queues, is in the plan.
1071 1062
10724.3 I/O contexts 10634.4 I/O contexts
1073I/O contexts provide a dynamically allocated per process data area. They may 1064I/O contexts provide a dynamically allocated per process data area. They may
1074be used in I/O schedulers, and in the block layer (could be used for IO statis, 1065be used in I/O schedulers, and in the block layer (could be used for IO statis,
1075priorities for example). See *io_context in drivers/block/ll_rw_blk.c, and 1066priorities for example). See *io_context in drivers/block/ll_rw_blk.c, and
diff --git a/Documentation/driver-model/driver.txt b/Documentation/driver-model/driver.txt
index fabaca1ab1b0..59806c9761f7 100644
--- a/Documentation/driver-model/driver.txt
+++ b/Documentation/driver-model/driver.txt
@@ -14,8 +14,8 @@ struct device_driver {
14 int (*probe) (struct device * dev); 14 int (*probe) (struct device * dev);
15 int (*remove) (struct device * dev); 15 int (*remove) (struct device * dev);
16 16
17 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 17 int (*suspend) (struct device * dev, pm_message_t state);
18 int (*resume) (struct device * dev, u32 level); 18 int (*resume) (struct device * dev);
19}; 19};
20 20
21 21
@@ -194,69 +194,13 @@ device; i.e. anything in the device's driver_data field.
194If the device is still present, it should quiesce the device and place 194If the device is still present, it should quiesce the device and place
195it into a supported low-power state. 195it into a supported low-power state.
196 196
197 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 197 int (*suspend) (struct device * dev, pm_message_t state);
198 198
199suspend is called to put the device in a low power state. There are 199suspend is called to put the device in a low power state.
200several stages to successfully suspending a device, which is denoted in
201the @level parameter. Breaking the suspend transition into several
202stages affords the platform flexibility in performing device power
203management based on the requirements of the system and the
204user-defined policy.
205 200
206SUSPEND_NOTIFY notifies the device that a suspend transition is about 201 int (*resume) (struct device * dev);
207to happen. This happens on system power state transitions to verify
208that all devices can successfully suspend.
209 202
210A driver may choose to fail on this call, which should cause the 203Resume is used to bring a device back from a low power state.
211entire suspend transition to fail. A driver should fail only if it
212knows that the device will not be able to be resumed properly when the
213system wakes up again. It could also fail if it somehow determines it
214is in the middle of an operation too important to stop.
215
216SUSPEND_DISABLE tells the device to stop I/O transactions. When it
217stops transactions, or what it should do with unfinished transactions
218is a policy of the driver. After this call, the driver should not
219accept any other I/O requests.
220
221SUSPEND_SAVE_STATE tells the device to save the context of the
222hardware. This includes any bus-specific hardware state and
223device-specific hardware state. A pointer to this saved state can be
224stored in the device's saved_state field.
225
226SUSPEND_POWER_DOWN tells the driver to place the device in the low
227power state requested.
228
229Whether suspend is called with a given level is a policy of the
230platform. Some levels may be omitted; drivers must not assume the
231reception of any level. However, all levels must be called in the
232order above; i.e. notification will always come before disabling;
233disabling the device will come before suspending the device.
234
235All calls are made with interrupts enabled, except for the
236SUSPEND_POWER_DOWN level.
237
238 int (*resume) (struct device * dev, u32 level);
239
240Resume is used to bring a device back from a low power state. Like the
241suspend transition, it happens in several stages.
242
243RESUME_POWER_ON tells the driver to set the power state to the state
244before the suspend call (The device could have already been in a low
245power state before the suspend call to put in a lower power state).
246
247RESUME_RESTORE_STATE tells the driver to restore the state saved by
248the SUSPEND_SAVE_STATE suspend call.
249
250RESUME_ENABLE tells the driver to start accepting I/O transactions
251again. Depending on driver policy, the device may already have pending
252I/O requests.
253
254RESUME_POWER_ON is called with interrupts disabled. The other resume
255levels are called with interrupts enabled.
256
257As with the various suspend stages, the driver must not assume that
258any other resume calls have been or will be made. Each call should be
259self-contained and not dependent on any external state.
260 204
261 205
262Attributes 206Attributes
diff --git a/Documentation/driver-model/porting.txt b/Documentation/driver-model/porting.txt
index ff2fef2107f0..98b233cb8b36 100644
--- a/Documentation/driver-model/porting.txt
+++ b/Documentation/driver-model/porting.txt
@@ -350,7 +350,7 @@ When a driver is registered, the bus's list of devices is iterated
350over. bus->match() is called for each device that is not already 350over. bus->match() is called for each device that is not already
351claimed by a driver. 351claimed by a driver.
352 352
353When a device is successfully bound to a device, device->driver is 353When a device is successfully bound to a driver, device->driver is
354set, the device is added to a per-driver list of devices, and a 354set, the device is added to a per-driver list of devices, and a
355symlink is created in the driver's sysfs directory that points to the 355symlink is created in the driver's sysfs directory that points to the
356device's physical directory: 356device's physical directory:
diff --git a/Documentation/hwmon/it87 b/Documentation/hwmon/it87
index 0d0195040d88..7f42e441c645 100644
--- a/Documentation/hwmon/it87
+++ b/Documentation/hwmon/it87
@@ -4,18 +4,18 @@ Kernel driver it87
4Supported chips: 4Supported chips:
5 * IT8705F 5 * IT8705F
6 Prefix: 'it87' 6 Prefix: 'it87'
7 Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) 7 Addresses scanned: from Super I/O config space (8 I/O ports)
8 Datasheet: Publicly available at the ITE website 8 Datasheet: Publicly available at the ITE website
9 http://www.ite.com.tw/ 9 http://www.ite.com.tw/
10 * IT8712F 10 * IT8712F
11 Prefix: 'it8712' 11 Prefix: 'it8712'
12 Addresses scanned: I2C 0x28 - 0x2f 12 Addresses scanned: I2C 0x28 - 0x2f
13 from Super I/O config space, or default ISA 0x290 (8 I/O ports) 13 from Super I/O config space (8 I/O ports)
14 Datasheet: Publicly available at the ITE website 14 Datasheet: Publicly available at the ITE website
15 http://www.ite.com.tw/ 15 http://www.ite.com.tw/
16 * SiS950 [clone of IT8705F] 16 * SiS950 [clone of IT8705F]
17 Prefix: 'sis950' 17 Prefix: 'it87'
18 Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) 18 Addresses scanned: from Super I/O config space (8 I/O ports)
19 Datasheet: No longer be available 19 Datasheet: No longer be available
20 20
21Author: Christophe Gauthron <chrisg@0-in.com> 21Author: Christophe Gauthron <chrisg@0-in.com>
diff --git a/Documentation/hwmon/lm90 b/Documentation/hwmon/lm90
index 2c4cf39471f4..438cb24cee5b 100644
--- a/Documentation/hwmon/lm90
+++ b/Documentation/hwmon/lm90
@@ -24,14 +24,14 @@ Supported chips:
24 http://www.national.com/pf/LM/LM86.html 24 http://www.national.com/pf/LM/LM86.html
25 * Analog Devices ADM1032 25 * Analog Devices ADM1032
26 Prefix: 'adm1032' 26 Prefix: 'adm1032'
27 Addresses scanned: I2C 0x4c 27 Addresses scanned: I2C 0x4c and 0x4d
28 Datasheet: Publicly available at the Analog Devices website 28 Datasheet: Publicly available at the Analog Devices website
29 http://products.analog.com/products/info.asp?product=ADM1032 29 http://www.analog.com/en/prod/0,2877,ADM1032,00.html
30 * Analog Devices ADT7461 30 * Analog Devices ADT7461
31 Prefix: 'adt7461' 31 Prefix: 'adt7461'
32 Addresses scanned: I2C 0x4c 32 Addresses scanned: I2C 0x4c and 0x4d
33 Datasheet: Publicly available at the Analog Devices website 33 Datasheet: Publicly available at the Analog Devices website
34 http://products.analog.com/products/info.asp?product=ADT7461 34 http://www.analog.com/en/prod/0,2877,ADT7461,00.html
35 Note: Only if in ADM1032 compatibility mode 35 Note: Only if in ADM1032 compatibility mode
36 * Maxim MAX6657 36 * Maxim MAX6657
37 Prefix: 'max6657' 37 Prefix: 'max6657'
@@ -71,8 +71,8 @@ increased resolution of the remote temperature measurement.
71 71
72The different chipsets of the family are not strictly identical, although 72The different chipsets of the family are not strictly identical, although
73very similar. This driver doesn't handle any specific feature for now, 73very similar. This driver doesn't handle any specific feature for now,
74but could if there ever was a need for it. For reference, here comes a 74with the exception of SMBus PEC. For reference, here comes a non-exhaustive
75non-exhaustive list of specific features: 75list of specific features:
76 76
77LM90: 77LM90:
78 * Filter and alert configuration register at 0xBF. 78 * Filter and alert configuration register at 0xBF.
@@ -91,6 +91,7 @@ ADM1032:
91 * Conversion averaging. 91 * Conversion averaging.
92 * Up to 64 conversions/s. 92 * Up to 64 conversions/s.
93 * ALERT is triggered by open remote sensor. 93 * ALERT is triggered by open remote sensor.
94 * SMBus PEC support for Write Byte and Receive Byte transactions.
94 95
95ADT7461 96ADT7461
96 * Extended temperature range (breaks compatibility) 97 * Extended temperature range (breaks compatibility)
@@ -119,3 +120,37 @@ The lm90 driver will not update its values more frequently than every
119other second; reading them more often will do no harm, but will return 120other second; reading them more often will do no harm, but will return
120'old' values. 121'old' values.
121 122
123PEC Support
124-----------
125
126The ADM1032 is the only chip of the family which supports PEC. It does
127not support PEC on all transactions though, so some care must be taken.
128
129When reading a register value, the PEC byte is computed and sent by the
130ADM1032 chip. However, in the case of a combined transaction (SMBus Read
131Byte), the ADM1032 computes the CRC value over only the second half of
132the message rather than its entirety, because it thinks the first half
133of the message belongs to a different transaction. As a result, the CRC
134value differs from what the SMBus master expects, and all reads fail.
135
136For this reason, the lm90 driver will enable PEC for the ADM1032 only if
137the bus supports the SMBus Send Byte and Receive Byte transaction types.
138These transactions will be used to read register values, instead of
139SMBus Read Byte, and PEC will work properly.
140
141Additionally, the ADM1032 doesn't support SMBus Send Byte with PEC.
142Instead, it will try to write the PEC value to the register (because the
143SMBus Send Byte transaction with PEC is similar to a Write Byte transaction
144without PEC), which is not what we want. Thus, PEC is explicitely disabled
145on SMBus Send Byte transactions in the lm90 driver.
146
147PEC on byte data transactions represents a significant increase in bandwidth
148usage (+33% for writes, +25% for reads) in normal conditions. With the need
149to use two SMBus transaction for reads, this overhead jumps to +50%. Worse,
150two transactions will typically mean twice as much delay waiting for
151transaction completion, effectively doubling the register cache refresh time.
152I guess reliability comes at a price, but it's quite expensive this time.
153
154So, as not everyone might enjoy the slowdown, PEC can be disabled through
155sysfs. Just write 0 to the "pec" file and PEC will be disabled. Write 1
156to that file to enable PEC again.
diff --git a/Documentation/hwmon/smsc47b397 b/Documentation/hwmon/smsc47b397
index da9d80c96432..20682f15ae41 100644
--- a/Documentation/hwmon/smsc47b397
+++ b/Documentation/hwmon/smsc47b397
@@ -3,6 +3,7 @@ Kernel driver smsc47b397
3 3
4Supported chips: 4Supported chips:
5 * SMSC LPC47B397-NC 5 * SMSC LPC47B397-NC
6 * SMSC SCH5307-NS
6 Prefix: 'smsc47b397' 7 Prefix: 'smsc47b397'
7 Addresses scanned: none, address read from Super I/O config space 8 Addresses scanned: none, address read from Super I/O config space
8 Datasheet: In this file 9 Datasheet: In this file
@@ -12,11 +13,14 @@ Authors: Mark M. Hoffman <mhoffman@lightlink.com>
12 13
13November 23, 2004 14November 23, 2004
14 15
15The following specification describes the SMSC LPC47B397-NC sensor chip 16The following specification describes the SMSC LPC47B397-NC[1] sensor chip
16(for which there is no public datasheet available). This document was 17(for which there is no public datasheet available). This document was
17provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected 18provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected
18by Mark M. Hoffman <mhoffman@lightlink.com>. 19by Mark M. Hoffman <mhoffman@lightlink.com>.
19 20
21[1] And SMSC SCH5307-NS, which has a different device ID but is otherwise
22compatible.
23
20* * * * * 24* * * * *
21 25
22Methods for detecting the HP SIO and reading the thermal data on a dc7100. 26Methods for detecting the HP SIO and reading the thermal data on a dc7100.
@@ -127,7 +131,7 @@ OUT DX,AL
127The registers of interest for identifying the SIO on the dc7100 are Device ID 131The registers of interest for identifying the SIO on the dc7100 are Device ID
128(0x20) and Device Rev (0x21). 132(0x20) and Device Rev (0x21).
129 133
130The Device ID will read 0X6F 134The Device ID will read 0x6F (for SCH5307-NS, 0x81)
131The Device Rev currently reads 0x01 135The Device Rev currently reads 0x01
132 136
133Obtaining the HWM Base Address. 137Obtaining the HWM Base Address.
diff --git a/Documentation/hwmon/smsc47m1 b/Documentation/hwmon/smsc47m1
index 34e6478c1425..c15bbe68264e 100644
--- a/Documentation/hwmon/smsc47m1
+++ b/Documentation/hwmon/smsc47m1
@@ -12,6 +12,10 @@ Supported chips:
12 http://www.smsc.com/main/datasheets/47m14x.pdf 12 http://www.smsc.com/main/datasheets/47m14x.pdf
13 http://www.smsc.com/main/tools/discontinued/47m15x.pdf 13 http://www.smsc.com/main/tools/discontinued/47m15x.pdf
14 http://www.smsc.com/main/datasheets/47m192.pdf 14 http://www.smsc.com/main/datasheets/47m192.pdf
15 * SMSC LPC47M997
16 Addresses scanned: none, address read from Super I/O config space
17 Prefix: 'smsc47m1'
18 Datasheet: none
15 19
16Authors: 20Authors:
17 Mark D. Studebaker <mdsxyz123@yahoo.com>, 21 Mark D. Studebaker <mdsxyz123@yahoo.com>,
@@ -30,6 +34,9 @@ The 47M15x and 47M192 chips contain a full 'hardware monitoring block'
30in addition to the fan monitoring and control. The hardware monitoring 34in addition to the fan monitoring and control. The hardware monitoring
31block is not supported by the driver. 35block is not supported by the driver.
32 36
37No documentation is available for the 47M997, but it has the same device
38ID as the 47M15x and 47M192 chips and seems to be compatible.
39
33Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 40Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit. Fan 41triggered if the rotation speed has dropped below a programmable limit. Fan
35readings can be divided by a programmable divider (1, 2, 4 or 8) to give 42readings can be divided by a programmable divider (1, 2, 4 or 8) to give
diff --git a/Documentation/hwmon/sysfs-interface b/Documentation/hwmon/sysfs-interface
index 346400519d0d..764cdc5480e7 100644
--- a/Documentation/hwmon/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
@@ -272,3 +272,6 @@ beep_mask Bitmask for beep.
272 272
273eeprom Raw EEPROM data in binary form. 273eeprom Raw EEPROM data in binary form.
274 Read only. 274 Read only.
275
276pec Enable or disable PEC (SMBus only)
277 Read/Write
diff --git a/Documentation/hwmon/via686a b/Documentation/hwmon/via686a
index b82014cb7c53..a936fb3824b2 100644
--- a/Documentation/hwmon/via686a
+++ b/Documentation/hwmon/via686a
@@ -18,8 +18,9 @@ Authors:
18Module Parameters 18Module Parameters
19----------------- 19-----------------
20 20
21force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards 21force_addr=0xaddr Set the I/O base address. Useful for boards that
22 that don't set the address in the BIOS. Does not do a 22 don't set the address in the BIOS. Look for a BIOS
23 upgrade before resorting to this. Does not do a
23 PCI force; the via686a must still be present in lspci. 24 PCI force; the via686a must still be present in lspci.
24 Don't use this unless the driver complains that the 25 Don't use this unless the driver complains that the
25 base address is not set. 26 base address is not set.
@@ -63,3 +64,15 @@ miss once-only alarms.
63 64
64The driver only updates its values each 1.5 seconds; reading it more often 65The driver only updates its values each 1.5 seconds; reading it more often
65will do no harm, but will return 'old' values. 66will do no harm, but will return 'old' values.
67
68Known Issues
69------------
70
71This driver handles sensors integrated in some VIA south bridges. It is
72possible that a motherboard maker used a VT82C686A/B chip as part of a
73product design but was not interested in its hardware monitoring features,
74in which case the sensor inputs will not be wired. This is the case of
75the Asus K7V, A7V and A7V133 motherboards, to name only a few of them.
76So, if you need the force_addr parameter, and end up with values which
77don't seem to make any sense, don't look any further: your chip is simply
78not wired for hardware monitoring.
diff --git a/Documentation/i2c/busses/i2c-i810 b/Documentation/i2c/busses/i2c-i810
index 0544eb332887..83c3b9743c3c 100644
--- a/Documentation/i2c/busses/i2c-i810
+++ b/Documentation/i2c/busses/i2c-i810
@@ -2,6 +2,7 @@ Kernel driver i2c-i810
2 2
3Supported adapters: 3Supported adapters:
4 * Intel 82810, 82810-DC100, 82810E, and 82815 (GMCH) 4 * Intel 82810, 82810-DC100, 82810E, and 82815 (GMCH)
5 * Intel 82845G (GMCH)
5 6
6Authors: 7Authors:
7 Frodo Looijaard <frodol@dds.nl>, 8 Frodo Looijaard <frodol@dds.nl>,
diff --git a/Documentation/i2c/busses/i2c-viapro b/Documentation/i2c/busses/i2c-viapro
index 702f5ac68c09..9363b8bd6109 100644
--- a/Documentation/i2c/busses/i2c-viapro
+++ b/Documentation/i2c/busses/i2c-viapro
@@ -4,17 +4,18 @@ Supported adapters:
4 * VIA Technologies, Inc. VT82C596A/B 4 * VIA Technologies, Inc. VT82C596A/B
5 Datasheet: Sometimes available at the VIA website 5 Datasheet: Sometimes available at the VIA website
6 6
7 * VIA Technologies, Inc. VT82C686A/B 7 * VIA Technologies, Inc. VT82C686A/B
8 Datasheet: Sometimes available at the VIA website 8 Datasheet: Sometimes available at the VIA website
9 9
10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A, VT8235, VT8237 10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A, VT8235, VT8237
11 Datasheet: available on request from Via 11 Datasheet: available on request from Via
12 12
13Authors: 13Authors:
14 Frodo Looijaard <frodol@dds.nl>, 14 Frodo Looijaard <frodol@dds.nl>,
15 Philip Edelbrock <phil@netroedge.com>, 15 Philip Edelbrock <phil@netroedge.com>,
16 Kyösti Mälkki <kmalkki@cc.hut.fi>, 16 Kyösti Mälkki <kmalkki@cc.hut.fi>,
17 Mark D. Studebaker <mdsxyz123@yahoo.com> 17 Mark D. Studebaker <mdsxyz123@yahoo.com>,
18 Jean Delvare <khali@linux-fr.org>
18 19
19Module Parameters 20Module Parameters
20----------------- 21-----------------
@@ -28,20 +29,22 @@ Description
28----------- 29-----------
29 30
30i2c-viapro is a true SMBus host driver for motherboards with one of the 31i2c-viapro is a true SMBus host driver for motherboards with one of the
31supported VIA southbridges. 32supported VIA south bridges.
32 33
33Your lspci -n listing must show one of these : 34Your lspci -n listing must show one of these :
34 35
35 device 1106:3050 (VT82C596 function 3) 36 device 1106:3050 (VT82C596A function 3)
36 device 1106:3051 (VT82C596 function 3) 37 device 1106:3051 (VT82C596B function 3)
37 device 1106:3057 (VT82C686 function 4) 38 device 1106:3057 (VT82C686 function 4)
38 device 1106:3074 (VT8233) 39 device 1106:3074 (VT8233)
39 device 1106:3147 (VT8233A) 40 device 1106:3147 (VT8233A)
40 device 1106:8235 (VT8231) 41 device 1106:8235 (VT8231 function 4)
41 devide 1106:3177 (VT8235) 42 device 1106:3177 (VT8235)
42 devide 1106:3227 (VT8237) 43 device 1106:3227 (VT8237R)
43 44
44If none of these show up, you should look in the BIOS for settings like 45If none of these show up, you should look in the BIOS for settings like
45enable ACPI / SMBus or even USB. 46enable ACPI / SMBus or even USB.
46 47
47 48Except for the oldest chips (VT82C596A/B, VT82C686A and most probably
49VT8231), this driver supports I2C block transactions. Such transactions
50are mainly useful to read from and write to EEPROMs.
diff --git a/Documentation/i2c/chips/x1205 b/Documentation/i2c/chips/x1205
new file mode 100644
index 000000000000..09407c991fe5
--- /dev/null
+++ b/Documentation/i2c/chips/x1205
@@ -0,0 +1,38 @@
1Kernel driver x1205
2===================
3
4Supported chips:
5 * Xicor X1205 RTC
6 Prefix: 'x1205'
7 Addresses scanned: none
8 Datasheet: http://www.intersil.com/cda/deviceinfo/0,1477,X1205,00.html
9
10Authors:
11 Karen Spearel <kas11@tampabay.rr.com>,
12 Alessandro Zummo <a.zummo@towertech.it>
13
14Description
15-----------
16
17This module aims to provide complete access to the Xicor X1205 RTC.
18Recently Xicor has merged with Intersil, but the chip is
19still sold under the Xicor brand.
20
21This chip is located at address 0x6f and uses a 2-byte register addressing.
22Two bytes need to be written to read a single register, while most
23other chips just require one and take the second one as the data
24to be written. To prevent corrupting unknown chips, the user must
25explicitely set the probe parameter.
26
27example:
28
29modprobe x1205 probe=0,0x6f
30
31The module supports one more option, hctosys, which is used to set the
32software clock from the x1205. On systems where the x1205 is the
33only hardware rtc, this parameter could be used to achieve a correct
34date/time earlier in the system boot sequence.
35
36example:
37
38modprobe x1205 probe=0,0x6f hctosys=1
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index 41ffefbdc60c..60cca249e452 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -17,9 +17,10 @@ For the most up-to-date list of functionality constants, please check
17 I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus 17 I2C_FUNC_I2C Plain i2c-level commands (Pure SMBus
18 adapters typically can not do these) 18 adapters typically can not do these)
19 I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions 19 I2C_FUNC_10BIT_ADDR Handles the 10-bit address extensions
20 I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_REV_DIR_ADDR, 20 I2C_FUNC_PROTOCOL_MANGLING Knows about the I2C_M_IGNORE_NAK,
21 I2C_M_REV_DIR_ADDR and I2C_M_REV_DIR_NOSTART 21 I2C_M_REV_DIR_ADDR, I2C_M_NOSTART and
22 flags (which modify the i2c protocol!) 22 I2C_M_NO_RD_ACK flags (which modify the
23 I2C protocol!)
23 I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command 24 I2C_FUNC_SMBUS_QUICK Handles the SMBus write_quick command
24 I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command 25 I2C_FUNC_SMBUS_READ_BYTE Handles the SMBus read_byte command
25 I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command 26 I2C_FUNC_SMBUS_WRITE_BYTE Handles the SMBus write_byte command
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index 4849dfd6961c..184fac2377aa 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -82,7 +82,7 @@ Technical changes:
82 exit and exit_free. For i2c+isa drivers, labels should be named 82 exit and exit_free. For i2c+isa drivers, labels should be named
83 ERROR0, ERROR1 and ERROR2. Don't forget to properly set err before 83 ERROR0, ERROR1 and ERROR2. Don't forget to properly set err before
84 jumping to error labels. By the way, labels should be left-aligned. 84 jumping to error labels. By the way, labels should be left-aligned.
85 Use memset to fill the client and data area with 0x00. 85 Use kzalloc instead of kmalloc.
86 Use i2c_set_clientdata to set the client data (as opposed to 86 Use i2c_set_clientdata to set the client data (as opposed to
87 a direct access to client->data). 87 a direct access to client->data).
88 Use strlcpy instead of strcpy to copy the client name. 88 Use strlcpy instead of strcpy to copy the client name.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 077275722a7c..e94d9c6cc522 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -33,8 +33,8 @@ static struct i2c_driver foo_driver = {
33 .command = &foo_command /* may be NULL */ 33 .command = &foo_command /* may be NULL */
34} 34}
35 35
36The name can be chosen freely, and may be upto 40 characters long. Please 36The name field must match the driver name, including the case. It must not
37use something descriptive here. 37contain spaces, and may be up to 31 characters long.
38 38
39Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This 39Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
40means that your driver will be notified when new adapters are found. 40means that your driver will be notified when new adapters are found.
@@ -43,9 +43,6 @@ This is almost always what you want.
43All other fields are for call-back functions which will be explained 43All other fields are for call-back functions which will be explained
44below. 44below.
45 45
46There use to be two additional fields in this structure, inc_use et dec_use,
47for module usage count, but these fields were obsoleted and removed.
48
49 46
50Extra client data 47Extra client data
51================= 48=================
@@ -58,6 +55,7 @@ be very useful.
58An example structure is below. 55An example structure is below.
59 56
60 struct foo_data { 57 struct foo_data {
58 struct i2c_client client;
61 struct semaphore lock; /* For ISA access in `sensors' drivers. */ 59 struct semaphore lock; /* For ISA access in `sensors' drivers. */
62 int sysctl_id; /* To keep the /proc directory entry for 60 int sysctl_id; /* To keep the /proc directory entry for
63 `sensors' drivers. */ 61 `sensors' drivers. */
@@ -310,22 +308,15 @@ For now, you can ignore the `flags' parameter. It is there for future use.
310 client structure, even though we cannot fill it completely yet. 308 client structure, even though we cannot fill it completely yet.
311 But it allows us to access several i2c functions safely */ 309 But it allows us to access several i2c functions safely */
312 310
313 /* Note that we reserve some space for foo_data too. If you don't 311 if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) {
314 need it, remove it. We do it here to help to lessen memory
315 fragmentation. */
316 if (! (new_client = kmalloc(sizeof(struct i2c_client) +
317 sizeof(struct foo_data),
318 GFP_KERNEL))) {
319 err = -ENOMEM; 312 err = -ENOMEM;
320 goto ERROR0; 313 goto ERROR0;
321 } 314 }
322 315
323 /* This is tricky, but it will set the data to the right value. */ 316 new_client = &data->client;
324 client->data = new_client + 1; 317 i2c_set_clientdata(new_client, data);
325 data = (struct foo_data *) (client->data);
326 318
327 new_client->addr = address; 319 new_client->addr = address;
328 new_client->data = data;
329 new_client->adapter = adapter; 320 new_client->adapter = adapter;
330 new_client->driver = &foo_driver; 321 new_client->driver = &foo_driver;
331 new_client->flags = 0; 322 new_client->flags = 0;
@@ -451,7 +442,7 @@ much simpler than the attachment code, fortunately!
451 release_region(client->addr,LM78_EXTENT); 442 release_region(client->addr,LM78_EXTENT);
452 /* HYBRID SENSORS CHIP ONLY END */ 443 /* HYBRID SENSORS CHIP ONLY END */
453 444
454 kfree(client); /* Frees client data too, if allocated at the same time */ 445 kfree(data);
455 return 0; 446 return 0;
456 } 447 }
457 448
@@ -576,12 +567,12 @@ SMBus communication
576 extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 567 extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
577 u8 command, u8 length, 568 u8 command, u8 length,
578 u8 *values); 569 u8 *values);
570 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
571 u8 command, u8 *values);
579 572
580These ones were removed in Linux 2.6.10 because they had no users, but could 573These ones were removed in Linux 2.6.10 because they had no users, but could
581be added back later if needed: 574be added back later if needed:
582 575
583 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
584 u8 command, u8 *values);
585 extern s32 i2c_smbus_read_block_data(struct i2c_client * client, 576 extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
586 u8 command, u8 *values); 577 u8 command, u8 *values);
587 extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 578 extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
diff --git a/Documentation/input/yealink.txt b/Documentation/input/yealink.txt
index 85f095a7ad04..0962c5c948be 100644
--- a/Documentation/input/yealink.txt
+++ b/Documentation/input/yealink.txt
@@ -2,7 +2,6 @@ Driver documentation for yealink usb-p1k phones
2 2
30. Status 30. Status
4~~~~~~~~~ 4~~~~~~~~~
5
6The p1k is a relatively cheap usb 1.1 phone with: 5The p1k is a relatively cheap usb 1.1 phone with:
7 - keyboard full support, yealink.ko / input event API 6 - keyboard full support, yealink.ko / input event API
8 - LCD full support, yealink.ko / sysfs API 7 - LCD full support, yealink.ko / sysfs API
@@ -17,9 +16,8 @@ For vendor documentation see http://www.yealink.com
17 16
181. Compilation (stand alone version) 171. Compilation (stand alone version)
19~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
21Currently only kernel 2.6.x.y versions are supported. 19Currently only kernel 2.6.x.y versions are supported.
22In order to build the yealink.ko module do: 20In order to build the yealink.ko module do
23 21
24 make 22 make
25 23
@@ -28,6 +26,21 @@ the Makefile is pointing to the location where your kernel sources
28are located, default /usr/src/linux. 26are located, default /usr/src/linux.
29 27
30 28
291.1 Troubleshooting
30~~~~~~~~~~~~~~~~~~~
31Q: Module yealink compiled and installed without any problem but phone
32 is not initialized and does not react to any actions.
33A: If you see something like:
34 hiddev0: USB HID v1.00 Device [Yealink Network Technology Ltd. VOIP USB Phone
35 in dmesg, it means that the hid driver has grabbed the device first. Try to
36 load module yealink before any other usb hid driver. Please see the
37 instructions provided by your distribution on module configuration.
38
39Q: Phone is working now (displays version and accepts keypad input) but I can't
40 find the sysfs files.
41A: The sysfs files are located on the particular usb endpoint. On most
42 distributions you can do: "find /sys/ -name get_icons" for a hint.
43
31 44
322. keyboard features 452. keyboard features
33~~~~~~~~~~~~~~~~~~~~ 46~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 971589a9752d..90766b75d1b7 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1517,8 +1517,6 @@ running once the system is up.
1517 uart6850= [HW,OSS] 1517 uart6850= [HW,OSS]
1518 Format: <io>,<irq> 1518 Format: <io>,<irq>
1519 1519
1520 usb-handoff [HW] Enable early USB BIOS -> OS handoff
1521
1522 usbhid.mousepoll= 1520 usbhid.mousepoll=
1523 [USBHID] The interval which mice are to be polled at. 1521 [USBHID] The interval which mice are to be polled at.
1524 1522
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index a55f0f95b171..b0fe41da007b 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -777,7 +777,7 @@ doing so is the same as described in the "Configuring Multiple Bonds
777Manually" section, below. 777Manually" section, below.
778 778
779 NOTE: It has been observed that some Red Hat supplied kernels 779 NOTE: It has been observed that some Red Hat supplied kernels
780are apparently unable to rename modules at load time (the "-obonding1" 780are apparently unable to rename modules at load time (the "-o bond1"
781part). Attempts to pass that option to modprobe will produce an 781part). Attempts to pass that option to modprobe will produce an
782"Operation not permitted" error. This has been reported on some 782"Operation not permitted" error. This has been reported on some
783Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels 783Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels
@@ -883,7 +883,8 @@ the above does not work, and the second bonding instance never sees
883its options. In that case, the second options line can be substituted 883its options. In that case, the second options line can be substituted
884as follows: 884as follows:
885 885
886install bonding1 /sbin/modprobe bonding -obond1 mode=balance-alb miimon=50 886install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \
887 mode=balance-alb miimon=50
887 888
888 This may be repeated any number of times, specifying a new and 889 This may be repeated any number of times, specifying a new and
889unique name in place of bond1 for each subsequent instance. 890unique name in place of bond1 for each subsequent instance.
diff --git a/MAINTAINERS b/MAINTAINERS
index 767fb610963e..770155a01523 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -116,12 +116,6 @@ M: ajk@iehk.rwth-aachen.de
116L: linux-hams@vger.kernel.org 116L: linux-hams@vger.kernel.org
117S: Maintained 117S: Maintained
118 118
119YEALINK PHONE DRIVER
120P: Henk Vergonet
121M: Henk.Vergonet@gmail.com
122L: usbb2k-api-dev@nongnu.org
123S: Maintained
124
1258139CP 10/100 FAST ETHERNET DRIVER 1198139CP 10/100 FAST ETHERNET DRIVER
126P: Jeff Garzik 120P: Jeff Garzik
127M: jgarzik@pobox.com 121M: jgarzik@pobox.com
@@ -197,6 +191,15 @@ M: Thorsten Knabe <linux@thorsten-knabe.de>
197W: http://linux.thorsten-knabe.de 191W: http://linux.thorsten-knabe.de
198S: Maintained 192S: Maintained
199 193
194AD1889 SOUND DRIVER
195P: Kyle McMartin
196M: kyle@parisc-linux.org
197P: Thibaut Varene
198M: T-Bone@parisc-linux.org
199W: http://wiki.parisc-linux.org/AD1889
200L: parisc-linux@lists.parisc-linux.org
201S: Maintained
202
200ADM1025 HARDWARE MONITOR DRIVER 203ADM1025 HARDWARE MONITOR DRIVER
201P: Jean Delvare 204P: Jean Delvare
202M: khali@linux-fr.org 205M: khali@linux-fr.org
@@ -2486,14 +2489,6 @@ L: linux-kernel@vger.kernel.org
2486L: linux-usb-devel@lists.sourceforge.net 2489L: linux-usb-devel@lists.sourceforge.net
2487S: Supported 2490S: Supported
2488 2491
2489USB BLUETOOTH TTY CONVERTER DRIVER
2490P: Greg Kroah-Hartman
2491M: greg@kroah.com
2492L: linux-usb-users@lists.sourceforge.net
2493L: linux-usb-devel@lists.sourceforge.net
2494S: Maintained
2495W: http://www.kroah.com/linux-usb/
2496
2497USB CDC ETHERNET DRIVER 2492USB CDC ETHERNET DRIVER
2498P: Greg Kroah-Hartman 2493P: Greg Kroah-Hartman
2499M: greg@kroah.com 2494M: greg@kroah.com
@@ -2727,6 +2722,12 @@ P: Roger Luethi
2727M: rl@hellgate.ch 2722M: rl@hellgate.ch
2728S: Maintained 2723S: Maintained
2729 2724
2725VIAPRO SMBUS DRIVER
2726P: Jean Delvare
2727M: khali@linux-fr.org
2728L: lm-sensors@lm-sensors.org
2729S: Maintained
2730
2730UCLINUX (AND M68KNOMMU) 2731UCLINUX (AND M68KNOMMU)
2731P: Greg Ungerer 2732P: Greg Ungerer
2732M: gerg@uclinux.org 2733M: gerg@uclinux.org
@@ -2848,6 +2849,12 @@ M: jpr@f6fbb.org
2848L: linux-hams@vger.kernel.org 2849L: linux-hams@vger.kernel.org
2849S: Maintained 2850S: Maintained
2850 2851
2852YEALINK PHONE DRIVER
2853P: Henk Vergonet
2854M: Henk.Vergonet@gmail.com
2855L: usbb2k-api-dev@nongnu.org
2856S: Maintained
2857
2851YMFPCI YAMAHA PCI SOUND (Use ALSA instead) 2858YMFPCI YAMAHA PCI SOUND (Use ALSA instead)
2852P: Pete Zaitcev 2859P: Pete Zaitcev
2853M: zaitcev@yahoo.com 2860M: zaitcev@yahoo.com
diff --git a/Makefile b/Makefile
index 1fa7e5343464..79601320ac3e 100644
--- a/Makefile
+++ b/Makefile
@@ -334,7 +334,7 @@ KALLSYMS = scripts/kallsyms
334PERL = perl 334PERL = perl
335CHECK = sparse 335CHECK = sparse
336 336
337CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ $(CF) 337CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
338MODFLAGS = -DMODULE 338MODFLAGS = -DMODULE
339CFLAGS_MODULE = $(MODFLAGS) 339CFLAGS_MODULE = $(MODFLAGS)
340AFLAGS_MODULE = $(MODFLAGS) 340AFLAGS_MODULE = $(MODFLAGS)
@@ -371,8 +371,8 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
371 371
372# Files to ignore in find ... statements 372# Files to ignore in find ... statements
373 373
374RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg \) -prune -o 374RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
375export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg 375export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
376 376
377# =========================================================================== 377# ===========================================================================
378# Rules shared between *config targets and build targets 378# Rules shared between *config targets and build targets
diff --git a/arch/alpha/kernel/pci-noop.c b/arch/alpha/kernel/pci-noop.c
index 582a3519fb28..9903e3a79102 100644
--- a/arch/alpha/kernel/pci-noop.c
+++ b/arch/alpha/kernel/pci-noop.c
@@ -154,7 +154,7 @@ pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask)
154 154
155void * 155void *
156dma_alloc_coherent(struct device *dev, size_t size, 156dma_alloc_coherent(struct device *dev, size_t size,
157 dma_addr_t *dma_handle, int gfp) 157 dma_addr_t *dma_handle, gfp_t gfp)
158{ 158{
159 void *ret; 159 void *ret;
160 160
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 7cb23f12ecbd..c468e312e5f8 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -397,7 +397,7 @@ pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp)
397{ 397{
398 void *cpu_addr; 398 void *cpu_addr;
399 long order = get_order(size); 399 long order = get_order(size);
400 int gfp = GFP_ATOMIC; 400 gfp_t gfp = GFP_ATOMIC;
401 401
402try_again: 402try_again:
403 cpu_addr = (void *)__get_free_pages(gfp, order); 403 cpu_addr = (void *)__get_free_pages(gfp, order);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 11fff042aa81..682367bd0f65 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -204,6 +204,7 @@ config ARCH_H720X
204 204
205config ARCH_AAEC2000 205config ARCH_AAEC2000
206 bool "Agilent AAEC-2000 based" 206 bool "Agilent AAEC-2000 based"
207 select ARM_AMBA
207 help 208 help
208 This enables support for systems based on the Agilent AAEC-2000 209 This enables support for systems based on the Agilent AAEC-2000
209 210
@@ -687,7 +688,8 @@ source "drivers/acorn/block/Kconfig"
687 688
688if PCMCIA || ARCH_CLPS7500 || ARCH_IOP3XX || ARCH_IXP4XX \ 689if PCMCIA || ARCH_CLPS7500 || ARCH_IOP3XX || ARCH_IXP4XX \
689 || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \ 690 || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \
690 || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE 691 || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE \
692 || MACH_MP1000
691source "drivers/ide/Kconfig" 693source "drivers/ide/Kconfig"
692endif 694endif
693 695
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 7c7f475e213e..a54d2eb64892 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -39,7 +39,8 @@
39 defined(CONFIG_ARCH_IXP4XX) || \ 39 defined(CONFIG_ARCH_IXP4XX) || \
40 defined(CONFIG_ARCH_IXP2000) || \ 40 defined(CONFIG_ARCH_IXP2000) || \
41 defined(CONFIG_ARCH_LH7A40X) || \ 41 defined(CONFIG_ARCH_LH7A40X) || \
42 defined(CONFIG_ARCH_OMAP) 42 defined(CONFIG_ARCH_OMAP) || \
43 defined(CONFIG_MACH_MP1000)
43 .macro loadsp, rb 44 .macro loadsp, rb
44 addruart \rb 45 addruart \rb
45 .endm 46 .endm
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index e8053d16829b..5cdb4122f057 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -550,15 +550,12 @@ struct locomo_save_data {
550 u16 LCM_SPIMD; 550 u16 LCM_SPIMD;
551}; 551};
552 552
553static int locomo_suspend(struct device *dev, pm_message_t state, u32 level) 553static int locomo_suspend(struct device *dev, pm_message_t state)
554{ 554{
555 struct locomo *lchip = dev_get_drvdata(dev); 555 struct locomo *lchip = dev_get_drvdata(dev);
556 struct locomo_save_data *save; 556 struct locomo_save_data *save;
557 unsigned long flags; 557 unsigned long flags;
558 558
559 if (level != SUSPEND_DISABLE)
560 return 0;
561
562 save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL); 559 save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
563 if (!save) 560 if (!save)
564 return -ENOMEM; 561 return -ENOMEM;
@@ -597,16 +594,13 @@ static int locomo_suspend(struct device *dev, pm_message_t state, u32 level)
597 return 0; 594 return 0;
598} 595}
599 596
600static int locomo_resume(struct device *dev, u32 level) 597static int locomo_resume(struct device *dev)
601{ 598{
602 struct locomo *lchip = dev_get_drvdata(dev); 599 struct locomo *lchip = dev_get_drvdata(dev);
603 struct locomo_save_data *save; 600 struct locomo_save_data *save;
604 unsigned long r; 601 unsigned long r;
605 unsigned long flags; 602 unsigned long flags;
606 603
607 if (level != RESUME_ENABLE)
608 return 0;
609
610 save = (struct locomo_save_data *) dev->power.saved_state; 604 save = (struct locomo_save_data *) dev->power.saved_state;
611 if (!save) 605 if (!save)
612 return 0; 606 return 0;
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 1a47fbf9cbbc..21e2a518ad3a 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -801,7 +801,7 @@ struct sa1111_save_data {
801 801
802#ifdef CONFIG_PM 802#ifdef CONFIG_PM
803 803
804static int sa1111_suspend(struct device *dev, pm_message_t state, u32 level) 804static int sa1111_suspend(struct device *dev, pm_message_t state)
805{ 805{
806 struct sa1111 *sachip = dev_get_drvdata(dev); 806 struct sa1111 *sachip = dev_get_drvdata(dev);
807 struct sa1111_save_data *save; 807 struct sa1111_save_data *save;
@@ -809,9 +809,6 @@ static int sa1111_suspend(struct device *dev, pm_message_t state, u32 level)
809 unsigned int val; 809 unsigned int val;
810 void __iomem *base; 810 void __iomem *base;
811 811
812 if (level != SUSPEND_DISABLE)
813 return 0;
814
815 save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); 812 save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
816 if (!save) 813 if (!save)
817 return -ENOMEM; 814 return -ENOMEM;
@@ -856,23 +853,19 @@ static int sa1111_suspend(struct device *dev, pm_message_t state, u32 level)
856/* 853/*
857 * sa1111_resume - Restore the SA1111 device state. 854 * sa1111_resume - Restore the SA1111 device state.
858 * @dev: device to restore 855 * @dev: device to restore
859 * @level: resume level
860 * 856 *
861 * Restore the general state of the SA1111; clock control and 857 * Restore the general state of the SA1111; clock control and
862 * interrupt controller. Other parts of the SA1111 must be 858 * interrupt controller. Other parts of the SA1111 must be
863 * restored by their respective drivers, and must be called 859 * restored by their respective drivers, and must be called
864 * via LDM after this function. 860 * via LDM after this function.
865 */ 861 */
866static int sa1111_resume(struct device *dev, u32 level) 862static int sa1111_resume(struct device *dev)
867{ 863{
868 struct sa1111 *sachip = dev_get_drvdata(dev); 864 struct sa1111 *sachip = dev_get_drvdata(dev);
869 struct sa1111_save_data *save; 865 struct sa1111_save_data *save;
870 unsigned long flags, id; 866 unsigned long flags, id;
871 void __iomem *base; 867 void __iomem *base;
872 868
873 if (level != RESUME_ENABLE)
874 return 0;
875
876 save = (struct sa1111_save_data *)dev->power.saved_state; 869 save = (struct sa1111_save_data *)dev->power.saved_state;
877 if (!save) 870 if (!save)
878 return 0; 871 return 0;
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index 9e5245c702de..e8356b76d7c6 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -102,26 +102,24 @@ static void check_scoop_reg(struct scoop_dev *sdev)
102} 102}
103 103
104#ifdef CONFIG_PM 104#ifdef CONFIG_PM
105static int scoop_suspend(struct device *dev, pm_message_t state, uint32_t level) 105static int scoop_suspend(struct device *dev, pm_message_t state)
106{ 106{
107 if (level == SUSPEND_POWER_DOWN) { 107 struct scoop_dev *sdev = dev_get_drvdata(dev);
108 struct scoop_dev *sdev = dev_get_drvdata(dev); 108
109 check_scoop_reg(sdev);
110 sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR);
111 SCOOP_REG(sdev->base, SCOOP_GPWR) = (sdev->scoop_gpwr & ~sdev->suspend_clr) | sdev->suspend_set;
109 112
110 check_scoop_reg(sdev);
111 sdev->scoop_gpwr = SCOOP_REG(sdev->base, SCOOP_GPWR);
112 SCOOP_REG(sdev->base, SCOOP_GPWR) = (sdev->scoop_gpwr & ~sdev->suspend_clr) | sdev->suspend_set;
113 }
114 return 0; 113 return 0;
115} 114}
116 115
117static int scoop_resume(struct device *dev, uint32_t level) 116static int scoop_resume(struct device *dev)
118{ 117{
119 if (level == RESUME_POWER_ON) { 118 struct scoop_dev *sdev = dev_get_drvdata(dev);
120 struct scoop_dev *sdev = dev_get_drvdata(dev); 119
120 check_scoop_reg(sdev);
121 SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr;
121 122
122 check_scoop_reg(sdev);
123 SCOOP_REG(sdev->base,SCOOP_GPWR) = sdev->scoop_gpwr;
124 }
125 return 0; 123 return 0;
126} 124}
127#else 125#else
diff --git a/arch/arm/configs/mp1000_defconfig b/arch/arm/configs/mp1000_defconfig
new file mode 100644
index 000000000000..d2cbc6fada1d
--- /dev/null
+++ b/arch/arm/configs/mp1000_defconfig
@@ -0,0 +1,897 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc1
4# Fri Sep 16 15:48:13 2005
5#
6CONFIG_ARM=y
7CONFIG_MMU=y
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16# CONFIG_CLEAN_COMPILE is not set
17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
30# CONFIG_BSD_PROCESS_ACCT is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33# CONFIG_HOTPLUG is not set
34CONFIG_KOBJECT_UEVENT=y
35CONFIG_IKCONFIG=y
36CONFIG_IKCONFIG_PROC=y
37CONFIG_INITRAMFS_SOURCE=""
38CONFIG_EMBEDDED=y
39CONFIG_KALLSYMS=y
40# CONFIG_KALLSYMS_ALL is not set
41# CONFIG_KALLSYMS_EXTRA_PASS is not set
42CONFIG_PRINTK=y
43CONFIG_BUG=y
44CONFIG_BASE_FULL=y
45CONFIG_FUTEX=y
46CONFIG_EPOLL=y
47CONFIG_CC_OPTIMIZE_FOR_SIZE=y
48CONFIG_SHMEM=y
49CONFIG_CC_ALIGN_FUNCTIONS=0
50CONFIG_CC_ALIGN_LABELS=0
51CONFIG_CC_ALIGN_LOOPS=0
52CONFIG_CC_ALIGN_JUMPS=0
53# CONFIG_TINY_SHMEM is not set
54CONFIG_BASE_SMALL=0
55
56#
57# Loadable module support
58#
59CONFIG_MODULES=y
60CONFIG_MODULE_UNLOAD=y
61# CONFIG_MODULE_FORCE_UNLOAD is not set
62CONFIG_OBSOLETE_MODPARM=y
63# CONFIG_MODVERSIONS is not set
64# CONFIG_MODULE_SRCVERSION_ALL is not set
65CONFIG_KMOD=y
66
67#
68# System Type
69#
70# CONFIG_ARCH_CLPS7500 is not set
71CONFIG_ARCH_CLPS711X=y
72# CONFIG_ARCH_CO285 is not set
73# CONFIG_ARCH_EBSA110 is not set
74# CONFIG_ARCH_CAMELOT is not set
75# CONFIG_ARCH_FOOTBRIDGE is not set
76# CONFIG_ARCH_INTEGRATOR is not set
77# CONFIG_ARCH_IOP3XX is not set
78# CONFIG_ARCH_IXP4XX is not set
79# CONFIG_ARCH_IXP2000 is not set
80# CONFIG_ARCH_L7200 is not set
81# CONFIG_ARCH_PXA is not set
82# CONFIG_ARCH_RPC is not set
83# CONFIG_ARCH_SA1100 is not set
84# CONFIG_ARCH_S3C2410 is not set
85# CONFIG_ARCH_SHARK is not set
86# CONFIG_ARCH_LH7A40X is not set
87# CONFIG_ARCH_OMAP is not set
88# CONFIG_ARCH_VERSATILE is not set
89# CONFIG_ARCH_IMX is not set
90# CONFIG_ARCH_H720X is not set
91# CONFIG_ARCH_AAEC2000 is not set
92
93#
94# CLPS711X/EP721X Implementations
95#
96# CONFIG_ARCH_AUTCPU12 is not set
97# CONFIG_ARCH_CDB89712 is not set
98# CONFIG_ARCH_CEIVA is not set
99# CONFIG_ARCH_CLEP7312 is not set
100# CONFIG_ARCH_EDB7211 is not set
101# CONFIG_ARCH_P720T is not set
102# CONFIG_ARCH_FORTUNET is not set
103CONFIG_MACH_MP1000=y
104CONFIG_MP1000_90MHZ=y
105
106#
107# Processor Type
108#
109CONFIG_CPU_32=y
110CONFIG_CPU_ARM720T=y
111CONFIG_CPU_32v4=y
112CONFIG_CPU_ABRT_LV4T=y
113CONFIG_CPU_CACHE_V4=y
114CONFIG_CPU_CACHE_VIVT=y
115CONFIG_CPU_COPY_V4WT=y
116CONFIG_CPU_TLB_V4WT=y
117
118#
119# Processor Features
120#
121CONFIG_ARM_THUMB=y
122
123#
124# Bus support
125#
126CONFIG_ISA_DMA_API=y
127
128#
129# PCCARD (PCMCIA/CardBus) support
130#
131# CONFIG_PCCARD is not set
132
133#
134# Kernel Features
135#
136# CONFIG_SMP is not set
137CONFIG_PREEMPT=y
138# CONFIG_NO_IDLE_HZ is not set
139# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
140CONFIG_SELECT_MEMORY_MODEL=y
141CONFIG_FLATMEM_MANUAL=y
142# CONFIG_DISCONTIGMEM_MANUAL is not set
143# CONFIG_SPARSEMEM_MANUAL is not set
144CONFIG_FLATMEM=y
145CONFIG_FLAT_NODE_MEM_MAP=y
146# CONFIG_SPARSEMEM_STATIC is not set
147CONFIG_ALIGNMENT_TRAP=y
148
149#
150# Boot options
151#
152CONFIG_ZBOOT_ROM_TEXT=0x0
153CONFIG_ZBOOT_ROM_BSS=0x0
154CONFIG_CMDLINE="console=ttyCL,38400 root=/dev/discs/disc0/part1 ip=any cs89x0_media=rj45"
155# CONFIG_XIP_KERNEL is not set
156
157#
158# Floating point emulation
159#
160
161#
162# At least one emulation must be selected
163#
164CONFIG_FPE_NWFPE=y
165# CONFIG_FPE_NWFPE_XP is not set
166# CONFIG_FPE_FASTFPE is not set
167
168#
169# Userspace binary formats
170#
171CONFIG_BINFMT_ELF=y
172# CONFIG_BINFMT_AOUT is not set
173CONFIG_BINFMT_MISC=y
174# CONFIG_ARTHUR is not set
175
176#
177# Power management options
178#
179# CONFIG_PM is not set
180
181#
182# Networking
183#
184CONFIG_NET=y
185
186#
187# Networking options
188#
189CONFIG_PACKET=y
190# CONFIG_PACKET_MMAP is not set
191CONFIG_UNIX=y
192# CONFIG_NET_KEY is not set
193CONFIG_INET=y
194# CONFIG_IP_MULTICAST is not set
195# CONFIG_IP_ADVANCED_ROUTER is not set
196CONFIG_IP_FIB_HASH=y
197CONFIG_IP_PNP=y
198CONFIG_IP_PNP_DHCP=y
199CONFIG_IP_PNP_BOOTP=y
200CONFIG_IP_PNP_RARP=y
201# CONFIG_NET_IPIP is not set
202# CONFIG_NET_IPGRE is not set
203# CONFIG_ARPD is not set
204# CONFIG_SYN_COOKIES is not set
205# CONFIG_INET_AH is not set
206# CONFIG_INET_ESP is not set
207# CONFIG_INET_IPCOMP is not set
208# CONFIG_INET_TUNNEL is not set
209CONFIG_INET_DIAG=y
210CONFIG_INET_TCP_DIAG=y
211# CONFIG_TCP_CONG_ADVANCED is not set
212CONFIG_TCP_CONG_BIC=y
213CONFIG_IPV6=y
214# CONFIG_IPV6_PRIVACY is not set
215# CONFIG_INET6_AH is not set
216# CONFIG_INET6_ESP is not set
217# CONFIG_INET6_IPCOMP is not set
218# CONFIG_INET6_TUNNEL is not set
219# CONFIG_IPV6_TUNNEL is not set
220# CONFIG_NETFILTER is not set
221
222#
223# DCCP Configuration (EXPERIMENTAL)
224#
225# CONFIG_IP_DCCP is not set
226
227#
228# SCTP Configuration (EXPERIMENTAL)
229#
230# CONFIG_IP_SCTP is not set
231# CONFIG_ATM is not set
232# CONFIG_BRIDGE is not set
233# CONFIG_VLAN_8021Q is not set
234# CONFIG_DECNET is not set
235# CONFIG_LLC2 is not set
236# CONFIG_IPX is not set
237# CONFIG_ATALK is not set
238# CONFIG_X25 is not set
239# CONFIG_LAPB is not set
240# CONFIG_NET_DIVERT is not set
241# CONFIG_ECONET is not set
242# CONFIG_WAN_ROUTER is not set
243# CONFIG_NET_SCHED is not set
244# CONFIG_NET_CLS_ROUTE is not set
245
246#
247# Network testing
248#
249# CONFIG_NET_PKTGEN is not set
250# CONFIG_NETFILTER_NETLINK is not set
251# CONFIG_HAMRADIO is not set
252# CONFIG_IRDA is not set
253# CONFIG_BT is not set
254# CONFIG_IEEE80211 is not set
255
256#
257# Device Drivers
258#
259
260#
261# Generic Driver Options
262#
263CONFIG_STANDALONE=y
264CONFIG_PREVENT_FIRMWARE_BUILD=y
265# CONFIG_FW_LOADER is not set
266# CONFIG_DEBUG_DRIVER is not set
267
268#
269# Memory Technology Devices (MTD)
270#
271CONFIG_MTD=y
272CONFIG_MTD_DEBUG=y
273CONFIG_MTD_DEBUG_VERBOSE=3
274# CONFIG_MTD_CONCAT is not set
275CONFIG_MTD_PARTITIONS=y
276CONFIG_MTD_REDBOOT_PARTS=m
277CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2
278CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
279# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
280CONFIG_MTD_CMDLINE_PARTS=y
281# CONFIG_MTD_AFS_PARTS is not set
282
283#
284# User Modules And Translation Layers
285#
286CONFIG_MTD_CHAR=y
287CONFIG_MTD_BLOCK=y
288# CONFIG_FTL is not set
289# CONFIG_NFTL is not set
290# CONFIG_INFTL is not set
291
292#
293# RAM/ROM/Flash chip drivers
294#
295CONFIG_MTD_CFI=m
296# CONFIG_MTD_JEDECPROBE is not set
297CONFIG_MTD_GEN_PROBE=m
298CONFIG_MTD_CFI_ADV_OPTIONS=y
299CONFIG_MTD_CFI_NOSWAP=y
300# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
301# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
302CONFIG_MTD_CFI_GEOMETRY=y
303# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set
304# CONFIG_MTD_MAP_BANK_WIDTH_2 is not set
305CONFIG_MTD_MAP_BANK_WIDTH_4=y
306# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
307# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
308# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
309# CONFIG_MTD_CFI_I1 is not set
310CONFIG_MTD_CFI_I2=y
311# CONFIG_MTD_CFI_I4 is not set
312# CONFIG_MTD_CFI_I8 is not set
313# CONFIG_MTD_OTP is not set
314CONFIG_MTD_CFI_INTELEXT=m
315# CONFIG_MTD_CFI_AMDSTD is not set
316# CONFIG_MTD_CFI_STAA is not set
317CONFIG_MTD_CFI_UTIL=m
318# CONFIG_MTD_RAM is not set
319# CONFIG_MTD_ROM is not set
320# CONFIG_MTD_ABSENT is not set
321# CONFIG_MTD_OBSOLETE_CHIPS is not set
322# CONFIG_MTD_XIP is not set
323
324#
325# Mapping drivers for chip access
326#
327# CONFIG_MTD_COMPLEX_MAPPINGS is not set
328CONFIG_MTD_PHYSMAP=m
329CONFIG_MTD_PHYSMAP_START=0x0000000
330CONFIG_MTD_PHYSMAP_LEN=0x4000000
331CONFIG_MTD_PHYSMAP_BANKWIDTH=2
332# CONFIG_MTD_ARM_INTEGRATOR is not set
333CONFIG_MTD_EDB7312=m
334# CONFIG_MTD_PLATRAM is not set
335
336#
337# Self-contained MTD device drivers
338#
339# CONFIG_MTD_SLRAM is not set
340# CONFIG_MTD_PHRAM is not set
341# CONFIG_MTD_MTDRAM is not set
342# CONFIG_MTD_BLKMTD is not set
343# CONFIG_MTD_BLOCK2MTD is not set
344
345#
346# Disk-On-Chip Device Drivers
347#
348# CONFIG_MTD_DOC2000 is not set
349# CONFIG_MTD_DOC2001 is not set
350# CONFIG_MTD_DOC2001PLUS is not set
351
352#
353# NAND Flash Device Drivers
354#
355CONFIG_MTD_NAND=y
356# CONFIG_MTD_NAND_VERIFY_WRITE is not set
357CONFIG_MTD_NAND_MP1000=y
358CONFIG_MTD_NAND_IDS=y
359# CONFIG_MTD_NAND_DISKONCHIP is not set
360# CONFIG_MTD_NAND_NANDSIM is not set
361
362#
363# Parallel port support
364#
365# CONFIG_PARPORT is not set
366
367#
368# Plug and Play support
369#
370
371#
372# Block devices
373#
374# CONFIG_BLK_DEV_COW_COMMON is not set
375CONFIG_BLK_DEV_LOOP=m
376# CONFIG_BLK_DEV_CRYPTOLOOP is not set
377# CONFIG_BLK_DEV_NBD is not set
378CONFIG_BLK_DEV_RAM=y
379CONFIG_BLK_DEV_RAM_COUNT=2
380CONFIG_BLK_DEV_RAM_SIZE=16384
381CONFIG_BLK_DEV_INITRD=y
382# CONFIG_CDROM_PKTCDVD is not set
383
384#
385# IO Schedulers
386#
387CONFIG_IOSCHED_NOOP=y
388CONFIG_IOSCHED_AS=y
389CONFIG_IOSCHED_DEADLINE=y
390CONFIG_IOSCHED_CFQ=y
391# CONFIG_ATA_OVER_ETH is not set
392
393#
394# ATA/ATAPI/MFM/RLL support
395#
396CONFIG_IDE=y
397CONFIG_BLK_DEV_IDE=y
398
399#
400# Please see Documentation/ide.txt for help/info on IDE drives
401#
402# CONFIG_BLK_DEV_IDE_SATA is not set
403# CONFIG_BLK_DEV_HD_IDE is not set
404CONFIG_BLK_DEV_IDEDISK=y
405# CONFIG_IDEDISK_MULTI_MODE is not set
406# CONFIG_BLK_DEV_IDECD is not set
407# CONFIG_BLK_DEV_IDETAPE is not set
408# CONFIG_BLK_DEV_IDEFLOPPY is not set
409# CONFIG_IDE_TASK_IOCTL is not set
410
411#
412# IDE chipset support/bugfixes
413#
414# CONFIG_IDE_GENERIC is not set
415CONFIG_IDE_ARM=y
416CONFIG_BLK_DEV_IDE_MP1000=y
417# CONFIG_BLK_DEV_IDEDMA is not set
418# CONFIG_IDEDMA_AUTO is not set
419# CONFIG_BLK_DEV_HD is not set
420
421#
422# SCSI device support
423#
424# CONFIG_RAID_ATTRS is not set
425# CONFIG_SCSI is not set
426
427#
428# Multi-device support (RAID and LVM)
429#
430CONFIG_MD=y
431# CONFIG_BLK_DEV_MD is not set
432CONFIG_BLK_DEV_DM=y
433# CONFIG_DM_CRYPT is not set
434# CONFIG_DM_SNAPSHOT is not set
435# CONFIG_DM_MIRROR is not set
436# CONFIG_DM_ZERO is not set
437# CONFIG_DM_MULTIPATH is not set
438
439#
440# Fusion MPT device support
441#
442# CONFIG_FUSION is not set
443
444#
445# IEEE 1394 (FireWire) support
446#
447# CONFIG_IEEE1394 is not set
448
449#
450# I2O device support
451#
452
453#
454# Network device support
455#
456CONFIG_NETDEVICES=y
457# CONFIG_DUMMY is not set
458# CONFIG_BONDING is not set
459# CONFIG_EQUALIZER is not set
460# CONFIG_TUN is not set
461
462#
463# PHY device support
464#
465# CONFIG_PHYLIB is not set
466
467#
468# Ethernet (10 or 100Mbit)
469#
470CONFIG_NET_ETHERNET=y
471# CONFIG_MII is not set
472# CONFIG_SMC91X is not set
473# CONFIG_DM9000 is not set
474CONFIG_CS89x0=y
475
476#
477# Ethernet (1000 Mbit)
478#
479
480#
481# Ethernet (10000 Mbit)
482#
483
484#
485# Token Ring devices
486#
487
488#
489# Wireless LAN (non-hamradio)
490#
491# CONFIG_NET_RADIO is not set
492
493#
494# Wan interfaces
495#
496# CONFIG_WAN is not set
497# CONFIG_PPP is not set
498# CONFIG_SLIP is not set
499# CONFIG_SHAPER is not set
500# CONFIG_NETCONSOLE is not set
501# CONFIG_NETPOLL is not set
502# CONFIG_NET_POLL_CONTROLLER is not set
503
504#
505# ISDN subsystem
506#
507# CONFIG_ISDN is not set
508
509#
510# Input device support
511#
512CONFIG_INPUT=y
513
514#
515# Userland interfaces
516#
517# CONFIG_INPUT_MOUSEDEV is not set
518# CONFIG_INPUT_JOYDEV is not set
519# CONFIG_INPUT_TSDEV is not set
520# CONFIG_INPUT_EVDEV is not set
521CONFIG_INPUT_EVBUG=y
522
523#
524# Input Device Drivers
525#
526# CONFIG_INPUT_KEYBOARD is not set
527# CONFIG_INPUT_MOUSE is not set
528# CONFIG_INPUT_JOYSTICK is not set
529# CONFIG_INPUT_TOUCHSCREEN is not set
530# CONFIG_INPUT_MISC is not set
531
532#
533# Hardware I/O ports
534#
535CONFIG_SERIO=y
536CONFIG_SERIO_SERPORT=y
537# CONFIG_SERIO_LIBPS2 is not set
538# CONFIG_SERIO_RAW is not set
539# CONFIG_GAMEPORT is not set
540
541#
542# Character devices
543#
544CONFIG_VT=y
545CONFIG_VT_CONSOLE=y
546CONFIG_HW_CONSOLE=y
547# CONFIG_SERIAL_NONSTANDARD is not set
548
549#
550# Serial drivers
551#
552CONFIG_SERIAL_8250=y
553CONFIG_SERIAL_8250_CONSOLE=y
554CONFIG_SERIAL_8250_NR_UARTS=2
555# CONFIG_SERIAL_8250_EXTENDED is not set
556
557#
558# Non-8250 serial port support
559#
560CONFIG_SERIAL_CLPS711X=y
561CONFIG_SERIAL_CLPS711X_CONSOLE=y
562CONFIG_SERIAL_CORE=y
563CONFIG_SERIAL_CORE_CONSOLE=y
564CONFIG_UNIX98_PTYS=y
565CONFIG_LEGACY_PTYS=y
566CONFIG_LEGACY_PTY_COUNT=256
567
568#
569# IPMI
570#
571# CONFIG_IPMI_HANDLER is not set
572
573#
574# Watchdog Cards
575#
576# CONFIG_WATCHDOG is not set
577CONFIG_NVRAM=y
578CONFIG_RTC=y
579# CONFIG_DTLK is not set
580# CONFIG_R3964 is not set
581
582#
583# Ftape, the floppy tape device driver
584#
585# CONFIG_RAW_DRIVER is not set
586
587#
588# TPM devices
589#
590
591#
592# I2C support
593#
594# CONFIG_I2C is not set
595
596#
597# Hardware Monitoring support
598#
599CONFIG_HWMON=y
600# CONFIG_HWMON_VID is not set
601# CONFIG_HWMON_DEBUG_CHIP is not set
602
603#
604# Misc devices
605#
606
607#
608# Multimedia Capabilities Port drivers
609#
610
611#
612# Multimedia devices
613#
614# CONFIG_VIDEO_DEV is not set
615
616#
617# Digital Video Broadcasting Devices
618#
619# CONFIG_DVB is not set
620
621#
622# Graphics support
623#
624# CONFIG_FB is not set
625
626#
627# Console display driver support
628#
629# CONFIG_VGA_CONSOLE is not set
630CONFIG_DUMMY_CONSOLE=y
631
632#
633# Sound
634#
635# CONFIG_SOUND is not set
636
637#
638# USB support
639#
640CONFIG_USB_ARCH_HAS_HCD=y
641# CONFIG_USB_ARCH_HAS_OHCI is not set
642# CONFIG_USB is not set
643
644#
645# USB Gadget Support
646#
647# CONFIG_USB_GADGET is not set
648
649#
650# MMC/SD Card support
651#
652# CONFIG_MMC is not set
653
654#
655# File systems
656#
657CONFIG_EXT2_FS=y
658CONFIG_EXT2_FS_XATTR=y
659# CONFIG_EXT2_FS_POSIX_ACL is not set
660# CONFIG_EXT2_FS_SECURITY is not set
661# CONFIG_EXT2_FS_XIP is not set
662CONFIG_EXT3_FS=y
663CONFIG_EXT3_FS_XATTR=y
664# CONFIG_EXT3_FS_POSIX_ACL is not set
665# CONFIG_EXT3_FS_SECURITY is not set
666CONFIG_JBD=y
667# CONFIG_JBD_DEBUG is not set
668CONFIG_FS_MBCACHE=y
669CONFIG_REISERFS_FS=m
670# CONFIG_REISERFS_CHECK is not set
671# CONFIG_REISERFS_PROC_INFO is not set
672# CONFIG_REISERFS_FS_XATTR is not set
673# CONFIG_JFS_FS is not set
674CONFIG_FS_POSIX_ACL=y
675# CONFIG_XFS_FS is not set
676# CONFIG_MINIX_FS is not set
677# CONFIG_ROMFS_FS is not set
678CONFIG_INOTIFY=y
679CONFIG_QUOTA=y
680# CONFIG_QFMT_V1 is not set
681# CONFIG_QFMT_V2 is not set
682CONFIG_QUOTACTL=y
683CONFIG_DNOTIFY=y
684# CONFIG_AUTOFS_FS is not set
685# CONFIG_AUTOFS4_FS is not set
686# CONFIG_FUSE_FS is not set
687
688#
689# CD-ROM/DVD Filesystems
690#
691# CONFIG_ISO9660_FS is not set
692# CONFIG_UDF_FS is not set
693
694#
695# DOS/FAT/NT Filesystems
696#
697# CONFIG_MSDOS_FS is not set
698# CONFIG_VFAT_FS is not set
699# CONFIG_NTFS_FS is not set
700
701#
702# Pseudo filesystems
703#
704CONFIG_PROC_FS=y
705CONFIG_SYSFS=y
706CONFIG_TMPFS=y
707# CONFIG_HUGETLBFS is not set
708# CONFIG_HUGETLB_PAGE is not set
709CONFIG_RAMFS=y
710# CONFIG_RELAYFS_FS is not set
711
712#
713# Miscellaneous filesystems
714#
715# CONFIG_ADFS_FS is not set
716# CONFIG_AFFS_FS is not set
717# CONFIG_HFS_FS is not set
718# CONFIG_HFSPLUS_FS is not set
719# CONFIG_BEFS_FS is not set
720# CONFIG_BFS_FS is not set
721# CONFIG_EFS_FS is not set
722# CONFIG_JFFS_FS is not set
723CONFIG_JFFS2_FS=m
724CONFIG_JFFS2_FS_DEBUG=0
725CONFIG_JFFS2_FS_WRITEBUFFER=y
726# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
727CONFIG_JFFS2_ZLIB=y
728CONFIG_JFFS2_RTIME=y
729# CONFIG_JFFS2_RUBIN is not set
730CONFIG_CRAMFS=m
731# CONFIG_VXFS_FS is not set
732# CONFIG_HPFS_FS is not set
733# CONFIG_QNX4FS_FS is not set
734# CONFIG_SYSV_FS is not set
735# CONFIG_UFS_FS is not set
736
737#
738# Network File Systems
739#
740CONFIG_NFS_FS=y
741CONFIG_NFS_V3=y
742# CONFIG_NFS_V3_ACL is not set
743CONFIG_NFS_V4=y
744# CONFIG_NFS_DIRECTIO is not set
745CONFIG_NFSD=y
746CONFIG_NFSD_V3=y
747# CONFIG_NFSD_V3_ACL is not set
748CONFIG_NFSD_V4=y
749CONFIG_NFSD_TCP=y
750CONFIG_ROOT_NFS=y
751CONFIG_LOCKD=y
752CONFIG_LOCKD_V4=y
753CONFIG_EXPORTFS=y
754CONFIG_NFS_COMMON=y
755CONFIG_SUNRPC=y
756CONFIG_SUNRPC_GSS=y
757CONFIG_RPCSEC_GSS_KRB5=y
758# CONFIG_RPCSEC_GSS_SPKM3 is not set
759CONFIG_SMB_FS=m
760# CONFIG_SMB_NLS_DEFAULT is not set
761CONFIG_CIFS=m
762# CONFIG_CIFS_STATS is not set
763# CONFIG_CIFS_XATTR is not set
764# CONFIG_CIFS_EXPERIMENTAL is not set
765# CONFIG_NCP_FS is not set
766# CONFIG_CODA_FS is not set
767# CONFIG_AFS_FS is not set
768# CONFIG_9P_FS is not set
769
770#
771# Partition Types
772#
773# CONFIG_PARTITION_ADVANCED is not set
774CONFIG_MSDOS_PARTITION=y
775
776#
777# Native Language Support
778#
779CONFIG_NLS=y
780CONFIG_NLS_DEFAULT="iso8859-1"
781CONFIG_NLS_CODEPAGE_437=y
782# CONFIG_NLS_CODEPAGE_737 is not set
783# CONFIG_NLS_CODEPAGE_775 is not set
784# CONFIG_NLS_CODEPAGE_850 is not set
785# CONFIG_NLS_CODEPAGE_852 is not set
786# CONFIG_NLS_CODEPAGE_855 is not set
787# CONFIG_NLS_CODEPAGE_857 is not set
788# CONFIG_NLS_CODEPAGE_860 is not set
789# CONFIG_NLS_CODEPAGE_861 is not set
790# CONFIG_NLS_CODEPAGE_862 is not set
791# CONFIG_NLS_CODEPAGE_863 is not set
792# CONFIG_NLS_CODEPAGE_864 is not set
793# CONFIG_NLS_CODEPAGE_865 is not set
794# CONFIG_NLS_CODEPAGE_866 is not set
795# CONFIG_NLS_CODEPAGE_869 is not set
796# CONFIG_NLS_CODEPAGE_936 is not set
797# CONFIG_NLS_CODEPAGE_950 is not set
798# CONFIG_NLS_CODEPAGE_932 is not set
799# CONFIG_NLS_CODEPAGE_949 is not set
800# CONFIG_NLS_CODEPAGE_874 is not set
801# CONFIG_NLS_ISO8859_8 is not set
802# CONFIG_NLS_CODEPAGE_1250 is not set
803# CONFIG_NLS_CODEPAGE_1251 is not set
804# CONFIG_NLS_ASCII is not set
805# CONFIG_NLS_ISO8859_1 is not set
806# CONFIG_NLS_ISO8859_2 is not set
807# CONFIG_NLS_ISO8859_3 is not set
808# CONFIG_NLS_ISO8859_4 is not set
809# CONFIG_NLS_ISO8859_5 is not set
810# CONFIG_NLS_ISO8859_6 is not set
811# CONFIG_NLS_ISO8859_7 is not set
812# CONFIG_NLS_ISO8859_9 is not set
813# CONFIG_NLS_ISO8859_13 is not set
814# CONFIG_NLS_ISO8859_14 is not set
815# CONFIG_NLS_ISO8859_15 is not set
816# CONFIG_NLS_KOI8_R is not set
817# CONFIG_NLS_KOI8_U is not set
818# CONFIG_NLS_UTF8 is not set
819
820#
821# Profiling support
822#
823# CONFIG_PROFILING is not set
824
825#
826# Kernel hacking
827#
828CONFIG_PRINTK_TIME=y
829CONFIG_DEBUG_KERNEL=y
830# CONFIG_MAGIC_SYSRQ is not set
831CONFIG_LOG_BUF_SHIFT=14
832CONFIG_DETECT_SOFTLOCKUP=y
833# CONFIG_SCHEDSTATS is not set
834# CONFIG_DEBUG_SLAB is not set
835CONFIG_DEBUG_PREEMPT=y
836# CONFIG_DEBUG_SPINLOCK is not set
837# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
838# CONFIG_DEBUG_KOBJECT is not set
839# CONFIG_DEBUG_BUGVERBOSE is not set
840CONFIG_DEBUG_INFO=y
841# CONFIG_DEBUG_FS is not set
842CONFIG_FRAME_POINTER=y
843CONFIG_DEBUG_USER=y
844CONFIG_DEBUG_WAITQ=y
845CONFIG_DEBUG_ERRORS=y
846CONFIG_DEBUG_LL=y
847# CONFIG_DEBUG_ICEDCC is not set
848# CONFIG_DEBUG_CLPS711X_UART2 is not set
849
850#
851# Security options
852#
853# CONFIG_KEYS is not set
854# CONFIG_SECURITY is not set
855
856#
857# Cryptographic options
858#
859CONFIG_CRYPTO=y
860# CONFIG_CRYPTO_HMAC is not set
861# CONFIG_CRYPTO_NULL is not set
862# CONFIG_CRYPTO_MD4 is not set
863CONFIG_CRYPTO_MD5=y
864# CONFIG_CRYPTO_SHA1 is not set
865# CONFIG_CRYPTO_SHA256 is not set
866# CONFIG_CRYPTO_SHA512 is not set
867# CONFIG_CRYPTO_WP512 is not set
868# CONFIG_CRYPTO_TGR192 is not set
869CONFIG_CRYPTO_DES=y
870# CONFIG_CRYPTO_BLOWFISH is not set
871# CONFIG_CRYPTO_TWOFISH is not set
872# CONFIG_CRYPTO_SERPENT is not set
873# CONFIG_CRYPTO_AES is not set
874# CONFIG_CRYPTO_CAST5 is not set
875# CONFIG_CRYPTO_CAST6 is not set
876# CONFIG_CRYPTO_TEA is not set
877# CONFIG_CRYPTO_ARC4 is not set
878# CONFIG_CRYPTO_KHAZAD is not set
879# CONFIG_CRYPTO_ANUBIS is not set
880# CONFIG_CRYPTO_DEFLATE is not set
881# CONFIG_CRYPTO_MICHAEL_MIC is not set
882# CONFIG_CRYPTO_CRC32C is not set
883# CONFIG_CRYPTO_TEST is not set
884
885#
886# Hardware crypto devices
887#
888
889#
890# Library routines
891#
892# CONFIG_CRC_CCITT is not set
893# CONFIG_CRC16 is not set
894CONFIG_CRC32=y
895# CONFIG_LIBCRC32C is not set
896CONFIG_ZLIB_INFLATE=m
897CONFIG_ZLIB_DEFLATE=m
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 1a85cfdad5ac..6055e1427ba3 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/config.h> 12#include <linux/config.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/moduleloader.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/elf.h> 16#include <linux/elf.h>
16#include <linux/vmalloc.h> 17#include <linux/vmalloc.h>
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index f6de76e0a45d..baa09601a64e 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -345,7 +345,9 @@ static int bad_syscall(int n, struct pt_regs *regs)
345 struct thread_info *thread = current_thread_info(); 345 struct thread_info *thread = current_thread_info();
346 siginfo_t info; 346 siginfo_t info;
347 347
348 if (current->personality != PER_LINUX && thread->exec_domain->handler) { 348 if (current->personality != PER_LINUX &&
349 current->personality != PER_LINUX_32BIT &&
350 thread->exec_domain->handler) {
349 thread->exec_domain->handler(n, regs); 351 thread->exec_domain->handler(n, regs);
350 return regs->ARM_r0; 352 return regs->ARM_r0;
351 } 353 }
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 8725d63e4219..71e5b99e519e 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -11,7 +11,7 @@ lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
11 strnlen_user.o strchr.o strrchr.o testchangebit.o \ 11 strnlen_user.o strchr.o strrchr.o testchangebit.o \
12 testclearbit.o testsetbit.o uaccess.o getuser.o \ 12 testclearbit.o testsetbit.o uaccess.o getuser.o \
13 putuser.o ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 13 putuser.o ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
14 ucmpdi2.o lib1funcs.o div64.o \ 14 ucmpdi2.o lib1funcs.o div64.o sha1.o \
15 io-readsb.o io-writesb.o io-readsl.o io-writesl.o 15 io-readsb.o io-writesb.o io-readsl.o io-writesl.o
16 16
17ifeq ($(CONFIG_CPU_32v3),y) 17ifeq ($(CONFIG_CPU_32v3),y)
diff --git a/arch/arm/lib/sha1.S b/arch/arm/lib/sha1.S
new file mode 100644
index 000000000000..ff6ece487ffc
--- /dev/null
+++ b/arch/arm/lib/sha1.S
@@ -0,0 +1,206 @@
1/*
2 * linux/arch/arm/lib/sha1.S
3 *
4 * SHA transform optimized for ARM
5 *
6 * Copyright: (C) 2005 by Nicolas Pitre <nico@cam.org>
7 * Created: September 17, 2005
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * The reference implementation for this code is linux/lib/sha1.c
14 */
15
16#include <linux/linkage.h>
17
18 .text
19
20
21/*
22 * void sha_transform(__u32 *digest, const char *in, __u32 *W)
23 *
24 * Note: the "in" ptr may be unaligned.
25 */
26
27ENTRY(sha_transform)
28
29 stmfd sp!, {r4 - r8, lr}
30
31 @ for (i = 0; i < 16; i++)
32 @ W[i] = be32_to_cpu(in[i]); */
33
34#ifdef __ARMEB__
35 mov r4, r0
36 mov r0, r2
37 mov r2, #64
38 bl memcpy
39 mov r2, r0
40 mov r0, r4
41#else
42 mov r3, r2
43 mov lr, #16
441: ldrb r4, [r1], #1
45 ldrb r5, [r1], #1
46 ldrb r6, [r1], #1
47 ldrb r7, [r1], #1
48 subs lr, lr, #1
49 orr r5, r5, r4, lsl #8
50 orr r6, r6, r5, lsl #8
51 orr r7, r7, r6, lsl #8
52 str r7, [r3], #4
53 bne 1b
54#endif
55
56 @ for (i = 0; i < 64; i++)
57 @ W[i+16] = ror(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 31);
58
59 sub r3, r2, #4
60 mov lr, #64
612: ldr r4, [r3, #4]!
62 subs lr, lr, #1
63 ldr r5, [r3, #8]
64 ldr r6, [r3, #32]
65 ldr r7, [r3, #52]
66 eor r4, r4, r5
67 eor r4, r4, r6
68 eor r4, r4, r7
69 mov r4, r4, ror #31
70 str r4, [r3, #64]
71 bne 2b
72
73 /*
74 * The SHA functions are:
75 *
76 * f1(B,C,D) = (D ^ (B & (C ^ D)))
77 * f2(B,C,D) = (B ^ C ^ D)
78 * f3(B,C,D) = ((B & C) | (D & (B | C)))
79 *
80 * Then the sub-blocks are processed as follows:
81 *
82 * A' = ror(A, 27) + f(B,C,D) + E + K + *W++
83 * B' = A
84 * C' = ror(B, 2)
85 * D' = C
86 * E' = D
87 *
88 * We therefore unroll each loop 5 times to avoid register shuffling.
89 * Also the ror for C (and also D and E which are successivelyderived
90 * from it) is applied in place to cut on an additional mov insn for
91 * each round.
92 */
93
94 .macro sha_f1, A, B, C, D, E
95 ldr r3, [r2], #4
96 eor ip, \C, \D
97 add \E, r1, \E, ror #2
98 and ip, \B, ip, ror #2
99 add \E, \E, \A, ror #27
100 eor ip, ip, \D, ror #2
101 add \E, \E, r3
102 add \E, \E, ip
103 .endm
104
105 .macro sha_f2, A, B, C, D, E
106 ldr r3, [r2], #4
107 add \E, r1, \E, ror #2
108 eor ip, \B, \C, ror #2
109 add \E, \E, \A, ror #27
110 eor ip, ip, \D, ror #2
111 add \E, \E, r3
112 add \E, \E, ip
113 .endm
114
115 .macro sha_f3, A, B, C, D, E
116 ldr r3, [r2], #4
117 add \E, r1, \E, ror #2
118 orr ip, \B, \C, ror #2
119 add \E, \E, \A, ror #27
120 and ip, ip, \D, ror #2
121 add \E, \E, r3
122 and r3, \B, \C, ror #2
123 orr ip, ip, r3
124 add \E, \E, ip
125 .endm
126
127 ldmia r0, {r4 - r8}
128
129 mov lr, #4
130 ldr r1, .L_sha_K + 0
131
132 /* adjust initial values */
133 mov r6, r6, ror #30
134 mov r7, r7, ror #30
135 mov r8, r8, ror #30
136
1373: subs lr, lr, #1
138 sha_f1 r4, r5, r6, r7, r8
139 sha_f1 r8, r4, r5, r6, r7
140 sha_f1 r7, r8, r4, r5, r6
141 sha_f1 r6, r7, r8, r4, r5
142 sha_f1 r5, r6, r7, r8, r4
143 bne 3b
144
145 ldr r1, .L_sha_K + 4
146 mov lr, #4
147
1484: subs lr, lr, #1
149 sha_f2 r4, r5, r6, r7, r8
150 sha_f2 r8, r4, r5, r6, r7
151 sha_f2 r7, r8, r4, r5, r6
152 sha_f2 r6, r7, r8, r4, r5
153 sha_f2 r5, r6, r7, r8, r4
154 bne 4b
155
156 ldr r1, .L_sha_K + 8
157 mov lr, #4
158
1595: subs lr, lr, #1
160 sha_f3 r4, r5, r6, r7, r8
161 sha_f3 r8, r4, r5, r6, r7
162 sha_f3 r7, r8, r4, r5, r6
163 sha_f3 r6, r7, r8, r4, r5
164 sha_f3 r5, r6, r7, r8, r4
165 bne 5b
166
167 ldr r1, .L_sha_K + 12
168 mov lr, #4
169
1706: subs lr, lr, #1
171 sha_f2 r4, r5, r6, r7, r8
172 sha_f2 r8, r4, r5, r6, r7
173 sha_f2 r7, r8, r4, r5, r6
174 sha_f2 r6, r7, r8, r4, r5
175 sha_f2 r5, r6, r7, r8, r4
176 bne 6b
177
178 ldmia r0, {r1, r2, r3, ip, lr}
179 add r4, r1, r4
180 add r5, r2, r5
181 add r6, r3, r6, ror #2
182 add r7, ip, r7, ror #2
183 add r8, lr, r8, ror #2
184 stmia r0, {r4 - r8}
185
186 ldmfd sp!, {r4 - r8, pc}
187
188.L_sha_K:
189 .word 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6
190
191
192/*
193 * void sha_init(__u32 *buf)
194 */
195
196.L_sha_initial_digest:
197 .word 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0
198
199ENTRY(sha_init)
200
201 str lr, [sp, #-4]!
202 adr r1, .L_sha_initial_digest
203 ldmia r1, {r1, r2, r3, ip, lr}
204 stmia r0, {r1, r2, r3, ip, lr}
205 ldr pc, [sp], #4
206
diff --git a/arch/arm/mach-aaec2000/Makefile b/arch/arm/mach-aaec2000/Makefile
index 20ec83896c37..a8e462f58bc9 100644
--- a/arch/arm/mach-aaec2000/Makefile
+++ b/arch/arm/mach-aaec2000/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support (must be linked before board specific support) 5# Common support (must be linked before board specific support)
6obj-y += core.o 6obj-y += core.o clock.o
7 7
8# Specific board support 8# Specific board support
9obj-$(CONFIG_MACH_AAED2000) += aaed2000.o 9obj-$(CONFIG_MACH_AAED2000) += aaed2000.o
diff --git a/arch/arm/mach-aaec2000/aaed2000.c b/arch/arm/mach-aaec2000/aaed2000.c
index c9d899886648..f5ef69702296 100644
--- a/arch/arm/mach-aaec2000/aaed2000.c
+++ b/arch/arm/mach-aaec2000/aaed2000.c
@@ -27,16 +27,65 @@
27#include <asm/mach/map.h> 27#include <asm/mach/map.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29 29
30#include <asm/arch/aaed2000.h>
31
30#include "core.h" 32#include "core.h"
31 33
34static void aaed2000_clcd_disable(struct clcd_fb *fb)
35{
36 AAED_EXT_GPIO &= ~AAED_EGPIO_LCD_PWR_EN;
37}
38
39static void aaed2000_clcd_enable(struct clcd_fb *fb)
40{
41 AAED_EXT_GPIO |= AAED_EGPIO_LCD_PWR_EN;
42}
43
44struct aaec2000_clcd_info clcd_info = {
45 .enable = aaed2000_clcd_enable,
46 .disable = aaed2000_clcd_disable,
47 .panel = {
48 .mode = {
49 .name = "Sharp",
50 .refresh = 60,
51 .xres = 640,
52 .yres = 480,
53 .pixclock = 39721,
54 .left_margin = 20,
55 .right_margin = 44,
56 .upper_margin = 21,
57 .lower_margin = 34,
58 .hsync_len = 96,
59 .vsync_len = 2,
60 .sync = 0,
61 .vmode = FB_VMODE_NONINTERLACED,
62 },
63 .width = -1,
64 .height = -1,
65 .tim2 = TIM2_IVS | TIM2_IHS,
66 .cntl = CNTL_LCDTFT,
67 .bpp = 16,
68 },
69};
70
32static void __init aaed2000_init_irq(void) 71static void __init aaed2000_init_irq(void)
33{ 72{
34 aaec2000_init_irq(); 73 aaec2000_init_irq();
35} 74}
36 75
76static void __init aaed2000_init(void)
77{
78 aaec2000_set_clcd_plat_data(&clcd_info);
79}
80
81static struct map_desc aaed2000_io_desc[] __initdata = {
82 { EXT_GPIO_VBASE, EXT_GPIO_PBASE, EXT_GPIO_LENGTH, MT_DEVICE }, /* Ext GPIO */
83};
84
37static void __init aaed2000_map_io(void) 85static void __init aaed2000_map_io(void)
38{ 86{
39 aaec2000_map_io(); 87 aaec2000_map_io();
88 iotable_init(aaed2000_io_desc, ARRAY_SIZE(aaed2000_io_desc));
40} 89}
41 90
42MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform") 91MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform")
@@ -47,4 +96,5 @@ MACHINE_START(AAED2000, "Agilent AAED-2000 Development Platform")
47 .map_io = aaed2000_map_io, 96 .map_io = aaed2000_map_io,
48 .init_irq = aaed2000_init_irq, 97 .init_irq = aaed2000_init_irq,
49 .timer = &aaec2000_timer, 98 .timer = &aaec2000_timer,
99 .init_machine = aaed2000_init,
50MACHINE_END 100MACHINE_END
diff --git a/arch/arm/mach-aaec2000/clock.c b/arch/arm/mach-aaec2000/clock.c
new file mode 100644
index 000000000000..99e019169dda
--- /dev/null
+++ b/arch/arm/mach-aaec2000/clock.c
@@ -0,0 +1,110 @@
1/*
2 * linux/arch/arm/mach-aaec2000/clock.c
3 *
4 * Copyright (C) 2005 Nicolas Bellido Y Ortega
5 *
6 * Based on linux/arch/arm/mach-integrator/clock.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/list.h>
15#include <linux/errno.h>
16#include <linux/err.h>
17
18#include <asm/semaphore.h>
19#include <asm/hardware/clock.h>
20
21#include "clock.h"
22
23static LIST_HEAD(clocks);
24static DECLARE_MUTEX(clocks_sem);
25
26struct clk *clk_get(struct device *dev, const char *id)
27{
28 struct clk *p, *clk = ERR_PTR(-ENOENT);
29
30 down(&clocks_sem);
31 list_for_each_entry(p, &clocks, node) {
32 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
33 clk = p;
34 break;
35 }
36 }
37 up(&clocks_sem);
38
39 return clk;
40}
41EXPORT_SYMBOL(clk_get);
42
43void clk_put(struct clk *clk)
44{
45 module_put(clk->owner);
46}
47EXPORT_SYMBOL(clk_put);
48
49int clk_enable(struct clk *clk)
50{
51 return 0;
52}
53EXPORT_SYMBOL(clk_enable);
54
55void clk_disable(struct clk *clk)
56{
57}
58EXPORT_SYMBOL(clk_disable);
59
60int clk_use(struct clk *clk)
61{
62 return 0;
63}
64EXPORT_SYMBOL(clk_use);
65
66void clk_unuse(struct clk *clk)
67{
68}
69EXPORT_SYMBOL(clk_unuse);
70
71unsigned long clk_get_rate(struct clk *clk)
72{
73 return clk->rate;
74}
75EXPORT_SYMBOL(clk_get_rate);
76
77long clk_round_rate(struct clk *clk, unsigned long rate)
78{
79 return rate;
80}
81EXPORT_SYMBOL(clk_round_rate);
82
83int clk_set_rate(struct clk *clk, unsigned long rate)
84{
85 return 0;
86}
87EXPORT_SYMBOL(clk_set_rate);
88
89int clk_register(struct clk *clk)
90{
91 down(&clocks_sem);
92 list_add(&clk->node, &clocks);
93 up(&clocks_sem);
94 return 0;
95}
96EXPORT_SYMBOL(clk_register);
97
98void clk_unregister(struct clk *clk)
99{
100 down(&clocks_sem);
101 list_del(&clk->node);
102 up(&clocks_sem);
103}
104EXPORT_SYMBOL(clk_unregister);
105
106static int __init clk_init(void)
107{
108 return 0;
109}
110arch_initcall(clk_init);
diff --git a/arch/arm/mach-aaec2000/clock.h b/arch/arm/mach-aaec2000/clock.h
new file mode 100644
index 000000000000..d4bb74ff613f
--- /dev/null
+++ b/arch/arm/mach-aaec2000/clock.h
@@ -0,0 +1,23 @@
1/*
2 * linux/arch/arm/mach-aaec2000/clock.h
3 *
4 * Copyright (C) 2005 Nicolas Bellido Y Ortega
5 *
6 * Based on linux/arch/arm/mach-integrator/clock.h
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12struct module;
13
14struct clk {
15 struct list_head node;
16 unsigned long rate;
17 struct module *owner;
18 const char *name;
19 void *data;
20};
21
22int clk_register(struct clk *clk);
23void clk_unregister(struct clk *clk);
diff --git a/arch/arm/mach-aaec2000/core.c b/arch/arm/mach-aaec2000/core.c
index aece0cd4f0a3..0c53dab80905 100644
--- a/arch/arm/mach-aaec2000/core.c
+++ b/arch/arm/mach-aaec2000/core.c
@@ -13,19 +13,27 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/device.h>
16#include <linux/list.h> 17#include <linux/list.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/dma-mapping.h>
18#include <linux/interrupt.h> 20#include <linux/interrupt.h>
19#include <linux/timex.h> 21#include <linux/timex.h>
20#include <linux/signal.h> 22#include <linux/signal.h>
21 23
22#include <asm/hardware.h> 24#include <asm/hardware.h>
23#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/sizes.h>
27#include <asm/hardware/amba.h>
24 28
29#include <asm/mach/flash.h>
25#include <asm/mach/irq.h> 30#include <asm/mach/irq.h>
26#include <asm/mach/time.h> 31#include <asm/mach/time.h>
27#include <asm/mach/map.h> 32#include <asm/mach/map.h>
28 33
34#include "core.h"
35#include "clock.h"
36
29/* 37/*
30 * Common I/O mapping: 38 * Common I/O mapping:
31 * 39 *
@@ -40,9 +48,17 @@
40 * default mapping provided here. 48 * default mapping provided here.
41 */ 49 */
42static struct map_desc standard_io_desc[] __initdata = { 50static struct map_desc standard_io_desc[] __initdata = {
43 /* virtual physical length type */ 51 {
44 { VIO_APB_BASE, PIO_APB_BASE, IO_APB_LENGTH, MT_DEVICE }, 52 .virtual = VIO_APB_BASE,
45 { VIO_AHB_BASE, PIO_AHB_BASE, IO_AHB_LENGTH, MT_DEVICE } 53 .physical = __phys_to_pfn(PIO_APB_BASE),
54 .length = IO_APB_LENGTH,
55 .type = MT_DEVICE
56 }, {
57 .virtual = VIO_AHB_BASE,
58 .physical = __phys_to_pfn(PIO_AHB_BASE),
59 .length = IO_AHB_LENGTH,
60 .type = MT_DEVICE
61 }
46}; 62};
47 63
48void __init aaec2000_map_io(void) 64void __init aaec2000_map_io(void)
@@ -155,3 +171,116 @@ struct sys_timer aaec2000_timer = {
155 .offset = aaec2000_gettimeoffset, 171 .offset = aaec2000_gettimeoffset,
156}; 172};
157 173
174static struct clcd_panel mach_clcd_panel;
175
176static int aaec2000_clcd_setup(struct clcd_fb *fb)
177{
178 dma_addr_t dma;
179
180 fb->panel = &mach_clcd_panel;
181
182 fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, SZ_1M,
183 &dma, GFP_KERNEL);
184
185 if (!fb->fb.screen_base) {
186 printk(KERN_ERR "CLCD: unable to map framebuffer\n");
187 return -ENOMEM;
188 }
189
190 fb->fb.fix.smem_start = dma;
191 fb->fb.fix.smem_len = SZ_1M;
192
193 return 0;
194}
195
196static int aaec2000_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
197{
198 return dma_mmap_writecombine(&fb->dev->dev, vma,
199 fb->fb.screen_base,
200 fb->fb.fix.smem_start,
201 fb->fb.fix.smem_len);
202}
203
204static void aaec2000_clcd_remove(struct clcd_fb *fb)
205{
206 dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
207 fb->fb.screen_base, fb->fb.fix.smem_start);
208}
209
210static struct clcd_board clcd_plat_data = {
211 .name = "AAEC-2000",
212 .check = clcdfb_check,
213 .decode = clcdfb_decode,
214 .setup = aaec2000_clcd_setup,
215 .mmap = aaec2000_clcd_mmap,
216 .remove = aaec2000_clcd_remove,
217};
218
219static struct amba_device clcd_device = {
220 .dev = {
221 .bus_id = "mb:16",
222 .coherent_dma_mask = ~0,
223 .platform_data = &clcd_plat_data,
224 },
225 .res = {
226 .start = AAEC_CLCD_PHYS,
227 .end = AAEC_CLCD_PHYS + SZ_4K - 1,
228 .flags = IORESOURCE_MEM,
229 },
230 .irq = { INT_LCD, NO_IRQ },
231 .periphid = 0x41110,
232};
233
234static struct amba_device *amba_devs[] __initdata = {
235 &clcd_device,
236};
237
238static struct clk aaec2000_clcd_clk = {
239 .name = "CLCDCLK",
240};
241
242void __init aaec2000_set_clcd_plat_data(struct aaec2000_clcd_info *clcd)
243{
244 clcd_plat_data.enable = clcd->enable;
245 clcd_plat_data.disable = clcd->disable;
246 memcpy(&mach_clcd_panel, &clcd->panel, sizeof(struct clcd_panel));
247}
248
249static struct flash_platform_data aaec2000_flash_data = {
250 .map_name = "cfi_probe",
251 .width = 4,
252};
253
254static struct resource aaec2000_flash_resource = {
255 .start = AAEC_FLASH_BASE,
256 .end = AAEC_FLASH_BASE + AAEC_FLASH_SIZE,
257 .flags = IORESOURCE_MEM,
258};
259
260static struct platform_device aaec2000_flash_device = {
261 .name = "armflash",
262 .id = 0,
263 .dev = {
264 .platform_data = &aaec2000_flash_data,
265 },
266 .num_resources = 1,
267 .resource = &aaec2000_flash_resource,
268};
269
270static int __init aaec2000_init(void)
271{
272 int i;
273
274 clk_register(&aaec2000_clcd_clk);
275
276 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
277 struct amba_device *d = amba_devs[i];
278 amba_device_register(d, &iomem_resource);
279 }
280
281 platform_device_register(&aaec2000_flash_device);
282
283 return 0;
284};
285arch_initcall(aaec2000_init);
286
diff --git a/arch/arm/mach-aaec2000/core.h b/arch/arm/mach-aaec2000/core.h
index 91893d848c16..daefc0ea14a1 100644
--- a/arch/arm/mach-aaec2000/core.h
+++ b/arch/arm/mach-aaec2000/core.h
@@ -9,8 +9,19 @@
9 * 9 *
10 */ 10 */
11 11
12#include <asm/hardware/amba_clcd.h>
13
12struct sys_timer; 14struct sys_timer;
13 15
14extern struct sys_timer aaec2000_timer; 16extern struct sys_timer aaec2000_timer;
15extern void __init aaec2000_map_io(void); 17extern void __init aaec2000_map_io(void);
16extern void __init aaec2000_init_irq(void); 18extern void __init aaec2000_init_irq(void);
19
20struct aaec2000_clcd_info {
21 struct clcd_panel panel;
22 void (*disable)(struct clcd_fb *);
23 void (*enable)(struct clcd_fb *);
24};
25
26extern void __init aaec2000_set_clcd_plat_data(struct aaec2000_clcd_info *);
27
diff --git a/arch/arm/mach-clps711x/Kconfig b/arch/arm/mach-clps711x/Kconfig
index 0793dcf54f2e..d5c155045762 100644
--- a/arch/arm/mach-clps711x/Kconfig
+++ b/arch/arm/mach-clps711x/Kconfig
@@ -69,6 +69,17 @@ config EP72XX_ROM_BOOT
69 69
70 You almost surely want to say N here. 70 You almost surely want to say N here.
71 71
72config MACH_MP1000
73 bool "MACH_MP1000"
74 help
75 Say Y if you intend to run the kernel on the Comdial MP1000 platform.
76
77config MP1000_90MHZ
78 bool "MP1000_90MHZ"
79 depends on MACH_MP1000
80 help
81 Say Y if you have the MP1000 configured to be set at 90MHZ rather than 74MHZ
82
72endmenu 83endmenu
73 84
74endif 85endif
diff --git a/arch/arm/mach-clps711x/Makefile b/arch/arm/mach-clps711x/Makefile
index 4a197315f0cf..8a6dc1ccf8fe 100644
--- a/arch/arm/mach-clps711x/Makefile
+++ b/arch/arm/mach-clps711x/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_ARCH_CDB89712) += cdb89712.o
15obj-$(CONFIG_ARCH_CLEP7312) += clep7312.o 15obj-$(CONFIG_ARCH_CLEP7312) += clep7312.o
16obj-$(CONFIG_ARCH_EDB7211) += edb7211-arch.o edb7211-mm.o 16obj-$(CONFIG_ARCH_EDB7211) += edb7211-arch.o edb7211-mm.o
17obj-$(CONFIG_ARCH_FORTUNET) += fortunet.o 17obj-$(CONFIG_ARCH_FORTUNET) += fortunet.o
18obj-$(CONFIG_MACH_MP1000) += mp1000-mach.o mp1000-mm.o mp1000-seprom.o
18obj-$(CONFIG_ARCH_P720T) += p720t.o 19obj-$(CONFIG_ARCH_P720T) += p720t.o
19leds-$(CONFIG_ARCH_P720T) += p720t-leds.o 20leds-$(CONFIG_ARCH_P720T) += p720t-leds.o
20obj-$(CONFIG_LEDS) += $(leds-y) 21obj-$(CONFIG_LEDS) += $(leds-y)
diff --git a/arch/arm/mach-clps711x/autcpu12.c b/arch/arm/mach-clps711x/autcpu12.c
index dc73feb1ffb0..43b9423d1440 100644
--- a/arch/arm/mach-clps711x/autcpu12.c
+++ b/arch/arm/mach-clps711x/autcpu12.c
@@ -46,10 +46,14 @@
46*/ 46*/
47 47
48static struct map_desc autcpu12_io_desc[] __initdata = { 48static struct map_desc autcpu12_io_desc[] __initdata = {
49 /* virtual, physical, length, type */ 49 /* memory-mapped extra io and CS8900A Ethernet chip */
50 /* memory-mapped extra io and CS8900A Ethernet chip */ 50 /* ethernet chip */
51 /* ethernet chip */ 51 {
52 { AUTCPU12_VIRT_CS8900A, AUTCPU12_PHYS_CS8900A, SZ_1M, MT_DEVICE } 52 .virtual = AUTCPU12_VIRT_CS8900A,
53 .pfn = __phys_to_pfn(AUTCPU12_PHYS_CS8900A),
54 .length = SZ_1M,
55 .type = MT_DEVICE
56 }
53}; 57};
54 58
55void __init autcpu12_map_io(void) 59void __init autcpu12_map_io(void)
diff --git a/arch/arm/mach-clps711x/cdb89712.c b/arch/arm/mach-clps711x/cdb89712.c
index a46c82cd2711..cba7be5a06c3 100644
--- a/arch/arm/mach-clps711x/cdb89712.c
+++ b/arch/arm/mach-clps711x/cdb89712.c
@@ -39,7 +39,12 @@
39 * ethernet driver, perhaps. 39 * ethernet driver, perhaps.
40 */ 40 */
41static struct map_desc cdb89712_io_desc[] __initdata = { 41static struct map_desc cdb89712_io_desc[] __initdata = {
42 { ETHER_BASE, ETHER_START, ETHER_SIZE, MT_DEVICE } 42 {
43 .virtual = ETHER_BASE,
44 .pfn =__phys_to_pfn(ETHER_START),
45 .length = ETHER_SIZE,
46 .type = MT_DEVICE
47 }
43}; 48};
44 49
45static void __init cdb89712_map_io(void) 50static void __init cdb89712_map_io(void)
diff --git a/arch/arm/mach-clps711x/ceiva.c b/arch/arm/mach-clps711x/ceiva.c
index 780d91805984..35d51a759b59 100644
--- a/arch/arm/mach-clps711x/ceiva.c
+++ b/arch/arm/mach-clps711x/ceiva.c
@@ -37,11 +37,13 @@
37#include "common.h" 37#include "common.h"
38 38
39static struct map_desc ceiva_io_desc[] __initdata = { 39static struct map_desc ceiva_io_desc[] __initdata = {
40 /* virtual, physical, length, type */ 40 /* SED1355 controlled video RAM & registers */
41 41 {
42 /* SED1355 controlled video RAM & registers */ 42 .virtual = CEIVA_VIRT_SED1355,
43 { CEIVA_VIRT_SED1355, CEIVA_PHYS_SED1355, SZ_2M, MT_DEVICE } 43 .pfn = __phys_to_pfn(CEIVA_PHYS_SED1355),
44 44 .length = SZ_2M,
45 .type = MT_DEVICE
46 }
45}; 47};
46 48
47 49
diff --git a/arch/arm/mach-clps711x/edb7211-mm.c b/arch/arm/mach-clps711x/edb7211-mm.c
index 7fd7b01822d0..72f8bb05d55e 100644
--- a/arch/arm/mach-clps711x/edb7211-mm.c
+++ b/arch/arm/mach-clps711x/edb7211-mm.c
@@ -51,15 +51,27 @@ extern void clps711x_map_io(void);
51 * happens). 51 * happens).
52 */ 52 */
53static struct map_desc edb7211_io_desc[] __initdata = { 53static struct map_desc edb7211_io_desc[] __initdata = {
54 /* virtual, physical, length, type */ 54 { /* memory-mapped extra keyboard row */
55 55 .virtual = EP7211_VIRT_EXTKBD,
56 /* memory-mapped extra keyboard row and CS8900A Ethernet chip */ 56 .pfn = __phys_to_pfn(EP7211_PHYS_EXTKBD),
57 { EP7211_VIRT_EXTKBD, EP7211_PHYS_EXTKBD, SZ_1M, MT_DEVICE }, 57 .length = SZ_1M,
58 { EP7211_VIRT_CS8900A, EP7211_PHYS_CS8900A, SZ_1M, MT_DEVICE }, 58 .type - MT_DEVICE
59 59 }, { /* and CS8900A Ethernet chip */
60 /* flash banks */ 60 .virtual = EP7211_VIRT_CS8900A,
61 { EP7211_VIRT_FLASH1, EP7211_PHYS_FLASH1, SZ_8M, MT_DEVICE }, 61 .pfn = __phys_to_pfn(EP7211_PHYS_CS8900A),
62 { EP7211_VIRT_FLASH2, EP7211_PHYS_FLASH2, SZ_8M, MT_DEVICE } 62 .length = SZ_1M,
63 .type = MT_DEVICE
64 }, { /* flash banks */
65 .virtual = EP7211_VIRT_FLASH1,
66 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH1),
67 .length = SZ_8M,
68 .type = MT_DEVICE
69 }, {
70 .virtual = EP7211_VIRT_FLASH2,
71 .pfn = __phys_to_pfn(EP7211_PHYS_FLASH2),
72 .length = SZ_8M,
73 .type = MT_DEVICE
74 }
63}; 75};
64 76
65void __init edb7211_map_io(void) 77void __init edb7211_map_io(void)
diff --git a/arch/arm/mach-clps711x/mm.c b/arch/arm/mach-clps711x/mm.c
index 120b7cac84b5..a00f77ef8df8 100644
--- a/arch/arm/mach-clps711x/mm.c
+++ b/arch/arm/mach-clps711x/mm.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/bootmem.h> 25#include <linux/bootmem.h>
26 26
27#include <asm/sizes.h>
27#include <asm/hardware.h> 28#include <asm/hardware.h>
28#include <asm/pgtable.h> 29#include <asm/pgtable.h>
29#include <asm/page.h> 30#include <asm/page.h>
@@ -34,7 +35,12 @@
34 * This maps the generic CLPS711x registers 35 * This maps the generic CLPS711x registers
35 */ 36 */
36static struct map_desc clps711x_io_desc[] __initdata = { 37static struct map_desc clps711x_io_desc[] __initdata = {
37 { CLPS7111_VIRT_BASE, CLPS7111_PHYS_BASE, 1048576, MT_DEVICE } 38 {
39 .virtual = CLPS7111_VIRT_BASE,
40 .pfn = __phys_to_pfn(CLPS7111_PHYS_BASE),
41 .length = SZ_1M,
42 .type = MT_DEVICE
43 }
38}; 44};
39 45
40void __init clps711x_map_io(void) 46void __init clps711x_map_io(void)
diff --git a/arch/arm/mach-clps711x/mp1000-mach.c b/arch/arm/mach-clps711x/mp1000-mach.c
new file mode 100644
index 000000000000..c2816bcde5e7
--- /dev/null
+++ b/arch/arm/mach-clps711x/mp1000-mach.c
@@ -0,0 +1,49 @@
1/*
2 * linux/arch/arm/mach-mp1000/mp1000.c
3 *
4 * Copyright (C) 2005 Comdial Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <linux/init.h>
21#include <linux/types.h>
22#include <linux/string.h>
23
24#include <asm/setup.h>
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/arch/mp1000-seprom.h>
28
29#include "common.h"
30
31extern void mp1000_map_io(void);
32
33static void __init mp1000_init(void)
34{
35 seprom_init();
36}
37
38MACHINE_START(MP1000, "Comdial MP1000")
39 /* Maintainer: Jon Ringle */
40 .phys_ram = 0xc0000000,
41 .phys_io = 0x80000000,
42 .io_pg_offst = ((0xff000000) >> 18) & 0xfffc,
43 .boot_params = 0xc0015100,
44 .map_io = mp1000_map_io,
45 .init_irq = clps711x_init_irq,
46 .init_machine = mp1000_init,
47 .timer = &clps711x_timer,
48MACHINE_END
49
diff --git a/arch/arm/mach-clps711x/mp1000-mm.c b/arch/arm/mach-clps711x/mp1000-mm.c
new file mode 100644
index 000000000000..20e810b0ec0c
--- /dev/null
+++ b/arch/arm/mach-clps711x/mp1000-mm.c
@@ -0,0 +1,47 @@
1/*
2 * linux/arch/arm/mach-mp1000/mm.c
3 *
4 * Extra MM routines for the MP1000
5 *
6 * Copyright (C) 2005 Comdial Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <linux/kernel.h>
23#include <linux/init.h>
24
25#include <asm/hardware.h>
26#include <asm/page.h>
27#include <asm/pgtable.h>
28#include <asm/sizes.h>
29
30#include <asm/mach/map.h>
31
32extern void clps711x_map_io(void);
33
34static struct map_desc mp1000_io_desc[] __initdata = {
35 { MP1000_EIO_BASE, MP1000_EIO_START, MP1000_EIO_SIZE, MT_DEVICE },
36 { MP1000_FIO_BASE, MP1000_FIO_START, MP1000_FIO_SIZE, MT_DEVICE },
37 { MP1000_LIO_BASE, MP1000_LIO_START, MP1000_LIO_SIZE, MT_DEVICE },
38 { MP1000_NIO_BASE, MP1000_NIO_START, MP1000_NIO_SIZE, MT_DEVICE },
39 { MP1000_IDE_BASE, MP1000_IDE_START, MP1000_IDE_SIZE, MT_DEVICE },
40 { MP1000_DSP_BASE, MP1000_DSP_START, MP1000_DSP_SIZE, MT_DEVICE }
41};
42
43void __init mp1000_map_io(void)
44{
45 clps711x_map_io();
46 iotable_init(mp1000_io_desc, ARRAY_SIZE(mp1000_io_desc));
47}
diff --git a/arch/arm/mach-clps711x/mp1000-seprom.c b/arch/arm/mach-clps711x/mp1000-seprom.c
new file mode 100644
index 000000000000..b22d0bebb851
--- /dev/null
+++ b/arch/arm/mach-clps711x/mp1000-seprom.c
@@ -0,0 +1,195 @@
1/*`
2 * mp1000-seprom.c
3 *
4 * This file contains the Serial EEPROM code for the MP1000 board
5 *
6 * Copyright (C) 2005 Comdial Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/kernel.h>
25#include <linux/init.h>
26#include <asm/hardware.h>
27#include <asm/hardware/clps7111.h>
28#include <asm/arch/mp1000-seprom.h>
29
30/* If SepromInit() can initialize and checksum the seprom successfully, */
31/* then it will point seprom_data_ptr at the shadow copy. */
32
33static eeprom_struct seprom_data; /* shadow copy of seprom content */
34
35eeprom_struct *seprom_data_ptr = 0; /* 0 => not initialized */
36
37/*
38 * Port D Bit 5 is Chip Select for EEPROM
39 * Port E Bit 0 is Input, Data out from EEPROM
40 * Port E Bit 1 is Output, Data in to EEPROM
41 * Port E Bit 2 is Output, CLK to EEPROM
42 */
43
44static char *port_d_ptr = (char *)(CLPS7111_VIRT_BASE + PDDR);
45static char *port_e_ptr = (char *)(CLPS7111_VIRT_BASE + PEDR);
46
47#define NO_OF_SHORTS 64 // Device is 64 x 16 bits
48#define ENABLE_RW 0
49#define DISABLE_RW 1
50
51static inline void toggle_seprom_clock(void)
52{
53 *port_e_ptr |= HwPortESepromCLK;
54 *port_e_ptr &= ~(HwPortESepromCLK);
55}
56
57static inline void select_eeprom(void)
58{
59 *port_d_ptr |= HwPortDEECS;
60 *port_e_ptr &= ~(HwPortESepromCLK);
61}
62
63static inline void deselect_eeprom(void)
64{
65 *port_d_ptr &= ~(HwPortDEECS);
66 *port_e_ptr &= ~(HwPortESepromDIn);
67}
68
69/*
70 * GetSepromDataPtr - returns pointer to shadow (RAM) copy of seprom
71 * and returns 0 if seprom is not initialized or
72 * has a checksum error.
73 */
74
75eeprom_struct* get_seprom_ptr(void)
76{
77 return seprom_data_ptr;
78}
79
80unsigned char* get_eeprom_mac_address(void)
81{
82 return seprom_data_ptr->variant.eprom_struct.mac_Address;
83}
84
85/*
86 * ReadSProm, Physically reads data from the Serial PROM
87 */
88static void read_sprom(short address, int length, eeprom_struct *buffer)
89{
90 short data = COMMAND_READ | (address & 0x3F);
91 short bit;
92 int i;
93
94 select_eeprom();
95
96 // Clock in 9 bits of the command
97 for (i = 0, bit = 0x100; i < 9; i++, bit >>= 1) {
98 if (data & bit)
99 *port_e_ptr |= HwPortESepromDIn;
100 else
101 *port_e_ptr &= ~(HwPortESepromDIn);
102
103 toggle_seprom_clock();
104 }
105
106 //
107 // Now read one or more shorts of data from the Seprom
108 //
109 while (length-- > 0) {
110 data = 0;
111
112 // Read 16 bits at a time
113 for (i = 0; i < 16; i++) {
114 data <<= 1;
115 toggle_seprom_clock();
116 data |= *port_e_ptr & HwPortESepromDOut;
117
118 }
119
120 buffer->variant.eprom_short_data[address++] = data;
121 }
122
123 deselect_eeprom();
124
125 return;
126}
127
128
129
130/*
131 * ReadSerialPROM
132 *
133 * Input: Pointer to array of 64 x 16 Bits
134 *
135 * Output: if no problem reading data is filled in
136 */
137static void read_serial_prom(eeprom_struct *data)
138{
139 read_sprom(0, 64, data);
140}
141
142
143//
144// Compute Serial EEPROM checksum
145//
146// Input: Pointer to struct with Eprom data
147//
148// Output: The computed Eprom checksum
149//
150static short compute_seprom_checksum(eeprom_struct *data)
151{
152 short checksum = 0;
153 int i;
154
155 for (i = 0; i < 126; i++) {
156 checksum += (short)data->variant.eprom_byte_data[i];
157 }
158
159 return((short)(0x5555 - (checksum & 0xFFFF)));
160}
161
162//
163// Make sure the data port bits for the SEPROM are correctly initialised
164//
165
166void __init seprom_init(void)
167{
168 short checksum;
169
170 // Init Port D
171 *(char *)(CLPS7111_VIRT_BASE + PDDDR) = 0x0;
172 *(char *)(CLPS7111_VIRT_BASE + PDDR) = 0x15;
173
174 // Init Port E
175 *(int *)(CLPS7111_VIRT_BASE + PEDDR) = 0x06;
176 *(int *)(CLPS7111_VIRT_BASE + PEDR) = 0x04;
177
178 //
179 // Make sure that EEPROM struct size never exceeds 128 bytes
180 //
181 if (sizeof(eeprom_struct) > 128) {
182 panic("Serial PROM struct size > 128, aborting read\n");
183 }
184
185 read_serial_prom(&seprom_data);
186
187 checksum = compute_seprom_checksum(&seprom_data);
188
189 if (checksum != seprom_data.variant.eprom_short_data[63]) {
190 panic("Serial EEPROM checksum failed\n");
191 }
192
193 seprom_data_ptr = &seprom_data;
194}
195
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index 5bdb90edf992..a1acb945fb51 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -29,6 +29,7 @@
29#include <asm/pgtable.h> 29#include <asm/pgtable.h>
30#include <asm/page.h> 30#include <asm/page.h>
31#include <asm/setup.h> 31#include <asm/setup.h>
32#include <asm/sizes.h>
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
34#include <asm/mach/map.h> 35#include <asm/mach/map.h>
@@ -42,8 +43,17 @@
42 * We map both here. 43 * We map both here.
43 */ 44 */
44static struct map_desc p720t_io_desc[] __initdata = { 45static struct map_desc p720t_io_desc[] __initdata = {
45 { SYSPLD_VIRT_BASE, SYSPLD_PHYS_BASE, 1048576, MT_DEVICE }, 46 {
46 { 0xfe400000, 0x10400000, 1048576, MT_DEVICE } 47 .virtual = SYSPLD_VIRT_BASE,
48 .pfn = __phys_to_pfn(SYSPLD_PHYS_BASE),
49 .length = SZ_1M,
50 .type = MT_DEVICE
51 }, {
52 .virtual = 0xfe400000,
53 .pfn = __phys_to_pfn(0x10400000),
54 .length = SZ_1M,
55 .type = MT_DEVICE
56 }
47}; 57};
48 58
49static void __init 59static void __init
diff --git a/arch/arm/mach-clps7500/core.c b/arch/arm/mach-clps7500/core.c
index e216ab8b9e8f..0364ba4b539e 100644
--- a/arch/arm/mach-clps7500/core.c
+++ b/arch/arm/mach-clps7500/core.c
@@ -259,10 +259,27 @@ static void __init clps7500_init_irq(void)
259} 259}
260 260
261static struct map_desc cl7500_io_desc[] __initdata = { 261static struct map_desc cl7500_io_desc[] __initdata = {
262 { IO_BASE, IO_START, IO_SIZE, MT_DEVICE }, /* IO space */ 262 { /* IO space */
263 { ISA_BASE, ISA_START, ISA_SIZE, MT_DEVICE }, /* ISA space */ 263 .virtual = IO_BASE,
264 { FLASH_BASE, FLASH_START, FLASH_SIZE, MT_DEVICE }, /* Flash */ 264 .pfn = __phys_to_pfn(IO_START),
265 { LED_BASE, LED_START, LED_SIZE, MT_DEVICE } /* LED */ 265 .length = IO_SIZE,
266 .type = MT_DEVICE
267 }, { /* ISA space */
268 .virtual = ISA_BASE,
269 .pfn = __phys_to_pfn(ISA_START),
270 .length = ISA_SIZE,
271 .type = MT_DEVICE
272 }, { /* Flash */
273 .virtual = FLASH_BASE,
274 .pfn = __phys_to_pfn(FLASH_START),
275 .length = FLASH_SIZE,
276 .type = MT_DEVICE
277 }, { /* LED */
278 .virtual = LED_BASE,
279 .pfn = __phys_to_pfn(LED_START),
280 .length = LED_SIZE,
281 .type = MT_DEVICE
282 }
266}; 283};
267 284
268static void __init clps7500_map_io(void) 285static void __init clps7500_map_io(void)
diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
index 5aeadfd72143..15261646dcdd 100644
--- a/arch/arm/mach-ebsa110/core.c
+++ b/arch/arm/mach-ebsa110/core.c
@@ -76,16 +76,42 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
76 /* 76 /*
77 * sparse external-decode ISAIO space 77 * sparse external-decode ISAIO space
78 */ 78 */
79 { IRQ_STAT, TRICK4_PHYS, PGDIR_SIZE, MT_DEVICE }, /* IRQ_STAT/IRQ_MCLR */ 79 { /* IRQ_STAT/IRQ_MCLR */
80 { IRQ_MASK, TRICK3_PHYS, PGDIR_SIZE, MT_DEVICE }, /* IRQ_MASK/IRQ_MSET */ 80 .virtual = IRQ_STAT,
81 { SOFT_BASE, TRICK1_PHYS, PGDIR_SIZE, MT_DEVICE }, /* SOFT_BASE */ 81 .pfn = __phys_to_pfn(TRICK4_PHYS),
82 { PIT_BASE, TRICK0_PHYS, PGDIR_SIZE, MT_DEVICE }, /* PIT_BASE */ 82 .length = PGDIR_SIZE,
83 .type = MT_DEVICE
84 }, { /* IRQ_MASK/IRQ_MSET */
85 .virtual = IRQ_MASK,
86 .pfn = __phys_to_pfn(TRICK3_PHYS),
87 .length = PGDIR_SIZE,
88 .type = MT_DEVICE
89 }, { /* SOFT_BASE */
90 .virtual = SOFT_BASE,
91 .pfn = __phys_to_pfn(TRICK1_PHYS),
92 .length = PGDIR_SIZE,
93 .type = MT_DEVICE
94 }, { /* PIT_BASE */
95 .virtual = PIT_BASE,
96 .pfn = __phys_to_pfn(TRICK0_PHYS),
97 .length = PGDIR_SIZE,
98 .type = MT_DEVICE
99 },
83 100
84 /* 101 /*
85 * self-decode ISAIO space 102 * self-decode ISAIO space
86 */ 103 */
87 { ISAIO_BASE, ISAIO_PHYS, ISAIO_SIZE, MT_DEVICE }, 104 {
88 { ISAMEM_BASE, ISAMEM_PHYS, ISAMEM_SIZE, MT_DEVICE } 105 .virtual = ISAIO_BASE,
106 .pfn = __phys_to_pfn(ISAIO_PHYS),
107 .length = ISAIO_SIZE,
108 .type = MT_DEVICE
109 }, {
110 .virtual = ISAMEM_BASE,
111 .pfn = __phys_to_pfn(ISAMEM_PHYS),
112 .length = ISAMEM_SIZE,
113 .type = MT_DEVICE
114 }
89}; 115};
90 116
91static void __init ebsa110_map_io(void) 117static void __init ebsa110_map_io(void)
diff --git a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c
index ef7eb5dc91bd..c648bfb676a1 100644
--- a/arch/arm/mach-ebsa110/io.c
+++ b/arch/arm/mach-ebsa110/io.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/types.h> 25#include <linux/types.h>
26 26
27#include <asm/hardware.h>
27#include <asm/io.h> 28#include <asm/io.h>
28#include <asm/page.h> 29#include <asm/page.h>
29 30
diff --git a/arch/arm/mach-epxa10db/mm.c b/arch/arm/mach-epxa10db/mm.c
index 2aa57fa46da3..e8832d0910ee 100644
--- a/arch/arm/mach-epxa10db/mm.c
+++ b/arch/arm/mach-epxa10db/mm.c
@@ -31,12 +31,37 @@
31/* Page table mapping for I/O region */ 31/* Page table mapping for I/O region */
32 32
33static struct map_desc epxa10db_io_desc[] __initdata = { 33static struct map_desc epxa10db_io_desc[] __initdata = {
34 { IO_ADDRESS(EXC_REGISTERS_BASE), EXC_REGISTERS_BASE, SZ_16K, MT_DEVICE }, 34 {
35 { IO_ADDRESS(EXC_PLD_BLOCK0_BASE), EXC_PLD_BLOCK0_BASE, SZ_16K, MT_DEVICE }, 35 .virtual = IO_ADDRESS(EXC_REGISTERS_BASE),
36 { IO_ADDRESS(EXC_PLD_BLOCK1_BASE), EXC_PLD_BLOCK1_BASE, SZ_16K, MT_DEVICE }, 36 .pfn = __phys_to_pfn(EXC_REGISTERS_BASE),
37 { IO_ADDRESS(EXC_PLD_BLOCK2_BASE), EXC_PLD_BLOCK2_BASE, SZ_16K, MT_DEVICE }, 37 .length = SZ_16K,
38 { IO_ADDRESS(EXC_PLD_BLOCK3_BASE), EXC_PLD_BLOCK3_BASE, SZ_16K, MT_DEVICE }, 38 .type = MT_DEVICE
39 { FLASH_VADDR(EXC_EBI_BLOCK0_BASE), EXC_EBI_BLOCK0_BASE, SZ_16M, MT_DEVICE } 39 }, {
40 .virtual = IO_ADDRESS(EXC_PLD_BLOCK0_BASE),
41 .pfn = __phys_to_pfn(EXC_PLD_BLOCK0_BASE),
42 .length = SZ_16K,
43 .type = MT_DEVICE
44 }, {
45 .virtual = IO_ADDRESS(EXC_PLD_BLOCK1_BASE),
46 .pfn =__phys_to_pfn(EXC_PLD_BLOCK1_BASE),
47 .length = SZ_16K,
48 .type = MT_DEVICE
49 }, {
50 .virtual = IO_ADDRESS(EXC_PLD_BLOCK2_BASE),
51 .physical = __phys_to_pfn(EXC_PLD_BLOCK2_BASE),
52 .length = SZ_16K,
53 .type = MT_DEVICE
54 }, {
55 .virtual = IO_ADDRESS(EXC_PLD_BLOCK3_BASE),
56 .pfn = __phys_to_pfn(EXC_PLD_BLOCK3_BASE),
57 .length = SZ_16K,
58 .type = MT_DEVICE
59 }, {
60 .virtual = FLASH_VADDR(EXC_EBI_BLOCK0_BASE),
61 .pfn = __phys_to_pfn(EXC_EBI_BLOCK0_BASE),
62 .length = SZ_16M,
63 .type = MT_DEVICE
64 }
40}; 65};
41 66
42void __init epxa10db_map_io(void) 67void __init epxa10db_map_io(void)
diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c
index eb8238c1ef06..dc09fd200c16 100644
--- a/arch/arm/mach-footbridge/common.c
+++ b/arch/arm/mach-footbridge/common.c
@@ -130,8 +130,17 @@ void __init footbridge_init_irq(void)
130 * it means that we have extra bullet protection on our feet. 130 * it means that we have extra bullet protection on our feet.
131 */ 131 */
132static struct map_desc fb_common_io_desc[] __initdata = { 132static struct map_desc fb_common_io_desc[] __initdata = {
133 { ARMCSR_BASE, DC21285_ARMCSR_BASE, ARMCSR_SIZE, MT_DEVICE }, 133 {
134 { XBUS_BASE, 0x40000000, XBUS_SIZE, MT_DEVICE } 134 .virtual = ARMCSR_BASE,
135 .pfn = DC21285_ARMCSR_BASE,
136 .length = ARMCSR_SIZE,
137 .type = MT_DEVICE
138 }, {
139 .virtual = XBUS_BASE,
140 .pfn = __phys_to_pfn(0x40000000),
141 .length = XBUS_SIZE,
142 .type = MT_DEVICE
143 }
135}; 144};
136 145
137/* 146/*
@@ -140,11 +149,32 @@ static struct map_desc fb_common_io_desc[] __initdata = {
140 */ 149 */
141static struct map_desc ebsa285_host_io_desc[] __initdata = { 150static struct map_desc ebsa285_host_io_desc[] __initdata = {
142#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST) 151#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)
143 { PCIMEM_BASE, DC21285_PCI_MEM, PCIMEM_SIZE, MT_DEVICE }, 152 {
144 { PCICFG0_BASE, DC21285_PCI_TYPE_0_CONFIG, PCICFG0_SIZE, MT_DEVICE }, 153 .virtual = PCIMEM_BASE,
145 { PCICFG1_BASE, DC21285_PCI_TYPE_1_CONFIG, PCICFG1_SIZE, MT_DEVICE }, 154 .pfn = __phys_to_pfn(DC21285_PCI_MEM),
146 { PCIIACK_BASE, DC21285_PCI_IACK, PCIIACK_SIZE, MT_DEVICE }, 155 .length = PCIMEM_SIZE,
147 { PCIO_BASE, DC21285_PCI_IO, PCIO_SIZE, MT_DEVICE } 156 .type = MT_DEVICE
157 }, {
158 .virtual = PCICFG0_BASE,
159 .pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG),
160 .length = PCICFG0_SIZE,
161 .type = MT_DEVICE
162 }, {
163 .virtual = PCICFG1_BASE,
164 .pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG),
165 .length = PCICFG1_SIZE,
166 .type = MT_DEVICE
167 }, {
168 .virtual = PCIIACK_BASE,
169 .pfn = __phys_to_pfn(DC21285_PCI_IACK),
170 .length = PCIIACK_SIZE,
171 .type = MT_DEVICE
172 }, {
173 .virtual = PCIO_BASE,
174 .pfn = __phys_to_pfn(DC21285_PCI_IO),
175 .length = PCIO_SIZE,
176 .type = MT_DEVICE
177 }
148#endif 178#endif
149}; 179};
150 180
@@ -153,8 +183,17 @@ static struct map_desc ebsa285_host_io_desc[] __initdata = {
153 */ 183 */
154static struct map_desc co285_io_desc[] __initdata = { 184static struct map_desc co285_io_desc[] __initdata = {
155#ifdef CONFIG_ARCH_CO285 185#ifdef CONFIG_ARCH_CO285
156 { PCIO_BASE, DC21285_PCI_IO, PCIO_SIZE, MT_DEVICE }, 186 {
157 { PCIMEM_BASE, DC21285_PCI_MEM, PCIMEM_SIZE, MT_DEVICE } 187 .virtual = PCIO_BASE,
188 .pfn = __phys_to_pfn(DC21285_PCI_IO),
189 .length = PCIO_SIZE,
190 .type = MT_DEVICE
191 }, {
192 .virtual = PCIMEM_BASE,
193 .pfn = __phys_to_pfn(DC21285_PCI_MEM),
194 .length = PCIMEM_SIZE,
195 .type = MT_DEVICE
196 }
158#endif 197#endif
159}; 198};
160 199
diff --git a/arch/arm/mach-h720x/common.c b/arch/arm/mach-h720x/common.c
index 5110e2e65ddd..c096b4569308 100644
--- a/arch/arm/mach-h720x/common.c
+++ b/arch/arm/mach-h720x/common.c
@@ -237,7 +237,12 @@ void __init h720x_init_irq (void)
237} 237}
238 238
239static struct map_desc h720x_io_desc[] __initdata = { 239static struct map_desc h720x_io_desc[] __initdata = {
240 { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE }, 240 {
241 .virtual = IO_VIRT,
242 .pfn = __phys_to_pfn(IO_PHYS),
243 .length = IO_SIZE,
244 .type = MT_DEVICE
245 },
241}; 246};
242 247
243/* Initialize io tables */ 248/* Initialize io tables */
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index f8a742bb2d5b..cb14b0682cef 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -273,8 +273,12 @@ static struct platform_device *devices[] __initdata = {
273}; 273};
274 274
275static struct map_desc imx_io_desc[] __initdata = { 275static struct map_desc imx_io_desc[] __initdata = {
276 /* virtual physical length type */ 276 {
277 {IMX_IO_BASE, IMX_IO_PHYS, IMX_IO_SIZE, MT_DEVICE}, 277 .virtual = IMX_IO_BASE,
278 .pfn = __phys_to_pfn(IMX_IO_PHYS),
279 .length = IMX_IO_SIZE,
280 .type = MT_DEVICE
281 }
278}; 282};
279 283
280void __init 284void __init
diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c
index a7511ddfe364..4cbdc1fe04b1 100644
--- a/arch/arm/mach-imx/mx1ads.c
+++ b/arch/arm/mach-imx/mx1ads.c
@@ -61,13 +61,37 @@ mx1ads_init(void)
61} 61}
62 62
63static struct map_desc mx1ads_io_desc[] __initdata = { 63static struct map_desc mx1ads_io_desc[] __initdata = {
64 /* virtual physical length type */ 64 {
65 {IMX_CS0_VIRT, IMX_CS0_PHYS, IMX_CS0_SIZE, MT_DEVICE}, 65 .virtual = IMX_CS0_VIRT,
66 {IMX_CS1_VIRT, IMX_CS1_PHYS, IMX_CS1_SIZE, MT_DEVICE}, 66 .pfn = __phys_to_pfn(IMX_CS0_PHYS),
67 {IMX_CS2_VIRT, IMX_CS2_PHYS, IMX_CS2_SIZE, MT_DEVICE}, 67 .length = IMX_CS0_SIZE,
68 {IMX_CS3_VIRT, IMX_CS3_PHYS, IMX_CS3_SIZE, MT_DEVICE}, 68 .type = MT_DEVICE
69 {IMX_CS4_VIRT, IMX_CS4_PHYS, IMX_CS4_SIZE, MT_DEVICE}, 69 }, {
70 {IMX_CS5_VIRT, IMX_CS5_PHYS, IMX_CS5_SIZE, MT_DEVICE}, 70 .virtual = IMX_CS1_VIRT,
71 .pfn = __phys_to_pfn(IMX_CS1_PHYS),
72 .length = IMX_CS1_SIZE,
73 .type = MT_DEVICE
74 }, {
75 .virtual = IMX_CS2_VIRT,
76 .pfn = __phys_to_pfn(IMX_CS2_PHYS),
77 .length = IMX_CS2_SIZE,
78 .type = MT_DEVICE
79 }, {
80 .virtual = IMX_CS3_VIRT,
81 .pfn = __phys_to_pfn(IMX_CS3_PHYS),
82 .length = IMX_CS3_SIZE,
83 .type = MT_DEVICE
84 }, {
85 .virtual = IMX_CS4_VIRT,
86 .pfn = __phys_to_pfn(IMX_CS4_PHYS),
87 .length = IMX_CS4_SIZE,
88 .type = MT_DEVICE
89 }, {
90 .virtual = IMX_CS5_VIRT,
91 .pfn = __phys_to_pfn(IMX_CS5_PHYS),
92 .length = IMX_CS5_SIZE,
93 .type = MT_DEVICE
94 }
71}; 95};
72 96
73static void __init 97static void __init
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 36e2b6eb67b7..f368b85f0447 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -75,19 +75,72 @@
75 */ 75 */
76 76
77static struct map_desc ap_io_desc[] __initdata = { 77static struct map_desc ap_io_desc[] __initdata = {
78 { IO_ADDRESS(INTEGRATOR_HDR_BASE), INTEGRATOR_HDR_BASE, SZ_4K, MT_DEVICE }, 78 {
79 { IO_ADDRESS(INTEGRATOR_SC_BASE), INTEGRATOR_SC_BASE, SZ_4K, MT_DEVICE }, 79 .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
80 { IO_ADDRESS(INTEGRATOR_EBI_BASE), INTEGRATOR_EBI_BASE, SZ_4K, MT_DEVICE }, 80 .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
81 { IO_ADDRESS(INTEGRATOR_CT_BASE), INTEGRATOR_CT_BASE, SZ_4K, MT_DEVICE }, 81 .length = SZ_4K,
82 { IO_ADDRESS(INTEGRATOR_IC_BASE), INTEGRATOR_IC_BASE, SZ_4K, MT_DEVICE }, 82 .type = MT_DEVICE
83 { IO_ADDRESS(INTEGRATOR_UART0_BASE), INTEGRATOR_UART0_BASE, SZ_4K, MT_DEVICE }, 83 }, {
84 { IO_ADDRESS(INTEGRATOR_UART1_BASE), INTEGRATOR_UART1_BASE, SZ_4K, MT_DEVICE }, 84 .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
85 { IO_ADDRESS(INTEGRATOR_DBG_BASE), INTEGRATOR_DBG_BASE, SZ_4K, MT_DEVICE }, 85 .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
86 { IO_ADDRESS(INTEGRATOR_GPIO_BASE), INTEGRATOR_GPIO_BASE, SZ_4K, MT_DEVICE }, 86 .length = SZ_4K,
87 { PCI_MEMORY_VADDR, PHYS_PCI_MEM_BASE, SZ_16M, MT_DEVICE }, 87 .type = MT_DEVICE
88 { PCI_CONFIG_VADDR, PHYS_PCI_CONFIG_BASE, SZ_16M, MT_DEVICE }, 88 }, {
89 { PCI_V3_VADDR, PHYS_PCI_V3_BASE, SZ_64K, MT_DEVICE }, 89 .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
90 { PCI_IO_VADDR, PHYS_PCI_IO_BASE, SZ_64K, MT_DEVICE } 90 .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
91 .length = SZ_4K,
92 .type = MT_DEVICE
93 }, {
94 .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
95 .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
96 .length = SZ_4K,
97 .type = MT_DEVICE
98 }, {
99 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
100 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
101 .length = SZ_4K,
102 .type = MT_DEVICE
103 }, {
104 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
105 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
106 .length = SZ_4K,
107 .type = MT_DEVICE
108 }, {
109 .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE),
110 .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE),
111 .length = SZ_4K,
112 .type = MT_DEVICE
113 }, {
114 .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
115 .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
116 .length = SZ_4K,
117 .type = MT_DEVICE
118 }, {
119 .virtual = IO_ADDRESS(INTEGRATOR_GPIO_BASE),
120 .pfn = __phys_to_pfn(INTEGRATOR_GPIO_BASE),
121 .length = SZ_4K,
122 .type = MT_DEVICE
123 }, {
124 .virtual = PCI_MEMORY_VADDR,
125 .pfn = __phys_to_pfn(PHYS_PCI_MEM_BASE),
126 .length = SZ_16M,
127 .type = MT_DEVICE
128 }, {
129 .virtual = PCI_CONFIG_VADDR,
130 .pfn = __phys_to_pfn(PHYS_PCI_CONFIG_BASE),
131 .length = SZ_16M,
132 .type = MT_DEVICE
133 }, {
134 .virtual = PCI_V3_VADDR,
135 .pfn = __phys_to_pfn(PHYS_PCI_V3_BASE),
136 .length = SZ_64K,
137 .type = MT_DEVICE
138 }, {
139 .virtual = PCI_IO_VADDR,
140 .pfn = __phys_to_pfn(PHYS_PCI_IO_BASE),
141 .length = SZ_64K,
142 .type = MT_DEVICE
143 }
91}; 144};
92 145
93static void __init ap_map_io(void) 146static void __init ap_map_io(void)
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 2be5c03ab87f..aa34c58b96c4 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -74,17 +74,62 @@
74 */ 74 */
75 75
76static struct map_desc intcp_io_desc[] __initdata = { 76static struct map_desc intcp_io_desc[] __initdata = {
77 { IO_ADDRESS(INTEGRATOR_HDR_BASE), INTEGRATOR_HDR_BASE, SZ_4K, MT_DEVICE }, 77 {
78 { IO_ADDRESS(INTEGRATOR_SC_BASE), INTEGRATOR_SC_BASE, SZ_4K, MT_DEVICE }, 78 .virtual = IO_ADDRESS(INTEGRATOR_HDR_BASE),
79 { IO_ADDRESS(INTEGRATOR_EBI_BASE), INTEGRATOR_EBI_BASE, SZ_4K, MT_DEVICE }, 79 .pfn = __phys_to_pfn(INTEGRATOR_HDR_BASE),
80 { IO_ADDRESS(INTEGRATOR_CT_BASE), INTEGRATOR_CT_BASE, SZ_4K, MT_DEVICE }, 80 .length = SZ_4K,
81 { IO_ADDRESS(INTEGRATOR_IC_BASE), INTEGRATOR_IC_BASE, SZ_4K, MT_DEVICE }, 81 .type = MT_DEVICE
82 { IO_ADDRESS(INTEGRATOR_UART0_BASE), INTEGRATOR_UART0_BASE, SZ_4K, MT_DEVICE }, 82 }, {
83 { IO_ADDRESS(INTEGRATOR_UART1_BASE), INTEGRATOR_UART1_BASE, SZ_4K, MT_DEVICE }, 83 .virtual = IO_ADDRESS(INTEGRATOR_SC_BASE),
84 { IO_ADDRESS(INTEGRATOR_DBG_BASE), INTEGRATOR_DBG_BASE, SZ_4K, MT_DEVICE }, 84 .pfn = __phys_to_pfn(INTEGRATOR_SC_BASE),
85 { IO_ADDRESS(INTEGRATOR_GPIO_BASE), INTEGRATOR_GPIO_BASE, SZ_4K, MT_DEVICE }, 85 .length = SZ_4K,
86 { 0xfca00000, 0xca000000, SZ_4K, MT_DEVICE }, 86 .type = MT_DEVICE
87 { 0xfcb00000, 0xcb000000, SZ_4K, MT_DEVICE }, 87 }, {
88 .virtual = IO_ADDRESS(INTEGRATOR_EBI_BASE),
89 .pfn = __phys_to_pfn(INTEGRATOR_EBI_BASE),
90 .length = SZ_4K,
91 .type = MT_DEVICE
92 }, {
93 .virtual = IO_ADDRESS(INTEGRATOR_CT_BASE),
94 .pfn = __phys_to_pfn(INTEGRATOR_CT_BASE),
95 .length = SZ_4K,
96 .type = MT_DEVICE
97 }, {
98 .virtual = IO_ADDRESS(INTEGRATOR_IC_BASE),
99 .pfn = __phys_to_pfn(INTEGRATOR_IC_BASE),
100 .length = SZ_4K,
101 .type = MT_DEVICE
102 }, {
103 .virtual = IO_ADDRESS(INTEGRATOR_UART0_BASE),
104 .pfn = __phys_to_pfn(INTEGRATOR_UART0_BASE),
105 .length = SZ_4K,
106 .type = MT_DEVICE
107 }, {
108 .virtual = IO_ADDRESS(INTEGRATOR_UART1_BASE),
109 .pfn = __phys_to_pfn(INTEGRATOR_UART1_BASE),
110 .length = SZ_4K,
111 .type = MT_DEVICE
112 }, {
113 .virtual = IO_ADDRESS(INTEGRATOR_DBG_BASE),
114 .pfn = __phys_to_pfn(INTEGRATOR_DBG_BASE),
115 .length = SZ_4K,
116 .type = MT_DEVICE
117 }, {
118 .virtual = IO_ADDRESS(INTEGRATOR_GPIO_BASE),
119 .pfn = __phys_to_pfn(INTEGRATOR_GPIO_BASE),
120 .length = SZ_4K,
121 .type = MT_DEVICE
122 }, {
123 .virtual = 0xfca00000,
124 .pfn = __phys_to_pfn(0xca000000),
125 .length = SZ_4K,
126 .type = MT_DEVICE
127 }, {
128 .virtual = 0xfcb00000,
129 .pfn = __phys_to_pfn(0xcb000000),
130 .length = SZ_4K,
131 .type = MT_DEVICE
132 }
88}; 133};
89 134
90static void __init intcp_map_io(void) 135static void __init intcp_map_io(void)
diff --git a/arch/arm/mach-iop3xx/iop321-setup.c b/arch/arm/mach-iop3xx/iop321-setup.c
index 0f921ba2750c..bb5091223b63 100644
--- a/arch/arm/mach-iop3xx/iop321-setup.c
+++ b/arch/arm/mach-iop3xx/iop321-setup.c
@@ -38,13 +38,17 @@
38 * Standard IO mapping for all IOP321 based systems 38 * Standard IO mapping for all IOP321 based systems
39 */ 39 */
40static struct map_desc iop321_std_desc[] __initdata = { 40static struct map_desc iop321_std_desc[] __initdata = {
41 /* virtual physical length type */ 41 { /* mem mapped registers */
42 42 .virtual = IOP321_VIRT_MEM_BASE,
43 /* mem mapped registers */ 43 .pfn = __phys_to_pfn(IOP321_PHYS_MEM_BASE),
44 { IOP321_VIRT_MEM_BASE, IOP321_PHYS_MEM_BASE, 0x00002000, MT_DEVICE }, 44 .length = 0x00002000,
45 45 .type = MT_DEVICE
46 /* PCI IO space */ 46 }, { /* PCI IO space */
47 { IOP321_PCI_LOWER_IO_VA, IOP321_PCI_LOWER_IO_PA, IOP321_PCI_IO_WINDOW_SIZE, MT_DEVICE } 47 .virtual = IOP321_PCI_LOWER_IO_VA,
48 .pfn = __phys_to_pfn(IOP321_PCI_LOWER_IO_PA),
49 .length = IOP321_PCI_IO_WINDOW_SIZE,
50 .type = MT_DEVICE
51 }
48}; 52};
49 53
50#ifdef CONFIG_ARCH_IQ80321 54#ifdef CONFIG_ARCH_IQ80321
diff --git a/arch/arm/mach-iop3xx/iop331-setup.c b/arch/arm/mach-iop3xx/iop331-setup.c
index fc74b722f72f..a2533c3ab42f 100644
--- a/arch/arm/mach-iop3xx/iop331-setup.c
+++ b/arch/arm/mach-iop3xx/iop331-setup.c
@@ -37,13 +37,17 @@
37 * Standard IO mapping for all IOP331 based systems 37 * Standard IO mapping for all IOP331 based systems
38 */ 38 */
39static struct map_desc iop331_std_desc[] __initdata = { 39static struct map_desc iop331_std_desc[] __initdata = {
40 /* virtual physical length type */ 40 { /* mem mapped registers */
41 41 .virtual = IOP331_VIRT_MEM_BASE,
42 /* mem mapped registers */ 42 .pfn = __phys_to_pfn(IOP331_PHYS_MEM_BASE),
43 { IOP331_VIRT_MEM_BASE, IOP331_PHYS_MEM_BASE, 0x00002000, MT_DEVICE }, 43 .length = 0x00002000,
44 44 .type = MT_DEVICE
45 /* PCI IO space */ 45 }, { /* PCI IO space */
46 { IOP331_PCI_LOWER_IO_VA, IOP331_PCI_LOWER_IO_PA, IOP331_PCI_IO_WINDOW_SIZE, MT_DEVICE } 46 .virtual = IOP331_PCI_LOWER_IO_VA,
47 .pfn = __phys_to_pfn(IOP331_PCI_LOWER_IO_PA),
48 .length = IOP331_PCI_IO_WINDOW_SIZE,
49 .type = MT_DEVICE
50 }
47}; 51};
48 52
49static struct uart_port iop331_serial_ports[] = { 53static struct uart_port iop331_serial_ports[] = {
diff --git a/arch/arm/mach-iop3xx/iq31244-mm.c b/arch/arm/mach-iop3xx/iq31244-mm.c
index 55992ab586ba..e874b54eefe3 100644
--- a/arch/arm/mach-iop3xx/iq31244-mm.c
+++ b/arch/arm/mach-iop3xx/iq31244-mm.c
@@ -29,10 +29,12 @@
29 * We use RedBoot's setup for the onboard devices. 29 * We use RedBoot's setup for the onboard devices.
30 */ 30 */
31static struct map_desc iq31244_io_desc[] __initdata = { 31static struct map_desc iq31244_io_desc[] __initdata = {
32 /* virtual physical length type */ 32 { /* on-board devices */
33 33 .virtual = IQ31244_UART,
34 /* on-board devices */ 34 .pfn = __phys_to_pfn(IQ31244_UART),
35 { IQ31244_UART, IQ31244_UART, 0x00100000, MT_DEVICE } 35 .length = 0x00100000,
36 .type = MT_DEVICE
37 }
36}; 38};
37 39
38void __init iq31244_map_io(void) 40void __init iq31244_map_io(void)
diff --git a/arch/arm/mach-iop3xx/iq80321-mm.c b/arch/arm/mach-iop3xx/iq80321-mm.c
index bb3e9e5a9aff..d9cac5e1fc3d 100644
--- a/arch/arm/mach-iop3xx/iq80321-mm.c
+++ b/arch/arm/mach-iop3xx/iq80321-mm.c
@@ -29,10 +29,12 @@
29 * We use RedBoot's setup for the onboard devices. 29 * We use RedBoot's setup for the onboard devices.
30 */ 30 */
31static struct map_desc iq80321_io_desc[] __initdata = { 31static struct map_desc iq80321_io_desc[] __initdata = {
32 /* virtual physical length type */ 32 { /* on-board devices */
33 33 .virtual = IQ80321_UART,
34 /* on-board devices */ 34 .pfn = __phys_to_pfn(IQ80321_UART),
35 { IQ80321_UART, IQ80321_UART, 0x00100000, MT_DEVICE } 35 .length = 0x00100000,
36 .type = MT_DEVICE
37 }
36}; 38};
37 39
38void __init iq80321_map_io(void) 40void __init iq80321_map_io(void)
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index f4d7f1f6ef85..01c393c504d0 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -83,42 +83,42 @@ void ixp2000_release_slowport(struct slowport_cfg *old_cfg)
83static struct map_desc ixp2000_io_desc[] __initdata = { 83static struct map_desc ixp2000_io_desc[] __initdata = {
84 { 84 {
85 .virtual = IXP2000_CAP_VIRT_BASE, 85 .virtual = IXP2000_CAP_VIRT_BASE,
86 .physical = IXP2000_CAP_PHYS_BASE, 86 .pfn = __phys_to_pfn(IXP2000_CAP_PHYS_BASE),
87 .length = IXP2000_CAP_SIZE, 87 .length = IXP2000_CAP_SIZE,
88 .type = MT_DEVICE 88 .type = MT_DEVICE
89 }, { 89 }, {
90 .virtual = IXP2000_INTCTL_VIRT_BASE, 90 .virtual = IXP2000_INTCTL_VIRT_BASE,
91 .physical = IXP2000_INTCTL_PHYS_BASE, 91 .pfn = __phys_to_pfn(IXP2000_INTCTL_PHYS_BASE),
92 .length = IXP2000_INTCTL_SIZE, 92 .length = IXP2000_INTCTL_SIZE,
93 .type = MT_DEVICE 93 .type = MT_DEVICE
94 }, { 94 }, {
95 .virtual = IXP2000_PCI_CREG_VIRT_BASE, 95 .virtual = IXP2000_PCI_CREG_VIRT_BASE,
96 .physical = IXP2000_PCI_CREG_PHYS_BASE, 96 .pfn = __phys_to_pfn(IXP2000_PCI_CREG_PHYS_BASE),
97 .length = IXP2000_PCI_CREG_SIZE, 97 .length = IXP2000_PCI_CREG_SIZE,
98 .type = MT_DEVICE 98 .type = MT_DEVICE
99 }, { 99 }, {
100 .virtual = IXP2000_PCI_CSR_VIRT_BASE, 100 .virtual = IXP2000_PCI_CSR_VIRT_BASE,
101 .physical = IXP2000_PCI_CSR_PHYS_BASE, 101 .pfn = __phys_to_pfn(IXP2000_PCI_CSR_PHYS_BASE),
102 .length = IXP2000_PCI_CSR_SIZE, 102 .length = IXP2000_PCI_CSR_SIZE,
103 .type = MT_DEVICE 103 .type = MT_DEVICE
104 }, { 104 }, {
105 .virtual = IXP2000_MSF_VIRT_BASE, 105 .virtual = IXP2000_MSF_VIRT_BASE,
106 .physical = IXP2000_MSF_PHYS_BASE, 106 .pfn = __phys_to_pfn(IXP2000_MSF_PHYS_BASE),
107 .length = IXP2000_MSF_SIZE, 107 .length = IXP2000_MSF_SIZE,
108 .type = MT_DEVICE 108 .type = MT_DEVICE
109 }, { 109 }, {
110 .virtual = IXP2000_PCI_IO_VIRT_BASE, 110 .virtual = IXP2000_PCI_IO_VIRT_BASE,
111 .physical = IXP2000_PCI_IO_PHYS_BASE, 111 .pfn = __phys_to_pfn(IXP2000_PCI_IO_PHYS_BASE),
112 .length = IXP2000_PCI_IO_SIZE, 112 .length = IXP2000_PCI_IO_SIZE,
113 .type = MT_DEVICE 113 .type = MT_DEVICE
114 }, { 114 }, {
115 .virtual = IXP2000_PCI_CFG0_VIRT_BASE, 115 .virtual = IXP2000_PCI_CFG0_VIRT_BASE,
116 .physical = IXP2000_PCI_CFG0_PHYS_BASE, 116 .pfn = __phys_to_pfn(IXP2000_PCI_CFG0_PHYS_BASE),
117 .length = IXP2000_PCI_CFG0_SIZE, 117 .length = IXP2000_PCI_CFG0_SIZE,
118 .type = MT_DEVICE 118 .type = MT_DEVICE
119 }, { 119 }, {
120 .virtual = IXP2000_PCI_CFG1_VIRT_BASE, 120 .virtual = IXP2000_PCI_CFG1_VIRT_BASE,
121 .physical = IXP2000_PCI_CFG1_PHYS_BASE, 121 .pfn = __phys_to_pfn(IXP2000_PCI_CFG1_PHYS_BASE),
122 .length = IXP2000_PCI_CFG1_SIZE, 122 .length = IXP2000_PCI_CFG1_SIZE,
123 .type = MT_DEVICE 123 .type = MT_DEVICE
124 } 124 }
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
index 63ba0191aa65..8b4a839b6279 100644
--- a/arch/arm/mach-ixp2000/ixdp2x00.c
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c
@@ -176,7 +176,7 @@ void ixdp2x00_init_irq(volatile unsigned long *stat_reg, volatile unsigned long
176 *************************************************************************/ 176 *************************************************************************/
177static struct map_desc ixdp2x00_io_desc __initdata = { 177static struct map_desc ixdp2x00_io_desc __initdata = {
178 .virtual = IXDP2X00_VIRT_CPLD_BASE, 178 .virtual = IXDP2X00_VIRT_CPLD_BASE,
179 .physical = IXDP2X00_PHYS_CPLD_BASE, 179 .pfn = __phys_to_pfn(IXDP2X00_PHYS_CPLD_BASE),
180 .length = IXDP2X00_CPLD_SIZE, 180 .length = IXDP2X00_CPLD_SIZE,
181 .type = MT_DEVICE 181 .type = MT_DEVICE
182}; 182};
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
index 7a5109921287..fee1d7b73503 100644
--- a/arch/arm/mach-ixp2000/ixdp2x01.c
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c
@@ -136,7 +136,7 @@ void __init ixdp2x01_init_irq(void)
136 *************************************************************************/ 136 *************************************************************************/
137static struct map_desc ixdp2x01_io_desc __initdata = { 137static struct map_desc ixdp2x01_io_desc __initdata = {
138 .virtual = IXDP2X01_VIRT_CPLD_BASE, 138 .virtual = IXDP2X01_VIRT_CPLD_BASE,
139 .physical = IXDP2X01_PHYS_CPLD_BASE, 139 .pfn = __phys_to_pfn(IXDP2X01_PHYS_CPLD_BASE),
140 .length = IXDP2X01_CPLD_REGION_SIZE, 140 .length = IXDP2X01_CPLD_REGION_SIZE,
141 .type = MT_DEVICE 141 .type = MT_DEVICE
142}; 142};
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 36b6045213ee..6c396447c4e0 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -44,24 +44,24 @@
44static struct map_desc ixp4xx_io_desc[] __initdata = { 44static struct map_desc ixp4xx_io_desc[] __initdata = {
45 { /* UART, Interrupt ctrl, GPIO, timers, NPEs, MACs, USB .... */ 45 { /* UART, Interrupt ctrl, GPIO, timers, NPEs, MACs, USB .... */
46 .virtual = IXP4XX_PERIPHERAL_BASE_VIRT, 46 .virtual = IXP4XX_PERIPHERAL_BASE_VIRT,
47 .physical = IXP4XX_PERIPHERAL_BASE_PHYS, 47 .pfn = __phys_to_pfn(IXP4XX_PERIPHERAL_BASE_PHYS),
48 .length = IXP4XX_PERIPHERAL_REGION_SIZE, 48 .length = IXP4XX_PERIPHERAL_REGION_SIZE,
49 .type = MT_DEVICE 49 .type = MT_DEVICE
50 }, { /* Expansion Bus Config Registers */ 50 }, { /* Expansion Bus Config Registers */
51 .virtual = IXP4XX_EXP_CFG_BASE_VIRT, 51 .virtual = IXP4XX_EXP_CFG_BASE_VIRT,
52 .physical = IXP4XX_EXP_CFG_BASE_PHYS, 52 .pfn = __phys_to_pfn(IXP4XX_EXP_CFG_BASE_PHYS),
53 .length = IXP4XX_EXP_CFG_REGION_SIZE, 53 .length = IXP4XX_EXP_CFG_REGION_SIZE,
54 .type = MT_DEVICE 54 .type = MT_DEVICE
55 }, { /* PCI Registers */ 55 }, { /* PCI Registers */
56 .virtual = IXP4XX_PCI_CFG_BASE_VIRT, 56 .virtual = IXP4XX_PCI_CFG_BASE_VIRT,
57 .physical = IXP4XX_PCI_CFG_BASE_PHYS, 57 .pfn = __phys_to_pfn(IXP4XX_PCI_CFG_BASE_PHYS),
58 .length = IXP4XX_PCI_CFG_REGION_SIZE, 58 .length = IXP4XX_PCI_CFG_REGION_SIZE,
59 .type = MT_DEVICE 59 .type = MT_DEVICE
60 }, 60 },
61#ifdef CONFIG_DEBUG_LL 61#ifdef CONFIG_DEBUG_LL
62 { /* Debug UART mapping */ 62 { /* Debug UART mapping */
63 .virtual = IXP4XX_DEBUG_UART_BASE_VIRT, 63 .virtual = IXP4XX_DEBUG_UART_BASE_VIRT,
64 .physical = IXP4XX_DEBUG_UART_BASE_PHYS, 64 .pfn = __phys_to_pfn(IXP4XX_DEBUG_UART_BASE_PHYS),
65 .length = IXP4XX_DEBUG_UART_REGION_SIZE, 65 .length = IXP4XX_DEBUG_UART_REGION_SIZE,
66 .type = MT_DEVICE 66 .type = MT_DEVICE
67 } 67 }
diff --git a/arch/arm/mach-lh7a40x/arch-kev7a400.c b/arch/arm/mach-lh7a40x/arch-kev7a400.c
index cb3dcd3bd00a..19f2fa2244c4 100644
--- a/arch/arm/mach-lh7a40x/arch-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/arch-kev7a400.c
@@ -26,8 +26,17 @@
26 /* This function calls the board specific IRQ initialization function. */ 26 /* This function calls the board specific IRQ initialization function. */
27 27
28static struct map_desc kev7a400_io_desc[] __initdata = { 28static struct map_desc kev7a400_io_desc[] __initdata = {
29 { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE }, 29 {
30 { CPLD_VIRT, CPLD_PHYS, CPLD_SIZE, MT_DEVICE }, 30 .virtual = IO_VIRT,
31 .pfn = __phys_to_pfn(IO_PHYS),
32 .length = IO_SIZE,
33 .type = MT_DEVICE
34 }, {
35 .virtual = CPLD_VIRT,
36 .pfn = __phys_to_pfn(CPLD_PHYS),
37 .length = CPLD_SIZE,
38 .type = MT_DEVICE
39 }
31}; 40};
32 41
33void __init kev7a400_map_io(void) 42void __init kev7a400_map_io(void)
diff --git a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
index 6eb61a17c63b..a20eabc132b0 100644
--- a/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/arch-lpd7a40x.c
@@ -227,23 +227,79 @@ void __init lh7a40x_init_board_irq (void)
227} 227}
228 228
229static struct map_desc lpd7a400_io_desc[] __initdata = { 229static struct map_desc lpd7a400_io_desc[] __initdata = {
230 { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE }, 230 {
231 /* Mapping added to work around chip select problems */ 231 .virtual = IO_VIRT,
232 { IOBARRIER_VIRT, IOBARRIER_PHYS, IOBARRIER_SIZE, MT_DEVICE }, 232 .pfn = __phys_to_pfn(IO_PHYS),
233 { CF_VIRT, CF_PHYS, CF_SIZE, MT_DEVICE }, 233 .length = IO_SIZE,
234 .type = MT_DEVICE
235 }, { /* Mapping added to work around chip select problems */
236 .virtual = IOBARRIER_VIRT,
237 .pfn = __phys_to_pfn(IOBARRIER_PHYS),
238 .length = IOBARRIER_SIZE,
239 .type = MT_DEVICE
240 }, {
241 .virtual = CF_VIRT,
242 .pfn = __phys_to_pfn(CF_PHYS),
243 .length = CF_SIZE,
244 .type = MT_DEVICE
245 }, {
246 .virtual = CPLD02_VIRT,
247 .pfn = __phys_to_pfn(CPLD02_PHYS),
248 .length = CPLD02_SIZE,
249 .type = MT_DEVICE
250 }, {
251 .virtual = CPLD06_VIRT,
252 .pfn = __phys_to_pfn(CPLD06_PHYS),
253 .length = CPLD06_SIZE,
254 .type = MT_DEVICE
255 }, {
256 .virtual = CPLD08_VIRT,
257 .pfn = __phys_to_pfn(CPLD08_PHYS),
258 .length = CPLD08_SIZE,
259 .type = MT_DEVICE
260 }, {
261 .virtual = CPLD0C_VIRT,
262 .pfn = __phys_to_pfn(CPLD0C_PHYS),
263 .length = CPLD0C_SIZE,
264 .type = MT_DEVICE
265 }, {
266 .virtual = CPLD0E_VIRT,
267 .pfn = __phys_to_pfn(CPLD0E_PHYS),
268 .length = CPLD0E_SIZE,
269 .type = MT_DEVICE
270 }, {
271 .virtual = CPLD10_VIRT,
272 .pfn = __phys_to_pfn(CPLD10_PHYS),
273 .length = CPLD10_SIZE,
274 .type = MT_DEVICE
275 }, {
276 .virtual = CPLD12_VIRT,
277 .pfn = __phys_to_pfn(CPLD12_PHYS),
278 .length = CPLD12_SIZE,
279 .type = MT_DEVICE
280 }, {
281 .virtual = CPLD14_VIRT,
282 .pfn = __phys_to_pfn(CPLD14_PHYS),
283 .length = CPLD14_SIZE,
284 .type = MT_DEVICE
285 }, {
286 .virtual = CPLD16_VIRT,
287 .pfn = __phys_to_pfn(CPLD16_PHYS),
288 .length = CPLD16_SIZE,
289 .type = MT_DEVICE
290 }, {
291 .virtual = CPLD18_VIRT,
292 .pfn = __phys_to_pfn(CPLD18_PHYS),
293 .length = CPLD18_SIZE,
294 .type = MT_DEVICE
295 }, {
296 .virtual = CPLD1A_VIRT,
297 .pfn = __phys_to_pfn(CPLD1A_PHYS),
298 .length = CPLD1A_SIZE,
299 .type = MT_DEVICE
300 },
234 /* This mapping is redundant since the smc driver performs another. */ 301 /* This mapping is redundant since the smc driver performs another. */
235/* { CPLD00_VIRT, CPLD00_PHYS, CPLD00_SIZE, MT_DEVICE }, */ 302/* { CPLD00_VIRT, CPLD00_PHYS, CPLD00_SIZE, MT_DEVICE }, */
236 { CPLD02_VIRT, CPLD02_PHYS, CPLD02_SIZE, MT_DEVICE },
237 { CPLD06_VIRT, CPLD06_PHYS, CPLD06_SIZE, MT_DEVICE },
238 { CPLD08_VIRT, CPLD08_PHYS, CPLD08_SIZE, MT_DEVICE },
239 { CPLD0C_VIRT, CPLD0C_PHYS, CPLD0C_SIZE, MT_DEVICE },
240 { CPLD0E_VIRT, CPLD0E_PHYS, CPLD0E_SIZE, MT_DEVICE },
241 { CPLD10_VIRT, CPLD10_PHYS, CPLD10_SIZE, MT_DEVICE },
242 { CPLD12_VIRT, CPLD12_PHYS, CPLD12_SIZE, MT_DEVICE },
243 { CPLD14_VIRT, CPLD14_PHYS, CPLD14_SIZE, MT_DEVICE },
244 { CPLD16_VIRT, CPLD16_PHYS, CPLD16_SIZE, MT_DEVICE },
245 { CPLD18_VIRT, CPLD18_PHYS, CPLD18_SIZE, MT_DEVICE },
246 { CPLD1A_VIRT, CPLD1A_PHYS, CPLD1A_SIZE, MT_DEVICE },
247}; 303};
248 304
249void __init 305void __init
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index df0312b596e4..fd9183ff2ed5 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -103,8 +103,12 @@ static struct platform_device innovator_flash_device = {
103 103
104/* Only FPGA needs to be mapped here. All others are done with ioremap */ 104/* Only FPGA needs to be mapped here. All others are done with ioremap */
105static struct map_desc innovator1510_io_desc[] __initdata = { 105static struct map_desc innovator1510_io_desc[] __initdata = {
106{ OMAP1510_FPGA_BASE, OMAP1510_FPGA_START, OMAP1510_FPGA_SIZE, 106 {
107 MT_DEVICE }, 107 .virtual = OMAP1510_FPGA_BASE,
108 .pfn = __phys_to_pfn(OMAP1510_FPGA_START),
109 .length = OMAP1510_FPGA_SIZE,
110 .type = MT_DEVICE
111 }
108}; 112};
109 113
110static struct resource innovator1510_smc91x_resources[] = { 114static struct resource innovator1510_smc91x_resources[] = {
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index 107c68c8ab54..2ba26e239108 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -134,8 +134,12 @@ void omap_perseus2_init_irq(void)
134 134
135/* Only FPGA needs to be mapped here. All others are done with ioremap */ 135/* Only FPGA needs to be mapped here. All others are done with ioremap */
136static struct map_desc omap_perseus2_io_desc[] __initdata = { 136static struct map_desc omap_perseus2_io_desc[] __initdata = {
137 {H2P2_DBG_FPGA_BASE, H2P2_DBG_FPGA_START, H2P2_DBG_FPGA_SIZE, 137 {
138 MT_DEVICE}, 138 .virtual = H2P2_DBG_FPGA_BASE,
139 .pfn = __phys_to_pfn(H2P2_DBG_FPGA_START),
140 .length = H2P2_DBG_FPGA_SIZE,
141 .type = MT_DEVICE
142 }
139}; 143};
140 144
141static void __init omap_perseus2_map_io(void) 145static void __init omap_perseus2_map_io(void)
diff --git a/arch/arm/mach-omap1/io.c b/arch/arm/mach-omap1/io.c
index eb8261d7dead..79fb86535ebc 100644
--- a/arch/arm/mach-omap1/io.c
+++ b/arch/arm/mach-omap1/io.c
@@ -26,27 +26,59 @@ extern void omap_sram_init(void);
26 * default mapping provided here. 26 * default mapping provided here.
27 */ 27 */
28static struct map_desc omap_io_desc[] __initdata = { 28static struct map_desc omap_io_desc[] __initdata = {
29 { IO_VIRT, IO_PHYS, IO_SIZE, MT_DEVICE }, 29 {
30 .virtual = IO_VIRT,
31 .pfn = __phys_to_pfn(IO_PHYS),
32 .length = IO_SIZE,
33 .type = MT_DEVICE
34 }
30}; 35};
31 36
32#ifdef CONFIG_ARCH_OMAP730 37#ifdef CONFIG_ARCH_OMAP730
33static struct map_desc omap730_io_desc[] __initdata = { 38static struct map_desc omap730_io_desc[] __initdata = {
34 { OMAP730_DSP_BASE, OMAP730_DSP_START, OMAP730_DSP_SIZE, MT_DEVICE }, 39 {
35 { OMAP730_DSPREG_BASE, OMAP730_DSPREG_START, OMAP730_DSPREG_SIZE, MT_DEVICE }, 40 .virtual = OMAP730_DSP_BASE,
41 .pfn = __phys_to_pfn(OMAP730_DSP_START),
42 .length = OMAP730_DSP_SIZE,
43 .type = MT_DEVICE
44 }, {
45 .virtual = OMAP730_DSPREG_BASE,
46 .pfn = __phys_to_pfn(OMAP730_DSPREG_START),
47 .length = OMAP730_DSPREG_SIZE,
48 .type = MT_DEVICE
49 }
36}; 50};
37#endif 51#endif
38 52
39#ifdef CONFIG_ARCH_OMAP1510 53#ifdef CONFIG_ARCH_OMAP1510
40static struct map_desc omap1510_io_desc[] __initdata = { 54static struct map_desc omap1510_io_desc[] __initdata = {
41 { OMAP1510_DSP_BASE, OMAP1510_DSP_START, OMAP1510_DSP_SIZE, MT_DEVICE }, 55 {
42 { OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_START, OMAP1510_DSPREG_SIZE, MT_DEVICE }, 56 .virtual = OMAP1510_DSP_BASE,
57 .pfn = __phys_to_pfn(OMAP1510_DSP_START),
58 .length = OMAP1510_DSP_SIZE,
59 .type = MT_DEVICE
60 }, {
61 .virtual = OMAP1510_DSPREG_BASE,
62 .pfn = __phys_to_pfn(OMAP1510_DSPREG_START),
63 .length = OMAP1510_DSPREG_SIZE,
64 .type = MT_DEVICE
65 }
43}; 66};
44#endif 67#endif
45 68
46#if defined(CONFIG_ARCH_OMAP16XX) 69#if defined(CONFIG_ARCH_OMAP16XX)
47static struct map_desc omap16xx_io_desc[] __initdata = { 70static struct map_desc omap16xx_io_desc[] __initdata = {
48 { OMAP16XX_DSP_BASE, OMAP16XX_DSP_START, OMAP16XX_DSP_SIZE, MT_DEVICE }, 71 {
49 { OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_START, OMAP16XX_DSPREG_SIZE, MT_DEVICE }, 72 .virtual = OMAP16XX_DSP_BASE,
73 .pfn = __phys_to_pfn(OMAP16XX_DSP_START),
74 .length = OMAP16XX_DSP_SIZE,
75 .type = MT_DEVICE
76 }, {
77 .virtual = OMAP16XX_DSPREG_BASE,
78 .pfn = __phys_to_pfn(OMAP16XX_DSPREG_START),
79 .length = OMAP16XX_DSPREG_SIZE,
80 .type = MT_DEVICE
81 }
50}; 82};
51#endif 83#endif
52 84
diff --git a/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
index 0ef428287055..136c269db0b7 100644
--- a/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -222,24 +222,22 @@ static int corgi_ssp_remove(struct device *dev)
222 return 0; 222 return 0;
223} 223}
224 224
225static int corgi_ssp_suspend(struct device *dev, pm_message_t state, u32 level) 225static int corgi_ssp_suspend(struct device *dev, pm_message_t state)
226{ 226{
227 if (level == SUSPEND_POWER_DOWN) { 227 ssp_flush(&corgi_ssp_dev);
228 ssp_flush(&corgi_ssp_dev); 228 ssp_save_state(&corgi_ssp_dev,&corgi_ssp_state);
229 ssp_save_state(&corgi_ssp_dev,&corgi_ssp_state); 229
230 }
231 return 0; 230 return 0;
232} 231}
233 232
234static int corgi_ssp_resume(struct device *dev, u32 level) 233static int corgi_ssp_resume(struct device *dev)
235{ 234{
236 if (level == RESUME_POWER_ON) { 235 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */
237 GPSR(ssp_machinfo->cs_lcdcon) = GPIO_bit(ssp_machinfo->cs_lcdcon); /* High - Disable LCD Control/Timing Gen */ 236 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/
238 GPSR(ssp_machinfo->cs_max1111) = GPIO_bit(ssp_machinfo->cs_max1111); /* High - Disable MAX1111*/ 237 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/
239 GPSR(ssp_machinfo->cs_ads7846) = GPIO_bit(ssp_machinfo->cs_ads7846); /* High - Disable ADS7846*/ 238 ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state);
240 ssp_restore_state(&corgi_ssp_dev,&corgi_ssp_state); 239 ssp_enable(&corgi_ssp_dev);
241 ssp_enable(&corgi_ssp_dev); 240
242 }
243 return 0; 241 return 0;
244} 242}
245 243
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 1d7677669a76..3248bc9b9495 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -34,6 +34,7 @@
34#include <asm/arch/udc.h> 34#include <asm/arch/udc.h>
35#include <asm/arch/pxafb.h> 35#include <asm/arch/pxafb.h>
36#include <asm/arch/mmc.h> 36#include <asm/arch/mmc.h>
37#include <asm/arch/irda.h>
37#include <asm/arch/i2c.h> 38#include <asm/arch/i2c.h>
38 39
39#include "generic.h" 40#include "generic.h"
@@ -92,14 +93,42 @@ EXPORT_SYMBOL(pxa_set_cken);
92 * and cache flush area. 93 * and cache flush area.
93 */ 94 */
94static struct map_desc standard_io_desc[] __initdata = { 95static struct map_desc standard_io_desc[] __initdata = {
95 /* virtual physical length type */ 96 { /* Devs */
96 { 0xf2000000, 0x40000000, 0x02000000, MT_DEVICE }, /* Devs */ 97 .virtual = 0xf2000000,
97 { 0xf4000000, 0x44000000, 0x00100000, MT_DEVICE }, /* LCD */ 98 .pfn = __phys_to_pfn(0x40000000),
98 { 0xf6000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Mem Ctl */ 99 .length = 0x02000000,
99 { 0xf8000000, 0x4c000000, 0x00100000, MT_DEVICE }, /* USB host */ 100 .type = MT_DEVICE
100 { 0xfa000000, 0x50000000, 0x00100000, MT_DEVICE }, /* Camera */ 101 }, { /* LCD */
101 { 0xfe000000, 0x58000000, 0x00100000, MT_DEVICE }, /* IMem ctl */ 102 .virtual = 0xf4000000,
102 { 0xff000000, 0x00000000, 0x00100000, MT_DEVICE } /* UNCACHED_PHYS_0 */ 103 .pfn = __phys_to_pfn(0x44000000),
104 .length = 0x00100000,
105 .type = MT_DEVICE
106 }, { /* Mem Ctl */
107 .virtual = 0xf6000000,
108 .pfn = __phys_to_pfn(0x48000000),
109 .length = 0x00100000,
110 .type = MT_DEVICE
111 }, { /* USB host */
112 .virtual = 0xf8000000,
113 .pfn = __phys_to_pfn(0x4c000000),
114 .length = 0x00100000,
115 .type = MT_DEVICE
116 }, { /* Camera */
117 .virtual = 0xfa000000,
118 .pfn = __phys_to_pfn(0x50000000),
119 .length = 0x00100000,
120 .type = MT_DEVICE
121 }, { /* IMem ctl */
122 .virtual = 0xfe000000,
123 .pfn = __phys_to_pfn(0x58000000),
124 .length = 0x00100000,
125 .type = MT_DEVICE
126 }, { /* UNCACHED_PHYS_0 */
127 .virtual = 0xff000000,
128 .pfn = __phys_to_pfn(0x00000000),
129 .length = 0x00100000,
130 .type = MT_DEVICE
131 }
103}; 132};
104 133
105void __init pxa_map_io(void) 134void __init pxa_map_io(void)
@@ -225,6 +254,10 @@ static struct platform_device stuart_device = {
225 .name = "pxa2xx-uart", 254 .name = "pxa2xx-uart",
226 .id = 2, 255 .id = 2,
227}; 256};
257static struct platform_device hwuart_device = {
258 .name = "pxa2xx-uart",
259 .id = 3,
260};
228 261
229static struct resource i2c_resources[] = { 262static struct resource i2c_resources[] = {
230 { 263 {
@@ -265,10 +298,26 @@ static struct resource i2s_resources[] = {
265static struct platform_device i2s_device = { 298static struct platform_device i2s_device = {
266 .name = "pxa2xx-i2s", 299 .name = "pxa2xx-i2s",
267 .id = -1, 300 .id = -1,
268 .resource = i2c_resources, 301 .resource = i2s_resources,
269 .num_resources = ARRAY_SIZE(i2s_resources), 302 .num_resources = ARRAY_SIZE(i2s_resources),
270}; 303};
271 304
305static u64 pxaficp_dmamask = ~(u32)0;
306
307static struct platform_device pxaficp_device = {
308 .name = "pxa2xx-ir",
309 .id = -1,
310 .dev = {
311 .dma_mask = &pxaficp_dmamask,
312 .coherent_dma_mask = 0xffffffff,
313 },
314};
315
316void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
317{
318 pxaficp_device.dev.platform_data = info;
319}
320
272static struct platform_device *devices[] __initdata = { 321static struct platform_device *devices[] __initdata = {
273 &pxamci_device, 322 &pxamci_device,
274 &udc_device, 323 &udc_device,
@@ -276,13 +325,26 @@ static struct platform_device *devices[] __initdata = {
276 &ffuart_device, 325 &ffuart_device,
277 &btuart_device, 326 &btuart_device,
278 &stuart_device, 327 &stuart_device,
328 &pxaficp_device,
279 &i2c_device, 329 &i2c_device,
280 &i2s_device, 330 &i2s_device,
281}; 331};
282 332
283static int __init pxa_init(void) 333static int __init pxa_init(void)
284{ 334{
285 return platform_add_devices(devices, ARRAY_SIZE(devices)); 335 int cpuid, ret;
336
337 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
338 if (ret)
339 return ret;
340
341 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */
342 cpuid = read_cpuid(CPUID_ID);
343 if (((cpuid >> 4) & 0xfff) == 0x2d0 ||
344 ((cpuid >> 4) & 0xfff) == 0x290)
345 ret = platform_device_register(&hwuart_device);
346
347 return ret;
286} 348}
287 349
288subsys_initcall(pxa_init); 350subsys_initcall(pxa_init);
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index 386e107b53cc..01a83ab09ac3 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -152,16 +152,17 @@ static void __init idp_init_irq(void)
152} 152}
153 153
154static struct map_desc idp_io_desc[] __initdata = { 154static struct map_desc idp_io_desc[] __initdata = {
155 /* virtual physical length type */ 155 {
156 156 .virtual = IDP_COREVOLT_VIRT,
157 { IDP_COREVOLT_VIRT, 157 .pfn = __phys_to_pfn(IDP_COREVOLT_PHYS),
158 IDP_COREVOLT_PHYS, 158 .length = IDP_COREVOLT_SIZE,
159 IDP_COREVOLT_SIZE, 159 .type = MT_DEVICE
160 MT_DEVICE }, 160 }, {
161 { IDP_CPLD_VIRT, 161 .virtual = IDP_CPLD_VIRT,
162 IDP_CPLD_PHYS, 162 .pfn = __phys_to_pfn(IDP_CPLD_PHYS),
163 IDP_CPLD_SIZE, 163 .length = IDP_CPLD_SIZE,
164 MT_DEVICE } 164 .type = MT_DEVICE
165 }
165}; 166};
166 167
167static void __init idp_map_io(void) 168static void __init idp_map_io(void)
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 1f38033921e9..beccf455f796 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -35,6 +35,7 @@
35#include <asm/arch/pxa-regs.h> 35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/lubbock.h> 36#include <asm/arch/lubbock.h>
37#include <asm/arch/udc.h> 37#include <asm/arch/udc.h>
38#include <asm/arch/irda.h>
38#include <asm/arch/pxafb.h> 39#include <asm/arch/pxafb.h>
39#include <asm/arch/mmc.h> 40#include <asm/arch/mmc.h>
40 41
@@ -237,16 +238,40 @@ static struct pxamci_platform_data lubbock_mci_platform_data = {
237 .init = lubbock_mci_init, 238 .init = lubbock_mci_init,
238}; 239};
239 240
241static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
242{
243 unsigned long flags;
244
245 local_irq_save(flags);
246 if (mode & IR_SIRMODE) {
247 LUB_MISC_WR &= ~(1 << 4);
248 } else if (mode & IR_FIRMODE) {
249 LUB_MISC_WR |= 1 << 4;
250 }
251 local_irq_restore(flags);
252}
253
254static struct pxaficp_platform_data lubbock_ficp_platform_data = {
255 .transceiver_cap = IR_SIRMODE | IR_FIRMODE,
256 .transceiver_mode = lubbock_irda_transceiver_mode,
257};
258
240static void __init lubbock_init(void) 259static void __init lubbock_init(void)
241{ 260{
242 pxa_set_udc_info(&udc_info); 261 pxa_set_udc_info(&udc_info);
243 set_pxa_fb_info(&sharp_lm8v31); 262 set_pxa_fb_info(&sharp_lm8v31);
244 pxa_set_mci_info(&lubbock_mci_platform_data); 263 pxa_set_mci_info(&lubbock_mci_platform_data);
264 pxa_set_ficp_info(&lubbock_ficp_platform_data);
245 (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 265 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
246} 266}
247 267
248static struct map_desc lubbock_io_desc[] __initdata = { 268static struct map_desc lubbock_io_desc[] __initdata = {
249 { LUBBOCK_FPGA_VIRT, LUBBOCK_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */ 269 { /* CPLD */
270 .virtual = LUBBOCK_FPGA_VIRT,
271 .pfn = __phys_to_pfn(LUBBOCK_FPGA_PHYS),
272 .length = 0x00100000,
273 .type = MT_DEVICE
274 }
250}; 275};
251 276
252static void __init lubbock_map_io(void) 277static void __init lubbock_map_io(void)
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 85fdb5b1470a..a48c64026e1f 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -37,6 +37,7 @@
37#include <asm/arch/audio.h> 37#include <asm/arch/audio.h>
38#include <asm/arch/pxafb.h> 38#include <asm/arch/pxafb.h>
39#include <asm/arch/mmc.h> 39#include <asm/arch/mmc.h>
40#include <asm/arch/irda.h>
40 41
41#include "generic.h" 42#include "generic.h"
42 43
@@ -294,6 +295,29 @@ static struct pxamci_platform_data mainstone_mci_platform_data = {
294 .exit = mainstone_mci_exit, 295 .exit = mainstone_mci_exit,
295}; 296};
296 297
298static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
299{
300 unsigned long flags;
301
302 local_irq_save(flags);
303 if (mode & IR_SIRMODE) {
304 MST_MSCWR1 &= ~MST_MSCWR1_IRDA_FIR;
305 } else if (mode & IR_FIRMODE) {
306 MST_MSCWR1 |= MST_MSCWR1_IRDA_FIR;
307 }
308 if (mode & IR_OFF) {
309 MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_OFF;
310 } else {
311 MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_FULL;
312 }
313 local_irq_restore(flags);
314}
315
316static struct pxaficp_platform_data mainstone_ficp_platform_data = {
317 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
318 .transceiver_mode = mainstone_irda_transceiver_mode,
319};
320
297static void __init mainstone_init(void) 321static void __init mainstone_init(void)
298{ 322{
299 /* 323 /*
@@ -313,11 +337,17 @@ static void __init mainstone_init(void)
313 set_pxa_fb_info(&toshiba_ltm035a776c); 337 set_pxa_fb_info(&toshiba_ltm035a776c);
314 338
315 pxa_set_mci_info(&mainstone_mci_platform_data); 339 pxa_set_mci_info(&mainstone_mci_platform_data);
340 pxa_set_ficp_info(&mainstone_ficp_platform_data);
316} 341}
317 342
318 343
319static struct map_desc mainstone_io_desc[] __initdata = { 344static struct map_desc mainstone_io_desc[] __initdata = {
320 { MST_FPGA_VIRT, MST_FPGA_PHYS, 0x00100000, MT_DEVICE }, /* CPLD */ 345 { /* CPLD */
346 .virtual = MST_FPGA_VIRT,
347 .pfn = __phys_to_pfn(MST_FPGA_PHYS),
348 .length = 0x00100000,
349 .type = MT_DEVICE
350 }
321}; 351};
322 352
323static void __init mainstone_map_io(void) 353static void __init mainstone_map_io(void)
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 7869c3b4e62f..573a5758e781 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -129,7 +129,7 @@ void pxa_cpu_pm_enter(suspend_state_t state)
129 case PM_SUSPEND_MEM: 129 case PM_SUSPEND_MEM:
130 /* set resume return address */ 130 /* set resume return address */
131 PSPR = virt_to_phys(pxa_cpu_resume); 131 PSPR = virt_to_phys(pxa_cpu_resume);
132 pxa_cpu_suspend(3); 132 pxa_cpu_suspend(PWRMODE_SLEEP);
133 break; 133 break;
134 } 134 }
135} 135}
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 9a791b07118d..09a5d593f04b 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -157,7 +157,7 @@ void pxa_cpu_pm_enter(suspend_state_t state)
157 case PM_SUSPEND_MEM: 157 case PM_SUSPEND_MEM:
158 /* set resume return address */ 158 /* set resume return address */
159 PSPR = virt_to_phys(pxa_cpu_resume); 159 PSPR = virt_to_phys(pxa_cpu_resume);
160 pxa_cpu_suspend(3); 160 pxa_cpu_suspend(PWRMODE_SLEEP);
161 break; 161 break;
162 } 162 }
163} 163}
diff --git a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S
index 5786ccad938c..c9862688ff3d 100644
--- a/arch/arm/mach-pxa/sleep.S
+++ b/arch/arm/mach-pxa/sleep.S
@@ -28,7 +28,9 @@
28/* 28/*
29 * pxa_cpu_suspend() 29 * pxa_cpu_suspend()
30 * 30 *
31 * Forces CPU into sleep state 31 * Forces CPU into sleep state.
32 *
33 * r0 = value for PWRMODE M field for desired sleep state
32 */ 34 */
33 35
34ENTRY(pxa_cpu_suspend) 36ENTRY(pxa_cpu_suspend)
@@ -53,6 +55,7 @@ ENTRY(pxa_cpu_suspend)
53 mov r10, sp 55 mov r10, sp
54 stmfd sp!, {r3 - r10} 56 stmfd sp!, {r3 - r10}
55 57
58 mov r5, r0 @ save sleep mode
56 @ preserve phys address of stack 59 @ preserve phys address of stack
57 mov r0, sp 60 mov r0, sp
58 bl sleep_phys_sp 61 bl sleep_phys_sp
@@ -66,7 +69,7 @@ ENTRY(pxa_cpu_suspend)
66 @ (also workaround for sighting 28071) 69 @ (also workaround for sighting 28071)
67 70
68 @ prepare value for sleep mode 71 @ prepare value for sleep mode
69 mov r1, #3 @ sleep mode 72 mov r1, r5 @ sleep mode
70 73
71 @ prepare pointer to physical address 0 (virtual mapping in generic.c) 74 @ prepare pointer to physical address 0 (virtual mapping in generic.c)
72 mov r2, #UNCACHED_PHYS_0 75 mov r2, #UNCACHED_PHYS_0
diff --git a/arch/arm/mach-pxa/standby.S b/arch/arm/mach-pxa/standby.S
index 8a3f27b76784..6f6dbbd08021 100644
--- a/arch/arm/mach-pxa/standby.S
+++ b/arch/arm/mach-pxa/standby.S
@@ -21,7 +21,7 @@
21ENTRY(pxa_cpu_standby) 21ENTRY(pxa_cpu_standby)
22 ldr r0, =PSSR 22 ldr r0, =PSSR
23 mov r1, #(PSSR_PH | PSSR_STS) 23 mov r1, #(PSSR_PH | PSSR_STS)
24 mov r2, #2 24 mov r2, #PWRMODE_STANDBY
25 mov r3, #UNCACHED_PHYS_0 @ Read mem context in. 25 mov r3, #UNCACHED_PHYS_0 @ Read mem context in.
26 ldr ip, [r3] 26 ldr ip, [r3]
27 b 1f 27 b 1f
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index e3587efec4bf..5c4ac1c008a6 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -61,9 +61,22 @@ static int __init parse_tag_acorn(const struct tag *tag)
61__tagtable(ATAG_ACORN, parse_tag_acorn); 61__tagtable(ATAG_ACORN, parse_tag_acorn);
62 62
63static struct map_desc rpc_io_desc[] __initdata = { 63static struct map_desc rpc_io_desc[] __initdata = {
64 { SCREEN_BASE, SCREEN_START, 2*1048576, MT_DEVICE }, /* VRAM */ 64 { /* VRAM */
65 { (u32)IO_BASE, IO_START, IO_SIZE , MT_DEVICE }, /* IO space */ 65 .virtual = SCREEN_BASE,
66 { EASI_BASE, EASI_START, EASI_SIZE, MT_DEVICE } /* EASI space */ 66 .pfn = __phys_to_pfn(SCREEN_START),
67 .length = 2*1048576,
68 .type = MT_DEVICE
69 }, { /* IO space */
70 .virtual = (u32)IO_BASE,
71 .pfn = __phys_to_pfn(IO_START),
72 .length = IO_SIZE ,
73 .type = MT_DEVICE
74 }, { /* EASI space */
75 .virtual = EASI_BASE,
76 .pfn = __phys_to_pfn(EASI_START),
77 .length = EASI_SIZE,
78 .type = MT_DEVICE
79 }
67}; 80};
68 81
69static void __init rpc_map_io(void) 82static void __init rpc_map_io(void)
diff --git a/arch/arm/mach-s3c2410/cpu.h b/arch/arm/mach-s3c2410/cpu.h
index 478c15c0e36a..9cbe5eef492b 100644
--- a/arch/arm/mach-s3c2410/cpu.h
+++ b/arch/arm/mach-s3c2410/cpu.h
@@ -21,7 +21,7 @@
21 21
22/* todo - fix when rmk changes iodescs to use `void __iomem *` */ 22/* todo - fix when rmk changes iodescs to use `void __iomem *` */
23 23
24#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, S3C2410_PA_##x, S3C24XX_SZ_##x, MT_DEVICE } 24#define IODESC_ENT(x) { (unsigned long)S3C24XX_VA_##x, __phys_to_pfn(S3C2410_PA_##x), S3C24XX_SZ_##x, MT_DEVICE }
25 25
26#ifndef MHZ 26#ifndef MHZ
27#define MHZ (1000*1000) 27#define MHZ (1000*1000)
diff --git a/arch/arm/mach-s3c2410/devs.c b/arch/arm/mach-s3c2410/devs.c
index 0077937a7ab8..08bc7d95a45d 100644
--- a/arch/arm/mach-s3c2410/devs.c
+++ b/arch/arm/mach-s3c2410/devs.c
@@ -47,7 +47,7 @@ struct platform_device *s3c24xx_uart_devs[3];
47static struct resource s3c_usb_resource[] = { 47static struct resource s3c_usb_resource[] = {
48 [0] = { 48 [0] = {
49 .start = S3C2410_PA_USBHOST, 49 .start = S3C2410_PA_USBHOST,
50 .end = S3C2410_PA_USBHOST + S3C24XX_SZ_USBHOST, 50 .end = S3C2410_PA_USBHOST + S3C24XX_SZ_USBHOST - 1,
51 .flags = IORESOURCE_MEM, 51 .flags = IORESOURCE_MEM,
52 }, 52 },
53 [1] = { 53 [1] = {
@@ -77,7 +77,7 @@ EXPORT_SYMBOL(s3c_device_usb);
77static struct resource s3c_lcd_resource[] = { 77static struct resource s3c_lcd_resource[] = {
78 [0] = { 78 [0] = {
79 .start = S3C2410_PA_LCD, 79 .start = S3C2410_PA_LCD,
80 .end = S3C2410_PA_LCD + S3C24XX_SZ_LCD, 80 .end = S3C2410_PA_LCD + S3C24XX_SZ_LCD - 1,
81 .flags = IORESOURCE_MEM, 81 .flags = IORESOURCE_MEM,
82 }, 82 },
83 [1] = { 83 [1] = {
@@ -103,21 +103,25 @@ struct platform_device s3c_device_lcd = {
103 103
104EXPORT_SYMBOL(s3c_device_lcd); 104EXPORT_SYMBOL(s3c_device_lcd);
105 105
106static struct s3c2410fb_mach_info s3c2410fb_info; 106void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
107
108void __init set_s3c2410fb_info(struct s3c2410fb_mach_info *hard_s3c2410fb_info)
109{ 107{
110 memcpy(&s3c2410fb_info,hard_s3c2410fb_info,sizeof(struct s3c2410fb_mach_info)); 108 struct s3c2410fb_mach_info *npd;
111 s3c_device_lcd.dev.platform_data = &s3c2410fb_info; 109
110 npd = kmalloc(sizeof(*npd), GFP_KERNEL);
111 if (npd) {
112 memcpy(npd, pd, sizeof(*npd));
113 s3c_device_lcd.dev.platform_data = npd;
114 } else {
115 printk(KERN_ERR "no memory for LCD platform data\n");
116 }
112} 117}
113EXPORT_SYMBOL(set_s3c2410fb_info);
114 118
115/* NAND Controller */ 119/* NAND Controller */
116 120
117static struct resource s3c_nand_resource[] = { 121static struct resource s3c_nand_resource[] = {
118 [0] = { 122 [0] = {
119 .start = S3C2410_PA_NAND, 123 .start = S3C2410_PA_NAND,
120 .end = S3C2410_PA_NAND + S3C24XX_SZ_NAND, 124 .end = S3C2410_PA_NAND + S3C24XX_SZ_NAND - 1,
121 .flags = IORESOURCE_MEM, 125 .flags = IORESOURCE_MEM,
122 } 126 }
123}; 127};
@@ -136,7 +140,7 @@ EXPORT_SYMBOL(s3c_device_nand);
136static struct resource s3c_usbgadget_resource[] = { 140static struct resource s3c_usbgadget_resource[] = {
137 [0] = { 141 [0] = {
138 .start = S3C2410_PA_USBDEV, 142 .start = S3C2410_PA_USBDEV,
139 .end = S3C2410_PA_USBDEV + S3C24XX_SZ_USBDEV, 143 .end = S3C2410_PA_USBDEV + S3C24XX_SZ_USBDEV - 1,
140 .flags = IORESOURCE_MEM, 144 .flags = IORESOURCE_MEM,
141 }, 145 },
142 [1] = { 146 [1] = {
@@ -161,7 +165,7 @@ EXPORT_SYMBOL(s3c_device_usbgadget);
161static struct resource s3c_wdt_resource[] = { 165static struct resource s3c_wdt_resource[] = {
162 [0] = { 166 [0] = {
163 .start = S3C2410_PA_WATCHDOG, 167 .start = S3C2410_PA_WATCHDOG,
164 .end = S3C2410_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG, 168 .end = S3C2410_PA_WATCHDOG + S3C24XX_SZ_WATCHDOG - 1,
165 .flags = IORESOURCE_MEM, 169 .flags = IORESOURCE_MEM,
166 }, 170 },
167 [1] = { 171 [1] = {
@@ -186,7 +190,7 @@ EXPORT_SYMBOL(s3c_device_wdt);
186static struct resource s3c_i2c_resource[] = { 190static struct resource s3c_i2c_resource[] = {
187 [0] = { 191 [0] = {
188 .start = S3C2410_PA_IIC, 192 .start = S3C2410_PA_IIC,
189 .end = S3C2410_PA_IIC + S3C24XX_SZ_IIC, 193 .end = S3C2410_PA_IIC + S3C24XX_SZ_IIC - 1,
190 .flags = IORESOURCE_MEM, 194 .flags = IORESOURCE_MEM,
191 }, 195 },
192 [1] = { 196 [1] = {
@@ -211,7 +215,7 @@ EXPORT_SYMBOL(s3c_device_i2c);
211static struct resource s3c_iis_resource[] = { 215static struct resource s3c_iis_resource[] = {
212 [0] = { 216 [0] = {
213 .start = S3C2410_PA_IIS, 217 .start = S3C2410_PA_IIS,
214 .end = S3C2410_PA_IIS + S3C24XX_SZ_IIS, 218 .end = S3C2410_PA_IIS + S3C24XX_SZ_IIS -1,
215 .flags = IORESOURCE_MEM, 219 .flags = IORESOURCE_MEM,
216 } 220 }
217}; 221};
@@ -265,7 +269,7 @@ EXPORT_SYMBOL(s3c_device_rtc);
265static struct resource s3c_adc_resource[] = { 269static struct resource s3c_adc_resource[] = {
266 [0] = { 270 [0] = {
267 .start = S3C2410_PA_ADC, 271 .start = S3C2410_PA_ADC,
268 .end = S3C2410_PA_ADC + S3C24XX_SZ_ADC, 272 .end = S3C2410_PA_ADC + S3C24XX_SZ_ADC - 1,
269 .flags = IORESOURCE_MEM, 273 .flags = IORESOURCE_MEM,
270 }, 274 },
271 [1] = { 275 [1] = {
@@ -288,7 +292,7 @@ struct platform_device s3c_device_adc = {
288static struct resource s3c_sdi_resource[] = { 292static struct resource s3c_sdi_resource[] = {
289 [0] = { 293 [0] = {
290 .start = S3C2410_PA_SDI, 294 .start = S3C2410_PA_SDI,
291 .end = S3C2410_PA_SDI + S3C24XX_SZ_SDI, 295 .end = S3C2410_PA_SDI + S3C24XX_SZ_SDI - 1,
292 .flags = IORESOURCE_MEM, 296 .flags = IORESOURCE_MEM,
293 }, 297 },
294 [1] = { 298 [1] = {
@@ -465,7 +469,7 @@ EXPORT_SYMBOL(s3c_device_timer3);
465static struct resource s3c_camif_resource[] = { 469static struct resource s3c_camif_resource[] = {
466 [0] = { 470 [0] = {
467 .start = S3C2440_PA_CAMIF, 471 .start = S3C2440_PA_CAMIF,
468 .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF, 472 .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1,
469 .flags = IORESOURCE_MEM, 473 .flags = IORESOURCE_MEM,
470 }, 474 },
471 [1] = { 475 [1] = {
diff --git a/arch/arm/mach-s3c2410/gpio.c b/arch/arm/mach-s3c2410/gpio.c
index 94f1776cf312..23ea3d5fa09c 100644
--- a/arch/arm/mach-s3c2410/gpio.c
+++ b/arch/arm/mach-s3c2410/gpio.c
@@ -30,6 +30,7 @@
30 * 04-Oct-2004 BJD Added irq filter controls for GPIO 30 * 04-Oct-2004 BJD Added irq filter controls for GPIO
31 * 05-Nov-2004 BJD EXPORT_SYMBOL() added for all code 31 * 05-Nov-2004 BJD EXPORT_SYMBOL() added for all code
32 * 13-Mar-2005 BJD Updates for __iomem 32 * 13-Mar-2005 BJD Updates for __iomem
33 * 26-Oct-2005 BJD Added generic configuration types
33 */ 34 */
34 35
35 36
@@ -58,6 +59,27 @@ void s3c2410_gpio_cfgpin(unsigned int pin, unsigned int function)
58 mask = 3 << S3C2410_GPIO_OFFSET(pin)*2; 59 mask = 3 << S3C2410_GPIO_OFFSET(pin)*2;
59 } 60 }
60 61
62 switch (function) {
63 case S3C2410_GPIO_LEAVE:
64 mask = 0;
65 function = 0;
66 break;
67
68 case S3C2410_GPIO_INPUT:
69 case S3C2410_GPIO_OUTPUT:
70 case S3C2410_GPIO_SFN2:
71 case S3C2410_GPIO_SFN3:
72 if (pin < S3C2410_GPIO_BANKB) {
73 function &= 1;
74 function <<= S3C2410_GPIO_OFFSET(pin);
75 } else {
76 function &= 3;
77 function <<= S3C2410_GPIO_OFFSET(pin)*2;
78 }
79 }
80
81 /* modify the specified register wwith IRQs off */
82
61 local_irq_save(flags); 83 local_irq_save(flags);
62 84
63 con = __raw_readl(base + 0x00); 85 con = __raw_readl(base + 0x00);
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 7b51bfd0ba6d..c1b5c63ec24a 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -32,6 +32,7 @@
32 * 25-Jul-2005 BJD Removed ASIX static mappings 32 * 25-Jul-2005 BJD Removed ASIX static mappings
33 * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus 33 * 27-Jul-2005 BJD Ensure maximum frequency of i2c bus
34 * 20-Sep-2005 BJD Added static to non-exported items 34 * 20-Sep-2005 BJD Added static to non-exported items
35 * 26-Oct-2005 BJD Added FB platform data
35*/ 36*/
36 37
37#include <linux/kernel.h> 38#include <linux/kernel.h>
@@ -61,8 +62,10 @@
61#include <asm/arch/regs-gpio.h> 62#include <asm/arch/regs-gpio.h>
62#include <asm/arch/regs-mem.h> 63#include <asm/arch/regs-mem.h>
63#include <asm/arch/regs-lcd.h> 64#include <asm/arch/regs-lcd.h>
65
64#include <asm/arch/nand.h> 66#include <asm/arch/nand.h>
65#include <asm/arch/iic.h> 67#include <asm/arch/iic.h>
68#include <asm/arch/fb.h>
66 69
67#include <linux/mtd/mtd.h> 70#include <linux/mtd/mtd.h>
68#include <linux/mtd/nand.h> 71#include <linux/mtd/nand.h>
@@ -399,6 +402,38 @@ static struct s3c2410_platform_i2c bast_i2c_info = {
399 .max_freq = 130*1000, 402 .max_freq = 130*1000,
400}; 403};
401 404
405
406static struct s3c2410fb_mach_info __initdata bast_lcd_info = {
407 .width = 640,
408 .height = 480,
409
410 .xres = {
411 .min = 320,
412 .max = 1024,
413 .defval = 640,
414 },
415
416 .yres = {
417 .min = 240,
418 .max = 600,
419 .defval = 480,
420 },
421
422 .bpp = {
423 .min = 4,
424 .max = 16,
425 .defval = 8,
426 },
427
428 .regs = {
429 .lcdcon1 = 0x00000176,
430 .lcdcon2 = 0x1d77c7c2,
431 .lcdcon3 = 0x013a7f13,
432 .lcdcon4 = 0x00000057,
433 .lcdcon5 = 0x00014b02,
434 }
435};
436
402/* Standard BAST devices */ 437/* Standard BAST devices */
403 438
404static struct platform_device *bast_devices[] __initdata = { 439static struct platform_device *bast_devices[] __initdata = {
@@ -454,6 +489,10 @@ static void __init bast_map_io(void)
454 usb_simtec_init(); 489 usb_simtec_init();
455} 490}
456 491
492static void __init bast_init(void)
493{
494 s3c24xx_fb_set_platdata(&bast_lcd_info);
495}
457 496
458MACHINE_START(BAST, "Simtec-BAST") 497MACHINE_START(BAST, "Simtec-BAST")
459 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */ 498 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
@@ -463,5 +502,6 @@ MACHINE_START(BAST, "Simtec-BAST")
463 .boot_params = S3C2410_SDRAM_PA + 0x100, 502 .boot_params = S3C2410_SDRAM_PA + 0x100,
464 .map_io = bast_map_io, 503 .map_io = bast_map_io,
465 .init_irq = s3c24xx_init_irq, 504 .init_irq = s3c24xx_init_irq,
505 .init_machine = bast_init,
466 .timer = &s3c24xx_timer, 506 .timer = &s3c24xx_timer,
467MACHINE_END 507MACHINE_END
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index fb3cb01266e5..7efeaaad2361 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -25,6 +25,7 @@
25 * 14-Jan-2005 BJD Added clock init 25 * 14-Jan-2005 BJD Added clock init
26 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 26 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
27 * 20-Sep-2005 BJD Added static to non-exported items 27 * 20-Sep-2005 BJD Added static to non-exported items
28 * 26-Oct-2005 BJD Changed name of fb init call
28*/ 29*/
29 30
30#include <linux/kernel.h> 31#include <linux/kernel.h>
@@ -164,7 +165,7 @@ static void __init h1940_init_irq(void)
164 165
165static void __init h1940_init(void) 166static void __init h1940_init(void)
166{ 167{
167 set_s3c2410fb_info(&h1940_lcdcfg); 168 s3c24xx_fb_set_platdata(&h1940_lcdcfg);
168} 169}
169 170
170MACHINE_START(H1940, "IPAQ-H1940") 171MACHINE_START(H1940, "IPAQ-H1940")
diff --git a/arch/arm/mach-s3c2410/mach-smdk2440.c b/arch/arm/mach-s3c2410/mach-smdk2440.c
index 722ef46b630a..6950e61b7914 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2440.c
@@ -19,6 +19,7 @@
19 * 10-Mar-2005 LCVR Replaced S3C2410_VA by S3C24XX_VA 19 * 10-Mar-2005 LCVR Replaced S3C2410_VA by S3C24XX_VA
20 * 14-Mar-2005 BJD void __iomem fixes 20 * 14-Mar-2005 BJD void __iomem fixes
21 * 20-Sep-2005 BJD Added static to non-exported items 21 * 20-Sep-2005 BJD Added static to non-exported items
22 * 26-Oct-2005 BJD Added framebuffer data
22*/ 23*/
23 24
24#include <linux/kernel.h> 25#include <linux/kernel.h>
@@ -41,7 +42,10 @@
41//#include <asm/debug-ll.h> 42//#include <asm/debug-ll.h>
42#include <asm/arch/regs-serial.h> 43#include <asm/arch/regs-serial.h>
43#include <asm/arch/regs-gpio.h> 44#include <asm/arch/regs-gpio.h>
45#include <asm/arch/regs-lcd.h>
46
44#include <asm/arch/idle.h> 47#include <asm/arch/idle.h>
48#include <asm/arch/fb.h>
45 49
46#include "s3c2410.h" 50#include "s3c2410.h"
47#include "s3c2440.h" 51#include "s3c2440.h"
@@ -86,6 +90,70 @@ static struct s3c2410_uartcfg smdk2440_uartcfgs[] = {
86 } 90 }
87}; 91};
88 92
93/* LCD driver info */
94
95static struct s3c2410fb_mach_info smdk2440_lcd_cfg __initdata = {
96 .regs = {
97
98 .lcdcon1 = S3C2410_LCDCON1_TFT16BPP |
99 S3C2410_LCDCON1_TFT |
100 S3C2410_LCDCON1_CLKVAL(0x04),
101
102 .lcdcon2 = S3C2410_LCDCON2_VBPD(7) |
103 S3C2410_LCDCON2_LINEVAL(319) |
104 S3C2410_LCDCON2_VFPD(6) |
105 S3C2410_LCDCON2_VSPW(3),
106
107 .lcdcon3 = S3C2410_LCDCON3_HBPD(19) |
108 S3C2410_LCDCON3_HOZVAL(239) |
109 S3C2410_LCDCON3_HFPD(7),
110
111 .lcdcon4 = S3C2410_LCDCON4_MVAL(0) |
112 S3C2410_LCDCON4_HSPW(3),
113
114 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
115 S3C2410_LCDCON5_INVVLINE |
116 S3C2410_LCDCON5_INVVFRAME |
117 S3C2410_LCDCON5_PWREN |
118 S3C2410_LCDCON5_HWSWP,
119 },
120
121#if 0
122 /* currently setup by downloader */
123 .gpccon = 0xaa940659,
124 .gpccon_mask = 0xffffffff,
125 .gpcup = 0x0000ffff,
126 .gpcup_mask = 0xffffffff,
127 .gpdcon = 0xaa84aaa0,
128 .gpdcon_mask = 0xffffffff,
129 .gpdup = 0x0000faff,
130 .gpdup_mask = 0xffffffff,
131#endif
132
133 .lpcsel = ((0xCE6) & ~7) | 1<<4,
134
135 .width = 240,
136 .height = 320,
137
138 .xres = {
139 .min = 240,
140 .max = 240,
141 .defval = 240,
142 },
143
144 .yres = {
145 .min = 320,
146 .max = 320,
147 .defval = 320,
148 },
149
150 .bpp = {
151 .min = 16,
152 .max = 16,
153 .defval = 16,
154 },
155};
156
89static struct platform_device *smdk2440_devices[] __initdata = { 157static struct platform_device *smdk2440_devices[] __initdata = {
90 &s3c_device_usb, 158 &s3c_device_usb,
91 &s3c_device_lcd, 159 &s3c_device_lcd,
@@ -121,6 +189,8 @@ static void __init smdk2440_machine_init(void)
121 s3c2410_gpio_setpin(S3C2410_GPF6, 0); 189 s3c2410_gpio_setpin(S3C2410_GPF6, 0);
122 s3c2410_gpio_setpin(S3C2410_GPF7, 0); 190 s3c2410_gpio_setpin(S3C2410_GPF7, 0);
123 191
192 s3c24xx_fb_set_platdata(&smdk2440_lcd_cfg);
193
124 s3c2410_pm_init(); 194 s3c2410_pm_init();
125} 195}
126 196
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 24687f511bf5..75efb5da5b6d 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -388,9 +388,17 @@ static struct sa1100_port_fns assabet_port_fns __initdata = {
388}; 388};
389 389
390static struct map_desc assabet_io_desc[] __initdata = { 390static struct map_desc assabet_io_desc[] __initdata = {
391 /* virtual physical length type */ 391 { /* Board Control Register */
392 { 0xf1000000, 0x12000000, 0x00100000, MT_DEVICE }, /* Board Control Register */ 392 .virtual = 0xf1000000,
393 { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE } /* MQ200 */ 393 .pfn = __phys_to_pfn(0x12000000),
394 .length = 0x00100000,
395 .type = MT_DEVICE
396 }, { /* MQ200 */
397 .virtual = 0xf2800000,
398 .pfn = __phys_to_pfn(0x4b800000),
399 .length = 0x00800000,
400 .type = MT_DEVICE
401 }
394}; 402};
395 403
396static void __init assabet_map_io(void) 404static void __init assabet_map_io(void)
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index b6169cb09196..c92cebff7f8e 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -254,10 +254,22 @@ EXPORT_SYMBOL(badge4_set_5V);
254 254
255 255
256static struct map_desc badge4_io_desc[] __initdata = { 256static struct map_desc badge4_io_desc[] __initdata = {
257 /* virtual physical length type */ 257 { /* SRAM bank 1 */
258 {0xf1000000, 0x08000000, 0x00100000, MT_DEVICE },/* SRAM bank 1 */ 258 .virtual = 0xf1000000,
259 {0xf2000000, 0x10000000, 0x00100000, MT_DEVICE },/* SRAM bank 2 */ 259 .pfn = __phys_to_pfn(0x08000000),
260 {0xf4000000, 0x48000000, 0x00100000, MT_DEVICE } /* SA-1111 */ 260 .length = 0x00100000,
261 .type = MT_DEVICE
262 }, { /* SRAM bank 2 */
263 .virtual = 0xf2000000,
264 .pfn = __phys_to_pfn(0x10000000),
265 .length = 0x00100000,
266 .type = MT_DEVICE
267 }, { /* SA-1111 */
268 .virtual = 0xf4000000,
269 .pfn = __phys_to_pfn(0x48000000),
270 .length = 0x00100000,
271 .type = MT_DEVICE
272 }
261}; 273};
262 274
263static void 275static void
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
index 9484be7dc671..23cb74885275 100644
--- a/arch/arm/mach-sa1100/cerf.c
+++ b/arch/arm/mach-sa1100/cerf.c
@@ -100,8 +100,12 @@ static void __init cerf_init_irq(void)
100} 100}
101 101
102static struct map_desc cerf_io_desc[] __initdata = { 102static struct map_desc cerf_io_desc[] __initdata = {
103 /* virtual physical length type */ 103 { /* Crystal Ethernet Chip */
104 { 0xf0000000, 0x08000000, 0x00100000, MT_DEVICE } /* Crystal Ethernet Chip */ 104 .virtual = 0xf0000000,
105 .pfn = __phys_to_pfn(0x08000000),
106 .length = 0x00100000,
107 .type = MT_DEVICE
108 }
105}; 109};
106 110
107static void __init cerf_map_io(void) 111static void __init cerf_map_io(void)
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 6ecab7e2c238..7fd6e29c36b7 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -171,9 +171,17 @@ static void __init collie_init(void)
171} 171}
172 172
173static struct map_desc collie_io_desc[] __initdata = { 173static struct map_desc collie_io_desc[] __initdata = {
174 /* virtual physical length type */ 174 { /* 32M main flash (cs0) */
175 {0xe8000000, 0x00000000, 0x02000000, MT_DEVICE}, /* 32M main flash (cs0) */ 175 .virtual = 0xe8000000,
176 {0xea000000, 0x08000000, 0x02000000, MT_DEVICE}, /* 32M boot flash (cs1) */ 176 .pfn = __phys_to_pfn(0x00000000),
177 .length = 0x02000000,
178 .type = MT_DEVICE
179 }, { /* 32M boot flash (cs1) */
180 .virtual = 0xea000000,
181 .pfn = __phys_to_pfn(0x08000000),
182 .length = 0x02000000,
183 .type = MT_DEVICE
184 }
177}; 185};
178 186
179static void __init collie_map_io(void) 187static void __init collie_map_io(void)
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 3f1e358455e5..93619497779c 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -369,11 +369,27 @@ EXPORT_SYMBOL(sa1100fb_lcd_power);
369 */ 369 */
370 370
371static struct map_desc standard_io_desc[] __initdata = { 371static struct map_desc standard_io_desc[] __initdata = {
372 /* virtual physical length type */ 372 { /* PCM */
373 { 0xf8000000, 0x80000000, 0x00100000, MT_DEVICE }, /* PCM */ 373 .virtual = 0xf8000000,
374 { 0xfa000000, 0x90000000, 0x00100000, MT_DEVICE }, /* SCM */ 374 .pfn = __phys_to_pfn(0x80000000),
375 { 0xfc000000, 0xa0000000, 0x00100000, MT_DEVICE }, /* MER */ 375 .length = 0x00100000,
376 { 0xfe000000, 0xb0000000, 0x00200000, MT_DEVICE } /* LCD + DMA */ 376 .type = MT_DEVICE
377 }, { /* SCM */
378 .virtual = 0xfa000000,
379 .pfn = __phys_to_pfn(0x90000000),
380 .length = 0x00100000,
381 .type = MT_DEVICE
382 }, { /* MER */
383 .virtual = 0xfc000000,
384 .pfn = __phys_to_pfn(0xa0000000),
385 .length = 0x00100000,
386 .type = MT_DEVICE
387 }, { /* LCD + DMA */
388 .virtual = 0xfe000000,
389 .pfn = __phys_to_pfn(0xb0000000),
390 .length = 0x00200000,
391 .type = MT_DEVICE
392 },
377}; 393};
378 394
379void __init sa1100_map_io(void) 395void __init sa1100_map_io(void)
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index e7aa2681ca64..e8352b7f74b0 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -223,10 +223,22 @@ static void h3xxx_lcd_power(int enable)
223} 223}
224 224
225static struct map_desc h3600_io_desc[] __initdata = { 225static struct map_desc h3600_io_desc[] __initdata = {
226 /* virtual physical length type */ 226 { /* static memory bank 2 CS#2 */
227 { H3600_BANK_2_VIRT, SA1100_CS2_PHYS, 0x02800000, MT_DEVICE }, /* static memory bank 2 CS#2 */ 227 .virtual = H3600_BANK_2_VIRT,
228 { H3600_BANK_4_VIRT, SA1100_CS4_PHYS, 0x00800000, MT_DEVICE }, /* static memory bank 4 CS#4 */ 228 .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
229 { H3600_EGPIO_VIRT, H3600_EGPIO_PHYS, 0x01000000, MT_DEVICE }, /* EGPIO 0 CS#5 */ 229 .length = 0x02800000,
230 .type = MT_DEVICE
231 }, { /* static memory bank 4 CS#4 */
232 .virtual = H3600_BANK_4_VIRT,
233 .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
234 .length = 0x00800000,
235 .type = MT_DEVICE
236 }, { /* EGPIO 0 CS#5 */
237 .virtual = H3600_EGPIO_VIRT,
238 .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
239 .length = 0x01000000,
240 .type = MT_DEVICE
241 }
230}; 242};
231 243
232/* 244/*
diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
index 502d65cfe654..c922e043c424 100644
--- a/arch/arm/mach-sa1100/hackkit.c
+++ b/arch/arm/mach-sa1100/hackkit.c
@@ -57,8 +57,12 @@ static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
57 */ 57 */
58 58
59static struct map_desc hackkit_io_desc[] __initdata = { 59static struct map_desc hackkit_io_desc[] __initdata = {
60 /* virtual physical length type */ 60 { /* Flash bank 0 */
61 { 0xe8000000, 0x00000000, 0x01000000, MT_DEVICE } /* Flash bank 0 */ 61 .virtual = 0xe8000000,
62 .pfn = __phys_to_pfn(0x00000000),
63 .length = 0x01000000,
64 .type = MT_DEVICE
65 },
62}; 66};
63 67
64static struct sa1100_port_fns hackkit_port_fns __initdata = { 68static struct sa1100_port_fns hackkit_port_fns __initdata = {
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index 2f497112c96a..9c363bfcf310 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -81,10 +81,22 @@ static int __init jornada720_init(void)
81arch_initcall(jornada720_init); 81arch_initcall(jornada720_init);
82 82
83static struct map_desc jornada720_io_desc[] __initdata = { 83static struct map_desc jornada720_io_desc[] __initdata = {
84 /* virtual physical length type */ 84 { /* Epson registers */
85 { 0xf0000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Epson registers */ 85 .virtual = 0xf0000000,
86 { 0xf1000000, 0x48200000, 0x00100000, MT_DEVICE }, /* Epson frame buffer */ 86 .pfn = __phys_to_pfn(0x48000000),
87 { 0xf4000000, 0x40000000, 0x00100000, MT_DEVICE } /* SA-1111 */ 87 .length = 0x00100000,
88 .type = MT_DEVICE
89 }, { /* Epson frame buffer */
90 .virtual = 0xf1000000,
91 .pfn = __phys_to_pfn(0x48200000),
92 .length = 0x00100000,
93 .type = MT_DEVICE
94 }, { /* SA-1111 */
95 .virtual = 0xf4000000,
96 .pfn = __phys_to_pfn(0x40000000),
97 .length = 0x00100000,
98 .type = MT_DEVICE
99 }
88}; 100};
89 101
90static void __init jornada720_map_io(void) 102static void __init jornada720_map_io(void)
diff --git a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c
index ed6744d480af..8c9e3dd52942 100644
--- a/arch/arm/mach-sa1100/lart.c
+++ b/arch/arm/mach-sa1100/lart.c
@@ -31,9 +31,17 @@ static void __init lart_init(void)
31} 31}
32 32
33static struct map_desc lart_io_desc[] __initdata = { 33static struct map_desc lart_io_desc[] __initdata = {
34 /* virtual physical length type */ 34 { /* main flash memory */
35 { 0xe8000000, 0x00000000, 0x00400000, MT_DEVICE }, /* main flash memory */ 35 .virtual = 0xe8000000,
36 { 0xec000000, 0x08000000, 0x00400000, MT_DEVICE } /* main flash, alternative location */ 36 .pfn = __phys_to_pfn(0x00000000),
37 .length = 0x00400000,
38 .type = MT_DEVICE
39 }, { /* main flash, alternative location */
40 .virtual = 0xec000000,
41 .pfn = __phys_to_pfn(0x08000000),
42 .length = 0x00400000,
43 .type = MT_DEVICE
44 }
37}; 45};
38 46
39static void __init lart_map_io(void) 47static void __init lart_map_io(void)
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index fc061641b7be..052e4caedb89 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -178,33 +178,27 @@ static int neponset_probe(struct device *dev)
178/* 178/*
179 * LDM power management. 179 * LDM power management.
180 */ 180 */
181static int neponset_suspend(struct device *dev, pm_message_t state, u32 level) 181static int neponset_suspend(struct device *dev, pm_message_t state)
182{ 182{
183 /* 183 /*
184 * Save state. 184 * Save state.
185 */ 185 */
186 if (level == SUSPEND_SAVE_STATE || 186 if (!dev->power.saved_state)
187 level == SUSPEND_DISABLE || 187 dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
188 level == SUSPEND_POWER_DOWN) { 188 if (!dev->power.saved_state)
189 if (!dev->power.saved_state) 189 return -ENOMEM;
190 dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL); 190
191 if (!dev->power.saved_state) 191 *(unsigned int *)dev->power.saved_state = NCR_0;
192 return -ENOMEM;
193
194 *(unsigned int *)dev->power.saved_state = NCR_0;
195 }
196 192
197 return 0; 193 return 0;
198} 194}
199 195
200static int neponset_resume(struct device *dev, u32 level) 196static int neponset_resume(struct device *dev)
201{ 197{
202 if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) { 198 if (dev->power.saved_state) {
203 if (dev->power.saved_state) { 199 NCR_0 = *(unsigned int *)dev->power.saved_state;
204 NCR_0 = *(unsigned int *)dev->power.saved_state; 200 kfree(dev->power.saved_state);
205 kfree(dev->power.saved_state); 201 dev->power.saved_state = NULL;
206 dev->power.saved_state = NULL;
207 }
208 } 202 }
209 203
210 return 0; 204 return 0;
@@ -331,9 +325,17 @@ static int __init neponset_init(void)
331subsys_initcall(neponset_init); 325subsys_initcall(neponset_init);
332 326
333static struct map_desc neponset_io_desc[] __initdata = { 327static struct map_desc neponset_io_desc[] __initdata = {
334 /* virtual physical length type */ 328 { /* System Registers */
335 { 0xf3000000, 0x10000000, SZ_1M, MT_DEVICE }, /* System Registers */ 329 .virtual = 0xf3000000,
336 { 0xf4000000, 0x40000000, SZ_1M, MT_DEVICE } /* SA-1111 */ 330 .pfn = __phys_to_pfn(0x10000000),
331 .length = SZ_1M,
332 .type = MT_DEVICE
333 }, { /* SA-1111 */
334 .virtual = 0xf4000000,
335 .pfn = __phys_to_pfn(0x40000000),
336 .length = SZ_1M,
337 .type = MT_DEVICE
338 }
337}; 339};
338 340
339void __init neponset_map_io(void) 341void __init neponset_map_io(void)
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index 07f6d5fd7bb0..cfb6658e5cdf 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -60,11 +60,17 @@ EXPORT_SYMBOL(set_cs3_bit);
60EXPORT_SYMBOL(clear_cs3_bit); 60EXPORT_SYMBOL(clear_cs3_bit);
61 61
62static struct map_desc simpad_io_desc[] __initdata = { 62static struct map_desc simpad_io_desc[] __initdata = {
63 /* virtual physical length type */ 63 { /* MQ200 */
64 /* MQ200 */ 64 .virtual = 0xf2800000,
65 { 0xf2800000, 0x4b800000, 0x00800000, MT_DEVICE }, 65 .pfn = __phys_to_pfn(0x4b800000),
66 /* Paules CS3, write only */ 66 .length = 0x00800000,
67 { 0xf1000000, 0x18000000, 0x00100000, MT_DEVICE }, 67 .type = MT_DEVICE
68 }, { /* Paules CS3, write only */
69 .virtual = 0xf1000000,
70 .pfn = __phys_to_pfn(0x18000000),
71 .length = 0x00100000,
72 .type = MT_DEVICE
73 },
68}; 74};
69 75
70 76
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index 946c0d11c73b..2d428b6dbb58 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -62,7 +62,12 @@ arch_initcall(shark_init);
62extern void shark_init_irq(void); 62extern void shark_init_irq(void);
63 63
64static struct map_desc shark_io_desc[] __initdata = { 64static struct map_desc shark_io_desc[] __initdata = {
65 { IO_BASE , IO_START , IO_SIZE , MT_DEVICE } 65 {
66 .virtual = IO_BASE,
67 .pfn = __phys_to_pfn(IO_START),
68 .length = IO_SIZE,
69 .type = MT_DEVICE
70 }
66}; 71};
67 72
68static void __init shark_map_io(void) 73static void __init shark_map_io(void)
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index a30e0451df72..7e4bdd07f4af 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -186,25 +186,82 @@ void __init versatile_init_irq(void)
186} 186}
187 187
188static struct map_desc versatile_io_desc[] __initdata = { 188static struct map_desc versatile_io_desc[] __initdata = {
189 { IO_ADDRESS(VERSATILE_SYS_BASE), VERSATILE_SYS_BASE, SZ_4K, MT_DEVICE }, 189 {
190 { IO_ADDRESS(VERSATILE_SIC_BASE), VERSATILE_SIC_BASE, SZ_4K, MT_DEVICE }, 190 .virtual = IO_ADDRESS(VERSATILE_SYS_BASE),
191 { IO_ADDRESS(VERSATILE_VIC_BASE), VERSATILE_VIC_BASE, SZ_4K, MT_DEVICE }, 191 .pfn = __phys_to_pfn(VERSATILE_SYS_BASE),
192 { IO_ADDRESS(VERSATILE_SCTL_BASE), VERSATILE_SCTL_BASE, SZ_4K * 9, MT_DEVICE }, 192 .length = SZ_4K,
193 .type = MT_DEVICE
194 }, {
195 .virtual = IO_ADDRESS(VERSATILE_SIC_BASE),
196 .pfn = __phys_to_pfn(VERSATILE_SIC_BASE),
197 .length = SZ_4K,
198 .type = MT_DEVICE
199 }, {
200 .virtual = IO_ADDRESS(VERSATILE_VIC_BASE),
201 .pfn = __phys_to_pfn(VERSATILE_VIC_BASE),
202 .length = SZ_4K,
203 .type = MT_DEVICE
204 }, {
205 .virtual = IO_ADDRESS(VERSATILE_SCTL_BASE),
206 .pfn = __phys_to_pfn(VERSATILE_SCTL_BASE),
207 .length = SZ_4K * 9,
208 .type = MT_DEVICE
209 },
193#ifdef CONFIG_MACH_VERSATILE_AB 210#ifdef CONFIG_MACH_VERSATILE_AB
194 { IO_ADDRESS(VERSATILE_GPIO0_BASE), VERSATILE_GPIO0_BASE, SZ_4K, MT_DEVICE }, 211 {
195 { IO_ADDRESS(VERSATILE_IB2_BASE), VERSATILE_IB2_BASE, SZ_64M, MT_DEVICE }, 212 .virtual = IO_ADDRESS(VERSATILE_GPIO0_BASE),
213 .pfn = __phys_to_pfn(VERSATILE_GPIO0_BASE),
214 .length = SZ_4K,
215 .type = MT_DEVICE
216 }, {
217 .virtual = IO_ADDRESS(VERSATILE_IB2_BASE),
218 .pfn = __phys_to_pfn(VERSATILE_IB2_BASE),
219 .length = SZ_64M,
220 .type = MT_DEVICE
221 },
196#endif 222#endif
197#ifdef CONFIG_DEBUG_LL 223#ifdef CONFIG_DEBUG_LL
198 { IO_ADDRESS(VERSATILE_UART0_BASE), VERSATILE_UART0_BASE, SZ_4K, MT_DEVICE }, 224 {
225 .virtual = IO_ADDRESS(VERSATILE_UART0_BASE),
226 .pfn = __phys_to_pfn(VERSATILE_UART0_BASE),
227 .length = SZ_4K,
228 .type = MT_DEVICE
229 },
199#endif 230#endif
200#ifdef CONFIG_PCI 231#ifdef CONFIG_PCI
201 { IO_ADDRESS(VERSATILE_PCI_CORE_BASE), VERSATILE_PCI_CORE_BASE, SZ_4K, MT_DEVICE }, 232 {
202 { VERSATILE_PCI_VIRT_BASE, VERSATILE_PCI_BASE, VERSATILE_PCI_BASE_SIZE, MT_DEVICE }, 233 .virtual = IO_ADDRESS(VERSATILE_PCI_CORE_BASE),
203 { VERSATILE_PCI_CFG_VIRT_BASE, VERSATILE_PCI_CFG_BASE, VERSATILE_PCI_CFG_BASE_SIZE, MT_DEVICE }, 234 .pfn = __phys_to_pfn(VERSATILE_PCI_CORE_BASE),
235 .length = SZ_4K,
236 .type = MT_DEVICE
237 }, {
238 .virtual = VERSATILE_PCI_VIRT_BASE,
239 .pfn = __phys_to_pfn(VERSATILE_PCI_BASE),
240 .length = VERSATILE_PCI_BASE_SIZE,
241 .type = MT_DEVICE
242 }, {
243 .virtual = VERSATILE_PCI_CFG_VIRT_BASE,
244 .pfn = __phys_to_pfn(VERSATILE_PCI_CFG_BASE),
245 .length = VERSATILE_PCI_CFG_BASE_SIZE,
246 .type = MT_DEVICE
247 },
204#if 0 248#if 0
205 { VERSATILE_PCI_VIRT_MEM_BASE0, VERSATILE_PCI_MEM_BASE0, SZ_16M, MT_DEVICE }, 249 {
206 { VERSATILE_PCI_VIRT_MEM_BASE1, VERSATILE_PCI_MEM_BASE1, SZ_16M, MT_DEVICE }, 250 .virtual = VERSATILE_PCI_VIRT_MEM_BASE0,
207 { VERSATILE_PCI_VIRT_MEM_BASE2, VERSATILE_PCI_MEM_BASE2, SZ_16M, MT_DEVICE }, 251 .pfn = __phys_to_pfn(VERSATILE_PCI_MEM_BASE0),
252 .length = SZ_16M,
253 .type = MT_DEVICE
254 }, {
255 .virtual = VERSATILE_PCI_VIRT_MEM_BASE1,
256 .pfn = __phys_to_pfn(VERSATILE_PCI_MEM_BASE1),
257 .length = SZ_16M,
258 .type = MT_DEVICE
259 }, {
260 .virtual = VERSATILE_PCI_VIRT_MEM_BASE2,
261 .pfn = __phys_to_pfn(VERSATILE_PCI_MEM_BASE2),
262 .length = SZ_16M,
263 .type = MT_DEVICE
264 },
208#endif 265#endif
209#endif 266#endif
210}; 267};
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index 26356ce4da54..82f4d5e27c54 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -75,7 +75,7 @@ static struct vm_region consistent_head = {
75}; 75};
76 76
77static struct vm_region * 77static struct vm_region *
78vm_region_alloc(struct vm_region *head, size_t size, int gfp) 78vm_region_alloc(struct vm_region *head, size_t size, gfp_t gfp)
79{ 79{
80 unsigned long addr = head->vm_start, end = head->vm_end - size; 80 unsigned long addr = head->vm_start, end = head->vm_end - size;
81 unsigned long flags; 81 unsigned long flags;
@@ -133,7 +133,7 @@ static struct vm_region *vm_region_find(struct vm_region *head, unsigned long ad
133#endif 133#endif
134 134
135static void * 135static void *
136__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, int gfp, 136__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp,
137 pgprot_t prot) 137 pgprot_t prot)
138{ 138{
139 struct page *page; 139 struct page *page;
@@ -251,7 +251,7 @@ __dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, int gfp,
251 * virtual and bus address for that space. 251 * virtual and bus address for that space.
252 */ 252 */
253void * 253void *
254dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, int gfp) 254dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
255{ 255{
256 return __dma_alloc(dev, size, handle, gfp, 256 return __dma_alloc(dev, size, handle, gfp,
257 pgprot_noncached(pgprot_kernel)); 257 pgprot_noncached(pgprot_kernel));
@@ -263,7 +263,7 @@ EXPORT_SYMBOL(dma_alloc_coherent);
263 * dma_alloc_coherent above. 263 * dma_alloc_coherent above.
264 */ 264 */
265void * 265void *
266dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, int gfp) 266dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
267{ 267{
268 return __dma_alloc(dev, size, handle, gfp, 268 return __dma_alloc(dev, size, handle, gfp,
269 pgprot_writecombine(pgprot_kernel)); 269 pgprot_writecombine(pgprot_kernel));
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index edffa47a4b2a..f4496813615a 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/mm/init.c 2 * linux/arch/arm/mm/init.c
3 * 3 *
4 * Copyright (C) 1995-2002 Russell King 4 * Copyright (C) 1995-2005 Russell King
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -86,14 +86,19 @@ void show_mem(void)
86 printk("%d pages swap cached\n", cached); 86 printk("%d pages swap cached\n", cached);
87} 87}
88 88
89struct node_info { 89static inline pmd_t *pmd_off(pgd_t *pgd, unsigned long virt)
90 unsigned int start; 90{
91 unsigned int end; 91 return pmd_offset(pgd, virt);
92 int bootmap_pages; 92}
93}; 93
94static inline pmd_t *pmd_off_k(unsigned long virt)
95{
96 return pmd_off(pgd_offset_k(virt), virt);
97}
94 98
95#define O_PFN_DOWN(x) ((x) >> PAGE_SHIFT) 99#define for_each_nodebank(iter,mi,no) \
96#define O_PFN_UP(x) (PAGE_ALIGN(x) >> PAGE_SHIFT) 100 for (iter = 0; iter < mi->nr_banks; iter++) \
101 if (mi->bank[iter].node == no)
97 102
98/* 103/*
99 * FIXME: We really want to avoid allocating the bootmap bitmap 104 * FIXME: We really want to avoid allocating the bootmap bitmap
@@ -106,15 +111,12 @@ find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
106{ 111{
107 unsigned int start_pfn, bank, bootmap_pfn; 112 unsigned int start_pfn, bank, bootmap_pfn;
108 113
109 start_pfn = O_PFN_UP(__pa(&_end)); 114 start_pfn = PAGE_ALIGN(__pa(&_end)) >> PAGE_SHIFT;
110 bootmap_pfn = 0; 115 bootmap_pfn = 0;
111 116
112 for (bank = 0; bank < mi->nr_banks; bank ++) { 117 for_each_nodebank(bank, mi, node) {
113 unsigned int start, end; 118 unsigned int start, end;
114 119
115 if (mi->bank[bank].node != node)
116 continue;
117
118 start = mi->bank[bank].start >> PAGE_SHIFT; 120 start = mi->bank[bank].start >> PAGE_SHIFT;
119 end = (mi->bank[bank].size + 121 end = (mi->bank[bank].size +
120 mi->bank[bank].start) >> PAGE_SHIFT; 122 mi->bank[bank].start) >> PAGE_SHIFT;
@@ -140,92 +142,6 @@ find_bootmap_pfn(int node, struct meminfo *mi, unsigned int bootmap_pages)
140 return bootmap_pfn; 142 return bootmap_pfn;
141} 143}
142 144
143/*
144 * Scan the memory info structure and pull out:
145 * - the end of memory
146 * - the number of nodes
147 * - the pfn range of each node
148 * - the number of bootmem bitmap pages
149 */
150static unsigned int __init
151find_memend_and_nodes(struct meminfo *mi, struct node_info *np)
152{
153 unsigned int i, bootmem_pages = 0, memend_pfn = 0;
154
155 for (i = 0; i < MAX_NUMNODES; i++) {
156 np[i].start = -1U;
157 np[i].end = 0;
158 np[i].bootmap_pages = 0;
159 }
160
161 for (i = 0; i < mi->nr_banks; i++) {
162 unsigned long start, end;
163 int node;
164
165 if (mi->bank[i].size == 0) {
166 /*
167 * Mark this bank with an invalid node number
168 */
169 mi->bank[i].node = -1;
170 continue;
171 }
172
173 node = mi->bank[i].node;
174
175 /*
176 * Make sure we haven't exceeded the maximum number of nodes
177 * that we have in this configuration. If we have, we're in
178 * trouble. (maybe we ought to limit, instead of bugging?)
179 */
180 if (node >= MAX_NUMNODES)
181 BUG();
182 node_set_online(node);
183
184 /*
185 * Get the start and end pfns for this bank
186 */
187 start = mi->bank[i].start >> PAGE_SHIFT;
188 end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT;
189
190 if (np[node].start > start)
191 np[node].start = start;
192
193 if (np[node].end < end)
194 np[node].end = end;
195
196 if (memend_pfn < end)
197 memend_pfn = end;
198 }
199
200 /*
201 * Calculate the number of pages we require to
202 * store the bootmem bitmaps.
203 */
204 for_each_online_node(i) {
205 if (np[i].end == 0)
206 continue;
207
208 np[i].bootmap_pages = bootmem_bootmap_pages(np[i].end -
209 np[i].start);
210 bootmem_pages += np[i].bootmap_pages;
211 }
212
213 high_memory = __va(memend_pfn << PAGE_SHIFT);
214
215 /*
216 * This doesn't seem to be used by the Linux memory
217 * manager any more. If we can get rid of it, we
218 * also get rid of some of the stuff above as well.
219 *
220 * Note: max_low_pfn and max_pfn reflect the number
221 * of _pages_ in the system, not the maximum PFN.
222 */
223 max_low_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
224 max_pfn = memend_pfn - O_PFN_DOWN(PHYS_OFFSET);
225
226 return bootmem_pages;
227}
228
229static int __init check_initrd(struct meminfo *mi) 145static int __init check_initrd(struct meminfo *mi)
230{ 146{
231 int initrd_node = -2; 147 int initrd_node = -2;
@@ -266,9 +182,8 @@ static int __init check_initrd(struct meminfo *mi)
266/* 182/*
267 * Reserve the various regions of node 0 183 * Reserve the various regions of node 0
268 */ 184 */
269static __init void reserve_node_zero(unsigned int bootmap_pfn, unsigned int bootmap_pages) 185static __init void reserve_node_zero(pg_data_t *pgdat)
270{ 186{
271 pg_data_t *pgdat = NODE_DATA(0);
272 unsigned long res_size = 0; 187 unsigned long res_size = 0;
273 188
274 /* 189 /*
@@ -289,13 +204,6 @@ static __init void reserve_node_zero(unsigned int bootmap_pfn, unsigned int boot
289 PTRS_PER_PGD * sizeof(pgd_t)); 204 PTRS_PER_PGD * sizeof(pgd_t));
290 205
291 /* 206 /*
292 * And don't forget to reserve the allocator bitmap,
293 * which will be freed later.
294 */
295 reserve_bootmem_node(pgdat, bootmap_pfn << PAGE_SHIFT,
296 bootmap_pages << PAGE_SHIFT);
297
298 /*
299 * Hmm... This should go elsewhere, but we really really need to 207 * Hmm... This should go elsewhere, but we really really need to
300 * stop things allocating the low memory; ideally we need a better 208 * stop things allocating the low memory; ideally we need a better
301 * implementation of GFP_DMA which does not assume that DMA-able 209 * implementation of GFP_DMA which does not assume that DMA-able
@@ -324,183 +232,276 @@ static __init void reserve_node_zero(unsigned int bootmap_pfn, unsigned int boot
324 reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size); 232 reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size);
325} 233}
326 234
327/* 235void __init build_mem_type_table(void);
328 * Register all available RAM in this node with the bootmem allocator. 236void __init create_mapping(struct map_desc *md);
329 */ 237
330static inline void free_bootmem_node_bank(int node, struct meminfo *mi) 238static unsigned long __init
239bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
331{ 240{
332 pg_data_t *pgdat = NODE_DATA(node); 241 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
333 int bank; 242 unsigned long start_pfn, end_pfn, boot_pfn;
243 unsigned int boot_pages;
244 pg_data_t *pgdat;
245 int i;
334 246
335 for (bank = 0; bank < mi->nr_banks; bank++) 247 start_pfn = -1UL;
336 if (mi->bank[bank].node == node) 248 end_pfn = 0;
337 free_bootmem_node(pgdat, mi->bank[bank].start,
338 mi->bank[bank].size);
339}
340 249
341/* 250 /*
342 * Initialise the bootmem allocator for all nodes. This is called 251 * Calculate the pfn range, and map the memory banks for this node.
343 * early during the architecture specific initialisation. 252 */
344 */ 253 for_each_nodebank(i, mi, node) {
345static void __init bootmem_init(struct meminfo *mi) 254 unsigned long start, end;
346{ 255 struct map_desc map;
347 struct node_info node_info[MAX_NUMNODES], *np = node_info;
348 unsigned int bootmap_pages, bootmap_pfn, map_pg;
349 int node, initrd_node;
350 256
351 bootmap_pages = find_memend_and_nodes(mi, np); 257 start = mi->bank[i].start >> PAGE_SHIFT;
352 bootmap_pfn = find_bootmap_pfn(0, mi, bootmap_pages); 258 end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT;
353 initrd_node = check_initrd(mi);
354 259
355 map_pg = bootmap_pfn; 260 if (start_pfn > start)
261 start_pfn = start;
262 if (end_pfn < end)
263 end_pfn = end;
264
265 map.pfn = __phys_to_pfn(mi->bank[i].start);
266 map.virtual = __phys_to_virt(mi->bank[i].start);
267 map.length = mi->bank[i].size;
268 map.type = MT_MEMORY;
269
270 create_mapping(&map);
271 }
356 272
357 /* 273 /*
358 * Initialise the bootmem nodes. 274 * If there is no memory in this node, ignore it.
359 *
360 * What we really want to do is:
361 *
362 * unmap_all_regions_except_kernel();
363 * for_each_node_in_reverse_order(node) {
364 * map_node(node);
365 * allocate_bootmem_map(node);
366 * init_bootmem_node(node);
367 * free_bootmem_node(node);
368 * }
369 *
370 * but this is a 2.5-type change. For now, we just set
371 * the nodes up in reverse order.
372 *
373 * (we could also do with rolling bootmem_init and paging_init
374 * into one generic "memory_init" type function).
375 */ 275 */
376 np += num_online_nodes() - 1; 276 if (end_pfn == 0)
377 for (node = num_online_nodes() - 1; node >= 0; node--, np--) { 277 return end_pfn;
378 /*
379 * If there are no pages in this node, ignore it.
380 * Note that node 0 must always have some pages.
381 */
382 if (np->end == 0 || !node_online(node)) {
383 if (node == 0)
384 BUG();
385 continue;
386 }
387 278
388 /* 279 /*
389 * Initialise the bootmem allocator. 280 * Allocate the bootmem bitmap page.
390 */ 281 */
391 init_bootmem_node(NODE_DATA(node), map_pg, np->start, np->end); 282 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
392 free_bootmem_node_bank(node, mi); 283 boot_pfn = find_bootmap_pfn(node, mi, boot_pages);
393 map_pg += np->bootmap_pages;
394 284
395 /* 285 /*
396 * If this is node 0, we need to reserve some areas ASAP - 286 * Initialise the bootmem allocator for this node, handing the
397 * we may use bootmem on node 0 to setup the other nodes. 287 * memory banks over to bootmem.
398 */ 288 */
399 if (node == 0) 289 node_set_online(node);
400 reserve_node_zero(bootmap_pfn, bootmap_pages); 290 pgdat = NODE_DATA(node);
401 } 291 init_bootmem_node(pgdat, boot_pfn, start_pfn, end_pfn);
402 292
293 for_each_nodebank(i, mi, node)
294 free_bootmem_node(pgdat, mi->bank[i].start, mi->bank[i].size);
295
296 /*
297 * Reserve the bootmem bitmap for this node.
298 */
299 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT,
300 boot_pages << PAGE_SHIFT);
403 301
404#ifdef CONFIG_BLK_DEV_INITRD 302#ifdef CONFIG_BLK_DEV_INITRD
405 if (phys_initrd_size && initrd_node >= 0) { 303 /*
406 reserve_bootmem_node(NODE_DATA(initrd_node), phys_initrd_start, 304 * If the initrd is in this node, reserve its memory.
305 */
306 if (node == initrd_node) {
307 reserve_bootmem_node(pgdat, phys_initrd_start,
407 phys_initrd_size); 308 phys_initrd_size);
408 initrd_start = __phys_to_virt(phys_initrd_start); 309 initrd_start = __phys_to_virt(phys_initrd_start);
409 initrd_end = initrd_start + phys_initrd_size; 310 initrd_end = initrd_start + phys_initrd_size;
410 } 311 }
411#endif 312#endif
412 313
413 BUG_ON(map_pg != bootmap_pfn + bootmap_pages); 314 /*
315 * Finally, reserve any node zero regions.
316 */
317 if (node == 0)
318 reserve_node_zero(pgdat);
319
320 /*
321 * initialise the zones within this node.
322 */
323 memset(zone_size, 0, sizeof(zone_size));
324 memset(zhole_size, 0, sizeof(zhole_size));
325
326 /*
327 * The size of this node has already been determined. If we need
328 * to do anything fancy with the allocation of this memory to the
329 * zones, now is the time to do it.
330 */
331 zone_size[0] = end_pfn - start_pfn;
332
333 /*
334 * For each bank in this node, calculate the size of the holes.
335 * holes = node_size - sum(bank_sizes_in_node)
336 */
337 zhole_size[0] = zone_size[0];
338 for_each_nodebank(i, mi, node)
339 zhole_size[0] -= mi->bank[i].size >> PAGE_SHIFT;
340
341 /*
342 * Adjust the sizes according to any special requirements for
343 * this machine type.
344 */
345 arch_adjust_zones(node, zone_size, zhole_size);
346
347 free_area_init_node(node, pgdat, zone_size, start_pfn, zhole_size);
348
349 return end_pfn;
414} 350}
415 351
416/* 352static void __init bootmem_init(struct meminfo *mi)
417 * paging_init() sets up the page tables, initialises the zone memory
418 * maps, and sets up the zero page, bad page and bad page tables.
419 */
420void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc)
421{ 353{
422 void *zero_page; 354 unsigned long addr, memend_pfn = 0;
423 int node; 355 int node, initrd_node, i;
424 356
425 bootmem_init(mi); 357 /*
358 * Invalidate the node number for empty or invalid memory banks
359 */
360 for (i = 0; i < mi->nr_banks; i++)
361 if (mi->bank[i].size == 0 || mi->bank[i].node >= MAX_NUMNODES)
362 mi->bank[i].node = -1;
426 363
427 memcpy(&meminfo, mi, sizeof(meminfo)); 364 memcpy(&meminfo, mi, sizeof(meminfo));
428 365
366#ifdef CONFIG_XIP_KERNEL
367#error needs fixing
368 p->pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & PMD_MASK);
369 p->virtual = (unsigned long)&_stext & PMD_MASK;
370 p->length = ((unsigned long)&_etext - p->virtual + ~PMD_MASK) & PMD_MASK;
371 p->type = MT_ROM;
372 p ++;
373#endif
374
429 /* 375 /*
430 * allocate the zero page. Note that we count on this going ok. 376 * Clear out all the mappings below the kernel image.
377 * FIXME: what about XIP?
431 */ 378 */
432 zero_page = alloc_bootmem_low_pages(PAGE_SIZE); 379 for (addr = 0; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
380 pmd_clear(pmd_off_k(addr));
433 381
434 /* 382 /*
435 * initialise the page tables. 383 * Clear out all the kernel space mappings, except for the first
384 * memory bank, up to the end of the vmalloc region.
436 */ 385 */
437 memtable_init(mi); 386 for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size);
438 if (mdesc->map_io) 387 addr < VMALLOC_END; addr += PGDIR_SIZE)
439 mdesc->map_io(); 388 pmd_clear(pmd_off_k(addr));
440 local_flush_tlb_all();
441 389
442 /* 390 /*
443 * initialise the zones within each node 391 * Locate which node contains the ramdisk image, if any.
444 */ 392 */
445 for_each_online_node(node) { 393 initrd_node = check_initrd(mi);
446 unsigned long zone_size[MAX_NR_ZONES];
447 unsigned long zhole_size[MAX_NR_ZONES];
448 struct bootmem_data *bdata;
449 pg_data_t *pgdat;
450 int i;
451 394
452 /* 395 /*
453 * Initialise the zone size information. 396 * Run through each node initialising the bootmem allocator.
454 */ 397 */
455 for (i = 0; i < MAX_NR_ZONES; i++) { 398 for_each_node(node) {
456 zone_size[i] = 0; 399 unsigned long end_pfn;
457 zhole_size[i] = 0;
458 }
459 400
460 pgdat = NODE_DATA(node); 401 end_pfn = bootmem_init_node(node, initrd_node, mi);
461 bdata = pgdat->bdata;
462 402
463 /* 403 /*
464 * The size of this node has already been determined. 404 * Remember the highest memory PFN.
465 * If we need to do anything fancy with the allocation
466 * of this memory to the zones, now is the time to do
467 * it.
468 */ 405 */
469 zone_size[0] = bdata->node_low_pfn - 406 if (end_pfn > memend_pfn)
470 (bdata->node_boot_start >> PAGE_SHIFT); 407 memend_pfn = end_pfn;
408 }
471 409
472 /* 410 high_memory = __va(memend_pfn << PAGE_SHIFT);
473 * If this zone has zero size, skip it.
474 */
475 if (!zone_size[0])
476 continue;
477 411
478 /* 412 /*
479 * For each bank in this node, calculate the size of the 413 * This doesn't seem to be used by the Linux memory manager any
480 * holes. holes = node_size - sum(bank_sizes_in_node) 414 * more, but is used by ll_rw_block. If we can get rid of it, we
481 */ 415 * also get rid of some of the stuff above as well.
482 zhole_size[0] = zone_size[0]; 416 *
483 for (i = 0; i < mi->nr_banks; i++) { 417 * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
484 if (mi->bank[i].node != node) 418 * the system, not the maximum PFN.
485 continue; 419 */
420 max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET;
421}
486 422
487 zhole_size[0] -= mi->bank[i].size >> PAGE_SHIFT; 423/*
488 } 424 * Set up device the mappings. Since we clear out the page tables for all
425 * mappings above VMALLOC_END, we will remove any debug device mappings.
426 * This means you have to be careful how you debug this function, or any
427 * called function. (Do it by code inspection!)
428 */
429static void __init devicemaps_init(struct machine_desc *mdesc)
430{
431 struct map_desc map;
432 unsigned long addr;
433 void *vectors;
489 434
490 /* 435 for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE)
491 * Adjust the sizes according to any special 436 pmd_clear(pmd_off_k(addr));
492 * requirements for this machine type.
493 */
494 arch_adjust_zones(node, zone_size, zhole_size);
495 437
496 free_area_init_node(node, pgdat, zone_size, 438 /*
497 bdata->node_boot_start >> PAGE_SHIFT, zhole_size); 439 * Map the cache flushing regions.
440 */
441#ifdef FLUSH_BASE
442 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
443 map.virtual = FLUSH_BASE;
444 map.length = PGDIR_SIZE;
445 map.type = MT_CACHECLEAN;
446 create_mapping(&map);
447#endif
448#ifdef FLUSH_BASE_MINICACHE
449 map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + PGDIR_SIZE);
450 map.virtual = FLUSH_BASE_MINICACHE;
451 map.length = PGDIR_SIZE;
452 map.type = MT_MINICLEAN;
453 create_mapping(&map);
454#endif
455
456 flush_cache_all();
457 local_flush_tlb_all();
458
459 vectors = alloc_bootmem_low_pages(PAGE_SIZE);
460 BUG_ON(!vectors);
461
462 /*
463 * Create a mapping for the machine vectors at the high-vectors
464 * location (0xffff0000). If we aren't using high-vectors, also
465 * create a mapping at the low-vectors virtual address.
466 */
467 map.pfn = __phys_to_pfn(virt_to_phys(vectors));
468 map.virtual = 0xffff0000;
469 map.length = PAGE_SIZE;
470 map.type = MT_HIGH_VECTORS;
471 create_mapping(&map);
472
473 if (!vectors_high()) {
474 map.virtual = 0;
475 map.type = MT_LOW_VECTORS;
476 create_mapping(&map);
498 } 477 }
499 478
500 /* 479 /*
501 * finish off the bad pages once 480 * Ask the machine support to map in the statically mapped devices.
502 * the mem_map is initialised 481 * After this point, we can start to touch devices again.
482 */
483 if (mdesc->map_io)
484 mdesc->map_io();
485}
486
487/*
488 * paging_init() sets up the page tables, initialises the zone memory
489 * maps, and sets up the zero page, bad page and bad page tables.
490 */
491void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc)
492{
493 void *zero_page;
494
495 build_mem_type_table();
496 bootmem_init(mi);
497 devicemaps_init(mdesc);
498
499 top_pmd = pmd_off_k(0xffff0000);
500
501 /*
502 * allocate the zero page. Note that we count on this going ok.
503 */ 503 */
504 zero_page = alloc_bootmem_low_pages(PAGE_SIZE);
504 memzero(zero_page, PAGE_SIZE); 505 memzero(zero_page, PAGE_SIZE);
505 empty_zero_page = virt_to_page(zero_page); 506 empty_zero_page = virt_to_page(zero_page);
506 flush_dcache_page(empty_zero_page); 507 flush_dcache_page(empty_zero_page);
@@ -562,10 +563,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
562 * may not be the case, especially if the user has provided the 563 * may not be the case, especially if the user has provided the
563 * information on the command line. 564 * information on the command line.
564 */ 565 */
565 for (i = 0; i < mi->nr_banks; i++) { 566 for_each_nodebank(i, mi, node) {
566 if (mi->bank[i].size == 0 || mi->bank[i].node != node)
567 continue;
568
569 bank_start = mi->bank[i].start >> PAGE_SHIFT; 567 bank_start = mi->bank[i].start >> PAGE_SHIFT;
570 if (bank_start < prev_bank_end) { 568 if (bank_start < prev_bank_end) {
571 printk(KERN_ERR "MEM: unordered memory banks. " 569 printk(KERN_ERR "MEM: unordered memory banks. "
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index 7110e54182b1..6fb1258df1b5 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -26,6 +26,7 @@
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27 27
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/hardware.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/tlbflush.h> 31#include <asm/tlbflush.h>
31 32
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index d125a3dc061c..61bc2fa0511e 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/mm/mm-armv.c 2 * linux/arch/arm/mm/mm-armv.c
3 * 3 *
4 * Copyright (C) 1998-2002 Russell King 4 * Copyright (C) 1998-2005 Russell King
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -305,16 +305,6 @@ alloc_init_page(unsigned long virt, unsigned long phys, unsigned int prot_l1, pg
305 set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot)); 305 set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot));
306} 306}
307 307
308/*
309 * Clear any PGD mapping. On a two-level page table system,
310 * the clearance is done by the middle-level functions (pmd)
311 * rather than the top-level (pgd) functions.
312 */
313static inline void clear_mapping(unsigned long virt)
314{
315 pmd_clear(pmd_off_k(virt));
316}
317
318struct mem_types { 308struct mem_types {
319 unsigned int prot_pte; 309 unsigned int prot_pte;
320 unsigned int prot_l1; 310 unsigned int prot_l1;
@@ -373,7 +363,7 @@ static struct mem_types mem_types[] __initdata = {
373/* 363/*
374 * Adjust the PMD section entries according to the CPU in use. 364 * Adjust the PMD section entries according to the CPU in use.
375 */ 365 */
376static void __init build_mem_type_table(void) 366void __init build_mem_type_table(void)
377{ 367{
378 struct cachepolicy *cp; 368 struct cachepolicy *cp;
379 unsigned int cr = get_cr(); 369 unsigned int cr = get_cr();
@@ -483,25 +473,25 @@ static void __init build_mem_type_table(void)
483 * offsets, and we take full advantage of sections and 473 * offsets, and we take full advantage of sections and
484 * supersections. 474 * supersections.
485 */ 475 */
486static void __init create_mapping(struct map_desc *md) 476void __init create_mapping(struct map_desc *md)
487{ 477{
488 unsigned long virt, length; 478 unsigned long virt, length;
489 int prot_sect, prot_l1, domain; 479 int prot_sect, prot_l1, domain;
490 pgprot_t prot_pte; 480 pgprot_t prot_pte;
491 long off; 481 unsigned long off = (u32)__pfn_to_phys(md->pfn);
492 482
493 if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) { 483 if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) {
494 printk(KERN_WARNING "BUG: not creating mapping for " 484 printk(KERN_WARNING "BUG: not creating mapping for "
495 "0x%08lx at 0x%08lx in user region\n", 485 "0x%016llx at 0x%08lx in user region\n",
496 md->physical, md->virtual); 486 __pfn_to_phys((u64)md->pfn), md->virtual);
497 return; 487 return;
498 } 488 }
499 489
500 if ((md->type == MT_DEVICE || md->type == MT_ROM) && 490 if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
501 md->virtual >= PAGE_OFFSET && md->virtual < VMALLOC_END) { 491 md->virtual >= PAGE_OFFSET && md->virtual < VMALLOC_END) {
502 printk(KERN_WARNING "BUG: mapping for 0x%08lx at 0x%08lx " 492 printk(KERN_WARNING "BUG: mapping for 0x%016llx at 0x%08lx "
503 "overlaps vmalloc space\n", 493 "overlaps vmalloc space\n",
504 md->physical, md->virtual); 494 __pfn_to_phys((u64)md->pfn), md->virtual);
505 } 495 }
506 496
507 domain = mem_types[md->type].domain; 497 domain = mem_types[md->type].domain;
@@ -509,15 +499,40 @@ static void __init create_mapping(struct map_desc *md)
509 prot_l1 = mem_types[md->type].prot_l1 | PMD_DOMAIN(domain); 499 prot_l1 = mem_types[md->type].prot_l1 | PMD_DOMAIN(domain);
510 prot_sect = mem_types[md->type].prot_sect | PMD_DOMAIN(domain); 500 prot_sect = mem_types[md->type].prot_sect | PMD_DOMAIN(domain);
511 501
502 /*
503 * Catch 36-bit addresses
504 */
505 if(md->pfn >= 0x100000) {
506 if(domain) {
507 printk(KERN_ERR "MM: invalid domain in supersection "
508 "mapping for 0x%016llx at 0x%08lx\n",
509 __pfn_to_phys((u64)md->pfn), md->virtual);
510 return;
511 }
512 if((md->virtual | md->length | __pfn_to_phys(md->pfn))
513 & ~SUPERSECTION_MASK) {
514 printk(KERN_ERR "MM: cannot create mapping for "
515 "0x%016llx at 0x%08lx invalid alignment\n",
516 __pfn_to_phys((u64)md->pfn), md->virtual);
517 return;
518 }
519
520 /*
521 * Shift bits [35:32] of address into bits [23:20] of PMD
522 * (See ARMv6 spec).
523 */
524 off |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20);
525 }
526
512 virt = md->virtual; 527 virt = md->virtual;
513 off = md->physical - virt; 528 off -= virt;
514 length = md->length; 529 length = md->length;
515 530
516 if (mem_types[md->type].prot_l1 == 0 && 531 if (mem_types[md->type].prot_l1 == 0 &&
517 (virt & 0xfffff || (virt + off) & 0xfffff || (virt + length) & 0xfffff)) { 532 (virt & 0xfffff || (virt + off) & 0xfffff || (virt + length) & 0xfffff)) {
518 printk(KERN_WARNING "BUG: map for 0x%08lx at 0x%08lx can not " 533 printk(KERN_WARNING "BUG: map for 0x%08lx at 0x%08lx can not "
519 "be mapped using pages, ignoring.\n", 534 "be mapped using pages, ignoring.\n",
520 md->physical, md->virtual); 535 __pfn_to_phys(md->pfn), md->virtual);
521 return; 536 return;
522 } 537 }
523 538
@@ -535,13 +550,22 @@ static void __init create_mapping(struct map_desc *md)
535 * of the actual domain assignments in use. 550 * of the actual domain assignments in use.
536 */ 551 */
537 if (cpu_architecture() >= CPU_ARCH_ARMv6 && domain == 0) { 552 if (cpu_architecture() >= CPU_ARCH_ARMv6 && domain == 0) {
538 /* Align to supersection boundary */ 553 /*
539 while ((virt & ~SUPERSECTION_MASK || (virt + off) & 554 * Align to supersection boundary if !high pages.
540 ~SUPERSECTION_MASK) && length >= (PGDIR_SIZE / 2)) { 555 * High pages have already been checked for proper
541 alloc_init_section(virt, virt + off, prot_sect); 556 * alignment above and they will fail the SUPSERSECTION_MASK
542 557 * check because of the way the address is encoded into
543 virt += (PGDIR_SIZE / 2); 558 * offset.
544 length -= (PGDIR_SIZE / 2); 559 */
560 if (md->pfn <= 0x100000) {
561 while ((virt & ~SUPERSECTION_MASK ||
562 (virt + off) & ~SUPERSECTION_MASK) &&
563 length >= (PGDIR_SIZE / 2)) {
564 alloc_init_section(virt, virt + off, prot_sect);
565
566 virt += (PGDIR_SIZE / 2);
567 length -= (PGDIR_SIZE / 2);
568 }
545 } 569 }
546 570
547 while (length >= SUPERSECTION_SIZE) { 571 while (length >= SUPERSECTION_SIZE) {
@@ -601,100 +625,6 @@ void setup_mm_for_reboot(char mode)
601 } 625 }
602} 626}
603 627
604extern void _stext, _etext;
605
606/*
607 * Setup initial mappings. We use the page we allocated for zero page to hold
608 * the mappings, which will get overwritten by the vectors in traps_init().
609 * The mappings must be in virtual address order.
610 */
611void __init memtable_init(struct meminfo *mi)
612{
613 struct map_desc *init_maps, *p, *q;
614 unsigned long address = 0;
615 int i;
616
617 build_mem_type_table();
618
619 init_maps = p = alloc_bootmem_low_pages(PAGE_SIZE);
620
621#ifdef CONFIG_XIP_KERNEL
622 p->physical = CONFIG_XIP_PHYS_ADDR & PMD_MASK;
623 p->virtual = (unsigned long)&_stext & PMD_MASK;
624 p->length = ((unsigned long)&_etext - p->virtual + ~PMD_MASK) & PMD_MASK;
625 p->type = MT_ROM;
626 p ++;
627#endif
628
629 for (i = 0; i < mi->nr_banks; i++) {
630 if (mi->bank[i].size == 0)
631 continue;
632
633 p->physical = mi->bank[i].start;
634 p->virtual = __phys_to_virt(p->physical);
635 p->length = mi->bank[i].size;
636 p->type = MT_MEMORY;
637 p ++;
638 }
639
640#ifdef FLUSH_BASE
641 p->physical = FLUSH_BASE_PHYS;
642 p->virtual = FLUSH_BASE;
643 p->length = PGDIR_SIZE;
644 p->type = MT_CACHECLEAN;
645 p ++;
646#endif
647
648#ifdef FLUSH_BASE_MINICACHE
649 p->physical = FLUSH_BASE_PHYS + PGDIR_SIZE;
650 p->virtual = FLUSH_BASE_MINICACHE;
651 p->length = PGDIR_SIZE;
652 p->type = MT_MINICLEAN;
653 p ++;
654#endif
655
656 /*
657 * Go through the initial mappings, but clear out any
658 * pgdir entries that are not in the description.
659 */
660 q = init_maps;
661 do {
662 if (address < q->virtual || q == p) {
663 clear_mapping(address);
664 address += PGDIR_SIZE;
665 } else {
666 create_mapping(q);
667
668 address = q->virtual + q->length;
669 address = (address + PGDIR_SIZE - 1) & PGDIR_MASK;
670
671 q ++;
672 }
673 } while (address != 0);
674
675 /*
676 * Create a mapping for the machine vectors at the high-vectors
677 * location (0xffff0000). If we aren't using high-vectors, also
678 * create a mapping at the low-vectors virtual address.
679 */
680 init_maps->physical = virt_to_phys(init_maps);
681 init_maps->virtual = 0xffff0000;
682 init_maps->length = PAGE_SIZE;
683 init_maps->type = MT_HIGH_VECTORS;
684 create_mapping(init_maps);
685
686 if (!vectors_high()) {
687 init_maps->virtual = 0;
688 init_maps->type = MT_LOW_VECTORS;
689 create_mapping(init_maps);
690 }
691
692 flush_cache_all();
693 local_flush_tlb_all();
694
695 top_pmd = pmd_off_k(0xffff0000);
696}
697
698/* 628/*
699 * Create the architecture specific mappings 629 * Create the architecture specific mappings
700 */ 630 */
diff --git a/arch/arm/oprofile/Makefile b/arch/arm/oprofile/Makefile
index 8ffb523e6c77..6a94e54848fd 100644
--- a/arch/arm/oprofile/Makefile
+++ b/arch/arm/oprofile/Makefile
@@ -6,6 +6,6 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
6 oprofilefs.o oprofile_stats.o \ 6 oprofilefs.o oprofile_stats.o \
7 timer_int.o ) 7 timer_int.o )
8 8
9oprofile-y := $(DRIVER_OBJS) init.o backtrace.o 9oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
10oprofile-$(CONFIG_CPU_XSCALE) += common.o op_model_xscale.o 10oprofile-$(CONFIG_CPU_XSCALE) += op_model_xscale.o
11 11
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index e57dde882898..1415930ceee1 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -10,74 +10,23 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/oprofile.h> 11#include <linux/oprofile.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <asm/semaphore.h>
14#include <linux/sysdev.h> 13#include <linux/sysdev.h>
14#include <asm/semaphore.h>
15 15
16#include "op_counter.h" 16#include "op_counter.h"
17#include "op_arm_model.h" 17#include "op_arm_model.h"
18 18
19static struct op_arm_model_spec *pmu_model; 19static struct op_arm_model_spec *op_arm_model;
20static int pmu_enabled; 20static int op_arm_enabled;
21static struct semaphore pmu_sem; 21static struct semaphore op_arm_sem;
22
23static int pmu_start(void);
24static int pmu_setup(void);
25static void pmu_stop(void);
26static int pmu_create_files(struct super_block *, struct dentry *);
27
28#ifdef CONFIG_PM
29static int pmu_suspend(struct sys_device *dev, pm_message_t state)
30{
31 if (pmu_enabled)
32 pmu_stop();
33 return 0;
34}
35
36static int pmu_resume(struct sys_device *dev)
37{
38 if (pmu_enabled)
39 pmu_start();
40 return 0;
41}
42
43static struct sysdev_class oprofile_sysclass = {
44 set_kset_name("oprofile"),
45 .resume = pmu_resume,
46 .suspend = pmu_suspend,
47};
48
49static struct sys_device device_oprofile = {
50 .id = 0,
51 .cls = &oprofile_sysclass,
52};
53
54static int __init init_driverfs(void)
55{
56 int ret;
57
58 if (!(ret = sysdev_class_register(&oprofile_sysclass)))
59 ret = sysdev_register(&device_oprofile);
60
61 return ret;
62}
63
64static void exit_driverfs(void)
65{
66 sysdev_unregister(&device_oprofile);
67 sysdev_class_unregister(&oprofile_sysclass);
68}
69#else
70#define init_driverfs() do { } while (0)
71#define exit_driverfs() do { } while (0)
72#endif /* CONFIG_PM */
73 22
74struct op_counter_config counter_config[OP_MAX_COUNTER]; 23struct op_counter_config counter_config[OP_MAX_COUNTER];
75 24
76static int pmu_create_files(struct super_block *sb, struct dentry *root) 25static int op_arm_create_files(struct super_block *sb, struct dentry *root)
77{ 26{
78 unsigned int i; 27 unsigned int i;
79 28
80 for (i = 0; i < pmu_model->num_counters; i++) { 29 for (i = 0; i < op_arm_model->num_counters; i++) {
81 struct dentry *dir; 30 struct dentry *dir;
82 char buf[2]; 31 char buf[2];
83 32
@@ -94,63 +43,123 @@ static int pmu_create_files(struct super_block *sb, struct dentry *root)
94 return 0; 43 return 0;
95} 44}
96 45
97static int pmu_setup(void) 46static int op_arm_setup(void)
98{ 47{
99 int ret; 48 int ret;
100 49
101 spin_lock(&oprofilefs_lock); 50 spin_lock(&oprofilefs_lock);
102 ret = pmu_model->setup_ctrs(); 51 ret = op_arm_model->setup_ctrs();
103 spin_unlock(&oprofilefs_lock); 52 spin_unlock(&oprofilefs_lock);
104 return ret; 53 return ret;
105} 54}
106 55
107static int pmu_start(void) 56static int op_arm_start(void)
108{ 57{
109 int ret = -EBUSY; 58 int ret = -EBUSY;
110 59
111 down(&pmu_sem); 60 down(&op_arm_sem);
112 if (!pmu_enabled) { 61 if (!op_arm_enabled) {
113 ret = pmu_model->start(); 62 ret = op_arm_model->start();
114 pmu_enabled = !ret; 63 op_arm_enabled = !ret;
115 } 64 }
116 up(&pmu_sem); 65 up(&op_arm_sem);
117 return ret; 66 return ret;
118} 67}
119 68
120static void pmu_stop(void) 69static void op_arm_stop(void)
70{
71 down(&op_arm_sem);
72 if (op_arm_enabled)
73 op_arm_model->stop();
74 op_arm_enabled = 0;
75 up(&op_arm_sem);
76}
77
78#ifdef CONFIG_PM
79static int op_arm_suspend(struct sys_device *dev, pm_message_t state)
121{ 80{
122 down(&pmu_sem); 81 down(&op_arm_sem);
123 if (pmu_enabled) 82 if (op_arm_enabled)
124 pmu_model->stop(); 83 op_arm_model->stop();
125 pmu_enabled = 0; 84 up(&op_arm_sem);
126 up(&pmu_sem); 85 return 0;
127} 86}
128 87
129int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec) 88static int op_arm_resume(struct sys_device *dev)
130{ 89{
131 init_MUTEX(&pmu_sem); 90 down(&op_arm_sem);
91 if (op_arm_enabled && op_arm_model->start())
92 op_arm_enabled = 0;
93 up(&op_arm_sem);
94 return 0;
95}
96
97static struct sysdev_class oprofile_sysclass = {
98 set_kset_name("oprofile"),
99 .resume = op_arm_resume,
100 .suspend = op_arm_suspend,
101};
132 102
133 if (spec->init() < 0) 103static struct sys_device device_oprofile = {
134 return -ENODEV; 104 .id = 0,
105 .cls = &oprofile_sysclass,
106};
135 107
136 pmu_model = spec; 108static int __init init_driverfs(void)
137 init_driverfs(); 109{
138 ops->create_files = pmu_create_files; 110 int ret;
139 ops->setup = pmu_setup;
140 ops->shutdown = pmu_stop;
141 ops->start = pmu_start;
142 ops->stop = pmu_stop;
143 ops->cpu_type = pmu_model->name;
144 printk(KERN_INFO "oprofile: using %s PMU\n", spec->name);
145 111
146 return 0; 112 if (!(ret = sysdev_class_register(&oprofile_sysclass)))
113 ret = sysdev_register(&device_oprofile);
114
115 return ret;
116}
117
118static void exit_driverfs(void)
119{
120 sysdev_unregister(&device_oprofile);
121 sysdev_class_unregister(&oprofile_sysclass);
122}
123#else
124#define init_driverfs() do { } while (0)
125#define exit_driverfs() do { } while (0)
126#endif /* CONFIG_PM */
127
128int __init oprofile_arch_init(struct oprofile_operations *ops)
129{
130 struct op_arm_model_spec *spec = NULL;
131 int ret = -ENODEV;
132
133#ifdef CONFIG_CPU_XSCALE
134 spec = &op_xscale_spec;
135#endif
136
137 if (spec) {
138 init_MUTEX(&op_arm_sem);
139
140 if (spec->init() < 0)
141 return -ENODEV;
142
143 op_arm_model = spec;
144 init_driverfs();
145 ops->create_files = op_arm_create_files;
146 ops->setup = op_arm_setup;
147 ops->shutdown = op_arm_stop;
148 ops->start = op_arm_start;
149 ops->stop = op_arm_stop;
150 ops->cpu_type = op_arm_model->name;
151 ops->backtrace = arm_backtrace;
152 printk(KERN_INFO "oprofile: using %s\n", spec->name);
153 }
154
155 return ret;
147} 156}
148 157
149void pmu_exit(void) 158void oprofile_arch_exit(void)
150{ 159{
151 if (pmu_model) { 160 if (op_arm_model) {
152 exit_driverfs(); 161 exit_driverfs();
153 pmu_model = NULL; 162 op_arm_model = NULL;
154 } 163 }
155} 164}
156 165
diff --git a/arch/arm/oprofile/init.c b/arch/arm/oprofile/init.c
deleted file mode 100644
index d315a3a86c86..000000000000
--- a/arch/arm/oprofile/init.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/**
2 * @file init.c
3 *
4 * @remark Copyright 2004 Oprofile Authors
5 * @remark Read the file COPYING
6 *
7 * @author Zwane Mwaikambo
8 */
9
10#include <linux/oprofile.h>
11#include <linux/init.h>
12#include <linux/errno.h>
13#include "op_arm_model.h"
14
15int __init oprofile_arch_init(struct oprofile_operations *ops)
16{
17 int ret = -ENODEV;
18
19#ifdef CONFIG_CPU_XSCALE
20 ret = pmu_init(ops, &op_xscale_spec);
21#endif
22
23 ops->backtrace = arm_backtrace;
24
25 return ret;
26}
27
28void oprofile_arch_exit(void)
29{
30#ifdef CONFIG_CPU_XSCALE
31 pmu_exit();
32#endif
33}
diff --git a/arch/arm/oprofile/op_arm_model.h b/arch/arm/oprofile/op_arm_model.h
index 2148d07484b7..38c6ad158547 100644
--- a/arch/arm/oprofile/op_arm_model.h
+++ b/arch/arm/oprofile/op_arm_model.h
@@ -26,6 +26,6 @@ extern struct op_arm_model_spec op_xscale_spec;
26 26
27extern void arm_backtrace(struct pt_regs * const regs, unsigned int depth); 27extern void arm_backtrace(struct pt_regs * const regs, unsigned int depth);
28 28
29extern int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec); 29extern int __init op_arm_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec);
30extern void pmu_exit(void); 30extern void op_arm_exit(void);
31#endif /* OP_ARM_MODEL_H */ 31#endif /* OP_ARM_MODEL_H */
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 7719a4062e3a..7ad69f14a3e7 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -59,7 +59,11 @@ void __init omap_detect_sram(void)
59} 59}
60 60
61static struct map_desc omap_sram_io_desc[] __initdata = { 61static struct map_desc omap_sram_io_desc[] __initdata = {
62 { OMAP1_SRAM_BASE, OMAP1_SRAM_START, 0, MT_DEVICE } 62 { /* .length gets filled in at runtime */
63 .virtual = OMAP1_SRAM_BASE,
64 .pfn = __phys_to_pfn(OMAP1_SRAM_START),
65 .type = MT_DEVICE
66 }
63}; 67};
64 68
65/* 69/*
diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c b/arch/frv/mb93090-mb00/pci-dma-nommu.c
index 819895cf0b9e..2082a9647f4f 100644
--- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
+++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
@@ -33,7 +33,7 @@ struct dma_alloc_record {
33static DEFINE_SPINLOCK(dma_alloc_lock); 33static DEFINE_SPINLOCK(dma_alloc_lock);
34static LIST_HEAD(dma_alloc_list); 34static LIST_HEAD(dma_alloc_list);
35 35
36void *dma_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, int gfp) 36void *dma_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t gfp)
37{ 37{
38 struct dma_alloc_record *new; 38 struct dma_alloc_record *new;
39 struct list_head *this = &dma_alloc_list; 39 struct list_head *this = &dma_alloc_list;
diff --git a/arch/frv/mb93090-mb00/pci-dma.c b/arch/frv/mb93090-mb00/pci-dma.c
index 27eb12066507..86fbdadc51b6 100644
--- a/arch/frv/mb93090-mb00/pci-dma.c
+++ b/arch/frv/mb93090-mb00/pci-dma.c
@@ -17,7 +17,7 @@
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20void *dma_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, int gfp) 20void *dma_alloc_coherent(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t gfp)
21{ 21{
22 void *ret; 22 void *ret;
23 23
diff --git a/arch/frv/mm/dma-alloc.c b/arch/frv/mm/dma-alloc.c
index 4b38d45435f6..cfc4f97490c6 100644
--- a/arch/frv/mm/dma-alloc.c
+++ b/arch/frv/mm/dma-alloc.c
@@ -81,7 +81,7 @@ static int map_page(unsigned long va, unsigned long pa, pgprot_t prot)
81 * portions of the kernel with single large page TLB entries, and 81 * portions of the kernel with single large page TLB entries, and
82 * still get unique uncached pages for consistent DMA. 82 * still get unique uncached pages for consistent DMA.
83 */ 83 */
84void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle) 84void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
85{ 85{
86 struct vm_struct *area; 86 struct vm_struct *area;
87 unsigned long page, va, pa; 87 unsigned long page, va, pa;
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index 4647db4ad6de..13bae799e626 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -163,7 +163,7 @@ static int cpuid_class_device_create(int i)
163 int err = 0; 163 int err = 0;
164 struct class_device *class_err; 164 struct class_device *class_err;
165 165
166 class_err = class_device_create(cpuid_class, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i); 166 class_err = class_device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i);
167 if (IS_ERR(class_err)) 167 if (IS_ERR(class_err))
168 err = PTR_ERR(class_err); 168 err = PTR_ERR(class_err);
169 return err; 169 return err;
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index 03100d6fc5d6..44470fea4309 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -246,7 +246,7 @@ static int msr_class_device_create(int i)
246 int err = 0; 246 int err = 0;
247 struct class_device *class_err; 247 struct class_device *class_err;
248 248
249 class_err = class_device_create(msr_class, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i); 249 class_err = class_device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i);
250 if (IS_ERR(class_err)) 250 if (IS_ERR(class_err))
251 err = PTR_ERR(class_err); 251 err = PTR_ERR(class_err);
252 return err; 252 return err;
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index 8e8e895e1b5a..330fd2b68075 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -2,6 +2,8 @@
2 * Exceptions for specific devices. Usually work-arounds for fatal design flaws. 2 * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
3 */ 3 */
4 4
5#include <linux/delay.h>
6#include <linux/dmi.h>
5#include <linux/pci.h> 7#include <linux/pci.h>
6#include <linux/init.h> 8#include <linux/init.h>
7#include "pci.h" 9#include "pci.h"
@@ -384,3 +386,60 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
384 } 386 }
385} 387}
386DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); 388DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
389
390/*
391 * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A.
392 *
393 * We pretend to bring them out of full D3 state, and restore the proper
394 * IRQ, PCI cache line size, and BARs, otherwise the device won't function
395 * properly. In some cases, the device will generate an interrupt on
396 * the wrong IRQ line, causing any devices sharing the the line it's
397 * *supposed* to use to be disabled by the kernel's IRQ debug code.
398 */
399static u16 toshiba_line_size;
400
401static struct dmi_system_id __devinit toshiba_ohci1394_dmi_table[] = {
402 {
403 .ident = "Toshiba PS5 based laptop",
404 .matches = {
405 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
406 DMI_MATCH(DMI_PRODUCT_VERSION, "PS5"),
407 },
408 },
409 {
410 .ident = "Toshiba PSM4 based laptop",
411 .matches = {
412 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
413 DMI_MATCH(DMI_PRODUCT_VERSION, "PSM4"),
414 },
415 },
416 { }
417};
418
419static void __devinit pci_pre_fixup_toshiba_ohci1394(struct pci_dev *dev)
420{
421 if (!dmi_check_system(toshiba_ohci1394_dmi_table))
422 return; /* only applies to certain Toshibas (so far) */
423
424 dev->current_state = PCI_D3cold;
425 pci_read_config_word(dev, PCI_CACHE_LINE_SIZE, &toshiba_line_size);
426}
427DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0x8032,
428 pci_pre_fixup_toshiba_ohci1394);
429
430static void __devinit pci_post_fixup_toshiba_ohci1394(struct pci_dev *dev)
431{
432 if (!dmi_check_system(toshiba_ohci1394_dmi_table))
433 return; /* only applies to certain Toshibas (so far) */
434
435 /* Restore config space on Toshiba laptops */
436 mdelay(10);
437 pci_write_config_word(dev, PCI_CACHE_LINE_SIZE, toshiba_line_size);
438 pci_write_config_word(dev, PCI_INTERRUPT_LINE, dev->irq);
439 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0,
440 pci_resource_start(dev, 0));
441 pci_write_config_dword(dev, PCI_BASE_ADDRESS_1,
442 pci_resource_start(dev, 1));
443}
444DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_TI, 0x8032,
445 pci_post_fixup_toshiba_ohci1394);
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 317c334c5a18..a5a5637507be 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -80,7 +80,7 @@ hwsw_init (void)
80} 80}
81 81
82void * 82void *
83hwsw_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, int flags) 83hwsw_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flags)
84{ 84{
85 if (use_swiotlb(dev)) 85 if (use_swiotlb(dev))
86 return swiotlb_alloc_coherent(dev, size, dma_handle, flags); 86 return swiotlb_alloc_coherent(dev, size, dma_handle, flags);
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index e64ca04ace89..bdccd0b1eb60 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -1076,7 +1076,7 @@ void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, int dir)
1076 * See Documentation/DMA-mapping.txt 1076 * See Documentation/DMA-mapping.txt
1077 */ 1077 */
1078void * 1078void *
1079sba_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, int flags) 1079sba_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flags)
1080{ 1080{
1081 struct ioc *ioc; 1081 struct ioc *ioc;
1082 void *addr; 1082 void *addr;
diff --git a/arch/ia64/lib/swiotlb.c b/arch/ia64/lib/swiotlb.c
index 48e5ff26eb1d..96edcc0fdcd9 100644
--- a/arch/ia64/lib/swiotlb.c
+++ b/arch/ia64/lib/swiotlb.c
@@ -416,7 +416,7 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
416 416
417void * 417void *
418swiotlb_alloc_coherent(struct device *hwdev, size_t size, 418swiotlb_alloc_coherent(struct device *hwdev, size_t size,
419 dma_addr_t *dma_handle, int flags) 419 dma_addr_t *dma_handle, gfp_t flags)
420{ 420{
421 unsigned long dev_addr; 421 unsigned long dev_addr;
422 void *ret; 422 void *ret;
diff --git a/arch/ia64/sn/kernel/xpc.h b/arch/ia64/sn/kernel/xpc.h
index 33df1b3758b6..fbcedc7c27fa 100644
--- a/arch/ia64/sn/kernel/xpc.h
+++ b/arch/ia64/sn/kernel/xpc.h
@@ -1221,7 +1221,7 @@ xpc_map_bte_errors(bte_result_t error)
1221 1221
1222 1222
1223static inline void * 1223static inline void *
1224xpc_kmalloc_cacheline_aligned(size_t size, int flags, void **base) 1224xpc_kmalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
1225{ 1225{
1226 /* see if kmalloc will give us cachline aligned memory by default */ 1226 /* see if kmalloc will give us cachline aligned memory by default */
1227 *base = kmalloc(size, flags); 1227 *base = kmalloc(size, flags);
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index abdf6eea6ac8..9bf9f23b9a1f 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -75,7 +75,7 @@ EXPORT_SYMBOL(sn_dma_set_mask);
75 * more information. 75 * more information.
76 */ 76 */
77void *sn_dma_alloc_coherent(struct device *dev, size_t size, 77void *sn_dma_alloc_coherent(struct device *dev, size_t size,
78 dma_addr_t * dma_handle, int flags) 78 dma_addr_t * dma_handle, gfp_t flags)
79{ 79{
80 void *cpuaddr; 80 void *cpuaddr;
81 unsigned long phys_addr; 81 unsigned long phys_addr;
diff --git a/arch/mips/mm/dma-coherent.c b/arch/mips/mm/dma-coherent.c
index 97a50d38c98f..a617f8c327e8 100644
--- a/arch/mips/mm/dma-coherent.c
+++ b/arch/mips/mm/dma-coherent.c
@@ -18,7 +18,7 @@
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20void *dma_alloc_noncoherent(struct device *dev, size_t size, 20void *dma_alloc_noncoherent(struct device *dev, size_t size,
21 dma_addr_t * dma_handle, int gfp) 21 dma_addr_t * dma_handle, gfp_t gfp)
22{ 22{
23 void *ret; 23 void *ret;
24 /* ignore region specifiers */ 24 /* ignore region specifiers */
@@ -39,7 +39,7 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
39EXPORT_SYMBOL(dma_alloc_noncoherent); 39EXPORT_SYMBOL(dma_alloc_noncoherent);
40 40
41void *dma_alloc_coherent(struct device *dev, size_t size, 41void *dma_alloc_coherent(struct device *dev, size_t size,
42 dma_addr_t * dma_handle, int gfp) 42 dma_addr_t * dma_handle, gfp_t gfp)
43 __attribute__((alias("dma_alloc_noncoherent"))); 43 __attribute__((alias("dma_alloc_noncoherent")));
44 44
45EXPORT_SYMBOL(dma_alloc_coherent); 45EXPORT_SYMBOL(dma_alloc_coherent);
diff --git a/arch/mips/mm/dma-ip27.c b/arch/mips/mm/dma-ip27.c
index aa7c94b5d781..8da19fd22ac6 100644
--- a/arch/mips/mm/dma-ip27.c
+++ b/arch/mips/mm/dma-ip27.c
@@ -22,7 +22,7 @@
22 pdev_to_baddr(to_pci_dev(dev), (addr)) 22 pdev_to_baddr(to_pci_dev(dev), (addr))
23 23
24void *dma_alloc_noncoherent(struct device *dev, size_t size, 24void *dma_alloc_noncoherent(struct device *dev, size_t size,
25 dma_addr_t * dma_handle, int gfp) 25 dma_addr_t * dma_handle, gfp_t gfp)
26{ 26{
27 void *ret; 27 void *ret;
28 28
@@ -44,7 +44,7 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
44EXPORT_SYMBOL(dma_alloc_noncoherent); 44EXPORT_SYMBOL(dma_alloc_noncoherent);
45 45
46void *dma_alloc_coherent(struct device *dev, size_t size, 46void *dma_alloc_coherent(struct device *dev, size_t size,
47 dma_addr_t * dma_handle, int gfp) 47 dma_addr_t * dma_handle, gfp_t gfp)
48 __attribute__((alias("dma_alloc_noncoherent"))); 48 __attribute__((alias("dma_alloc_noncoherent")));
49 49
50EXPORT_SYMBOL(dma_alloc_coherent); 50EXPORT_SYMBOL(dma_alloc_coherent);
diff --git a/arch/mips/mm/dma-ip32.c b/arch/mips/mm/dma-ip32.c
index 2cbe196c35fb..a7e3072ff78d 100644
--- a/arch/mips/mm/dma-ip32.c
+++ b/arch/mips/mm/dma-ip32.c
@@ -37,7 +37,7 @@
37#define RAM_OFFSET_MASK 0x3fffffff 37#define RAM_OFFSET_MASK 0x3fffffff
38 38
39void *dma_alloc_noncoherent(struct device *dev, size_t size, 39void *dma_alloc_noncoherent(struct device *dev, size_t size,
40 dma_addr_t * dma_handle, int gfp) 40 dma_addr_t * dma_handle, gfp_t gfp)
41{ 41{
42 void *ret; 42 void *ret;
43 /* ignore region specifiers */ 43 /* ignore region specifiers */
@@ -61,7 +61,7 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
61EXPORT_SYMBOL(dma_alloc_noncoherent); 61EXPORT_SYMBOL(dma_alloc_noncoherent);
62 62
63void *dma_alloc_coherent(struct device *dev, size_t size, 63void *dma_alloc_coherent(struct device *dev, size_t size,
64 dma_addr_t * dma_handle, int gfp) 64 dma_addr_t * dma_handle, gfp_t gfp)
65{ 65{
66 void *ret; 66 void *ret;
67 67
diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c
index 59e54f12212e..4ce02028a292 100644
--- a/arch/mips/mm/dma-noncoherent.c
+++ b/arch/mips/mm/dma-noncoherent.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26void *dma_alloc_noncoherent(struct device *dev, size_t size, 26void *dma_alloc_noncoherent(struct device *dev, size_t size,
27 dma_addr_t * dma_handle, int gfp) 27 dma_addr_t * dma_handle, gfp_t gfp)
28{ 28{
29 void *ret; 29 void *ret;
30 /* ignore region specifiers */ 30 /* ignore region specifiers */
@@ -45,7 +45,7 @@ void *dma_alloc_noncoherent(struct device *dev, size_t size,
45EXPORT_SYMBOL(dma_alloc_noncoherent); 45EXPORT_SYMBOL(dma_alloc_noncoherent);
46 46
47void *dma_alloc_coherent(struct device *dev, size_t size, 47void *dma_alloc_coherent(struct device *dev, size_t size,
48 dma_addr_t * dma_handle, int gfp) 48 dma_addr_t * dma_handle, gfp_t gfp)
49{ 49{
50 void *ret; 50 void *ret;
51 51
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 0b07922a2ac6..874a283edb95 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -47,10 +47,10 @@ config PM
47 47
48config ISA_DMA_API 48config ISA_DMA_API
49 bool 49 bool
50 default y
51 50
52config ARCH_MAY_HAVE_PC_FDC 51config ARCH_MAY_HAVE_PC_FDC
53 bool 52 bool
53 depends on BROKEN
54 default y 54 default y
55 55
56source "init/Kconfig" 56source "init/Kconfig"
@@ -154,13 +154,14 @@ config HOTPLUG_CPU
154 154
155config ARCH_DISCONTIGMEM_ENABLE 155config ARCH_DISCONTIGMEM_ENABLE
156 bool "Discontiguous memory support (EXPERIMENTAL)" 156 bool "Discontiguous memory support (EXPERIMENTAL)"
157 depends on EXPERIMENTAL 157 depends on 64BIT && EXPERIMENTAL
158 help 158 help
159 Say Y to support efficient handling of discontiguous physical memory, 159 Say Y to support efficient handling of discontiguous physical memory,
160 for architectures which are either NUMA (Non-Uniform Memory Access) 160 for architectures which are either NUMA (Non-Uniform Memory Access)
161 or have huge holes in the physical address space for other reasons. 161 or have huge holes in the physical address space for other reasons.
162 See <file:Documentation/vm/numa> for more. 162 See <file:Documentation/vm/numa> for more.
163 163
164source "kernel/Kconfig.hz"
164source "mm/Kconfig" 165source "mm/Kconfig"
165 166
166config PREEMPT 167config PREEMPT
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 3b339b1cce13..9b7e42490dd1 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -20,7 +20,8 @@ NM = sh $(srctree)/arch/parisc/nm
20CHECKFLAGS += -D__hppa__=1 20CHECKFLAGS += -D__hppa__=1
21 21
22ifdef CONFIG_64BIT 22ifdef CONFIG_64BIT
23CROSS_COMPILE := hppa64-linux- 23CROSS_COMPILE := $(shell if [ -x /usr/bin/hppa64-linux-gnu-gcc ]; then \
24 echo hppa64-linux-gnu-; else echo hppa64-linux-; fi)
24UTS_MACHINE := parisc64 25UTS_MACHINE := parisc64
25CHECKFLAGS += -D__LP64__=1 -m64 26CHECKFLAGS += -D__LP64__=1 -m64
26else 27else
@@ -34,6 +35,14 @@ FINAL_LD=$(CROSS_COMPILE)ld --warn-common --warn-section-align
34 35
35OBJCOPY_FLAGS =-O binary -R .note -R .comment -S 36OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
36 37
38GCC_VERSION := $(call cc-version)
39ifneq ($(shell if [ -z $(GCC_VERSION) ] ; then echo "bad"; fi ;),)
40$(error Sorry, couldn't find ($(cc-version)).)
41endif
42ifneq ($(shell if [ $(GCC_VERSION) -lt 0303 ] ; then echo "bad"; fi ;),)
43$(error Sorry, your compiler is too old ($(GCC_VERSION)). GCC v3.3 or above is required.)
44endif
45
37cflags-y := -pipe 46cflags-y := -pipe
38 47
39# These flags should be implied by an hppa-linux configuration, but they 48# These flags should be implied by an hppa-linux configuration, but they
@@ -43,7 +52,7 @@ cflags-y += -mno-space-regs -mfast-indirect-calls
43# Currently we save and restore fpregs on all kernel entry/interruption paths. 52# Currently we save and restore fpregs on all kernel entry/interruption paths.
44# If that gets optimized, we might need to disable the use of fpregs in the 53# If that gets optimized, we might need to disable the use of fpregs in the
45# kernel. 54# kernel.
46#cflags-y += -mdisable-fpregs 55cflags-y += -mdisable-fpregs
47 56
48# Without this, "ld -r" results in .text sections that are too big 57# Without this, "ld -r" results in .text sections that are too big
49# (> 0x40000) for branches to reach stubs. 58# (> 0x40000) for branches to reach stubs.
diff --git a/arch/parisc/configs/712_defconfig b/arch/parisc/configs/712_defconfig
index 6efaa9293eef..3e013f55df64 100644
--- a/arch/parisc/configs/712_defconfig
+++ b/arch/parisc/configs/712_defconfig
@@ -1,12 +1,16 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.10-pa5 3# Linux kernel version: 2.6.14-rc5-pa1
4# Wed Jan 5 13:20:32 2005 4# Fri Oct 21 23:04:34 2005
5# 5#
6CONFIG_PARISC=y 6CONFIG_PARISC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_STACK_GROWSUP=y 8CONFIG_STACK_GROWSUP=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_GENERIC_IRQ_PROBE=y
13CONFIG_ARCH_MAY_HAVE_PC_FDC=y
10 14
11# 15#
12# Code maturity level options 16# Code maturity level options
@@ -15,35 +19,40 @@ CONFIG_EXPERIMENTAL=y
15# CONFIG_CLEAN_COMPILE is not set 19# CONFIG_CLEAN_COMPILE is not set
16CONFIG_BROKEN=y 20CONFIG_BROKEN=y
17CONFIG_BROKEN_ON_SMP=y 21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
18 23
19# 24#
20# General setup 25# General setup
21# 26#
22CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
28# CONFIG_LOCALVERSION_AUTO is not set
23CONFIG_SWAP=y 29CONFIG_SWAP=y
24CONFIG_SYSVIPC=y 30CONFIG_SYSVIPC=y
25CONFIG_POSIX_MQUEUE=y 31CONFIG_POSIX_MQUEUE=y
26# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
27CONFIG_SYSCTL=y 33CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 34# CONFIG_AUDIT is not set
29CONFIG_LOG_BUF_SHIFT=16
30CONFIG_HOTPLUG=y 35CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y 36CONFIG_KOBJECT_UEVENT=y
32CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
33CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
39CONFIG_INITRAMFS_SOURCE=""
34# CONFIG_EMBEDDED is not set 40# CONFIG_EMBEDDED is not set
35CONFIG_KALLSYMS=y 41CONFIG_KALLSYMS=y
36CONFIG_KALLSYMS_ALL=y 42CONFIG_KALLSYMS_ALL=y
37# CONFIG_KALLSYMS_EXTRA_PASS is not set 43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y 47CONFIG_FUTEX=y
39CONFIG_EPOLL=y 48CONFIG_EPOLL=y
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
41CONFIG_SHMEM=y 49CONFIG_SHMEM=y
42CONFIG_CC_ALIGN_FUNCTIONS=0 50CONFIG_CC_ALIGN_FUNCTIONS=0
43CONFIG_CC_ALIGN_LABELS=0 51CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 52CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 53CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 54# CONFIG_TINY_SHMEM is not set
55CONFIG_BASE_SMALL=0
47 56
48# 57#
49# Loadable module support 58# Loadable module support
@@ -65,9 +74,18 @@ CONFIG_PA7100LC=y
65# CONFIG_PA7300LC is not set 74# CONFIG_PA7300LC is not set
66# CONFIG_PA8X00 is not set 75# CONFIG_PA8X00 is not set
67CONFIG_PA11=y 76CONFIG_PA11=y
68# CONFIG_64BIT is not set
69# CONFIG_SMP is not set 77# CONFIG_SMP is not set
70# CONFIG_DISCONTIGMEM is not set 78# CONFIG_HZ_100 is not set
79CONFIG_HZ_250=y
80# CONFIG_HZ_1000 is not set
81CONFIG_HZ=250
82CONFIG_SELECT_MEMORY_MODEL=y
83CONFIG_FLATMEM_MANUAL=y
84# CONFIG_DISCONTIGMEM_MANUAL is not set
85# CONFIG_SPARSEMEM_MANUAL is not set
86CONFIG_FLATMEM=y
87CONFIG_FLAT_NODE_MEM_MAP=y
88# CONFIG_SPARSEMEM_STATIC is not set
71# CONFIG_PREEMPT is not set 89# CONFIG_PREEMPT is not set
72# CONFIG_HPUX is not set 90# CONFIG_HPUX is not set
73 91
@@ -81,8 +99,6 @@ CONFIG_GSC_LASI=y
81# CONFIG_GSC_WAX is not set 99# CONFIG_GSC_WAX is not set
82# CONFIG_EISA is not set 100# CONFIG_EISA is not set
83# CONFIG_PCI is not set 101# CONFIG_PCI is not set
84CONFIG_CHASSIS_LCD_LED=y
85# CONFIG_PDC_CHASSIS is not set
86 102
87# 103#
88# PCCARD (PCMCIA/CardBus) support 104# PCCARD (PCMCIA/CardBus) support
@@ -90,12 +106,15 @@ CONFIG_CHASSIS_LCD_LED=y
90# CONFIG_PCCARD is not set 106# CONFIG_PCCARD is not set
91 107
92# 108#
93# PC-card bridges 109# PCI Hotplug Support
94# 110#
95 111
96# 112#
97# PCI Hotplug Support 113# PA-RISC specific drivers
98# 114#
115CONFIG_CHASSIS_LCD_LED=y
116# CONFIG_PDC_CHASSIS is not set
117CONFIG_PDC_STABLE=y
99 118
100# 119#
101# Executable file formats 120# Executable file formats
@@ -104,137 +123,7 @@ CONFIG_BINFMT_ELF=y
104CONFIG_BINFMT_MISC=m 123CONFIG_BINFMT_MISC=m
105 124
106# 125#
107# Device Drivers 126# Networking
108#
109
110#
111# Generic Driver Options
112#
113# CONFIG_STANDALONE is not set
114# CONFIG_PREVENT_FIRMWARE_BUILD is not set
115CONFIG_FW_LOADER=y
116# CONFIG_DEBUG_DRIVER is not set
117
118#
119# Memory Technology Devices (MTD)
120#
121# CONFIG_MTD is not set
122
123#
124# Parallel port support
125#
126CONFIG_PARPORT=y
127CONFIG_PARPORT_PC=m
128CONFIG_PARPORT_PC_CML1=m
129# CONFIG_PARPORT_PC_FIFO is not set
130# CONFIG_PARPORT_PC_SUPERIO is not set
131CONFIG_PARPORT_GSC=y
132# CONFIG_PARPORT_OTHER is not set
133# CONFIG_PARPORT_1284 is not set
134
135#
136# Plug and Play support
137#
138
139#
140# Block devices
141#
142# CONFIG_BLK_DEV_FD is not set
143# CONFIG_PARIDE is not set
144CONFIG_BLK_DEV_LOOP=y
145CONFIG_BLK_DEV_CRYPTOLOOP=y
146# CONFIG_BLK_DEV_NBD is not set
147CONFIG_BLK_DEV_RAM=y
148CONFIG_BLK_DEV_RAM_COUNT=16
149CONFIG_BLK_DEV_RAM_SIZE=6144
150CONFIG_BLK_DEV_INITRD=y
151CONFIG_INITRAMFS_SOURCE=""
152# CONFIG_CDROM_PKTCDVD is not set
153
154#
155# IO Schedulers
156#
157CONFIG_IOSCHED_NOOP=y
158CONFIG_IOSCHED_AS=y
159CONFIG_IOSCHED_DEADLINE=y
160CONFIG_IOSCHED_CFQ=y
161
162#
163# ATA/ATAPI/MFM/RLL support
164#
165# CONFIG_IDE is not set
166
167#
168# SCSI device support
169#
170CONFIG_SCSI=y
171CONFIG_SCSI_PROC_FS=y
172
173#
174# SCSI support type (disk, tape, CD-ROM)
175#
176CONFIG_BLK_DEV_SD=y
177CONFIG_CHR_DEV_ST=y
178# CONFIG_CHR_DEV_OSST is not set
179CONFIG_BLK_DEV_SR=y
180# CONFIG_BLK_DEV_SR_VENDOR is not set
181CONFIG_CHR_DEV_SG=y
182
183#
184# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
185#
186# CONFIG_SCSI_MULTI_LUN is not set
187# CONFIG_SCSI_CONSTANTS is not set
188# CONFIG_SCSI_LOGGING is not set
189
190#
191# SCSI Transport Attributes
192#
193CONFIG_SCSI_SPI_ATTRS=y
194# CONFIG_SCSI_FC_ATTRS is not set
195
196#
197# SCSI low-level drivers
198#
199# CONFIG_SCSI_SATA is not set
200# CONFIG_SCSI_PPA is not set
201# CONFIG_SCSI_IMM is not set
202CONFIG_SCSI_LASI700=y
203CONFIG_53C700_MEM_MAPPED=y
204CONFIG_53C700_LE_ON_BE=y
205# CONFIG_SCSI_ZALON is not set
206CONFIG_SCSI_DEBUG=m
207
208#
209# Multi-device support (RAID and LVM)
210#
211CONFIG_MD=y
212CONFIG_BLK_DEV_MD=m
213CONFIG_MD_LINEAR=m
214CONFIG_MD_RAID0=m
215CONFIG_MD_RAID1=m
216# CONFIG_MD_RAID10 is not set
217# CONFIG_MD_RAID5 is not set
218# CONFIG_MD_RAID6 is not set
219# CONFIG_MD_MULTIPATH is not set
220# CONFIG_MD_FAULTY is not set
221# CONFIG_BLK_DEV_DM is not set
222
223#
224# Fusion MPT device support
225#
226
227#
228# IEEE 1394 (FireWire) support
229#
230# CONFIG_IEEE1394 is not set
231
232#
233# I2O device support
234#
235
236#
237# Networking support
238# 127#
239CONFIG_NET=y 128CONFIG_NET=y
240 129
@@ -243,12 +132,14 @@ CONFIG_NET=y
243# 132#
244CONFIG_PACKET=y 133CONFIG_PACKET=y
245CONFIG_PACKET_MMAP=y 134CONFIG_PACKET_MMAP=y
246CONFIG_NETLINK_DEV=y
247CONFIG_UNIX=y 135CONFIG_UNIX=y
136CONFIG_XFRM=y
137CONFIG_XFRM_USER=m
248CONFIG_NET_KEY=m 138CONFIG_NET_KEY=m
249CONFIG_INET=y 139CONFIG_INET=y
250CONFIG_IP_MULTICAST=y 140CONFIG_IP_MULTICAST=y
251# CONFIG_IP_ADVANCED_ROUTER is not set 141# CONFIG_IP_ADVANCED_ROUTER is not set
142CONFIG_IP_FIB_HASH=y
252CONFIG_IP_PNP=y 143CONFIG_IP_PNP=y
253CONFIG_IP_PNP_DHCP=y 144CONFIG_IP_PNP_DHCP=y
254CONFIG_IP_PNP_BOOTP=y 145CONFIG_IP_PNP_BOOTP=y
@@ -262,8 +153,10 @@ CONFIG_INET_AH=m
262CONFIG_INET_ESP=m 153CONFIG_INET_ESP=m
263# CONFIG_INET_IPCOMP is not set 154# CONFIG_INET_IPCOMP is not set
264CONFIG_INET_TUNNEL=m 155CONFIG_INET_TUNNEL=m
265CONFIG_IP_TCPDIAG=y 156CONFIG_INET_DIAG=m
266# CONFIG_IP_TCPDIAG_IPV6 is not set 157CONFIG_INET_TCP_DIAG=m
158# CONFIG_TCP_CONG_ADVANCED is not set
159CONFIG_TCP_CONG_BIC=y
267 160
268# 161#
269# IP: Virtual Server Configuration 162# IP: Virtual Server Configuration
@@ -272,6 +165,7 @@ CONFIG_IP_TCPDIAG=y
272# CONFIG_IPV6 is not set 165# CONFIG_IPV6 is not set
273CONFIG_NETFILTER=y 166CONFIG_NETFILTER=y
274# CONFIG_NETFILTER_DEBUG is not set 167# CONFIG_NETFILTER_DEBUG is not set
168# CONFIG_NETFILTER_NETLINK is not set
275 169
276# 170#
277# IP: Netfilter Configuration 171# IP: Netfilter Configuration
@@ -279,11 +173,14 @@ CONFIG_NETFILTER=y
279CONFIG_IP_NF_CONNTRACK=m 173CONFIG_IP_NF_CONNTRACK=m
280# CONFIG_IP_NF_CT_ACCT is not set 174# CONFIG_IP_NF_CT_ACCT is not set
281CONFIG_IP_NF_CONNTRACK_MARK=y 175CONFIG_IP_NF_CONNTRACK_MARK=y
176# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
282CONFIG_IP_NF_CT_PROTO_SCTP=m 177CONFIG_IP_NF_CT_PROTO_SCTP=m
283CONFIG_IP_NF_FTP=m 178CONFIG_IP_NF_FTP=m
284CONFIG_IP_NF_IRC=m 179CONFIG_IP_NF_IRC=m
180# CONFIG_IP_NF_NETBIOS_NS is not set
285CONFIG_IP_NF_TFTP=m 181CONFIG_IP_NF_TFTP=m
286CONFIG_IP_NF_AMANDA=m 182CONFIG_IP_NF_AMANDA=m
183# CONFIG_IP_NF_PPTP is not set
287CONFIG_IP_NF_QUEUE=m 184CONFIG_IP_NF_QUEUE=m
288CONFIG_IP_NF_IPTABLES=m 185CONFIG_IP_NF_IPTABLES=m
289CONFIG_IP_NF_MATCH_LIMIT=m 186CONFIG_IP_NF_MATCH_LIMIT=m
@@ -307,21 +204,23 @@ CONFIG_IP_NF_MATCH_OWNER=m
307# CONFIG_IP_NF_MATCH_ADDRTYPE is not set 204# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
308# CONFIG_IP_NF_MATCH_REALM is not set 205# CONFIG_IP_NF_MATCH_REALM is not set
309CONFIG_IP_NF_MATCH_SCTP=m 206CONFIG_IP_NF_MATCH_SCTP=m
207# CONFIG_IP_NF_MATCH_DCCP is not set
310CONFIG_IP_NF_MATCH_COMMENT=m 208CONFIG_IP_NF_MATCH_COMMENT=m
311CONFIG_IP_NF_MATCH_CONNMARK=m 209CONFIG_IP_NF_MATCH_CONNMARK=m
312CONFIG_IP_NF_MATCH_HASHLIMIT=m 210CONFIG_IP_NF_MATCH_HASHLIMIT=m
211# CONFIG_IP_NF_MATCH_STRING is not set
313CONFIG_IP_NF_FILTER=m 212CONFIG_IP_NF_FILTER=m
314CONFIG_IP_NF_TARGET_REJECT=m 213CONFIG_IP_NF_TARGET_REJECT=m
315CONFIG_IP_NF_TARGET_LOG=m 214CONFIG_IP_NF_TARGET_LOG=m
316CONFIG_IP_NF_TARGET_ULOG=m 215CONFIG_IP_NF_TARGET_ULOG=m
317CONFIG_IP_NF_TARGET_TCPMSS=m 216CONFIG_IP_NF_TARGET_TCPMSS=m
217# CONFIG_IP_NF_TARGET_NFQUEUE is not set
318CONFIG_IP_NF_NAT=m 218CONFIG_IP_NF_NAT=m
319CONFIG_IP_NF_NAT_NEEDED=y 219CONFIG_IP_NF_NAT_NEEDED=y
320CONFIG_IP_NF_TARGET_MASQUERADE=m 220CONFIG_IP_NF_TARGET_MASQUERADE=m
321CONFIG_IP_NF_TARGET_REDIRECT=m 221CONFIG_IP_NF_TARGET_REDIRECT=m
322CONFIG_IP_NF_TARGET_NETMAP=m 222CONFIG_IP_NF_TARGET_NETMAP=m
323CONFIG_IP_NF_TARGET_SAME=m 223CONFIG_IP_NF_TARGET_SAME=m
324# CONFIG_IP_NF_NAT_LOCAL is not set
325CONFIG_IP_NF_NAT_SNMP_BASIC=m 224CONFIG_IP_NF_NAT_SNMP_BASIC=m
326CONFIG_IP_NF_NAT_IRC=m 225CONFIG_IP_NF_NAT_IRC=m
327CONFIG_IP_NF_NAT_FTP=m 226CONFIG_IP_NF_NAT_FTP=m
@@ -333,6 +232,7 @@ CONFIG_IP_NF_TARGET_ECN=m
333CONFIG_IP_NF_TARGET_DSCP=m 232CONFIG_IP_NF_TARGET_DSCP=m
334CONFIG_IP_NF_TARGET_MARK=m 233CONFIG_IP_NF_TARGET_MARK=m
335CONFIG_IP_NF_TARGET_CLASSIFY=m 234CONFIG_IP_NF_TARGET_CLASSIFY=m
235# CONFIG_IP_NF_TARGET_TTL is not set
336CONFIG_IP_NF_TARGET_CONNMARK=m 236CONFIG_IP_NF_TARGET_CONNMARK=m
337CONFIG_IP_NF_TARGET_CLUSTERIP=m 237CONFIG_IP_NF_TARGET_CLUSTERIP=m
338CONFIG_IP_NF_RAW=m 238CONFIG_IP_NF_RAW=m
@@ -340,10 +240,11 @@ CONFIG_IP_NF_TARGET_NOTRACK=m
340CONFIG_IP_NF_ARPTABLES=m 240CONFIG_IP_NF_ARPTABLES=m
341CONFIG_IP_NF_ARPFILTER=m 241CONFIG_IP_NF_ARPFILTER=m
342CONFIG_IP_NF_ARP_MANGLE=m 242CONFIG_IP_NF_ARP_MANGLE=m
343# CONFIG_IP_NF_COMPAT_IPCHAINS is not set 243
344# CONFIG_IP_NF_COMPAT_IPFWADM is not set 244#
345CONFIG_XFRM=y 245# DCCP Configuration (EXPERIMENTAL)
346CONFIG_XFRM_USER=m 246#
247# CONFIG_IP_DCCP is not set
347 248
348# 249#
349# SCTP Configuration (EXPERIMENTAL) 250# SCTP Configuration (EXPERIMENTAL)
@@ -362,10 +263,6 @@ CONFIG_LLC2=m
362# CONFIG_NET_DIVERT is not set 263# CONFIG_NET_DIVERT is not set
363# CONFIG_ECONET is not set 264# CONFIG_ECONET is not set
364# CONFIG_WAN_ROUTER is not set 265# CONFIG_WAN_ROUTER is not set
365
366#
367# QoS and/or fair queueing
368#
369# CONFIG_NET_SCHED is not set 266# CONFIG_NET_SCHED is not set
370# CONFIG_NET_CLS_ROUTE is not set 267# CONFIG_NET_CLS_ROUTE is not set
371 268
@@ -373,17 +270,162 @@ CONFIG_LLC2=m
373# Network testing 270# Network testing
374# 271#
375CONFIG_NET_PKTGEN=m 272CONFIG_NET_PKTGEN=m
376# CONFIG_NETPOLL is not set
377# CONFIG_NET_POLL_CONTROLLER is not set
378# CONFIG_HAMRADIO is not set 273# CONFIG_HAMRADIO is not set
379# CONFIG_IRDA is not set 274# CONFIG_IRDA is not set
380# CONFIG_BT is not set 275# CONFIG_BT is not set
276# CONFIG_IEEE80211 is not set
277
278#
279# Device Drivers
280#
281
282#
283# Generic Driver Options
284#
285# CONFIG_STANDALONE is not set
286# CONFIG_PREVENT_FIRMWARE_BUILD is not set
287CONFIG_FW_LOADER=y
288# CONFIG_DEBUG_DRIVER is not set
289
290#
291# Connector - unified userspace <-> kernelspace linker
292#
293# CONFIG_CONNECTOR is not set
294
295#
296# Memory Technology Devices (MTD)
297#
298# CONFIG_MTD is not set
299
300#
301# Parallel port support
302#
303CONFIG_PARPORT=y
304CONFIG_PARPORT_PC=m
305# CONFIG_PARPORT_PC_FIFO is not set
306# CONFIG_PARPORT_PC_SUPERIO is not set
307CONFIG_PARPORT_GSC=y
308# CONFIG_PARPORT_1284 is not set
309
310#
311# Plug and Play support
312#
313
314#
315# Block devices
316#
317# CONFIG_BLK_DEV_FD is not set
318# CONFIG_PARIDE is not set
319# CONFIG_BLK_DEV_COW_COMMON is not set
320CONFIG_BLK_DEV_LOOP=y
321CONFIG_BLK_DEV_CRYPTOLOOP=y
322# CONFIG_BLK_DEV_NBD is not set
323CONFIG_BLK_DEV_RAM=y
324CONFIG_BLK_DEV_RAM_COUNT=16
325CONFIG_BLK_DEV_RAM_SIZE=6144
326CONFIG_BLK_DEV_INITRD=y
327# CONFIG_CDROM_PKTCDVD is not set
328
329#
330# IO Schedulers
331#
332CONFIG_IOSCHED_NOOP=y
333CONFIG_IOSCHED_AS=y
334CONFIG_IOSCHED_DEADLINE=y
335CONFIG_IOSCHED_CFQ=y
336CONFIG_ATA_OVER_ETH=m
337
338#
339# ATA/ATAPI/MFM/RLL support
340#
341# CONFIG_IDE is not set
342
343#
344# SCSI device support
345#
346# CONFIG_RAID_ATTRS is not set
347CONFIG_SCSI=y
348CONFIG_SCSI_PROC_FS=y
349
350#
351# SCSI support type (disk, tape, CD-ROM)
352#
353CONFIG_BLK_DEV_SD=y
354CONFIG_CHR_DEV_ST=y
355# CONFIG_CHR_DEV_OSST is not set
356CONFIG_BLK_DEV_SR=y
357# CONFIG_BLK_DEV_SR_VENDOR is not set
358CONFIG_CHR_DEV_SG=y
359# CONFIG_CHR_DEV_SCH is not set
360
361#
362# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
363#
364# CONFIG_SCSI_MULTI_LUN is not set
365# CONFIG_SCSI_CONSTANTS is not set
366# CONFIG_SCSI_LOGGING is not set
367
368#
369# SCSI Transport Attributes
370#
371CONFIG_SCSI_SPI_ATTRS=y
372# CONFIG_SCSI_FC_ATTRS is not set
373CONFIG_SCSI_ISCSI_ATTRS=m
374# CONFIG_SCSI_SAS_ATTRS is not set
375
376#
377# SCSI low-level drivers
378#
379# CONFIG_SCSI_SATA is not set
380# CONFIG_SCSI_PPA is not set
381# CONFIG_SCSI_IMM is not set
382CONFIG_SCSI_LASI700=y
383CONFIG_53C700_LE_ON_BE=y
384# CONFIG_SCSI_ZALON is not set
385CONFIG_SCSI_DEBUG=m
386
387#
388# Multi-device support (RAID and LVM)
389#
390CONFIG_MD=y
391CONFIG_BLK_DEV_MD=m
392CONFIG_MD_LINEAR=m
393CONFIG_MD_RAID0=m
394CONFIG_MD_RAID1=m
395# CONFIG_MD_RAID10 is not set
396# CONFIG_MD_RAID5 is not set
397# CONFIG_MD_RAID6 is not set
398# CONFIG_MD_MULTIPATH is not set
399# CONFIG_MD_FAULTY is not set
400# CONFIG_BLK_DEV_DM is not set
401
402#
403# Fusion MPT device support
404#
405# CONFIG_FUSION is not set
406
407#
408# IEEE 1394 (FireWire) support
409#
410# CONFIG_IEEE1394 is not set
411
412#
413# I2O device support
414#
415
416#
417# Network device support
418#
381CONFIG_NETDEVICES=y 419CONFIG_NETDEVICES=y
382CONFIG_DUMMY=m 420CONFIG_DUMMY=m
383CONFIG_BONDING=m 421CONFIG_BONDING=m
384# CONFIG_EQUALIZER is not set 422# CONFIG_EQUALIZER is not set
385CONFIG_TUN=m 423CONFIG_TUN=m
386# CONFIG_ETHERTAP is not set 424
425#
426# PHY device support
427#
428# CONFIG_PHYLIB is not set
387 429
388# 430#
389# Ethernet (10 or 100Mbit) 431# Ethernet (10 or 100Mbit)
@@ -391,6 +433,7 @@ CONFIG_TUN=m
391CONFIG_NET_ETHERNET=y 433CONFIG_NET_ETHERNET=y
392CONFIG_MII=m 434CONFIG_MII=m
393CONFIG_LASI_82596=y 435CONFIG_LASI_82596=y
436# CONFIG_NET_POCKET is not set
394 437
395# 438#
396# Ethernet (1000 Mbit) 439# Ethernet (1000 Mbit)
@@ -414,6 +457,7 @@ CONFIG_NET_RADIO=y
414# 457#
415# CONFIG_STRIP is not set 458# CONFIG_STRIP is not set
416# CONFIG_ATMEL is not set 459# CONFIG_ATMEL is not set
460# CONFIG_HOSTAP is not set
417 461
418# 462#
419# Wan interfaces 463# Wan interfaces
@@ -431,6 +475,8 @@ CONFIG_PPPOE=m
431# CONFIG_SLIP is not set 475# CONFIG_SLIP is not set
432# CONFIG_SHAPER is not set 476# CONFIG_SHAPER is not set
433# CONFIG_NETCONSOLE is not set 477# CONFIG_NETCONSOLE is not set
478# CONFIG_NETPOLL is not set
479# CONFIG_NET_POLL_CONTROLLER is not set
434 480
435# 481#
436# ISDN subsystem 482# ISDN subsystem
@@ -460,19 +506,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
460# CONFIG_INPUT_EVBUG is not set 506# CONFIG_INPUT_EVBUG is not set
461 507
462# 508#
463# Input I/O drivers
464#
465# CONFIG_GAMEPORT is not set
466CONFIG_SOUND_GAMEPORT=y
467CONFIG_SERIO=y
468CONFIG_SERIO_SERPORT=y
469# CONFIG_SERIO_PARKBD is not set
470CONFIG_SERIO_GSCPS2=y
471CONFIG_HP_SDC=y
472CONFIG_HIL_MLC=y
473# CONFIG_SERIO_RAW is not set
474
475#
476# Input Device Drivers 509# Input Device Drivers
477# 510#
478CONFIG_INPUT_KEYBOARD=y 511CONFIG_INPUT_KEYBOARD=y
@@ -483,6 +516,7 @@ CONFIG_KEYBOARD_ATKBD_HP_KEYCODES=y
483# CONFIG_KEYBOARD_LKKBD is not set 516# CONFIG_KEYBOARD_LKKBD is not set
484# CONFIG_KEYBOARD_XTKBD is not set 517# CONFIG_KEYBOARD_XTKBD is not set
485# CONFIG_KEYBOARD_NEWTON is not set 518# CONFIG_KEYBOARD_NEWTON is not set
519CONFIG_KEYBOARD_HIL_OLD=y
486# CONFIG_KEYBOARD_HIL is not set 520# CONFIG_KEYBOARD_HIL is not set
487CONFIG_INPUT_MOUSE=y 521CONFIG_INPUT_MOUSE=y
488CONFIG_MOUSE_PS2=y 522CONFIG_MOUSE_PS2=y
@@ -494,6 +528,19 @@ CONFIG_MOUSE_HIL=m
494# CONFIG_INPUT_MISC is not set 528# CONFIG_INPUT_MISC is not set
495 529
496# 530#
531# Hardware I/O ports
532#
533CONFIG_SERIO=y
534CONFIG_SERIO_SERPORT=y
535# CONFIG_SERIO_PARKBD is not set
536CONFIG_SERIO_GSCPS2=y
537CONFIG_HP_SDC=y
538CONFIG_HIL_MLC=y
539CONFIG_SERIO_LIBPS2=y
540# CONFIG_SERIO_RAW is not set
541# CONFIG_GAMEPORT is not set
542
543#
497# Character devices 544# Character devices
498# 545#
499CONFIG_VT=y 546CONFIG_VT=y
@@ -511,7 +558,6 @@ CONFIG_SERIAL_8250_EXTENDED=y
511CONFIG_SERIAL_8250_MANY_PORTS=y 558CONFIG_SERIAL_8250_MANY_PORTS=y
512CONFIG_SERIAL_8250_SHARE_IRQ=y 559CONFIG_SERIAL_8250_SHARE_IRQ=y
513# CONFIG_SERIAL_8250_DETECT_IRQ is not set 560# CONFIG_SERIAL_8250_DETECT_IRQ is not set
514# CONFIG_SERIAL_8250_MULTIPORT is not set
515# CONFIG_SERIAL_8250_RSA is not set 561# CONFIG_SERIAL_8250_RSA is not set
516 562
517# 563#
@@ -546,12 +592,14 @@ CONFIG_GEN_RTC_X=y
546# 592#
547# Ftape, the floppy tape device driver 593# Ftape, the floppy tape device driver
548# 594#
549# CONFIG_AGP is not set
550# CONFIG_DRM is not set
551CONFIG_RAW_DRIVER=y 595CONFIG_RAW_DRIVER=y
552CONFIG_MAX_RAW_DEVS=256 596CONFIG_MAX_RAW_DEVS=256
553 597
554# 598#
599# TPM devices
600#
601
602#
555# I2C support 603# I2C support
556# 604#
557# CONFIG_I2C is not set 605# CONFIG_I2C is not set
@@ -562,10 +610,20 @@ CONFIG_MAX_RAW_DEVS=256
562# CONFIG_W1 is not set 610# CONFIG_W1 is not set
563 611
564# 612#
613# Hardware Monitoring support
614#
615# CONFIG_HWMON is not set
616# CONFIG_HWMON_VID is not set
617
618#
565# Misc devices 619# Misc devices
566# 620#
567 621
568# 622#
623# Multimedia Capabilities Port drivers
624#
625
626#
569# Multimedia devices 627# Multimedia devices
570# 628#
571# CONFIG_VIDEO_DEV is not set 629# CONFIG_VIDEO_DEV is not set
@@ -579,28 +637,36 @@ CONFIG_MAX_RAW_DEVS=256
579# Graphics support 637# Graphics support
580# 638#
581CONFIG_FB=y 639CONFIG_FB=y
640CONFIG_FB_CFB_FILLRECT=y
641CONFIG_FB_CFB_COPYAREA=y
642CONFIG_FB_CFB_IMAGEBLIT=y
643CONFIG_FB_SOFT_CURSOR=y
644# CONFIG_FB_MACMODES is not set
582CONFIG_FB_MODE_HELPERS=y 645CONFIG_FB_MODE_HELPERS=y
583CONFIG_FB_TILEBLITTING=y 646CONFIG_FB_TILEBLITTING=y
584CONFIG_FB_STI=y 647CONFIG_FB_STI=y
648# CONFIG_FB_S1D13XXX is not set
585# CONFIG_FB_VIRTUAL is not set 649# CONFIG_FB_VIRTUAL is not set
586 650
587# 651#
588# Console display driver support 652# Console display driver support
589# 653#
590CONFIG_STI_CONSOLE=y 654CONFIG_DUMMY_CONSOLE=y
591CONFIG_DUMMY_CONSOLE_COLUMNS=128 655CONFIG_DUMMY_CONSOLE_COLUMNS=128
592CONFIG_DUMMY_CONSOLE_ROWS=48 656CONFIG_DUMMY_CONSOLE_ROWS=48
593CONFIG_DUMMY_CONSOLE=y
594CONFIG_FRAMEBUFFER_CONSOLE=y 657CONFIG_FRAMEBUFFER_CONSOLE=y
658CONFIG_STI_CONSOLE=y
595CONFIG_FONTS=y 659CONFIG_FONTS=y
596CONFIG_FONT_8x8=y 660CONFIG_FONT_8x8=y
597CONFIG_FONT_8x16=y 661CONFIG_FONT_8x16=y
598# CONFIG_FONT_6x11 is not set 662# CONFIG_FONT_6x11 is not set
663# CONFIG_FONT_7x14 is not set
599# CONFIG_FONT_PEARL_8x8 is not set 664# CONFIG_FONT_PEARL_8x8 is not set
600# CONFIG_FONT_ACORN_8x8 is not set 665# CONFIG_FONT_ACORN_8x8 is not set
601# CONFIG_FONT_MINI_4x6 is not set 666# CONFIG_FONT_MINI_4x6 is not set
602# CONFIG_FONT_SUN8x16 is not set 667# CONFIG_FONT_SUN8x16 is not set
603# CONFIG_FONT_SUN12x22 is not set 668# CONFIG_FONT_SUN12x22 is not set
669# CONFIG_FONT_10x18 is not set
604 670
605# 671#
606# Logo configuration 672# Logo configuration
@@ -610,6 +676,7 @@ CONFIG_LOGO=y
610# CONFIG_LOGO_LINUX_VGA16 is not set 676# CONFIG_LOGO_LINUX_VGA16 is not set
611# CONFIG_LOGO_LINUX_CLUT224 is not set 677# CONFIG_LOGO_LINUX_CLUT224 is not set
612CONFIG_LOGO_PARISC_CLUT224=y 678CONFIG_LOGO_PARISC_CLUT224=y
679# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
613 680
614# 681#
615# Sound 682# Sound
@@ -657,10 +724,6 @@ CONFIG_SND_HARMONY=y
657# CONFIG_USB_ARCH_HAS_OHCI is not set 724# CONFIG_USB_ARCH_HAS_OHCI is not set
658 725
659# 726#
660# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
661#
662
663#
664# USB Gadget Support 727# USB Gadget Support
665# 728#
666# CONFIG_USB_GADGET is not set 729# CONFIG_USB_GADGET is not set
@@ -671,10 +734,20 @@ CONFIG_SND_HARMONY=y
671# CONFIG_MMC is not set 734# CONFIG_MMC is not set
672 735
673# 736#
737# InfiniBand support
738#
739# CONFIG_INFINIBAND is not set
740
741#
742# SN Devices
743#
744
745#
674# File systems 746# File systems
675# 747#
676CONFIG_EXT2_FS=y 748CONFIG_EXT2_FS=y
677# CONFIG_EXT2_FS_XATTR is not set 749# CONFIG_EXT2_FS_XATTR is not set
750# CONFIG_EXT2_FS_XIP is not set
678CONFIG_EXT3_FS=y 751CONFIG_EXT3_FS=y
679# CONFIG_EXT3_FS_XATTR is not set 752# CONFIG_EXT3_FS_XATTR is not set
680CONFIG_JBD=y 753CONFIG_JBD=y
@@ -682,20 +755,24 @@ CONFIG_JBD=y
682# CONFIG_REISERFS_FS is not set 755# CONFIG_REISERFS_FS is not set
683CONFIG_JFS_FS=m 756CONFIG_JFS_FS=m
684# CONFIG_JFS_POSIX_ACL is not set 757# CONFIG_JFS_POSIX_ACL is not set
758# CONFIG_JFS_SECURITY is not set
685# CONFIG_JFS_DEBUG is not set 759# CONFIG_JFS_DEBUG is not set
686# CONFIG_JFS_STATISTICS is not set 760# CONFIG_JFS_STATISTICS is not set
687CONFIG_FS_POSIX_ACL=y 761CONFIG_FS_POSIX_ACL=y
688CONFIG_XFS_FS=m 762CONFIG_XFS_FS=m
689# CONFIG_XFS_RT is not set 763CONFIG_XFS_EXPORT=y
690# CONFIG_XFS_QUOTA is not set 764# CONFIG_XFS_QUOTA is not set
691# CONFIG_XFS_SECURITY is not set 765# CONFIG_XFS_SECURITY is not set
692# CONFIG_XFS_POSIX_ACL is not set 766# CONFIG_XFS_POSIX_ACL is not set
767# CONFIG_XFS_RT is not set
693# CONFIG_MINIX_FS is not set 768# CONFIG_MINIX_FS is not set
694# CONFIG_ROMFS_FS is not set 769# CONFIG_ROMFS_FS is not set
770CONFIG_INOTIFY=y
695# CONFIG_QUOTA is not set 771# CONFIG_QUOTA is not set
696CONFIG_DNOTIFY=y 772CONFIG_DNOTIFY=y
697# CONFIG_AUTOFS_FS is not set 773# CONFIG_AUTOFS_FS is not set
698CONFIG_AUTOFS4_FS=y 774CONFIG_AUTOFS4_FS=y
775# CONFIG_FUSE_FS is not set
699 776
700# 777#
701# CD-ROM/DVD Filesystems 778# CD-ROM/DVD Filesystems
@@ -722,14 +799,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
722CONFIG_PROC_FS=y 799CONFIG_PROC_FS=y
723CONFIG_PROC_KCORE=y 800CONFIG_PROC_KCORE=y
724CONFIG_SYSFS=y 801CONFIG_SYSFS=y
725# CONFIG_DEVFS_FS is not set
726# CONFIG_DEVPTS_FS_XATTR is not set
727CONFIG_TMPFS=y 802CONFIG_TMPFS=y
728CONFIG_TMPFS_XATTR=y
729# CONFIG_TMPFS_SECURITY is not set
730# CONFIG_HUGETLBFS is not set 803# CONFIG_HUGETLBFS is not set
731# CONFIG_HUGETLB_PAGE is not set 804# CONFIG_HUGETLB_PAGE is not set
732CONFIG_RAMFS=y 805CONFIG_RAMFS=y
806# CONFIG_RELAYFS_FS is not set
733 807
734# 808#
735# Miscellaneous filesystems 809# Miscellaneous filesystems
@@ -754,16 +828,19 @@ CONFIG_UFS_FS=m
754# 828#
755CONFIG_NFS_FS=y 829CONFIG_NFS_FS=y
756CONFIG_NFS_V3=y 830CONFIG_NFS_V3=y
831# CONFIG_NFS_V3_ACL is not set
757CONFIG_NFS_V4=y 832CONFIG_NFS_V4=y
758CONFIG_NFS_DIRECTIO=y 833CONFIG_NFS_DIRECTIO=y
759CONFIG_NFSD=m 834CONFIG_NFSD=m
760CONFIG_NFSD_V3=y 835CONFIG_NFSD_V3=y
836# CONFIG_NFSD_V3_ACL is not set
761CONFIG_NFSD_V4=y 837CONFIG_NFSD_V4=y
762CONFIG_NFSD_TCP=y 838CONFIG_NFSD_TCP=y
763CONFIG_ROOT_NFS=y 839CONFIG_ROOT_NFS=y
764CONFIG_LOCKD=y 840CONFIG_LOCKD=y
765CONFIG_LOCKD_V4=y 841CONFIG_LOCKD_V4=y
766CONFIG_EXPORTFS=m 842CONFIG_EXPORTFS=m
843CONFIG_NFS_COMMON=y
767CONFIG_SUNRPC=y 844CONFIG_SUNRPC=y
768CONFIG_SUNRPC_GSS=y 845CONFIG_SUNRPC_GSS=y
769CONFIG_RPCSEC_GSS_KRB5=y 846CONFIG_RPCSEC_GSS_KRB5=y
@@ -778,6 +855,7 @@ CONFIG_CIFS=m
778# CONFIG_NCP_FS is not set 855# CONFIG_NCP_FS is not set
779# CONFIG_CODA_FS is not set 856# CONFIG_CODA_FS is not set
780# CONFIG_AFS_FS is not set 857# CONFIG_AFS_FS is not set
858# CONFIG_9P_FS is not set
781 859
782# 860#
783# Partition Types 861# Partition Types
@@ -838,13 +916,19 @@ CONFIG_OPROFILE=m
838# 916#
839# Kernel hacking 917# Kernel hacking
840# 918#
919# CONFIG_PRINTK_TIME is not set
841CONFIG_DEBUG_KERNEL=y 920CONFIG_DEBUG_KERNEL=y
842CONFIG_MAGIC_SYSRQ=y 921CONFIG_MAGIC_SYSRQ=y
922CONFIG_LOG_BUF_SHIFT=16
923CONFIG_DETECT_SOFTLOCKUP=y
843# CONFIG_SCHEDSTATS is not set 924# CONFIG_SCHEDSTATS is not set
844# CONFIG_DEBUG_SLAB is not set 925# CONFIG_DEBUG_SLAB is not set
845# CONFIG_DEBUG_SPINLOCK is not set 926# CONFIG_DEBUG_SPINLOCK is not set
927# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
846# CONFIG_DEBUG_KOBJECT is not set 928# CONFIG_DEBUG_KOBJECT is not set
847# CONFIG_DEBUG_INFO is not set 929# CONFIG_DEBUG_INFO is not set
930# CONFIG_DEBUG_IOREMAP is not set
931# CONFIG_DEBUG_FS is not set
848 932
849# 933#
850# Security options 934# Security options
@@ -865,6 +949,7 @@ CONFIG_CRYPTO_SHA1=m
865CONFIG_CRYPTO_SHA256=m 949CONFIG_CRYPTO_SHA256=m
866CONFIG_CRYPTO_SHA512=m 950CONFIG_CRYPTO_SHA512=m
867CONFIG_CRYPTO_WP512=m 951CONFIG_CRYPTO_WP512=m
952CONFIG_CRYPTO_TGR192=m
868CONFIG_CRYPTO_DES=y 953CONFIG_CRYPTO_DES=y
869CONFIG_CRYPTO_BLOWFISH=m 954CONFIG_CRYPTO_BLOWFISH=m
870CONFIG_CRYPTO_TWOFISH=m 955CONFIG_CRYPTO_TWOFISH=m
@@ -882,9 +967,14 @@ CONFIG_CRYPTO_CRC32C=m
882CONFIG_CRYPTO_TEST=m 967CONFIG_CRYPTO_TEST=m
883 968
884# 969#
970# Hardware crypto devices
971#
972
973#
885# Library routines 974# Library routines
886# 975#
887CONFIG_CRC_CCITT=m 976CONFIG_CRC_CCITT=m
977# CONFIG_CRC16 is not set
888CONFIG_CRC32=y 978CONFIG_CRC32=y
889CONFIG_LIBCRC32C=m 979CONFIG_LIBCRC32C=m
890CONFIG_ZLIB_INFLATE=m 980CONFIG_ZLIB_INFLATE=m
diff --git a/arch/parisc/configs/a500_defconfig b/arch/parisc/configs/a500_defconfig
index 30fc03ed0cfb..955ef5084f3e 100644
--- a/arch/parisc/configs/a500_defconfig
+++ b/arch/parisc/configs/a500_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.11-rc4-pa1 3# Linux kernel version: 2.6.14-rc5-pa1
4# Wed Feb 16 11:32:49 2005 4# Fri Oct 21 23:04:54 2005
5# 5#
6CONFIG_PARISC=y 6CONFIG_PARISC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -10,6 +10,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y 10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_HARDIRQS=y 11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_GENERIC_IRQ_PROBE=y 12CONFIG_GENERIC_IRQ_PROBE=y
13CONFIG_ARCH_MAY_HAVE_PC_FDC=y
13 14
14# 15#
15# Code maturity level options 16# Code maturity level options
@@ -19,26 +20,32 @@ CONFIG_EXPERIMENTAL=y
19CONFIG_BROKEN=y 20CONFIG_BROKEN=y
20CONFIG_BROKEN_ON_SMP=y 21CONFIG_BROKEN_ON_SMP=y
21CONFIG_LOCK_KERNEL=y 22CONFIG_LOCK_KERNEL=y
23CONFIG_INIT_ENV_ARG_LIMIT=32
22 24
23# 25#
24# General setup 26# General setup
25# 27#
26CONFIG_LOCALVERSION="" 28CONFIG_LOCALVERSION=""
29# CONFIG_LOCALVERSION_AUTO is not set
27CONFIG_SWAP=y 30CONFIG_SWAP=y
28CONFIG_SYSVIPC=y 31CONFIG_SYSVIPC=y
29CONFIG_POSIX_MQUEUE=y 32CONFIG_POSIX_MQUEUE=y
30# CONFIG_BSD_PROCESS_ACCT is not set 33# CONFIG_BSD_PROCESS_ACCT is not set
31CONFIG_SYSCTL=y 34CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set 35# CONFIG_AUDIT is not set
33CONFIG_LOG_BUF_SHIFT=16
34CONFIG_HOTPLUG=y 36CONFIG_HOTPLUG=y
35CONFIG_KOBJECT_UEVENT=y 37CONFIG_KOBJECT_UEVENT=y
36CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
37CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
40# CONFIG_CPUSETS is not set
41CONFIG_INITRAMFS_SOURCE=""
38CONFIG_EMBEDDED=y 42CONFIG_EMBEDDED=y
39CONFIG_KALLSYMS=y 43CONFIG_KALLSYMS=y
40CONFIG_KALLSYMS_ALL=y 44CONFIG_KALLSYMS_ALL=y
41# CONFIG_KALLSYMS_EXTRA_PASS is not set 45# CONFIG_KALLSYMS_EXTRA_PASS is not set
46CONFIG_PRINTK=y
47CONFIG_BUG=y
48CONFIG_BASE_FULL=y
42CONFIG_FUTEX=y 49CONFIG_FUTEX=y
43CONFIG_EPOLL=y 50CONFIG_EPOLL=y
44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 51# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -48,6 +55,7 @@ CONFIG_CC_ALIGN_LABELS=0
48CONFIG_CC_ALIGN_LOOPS=0 55CONFIG_CC_ALIGN_LOOPS=0
49CONFIG_CC_ALIGN_JUMPS=0 56CONFIG_CC_ALIGN_JUMPS=0
50# CONFIG_TINY_SHMEM is not set 57# CONFIG_TINY_SHMEM is not set
58CONFIG_BASE_SMALL=0
51 59
52# 60#
53# Loadable module support 61# Loadable module support
@@ -74,7 +82,19 @@ CONFIG_PREFETCH=y
74CONFIG_64BIT=y 82CONFIG_64BIT=y
75CONFIG_SMP=y 83CONFIG_SMP=y
76CONFIG_HOTPLUG_CPU=y 84CONFIG_HOTPLUG_CPU=y
85CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
86# CONFIG_HZ_100 is not set
87CONFIG_HZ_250=y
88# CONFIG_HZ_1000 is not set
89CONFIG_HZ=250
90CONFIG_SELECT_MEMORY_MODEL=y
91# CONFIG_FLATMEM_MANUAL is not set
92CONFIG_DISCONTIGMEM_MANUAL=y
93# CONFIG_SPARSEMEM_MANUAL is not set
77CONFIG_DISCONTIGMEM=y 94CONFIG_DISCONTIGMEM=y
95CONFIG_FLAT_NODE_MEM_MAP=y
96CONFIG_NEED_MULTIPLE_NODES=y
97# CONFIG_SPARSEMEM_STATIC is not set
78# CONFIG_PREEMPT is not set 98# CONFIG_PREEMPT is not set
79CONFIG_COMPAT=y 99CONFIG_COMPAT=y
80CONFIG_NR_CPUS=8 100CONFIG_NR_CPUS=8
@@ -85,7 +105,7 @@ CONFIG_NR_CPUS=8
85# CONFIG_GSC is not set 105# CONFIG_GSC is not set
86CONFIG_PCI=y 106CONFIG_PCI=y
87CONFIG_PCI_LEGACY_PROC=y 107CONFIG_PCI_LEGACY_PROC=y
88CONFIG_PCI_NAMES=y 108# CONFIG_PCI_DEBUG is not set
89CONFIG_PCI_LBA=y 109CONFIG_PCI_LBA=y
90CONFIG_IOSAPIC=y 110CONFIG_IOSAPIC=y
91CONFIG_IOMMU_SBA=y 111CONFIG_IOMMU_SBA=y
@@ -96,6 +116,8 @@ CONFIG_IOMMU_SBA=y
96CONFIG_PCCARD=m 116CONFIG_PCCARD=m
97# CONFIG_PCMCIA_DEBUG is not set 117# CONFIG_PCMCIA_DEBUG is not set
98CONFIG_PCMCIA=m 118CONFIG_PCMCIA=m
119# CONFIG_PCMCIA_LOAD_CIS is not set
120CONFIG_PCMCIA_IOCTL=y
99CONFIG_CARDBUS=y 121CONFIG_CARDBUS=y
100 122
101# 123#
@@ -104,7 +126,6 @@ CONFIG_CARDBUS=y
104CONFIG_YENTA=m 126CONFIG_YENTA=m
105CONFIG_PD6729=m 127CONFIG_PD6729=m
106CONFIG_I82092=m 128CONFIG_I82092=m
107CONFIG_TCIC=m
108CONFIG_PCCARD_NONSTATIC=m 129CONFIG_PCCARD_NONSTATIC=m
109 130
110# 131#
@@ -127,6 +148,203 @@ CONFIG_BINFMT_ELF=y
127# CONFIG_BINFMT_MISC is not set 148# CONFIG_BINFMT_MISC is not set
128 149
129# 150#
151# Networking
152#
153CONFIG_NET=y
154
155#
156# Networking options
157#
158CONFIG_PACKET=y
159CONFIG_PACKET_MMAP=y
160CONFIG_UNIX=y
161CONFIG_XFRM=y
162CONFIG_XFRM_USER=m
163CONFIG_NET_KEY=m
164CONFIG_INET=y
165CONFIG_IP_MULTICAST=y
166# CONFIG_IP_ADVANCED_ROUTER is not set
167CONFIG_IP_FIB_HASH=y
168CONFIG_IP_PNP=y
169CONFIG_IP_PNP_DHCP=y
170CONFIG_IP_PNP_BOOTP=y
171# CONFIG_IP_PNP_RARP is not set
172# CONFIG_NET_IPIP is not set
173# CONFIG_NET_IPGRE is not set
174# CONFIG_IP_MROUTE is not set
175# CONFIG_ARPD is not set
176# CONFIG_SYN_COOKIES is not set
177CONFIG_INET_AH=m
178CONFIG_INET_ESP=m
179# CONFIG_INET_IPCOMP is not set
180CONFIG_INET_TUNNEL=m
181CONFIG_INET_DIAG=y
182CONFIG_INET_TCP_DIAG=y
183# CONFIG_TCP_CONG_ADVANCED is not set
184CONFIG_TCP_CONG_BIC=y
185
186#
187# IP: Virtual Server Configuration
188#
189# CONFIG_IP_VS is not set
190CONFIG_IPV6=m
191# CONFIG_IPV6_PRIVACY is not set
192CONFIG_INET6_AH=m
193CONFIG_INET6_ESP=m
194CONFIG_INET6_IPCOMP=m
195CONFIG_INET6_TUNNEL=m
196CONFIG_IPV6_TUNNEL=m
197CONFIG_NETFILTER=y
198# CONFIG_NETFILTER_DEBUG is not set
199# CONFIG_NETFILTER_NETLINK is not set
200
201#
202# IP: Netfilter Configuration
203#
204CONFIG_IP_NF_CONNTRACK=m
205# CONFIG_IP_NF_CT_ACCT is not set
206CONFIG_IP_NF_CONNTRACK_MARK=y
207# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
208CONFIG_IP_NF_CT_PROTO_SCTP=m
209CONFIG_IP_NF_FTP=m
210CONFIG_IP_NF_IRC=m
211# CONFIG_IP_NF_NETBIOS_NS is not set
212CONFIG_IP_NF_TFTP=m
213CONFIG_IP_NF_AMANDA=m
214# CONFIG_IP_NF_PPTP is not set
215CONFIG_IP_NF_QUEUE=m
216CONFIG_IP_NF_IPTABLES=m
217CONFIG_IP_NF_MATCH_LIMIT=m
218CONFIG_IP_NF_MATCH_IPRANGE=m
219CONFIG_IP_NF_MATCH_MAC=m
220CONFIG_IP_NF_MATCH_PKTTYPE=m
221CONFIG_IP_NF_MATCH_MARK=m
222CONFIG_IP_NF_MATCH_MULTIPORT=m
223CONFIG_IP_NF_MATCH_TOS=m
224CONFIG_IP_NF_MATCH_RECENT=m
225CONFIG_IP_NF_MATCH_ECN=m
226CONFIG_IP_NF_MATCH_DSCP=m
227CONFIG_IP_NF_MATCH_AH_ESP=m
228CONFIG_IP_NF_MATCH_LENGTH=m
229CONFIG_IP_NF_MATCH_TTL=m
230CONFIG_IP_NF_MATCH_TCPMSS=m
231CONFIG_IP_NF_MATCH_HELPER=m
232CONFIG_IP_NF_MATCH_STATE=m
233CONFIG_IP_NF_MATCH_CONNTRACK=m
234CONFIG_IP_NF_MATCH_OWNER=m
235# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
236# CONFIG_IP_NF_MATCH_REALM is not set
237CONFIG_IP_NF_MATCH_SCTP=m
238# CONFIG_IP_NF_MATCH_DCCP is not set
239CONFIG_IP_NF_MATCH_COMMENT=m
240CONFIG_IP_NF_MATCH_CONNMARK=m
241CONFIG_IP_NF_MATCH_HASHLIMIT=m
242# CONFIG_IP_NF_MATCH_STRING is not set
243CONFIG_IP_NF_FILTER=m
244CONFIG_IP_NF_TARGET_REJECT=m
245CONFIG_IP_NF_TARGET_LOG=m
246CONFIG_IP_NF_TARGET_ULOG=m
247CONFIG_IP_NF_TARGET_TCPMSS=m
248# CONFIG_IP_NF_TARGET_NFQUEUE is not set
249CONFIG_IP_NF_NAT=m
250CONFIG_IP_NF_NAT_NEEDED=y
251CONFIG_IP_NF_TARGET_MASQUERADE=m
252CONFIG_IP_NF_TARGET_REDIRECT=m
253CONFIG_IP_NF_TARGET_NETMAP=m
254CONFIG_IP_NF_TARGET_SAME=m
255CONFIG_IP_NF_NAT_SNMP_BASIC=m
256CONFIG_IP_NF_NAT_IRC=m
257CONFIG_IP_NF_NAT_FTP=m
258CONFIG_IP_NF_NAT_TFTP=m
259CONFIG_IP_NF_NAT_AMANDA=m
260CONFIG_IP_NF_MANGLE=m
261CONFIG_IP_NF_TARGET_TOS=m
262CONFIG_IP_NF_TARGET_ECN=m
263CONFIG_IP_NF_TARGET_DSCP=m
264CONFIG_IP_NF_TARGET_MARK=m
265CONFIG_IP_NF_TARGET_CLASSIFY=m
266# CONFIG_IP_NF_TARGET_TTL is not set
267CONFIG_IP_NF_TARGET_CONNMARK=m
268CONFIG_IP_NF_TARGET_CLUSTERIP=m
269CONFIG_IP_NF_RAW=m
270CONFIG_IP_NF_TARGET_NOTRACK=m
271CONFIG_IP_NF_ARPTABLES=m
272CONFIG_IP_NF_ARPFILTER=m
273CONFIG_IP_NF_ARP_MANGLE=m
274
275#
276# IPv6: Netfilter Configuration (EXPERIMENTAL)
277#
278# CONFIG_IP6_NF_QUEUE is not set
279CONFIG_IP6_NF_IPTABLES=m
280# CONFIG_IP6_NF_MATCH_LIMIT is not set
281CONFIG_IP6_NF_MATCH_MAC=m
282CONFIG_IP6_NF_MATCH_RT=m
283CONFIG_IP6_NF_MATCH_OPTS=m
284CONFIG_IP6_NF_MATCH_FRAG=m
285CONFIG_IP6_NF_MATCH_HL=m
286# CONFIG_IP6_NF_MATCH_MULTIPORT is not set
287# CONFIG_IP6_NF_MATCH_OWNER is not set
288# CONFIG_IP6_NF_MATCH_MARK is not set
289CONFIG_IP6_NF_MATCH_IPV6HEADER=m
290# CONFIG_IP6_NF_MATCH_AHESP is not set
291# CONFIG_IP6_NF_MATCH_LENGTH is not set
292# CONFIG_IP6_NF_MATCH_EUI64 is not set
293CONFIG_IP6_NF_FILTER=m
294CONFIG_IP6_NF_TARGET_LOG=m
295CONFIG_IP6_NF_TARGET_REJECT=m
296# CONFIG_IP6_NF_TARGET_NFQUEUE is not set
297CONFIG_IP6_NF_MANGLE=m
298# CONFIG_IP6_NF_TARGET_MARK is not set
299# CONFIG_IP6_NF_TARGET_HL is not set
300CONFIG_IP6_NF_RAW=m
301
302#
303# DCCP Configuration (EXPERIMENTAL)
304#
305CONFIG_IP_DCCP=m
306CONFIG_INET_DCCP_DIAG=m
307
308#
309# DCCP CCIDs Configuration (EXPERIMENTAL)
310#
311# CONFIG_IP_DCCP_CCID3 is not set
312
313#
314# DCCP Kernel Hacking
315#
316# CONFIG_IP_DCCP_DEBUG is not set
317
318#
319# SCTP Configuration (EXPERIMENTAL)
320#
321# CONFIG_IP_SCTP is not set
322# CONFIG_ATM is not set
323# CONFIG_BRIDGE is not set
324# CONFIG_VLAN_8021Q is not set
325# CONFIG_DECNET is not set
326CONFIG_LLC=m
327CONFIG_LLC2=m
328# CONFIG_IPX is not set
329# CONFIG_ATALK is not set
330# CONFIG_X25 is not set
331# CONFIG_LAPB is not set
332# CONFIG_NET_DIVERT is not set
333# CONFIG_ECONET is not set
334# CONFIG_WAN_ROUTER is not set
335# CONFIG_NET_SCHED is not set
336# CONFIG_NET_CLS_ROUTE is not set
337
338#
339# Network testing
340#
341CONFIG_NET_PKTGEN=m
342# CONFIG_HAMRADIO is not set
343# CONFIG_IRDA is not set
344# CONFIG_BT is not set
345# CONFIG_IEEE80211 is not set
346
347#
130# Device Drivers 348# Device Drivers
131# 349#
132 350
@@ -139,6 +357,11 @@ CONFIG_FW_LOADER=y
139# CONFIG_DEBUG_DRIVER is not set 357# CONFIG_DEBUG_DRIVER is not set
140 358
141# 359#
360# Connector - unified userspace <-> kernelspace linker
361#
362# CONFIG_CONNECTOR is not set
363
364#
142# Memory Technology Devices (MTD) 365# Memory Technology Devices (MTD)
143# 366#
144# CONFIG_MTD is not set 367# CONFIG_MTD is not set
@@ -169,7 +392,6 @@ CONFIG_BLK_DEV_RAM=y
169CONFIG_BLK_DEV_RAM_COUNT=16 392CONFIG_BLK_DEV_RAM_COUNT=16
170CONFIG_BLK_DEV_RAM_SIZE=6144 393CONFIG_BLK_DEV_RAM_SIZE=6144
171CONFIG_BLK_DEV_INITRD=y 394CONFIG_BLK_DEV_INITRD=y
172CONFIG_INITRAMFS_SOURCE=""
173# CONFIG_CDROM_PKTCDVD is not set 395# CONFIG_CDROM_PKTCDVD is not set
174 396
175# 397#
@@ -189,6 +411,7 @@ CONFIG_IOSCHED_CFQ=y
189# 411#
190# SCSI device support 412# SCSI device support
191# 413#
414CONFIG_RAID_ATTRS=m
192CONFIG_SCSI=y 415CONFIG_SCSI=y
193CONFIG_SCSI_PROC_FS=y 416CONFIG_SCSI_PROC_FS=y
194 417
@@ -201,6 +424,7 @@ CONFIG_CHR_DEV_ST=y
201CONFIG_BLK_DEV_SR=y 424CONFIG_BLK_DEV_SR=y
202# CONFIG_BLK_DEV_SR_VENDOR is not set 425# CONFIG_BLK_DEV_SR_VENDOR is not set
203CONFIG_CHR_DEV_SG=y 426CONFIG_CHR_DEV_SG=y
427# CONFIG_CHR_DEV_SCH is not set
204 428
205# 429#
206# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 430# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -215,6 +439,7 @@ CONFIG_SCSI_MULTI_LUN=y
215CONFIG_SCSI_SPI_ATTRS=y 439CONFIG_SCSI_SPI_ATTRS=y
216CONFIG_SCSI_FC_ATTRS=m 440CONFIG_SCSI_FC_ATTRS=m
217CONFIG_SCSI_ISCSI_ATTRS=m 441CONFIG_SCSI_ISCSI_ATTRS=m
442CONFIG_SCSI_SAS_ATTRS=m
218 443
219# 444#
220# SCSI low-level drivers 445# SCSI low-level drivers
@@ -229,14 +454,12 @@ CONFIG_SCSI_ISCSI_ATTRS=m
229# CONFIG_SCSI_ADVANSYS is not set 454# CONFIG_SCSI_ADVANSYS is not set
230# CONFIG_MEGARAID_NEWGEN is not set 455# CONFIG_MEGARAID_NEWGEN is not set
231# CONFIG_MEGARAID_LEGACY is not set 456# CONFIG_MEGARAID_LEGACY is not set
457# CONFIG_MEGARAID_SAS is not set
232# CONFIG_SCSI_SATA is not set 458# CONFIG_SCSI_SATA is not set
233# CONFIG_SCSI_BUSLOGIC is not set
234# CONFIG_SCSI_CPQFCTS is not set 459# CONFIG_SCSI_CPQFCTS is not set
235# CONFIG_SCSI_DMX3191D is not set 460# CONFIG_SCSI_DMX3191D is not set
236# CONFIG_SCSI_EATA is not set
237# CONFIG_SCSI_EATA_PIO is not set 461# CONFIG_SCSI_EATA_PIO is not set
238# CONFIG_SCSI_FUTURE_DOMAIN is not set 462# CONFIG_SCSI_FUTURE_DOMAIN is not set
239# CONFIG_SCSI_GDTH is not set
240# CONFIG_SCSI_IPS is not set 463# CONFIG_SCSI_IPS is not set
241# CONFIG_SCSI_INITIO is not set 464# CONFIG_SCSI_INITIO is not set
242# CONFIG_SCSI_INIA100 is not set 465# CONFIG_SCSI_INIA100 is not set
@@ -246,8 +469,6 @@ CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
246CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 469CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
247# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set 470# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
248# CONFIG_SCSI_IPR is not set 471# CONFIG_SCSI_IPR is not set
249# CONFIG_SCSI_PCI2000 is not set
250# CONFIG_SCSI_PCI2220I is not set
251# CONFIG_SCSI_QLOGIC_ISP is not set 472# CONFIG_SCSI_QLOGIC_ISP is not set
252CONFIG_SCSI_QLOGIC_FC=m 473CONFIG_SCSI_QLOGIC_FC=m
253# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set 474# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set
@@ -258,7 +479,9 @@ CONFIG_SCSI_QLA2XXX=y
258# CONFIG_SCSI_QLA22XX is not set 479# CONFIG_SCSI_QLA22XX is not set
259CONFIG_SCSI_QLA2300=m 480CONFIG_SCSI_QLA2300=m
260CONFIG_SCSI_QLA2322=m 481CONFIG_SCSI_QLA2322=m
261CONFIG_SCSI_QLA6312=m 482# CONFIG_SCSI_QLA6312 is not set
483# CONFIG_SCSI_QLA24XX is not set
484# CONFIG_SCSI_LPFC is not set
262# CONFIG_SCSI_DC395x is not set 485# CONFIG_SCSI_DC395x is not set
263# CONFIG_SCSI_DC390T is not set 486# CONFIG_SCSI_DC390T is not set
264CONFIG_SCSI_DEBUG=m 487CONFIG_SCSI_DEBUG=m
@@ -288,8 +511,11 @@ CONFIG_MD_RAID1=y
288# 511#
289# Fusion MPT device support 512# Fusion MPT device support
290# 513#
291CONFIG_FUSION=m 514CONFIG_FUSION=y
292CONFIG_FUSION_MAX_SGE=40 515CONFIG_FUSION_SPI=m
516CONFIG_FUSION_FC=m
517# CONFIG_FUSION_SAS is not set
518CONFIG_FUSION_MAX_SGE=128
293CONFIG_FUSION_CTL=m 519CONFIG_FUSION_CTL=m
294 520
295# 521#
@@ -303,153 +529,13 @@ CONFIG_FUSION_CTL=m
303# CONFIG_I2O is not set 529# CONFIG_I2O is not set
304 530
305# 531#
306# Networking support 532# Network device support
307#
308CONFIG_NET=y
309
310#
311# Networking options
312#
313CONFIG_PACKET=y
314CONFIG_PACKET_MMAP=y
315CONFIG_NETLINK_DEV=y
316CONFIG_UNIX=y
317CONFIG_NET_KEY=m
318CONFIG_INET=y
319CONFIG_IP_MULTICAST=y
320# CONFIG_IP_ADVANCED_ROUTER is not set
321CONFIG_IP_PNP=y
322CONFIG_IP_PNP_DHCP=y
323CONFIG_IP_PNP_BOOTP=y
324# CONFIG_IP_PNP_RARP is not set
325# CONFIG_NET_IPIP is not set
326# CONFIG_NET_IPGRE is not set
327# CONFIG_IP_MROUTE is not set
328# CONFIG_ARPD is not set
329# CONFIG_SYN_COOKIES is not set
330CONFIG_INET_AH=m
331CONFIG_INET_ESP=m
332# CONFIG_INET_IPCOMP is not set
333CONFIG_INET_TUNNEL=m
334CONFIG_IP_TCPDIAG=y
335# CONFIG_IP_TCPDIAG_IPV6 is not set
336
337#
338# IP: Virtual Server Configuration
339# 533#
340# CONFIG_IP_VS is not set
341# CONFIG_IPV6 is not set
342CONFIG_NETFILTER=y
343# CONFIG_NETFILTER_DEBUG is not set
344
345#
346# IP: Netfilter Configuration
347#
348CONFIG_IP_NF_CONNTRACK=m
349# CONFIG_IP_NF_CT_ACCT is not set
350CONFIG_IP_NF_CONNTRACK_MARK=y
351CONFIG_IP_NF_CT_PROTO_SCTP=m
352CONFIG_IP_NF_FTP=m
353CONFIG_IP_NF_IRC=m
354CONFIG_IP_NF_TFTP=m
355CONFIG_IP_NF_AMANDA=m
356CONFIG_IP_NF_QUEUE=m
357CONFIG_IP_NF_IPTABLES=m
358CONFIG_IP_NF_MATCH_LIMIT=m
359CONFIG_IP_NF_MATCH_IPRANGE=m
360CONFIG_IP_NF_MATCH_MAC=m
361CONFIG_IP_NF_MATCH_PKTTYPE=m
362CONFIG_IP_NF_MATCH_MARK=m
363CONFIG_IP_NF_MATCH_MULTIPORT=m
364CONFIG_IP_NF_MATCH_TOS=m
365CONFIG_IP_NF_MATCH_RECENT=m
366CONFIG_IP_NF_MATCH_ECN=m
367CONFIG_IP_NF_MATCH_DSCP=m
368CONFIG_IP_NF_MATCH_AH_ESP=m
369CONFIG_IP_NF_MATCH_LENGTH=m
370CONFIG_IP_NF_MATCH_TTL=m
371CONFIG_IP_NF_MATCH_TCPMSS=m
372CONFIG_IP_NF_MATCH_HELPER=m
373CONFIG_IP_NF_MATCH_STATE=m
374CONFIG_IP_NF_MATCH_CONNTRACK=m
375CONFIG_IP_NF_MATCH_OWNER=m
376# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
377# CONFIG_IP_NF_MATCH_REALM is not set
378CONFIG_IP_NF_MATCH_SCTP=m
379CONFIG_IP_NF_MATCH_COMMENT=m
380CONFIG_IP_NF_MATCH_CONNMARK=m
381CONFIG_IP_NF_MATCH_HASHLIMIT=m
382CONFIG_IP_NF_FILTER=m
383CONFIG_IP_NF_TARGET_REJECT=m
384CONFIG_IP_NF_TARGET_LOG=m
385CONFIG_IP_NF_TARGET_ULOG=m
386CONFIG_IP_NF_TARGET_TCPMSS=m
387CONFIG_IP_NF_NAT=m
388CONFIG_IP_NF_NAT_NEEDED=y
389CONFIG_IP_NF_TARGET_MASQUERADE=m
390CONFIG_IP_NF_TARGET_REDIRECT=m
391CONFIG_IP_NF_TARGET_NETMAP=m
392CONFIG_IP_NF_TARGET_SAME=m
393CONFIG_IP_NF_NAT_SNMP_BASIC=m
394CONFIG_IP_NF_NAT_IRC=m
395CONFIG_IP_NF_NAT_FTP=m
396CONFIG_IP_NF_NAT_TFTP=m
397CONFIG_IP_NF_NAT_AMANDA=m
398CONFIG_IP_NF_MANGLE=m
399CONFIG_IP_NF_TARGET_TOS=m
400CONFIG_IP_NF_TARGET_ECN=m
401CONFIG_IP_NF_TARGET_DSCP=m
402CONFIG_IP_NF_TARGET_MARK=m
403CONFIG_IP_NF_TARGET_CLASSIFY=m
404CONFIG_IP_NF_TARGET_CONNMARK=m
405CONFIG_IP_NF_TARGET_CLUSTERIP=m
406CONFIG_IP_NF_RAW=m
407CONFIG_IP_NF_TARGET_NOTRACK=m
408CONFIG_IP_NF_ARPTABLES=m
409CONFIG_IP_NF_ARPFILTER=m
410CONFIG_IP_NF_ARP_MANGLE=m
411CONFIG_XFRM=y
412CONFIG_XFRM_USER=m
413
414#
415# SCTP Configuration (EXPERIMENTAL)
416#
417# CONFIG_IP_SCTP is not set
418# CONFIG_ATM is not set
419# CONFIG_BRIDGE is not set
420# CONFIG_VLAN_8021Q is not set
421# CONFIG_DECNET is not set
422CONFIG_LLC=m
423CONFIG_LLC2=m
424# CONFIG_IPX is not set
425# CONFIG_ATALK is not set
426# CONFIG_X25 is not set
427# CONFIG_LAPB is not set
428# CONFIG_NET_DIVERT is not set
429# CONFIG_ECONET is not set
430# CONFIG_WAN_ROUTER is not set
431
432#
433# QoS and/or fair queueing
434#
435# CONFIG_NET_SCHED is not set
436# CONFIG_NET_CLS_ROUTE is not set
437
438#
439# Network testing
440#
441CONFIG_NET_PKTGEN=m
442# CONFIG_NETPOLL is not set
443# CONFIG_NET_POLL_CONTROLLER is not set
444# CONFIG_HAMRADIO is not set
445# CONFIG_IRDA is not set
446# CONFIG_BT is not set
447CONFIG_NETDEVICES=y 534CONFIG_NETDEVICES=y
448CONFIG_DUMMY=m 535CONFIG_DUMMY=m
449CONFIG_BONDING=m 536CONFIG_BONDING=m
450# CONFIG_EQUALIZER is not set 537# CONFIG_EQUALIZER is not set
451CONFIG_TUN=m 538CONFIG_TUN=m
452# CONFIG_ETHERTAP is not set
453 539
454# 540#
455# ARCnet devices 541# ARCnet devices
@@ -457,12 +543,18 @@ CONFIG_TUN=m
457# CONFIG_ARCNET is not set 543# CONFIG_ARCNET is not set
458 544
459# 545#
546# PHY device support
547#
548# CONFIG_PHYLIB is not set
549
550#
460# Ethernet (10 or 100Mbit) 551# Ethernet (10 or 100Mbit)
461# 552#
462CONFIG_NET_ETHERNET=y 553CONFIG_NET_ETHERNET=y
463CONFIG_MII=m 554CONFIG_MII=m
464# CONFIG_HAPPYMEAL is not set 555# CONFIG_HAPPYMEAL is not set
465# CONFIG_SUNGEM is not set 556# CONFIG_SUNGEM is not set
557# CONFIG_CASSINI is not set
466CONFIG_NET_VENDOR_3COM=y 558CONFIG_NET_VENDOR_3COM=y
467CONFIG_VORTEX=m 559CONFIG_VORTEX=m
468CONFIG_TYPHOON=m 560CONFIG_TYPHOON=m
@@ -479,6 +571,7 @@ CONFIG_TULIP_MMIO=y
479# CONFIG_DE4X5 is not set 571# CONFIG_DE4X5 is not set
480# CONFIG_WINBOND_840 is not set 572# CONFIG_WINBOND_840 is not set
481# CONFIG_DM9102 is not set 573# CONFIG_DM9102 is not set
574# CONFIG_ULI526X is not set
482CONFIG_PCMCIA_XIRCOM=m 575CONFIG_PCMCIA_XIRCOM=m
483# CONFIG_PCMCIA_XIRTULIP is not set 576# CONFIG_PCMCIA_XIRTULIP is not set
484CONFIG_HP100=m 577CONFIG_HP100=m
@@ -489,48 +582,43 @@ CONFIG_PCNET32=m
489# CONFIG_B44 is not set 582# CONFIG_B44 is not set
490# CONFIG_FORCEDETH is not set 583# CONFIG_FORCEDETH is not set
491# CONFIG_DGRS is not set 584# CONFIG_DGRS is not set
492CONFIG_EEPRO100=m 585# CONFIG_EEPRO100 is not set
493CONFIG_E100=m 586CONFIG_E100=m
494CONFIG_E100_NAPI=y
495# CONFIG_FEALNX is not set 587# CONFIG_FEALNX is not set
496CONFIG_NATSEMI=m 588# CONFIG_NATSEMI is not set
497# CONFIG_NE2K_PCI is not set 589# CONFIG_NE2K_PCI is not set
498# CONFIG_8139CP is not set 590# CONFIG_8139CP is not set
499CONFIG_8139TOO=m 591# CONFIG_8139TOO is not set
500# CONFIG_8139TOO_PIO is not set
501# CONFIG_8139TOO_TUNE_TWISTER is not set
502# CONFIG_8139TOO_8129 is not set
503# CONFIG_8139_OLD_RX_RESET is not set
504# CONFIG_SIS900 is not set 592# CONFIG_SIS900 is not set
505CONFIG_EPIC100=m 593# CONFIG_EPIC100 is not set
506# CONFIG_SUNDANCE is not set 594# CONFIG_SUNDANCE is not set
507CONFIG_VIA_RHINE=m 595# CONFIG_VIA_RHINE is not set
508CONFIG_VIA_RHINE_MMIO=y
509 596
510# 597#
511# Ethernet (1000 Mbit) 598# Ethernet (1000 Mbit)
512# 599#
513CONFIG_ACENIC=m 600CONFIG_ACENIC=m
514CONFIG_ACENIC_OMIT_TIGON_I=y 601CONFIG_ACENIC_OMIT_TIGON_I=y
515CONFIG_DL2K=m 602# CONFIG_DL2K is not set
516CONFIG_E1000=m 603CONFIG_E1000=m
517CONFIG_E1000_NAPI=y 604CONFIG_E1000_NAPI=y
518# CONFIG_NS83820 is not set 605# CONFIG_NS83820 is not set
519# CONFIG_HAMACHI is not set 606# CONFIG_HAMACHI is not set
520# CONFIG_YELLOWFIN is not set 607# CONFIG_YELLOWFIN is not set
521# CONFIG_R8169 is not set 608# CONFIG_R8169 is not set
609# CONFIG_SIS190 is not set
610# CONFIG_SKGE is not set
522# CONFIG_SK98LIN is not set 611# CONFIG_SK98LIN is not set
523# CONFIG_VIA_VELOCITY is not set 612# CONFIG_VIA_VELOCITY is not set
524CONFIG_TIGON3=m 613CONFIG_TIGON3=m
614# CONFIG_BNX2 is not set
525 615
526# 616#
527# Ethernet (10000 Mbit) 617# Ethernet (10000 Mbit)
528# 618#
529CONFIG_IXGB=m 619# CONFIG_CHELSIO_T1 is not set
530CONFIG_IXGB_NAPI=y 620# CONFIG_IXGB is not set
531CONFIG_S2IO=m 621# CONFIG_S2IO is not set
532CONFIG_S2IO_NAPI=y
533# CONFIG_2BUFF_MODE is not set
534 622
535# 623#
536# Token Ring devices 624# Token Ring devices
@@ -560,6 +648,7 @@ CONFIG_PCMCIA_RAYCS=m
560CONFIG_HERMES=m 648CONFIG_HERMES=m
561CONFIG_PLX_HERMES=m 649CONFIG_PLX_HERMES=m
562CONFIG_TMD_HERMES=m 650CONFIG_TMD_HERMES=m
651# CONFIG_NORTEL_HERMES is not set
563CONFIG_PCI_HERMES=m 652CONFIG_PCI_HERMES=m
564# CONFIG_ATMEL is not set 653# CONFIG_ATMEL is not set
565 654
@@ -567,6 +656,7 @@ CONFIG_PCI_HERMES=m
567# Wireless 802.11b Pcmcia/Cardbus cards support 656# Wireless 802.11b Pcmcia/Cardbus cards support
568# 657#
569CONFIG_PCMCIA_HERMES=m 658CONFIG_PCMCIA_HERMES=m
659# CONFIG_PCMCIA_SPECTRUM is not set
570CONFIG_AIRO_CS=m 660CONFIG_AIRO_CS=m
571CONFIG_PCMCIA_WL3501=m 661CONFIG_PCMCIA_WL3501=m
572 662
@@ -574,6 +664,7 @@ CONFIG_PCMCIA_WL3501=m
574# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support 664# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
575# 665#
576# CONFIG_PRISM54 is not set 666# CONFIG_PRISM54 is not set
667# CONFIG_HOSTAP is not set
577CONFIG_NET_WIRELESS=y 668CONFIG_NET_WIRELESS=y
578 669
579# 670#
@@ -607,6 +698,8 @@ CONFIG_PPP_BSDCOMP=m
607# CONFIG_NET_FC is not set 698# CONFIG_NET_FC is not set
608# CONFIG_SHAPER is not set 699# CONFIG_SHAPER is not set
609# CONFIG_NETCONSOLE is not set 700# CONFIG_NETCONSOLE is not set
701# CONFIG_NETPOLL is not set
702# CONFIG_NET_POLL_CONTROLLER is not set
610 703
611# 704#
612# ISDN subsystem 705# ISDN subsystem
@@ -633,13 +726,6 @@ CONFIG_INPUT=y
633# CONFIG_INPUT_EVBUG is not set 726# CONFIG_INPUT_EVBUG is not set
634 727
635# 728#
636# Input I/O drivers
637#
638# CONFIG_GAMEPORT is not set
639CONFIG_SOUND_GAMEPORT=y
640# CONFIG_SERIO is not set
641
642#
643# Input Device Drivers 729# Input Device Drivers
644# 730#
645# CONFIG_INPUT_KEYBOARD is not set 731# CONFIG_INPUT_KEYBOARD is not set
@@ -649,6 +735,12 @@ CONFIG_SOUND_GAMEPORT=y
649# CONFIG_INPUT_MISC is not set 735# CONFIG_INPUT_MISC is not set
650 736
651# 737#
738# Hardware I/O ports
739#
740# CONFIG_SERIO is not set
741# CONFIG_GAMEPORT is not set
742
743#
652# Character devices 744# Character devices
653# 745#
654CONFIG_VT=y 746CONFIG_VT=y
@@ -667,7 +759,6 @@ CONFIG_SERIAL_8250_EXTENDED=y
667CONFIG_SERIAL_8250_MANY_PORTS=y 759CONFIG_SERIAL_8250_MANY_PORTS=y
668CONFIG_SERIAL_8250_SHARE_IRQ=y 760CONFIG_SERIAL_8250_SHARE_IRQ=y
669# CONFIG_SERIAL_8250_DETECT_IRQ is not set 761# CONFIG_SERIAL_8250_DETECT_IRQ is not set
670# CONFIG_SERIAL_8250_MULTIPORT is not set
671# CONFIG_SERIAL_8250_RSA is not set 762# CONFIG_SERIAL_8250_RSA is not set
672 763
673# 764#
@@ -677,6 +768,7 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
677CONFIG_PDC_CONSOLE=y 768CONFIG_PDC_CONSOLE=y
678CONFIG_SERIAL_CORE=y 769CONFIG_SERIAL_CORE=y
679CONFIG_SERIAL_CORE_CONSOLE=y 770CONFIG_SERIAL_CORE_CONSOLE=y
771# CONFIG_SERIAL_JSM is not set
680CONFIG_UNIX98_PTYS=y 772CONFIG_UNIX98_PTYS=y
681# CONFIG_LEGACY_PTYS is not set 773# CONFIG_LEGACY_PTYS is not set
682 774
@@ -708,6 +800,11 @@ CONFIG_RAW_DRIVER=y
708CONFIG_MAX_RAW_DEVS=256 800CONFIG_MAX_RAW_DEVS=256
709 801
710# 802#
803# TPM devices
804#
805# CONFIG_TCG_TPM is not set
806
807#
711# I2C support 808# I2C support
712# 809#
713# CONFIG_I2C is not set 810# CONFIG_I2C is not set
@@ -718,10 +815,20 @@ CONFIG_MAX_RAW_DEVS=256
718# CONFIG_W1 is not set 815# CONFIG_W1 is not set
719 816
720# 817#
818# Hardware Monitoring support
819#
820# CONFIG_HWMON is not set
821# CONFIG_HWMON_VID is not set
822
823#
721# Misc devices 824# Misc devices
722# 825#
723 826
724# 827#
828# Multimedia Capabilities Port drivers
829#
830
831#
725# Multimedia devices 832# Multimedia devices
726# 833#
727# CONFIG_VIDEO_DEV is not set 834# CONFIG_VIDEO_DEV is not set
@@ -742,6 +849,7 @@ CONFIG_MAX_RAW_DEVS=256
742CONFIG_DUMMY_CONSOLE=y 849CONFIG_DUMMY_CONSOLE=y
743CONFIG_DUMMY_CONSOLE_COLUMNS=160 850CONFIG_DUMMY_CONSOLE_COLUMNS=160
744CONFIG_DUMMY_CONSOLE_ROWS=64 851CONFIG_DUMMY_CONSOLE_ROWS=64
852# CONFIG_STI_CONSOLE is not set
745 853
746# 854#
747# Sound 855# Sound
@@ -751,13 +859,9 @@ CONFIG_DUMMY_CONSOLE_ROWS=64
751# 859#
752# USB support 860# USB support
753# 861#
754# CONFIG_USB is not set
755CONFIG_USB_ARCH_HAS_HCD=y 862CONFIG_USB_ARCH_HAS_HCD=y
756CONFIG_USB_ARCH_HAS_OHCI=y 863CONFIG_USB_ARCH_HAS_OHCI=y
757 864# CONFIG_USB is not set
758#
759# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
760#
761 865
762# 866#
763# USB Gadget Support 867# USB Gadget Support
@@ -772,17 +876,18 @@ CONFIG_USB_ARCH_HAS_OHCI=y
772# 876#
773# InfiniBand support 877# InfiniBand support
774# 878#
775CONFIG_INFINIBAND=m 879# CONFIG_INFINIBAND is not set
776CONFIG_INFINIBAND_MTHCA=m 880
777# CONFIG_INFINIBAND_MTHCA_DEBUG is not set 881#
778CONFIG_INFINIBAND_IPOIB=m 882# SN Devices
779# CONFIG_INFINIBAND_IPOIB_DEBUG is not set 883#
780 884
781# 885#
782# File systems 886# File systems
783# 887#
784CONFIG_EXT2_FS=y 888CONFIG_EXT2_FS=y
785# CONFIG_EXT2_FS_XATTR is not set 889# CONFIG_EXT2_FS_XATTR is not set
890# CONFIG_EXT2_FS_XIP is not set
786CONFIG_EXT3_FS=y 891CONFIG_EXT3_FS=y
787# CONFIG_EXT3_FS_XATTR is not set 892# CONFIG_EXT3_FS_XATTR is not set
788CONFIG_JBD=y 893CONFIG_JBD=y
@@ -794,22 +899,20 @@ CONFIG_JFS_FS=m
794# CONFIG_JFS_DEBUG is not set 899# CONFIG_JFS_DEBUG is not set
795# CONFIG_JFS_STATISTICS is not set 900# CONFIG_JFS_STATISTICS is not set
796CONFIG_FS_POSIX_ACL=y 901CONFIG_FS_POSIX_ACL=y
797
798#
799# XFS support
800#
801CONFIG_XFS_FS=m 902CONFIG_XFS_FS=m
802CONFIG_XFS_EXPORT=y 903CONFIG_XFS_EXPORT=y
803# CONFIG_XFS_RT is not set
804# CONFIG_XFS_QUOTA is not set 904# CONFIG_XFS_QUOTA is not set
805# CONFIG_XFS_SECURITY is not set 905# CONFIG_XFS_SECURITY is not set
806# CONFIG_XFS_POSIX_ACL is not set 906# CONFIG_XFS_POSIX_ACL is not set
907# CONFIG_XFS_RT is not set
807# CONFIG_MINIX_FS is not set 908# CONFIG_MINIX_FS is not set
808# CONFIG_ROMFS_FS is not set 909# CONFIG_ROMFS_FS is not set
910CONFIG_INOTIFY=y
809# CONFIG_QUOTA is not set 911# CONFIG_QUOTA is not set
810CONFIG_DNOTIFY=y 912CONFIG_DNOTIFY=y
811# CONFIG_AUTOFS_FS is not set 913# CONFIG_AUTOFS_FS is not set
812CONFIG_AUTOFS4_FS=y 914CONFIG_AUTOFS4_FS=y
915# CONFIG_FUSE_FS is not set
813 916
814# 917#
815# CD-ROM/DVD Filesystems 918# CD-ROM/DVD Filesystems
@@ -836,13 +939,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
836CONFIG_PROC_FS=y 939CONFIG_PROC_FS=y
837CONFIG_PROC_KCORE=y 940CONFIG_PROC_KCORE=y
838CONFIG_SYSFS=y 941CONFIG_SYSFS=y
839# CONFIG_DEVFS_FS is not set
840# CONFIG_DEVPTS_FS_XATTR is not set
841CONFIG_TMPFS=y 942CONFIG_TMPFS=y
842# CONFIG_TMPFS_XATTR is not set
843# CONFIG_HUGETLBFS is not set 943# CONFIG_HUGETLBFS is not set
844# CONFIG_HUGETLB_PAGE is not set 944# CONFIG_HUGETLB_PAGE is not set
845CONFIG_RAMFS=y 945CONFIG_RAMFS=y
946# CONFIG_RELAYFS_FS is not set
846 947
847# 948#
848# Miscellaneous filesystems 949# Miscellaneous filesystems
@@ -867,15 +968,18 @@ CONFIG_UFS_FS=m
867# 968#
868CONFIG_NFS_FS=m 969CONFIG_NFS_FS=m
869CONFIG_NFS_V3=y 970CONFIG_NFS_V3=y
971# CONFIG_NFS_V3_ACL is not set
870CONFIG_NFS_V4=y 972CONFIG_NFS_V4=y
871CONFIG_NFS_DIRECTIO=y 973CONFIG_NFS_DIRECTIO=y
872CONFIG_NFSD=m 974CONFIG_NFSD=m
873CONFIG_NFSD_V3=y 975CONFIG_NFSD_V3=y
976# CONFIG_NFSD_V3_ACL is not set
874CONFIG_NFSD_V4=y 977CONFIG_NFSD_V4=y
875CONFIG_NFSD_TCP=y 978CONFIG_NFSD_TCP=y
876CONFIG_LOCKD=m 979CONFIG_LOCKD=m
877CONFIG_LOCKD_V4=y 980CONFIG_LOCKD_V4=y
878CONFIG_EXPORTFS=m 981CONFIG_EXPORTFS=m
982CONFIG_NFS_COMMON=y
879CONFIG_SUNRPC=m 983CONFIG_SUNRPC=m
880CONFIG_SUNRPC_GSS=m 984CONFIG_SUNRPC_GSS=m
881CONFIG_RPCSEC_GSS_KRB5=m 985CONFIG_RPCSEC_GSS_KRB5=m
@@ -890,6 +994,7 @@ CONFIG_CIFS=m
890# CONFIG_NCP_FS is not set 994# CONFIG_NCP_FS is not set
891# CONFIG_CODA_FS is not set 995# CONFIG_CODA_FS is not set
892# CONFIG_AFS_FS is not set 996# CONFIG_AFS_FS is not set
997# CONFIG_9P_FS is not set
893 998
894# 999#
895# Partition Types 1000# Partition Types
@@ -906,15 +1011,15 @@ CONFIG_NLS_CODEPAGE_437=m
906# CONFIG_NLS_CODEPAGE_737 is not set 1011# CONFIG_NLS_CODEPAGE_737 is not set
907# CONFIG_NLS_CODEPAGE_775 is not set 1012# CONFIG_NLS_CODEPAGE_775 is not set
908CONFIG_NLS_CODEPAGE_850=m 1013CONFIG_NLS_CODEPAGE_850=m
909CONFIG_NLS_CODEPAGE_852=m 1014# CONFIG_NLS_CODEPAGE_852 is not set
910# CONFIG_NLS_CODEPAGE_855 is not set 1015# CONFIG_NLS_CODEPAGE_855 is not set
911# CONFIG_NLS_CODEPAGE_857 is not set 1016# CONFIG_NLS_CODEPAGE_857 is not set
912# CONFIG_NLS_CODEPAGE_860 is not set 1017# CONFIG_NLS_CODEPAGE_860 is not set
913# CONFIG_NLS_CODEPAGE_861 is not set 1018# CONFIG_NLS_CODEPAGE_861 is not set
914# CONFIG_NLS_CODEPAGE_862 is not set 1019# CONFIG_NLS_CODEPAGE_862 is not set
915CONFIG_NLS_CODEPAGE_863=m 1020# CONFIG_NLS_CODEPAGE_863 is not set
916# CONFIG_NLS_CODEPAGE_864 is not set 1021# CONFIG_NLS_CODEPAGE_864 is not set
917CONFIG_NLS_CODEPAGE_865=m 1022# CONFIG_NLS_CODEPAGE_865 is not set
918# CONFIG_NLS_CODEPAGE_866 is not set 1023# CONFIG_NLS_CODEPAGE_866 is not set
919# CONFIG_NLS_CODEPAGE_869 is not set 1024# CONFIG_NLS_CODEPAGE_869 is not set
920# CONFIG_NLS_CODEPAGE_936 is not set 1025# CONFIG_NLS_CODEPAGE_936 is not set
@@ -926,10 +1031,10 @@ CONFIG_NLS_CODEPAGE_865=m
926# CONFIG_NLS_CODEPAGE_1250 is not set 1031# CONFIG_NLS_CODEPAGE_1250 is not set
927# CONFIG_NLS_CODEPAGE_1251 is not set 1032# CONFIG_NLS_CODEPAGE_1251 is not set
928# CONFIG_NLS_ASCII is not set 1033# CONFIG_NLS_ASCII is not set
929CONFIG_NLS_ISO8859_1=m 1034# CONFIG_NLS_ISO8859_1 is not set
930CONFIG_NLS_ISO8859_2=m 1035# CONFIG_NLS_ISO8859_2 is not set
931CONFIG_NLS_ISO8859_3=m 1036# CONFIG_NLS_ISO8859_3 is not set
932CONFIG_NLS_ISO8859_4=m 1037# CONFIG_NLS_ISO8859_4 is not set
933# CONFIG_NLS_ISO8859_5 is not set 1038# CONFIG_NLS_ISO8859_5 is not set
934# CONFIG_NLS_ISO8859_6 is not set 1039# CONFIG_NLS_ISO8859_6 is not set
935# CONFIG_NLS_ISO8859_7 is not set 1040# CONFIG_NLS_ISO8859_7 is not set
@@ -950,11 +1055,15 @@ CONFIG_OPROFILE=m
950# 1055#
951# Kernel hacking 1056# Kernel hacking
952# 1057#
1058# CONFIG_PRINTK_TIME is not set
953CONFIG_DEBUG_KERNEL=y 1059CONFIG_DEBUG_KERNEL=y
954CONFIG_MAGIC_SYSRQ=y 1060CONFIG_MAGIC_SYSRQ=y
1061CONFIG_LOG_BUF_SHIFT=16
1062CONFIG_DETECT_SOFTLOCKUP=y
955# CONFIG_SCHEDSTATS is not set 1063# CONFIG_SCHEDSTATS is not set
956# CONFIG_DEBUG_SLAB is not set 1064# CONFIG_DEBUG_SLAB is not set
957# CONFIG_DEBUG_SPINLOCK is not set 1065# CONFIG_DEBUG_SPINLOCK is not set
1066# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
958# CONFIG_DEBUG_KOBJECT is not set 1067# CONFIG_DEBUG_KOBJECT is not set
959# CONFIG_DEBUG_INFO is not set 1068# CONFIG_DEBUG_INFO is not set
960# CONFIG_DEBUG_IOREMAP is not set 1069# CONFIG_DEBUG_IOREMAP is not set
@@ -974,25 +1083,26 @@ CONFIG_KEYS_DEBUG_PROC_KEYS=y
974CONFIG_CRYPTO=y 1083CONFIG_CRYPTO=y
975CONFIG_CRYPTO_HMAC=y 1084CONFIG_CRYPTO_HMAC=y
976CONFIG_CRYPTO_NULL=m 1085CONFIG_CRYPTO_NULL=m
977CONFIG_CRYPTO_MD4=m 1086# CONFIG_CRYPTO_MD4 is not set
978CONFIG_CRYPTO_MD5=m 1087CONFIG_CRYPTO_MD5=y
979CONFIG_CRYPTO_SHA1=m 1088CONFIG_CRYPTO_SHA1=m
980CONFIG_CRYPTO_SHA256=m 1089# CONFIG_CRYPTO_SHA256 is not set
981CONFIG_CRYPTO_SHA512=m 1090# CONFIG_CRYPTO_SHA512 is not set
982CONFIG_CRYPTO_WP512=m 1091# CONFIG_CRYPTO_WP512 is not set
1092# CONFIG_CRYPTO_TGR192 is not set
983CONFIG_CRYPTO_DES=m 1093CONFIG_CRYPTO_DES=m
984CONFIG_CRYPTO_BLOWFISH=m 1094CONFIG_CRYPTO_BLOWFISH=m
985CONFIG_CRYPTO_TWOFISH=m 1095# CONFIG_CRYPTO_TWOFISH is not set
986CONFIG_CRYPTO_SERPENT=m 1096# CONFIG_CRYPTO_SERPENT is not set
987CONFIG_CRYPTO_AES=m 1097# CONFIG_CRYPTO_AES is not set
988CONFIG_CRYPTO_CAST5=m 1098# CONFIG_CRYPTO_CAST5 is not set
989CONFIG_CRYPTO_CAST6=m 1099# CONFIG_CRYPTO_CAST6 is not set
990CONFIG_CRYPTO_TEA=m 1100# CONFIG_CRYPTO_TEA is not set
991CONFIG_CRYPTO_ARC4=m 1101# CONFIG_CRYPTO_ARC4 is not set
992CONFIG_CRYPTO_KHAZAD=m 1102# CONFIG_CRYPTO_KHAZAD is not set
993CONFIG_CRYPTO_ANUBIS=m 1103# CONFIG_CRYPTO_ANUBIS is not set
994CONFIG_CRYPTO_DEFLATE=m 1104CONFIG_CRYPTO_DEFLATE=m
995CONFIG_CRYPTO_MICHAEL_MIC=m 1105# CONFIG_CRYPTO_MICHAEL_MIC is not set
996CONFIG_CRYPTO_CRC32C=m 1106CONFIG_CRYPTO_CRC32C=m
997CONFIG_CRYPTO_TEST=m 1107CONFIG_CRYPTO_TEST=m
998 1108
@@ -1004,6 +1114,7 @@ CONFIG_CRYPTO_TEST=m
1004# Library routines 1114# Library routines
1005# 1115#
1006CONFIG_CRC_CCITT=m 1116CONFIG_CRC_CCITT=m
1117# CONFIG_CRC16 is not set
1007CONFIG_CRC32=y 1118CONFIG_CRC32=y
1008CONFIG_LIBCRC32C=m 1119CONFIG_LIBCRC32C=m
1009CONFIG_ZLIB_INFLATE=m 1120CONFIG_ZLIB_INFLATE=m
diff --git a/arch/parisc/configs/b180_defconfig b/arch/parisc/configs/b180_defconfig
index 46c9511f3229..8819e7e6ae3f 100644
--- a/arch/parisc/configs/b180_defconfig
+++ b/arch/parisc/configs/b180_defconfig
@@ -1,12 +1,15 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.10-pa5 3# Linux kernel version: 2.6.14-rc5-pa1
4# Wed Jan 5 13:35:54 2005 4# Fri Oct 21 23:06:10 2005
5# 5#
6CONFIG_PARISC=y 6CONFIG_PARISC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_STACK_GROWSUP=y 8CONFIG_STACK_GROWSUP=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_GENERIC_IRQ_PROBE=y
10 13
11# 14#
12# Code maturity level options 15# Code maturity level options
@@ -14,33 +17,39 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
14# CONFIG_EXPERIMENTAL is not set 17# CONFIG_EXPERIMENTAL is not set
15CONFIG_CLEAN_COMPILE=y 18CONFIG_CLEAN_COMPILE=y
16CONFIG_BROKEN_ON_SMP=y 19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
17 21
18# 22#
19# General setup 23# General setup
20# 24#
21CONFIG_LOCALVERSION="" 25CONFIG_LOCALVERSION=""
26# CONFIG_LOCALVERSION_AUTO is not set
22CONFIG_SWAP=y 27CONFIG_SWAP=y
23CONFIG_SYSVIPC=y 28CONFIG_SYSVIPC=y
24# CONFIG_BSD_PROCESS_ACCT is not set 29# CONFIG_BSD_PROCESS_ACCT is not set
25CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
26# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
27CONFIG_LOG_BUF_SHIFT=16
28# CONFIG_HOTPLUG is not set 32# CONFIG_HOTPLUG is not set
29CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
30# CONFIG_IKCONFIG is not set 34CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y
36CONFIG_INITRAMFS_SOURCE=""
31# CONFIG_EMBEDDED is not set 37# CONFIG_EMBEDDED is not set
32CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
33# CONFIG_KALLSYMS_ALL is not set 39# CONFIG_KALLSYMS_ALL is not set
34# CONFIG_KALLSYMS_EXTRA_PASS is not set 40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
35CONFIG_FUTEX=y 44CONFIG_FUTEX=y
36CONFIG_EPOLL=y 45CONFIG_EPOLL=y
37# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
38CONFIG_SHMEM=y 46CONFIG_SHMEM=y
39CONFIG_CC_ALIGN_FUNCTIONS=0 47CONFIG_CC_ALIGN_FUNCTIONS=0
40CONFIG_CC_ALIGN_LABELS=0 48CONFIG_CC_ALIGN_LABELS=0
41CONFIG_CC_ALIGN_LOOPS=0 49CONFIG_CC_ALIGN_LOOPS=0
42CONFIG_CC_ALIGN_JUMPS=0 50CONFIG_CC_ALIGN_JUMPS=0
43# CONFIG_TINY_SHMEM is not set 51# CONFIG_TINY_SHMEM is not set
52CONFIG_BASE_SMALL=0
44 53
45# 54#
46# Loadable module support 55# Loadable module support
@@ -60,8 +69,14 @@ CONFIG_PA7100LC=y
60# CONFIG_PA7300LC is not set 69# CONFIG_PA7300LC is not set
61# CONFIG_PA8X00 is not set 70# CONFIG_PA8X00 is not set
62CONFIG_PA11=y 71CONFIG_PA11=y
63# CONFIG_64BIT is not set
64# CONFIG_SMP is not set 72# CONFIG_SMP is not set
73# CONFIG_HZ_100 is not set
74CONFIG_HZ_250=y
75# CONFIG_HZ_1000 is not set
76CONFIG_HZ=250
77CONFIG_FLATMEM=y
78CONFIG_FLAT_NODE_MEM_MAP=y
79# CONFIG_SPARSEMEM_STATIC is not set
65# CONFIG_PREEMPT is not set 80# CONFIG_PREEMPT is not set
66# CONFIG_HPUX is not set 81# CONFIG_HPUX is not set
67 82
@@ -78,11 +93,25 @@ CONFIG_EISA_NAMES=y
78CONFIG_ISA=y 93CONFIG_ISA=y
79CONFIG_PCI=y 94CONFIG_PCI=y
80CONFIG_PCI_LEGACY_PROC=y 95CONFIG_PCI_LEGACY_PROC=y
81CONFIG_PCI_NAMES=y 96# CONFIG_PCI_DEBUG is not set
82CONFIG_GSC_DINO=y 97CONFIG_GSC_DINO=y
83# CONFIG_PCI_LBA is not set 98# CONFIG_PCI_LBA is not set
99
100#
101# PCCARD (PCMCIA/CardBus) support
102#
103# CONFIG_PCCARD is not set
104
105#
106# PCI Hotplug Support
107#
108
109#
110# PA-RISC specific drivers
111#
84CONFIG_CHASSIS_LCD_LED=y 112CONFIG_CHASSIS_LCD_LED=y
85# CONFIG_PDC_CHASSIS is not set 113# CONFIG_PDC_CHASSIS is not set
114CONFIG_PDC_STABLE=y
86 115
87# 116#
88# Executable file formats 117# Executable file formats
@@ -91,6 +120,64 @@ CONFIG_BINFMT_ELF=y
91# CONFIG_BINFMT_MISC is not set 120# CONFIG_BINFMT_MISC is not set
92 121
93# 122#
123# Networking
124#
125CONFIG_NET=y
126
127#
128# Networking options
129#
130CONFIG_PACKET=y
131CONFIG_PACKET_MMAP=y
132CONFIG_UNIX=y
133# CONFIG_NET_KEY is not set
134CONFIG_INET=y
135CONFIG_IP_MULTICAST=y
136# CONFIG_IP_ADVANCED_ROUTER is not set
137CONFIG_IP_FIB_HASH=y
138CONFIG_IP_PNP=y
139# CONFIG_IP_PNP_DHCP is not set
140CONFIG_IP_PNP_BOOTP=y
141# CONFIG_IP_PNP_RARP is not set
142# CONFIG_NET_IPIP is not set
143# CONFIG_NET_IPGRE is not set
144# CONFIG_IP_MROUTE is not set
145# CONFIG_SYN_COOKIES is not set
146# CONFIG_INET_AH is not set
147# CONFIG_INET_ESP is not set
148# CONFIG_INET_IPCOMP is not set
149# CONFIG_INET_TUNNEL is not set
150CONFIG_INET_DIAG=y
151CONFIG_INET_TCP_DIAG=y
152# CONFIG_TCP_CONG_ADVANCED is not set
153CONFIG_TCP_CONG_BIC=y
154CONFIG_IPV6=y
155# CONFIG_IPV6_PRIVACY is not set
156# CONFIG_INET6_AH is not set
157# CONFIG_INET6_ESP is not set
158# CONFIG_INET6_IPCOMP is not set
159# CONFIG_INET6_TUNNEL is not set
160# CONFIG_IPV6_TUNNEL is not set
161# CONFIG_NETFILTER is not set
162# CONFIG_BRIDGE is not set
163# CONFIG_VLAN_8021Q is not set
164# CONFIG_DECNET is not set
165# CONFIG_LLC2 is not set
166# CONFIG_IPX is not set
167# CONFIG_ATALK is not set
168# CONFIG_NET_SCHED is not set
169# CONFIG_NET_CLS_ROUTE is not set
170
171#
172# Network testing
173#
174# CONFIG_NET_PKTGEN is not set
175# CONFIG_HAMRADIO is not set
176# CONFIG_IRDA is not set
177# CONFIG_BT is not set
178# CONFIG_IEEE80211 is not set
179
180#
94# Device Drivers 181# Device Drivers
95# 182#
96 183
@@ -99,9 +186,15 @@ CONFIG_BINFMT_ELF=y
99# 186#
100CONFIG_STANDALONE=y 187CONFIG_STANDALONE=y
101# CONFIG_PREVENT_FIRMWARE_BUILD is not set 188# CONFIG_PREVENT_FIRMWARE_BUILD is not set
189# CONFIG_FW_LOADER is not set
102# CONFIG_DEBUG_DRIVER is not set 190# CONFIG_DEBUG_DRIVER is not set
103 191
104# 192#
193# Connector - unified userspace <-> kernelspace linker
194#
195# CONFIG_CONNECTOR is not set
196
197#
105# Memory Technology Devices (MTD) 198# Memory Technology Devices (MTD)
106# 199#
107# CONFIG_MTD is not set 200# CONFIG_MTD is not set
@@ -111,10 +204,8 @@ CONFIG_STANDALONE=y
111# 204#
112CONFIG_PARPORT=y 205CONFIG_PARPORT=y
113CONFIG_PARPORT_PC=y 206CONFIG_PARPORT_PC=y
114CONFIG_PARPORT_PC_CML1=y
115# CONFIG_PARPORT_SERIAL is not set 207# CONFIG_PARPORT_SERIAL is not set
116CONFIG_PARPORT_GSC=y 208CONFIG_PARPORT_GSC=y
117# CONFIG_PARPORT_OTHER is not set
118# CONFIG_PARPORT_1284 is not set 209# CONFIG_PARPORT_1284 is not set
119 210
120# 211#
@@ -125,19 +216,17 @@ CONFIG_PARPORT_GSC=y
125# 216#
126# Block devices 217# Block devices
127# 218#
128# CONFIG_BLK_DEV_FD is not set
129# CONFIG_BLK_DEV_XD is not set
130# CONFIG_PARIDE is not set 219# CONFIG_PARIDE is not set
131# CONFIG_BLK_CPQ_DA is not set 220# CONFIG_BLK_CPQ_DA is not set
132# CONFIG_BLK_CPQ_CISS_DA is not set 221# CONFIG_BLK_CPQ_CISS_DA is not set
133# CONFIG_BLK_DEV_DAC960 is not set 222# CONFIG_BLK_DEV_DAC960 is not set
223# CONFIG_BLK_DEV_COW_COMMON is not set
134CONFIG_BLK_DEV_LOOP=y 224CONFIG_BLK_DEV_LOOP=y
135CONFIG_BLK_DEV_CRYPTOLOOP=y 225CONFIG_BLK_DEV_CRYPTOLOOP=y
136# CONFIG_BLK_DEV_NBD is not set 226# CONFIG_BLK_DEV_NBD is not set
137# CONFIG_BLK_DEV_SX8 is not set 227# CONFIG_BLK_DEV_SX8 is not set
138# CONFIG_BLK_DEV_RAM is not set 228# CONFIG_BLK_DEV_RAM is not set
139CONFIG_BLK_DEV_RAM_COUNT=16 229CONFIG_BLK_DEV_RAM_COUNT=16
140CONFIG_INITRAMFS_SOURCE=""
141CONFIG_CDROM_PKTCDVD=m 230CONFIG_CDROM_PKTCDVD=m
142CONFIG_CDROM_PKTCDVD_BUFFERS=8 231CONFIG_CDROM_PKTCDVD_BUFFERS=8
143# CONFIG_CDROM_PKTCDVD_WCACHE is not set 232# CONFIG_CDROM_PKTCDVD_WCACHE is not set
@@ -149,6 +238,7 @@ CONFIG_IOSCHED_NOOP=y
149CONFIG_IOSCHED_AS=y 238CONFIG_IOSCHED_AS=y
150CONFIG_IOSCHED_DEADLINE=y 239CONFIG_IOSCHED_DEADLINE=y
151CONFIG_IOSCHED_CFQ=y 240CONFIG_IOSCHED_CFQ=y
241CONFIG_ATA_OVER_ETH=y
152 242
153# 243#
154# ATA/ATAPI/MFM/RLL support 244# ATA/ATAPI/MFM/RLL support
@@ -158,6 +248,7 @@ CONFIG_IOSCHED_CFQ=y
158# 248#
159# SCSI device support 249# SCSI device support
160# 250#
251# CONFIG_RAID_ATTRS is not set
161CONFIG_SCSI=y 252CONFIG_SCSI=y
162CONFIG_SCSI_PROC_FS=y 253CONFIG_SCSI_PROC_FS=y
163 254
@@ -170,6 +261,7 @@ CONFIG_CHR_DEV_ST=y
170CONFIG_BLK_DEV_SR=y 261CONFIG_BLK_DEV_SR=y
171# CONFIG_BLK_DEV_SR_VENDOR is not set 262# CONFIG_BLK_DEV_SR_VENDOR is not set
172CONFIG_CHR_DEV_SG=y 263CONFIG_CHR_DEV_SG=y
264# CONFIG_CHR_DEV_SCH is not set
173 265
174# 266#
175# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 267# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -183,16 +275,16 @@ CONFIG_CHR_DEV_SG=y
183# 275#
184CONFIG_SCSI_SPI_ATTRS=y 276CONFIG_SCSI_SPI_ATTRS=y
185# CONFIG_SCSI_FC_ATTRS is not set 277# CONFIG_SCSI_FC_ATTRS is not set
278# CONFIG_SCSI_ISCSI_ATTRS is not set
279# CONFIG_SCSI_SAS_ATTRS is not set
186 280
187# 281#
188# SCSI low-level drivers 282# SCSI low-level drivers
189# 283#
190# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 284# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
191# CONFIG_SCSI_3W_9XXX is not set 285# CONFIG_SCSI_3W_9XXX is not set
192# CONFIG_SCSI_7000FASST is not set
193# CONFIG_SCSI_ACARD is not set 286# CONFIG_SCSI_ACARD is not set
194# CONFIG_SCSI_AHA152X is not set 287# CONFIG_SCSI_AHA152X is not set
195# CONFIG_SCSI_AHA1542 is not set
196# CONFIG_SCSI_AHA1740 is not set 288# CONFIG_SCSI_AHA1740 is not set
197# CONFIG_SCSI_AACRAID is not set 289# CONFIG_SCSI_AACRAID is not set
198# CONFIG_SCSI_AIC7XXX is not set 290# CONFIG_SCSI_AIC7XXX is not set
@@ -202,14 +294,11 @@ CONFIG_SCSI_SPI_ATTRS=y
202# CONFIG_SCSI_IN2000 is not set 294# CONFIG_SCSI_IN2000 is not set
203# CONFIG_MEGARAID_NEWGEN is not set 295# CONFIG_MEGARAID_NEWGEN is not set
204# CONFIG_MEGARAID_LEGACY is not set 296# CONFIG_MEGARAID_LEGACY is not set
297# CONFIG_MEGARAID_SAS is not set
205# CONFIG_SCSI_SATA is not set 298# CONFIG_SCSI_SATA is not set
206# CONFIG_SCSI_BUSLOGIC is not set
207# CONFIG_SCSI_DMX3191D is not set 299# CONFIG_SCSI_DMX3191D is not set
208# CONFIG_SCSI_DTC3280 is not set 300# CONFIG_SCSI_DTC3280 is not set
209# CONFIG_SCSI_EATA is not set
210# CONFIG_SCSI_EATA_PIO is not set
211# CONFIG_SCSI_FUTURE_DOMAIN is not set 301# CONFIG_SCSI_FUTURE_DOMAIN is not set
212# CONFIG_SCSI_GDTH is not set
213# CONFIG_SCSI_GENERIC_NCR5380 is not set 302# CONFIG_SCSI_GENERIC_NCR5380 is not set
214# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set 303# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
215# CONFIG_SCSI_IPS is not set 304# CONFIG_SCSI_IPS is not set
@@ -219,7 +308,6 @@ CONFIG_SCSI_SPI_ATTRS=y
219# CONFIG_SCSI_IMM is not set 308# CONFIG_SCSI_IMM is not set
220# CONFIG_SCSI_NCR53C406A is not set 309# CONFIG_SCSI_NCR53C406A is not set
221CONFIG_SCSI_LASI700=y 310CONFIG_SCSI_LASI700=y
222CONFIG_53C700_MEM_MAPPED=y
223CONFIG_53C700_LE_ON_BE=y 311CONFIG_53C700_LE_ON_BE=y
224CONFIG_SCSI_SYM53C8XX_2=y 312CONFIG_SCSI_SYM53C8XX_2=y
225CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0 313CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
@@ -231,7 +319,6 @@ CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
231# CONFIG_SCSI_PAS16 is not set 319# CONFIG_SCSI_PAS16 is not set
232# CONFIG_SCSI_PSI240I is not set 320# CONFIG_SCSI_PSI240I is not set
233# CONFIG_SCSI_QLOGIC_FAS is not set 321# CONFIG_SCSI_QLOGIC_FAS is not set
234# CONFIG_SCSI_QLOGIC_ISP is not set
235# CONFIG_SCSI_QLOGIC_FC is not set 322# CONFIG_SCSI_QLOGIC_FC is not set
236# CONFIG_SCSI_QLOGIC_1280 is not set 323# CONFIG_SCSI_QLOGIC_1280 is not set
237CONFIG_SCSI_QLA2XXX=y 324CONFIG_SCSI_QLA2XXX=y
@@ -240,12 +327,12 @@ CONFIG_SCSI_QLA2XXX=y
240# CONFIG_SCSI_QLA2300 is not set 327# CONFIG_SCSI_QLA2300 is not set
241# CONFIG_SCSI_QLA2322 is not set 328# CONFIG_SCSI_QLA2322 is not set
242# CONFIG_SCSI_QLA6312 is not set 329# CONFIG_SCSI_QLA6312 is not set
243# CONFIG_SCSI_QLA6322 is not set 330# CONFIG_SCSI_QLA24XX is not set
331# CONFIG_SCSI_LPFC is not set
244# CONFIG_SCSI_SIM710 is not set 332# CONFIG_SCSI_SIM710 is not set
245# CONFIG_SCSI_SYM53C416 is not set 333# CONFIG_SCSI_SYM53C416 is not set
246# CONFIG_SCSI_DC390T is not set 334# CONFIG_SCSI_DC390T is not set
247# CONFIG_SCSI_T128 is not set 335# CONFIG_SCSI_T128 is not set
248# CONFIG_SCSI_U14_34F is not set
249# CONFIG_SCSI_NSP32 is not set 336# CONFIG_SCSI_NSP32 is not set
250# CONFIG_SCSI_DEBUG is not set 337# CONFIG_SCSI_DEBUG is not set
251 338
@@ -263,6 +350,7 @@ CONFIG_MD_LINEAR=y
263CONFIG_MD_RAID0=y 350CONFIG_MD_RAID0=y
264CONFIG_MD_RAID1=y 351CONFIG_MD_RAID1=y
265CONFIG_MD_RAID5=y 352CONFIG_MD_RAID5=y
353CONFIG_MD_RAID6=y
266# CONFIG_MD_MULTIPATH is not set 354# CONFIG_MD_MULTIPATH is not set
267# CONFIG_MD_FAULTY is not set 355# CONFIG_MD_FAULTY is not set
268# CONFIG_BLK_DEV_DM is not set 356# CONFIG_BLK_DEV_DM is not set
@@ -271,6 +359,9 @@ CONFIG_MD_RAID5=y
271# Fusion MPT device support 359# Fusion MPT device support
272# 360#
273# CONFIG_FUSION is not set 361# CONFIG_FUSION is not set
362# CONFIG_FUSION_SPI is not set
363# CONFIG_FUSION_FC is not set
364# CONFIG_FUSION_SAS is not set
274 365
275# 366#
276# IEEE 1394 (FireWire) support 367# IEEE 1394 (FireWire) support
@@ -283,58 +374,8 @@ CONFIG_MD_RAID5=y
283# CONFIG_I2O is not set 374# CONFIG_I2O is not set
284 375
285# 376#
286# Networking support 377# Network device support
287#
288CONFIG_NET=y
289
290#
291# Networking options
292#
293CONFIG_PACKET=y
294CONFIG_PACKET_MMAP=y
295CONFIG_NETLINK_DEV=y
296CONFIG_UNIX=y
297# CONFIG_NET_KEY is not set
298CONFIG_INET=y
299CONFIG_IP_MULTICAST=y
300# CONFIG_IP_ADVANCED_ROUTER is not set
301CONFIG_IP_PNP=y
302# CONFIG_IP_PNP_DHCP is not set
303CONFIG_IP_PNP_BOOTP=y
304# CONFIG_IP_PNP_RARP is not set
305# CONFIG_NET_IPIP is not set
306# CONFIG_NET_IPGRE is not set
307# CONFIG_IP_MROUTE is not set
308# CONFIG_SYN_COOKIES is not set
309# CONFIG_INET_AH is not set
310# CONFIG_INET_ESP is not set
311# CONFIG_INET_IPCOMP is not set
312# CONFIG_INET_TUNNEL is not set
313CONFIG_IP_TCPDIAG=y
314# CONFIG_IP_TCPDIAG_IPV6 is not set
315# CONFIG_NETFILTER is not set
316# CONFIG_BRIDGE is not set
317# CONFIG_VLAN_8021Q is not set
318# CONFIG_DECNET is not set
319# CONFIG_LLC2 is not set
320# CONFIG_IPX is not set
321# CONFIG_ATALK is not set
322
323#
324# QoS and/or fair queueing
325#
326# CONFIG_NET_SCHED is not set
327# CONFIG_NET_CLS_ROUTE is not set
328
329#
330# Network testing
331# 378#
332# CONFIG_NET_PKTGEN is not set
333# CONFIG_NETPOLL is not set
334# CONFIG_NET_POLL_CONTROLLER is not set
335# CONFIG_HAMRADIO is not set
336# CONFIG_IRDA is not set
337# CONFIG_BT is not set
338CONFIG_NETDEVICES=y 379CONFIG_NETDEVICES=y
339# CONFIG_DUMMY is not set 380# CONFIG_DUMMY is not set
340# CONFIG_BONDING is not set 381# CONFIG_BONDING is not set
@@ -347,6 +388,11 @@ CONFIG_NETDEVICES=y
347# CONFIG_ARCNET is not set 388# CONFIG_ARCNET is not set
348 389
349# 390#
391# PHY device support
392#
393# CONFIG_PHYLIB is not set
394
395#
350# Ethernet (10 or 100Mbit) 396# Ethernet (10 or 100Mbit)
351# 397#
352CONFIG_NET_ETHERNET=y 398CONFIG_NET_ETHERNET=y
@@ -354,8 +400,8 @@ CONFIG_NET_ETHERNET=y
354# CONFIG_LASI_82596 is not set 400# CONFIG_LASI_82596 is not set
355# CONFIG_HAPPYMEAL is not set 401# CONFIG_HAPPYMEAL is not set
356# CONFIG_SUNGEM is not set 402# CONFIG_SUNGEM is not set
403# CONFIG_CASSINI is not set
357# CONFIG_NET_VENDOR_3COM is not set 404# CONFIG_NET_VENDOR_3COM is not set
358# CONFIG_LANCE is not set
359# CONFIG_NET_VENDOR_SMC is not set 405# CONFIG_NET_VENDOR_SMC is not set
360# CONFIG_NET_VENDOR_RACAL is not set 406# CONFIG_NET_VENDOR_RACAL is not set
361 407
@@ -369,6 +415,7 @@ CONFIG_TULIP=y
369# CONFIG_DE4X5 is not set 415# CONFIG_DE4X5 is not set
370# CONFIG_WINBOND_840 is not set 416# CONFIG_WINBOND_840 is not set
371# CONFIG_DM9102 is not set 417# CONFIG_DM9102 is not set
418# CONFIG_ULI526X is not set
372# CONFIG_DEPCA is not set 419# CONFIG_DEPCA is not set
373# CONFIG_HP100 is not set 420# CONFIG_HP100 is not set
374# CONFIG_NET_ISA is not set 421# CONFIG_NET_ISA is not set
@@ -384,12 +431,15 @@ CONFIG_TULIP=y
384# CONFIG_NS83820 is not set 431# CONFIG_NS83820 is not set
385# CONFIG_HAMACHI is not set 432# CONFIG_HAMACHI is not set
386# CONFIG_R8169 is not set 433# CONFIG_R8169 is not set
434# CONFIG_SIS190 is not set
387# CONFIG_SK98LIN is not set 435# CONFIG_SK98LIN is not set
388# CONFIG_TIGON3 is not set 436# CONFIG_TIGON3 is not set
437# CONFIG_BNX2 is not set
389 438
390# 439#
391# Ethernet (10000 Mbit) 440# Ethernet (10000 Mbit)
392# 441#
442# CONFIG_CHELSIO_T1 is not set
393# CONFIG_IXGB is not set 443# CONFIG_IXGB is not set
394# CONFIG_S2IO is not set 444# CONFIG_S2IO is not set
395 445
@@ -413,12 +463,12 @@ CONFIG_NET_RADIO=y
413# 463#
414# Wireless 802.11b ISA/PCI cards support 464# Wireless 802.11b ISA/PCI cards support
415# 465#
416# CONFIG_AIRO is not set
417# CONFIG_HERMES is not set 466# CONFIG_HERMES is not set
418 467
419# 468#
420# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support 469# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
421# 470#
471# CONFIG_HOSTAP is not set
422CONFIG_NET_WIRELESS=y 472CONFIG_NET_WIRELESS=y
423 473
424# 474#
@@ -435,6 +485,8 @@ CONFIG_PPP=y
435# CONFIG_PPP_BSDCOMP is not set 485# CONFIG_PPP_BSDCOMP is not set
436# CONFIG_SLIP is not set 486# CONFIG_SLIP is not set
437# CONFIG_NET_FC is not set 487# CONFIG_NET_FC is not set
488# CONFIG_NETPOLL is not set
489# CONFIG_NET_POLL_CONTROLLER is not set
438 490
439# 491#
440# ISDN subsystem 492# ISDN subsystem
@@ -464,23 +516,12 @@ CONFIG_INPUT_EVDEV=y
464# CONFIG_INPUT_EVBUG is not set 516# CONFIG_INPUT_EVBUG is not set
465 517
466# 518#
467# Input I/O drivers
468#
469# CONFIG_GAMEPORT is not set
470CONFIG_SOUND_GAMEPORT=y
471CONFIG_SERIO=y
472# CONFIG_SERIO_SERPORT is not set
473# CONFIG_SERIO_PARKBD is not set
474CONFIG_SERIO_GSCPS2=y
475# CONFIG_HP_SDC is not set
476# CONFIG_SERIO_PCIPS2 is not set
477# CONFIG_SERIO_RAW is not set
478
479#
480# Input Device Drivers 519# Input Device Drivers
481# 520#
482CONFIG_INPUT_KEYBOARD=y 521CONFIG_INPUT_KEYBOARD=y
483# CONFIG_KEYBOARD_ATKBD is not set 522CONFIG_KEYBOARD_ATKBD=y
523CONFIG_KEYBOARD_ATKBD_HP_KEYCODES=y
524# CONFIG_KEYBOARD_ATKBD_RDI_KEYCODES is not set
484# CONFIG_KEYBOARD_SUNKBD is not set 525# CONFIG_KEYBOARD_SUNKBD is not set
485# CONFIG_KEYBOARD_LKKBD is not set 526# CONFIG_KEYBOARD_LKKBD is not set
486# CONFIG_KEYBOARD_XTKBD is not set 527# CONFIG_KEYBOARD_XTKBD is not set
@@ -488,7 +529,7 @@ CONFIG_INPUT_KEYBOARD=y
488# CONFIG_KEYBOARD_HIL_OLD is not set 529# CONFIG_KEYBOARD_HIL_OLD is not set
489# CONFIG_KEYBOARD_HIL is not set 530# CONFIG_KEYBOARD_HIL is not set
490CONFIG_INPUT_MOUSE=y 531CONFIG_INPUT_MOUSE=y
491# CONFIG_MOUSE_PS2 is not set 532CONFIG_MOUSE_PS2=y
492# CONFIG_MOUSE_SERIAL is not set 533# CONFIG_MOUSE_SERIAL is not set
493# CONFIG_MOUSE_INPORT is not set 534# CONFIG_MOUSE_INPORT is not set
494# CONFIG_MOUSE_LOGIBM is not set 535# CONFIG_MOUSE_LOGIBM is not set
@@ -502,6 +543,19 @@ CONFIG_INPUT_MISC=y
502# CONFIG_HP_SDC_RTC is not set 543# CONFIG_HP_SDC_RTC is not set
503 544
504# 545#
546# Hardware I/O ports
547#
548CONFIG_SERIO=y
549# CONFIG_SERIO_SERPORT is not set
550# CONFIG_SERIO_PARKBD is not set
551CONFIG_SERIO_GSCPS2=y
552# CONFIG_HP_SDC is not set
553# CONFIG_SERIO_PCIPS2 is not set
554CONFIG_SERIO_LIBPS2=y
555# CONFIG_SERIO_RAW is not set
556# CONFIG_GAMEPORT is not set
557
558#
505# Character devices 559# Character devices
506# 560#
507CONFIG_VT=y 561CONFIG_VT=y
@@ -519,8 +573,11 @@ CONFIG_SERIAL_8250_EXTENDED=y
519CONFIG_SERIAL_8250_MANY_PORTS=y 573CONFIG_SERIAL_8250_MANY_PORTS=y
520CONFIG_SERIAL_8250_SHARE_IRQ=y 574CONFIG_SERIAL_8250_SHARE_IRQ=y
521# CONFIG_SERIAL_8250_DETECT_IRQ is not set 575# CONFIG_SERIAL_8250_DETECT_IRQ is not set
522# CONFIG_SERIAL_8250_MULTIPORT is not set
523# CONFIG_SERIAL_8250_RSA is not set 576# CONFIG_SERIAL_8250_RSA is not set
577# CONFIG_SERIAL_8250_FOURPORT is not set
578# CONFIG_SERIAL_8250_ACCENT is not set
579# CONFIG_SERIAL_8250_BOCA is not set
580# CONFIG_SERIAL_8250_HUB6 is not set
524 581
525# 582#
526# Non-8250 serial port support 583# Non-8250 serial port support
@@ -529,6 +586,7 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
529# CONFIG_PDC_CONSOLE is not set 586# CONFIG_PDC_CONSOLE is not set
530CONFIG_SERIAL_CORE=y 587CONFIG_SERIAL_CORE=y
531CONFIG_SERIAL_CORE_CONSOLE=y 588CONFIG_SERIAL_CORE_CONSOLE=y
589# CONFIG_SERIAL_JSM is not set
532CONFIG_UNIX98_PTYS=y 590CONFIG_UNIX98_PTYS=y
533CONFIG_LEGACY_PTYS=y 591CONFIG_LEGACY_PTYS=y
534CONFIG_LEGACY_PTY_COUNT=256 592CONFIG_LEGACY_PTY_COUNT=256
@@ -555,11 +613,14 @@ CONFIG_GEN_RTC=y
555# 613#
556# Ftape, the floppy tape device driver 614# Ftape, the floppy tape device driver
557# 615#
558# CONFIG_AGP is not set
559# CONFIG_DRM is not set 616# CONFIG_DRM is not set
560# CONFIG_RAW_DRIVER is not set 617# CONFIG_RAW_DRIVER is not set
561 618
562# 619#
620# TPM devices
621#
622
623#
563# I2C support 624# I2C support
564# 625#
565# CONFIG_I2C is not set 626# CONFIG_I2C is not set
@@ -570,10 +631,20 @@ CONFIG_GEN_RTC=y
570# CONFIG_W1 is not set 631# CONFIG_W1 is not set
571 632
572# 633#
634# Hardware Monitoring support
635#
636# CONFIG_HWMON is not set
637# CONFIG_HWMON_VID is not set
638
639#
573# Misc devices 640# Misc devices
574# 641#
575 642
576# 643#
644# Multimedia Capabilities Port drivers
645#
646
647#
577# Multimedia devices 648# Multimedia devices
578# 649#
579# CONFIG_VIDEO_DEV is not set 650# CONFIG_VIDEO_DEV is not set
@@ -587,6 +658,11 @@ CONFIG_GEN_RTC=y
587# Graphics support 658# Graphics support
588# 659#
589CONFIG_FB=y 660CONFIG_FB=y
661CONFIG_FB_CFB_FILLRECT=y
662CONFIG_FB_CFB_COPYAREA=y
663CONFIG_FB_CFB_IMAGEBLIT=y
664CONFIG_FB_SOFT_CURSOR=y
665# CONFIG_FB_MACMODES is not set
590# CONFIG_FB_MODE_HELPERS is not set 666# CONFIG_FB_MODE_HELPERS is not set
591# CONFIG_FB_TILEBLITTING is not set 667# CONFIG_FB_TILEBLITTING is not set
592# CONFIG_FB_CIRRUS is not set 668# CONFIG_FB_CIRRUS is not set
@@ -595,6 +671,7 @@ CONFIG_FB=y
595# CONFIG_FB_ASILIANT is not set 671# CONFIG_FB_ASILIANT is not set
596# CONFIG_FB_IMSTT is not set 672# CONFIG_FB_IMSTT is not set
597CONFIG_FB_STI=y 673CONFIG_FB_STI=y
674# CONFIG_FB_NVIDIA is not set
598# CONFIG_FB_RIVA is not set 675# CONFIG_FB_RIVA is not set
599# CONFIG_FB_MATROX is not set 676# CONFIG_FB_MATROX is not set
600# CONFIG_FB_RADEON_OLD is not set 677# CONFIG_FB_RADEON_OLD is not set
@@ -606,18 +683,19 @@ CONFIG_FB_STI=y
606# CONFIG_FB_KYRO is not set 683# CONFIG_FB_KYRO is not set
607# CONFIG_FB_3DFX is not set 684# CONFIG_FB_3DFX is not set
608# CONFIG_FB_VOODOO1 is not set 685# CONFIG_FB_VOODOO1 is not set
686# CONFIG_FB_CYBLA is not set
609# CONFIG_FB_TRIDENT is not set 687# CONFIG_FB_TRIDENT is not set
688# CONFIG_FB_S1D13XXX is not set
610# CONFIG_FB_VIRTUAL is not set 689# CONFIG_FB_VIRTUAL is not set
611 690
612# 691#
613# Console display driver support 692# Console display driver support
614# 693#
615# CONFIG_MDA_CONSOLE is not set 694CONFIG_DUMMY_CONSOLE=y
616CONFIG_STI_CONSOLE=y
617CONFIG_DUMMY_CONSOLE_COLUMNS=160 695CONFIG_DUMMY_CONSOLE_COLUMNS=160
618CONFIG_DUMMY_CONSOLE_ROWS=64 696CONFIG_DUMMY_CONSOLE_ROWS=64
619CONFIG_DUMMY_CONSOLE=y
620CONFIG_FRAMEBUFFER_CONSOLE=y 697CONFIG_FRAMEBUFFER_CONSOLE=y
698CONFIG_STI_CONSOLE=y
621# CONFIG_FONTS is not set 699# CONFIG_FONTS is not set
622CONFIG_FONT_8x8=y 700CONFIG_FONT_8x8=y
623CONFIG_FONT_8x16=y 701CONFIG_FONT_8x16=y
@@ -630,6 +708,7 @@ CONFIG_LOGO_LINUX_MONO=y
630CONFIG_LOGO_LINUX_VGA16=y 708CONFIG_LOGO_LINUX_VGA16=y
631CONFIG_LOGO_LINUX_CLUT224=y 709CONFIG_LOGO_LINUX_CLUT224=y
632CONFIG_LOGO_PARISC_CLUT224=y 710CONFIG_LOGO_PARISC_CLUT224=y
711# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
633 712
634# 713#
635# Sound 714# Sound
@@ -639,13 +718,9 @@ CONFIG_LOGO_PARISC_CLUT224=y
639# 718#
640# USB support 719# USB support
641# 720#
642# CONFIG_USB is not set
643CONFIG_USB_ARCH_HAS_HCD=y 721CONFIG_USB_ARCH_HAS_HCD=y
644CONFIG_USB_ARCH_HAS_OHCI=y 722CONFIG_USB_ARCH_HAS_OHCI=y
645 723# CONFIG_USB is not set
646#
647# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
648#
649 724
650# 725#
651# USB Gadget Support 726# USB Gadget Support
@@ -658,23 +733,36 @@ CONFIG_USB_ARCH_HAS_OHCI=y
658# CONFIG_MMC is not set 733# CONFIG_MMC is not set
659 734
660# 735#
736# InfiniBand support
737#
738# CONFIG_INFINIBAND is not set
739
740#
741# SN Devices
742#
743
744#
661# File systems 745# File systems
662# 746#
663CONFIG_EXT2_FS=y 747CONFIG_EXT2_FS=y
664# CONFIG_EXT2_FS_XATTR is not set 748# CONFIG_EXT2_FS_XATTR is not set
749# CONFIG_EXT2_FS_XIP is not set
665CONFIG_EXT3_FS=y 750CONFIG_EXT3_FS=y
666# CONFIG_EXT3_FS_XATTR is not set 751# CONFIG_EXT3_FS_XATTR is not set
667CONFIG_JBD=y 752CONFIG_JBD=y
668# CONFIG_JBD_DEBUG is not set 753# CONFIG_JBD_DEBUG is not set
669# CONFIG_REISERFS_FS is not set 754# CONFIG_REISERFS_FS is not set
670# CONFIG_JFS_FS is not set 755# CONFIG_JFS_FS is not set
756# CONFIG_FS_POSIX_ACL is not set
671# CONFIG_XFS_FS is not set 757# CONFIG_XFS_FS is not set
672# CONFIG_MINIX_FS is not set 758# CONFIG_MINIX_FS is not set
673# CONFIG_ROMFS_FS is not set 759# CONFIG_ROMFS_FS is not set
760CONFIG_INOTIFY=y
674# CONFIG_QUOTA is not set 761# CONFIG_QUOTA is not set
675CONFIG_DNOTIFY=y 762CONFIG_DNOTIFY=y
676# CONFIG_AUTOFS_FS is not set 763# CONFIG_AUTOFS_FS is not set
677CONFIG_AUTOFS4_FS=y 764CONFIG_AUTOFS4_FS=y
765# CONFIG_FUSE_FS is not set
678 766
679# 767#
680# CD-ROM/DVD Filesystems 768# CD-ROM/DVD Filesystems
@@ -697,11 +785,10 @@ CONFIG_JOLIET=y
697CONFIG_PROC_FS=y 785CONFIG_PROC_FS=y
698CONFIG_PROC_KCORE=y 786CONFIG_PROC_KCORE=y
699CONFIG_SYSFS=y 787CONFIG_SYSFS=y
700# CONFIG_DEVPTS_FS_XATTR is not set
701CONFIG_TMPFS=y 788CONFIG_TMPFS=y
702# CONFIG_TMPFS_XATTR is not set
703# CONFIG_HUGETLB_PAGE is not set 789# CONFIG_HUGETLB_PAGE is not set
704CONFIG_RAMFS=y 790CONFIG_RAMFS=y
791# CONFIG_RELAYFS_FS is not set
705 792
706# 793#
707# Miscellaneous filesystems 794# Miscellaneous filesystems
@@ -719,15 +806,19 @@ CONFIG_RAMFS=y
719# 806#
720CONFIG_NFS_FS=y 807CONFIG_NFS_FS=y
721CONFIG_NFS_V3=y 808CONFIG_NFS_V3=y
809# CONFIG_NFS_V3_ACL is not set
722CONFIG_NFSD=y 810CONFIG_NFSD=y
723CONFIG_NFSD_V3=y 811CONFIG_NFSD_V3=y
812# CONFIG_NFSD_V3_ACL is not set
724CONFIG_NFSD_TCP=y 813CONFIG_NFSD_TCP=y
725CONFIG_ROOT_NFS=y 814CONFIG_ROOT_NFS=y
726CONFIG_LOCKD=y 815CONFIG_LOCKD=y
727CONFIG_LOCKD_V4=y 816CONFIG_LOCKD_V4=y
728CONFIG_EXPORTFS=y 817CONFIG_EXPORTFS=y
818CONFIG_NFS_COMMON=y
729CONFIG_SUNRPC=y 819CONFIG_SUNRPC=y
730# CONFIG_SMB_FS is not set 820CONFIG_SMB_FS=y
821# CONFIG_SMB_NLS_DEFAULT is not set
731# CONFIG_CIFS is not set 822# CONFIG_CIFS is not set
732# CONFIG_NCP_FS is not set 823# CONFIG_NCP_FS is not set
733# CONFIG_CODA_FS is not set 824# CONFIG_CODA_FS is not set
@@ -785,13 +876,19 @@ CONFIG_NLS_DEFAULT="iso8859-1"
785# 876#
786# Kernel hacking 877# Kernel hacking
787# 878#
879# CONFIG_PRINTK_TIME is not set
788CONFIG_DEBUG_KERNEL=y 880CONFIG_DEBUG_KERNEL=y
789CONFIG_MAGIC_SYSRQ=y 881CONFIG_MAGIC_SYSRQ=y
882CONFIG_LOG_BUF_SHIFT=16
883CONFIG_DETECT_SOFTLOCKUP=y
790# CONFIG_SCHEDSTATS is not set 884# CONFIG_SCHEDSTATS is not set
791# CONFIG_DEBUG_SLAB is not set 885# CONFIG_DEBUG_SLAB is not set
792# CONFIG_DEBUG_SPINLOCK is not set 886# CONFIG_DEBUG_SPINLOCK is not set
887# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
793# CONFIG_DEBUG_KOBJECT is not set 888# CONFIG_DEBUG_KOBJECT is not set
794# CONFIG_DEBUG_INFO is not set 889# CONFIG_DEBUG_INFO is not set
890# CONFIG_DEBUG_IOREMAP is not set
891# CONFIG_DEBUG_FS is not set
795 892
796# 893#
797# Security options 894# Security options
@@ -815,6 +912,7 @@ CONFIG_CRYPTO=y
815# CONFIG_CRYPTO_SHA256 is not set 912# CONFIG_CRYPTO_SHA256 is not set
816# CONFIG_CRYPTO_SHA512 is not set 913# CONFIG_CRYPTO_SHA512 is not set
817# CONFIG_CRYPTO_WP512 is not set 914# CONFIG_CRYPTO_WP512 is not set
915# CONFIG_CRYPTO_TGR192 is not set
818# CONFIG_CRYPTO_DES is not set 916# CONFIG_CRYPTO_DES is not set
819# CONFIG_CRYPTO_BLOWFISH is not set 917# CONFIG_CRYPTO_BLOWFISH is not set
820# CONFIG_CRYPTO_TWOFISH is not set 918# CONFIG_CRYPTO_TWOFISH is not set
@@ -832,8 +930,13 @@ CONFIG_CRYPTO=y
832# CONFIG_CRYPTO_TEST is not set 930# CONFIG_CRYPTO_TEST is not set
833 931
834# 932#
933# Hardware crypto devices
934#
935
936#
835# Library routines 937# Library routines
836# 938#
837# CONFIG_CRC_CCITT is not set 939# CONFIG_CRC_CCITT is not set
940# CONFIG_CRC16 is not set
838CONFIG_CRC32=y 941CONFIG_CRC32=y
839# CONFIG_LIBCRC32C is not set 942# CONFIG_LIBCRC32C is not set
diff --git a/arch/parisc/configs/c3000_defconfig b/arch/parisc/configs/c3000_defconfig
index 67aca6ccc9b0..9d86b6b1ebd1 100644
--- a/arch/parisc/configs/c3000_defconfig
+++ b/arch/parisc/configs/c3000_defconfig
@@ -1,12 +1,16 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.10-pa5 3# Linux kernel version: 2.6.14-rc5-pa1
4# Wed Jan 5 13:26:49 2005 4# Fri Oct 21 23:06:31 2005
5# 5#
6CONFIG_PARISC=y 6CONFIG_PARISC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
8CONFIG_STACK_GROWSUP=y 8CONFIG_STACK_GROWSUP=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_GENERIC_IRQ_PROBE=y
13CONFIG_ARCH_MAY_HAVE_PC_FDC=y
10 14
11# 15#
12# Code maturity level options 16# Code maturity level options
@@ -15,26 +19,31 @@ CONFIG_EXPERIMENTAL=y
15# CONFIG_CLEAN_COMPILE is not set 19# CONFIG_CLEAN_COMPILE is not set
16CONFIG_BROKEN=y 20CONFIG_BROKEN=y
17CONFIG_BROKEN_ON_SMP=y 21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
18 23
19# 24#
20# General setup 25# General setup
21# 26#
22CONFIG_LOCALVERSION="" 27CONFIG_LOCALVERSION=""
28# CONFIG_LOCALVERSION_AUTO is not set
23CONFIG_SWAP=y 29CONFIG_SWAP=y
24CONFIG_SYSVIPC=y 30CONFIG_SYSVIPC=y
25# CONFIG_POSIX_MQUEUE is not set 31# CONFIG_POSIX_MQUEUE is not set
26# CONFIG_BSD_PROCESS_ACCT is not set 32# CONFIG_BSD_PROCESS_ACCT is not set
27CONFIG_SYSCTL=y 33CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 34# CONFIG_AUDIT is not set
29CONFIG_LOG_BUF_SHIFT=16
30CONFIG_HOTPLUG=y 35CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y 36CONFIG_KOBJECT_UEVENT=y
32CONFIG_IKCONFIG=y 37CONFIG_IKCONFIG=y
33CONFIG_IKCONFIG_PROC=y 38CONFIG_IKCONFIG_PROC=y
39CONFIG_INITRAMFS_SOURCE=""
34CONFIG_EMBEDDED=y 40CONFIG_EMBEDDED=y
35CONFIG_KALLSYMS=y 41CONFIG_KALLSYMS=y
36CONFIG_KALLSYMS_ALL=y 42CONFIG_KALLSYMS_ALL=y
37# CONFIG_KALLSYMS_EXTRA_PASS is not set 43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_BASE_FULL=y
38CONFIG_FUTEX=y 47CONFIG_FUTEX=y
39CONFIG_EPOLL=y 48CONFIG_EPOLL=y
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 49# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +53,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 53CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 54CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 55# CONFIG_TINY_SHMEM is not set
56CONFIG_BASE_SMALL=0
47 57
48# 58#
49# Loadable module support 59# Loadable module support
@@ -66,10 +76,19 @@ CONFIG_KMOD=y
66CONFIG_PA8X00=y 76CONFIG_PA8X00=y
67CONFIG_PA20=y 77CONFIG_PA20=y
68CONFIG_PREFETCH=y 78CONFIG_PREFETCH=y
69# CONFIG_PARISC64 is not set
70# CONFIG_64BIT is not set 79# CONFIG_64BIT is not set
71# CONFIG_SMP is not set 80# CONFIG_SMP is not set
72# CONFIG_DISCONTIGMEM is not set 81# CONFIG_HZ_100 is not set
82CONFIG_HZ_250=y
83# CONFIG_HZ_1000 is not set
84CONFIG_HZ=250
85CONFIG_SELECT_MEMORY_MODEL=y
86CONFIG_FLATMEM_MANUAL=y
87# CONFIG_DISCONTIGMEM_MANUAL is not set
88# CONFIG_SPARSEMEM_MANUAL is not set
89CONFIG_FLATMEM=y
90CONFIG_FLAT_NODE_MEM_MAP=y
91# CONFIG_SPARSEMEM_STATIC is not set
73# CONFIG_PREEMPT is not set 92# CONFIG_PREEMPT is not set
74# CONFIG_HPUX is not set 93# CONFIG_HPUX is not set
75 94
@@ -79,13 +98,10 @@ CONFIG_PREFETCH=y
79# CONFIG_GSC is not set 98# CONFIG_GSC is not set
80CONFIG_PCI=y 99CONFIG_PCI=y
81CONFIG_PCI_LEGACY_PROC=y 100CONFIG_PCI_LEGACY_PROC=y
82CONFIG_PCI_NAMES=y 101# CONFIG_PCI_DEBUG is not set
83CONFIG_PCI_LBA=y 102CONFIG_PCI_LBA=y
84CONFIG_IOSAPIC=y 103CONFIG_IOSAPIC=y
85CONFIG_IOMMU_SBA=y 104CONFIG_IOMMU_SBA=y
86CONFIG_SUPERIO=y
87CONFIG_CHASSIS_LCD_LED=y
88# CONFIG_PDC_CHASSIS is not set
89 105
90# 106#
91# PCCARD (PCMCIA/CardBus) support 107# PCCARD (PCMCIA/CardBus) support
@@ -93,13 +109,17 @@ CONFIG_CHASSIS_LCD_LED=y
93# CONFIG_PCCARD is not set 109# CONFIG_PCCARD is not set
94 110
95# 111#
96# PC-card bridges 112# PCI Hotplug Support
97# 113#
114# CONFIG_HOTPLUG_PCI is not set
98 115
99# 116#
100# PCI Hotplug Support 117# PA-RISC specific drivers
101# 118#
102# CONFIG_HOTPLUG_PCI is not set 119CONFIG_SUPERIO=y
120CONFIG_CHASSIS_LCD_LED=y
121# CONFIG_PDC_CHASSIS is not set
122CONFIG_PDC_STABLE=y
103 123
104# 124#
105# Executable file formats 125# Executable file formats
@@ -108,6 +128,186 @@ CONFIG_BINFMT_ELF=y
108# CONFIG_BINFMT_MISC is not set 128# CONFIG_BINFMT_MISC is not set
109 129
110# 130#
131# Networking
132#
133CONFIG_NET=y
134
135#
136# Networking options
137#
138CONFIG_PACKET=y
139CONFIG_PACKET_MMAP=y
140CONFIG_UNIX=y
141CONFIG_XFRM=y
142CONFIG_XFRM_USER=m
143CONFIG_NET_KEY=m
144CONFIG_INET=y
145CONFIG_IP_MULTICAST=y
146# CONFIG_IP_ADVANCED_ROUTER is not set
147CONFIG_IP_FIB_HASH=y
148CONFIG_IP_PNP=y
149# CONFIG_IP_PNP_DHCP is not set
150CONFIG_IP_PNP_BOOTP=y
151# CONFIG_IP_PNP_RARP is not set
152# CONFIG_NET_IPIP is not set
153# CONFIG_NET_IPGRE is not set
154# CONFIG_IP_MROUTE is not set
155# CONFIG_ARPD is not set
156# CONFIG_SYN_COOKIES is not set
157# CONFIG_INET_AH is not set
158# CONFIG_INET_ESP is not set
159# CONFIG_INET_IPCOMP is not set
160# CONFIG_INET_TUNNEL is not set
161# CONFIG_INET_DIAG is not set
162# CONFIG_TCP_CONG_ADVANCED is not set
163CONFIG_TCP_CONG_BIC=y
164
165#
166# IP: Virtual Server Configuration
167#
168# CONFIG_IP_VS is not set
169CONFIG_IPV6=m
170# CONFIG_IPV6_PRIVACY is not set
171# CONFIG_INET6_AH is not set
172# CONFIG_INET6_ESP is not set
173CONFIG_INET6_IPCOMP=m
174CONFIG_INET6_TUNNEL=m
175CONFIG_IPV6_TUNNEL=m
176CONFIG_NETFILTER=y
177CONFIG_NETFILTER_DEBUG=y
178# CONFIG_NETFILTER_NETLINK is not set
179
180#
181# IP: Netfilter Configuration
182#
183CONFIG_IP_NF_CONNTRACK=m
184# CONFIG_IP_NF_CT_ACCT is not set
185# CONFIG_IP_NF_CONNTRACK_MARK is not set
186# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
187# CONFIG_IP_NF_CT_PROTO_SCTP is not set
188CONFIG_IP_NF_FTP=m
189CONFIG_IP_NF_IRC=m
190# CONFIG_IP_NF_NETBIOS_NS is not set
191CONFIG_IP_NF_TFTP=m
192CONFIG_IP_NF_AMANDA=m
193# CONFIG_IP_NF_PPTP is not set
194CONFIG_IP_NF_QUEUE=m
195CONFIG_IP_NF_IPTABLES=m
196CONFIG_IP_NF_MATCH_LIMIT=m
197CONFIG_IP_NF_MATCH_IPRANGE=m
198CONFIG_IP_NF_MATCH_MAC=m
199CONFIG_IP_NF_MATCH_PKTTYPE=m
200CONFIG_IP_NF_MATCH_MARK=m
201CONFIG_IP_NF_MATCH_MULTIPORT=m
202CONFIG_IP_NF_MATCH_TOS=m
203CONFIG_IP_NF_MATCH_RECENT=m
204CONFIG_IP_NF_MATCH_ECN=m
205CONFIG_IP_NF_MATCH_DSCP=m
206CONFIG_IP_NF_MATCH_AH_ESP=m
207CONFIG_IP_NF_MATCH_LENGTH=m
208CONFIG_IP_NF_MATCH_TTL=m
209CONFIG_IP_NF_MATCH_TCPMSS=m
210CONFIG_IP_NF_MATCH_HELPER=m
211CONFIG_IP_NF_MATCH_STATE=m
212CONFIG_IP_NF_MATCH_CONNTRACK=m
213CONFIG_IP_NF_MATCH_OWNER=m
214# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
215# CONFIG_IP_NF_MATCH_REALM is not set
216# CONFIG_IP_NF_MATCH_SCTP is not set
217# CONFIG_IP_NF_MATCH_DCCP is not set
218# CONFIG_IP_NF_MATCH_COMMENT is not set
219# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
220# CONFIG_IP_NF_MATCH_STRING is not set
221CONFIG_IP_NF_FILTER=m
222CONFIG_IP_NF_TARGET_REJECT=m
223CONFIG_IP_NF_TARGET_LOG=m
224CONFIG_IP_NF_TARGET_ULOG=m
225CONFIG_IP_NF_TARGET_TCPMSS=m
226# CONFIG_IP_NF_TARGET_NFQUEUE is not set
227CONFIG_IP_NF_NAT=m
228CONFIG_IP_NF_NAT_NEEDED=y
229CONFIG_IP_NF_TARGET_MASQUERADE=m
230CONFIG_IP_NF_TARGET_REDIRECT=m
231CONFIG_IP_NF_TARGET_NETMAP=m
232CONFIG_IP_NF_TARGET_SAME=m
233CONFIG_IP_NF_NAT_SNMP_BASIC=m
234CONFIG_IP_NF_NAT_IRC=m
235CONFIG_IP_NF_NAT_FTP=m
236CONFIG_IP_NF_NAT_TFTP=m
237CONFIG_IP_NF_NAT_AMANDA=m
238CONFIG_IP_NF_MANGLE=m
239CONFIG_IP_NF_TARGET_TOS=m
240CONFIG_IP_NF_TARGET_ECN=m
241CONFIG_IP_NF_TARGET_DSCP=m
242CONFIG_IP_NF_TARGET_MARK=m
243CONFIG_IP_NF_TARGET_CLASSIFY=m
244# CONFIG_IP_NF_TARGET_TTL is not set
245# CONFIG_IP_NF_RAW is not set
246CONFIG_IP_NF_ARPTABLES=m
247CONFIG_IP_NF_ARPFILTER=m
248CONFIG_IP_NF_ARP_MANGLE=m
249
250#
251# IPv6: Netfilter Configuration (EXPERIMENTAL)
252#
253# CONFIG_IP6_NF_QUEUE is not set
254CONFIG_IP6_NF_IPTABLES=m
255# CONFIG_IP6_NF_MATCH_LIMIT is not set
256CONFIG_IP6_NF_MATCH_MAC=m
257CONFIG_IP6_NF_MATCH_RT=m
258# CONFIG_IP6_NF_MATCH_OPTS is not set
259# CONFIG_IP6_NF_MATCH_FRAG is not set
260# CONFIG_IP6_NF_MATCH_HL is not set
261# CONFIG_IP6_NF_MATCH_MULTIPORT is not set
262CONFIG_IP6_NF_MATCH_OWNER=m
263# CONFIG_IP6_NF_MATCH_MARK is not set
264CONFIG_IP6_NF_MATCH_IPV6HEADER=m
265# CONFIG_IP6_NF_MATCH_AHESP is not set
266CONFIG_IP6_NF_MATCH_LENGTH=m
267# CONFIG_IP6_NF_MATCH_EUI64 is not set
268CONFIG_IP6_NF_FILTER=m
269CONFIG_IP6_NF_TARGET_LOG=m
270CONFIG_IP6_NF_TARGET_REJECT=m
271# CONFIG_IP6_NF_TARGET_NFQUEUE is not set
272CONFIG_IP6_NF_MANGLE=m
273# CONFIG_IP6_NF_TARGET_MARK is not set
274# CONFIG_IP6_NF_TARGET_HL is not set
275# CONFIG_IP6_NF_RAW is not set
276
277#
278# DCCP Configuration (EXPERIMENTAL)
279#
280# CONFIG_IP_DCCP is not set
281
282#
283# SCTP Configuration (EXPERIMENTAL)
284#
285# CONFIG_IP_SCTP is not set
286# CONFIG_ATM is not set
287# CONFIG_BRIDGE is not set
288# CONFIG_VLAN_8021Q is not set
289# CONFIG_DECNET is not set
290# CONFIG_LLC2 is not set
291# CONFIG_IPX is not set
292# CONFIG_ATALK is not set
293# CONFIG_X25 is not set
294# CONFIG_LAPB is not set
295# CONFIG_NET_DIVERT is not set
296# CONFIG_ECONET is not set
297# CONFIG_WAN_ROUTER is not set
298# CONFIG_NET_SCHED is not set
299# CONFIG_NET_CLS_ROUTE is not set
300
301#
302# Network testing
303#
304CONFIG_NET_PKTGEN=m
305# CONFIG_HAMRADIO is not set
306# CONFIG_IRDA is not set
307# CONFIG_BT is not set
308# CONFIG_IEEE80211 is not set
309
310#
111# Device Drivers 311# Device Drivers
112# 312#
113 313
@@ -120,6 +320,11 @@ CONFIG_FW_LOADER=y
120# CONFIG_DEBUG_DRIVER is not set 320# CONFIG_DEBUG_DRIVER is not set
121 321
122# 322#
323# Connector - unified userspace <-> kernelspace linker
324#
325# CONFIG_CONNECTOR is not set
326
327#
123# Memory Technology Devices (MTD) 328# Memory Technology Devices (MTD)
124# 329#
125# CONFIG_MTD is not set 330# CONFIG_MTD is not set
@@ -141,14 +346,14 @@ CONFIG_FW_LOADER=y
141# CONFIG_BLK_CPQ_CISS_DA is not set 346# CONFIG_BLK_CPQ_CISS_DA is not set
142# CONFIG_BLK_DEV_DAC960 is not set 347# CONFIG_BLK_DEV_DAC960 is not set
143CONFIG_BLK_DEV_UMEM=m 348CONFIG_BLK_DEV_UMEM=m
349# CONFIG_BLK_DEV_COW_COMMON is not set
144CONFIG_BLK_DEV_LOOP=y 350CONFIG_BLK_DEV_LOOP=y
145# CONFIG_BLK_DEV_CRYPTOLOOP is not set 351CONFIG_BLK_DEV_CRYPTOLOOP=m
146# CONFIG_BLK_DEV_NBD is not set 352# CONFIG_BLK_DEV_NBD is not set
147# CONFIG_BLK_DEV_SX8 is not set 353# CONFIG_BLK_DEV_SX8 is not set
148# CONFIG_BLK_DEV_UB is not set 354# CONFIG_BLK_DEV_UB is not set
149# CONFIG_BLK_DEV_RAM is not set 355# CONFIG_BLK_DEV_RAM is not set
150CONFIG_BLK_DEV_RAM_COUNT=16 356CONFIG_BLK_DEV_RAM_COUNT=16
151CONFIG_INITRAMFS_SOURCE=""
152# CONFIG_CDROM_PKTCDVD is not set 357# CONFIG_CDROM_PKTCDVD is not set
153 358
154# 359#
@@ -158,6 +363,7 @@ CONFIG_IOSCHED_NOOP=y
158CONFIG_IOSCHED_AS=y 363CONFIG_IOSCHED_AS=y
159CONFIG_IOSCHED_DEADLINE=y 364CONFIG_IOSCHED_DEADLINE=y
160CONFIG_IOSCHED_CFQ=y 365CONFIG_IOSCHED_CFQ=y
366# CONFIG_ATA_OVER_ETH is not set
161 367
162# 368#
163# ATA/ATAPI/MFM/RLL support 369# ATA/ATAPI/MFM/RLL support
@@ -201,6 +407,7 @@ CONFIG_BLK_DEV_IDEDMA_PCI=y
201# CONFIG_BLK_DEV_HPT366 is not set 407# CONFIG_BLK_DEV_HPT366 is not set
202# CONFIG_BLK_DEV_SC1200 is not set 408# CONFIG_BLK_DEV_SC1200 is not set
203# CONFIG_BLK_DEV_PIIX is not set 409# CONFIG_BLK_DEV_PIIX is not set
410# CONFIG_BLK_DEV_IT821X is not set
204CONFIG_BLK_DEV_NS87415=y 411CONFIG_BLK_DEV_NS87415=y
205# CONFIG_BLK_DEV_PDC202XX_OLD is not set 412# CONFIG_BLK_DEV_PDC202XX_OLD is not set
206# CONFIG_BLK_DEV_PDC202XX_NEW is not set 413# CONFIG_BLK_DEV_PDC202XX_NEW is not set
@@ -218,6 +425,7 @@ CONFIG_BLK_DEV_IDEDMA=y
218# 425#
219# SCSI device support 426# SCSI device support
220# 427#
428# CONFIG_RAID_ATTRS is not set
221CONFIG_SCSI=y 429CONFIG_SCSI=y
222CONFIG_SCSI_PROC_FS=y 430CONFIG_SCSI_PROC_FS=y
223 431
@@ -230,6 +438,7 @@ CONFIG_CHR_DEV_ST=y
230CONFIG_BLK_DEV_SR=y 438CONFIG_BLK_DEV_SR=y
231# CONFIG_BLK_DEV_SR_VENDOR is not set 439# CONFIG_BLK_DEV_SR_VENDOR is not set
232CONFIG_CHR_DEV_SG=y 440CONFIG_CHR_DEV_SG=y
441# CONFIG_CHR_DEV_SCH is not set
233 442
234# 443#
235# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 444# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -242,7 +451,9 @@ CONFIG_SCSI_MULTI_LUN=y
242# SCSI Transport Attributes 451# SCSI Transport Attributes
243# 452#
244CONFIG_SCSI_SPI_ATTRS=y 453CONFIG_SCSI_SPI_ATTRS=y
245CONFIG_SCSI_FC_ATTRS=m 454# CONFIG_SCSI_FC_ATTRS is not set
455CONFIG_SCSI_ISCSI_ATTRS=m
456# CONFIG_SCSI_SAS_ATTRS is not set
246 457
247# 458#
248# SCSI low-level drivers 459# SCSI low-level drivers
@@ -258,25 +469,26 @@ CONFIG_SCSI_FC_ATTRS=m
258# CONFIG_SCSI_ADVANSYS is not set 469# CONFIG_SCSI_ADVANSYS is not set
259# CONFIG_MEGARAID_NEWGEN is not set 470# CONFIG_MEGARAID_NEWGEN is not set
260# CONFIG_MEGARAID_LEGACY is not set 471# CONFIG_MEGARAID_LEGACY is not set
472# CONFIG_MEGARAID_SAS is not set
261CONFIG_SCSI_SATA=y 473CONFIG_SCSI_SATA=y
262# CONFIG_SCSI_SATA_AHCI is not set 474# CONFIG_SCSI_SATA_AHCI is not set
263# CONFIG_SCSI_SATA_SVW is not set 475# CONFIG_SCSI_SATA_SVW is not set
264CONFIG_SCSI_ATA_PIIX=m 476CONFIG_SCSI_ATA_PIIX=m
477# CONFIG_SCSI_SATA_MV is not set
265# CONFIG_SCSI_SATA_NV is not set 478# CONFIG_SCSI_SATA_NV is not set
266CONFIG_SCSI_SATA_PROMISE=m 479CONFIG_SCSI_SATA_PROMISE=m
480# CONFIG_SCSI_SATA_QSTOR is not set
267# CONFIG_SCSI_SATA_SX4 is not set 481# CONFIG_SCSI_SATA_SX4 is not set
268CONFIG_SCSI_SATA_SIL=m 482CONFIG_SCSI_SATA_SIL=m
269# CONFIG_SCSI_SATA_SIS is not set 483# CONFIG_SCSI_SATA_SIS is not set
270# CONFIG_SCSI_SATA_ULI is not set 484# CONFIG_SCSI_SATA_ULI is not set
271CONFIG_SCSI_SATA_VIA=m 485CONFIG_SCSI_SATA_VIA=m
272# CONFIG_SCSI_SATA_VITESSE is not set 486# CONFIG_SCSI_SATA_VITESSE is not set
273# CONFIG_SCSI_BUSLOGIC is not set 487CONFIG_SCSI_SATA_INTEL_COMBINED=y
274# CONFIG_SCSI_CPQFCTS is not set 488# CONFIG_SCSI_CPQFCTS is not set
275# CONFIG_SCSI_DMX3191D is not set 489# CONFIG_SCSI_DMX3191D is not set
276# CONFIG_SCSI_EATA is not set
277# CONFIG_SCSI_EATA_PIO is not set 490# CONFIG_SCSI_EATA_PIO is not set
278# CONFIG_SCSI_FUTURE_DOMAIN is not set 491# CONFIG_SCSI_FUTURE_DOMAIN is not set
279# CONFIG_SCSI_GDTH is not set
280# CONFIG_SCSI_IPS is not set 492# CONFIG_SCSI_IPS is not set
281# CONFIG_SCSI_INITIO is not set 493# CONFIG_SCSI_INITIO is not set
282# CONFIG_SCSI_INIA100 is not set 494# CONFIG_SCSI_INIA100 is not set
@@ -286,20 +498,17 @@ CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
286CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 498CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
287# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set 499# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
288# CONFIG_SCSI_IPR is not set 500# CONFIG_SCSI_IPR is not set
289# CONFIG_SCSI_PCI2000 is not set
290# CONFIG_SCSI_PCI2220I is not set
291# CONFIG_SCSI_QLOGIC_ISP is not set 501# CONFIG_SCSI_QLOGIC_ISP is not set
292CONFIG_SCSI_QLOGIC_FC=m 502# CONFIG_SCSI_QLOGIC_FC is not set
293# CONFIG_SCSI_QLOGIC_FC_FIRMWARE is not set 503# CONFIG_SCSI_QLOGIC_1280 is not set
294CONFIG_SCSI_QLOGIC_1280=m
295# CONFIG_SCSI_QLOGIC_1280_1040 is not set
296CONFIG_SCSI_QLA2XXX=y 504CONFIG_SCSI_QLA2XXX=y
297# CONFIG_SCSI_QLA21XX is not set 505# CONFIG_SCSI_QLA21XX is not set
298# CONFIG_SCSI_QLA22XX is not set 506# CONFIG_SCSI_QLA22XX is not set
299CONFIG_SCSI_QLA2300=m 507# CONFIG_SCSI_QLA2300 is not set
300CONFIG_SCSI_QLA2322=m 508# CONFIG_SCSI_QLA2322 is not set
301CONFIG_SCSI_QLA6312=m 509# CONFIG_SCSI_QLA6312 is not set
302CONFIG_SCSI_QLA6322=m 510# CONFIG_SCSI_QLA24XX is not set
511# CONFIG_SCSI_LPFC is not set
303# CONFIG_SCSI_DC395x is not set 512# CONFIG_SCSI_DC395x is not set
304# CONFIG_SCSI_DC390T is not set 513# CONFIG_SCSI_DC390T is not set
305# CONFIG_SCSI_NSP32 is not set 514# CONFIG_SCSI_NSP32 is not set
@@ -316,19 +525,24 @@ CONFIG_MD_RAID1=y
316# CONFIG_MD_RAID10 is not set 525# CONFIG_MD_RAID10 is not set
317# CONFIG_MD_RAID5 is not set 526# CONFIG_MD_RAID5 is not set
318# CONFIG_MD_RAID6 is not set 527# CONFIG_MD_RAID6 is not set
319CONFIG_MD_MULTIPATH=y 528# CONFIG_MD_MULTIPATH is not set
320# CONFIG_MD_FAULTY is not set 529# CONFIG_MD_FAULTY is not set
321CONFIG_BLK_DEV_DM=y 530CONFIG_BLK_DEV_DM=m
322# CONFIG_DM_CRYPT is not set 531CONFIG_DM_CRYPT=m
323# CONFIG_DM_SNAPSHOT is not set 532CONFIG_DM_SNAPSHOT=m
324# CONFIG_DM_MIRROR is not set 533CONFIG_DM_MIRROR=m
325# CONFIG_DM_ZERO is not set 534CONFIG_DM_ZERO=m
535CONFIG_DM_MULTIPATH=m
536# CONFIG_DM_MULTIPATH_EMC is not set
326 537
327# 538#
328# Fusion MPT device support 539# Fusion MPT device support
329# 540#
330CONFIG_FUSION=m 541CONFIG_FUSION=y
331CONFIG_FUSION_MAX_SGE=40 542CONFIG_FUSION_SPI=m
543# CONFIG_FUSION_FC is not set
544# CONFIG_FUSION_SAS is not set
545CONFIG_FUSION_MAX_SGE=128
332CONFIG_FUSION_CTL=m 546CONFIG_FUSION_CTL=m
333 547
334# 548#
@@ -342,151 +556,13 @@ CONFIG_FUSION_CTL=m
342# CONFIG_I2O is not set 556# CONFIG_I2O is not set
343 557
344# 558#
345# Networking support 559# Network device support
346#
347CONFIG_NET=y
348
349#
350# Networking options
351#
352CONFIG_PACKET=y
353CONFIG_PACKET_MMAP=y
354CONFIG_NETLINK_DEV=y
355CONFIG_UNIX=y
356CONFIG_NET_KEY=m
357CONFIG_INET=y
358CONFIG_IP_MULTICAST=y
359# CONFIG_IP_ADVANCED_ROUTER is not set
360CONFIG_IP_PNP=y
361# CONFIG_IP_PNP_DHCP is not set
362CONFIG_IP_PNP_BOOTP=y
363# CONFIG_IP_PNP_RARP is not set
364# CONFIG_NET_IPIP is not set
365# CONFIG_NET_IPGRE is not set
366# CONFIG_IP_MROUTE is not set
367# CONFIG_ARPD is not set
368# CONFIG_SYN_COOKIES is not set
369CONFIG_INET_AH=m
370CONFIG_INET_ESP=m
371# CONFIG_INET_IPCOMP is not set
372# CONFIG_INET_TUNNEL is not set
373CONFIG_IP_TCPDIAG=y
374# CONFIG_IP_TCPDIAG_IPV6 is not set
375
376#
377# IP: Virtual Server Configuration
378#
379# CONFIG_IP_VS is not set
380# CONFIG_IPV6 is not set
381CONFIG_NETFILTER=y
382CONFIG_NETFILTER_DEBUG=y
383
384#
385# IP: Netfilter Configuration
386#
387CONFIG_IP_NF_CONNTRACK=m
388# CONFIG_IP_NF_CT_ACCT is not set
389# CONFIG_IP_NF_CONNTRACK_MARK is not set
390# CONFIG_IP_NF_CT_PROTO_SCTP is not set
391CONFIG_IP_NF_FTP=m
392CONFIG_IP_NF_IRC=m
393CONFIG_IP_NF_TFTP=m
394CONFIG_IP_NF_AMANDA=m
395CONFIG_IP_NF_QUEUE=m
396CONFIG_IP_NF_IPTABLES=m
397CONFIG_IP_NF_MATCH_LIMIT=m
398CONFIG_IP_NF_MATCH_IPRANGE=m
399CONFIG_IP_NF_MATCH_MAC=m
400CONFIG_IP_NF_MATCH_PKTTYPE=m
401CONFIG_IP_NF_MATCH_MARK=m
402CONFIG_IP_NF_MATCH_MULTIPORT=m
403CONFIG_IP_NF_MATCH_TOS=m
404CONFIG_IP_NF_MATCH_RECENT=m
405CONFIG_IP_NF_MATCH_ECN=m
406CONFIG_IP_NF_MATCH_DSCP=m
407CONFIG_IP_NF_MATCH_AH_ESP=m
408CONFIG_IP_NF_MATCH_LENGTH=m
409CONFIG_IP_NF_MATCH_TTL=m
410CONFIG_IP_NF_MATCH_TCPMSS=m
411CONFIG_IP_NF_MATCH_HELPER=m
412CONFIG_IP_NF_MATCH_STATE=m
413CONFIG_IP_NF_MATCH_CONNTRACK=m
414CONFIG_IP_NF_MATCH_OWNER=m
415# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
416# CONFIG_IP_NF_MATCH_REALM is not set
417# CONFIG_IP_NF_MATCH_SCTP is not set
418# CONFIG_IP_NF_MATCH_COMMENT is not set
419# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
420CONFIG_IP_NF_FILTER=m
421CONFIG_IP_NF_TARGET_REJECT=m
422CONFIG_IP_NF_TARGET_LOG=m
423CONFIG_IP_NF_TARGET_ULOG=m
424CONFIG_IP_NF_TARGET_TCPMSS=m
425CONFIG_IP_NF_NAT=m
426CONFIG_IP_NF_NAT_NEEDED=y
427CONFIG_IP_NF_TARGET_MASQUERADE=m
428CONFIG_IP_NF_TARGET_REDIRECT=m
429CONFIG_IP_NF_TARGET_NETMAP=m
430CONFIG_IP_NF_TARGET_SAME=m
431CONFIG_IP_NF_NAT_SNMP_BASIC=m
432CONFIG_IP_NF_NAT_IRC=m
433CONFIG_IP_NF_NAT_FTP=m
434CONFIG_IP_NF_NAT_TFTP=m
435CONFIG_IP_NF_NAT_AMANDA=m
436CONFIG_IP_NF_MANGLE=m
437CONFIG_IP_NF_TARGET_TOS=m
438CONFIG_IP_NF_TARGET_ECN=m
439CONFIG_IP_NF_TARGET_DSCP=m
440CONFIG_IP_NF_TARGET_MARK=m
441CONFIG_IP_NF_TARGET_CLASSIFY=m
442# CONFIG_IP_NF_RAW is not set
443CONFIG_IP_NF_ARPTABLES=m
444CONFIG_IP_NF_ARPFILTER=m
445CONFIG_IP_NF_ARP_MANGLE=m
446CONFIG_IP_NF_COMPAT_IPCHAINS=m
447CONFIG_IP_NF_COMPAT_IPFWADM=m
448CONFIG_XFRM=y
449CONFIG_XFRM_USER=m
450
451#
452# SCTP Configuration (EXPERIMENTAL)
453#
454# CONFIG_IP_SCTP is not set
455# CONFIG_ATM is not set
456# CONFIG_BRIDGE is not set
457# CONFIG_VLAN_8021Q is not set
458# CONFIG_DECNET is not set
459CONFIG_LLC=m
460CONFIG_LLC2=m
461# CONFIG_IPX is not set
462# CONFIG_ATALK is not set
463# CONFIG_X25 is not set
464# CONFIG_LAPB is not set
465# CONFIG_NET_DIVERT is not set
466# CONFIG_ECONET is not set
467# CONFIG_WAN_ROUTER is not set
468
469#
470# QoS and/or fair queueing
471#
472# CONFIG_NET_SCHED is not set
473# CONFIG_NET_CLS_ROUTE is not set
474
475#
476# Network testing
477# 560#
478# CONFIG_NET_PKTGEN is not set
479# CONFIG_NETPOLL is not set
480# CONFIG_NET_POLL_CONTROLLER is not set
481# CONFIG_HAMRADIO is not set
482# CONFIG_IRDA is not set
483# CONFIG_BT is not set
484CONFIG_NETDEVICES=y 561CONFIG_NETDEVICES=y
485CONFIG_DUMMY=m 562CONFIG_DUMMY=m
486CONFIG_BONDING=m 563CONFIG_BONDING=m
487# CONFIG_EQUALIZER is not set 564# CONFIG_EQUALIZER is not set
488CONFIG_TUN=m 565CONFIG_TUN=m
489# CONFIG_ETHERTAP is not set
490 566
491# 567#
492# ARCnet devices 568# ARCnet devices
@@ -494,12 +570,18 @@ CONFIG_TUN=m
494# CONFIG_ARCNET is not set 570# CONFIG_ARCNET is not set
495 571
496# 572#
573# PHY device support
574#
575# CONFIG_PHYLIB is not set
576
577#
497# Ethernet (10 or 100Mbit) 578# Ethernet (10 or 100Mbit)
498# 579#
499CONFIG_NET_ETHERNET=y 580CONFIG_NET_ETHERNET=y
500CONFIG_MII=m 581CONFIG_MII=m
501CONFIG_HAPPYMEAL=m 582# CONFIG_HAPPYMEAL is not set
502# CONFIG_SUNGEM is not set 583# CONFIG_SUNGEM is not set
584# CONFIG_CASSINI is not set
503# CONFIG_NET_VENDOR_3COM is not set 585# CONFIG_NET_VENDOR_3COM is not set
504 586
505# 587#
@@ -514,28 +596,22 @@ CONFIG_TULIP_MMIO=y
514# CONFIG_DE4X5 is not set 596# CONFIG_DE4X5 is not set
515# CONFIG_WINBOND_840 is not set 597# CONFIG_WINBOND_840 is not set
516# CONFIG_DM9102 is not set 598# CONFIG_DM9102 is not set
599# CONFIG_ULI526X is not set
517# CONFIG_HP100 is not set 600# CONFIG_HP100 is not set
518CONFIG_NET_PCI=y 601CONFIG_NET_PCI=y
519CONFIG_PCNET32=m 602# CONFIG_PCNET32 is not set
520# CONFIG_AMD8111_ETH is not set 603# CONFIG_AMD8111_ETH is not set
521CONFIG_ADAPTEC_STARFIRE=m 604# CONFIG_ADAPTEC_STARFIRE is not set
522# CONFIG_ADAPTEC_STARFIRE_NAPI is not set 605# CONFIG_B44 is not set
523CONFIG_B44=m
524# CONFIG_FORCEDETH is not set 606# CONFIG_FORCEDETH is not set
525# CONFIG_DGRS is not set 607# CONFIG_DGRS is not set
526CONFIG_EEPRO100=m 608# CONFIG_EEPRO100 is not set
527# CONFIG_EEPRO100_PIO is not set
528CONFIG_E100=m 609CONFIG_E100=m
529# CONFIG_E100_NAPI is not set
530# CONFIG_FEALNX is not set 610# CONFIG_FEALNX is not set
531CONFIG_NATSEMI=m 611# CONFIG_NATSEMI is not set
532# CONFIG_NE2K_PCI is not set 612# CONFIG_NE2K_PCI is not set
533# CONFIG_8139CP is not set 613# CONFIG_8139CP is not set
534CONFIG_8139TOO=m 614# CONFIG_8139TOO is not set
535# CONFIG_8139TOO_PIO is not set
536# CONFIG_8139TOO_TUNE_TWISTER is not set
537# CONFIG_8139TOO_8129 is not set
538# CONFIG_8139_OLD_RX_RESET is not set
539# CONFIG_SIS900 is not set 615# CONFIG_SIS900 is not set
540# CONFIG_EPIC100 is not set 616# CONFIG_EPIC100 is not set
541# CONFIG_SUNDANCE is not set 617# CONFIG_SUNDANCE is not set
@@ -554,15 +630,18 @@ CONFIG_E1000=m
554# CONFIG_HAMACHI is not set 630# CONFIG_HAMACHI is not set
555# CONFIG_YELLOWFIN is not set 631# CONFIG_YELLOWFIN is not set
556# CONFIG_R8169 is not set 632# CONFIG_R8169 is not set
633# CONFIG_SIS190 is not set
634# CONFIG_SKGE is not set
557# CONFIG_SK98LIN is not set 635# CONFIG_SK98LIN is not set
558# CONFIG_VIA_VELOCITY is not set 636# CONFIG_VIA_VELOCITY is not set
559CONFIG_TIGON3=m 637CONFIG_TIGON3=m
638# CONFIG_BNX2 is not set
560 639
561# 640#
562# Ethernet (10000 Mbit) 641# Ethernet (10000 Mbit)
563# 642#
564CONFIG_IXGB=y 643# CONFIG_CHELSIO_T1 is not set
565CONFIG_IXGB_NAPI=y 644# CONFIG_IXGB is not set
566# CONFIG_S2IO is not set 645# CONFIG_S2IO is not set
567 646
568# 647#
@@ -593,6 +672,8 @@ CONFIG_PPPOE=m
593# CONFIG_NET_FC is not set 672# CONFIG_NET_FC is not set
594# CONFIG_SHAPER is not set 673# CONFIG_SHAPER is not set
595# CONFIG_NETCONSOLE is not set 674# CONFIG_NETCONSOLE is not set
675# CONFIG_NETPOLL is not set
676# CONFIG_NET_POLL_CONTROLLER is not set
596 677
597# 678#
598# ISDN subsystem 679# ISDN subsystem
@@ -622,16 +703,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1200
622# CONFIG_INPUT_EVBUG is not set 703# CONFIG_INPUT_EVBUG is not set
623 704
624# 705#
625# Input I/O drivers
626#
627# CONFIG_GAMEPORT is not set
628CONFIG_SOUND_GAMEPORT=y
629CONFIG_SERIO=m
630CONFIG_SERIO_SERPORT=m
631# CONFIG_SERIO_PCIPS2 is not set
632# CONFIG_SERIO_RAW is not set
633
634#
635# Input Device Drivers 706# Input Device Drivers
636# 707#
637CONFIG_INPUT_KEYBOARD=y 708CONFIG_INPUT_KEYBOARD=y
@@ -649,6 +720,16 @@ CONFIG_INPUT_MOUSE=y
649# CONFIG_INPUT_MISC is not set 720# CONFIG_INPUT_MISC is not set
650 721
651# 722#
723# Hardware I/O ports
724#
725CONFIG_SERIO=m
726CONFIG_SERIO_SERPORT=m
727# CONFIG_SERIO_PCIPS2 is not set
728CONFIG_SERIO_LIBPS2=m
729# CONFIG_SERIO_RAW is not set
730# CONFIG_GAMEPORT is not set
731
732#
652# Character devices 733# Character devices
653# 734#
654CONFIG_VT=y 735CONFIG_VT=y
@@ -666,7 +747,6 @@ CONFIG_SERIAL_8250_EXTENDED=y
666CONFIG_SERIAL_8250_MANY_PORTS=y 747CONFIG_SERIAL_8250_MANY_PORTS=y
667CONFIG_SERIAL_8250_SHARE_IRQ=y 748CONFIG_SERIAL_8250_SHARE_IRQ=y
668# CONFIG_SERIAL_8250_DETECT_IRQ is not set 749# CONFIG_SERIAL_8250_DETECT_IRQ is not set
669# CONFIG_SERIAL_8250_MULTIPORT is not set
670# CONFIG_SERIAL_8250_RSA is not set 750# CONFIG_SERIAL_8250_RSA is not set
671 751
672# 752#
@@ -676,6 +756,7 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
676# CONFIG_PDC_CONSOLE is not set 756# CONFIG_PDC_CONSOLE is not set
677CONFIG_SERIAL_CORE=y 757CONFIG_SERIAL_CORE=y
678CONFIG_SERIAL_CORE_CONSOLE=y 758CONFIG_SERIAL_CORE_CONSOLE=y
759# CONFIG_SERIAL_JSM is not set
679CONFIG_UNIX98_PTYS=y 760CONFIG_UNIX98_PTYS=y
680CONFIG_LEGACY_PTYS=y 761CONFIG_LEGACY_PTYS=y
681CONFIG_LEGACY_PTY_COUNT=256 762CONFIG_LEGACY_PTY_COUNT=256
@@ -698,12 +779,16 @@ CONFIG_GEN_RTC_X=y
698# 779#
699# Ftape, the floppy tape device driver 780# Ftape, the floppy tape device driver
700# 781#
701# CONFIG_AGP is not set
702# CONFIG_DRM is not set 782# CONFIG_DRM is not set
703CONFIG_RAW_DRIVER=y 783CONFIG_RAW_DRIVER=y
704CONFIG_MAX_RAW_DEVS=256 784CONFIG_MAX_RAW_DEVS=256
705 785
706# 786#
787# TPM devices
788#
789# CONFIG_TCG_TPM is not set
790
791#
707# I2C support 792# I2C support
708# 793#
709# CONFIG_I2C is not set 794# CONFIG_I2C is not set
@@ -714,10 +799,20 @@ CONFIG_MAX_RAW_DEVS=256
714# CONFIG_W1 is not set 799# CONFIG_W1 is not set
715 800
716# 801#
802# Hardware Monitoring support
803#
804# CONFIG_HWMON is not set
805# CONFIG_HWMON_VID is not set
806
807#
717# Misc devices 808# Misc devices
718# 809#
719 810
720# 811#
812# Multimedia Capabilities Port drivers
813#
814
815#
721# Multimedia devices 816# Multimedia devices
722# 817#
723# CONFIG_VIDEO_DEV is not set 818# CONFIG_VIDEO_DEV is not set
@@ -731,6 +826,11 @@ CONFIG_MAX_RAW_DEVS=256
731# Graphics support 826# Graphics support
732# 827#
733CONFIG_FB=y 828CONFIG_FB=y
829CONFIG_FB_CFB_FILLRECT=y
830CONFIG_FB_CFB_COPYAREA=y
831CONFIG_FB_CFB_IMAGEBLIT=y
832CONFIG_FB_SOFT_CURSOR=y
833# CONFIG_FB_MACMODES is not set
734# CONFIG_FB_MODE_HELPERS is not set 834# CONFIG_FB_MODE_HELPERS is not set
735# CONFIG_FB_TILEBLITTING is not set 835# CONFIG_FB_TILEBLITTING is not set
736# CONFIG_FB_CIRRUS is not set 836# CONFIG_FB_CIRRUS is not set
@@ -739,6 +839,7 @@ CONFIG_FB=y
739# CONFIG_FB_ASILIANT is not set 839# CONFIG_FB_ASILIANT is not set
740# CONFIG_FB_IMSTT is not set 840# CONFIG_FB_IMSTT is not set
741CONFIG_FB_STI=y 841CONFIG_FB_STI=y
842# CONFIG_FB_NVIDIA is not set
742# CONFIG_FB_RIVA is not set 843# CONFIG_FB_RIVA is not set
743# CONFIG_FB_MATROX is not set 844# CONFIG_FB_MATROX is not set
744# CONFIG_FB_RADEON_OLD is not set 845# CONFIG_FB_RADEON_OLD is not set
@@ -751,18 +852,20 @@ CONFIG_FB_STI=y
751# CONFIG_FB_KYRO is not set 852# CONFIG_FB_KYRO is not set
752# CONFIG_FB_3DFX is not set 853# CONFIG_FB_3DFX is not set
753# CONFIG_FB_VOODOO1 is not set 854# CONFIG_FB_VOODOO1 is not set
855# CONFIG_FB_CYBLA is not set
754# CONFIG_FB_TRIDENT is not set 856# CONFIG_FB_TRIDENT is not set
755# CONFIG_FB_PM3 is not set 857# CONFIG_FB_PM3 is not set
858# CONFIG_FB_S1D13XXX is not set
756# CONFIG_FB_VIRTUAL is not set 859# CONFIG_FB_VIRTUAL is not set
757 860
758# 861#
759# Console display driver support 862# Console display driver support
760# 863#
761CONFIG_STI_CONSOLE=y 864CONFIG_DUMMY_CONSOLE=y
762CONFIG_DUMMY_CONSOLE_COLUMNS=160 865CONFIG_DUMMY_CONSOLE_COLUMNS=160
763CONFIG_DUMMY_CONSOLE_ROWS=64 866CONFIG_DUMMY_CONSOLE_ROWS=64
764CONFIG_DUMMY_CONSOLE=y
765CONFIG_FRAMEBUFFER_CONSOLE=y 867CONFIG_FRAMEBUFFER_CONSOLE=y
868CONFIG_STI_CONSOLE=y
766# CONFIG_FONTS is not set 869# CONFIG_FONTS is not set
767CONFIG_FONT_8x8=y 870CONFIG_FONT_8x8=y
768CONFIG_FONT_8x16=y 871CONFIG_FONT_8x16=y
@@ -775,6 +878,7 @@ CONFIG_LOGO=y
775# CONFIG_LOGO_LINUX_VGA16 is not set 878# CONFIG_LOGO_LINUX_VGA16 is not set
776# CONFIG_LOGO_LINUX_CLUT224 is not set 879# CONFIG_LOGO_LINUX_CLUT224 is not set
777CONFIG_LOGO_PARISC_CLUT224=y 880CONFIG_LOGO_PARISC_CLUT224=y
881# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
778 882
779# 883#
780# Sound 884# Sound
@@ -784,7 +888,78 @@ CONFIG_SOUND=y
784# 888#
785# Advanced Linux Sound Architecture 889# Advanced Linux Sound Architecture
786# 890#
787# CONFIG_SND is not set 891CONFIG_SND=y
892CONFIG_SND_TIMER=y
893CONFIG_SND_PCM=y
894CONFIG_SND_SEQUENCER=y
895# CONFIG_SND_SEQ_DUMMY is not set
896CONFIG_SND_OSSEMUL=y
897CONFIG_SND_MIXER_OSS=y
898CONFIG_SND_PCM_OSS=y
899CONFIG_SND_SEQUENCER_OSS=y
900# CONFIG_SND_VERBOSE_PRINTK is not set
901# CONFIG_SND_DEBUG is not set
902
903#
904# Generic devices
905#
906# CONFIG_SND_DUMMY is not set
907# CONFIG_SND_VIRMIDI is not set
908# CONFIG_SND_MTPAV is not set
909# CONFIG_SND_SERIAL_U16550 is not set
910# CONFIG_SND_MPU401 is not set
911CONFIG_SND_AC97_CODEC=y
912CONFIG_SND_AC97_BUS=y
913
914#
915# PCI devices
916#
917# CONFIG_SND_ALI5451 is not set
918# CONFIG_SND_ATIIXP is not set
919# CONFIG_SND_ATIIXP_MODEM is not set
920# CONFIG_SND_AU8810 is not set
921# CONFIG_SND_AU8820 is not set
922# CONFIG_SND_AU8830 is not set
923# CONFIG_SND_AZT3328 is not set
924# CONFIG_SND_BT87X is not set
925# CONFIG_SND_CS46XX is not set
926# CONFIG_SND_CS4281 is not set
927# CONFIG_SND_EMU10K1 is not set
928# CONFIG_SND_EMU10K1X is not set
929# CONFIG_SND_CA0106 is not set
930# CONFIG_SND_KORG1212 is not set
931# CONFIG_SND_MIXART is not set
932# CONFIG_SND_NM256 is not set
933# CONFIG_SND_RME32 is not set
934# CONFIG_SND_RME96 is not set
935# CONFIG_SND_RME9652 is not set
936# CONFIG_SND_HDSP is not set
937# CONFIG_SND_HDSPM is not set
938# CONFIG_SND_TRIDENT is not set
939# CONFIG_SND_YMFPCI is not set
940CONFIG_SND_AD1889=y
941# CONFIG_SND_AD1889_OPL3 is not set
942# CONFIG_SND_CMIPCI is not set
943# CONFIG_SND_ENS1370 is not set
944# CONFIG_SND_ENS1371 is not set
945# CONFIG_SND_ES1938 is not set
946# CONFIG_SND_ES1968 is not set
947# CONFIG_SND_MAESTRO3 is not set
948# CONFIG_SND_FM801 is not set
949# CONFIG_SND_ICE1712 is not set
950# CONFIG_SND_ICE1724 is not set
951# CONFIG_SND_INTEL8X0 is not set
952# CONFIG_SND_INTEL8X0M is not set
953# CONFIG_SND_SONICVIBES is not set
954# CONFIG_SND_VIA82XX is not set
955# CONFIG_SND_VIA82XX_MODEM is not set
956# CONFIG_SND_VX222 is not set
957# CONFIG_SND_HDA_INTEL is not set
958
959#
960# USB devices
961#
962# CONFIG_SND_USB_AUDIO is not set
788 963
789# 964#
790# Open Sound System 965# Open Sound System
@@ -794,6 +969,8 @@ CONFIG_SOUND=y
794# 969#
795# USB support 970# USB support
796# 971#
972CONFIG_USB_ARCH_HAS_HCD=y
973CONFIG_USB_ARCH_HAS_OHCI=y
797CONFIG_USB=y 974CONFIG_USB=y
798CONFIG_USB_DEBUG=y 975CONFIG_USB_DEBUG=y
799 976
@@ -804,23 +981,23 @@ CONFIG_USB_DEVICEFS=y
804# CONFIG_USB_BANDWIDTH is not set 981# CONFIG_USB_BANDWIDTH is not set
805# CONFIG_USB_DYNAMIC_MINORS is not set 982# CONFIG_USB_DYNAMIC_MINORS is not set
806# CONFIG_USB_OTG is not set 983# CONFIG_USB_OTG is not set
807CONFIG_USB_ARCH_HAS_HCD=y
808CONFIG_USB_ARCH_HAS_OHCI=y
809 984
810# 985#
811# USB Host Controller Drivers 986# USB Host Controller Drivers
812# 987#
813# CONFIG_USB_EHCI_HCD is not set 988# CONFIG_USB_EHCI_HCD is not set
989# CONFIG_USB_ISP116X_HCD is not set
814CONFIG_USB_OHCI_HCD=y 990CONFIG_USB_OHCI_HCD=y
991# CONFIG_USB_OHCI_BIG_ENDIAN is not set
992CONFIG_USB_OHCI_LITTLE_ENDIAN=y
815# CONFIG_USB_UHCI_HCD is not set 993# CONFIG_USB_UHCI_HCD is not set
816# CONFIG_USB_SL811_HCD is not set 994# CONFIG_USB_SL811_HCD is not set
817 995
818# 996#
819# USB Device Class drivers 997# USB Device Class drivers
820# 998#
821# CONFIG_USB_AUDIO is not set 999# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
822# CONFIG_USB_BLUETOOTH_TTY is not set 1000# CONFIG_USB_BLUETOOTH_TTY is not set
823# CONFIG_USB_MIDI is not set
824# CONFIG_USB_ACM is not set 1001# CONFIG_USB_ACM is not set
825CONFIG_USB_PRINTER=m 1002CONFIG_USB_PRINTER=m
826 1003
@@ -829,12 +1006,11 @@ CONFIG_USB_PRINTER=m
829# 1006#
830CONFIG_USB_STORAGE=m 1007CONFIG_USB_STORAGE=m
831# CONFIG_USB_STORAGE_DEBUG is not set 1008# CONFIG_USB_STORAGE_DEBUG is not set
832# CONFIG_USB_STORAGE_RW_DETECT is not set 1009# CONFIG_USB_STORAGE_DATAFAB is not set
833CONFIG_USB_STORAGE_DATAFAB=y 1010# CONFIG_USB_STORAGE_FREECOM is not set
834CONFIG_USB_STORAGE_FREECOM=y
835# CONFIG_USB_STORAGE_ISD200 is not set 1011# CONFIG_USB_STORAGE_ISD200 is not set
836CONFIG_USB_STORAGE_DPCM=y 1012CONFIG_USB_STORAGE_DPCM=y
837CONFIG_USB_STORAGE_HP8200e=y 1013CONFIG_USB_STORAGE_USBAT=y
838CONFIG_USB_STORAGE_SDDR09=y 1014CONFIG_USB_STORAGE_SDDR09=y
839CONFIG_USB_STORAGE_SDDR55=y 1015CONFIG_USB_STORAGE_SDDR55=y
840CONFIG_USB_STORAGE_JUMPSHOT=y 1016CONFIG_USB_STORAGE_JUMPSHOT=y
@@ -846,21 +1022,25 @@ CONFIG_USB_HID=y
846CONFIG_USB_HIDINPUT=y 1022CONFIG_USB_HIDINPUT=y
847# CONFIG_HID_FF is not set 1023# CONFIG_HID_FF is not set
848CONFIG_USB_HIDDEV=y 1024CONFIG_USB_HIDDEV=y
849CONFIG_USB_AIPTEK=m 1025# CONFIG_USB_AIPTEK is not set
850CONFIG_USB_WACOM=m 1026# CONFIG_USB_WACOM is not set
851CONFIG_USB_KBTAB=m 1027# CONFIG_USB_ACECAD is not set
1028# CONFIG_USB_KBTAB is not set
852# CONFIG_USB_POWERMATE is not set 1029# CONFIG_USB_POWERMATE is not set
853# CONFIG_USB_MTOUCH is not set 1030# CONFIG_USB_MTOUCH is not set
1031# CONFIG_USB_ITMTOUCH is not set
854# CONFIG_USB_EGALAX is not set 1032# CONFIG_USB_EGALAX is not set
1033# CONFIG_USB_YEALINK is not set
855# CONFIG_USB_XPAD is not set 1034# CONFIG_USB_XPAD is not set
856# CONFIG_USB_ATI_REMOTE is not set 1035# CONFIG_USB_ATI_REMOTE is not set
1036# CONFIG_USB_KEYSPAN_REMOTE is not set
1037# CONFIG_USB_APPLETOUCH is not set
857 1038
858# 1039#
859# USB Imaging devices 1040# USB Imaging devices
860# 1041#
861CONFIG_USB_MDC800=m 1042CONFIG_USB_MDC800=m
862CONFIG_USB_MICROTEK=m 1043CONFIG_USB_MICROTEK=m
863CONFIG_USB_HPUSBSCSI=m
864 1044
865# 1045#
866# USB Multimedia devices 1046# USB Multimedia devices
@@ -879,6 +1059,7 @@ CONFIG_USB_HPUSBSCSI=m
879# CONFIG_USB_PEGASUS is not set 1059# CONFIG_USB_PEGASUS is not set
880# CONFIG_USB_RTL8150 is not set 1060# CONFIG_USB_RTL8150 is not set
881# CONFIG_USB_USBNET is not set 1061# CONFIG_USB_USBNET is not set
1062# CONFIG_USB_MON is not set
882 1063
883# 1064#
884# USB port drivers 1065# USB port drivers
@@ -894,7 +1075,6 @@ CONFIG_USB_HPUSBSCSI=m
894# 1075#
895# CONFIG_USB_EMI62 is not set 1076# CONFIG_USB_EMI62 is not set
896# CONFIG_USB_EMI26 is not set 1077# CONFIG_USB_EMI26 is not set
897# CONFIG_USB_TIGL is not set
898# CONFIG_USB_AUERSWALD is not set 1078# CONFIG_USB_AUERSWALD is not set
899# CONFIG_USB_RIO500 is not set 1079# CONFIG_USB_RIO500 is not set
900CONFIG_USB_LEGOTOWER=m 1080CONFIG_USB_LEGOTOWER=m
@@ -903,10 +1083,12 @@ CONFIG_USB_LEGOTOWER=m
903# CONFIG_USB_CYTHERM is not set 1083# CONFIG_USB_CYTHERM is not set
904# CONFIG_USB_PHIDGETKIT is not set 1084# CONFIG_USB_PHIDGETKIT is not set
905# CONFIG_USB_PHIDGETSERVO is not set 1085# CONFIG_USB_PHIDGETSERVO is not set
1086# CONFIG_USB_IDMOUSE is not set
1087# CONFIG_USB_LD is not set
906# CONFIG_USB_TEST is not set 1088# CONFIG_USB_TEST is not set
907 1089
908# 1090#
909# USB ATM/DSL drivers 1091# USB DSL modem support
910# 1092#
911 1093
912# 1094#
@@ -920,27 +1102,41 @@ CONFIG_USB_LEGOTOWER=m
920# CONFIG_MMC is not set 1102# CONFIG_MMC is not set
921 1103
922# 1104#
1105# InfiniBand support
1106#
1107# CONFIG_INFINIBAND is not set
1108
1109#
1110# SN Devices
1111#
1112
1113#
923# File systems 1114# File systems
924# 1115#
925CONFIG_EXT2_FS=y 1116CONFIG_EXT2_FS=y
926# CONFIG_EXT2_FS_XATTR is not set 1117# CONFIG_EXT2_FS_XATTR is not set
1118# CONFIG_EXT2_FS_XIP is not set
927CONFIG_EXT3_FS=y 1119CONFIG_EXT3_FS=y
928# CONFIG_EXT3_FS_XATTR is not set 1120# CONFIG_EXT3_FS_XATTR is not set
929CONFIG_JBD=y 1121CONFIG_JBD=y
930# CONFIG_JBD_DEBUG is not set 1122# CONFIG_JBD_DEBUG is not set
931# CONFIG_REISERFS_FS is not set 1123# CONFIG_REISERFS_FS is not set
932# CONFIG_JFS_FS is not set 1124# CONFIG_JFS_FS is not set
1125# CONFIG_FS_POSIX_ACL is not set
933CONFIG_XFS_FS=m 1126CONFIG_XFS_FS=m
934# CONFIG_XFS_RT is not set 1127CONFIG_XFS_EXPORT=y
935# CONFIG_XFS_QUOTA is not set 1128# CONFIG_XFS_QUOTA is not set
936# CONFIG_XFS_SECURITY is not set 1129# CONFIG_XFS_SECURITY is not set
937# CONFIG_XFS_POSIX_ACL is not set 1130# CONFIG_XFS_POSIX_ACL is not set
1131# CONFIG_XFS_RT is not set
938# CONFIG_MINIX_FS is not set 1132# CONFIG_MINIX_FS is not set
939# CONFIG_ROMFS_FS is not set 1133# CONFIG_ROMFS_FS is not set
1134CONFIG_INOTIFY=y
940# CONFIG_QUOTA is not set 1135# CONFIG_QUOTA is not set
941CONFIG_DNOTIFY=y 1136CONFIG_DNOTIFY=y
942# CONFIG_AUTOFS_FS is not set 1137# CONFIG_AUTOFS_FS is not set
943CONFIG_AUTOFS4_FS=y 1138CONFIG_AUTOFS4_FS=y
1139# CONFIG_FUSE_FS is not set
944 1140
945# 1141#
946# CD-ROM/DVD Filesystems 1142# CD-ROM/DVD Filesystems
@@ -966,13 +1162,11 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
966CONFIG_PROC_FS=y 1162CONFIG_PROC_FS=y
967CONFIG_PROC_KCORE=y 1163CONFIG_PROC_KCORE=y
968CONFIG_SYSFS=y 1164CONFIG_SYSFS=y
969# CONFIG_DEVFS_FS is not set
970# CONFIG_DEVPTS_FS_XATTR is not set
971CONFIG_TMPFS=y 1165CONFIG_TMPFS=y
972# CONFIG_TMPFS_XATTR is not set
973# CONFIG_HUGETLBFS is not set 1166# CONFIG_HUGETLBFS is not set
974# CONFIG_HUGETLB_PAGE is not set 1167# CONFIG_HUGETLB_PAGE is not set
975CONFIG_RAMFS=y 1168CONFIG_RAMFS=y
1169# CONFIG_RELAYFS_FS is not set
976 1170
977# 1171#
978# Miscellaneous filesystems 1172# Miscellaneous filesystems
@@ -996,16 +1190,19 @@ CONFIG_RAMFS=y
996# 1190#
997CONFIG_NFS_FS=y 1191CONFIG_NFS_FS=y
998CONFIG_NFS_V3=y 1192CONFIG_NFS_V3=y
1193# CONFIG_NFS_V3_ACL is not set
999# CONFIG_NFS_V4 is not set 1194# CONFIG_NFS_V4 is not set
1000# CONFIG_NFS_DIRECTIO is not set 1195# CONFIG_NFS_DIRECTIO is not set
1001CONFIG_NFSD=y 1196CONFIG_NFSD=y
1002CONFIG_NFSD_V3=y 1197CONFIG_NFSD_V3=y
1198# CONFIG_NFSD_V3_ACL is not set
1003# CONFIG_NFSD_V4 is not set 1199# CONFIG_NFSD_V4 is not set
1004# CONFIG_NFSD_TCP is not set 1200# CONFIG_NFSD_TCP is not set
1005CONFIG_ROOT_NFS=y 1201CONFIG_ROOT_NFS=y
1006CONFIG_LOCKD=y 1202CONFIG_LOCKD=y
1007CONFIG_LOCKD_V4=y 1203CONFIG_LOCKD_V4=y
1008CONFIG_EXPORTFS=y 1204CONFIG_EXPORTFS=y
1205CONFIG_NFS_COMMON=y
1009CONFIG_SUNRPC=y 1206CONFIG_SUNRPC=y
1010# CONFIG_RPCSEC_GSS_KRB5 is not set 1207# CONFIG_RPCSEC_GSS_KRB5 is not set
1011# CONFIG_RPCSEC_GSS_SPKM3 is not set 1208# CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -1014,6 +1211,7 @@ CONFIG_SUNRPC=y
1014# CONFIG_NCP_FS is not set 1211# CONFIG_NCP_FS is not set
1015# CONFIG_CODA_FS is not set 1212# CONFIG_CODA_FS is not set
1016# CONFIG_AFS_FS is not set 1213# CONFIG_AFS_FS is not set
1214# CONFIG_9P_FS is not set
1017 1215
1018# 1216#
1019# Partition Types 1217# Partition Types
@@ -1074,13 +1272,19 @@ CONFIG_OPROFILE=m
1074# 1272#
1075# Kernel hacking 1273# Kernel hacking
1076# 1274#
1275# CONFIG_PRINTK_TIME is not set
1077CONFIG_DEBUG_KERNEL=y 1276CONFIG_DEBUG_KERNEL=y
1078CONFIG_MAGIC_SYSRQ=y 1277CONFIG_MAGIC_SYSRQ=y
1278CONFIG_LOG_BUF_SHIFT=16
1279CONFIG_DETECT_SOFTLOCKUP=y
1079# CONFIG_SCHEDSTATS is not set 1280# CONFIG_SCHEDSTATS is not set
1080# CONFIG_DEBUG_SLAB is not set 1281# CONFIG_DEBUG_SLAB is not set
1081# CONFIG_DEBUG_SPINLOCK is not set 1282# CONFIG_DEBUG_SPINLOCK is not set
1283# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1082# CONFIG_DEBUG_KOBJECT is not set 1284# CONFIG_DEBUG_KOBJECT is not set
1083# CONFIG_DEBUG_INFO is not set 1285# CONFIG_DEBUG_INFO is not set
1286# CONFIG_DEBUG_IOREMAP is not set
1287# CONFIG_DEBUG_FS is not set
1084 1288
1085# 1289#
1086# Security options 1290# Security options
@@ -1092,21 +1296,22 @@ CONFIG_MAGIC_SYSRQ=y
1092# Cryptographic options 1296# Cryptographic options
1093# 1297#
1094CONFIG_CRYPTO=y 1298CONFIG_CRYPTO=y
1095CONFIG_CRYPTO_HMAC=y 1299# CONFIG_CRYPTO_HMAC is not set
1096CONFIG_CRYPTO_NULL=m 1300CONFIG_CRYPTO_NULL=m
1097CONFIG_CRYPTO_MD4=m 1301# CONFIG_CRYPTO_MD4 is not set
1098CONFIG_CRYPTO_MD5=m 1302CONFIG_CRYPTO_MD5=m
1099CONFIG_CRYPTO_SHA1=m 1303# CONFIG_CRYPTO_SHA1 is not set
1100CONFIG_CRYPTO_SHA256=m 1304# CONFIG_CRYPTO_SHA256 is not set
1101# CONFIG_CRYPTO_SHA512 is not set 1305# CONFIG_CRYPTO_SHA512 is not set
1102# CONFIG_CRYPTO_WP512 is not set 1306# CONFIG_CRYPTO_WP512 is not set
1307# CONFIG_CRYPTO_TGR192 is not set
1103CONFIG_CRYPTO_DES=m 1308CONFIG_CRYPTO_DES=m
1104CONFIG_CRYPTO_BLOWFISH=m 1309CONFIG_CRYPTO_BLOWFISH=m
1105CONFIG_CRYPTO_TWOFISH=m 1310# CONFIG_CRYPTO_TWOFISH is not set
1106CONFIG_CRYPTO_SERPENT=m 1311# CONFIG_CRYPTO_SERPENT is not set
1107CONFIG_CRYPTO_AES=m 1312# CONFIG_CRYPTO_AES is not set
1108CONFIG_CRYPTO_CAST5=m 1313# CONFIG_CRYPTO_CAST5 is not set
1109CONFIG_CRYPTO_CAST6=m 1314# CONFIG_CRYPTO_CAST6 is not set
1110# CONFIG_CRYPTO_TEA is not set 1315# CONFIG_CRYPTO_TEA is not set
1111# CONFIG_CRYPTO_ARC4 is not set 1316# CONFIG_CRYPTO_ARC4 is not set
1112# CONFIG_CRYPTO_KHAZAD is not set 1317# CONFIG_CRYPTO_KHAZAD is not set
@@ -1117,9 +1322,14 @@ CONFIG_CRYPTO_CRC32C=m
1117CONFIG_CRYPTO_TEST=m 1322CONFIG_CRYPTO_TEST=m
1118 1323
1119# 1324#
1325# Hardware crypto devices
1326#
1327
1328#
1120# Library routines 1329# Library routines
1121# 1330#
1122CONFIG_CRC_CCITT=m 1331CONFIG_CRC_CCITT=m
1332# CONFIG_CRC16 is not set
1123CONFIG_CRC32=y 1333CONFIG_CRC32=y
1124CONFIG_LIBCRC32C=m 1334CONFIG_LIBCRC32C=m
1125CONFIG_ZLIB_INFLATE=m 1335CONFIG_ZLIB_INFLATE=m
diff --git a/arch/parisc/defconfig b/arch/parisc/defconfig
index fdae21c503d7..f38a4620d24f 100644
--- a/arch/parisc/defconfig
+++ b/arch/parisc/defconfig
@@ -1,38 +1,56 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc5-pa1
4# Fri Oct 21 23:01:33 2005
3# 5#
4CONFIG_PARISC=y 6CONFIG_PARISC=y
5CONFIG_MMU=y 7CONFIG_MMU=y
6CONFIG_STACK_GROWSUP=y 8CONFIG_STACK_GROWSUP=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10CONFIG_GENERIC_CALIBRATE_DELAY=y
11CONFIG_GENERIC_HARDIRQS=y
12CONFIG_GENERIC_IRQ_PROBE=y
8 13
9# 14#
10# Code maturity level options 15# Code maturity level options
11# 16#
12CONFIG_EXPERIMENTAL=y 17CONFIG_EXPERIMENTAL=y
13CONFIG_CLEAN_COMPILE=y 18CONFIG_CLEAN_COMPILE=y
14CONFIG_STANDALONE=y
15CONFIG_BROKEN_ON_SMP=y 19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
16 21
17# 22#
18# General setup 23# General setup
19# 24#
25CONFIG_LOCALVERSION=""
26# CONFIG_LOCALVERSION_AUTO is not set
20CONFIG_SWAP=y 27CONFIG_SWAP=y
21CONFIG_SYSVIPC=y 28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
22# CONFIG_BSD_PROCESS_ACCT is not set 30# CONFIG_BSD_PROCESS_ACCT is not set
23CONFIG_SYSCTL=y 31CONFIG_SYSCTL=y
24CONFIG_LOG_BUF_SHIFT=15 32# CONFIG_AUDIT is not set
25# CONFIG_HOTPLUG is not set 33# CONFIG_HOTPLUG is not set
34CONFIG_KOBJECT_UEVENT=y
26CONFIG_IKCONFIG=y 35CONFIG_IKCONFIG=y
27CONFIG_IKCONFIG_PROC=y 36CONFIG_IKCONFIG_PROC=y
37CONFIG_INITRAMFS_SOURCE=""
28# CONFIG_EMBEDDED is not set 38# CONFIG_EMBEDDED is not set
29CONFIG_KALLSYMS=y 39CONFIG_KALLSYMS=y
40# CONFIG_KALLSYMS_ALL is not set
41# CONFIG_KALLSYMS_EXTRA_PASS is not set
42CONFIG_PRINTK=y
43CONFIG_BUG=y
44CONFIG_BASE_FULL=y
30CONFIG_FUTEX=y 45CONFIG_FUTEX=y
31CONFIG_EPOLL=y 46CONFIG_EPOLL=y
32CONFIG_IOSCHED_NOOP=y 47CONFIG_SHMEM=y
33CONFIG_IOSCHED_AS=y 48CONFIG_CC_ALIGN_FUNCTIONS=0
34CONFIG_IOSCHED_DEADLINE=y 49CONFIG_CC_ALIGN_LABELS=0
35# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
36 54
37# 55#
38# Loadable module support 56# Loadable module support
@@ -45,10 +63,21 @@ CONFIG_IOSCHED_DEADLINE=y
45CONFIG_PA7000=y 63CONFIG_PA7000=y
46# CONFIG_PA7100LC is not set 64# CONFIG_PA7100LC is not set
47# CONFIG_PA7200 is not set 65# CONFIG_PA7200 is not set
66# CONFIG_PA7300LC is not set
48# CONFIG_PA8X00 is not set 67# CONFIG_PA8X00 is not set
49CONFIG_PA11=y 68CONFIG_PA11=y
50# CONFIG_64BIT is not set
51# CONFIG_SMP is not set 69# CONFIG_SMP is not set
70# CONFIG_HZ_100 is not set
71CONFIG_HZ_250=y
72# CONFIG_HZ_1000 is not set
73CONFIG_HZ=250
74CONFIG_SELECT_MEMORY_MODEL=y
75CONFIG_FLATMEM_MANUAL=y
76# CONFIG_DISCONTIGMEM_MANUAL is not set
77# CONFIG_SPARSEMEM_MANUAL is not set
78CONFIG_FLATMEM=y
79CONFIG_FLAT_NODE_MEM_MAP=y
80# CONFIG_SPARSEMEM_STATIC is not set
52# CONFIG_PREEMPT is not set 81# CONFIG_PREEMPT is not set
53# CONFIG_HPUX is not set 82# CONFIG_HPUX is not set
54 83
@@ -65,14 +94,29 @@ CONFIG_EISA_NAMES=y
65# CONFIG_ISA is not set 94# CONFIG_ISA is not set
66CONFIG_PCI=y 95CONFIG_PCI=y
67CONFIG_PCI_LEGACY_PROC=y 96CONFIG_PCI_LEGACY_PROC=y
68CONFIG_PCI_NAMES=y 97# CONFIG_PCI_DEBUG is not set
69CONFIG_GSC_DINO=y 98CONFIG_GSC_DINO=y
70CONFIG_PCI_LBA=y 99CONFIG_PCI_LBA=y
71CONFIG_IOSAPIC=y 100CONFIG_IOSAPIC=y
72CONFIG_IOMMU_SBA=y 101CONFIG_IOMMU_SBA=y
102
103#
104# PCCARD (PCMCIA/CardBus) support
105#
106# CONFIG_PCCARD is not set
107
108#
109# PCI Hotplug Support
110#
111# CONFIG_HOTPLUG_PCI is not set
112
113#
114# PA-RISC specific drivers
115#
73CONFIG_SUPERIO=y 116CONFIG_SUPERIO=y
74CONFIG_CHASSIS_LCD_LED=y 117CONFIG_CHASSIS_LCD_LED=y
75CONFIG_PDC_CHASSIS=y 118CONFIG_PDC_CHASSIS=y
119CONFIG_PDC_STABLE=y
76 120
77# 121#
78# Executable file formats 122# Executable file formats
@@ -81,15 +125,97 @@ CONFIG_BINFMT_ELF=y
81# CONFIG_BINFMT_MISC is not set 125# CONFIG_BINFMT_MISC is not set
82 126
83# 127#
128# Networking
129#
130CONFIG_NET=y
131
132#
133# Networking options
134#
135CONFIG_PACKET=y
136CONFIG_PACKET_MMAP=y
137CONFIG_UNIX=y
138# CONFIG_NET_KEY is not set
139CONFIG_INET=y
140CONFIG_IP_MULTICAST=y
141# CONFIG_IP_ADVANCED_ROUTER is not set
142CONFIG_IP_FIB_HASH=y
143CONFIG_IP_PNP=y
144# CONFIG_IP_PNP_DHCP is not set
145CONFIG_IP_PNP_BOOTP=y
146# CONFIG_IP_PNP_RARP is not set
147# CONFIG_NET_IPIP is not set
148# CONFIG_NET_IPGRE is not set
149# CONFIG_IP_MROUTE is not set
150# CONFIG_ARPD is not set
151# CONFIG_SYN_COOKIES is not set
152# CONFIG_INET_AH is not set
153# CONFIG_INET_ESP is not set
154# CONFIG_INET_IPCOMP is not set
155# CONFIG_INET_TUNNEL is not set
156# CONFIG_INET_DIAG is not set
157# CONFIG_TCP_CONG_ADVANCED is not set
158CONFIG_TCP_CONG_BIC=y
159CONFIG_IPV6=y
160# CONFIG_IPV6_PRIVACY is not set
161# CONFIG_INET6_AH is not set
162# CONFIG_INET6_ESP is not set
163# CONFIG_INET6_IPCOMP is not set
164# CONFIG_INET6_TUNNEL is not set
165# CONFIG_IPV6_TUNNEL is not set
166# CONFIG_NETFILTER is not set
167
168#
169# DCCP Configuration (EXPERIMENTAL)
170#
171# CONFIG_IP_DCCP is not set
172
173#
174# SCTP Configuration (EXPERIMENTAL)
175#
176# CONFIG_IP_SCTP is not set
177# CONFIG_ATM is not set
178# CONFIG_BRIDGE is not set
179# CONFIG_VLAN_8021Q is not set
180# CONFIG_DECNET is not set
181# CONFIG_LLC2 is not set
182# CONFIG_IPX is not set
183# CONFIG_ATALK is not set
184# CONFIG_X25 is not set
185# CONFIG_LAPB is not set
186# CONFIG_NET_DIVERT is not set
187# CONFIG_ECONET is not set
188# CONFIG_WAN_ROUTER is not set
189# CONFIG_NET_SCHED is not set
190# CONFIG_NET_CLS_ROUTE is not set
191
192#
193# Network testing
194#
195# CONFIG_NET_PKTGEN is not set
196# CONFIG_HAMRADIO is not set
197# CONFIG_IRDA is not set
198# CONFIG_BT is not set
199# CONFIG_IEEE80211 is not set
200
201#
84# Device Drivers 202# Device Drivers
85# 203#
86 204
87# 205#
88# Generic Driver Options 206# Generic Driver Options
89# 207#
208CONFIG_STANDALONE=y
209CONFIG_PREVENT_FIRMWARE_BUILD=y
210# CONFIG_FW_LOADER is not set
90# CONFIG_DEBUG_DRIVER is not set 211# CONFIG_DEBUG_DRIVER is not set
91 212
92# 213#
214# Connector - unified userspace <-> kernelspace linker
215#
216# CONFIG_CONNECTOR is not set
217
218#
93# Memory Technology Devices (MTD) 219# Memory Technology Devices (MTD)
94# 220#
95# CONFIG_MTD is not set 221# CONFIG_MTD is not set
@@ -99,12 +225,10 @@ CONFIG_BINFMT_ELF=y
99# 225#
100CONFIG_PARPORT=y 226CONFIG_PARPORT=y
101CONFIG_PARPORT_PC=y 227CONFIG_PARPORT_PC=y
102CONFIG_PARPORT_PC_CML1=y
103# CONFIG_PARPORT_SERIAL is not set 228# CONFIG_PARPORT_SERIAL is not set
104# CONFIG_PARPORT_PC_FIFO is not set 229# CONFIG_PARPORT_PC_FIFO is not set
105# CONFIG_PARPORT_PC_SUPERIO is not set 230# CONFIG_PARPORT_PC_SUPERIO is not set
106CONFIG_PARPORT_GSC=y 231CONFIG_PARPORT_GSC=y
107# CONFIG_PARPORT_OTHER is not set
108# CONFIG_PARPORT_1284 is not set 232# CONFIG_PARPORT_1284 is not set
109 233
110# 234#
@@ -114,18 +238,31 @@ CONFIG_PARPORT_GSC=y
114# 238#
115# Block devices 239# Block devices
116# 240#
117# CONFIG_BLK_DEV_FD is not set
118# CONFIG_PARIDE is not set 241# CONFIG_PARIDE is not set
119# CONFIG_BLK_CPQ_DA is not set 242# CONFIG_BLK_CPQ_DA is not set
120# CONFIG_BLK_CPQ_CISS_DA is not set 243# CONFIG_BLK_CPQ_CISS_DA is not set
121# CONFIG_BLK_DEV_DAC960 is not set 244# CONFIG_BLK_DEV_DAC960 is not set
122# CONFIG_BLK_DEV_UMEM is not set 245# CONFIG_BLK_DEV_UMEM is not set
246# CONFIG_BLK_DEV_COW_COMMON is not set
123CONFIG_BLK_DEV_LOOP=y 247CONFIG_BLK_DEV_LOOP=y
124CONFIG_BLK_DEV_CRYPTOLOOP=y 248CONFIG_BLK_DEV_CRYPTOLOOP=y
125# CONFIG_BLK_DEV_NBD is not set 249# CONFIG_BLK_DEV_NBD is not set
250# CONFIG_BLK_DEV_SX8 is not set
251# CONFIG_BLK_DEV_UB is not set
126CONFIG_BLK_DEV_RAM=y 252CONFIG_BLK_DEV_RAM=y
253CONFIG_BLK_DEV_RAM_COUNT=16
127CONFIG_BLK_DEV_RAM_SIZE=4096 254CONFIG_BLK_DEV_RAM_SIZE=4096
128CONFIG_BLK_DEV_INITRD=y 255CONFIG_BLK_DEV_INITRD=y
256# CONFIG_CDROM_PKTCDVD is not set
257
258#
259# IO Schedulers
260#
261CONFIG_IOSCHED_NOOP=y
262CONFIG_IOSCHED_AS=y
263CONFIG_IOSCHED_DEADLINE=y
264CONFIG_IOSCHED_CFQ=y
265# CONFIG_ATA_OVER_ETH is not set
129 266
130# 267#
131# ATA/ATAPI/MFM/RLL support 268# ATA/ATAPI/MFM/RLL support
@@ -135,6 +272,7 @@ CONFIG_BLK_DEV_INITRD=y
135# 272#
136# SCSI device support 273# SCSI device support
137# 274#
275# CONFIG_RAID_ATTRS is not set
138CONFIG_SCSI=y 276CONFIG_SCSI=y
139CONFIG_SCSI_PROC_FS=y 277CONFIG_SCSI_PROC_FS=y
140 278
@@ -147,53 +285,59 @@ CONFIG_CHR_DEV_ST=y
147CONFIG_BLK_DEV_SR=y 285CONFIG_BLK_DEV_SR=y
148# CONFIG_BLK_DEV_SR_VENDOR is not set 286# CONFIG_BLK_DEV_SR_VENDOR is not set
149CONFIG_CHR_DEV_SG=y 287CONFIG_CHR_DEV_SG=y
288# CONFIG_CHR_DEV_SCH is not set
150 289
151# 290#
152# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 291# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
153# 292#
154# CONFIG_SCSI_MULTI_LUN is not set 293# CONFIG_SCSI_MULTI_LUN is not set
155# CONFIG_SCSI_REPORT_LUNS is not set
156# CONFIG_SCSI_CONSTANTS is not set 294# CONFIG_SCSI_CONSTANTS is not set
157# CONFIG_SCSI_LOGGING is not set 295# CONFIG_SCSI_LOGGING is not set
158 296
159# 297#
298# SCSI Transport Attributes
299#
300CONFIG_SCSI_SPI_ATTRS=y
301# CONFIG_SCSI_FC_ATTRS is not set
302# CONFIG_SCSI_ISCSI_ATTRS is not set
303# CONFIG_SCSI_SAS_ATTRS is not set
304
305#
160# SCSI low-level drivers 306# SCSI low-level drivers
161# 307#
162# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 308# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
309# CONFIG_SCSI_3W_9XXX is not set
163# CONFIG_SCSI_ACARD is not set 310# CONFIG_SCSI_ACARD is not set
164# CONFIG_SCSI_AHA1740 is not set 311# CONFIG_SCSI_AHA1740 is not set
165# CONFIG_SCSI_AACRAID is not set 312# CONFIG_SCSI_AACRAID is not set
166# CONFIG_SCSI_AIC7XXX is not set 313# CONFIG_SCSI_AIC7XXX is not set
167# CONFIG_SCSI_AIC7XXX_OLD is not set 314# CONFIG_SCSI_AIC7XXX_OLD is not set
168# CONFIG_SCSI_AIC79XX is not set 315# CONFIG_SCSI_AIC79XX is not set
169# CONFIG_SCSI_ADVANSYS is not set 316# CONFIG_SCSI_DPT_I2O is not set
170# CONFIG_SCSI_MEGARAID is not set 317# CONFIG_MEGARAID_NEWGEN is not set
318# CONFIG_MEGARAID_LEGACY is not set
319# CONFIG_MEGARAID_SAS is not set
171# CONFIG_SCSI_SATA is not set 320# CONFIG_SCSI_SATA is not set
172# CONFIG_SCSI_BUSLOGIC is not set
173# CONFIG_SCSI_CPQFCTS is not set
174# CONFIG_SCSI_DMX3191D is not set 321# CONFIG_SCSI_DMX3191D is not set
175# CONFIG_SCSI_EATA is not set
176# CONFIG_SCSI_EATA_PIO is not set
177# CONFIG_SCSI_FUTURE_DOMAIN is not set 322# CONFIG_SCSI_FUTURE_DOMAIN is not set
178# CONFIG_SCSI_GDTH is not set
179# CONFIG_SCSI_IPS is not set 323# CONFIG_SCSI_IPS is not set
324# CONFIG_SCSI_INITIO is not set
180# CONFIG_SCSI_INIA100 is not set 325# CONFIG_SCSI_INIA100 is not set
181# CONFIG_SCSI_PPA is not set 326# CONFIG_SCSI_PPA is not set
182# CONFIG_SCSI_IMM is not set 327# CONFIG_SCSI_IMM is not set
183CONFIG_SCSI_LASI700=y 328CONFIG_SCSI_LASI700=y
184CONFIG_53C700_MEM_MAPPED=y
185CONFIG_53C700_LE_ON_BE=y 329CONFIG_53C700_LE_ON_BE=y
186CONFIG_SCSI_SYM53C8XX_2=y 330CONFIG_SCSI_SYM53C8XX_2=y
187CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1 331CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
188CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 332CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
189CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 333CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
190# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set 334# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set
335# CONFIG_SCSI_IPR is not set
191CONFIG_SCSI_ZALON=y 336CONFIG_SCSI_ZALON=y
192CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 337CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8
193CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 338CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32
194CONFIG_SCSI_NCR53C8XX_SYNC=20 339CONFIG_SCSI_NCR53C8XX_SYNC=20
195# CONFIG_SCSI_NCR53C8XX_PROFILE is not set 340# CONFIG_SCSI_NCR53C8XX_PROFILE is not set
196# CONFIG_SCSI_QLOGIC_ISP is not set
197# CONFIG_SCSI_QLOGIC_FC is not set 341# CONFIG_SCSI_QLOGIC_FC is not set
198# CONFIG_SCSI_QLOGIC_1280 is not set 342# CONFIG_SCSI_QLOGIC_1280 is not set
199CONFIG_SCSI_QLA2XXX=y 343CONFIG_SCSI_QLA2XXX=y
@@ -202,7 +346,8 @@ CONFIG_SCSI_QLA2XXX=y
202# CONFIG_SCSI_QLA2300 is not set 346# CONFIG_SCSI_QLA2300 is not set
203# CONFIG_SCSI_QLA2322 is not set 347# CONFIG_SCSI_QLA2322 is not set
204# CONFIG_SCSI_QLA6312 is not set 348# CONFIG_SCSI_QLA6312 is not set
205# CONFIG_SCSI_QLA6322 is not set 349# CONFIG_SCSI_QLA24XX is not set
350# CONFIG_SCSI_LPFC is not set
206# CONFIG_SCSI_SIM710 is not set 351# CONFIG_SCSI_SIM710 is not set
207# CONFIG_SCSI_DC395x is not set 352# CONFIG_SCSI_DC395x is not set
208# CONFIG_SCSI_DC390T is not set 353# CONFIG_SCSI_DC390T is not set
@@ -217,15 +362,20 @@ CONFIG_BLK_DEV_MD=y
217CONFIG_MD_LINEAR=y 362CONFIG_MD_LINEAR=y
218CONFIG_MD_RAID0=y 363CONFIG_MD_RAID0=y
219CONFIG_MD_RAID1=y 364CONFIG_MD_RAID1=y
365# CONFIG_MD_RAID10 is not set
220CONFIG_MD_RAID5=y 366CONFIG_MD_RAID5=y
221# CONFIG_MD_RAID6 is not set 367# CONFIG_MD_RAID6 is not set
222# CONFIG_MD_MULTIPATH is not set 368# CONFIG_MD_MULTIPATH is not set
369# CONFIG_MD_FAULTY is not set
223# CONFIG_BLK_DEV_DM is not set 370# CONFIG_BLK_DEV_DM is not set
224 371
225# 372#
226# Fusion MPT device support 373# Fusion MPT device support
227# 374#
228# CONFIG_FUSION is not set 375# CONFIG_FUSION is not set
376# CONFIG_FUSION_SPI is not set
377# CONFIG_FUSION_FC is not set
378# CONFIG_FUSION_SAS is not set
229 379
230# 380#
231# IEEE 1394 (FireWire) support 381# IEEE 1394 (FireWire) support
@@ -238,80 +388,23 @@ CONFIG_MD_RAID5=y
238# CONFIG_I2O is not set 388# CONFIG_I2O is not set
239 389
240# 390#
241# Macintosh device drivers 391# Network device support
242#
243
244#
245# Networking support
246#
247CONFIG_NET=y
248
249#
250# Networking options
251#
252CONFIG_PACKET=y
253CONFIG_PACKET_MMAP=y
254CONFIG_NETLINK_DEV=y
255CONFIG_UNIX=y
256# CONFIG_NET_KEY is not set
257CONFIG_INET=y
258CONFIG_IP_MULTICAST=y
259# CONFIG_IP_ADVANCED_ROUTER is not set
260CONFIG_IP_PNP=y
261# CONFIG_IP_PNP_DHCP is not set
262CONFIG_IP_PNP_BOOTP=y
263# CONFIG_IP_PNP_RARP is not set
264# CONFIG_NET_IPIP is not set
265# CONFIG_NET_IPGRE is not set
266# CONFIG_IP_MROUTE is not set
267# CONFIG_ARPD is not set
268# CONFIG_INET_ECN is not set
269# CONFIG_SYN_COOKIES is not set
270# CONFIG_INET_AH is not set
271# CONFIG_INET_ESP is not set
272# CONFIG_INET_IPCOMP is not set
273# CONFIG_IPV6 is not set
274# CONFIG_DECNET is not set
275# CONFIG_BRIDGE is not set
276# CONFIG_NETFILTER is not set
277
278#
279# SCTP Configuration (EXPERIMENTAL)
280#
281CONFIG_IPV6_SCTP__=y
282# CONFIG_IP_SCTP is not set
283# CONFIG_ATM is not set
284# CONFIG_VLAN_8021Q is not set
285# CONFIG_LLC2 is not set
286# CONFIG_IPX is not set
287# CONFIG_ATALK is not set
288# CONFIG_X25 is not set
289# CONFIG_LAPB is not set
290# CONFIG_NET_DIVERT is not set
291# CONFIG_ECONET is not set
292# CONFIG_WAN_ROUTER is not set
293# CONFIG_NET_HW_FLOWCONTROL is not set
294
295#
296# QoS and/or fair queueing
297#
298# CONFIG_NET_SCHED is not set
299
300#
301# Network testing
302# 392#
303# CONFIG_NET_PKTGEN is not set
304CONFIG_NETDEVICES=y 393CONFIG_NETDEVICES=y
394# CONFIG_DUMMY is not set
395# CONFIG_BONDING is not set
396# CONFIG_EQUALIZER is not set
397# CONFIG_TUN is not set
305 398
306# 399#
307# ARCnet devices 400# ARCnet devices
308# 401#
309# CONFIG_ARCNET is not set 402# CONFIG_ARCNET is not set
310# CONFIG_DUMMY is not set 403
311# CONFIG_BONDING is not set 404#
312# CONFIG_EQUALIZER is not set 405# PHY device support
313# CONFIG_TUN is not set 406#
314# CONFIG_ETHERTAP is not set 407# CONFIG_PHYLIB is not set
315 408
316# 409#
317# Ethernet (10 or 100Mbit) 410# Ethernet (10 or 100Mbit)
@@ -321,6 +414,7 @@ CONFIG_NET_ETHERNET=y
321CONFIG_LASI_82596=y 414CONFIG_LASI_82596=y
322# CONFIG_HAPPYMEAL is not set 415# CONFIG_HAPPYMEAL is not set
323# CONFIG_SUNGEM is not set 416# CONFIG_SUNGEM is not set
417# CONFIG_CASSINI is not set
324# CONFIG_NET_VENDOR_3COM is not set 418# CONFIG_NET_VENDOR_3COM is not set
325# CONFIG_NET_VENDOR_SMC is not set 419# CONFIG_NET_VENDOR_SMC is not set
326 420
@@ -336,6 +430,7 @@ CONFIG_TULIP=y
336# CONFIG_DE4X5 is not set 430# CONFIG_DE4X5 is not set
337# CONFIG_WINBOND_840 is not set 431# CONFIG_WINBOND_840 is not set
338# CONFIG_DM9102 is not set 432# CONFIG_DM9102 is not set
433# CONFIG_ULI526X is not set
339# CONFIG_DEPCA is not set 434# CONFIG_DEPCA is not set
340# CONFIG_HP100 is not set 435# CONFIG_HP100 is not set
341CONFIG_NET_PCI=y 436CONFIG_NET_PCI=y
@@ -361,30 +456,37 @@ CONFIG_NET_PCI=y
361# CONFIG_SUNDANCE is not set 456# CONFIG_SUNDANCE is not set
362# CONFIG_TLAN is not set 457# CONFIG_TLAN is not set
363# CONFIG_VIA_RHINE is not set 458# CONFIG_VIA_RHINE is not set
459# CONFIG_NET_POCKET is not set
364 460
365# 461#
366# Ethernet (1000 Mbit) 462# Ethernet (1000 Mbit)
367# 463#
368# CONFIG_ACENIC is not set 464CONFIG_ACENIC=y
369CONFIG_DL2K=y 465# CONFIG_ACENIC_OMIT_TIGON_I is not set
466# CONFIG_DL2K is not set
370# CONFIG_E1000 is not set 467# CONFIG_E1000 is not set
371# CONFIG_NS83820 is not set 468# CONFIG_NS83820 is not set
372# CONFIG_HAMACHI is not set 469# CONFIG_HAMACHI is not set
373# CONFIG_YELLOWFIN is not set 470# CONFIG_YELLOWFIN is not set
374# CONFIG_R8169 is not set 471# CONFIG_R8169 is not set
375# CONFIG_SIS190 is not set 472# CONFIG_SIS190 is not set
473# CONFIG_SKGE is not set
376# CONFIG_SK98LIN is not set 474# CONFIG_SK98LIN is not set
377# CONFIG_TIGON3 is not set 475# CONFIG_VIA_VELOCITY is not set
476CONFIG_TIGON3=y
477# CONFIG_BNX2 is not set
378 478
379# 479#
380# Ethernet (10000 Mbit) 480# Ethernet (10000 Mbit)
381# 481#
482# CONFIG_CHELSIO_T1 is not set
382# CONFIG_IXGB is not set 483# CONFIG_IXGB is not set
383# CONFIG_FDDI is not set 484# CONFIG_S2IO is not set
384# CONFIG_HIPPI is not set 485
385# CONFIG_PLIP is not set 486#
386# CONFIG_PPP is not set 487# Token Ring devices
387# CONFIG_SLIP is not set 488#
489# CONFIG_TR is not set
388 490
389# 491#
390# Wireless LAN (non-hamradio) 492# Wireless LAN (non-hamradio)
@@ -399,38 +501,30 @@ CONFIG_NET_RADIO=y
399# 501#
400# Wireless 802.11b ISA/PCI cards support 502# Wireless 802.11b ISA/PCI cards support
401# 503#
402CONFIG_AIRO=y
403# CONFIG_HERMES is not set 504# CONFIG_HERMES is not set
404# CONFIG_ATMEL is not set 505# CONFIG_ATMEL is not set
405CONFIG_NET_WIRELESS=y
406 506
407# 507#
408# Token Ring devices 508# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
409# 509#
410# CONFIG_TR is not set 510# CONFIG_PRISM54 is not set
411# CONFIG_NET_FC is not set 511# CONFIG_HOSTAP is not set
412# CONFIG_RCPCI is not set 512CONFIG_NET_WIRELESS=y
413# CONFIG_SHAPER is not set
414 513
415# 514#
416# Wan interfaces 515# Wan interfaces
417# 516#
418# CONFIG_WAN is not set 517# CONFIG_WAN is not set
419 518# CONFIG_FDDI is not set
420# 519# CONFIG_HIPPI is not set
421# Amateur Radio support 520# CONFIG_PLIP is not set
422# 521# CONFIG_PPP is not set
423# CONFIG_HAMRADIO is not set 522# CONFIG_SLIP is not set
424 523# CONFIG_NET_FC is not set
425# 524# CONFIG_SHAPER is not set
426# IrDA (infrared) support 525# CONFIG_NETCONSOLE is not set
427# 526# CONFIG_NETPOLL is not set
428# CONFIG_IRDA is not set 527# CONFIG_NET_POLL_CONTROLLER is not set
429
430#
431# Bluetooth support
432#
433# CONFIG_BT is not set
434 528
435# 529#
436# ISDN subsystem 530# ISDN subsystem
@@ -460,51 +554,67 @@ CONFIG_INPUT_EVDEV=y
460# CONFIG_INPUT_EVBUG is not set 554# CONFIG_INPUT_EVBUG is not set
461 555
462# 556#
463# Input I/O drivers
464#
465# CONFIG_GAMEPORT is not set
466CONFIG_SOUND_GAMEPORT=y
467CONFIG_SERIO=y
468# CONFIG_SERIO_SERPORT is not set
469# CONFIG_SERIO_PARKBD is not set
470CONFIG_SERIO_GSCPS2=y
471CONFIG_HP_SDC=y
472CONFIG_HIL_MLC=y
473# CONFIG_SERIO_PCIPS2 is not set
474
475#
476# Input Device Drivers 557# Input Device Drivers
477# 558#
478CONFIG_INPUT_KEYBOARD=y 559CONFIG_INPUT_KEYBOARD=y
479# CONFIG_KEYBOARD_ATKBD is not set 560# CONFIG_KEYBOARD_ATKBD is not set
480# CONFIG_KEYBOARD_SUNKBD is not set 561# CONFIG_KEYBOARD_SUNKBD is not set
562# CONFIG_KEYBOARD_LKKBD is not set
481# CONFIG_KEYBOARD_XTKBD is not set 563# CONFIG_KEYBOARD_XTKBD is not set
482# CONFIG_KEYBOARD_NEWTON is not set 564# CONFIG_KEYBOARD_NEWTON is not set
565CONFIG_KEYBOARD_HIL_OLD=y
483CONFIG_KEYBOARD_HIL=y 566CONFIG_KEYBOARD_HIL=y
484CONFIG_INPUT_MOUSE=y 567CONFIG_INPUT_MOUSE=y
485# CONFIG_MOUSE_PS2 is not set 568# CONFIG_MOUSE_PS2 is not set
486# CONFIG_MOUSE_SERIAL is not set 569# CONFIG_MOUSE_SERIAL is not set
570# CONFIG_MOUSE_VSXXXAA is not set
487# CONFIG_MOUSE_HIL is not set 571# CONFIG_MOUSE_HIL is not set
488CONFIG_INPUT_JOYSTICK=y 572CONFIG_INPUT_JOYSTICK=y
573# CONFIG_JOYSTICK_ANALOG is not set
574# CONFIG_JOYSTICK_A3D is not set
575# CONFIG_JOYSTICK_ADI is not set
576# CONFIG_JOYSTICK_COBRA is not set
577# CONFIG_JOYSTICK_GF2K is not set
578# CONFIG_JOYSTICK_GRIP is not set
579# CONFIG_JOYSTICK_GRIP_MP is not set
580# CONFIG_JOYSTICK_GUILLEMOT is not set
581# CONFIG_JOYSTICK_INTERACT is not set
582# CONFIG_JOYSTICK_SIDEWINDER is not set
583# CONFIG_JOYSTICK_TMDC is not set
489# CONFIG_JOYSTICK_IFORCE is not set 584# CONFIG_JOYSTICK_IFORCE is not set
490# CONFIG_JOYSTICK_WARRIOR is not set 585# CONFIG_JOYSTICK_WARRIOR is not set
491# CONFIG_JOYSTICK_MAGELLAN is not set 586# CONFIG_JOYSTICK_MAGELLAN is not set
492# CONFIG_JOYSTICK_SPACEORB is not set 587# CONFIG_JOYSTICK_SPACEORB is not set
493# CONFIG_JOYSTICK_SPACEBALL is not set 588# CONFIG_JOYSTICK_SPACEBALL is not set
494# CONFIG_JOYSTICK_STINGER is not set 589# CONFIG_JOYSTICK_STINGER is not set
495# CONFIG_JOYSTICK_TWIDDLER is not set 590# CONFIG_JOYSTICK_TWIDJOY is not set
496# CONFIG_JOYSTICK_DB9 is not set 591# CONFIG_JOYSTICK_DB9 is not set
497# CONFIG_JOYSTICK_GAMECON is not set 592# CONFIG_JOYSTICK_GAMECON is not set
498# CONFIG_JOYSTICK_TURBOGRAFX is not set 593# CONFIG_JOYSTICK_TURBOGRAFX is not set
499# CONFIG_INPUT_JOYDUMP is not set 594# CONFIG_JOYSTICK_JOYDUMP is not set
500CONFIG_INPUT_TOUCHSCREEN=y 595CONFIG_INPUT_TOUCHSCREEN=y
501# CONFIG_TOUCHSCREEN_GUNZE is not set 596# CONFIG_TOUCHSCREEN_GUNZE is not set
597# CONFIG_TOUCHSCREEN_ELO is not set
598# CONFIG_TOUCHSCREEN_MTOUCH is not set
599# CONFIG_TOUCHSCREEN_MK712 is not set
502CONFIG_INPUT_MISC=y 600CONFIG_INPUT_MISC=y
503# CONFIG_INPUT_PCSPKR is not set
504# CONFIG_INPUT_UINPUT is not set 601# CONFIG_INPUT_UINPUT is not set
505CONFIG_HP_SDC_RTC=y 602CONFIG_HP_SDC_RTC=y
506 603
507# 604#
605# Hardware I/O ports
606#
607CONFIG_SERIO=y
608# CONFIG_SERIO_SERPORT is not set
609# CONFIG_SERIO_PARKBD is not set
610CONFIG_SERIO_GSCPS2=y
611CONFIG_HP_SDC=y
612CONFIG_HIL_MLC=y
613# CONFIG_SERIO_PCIPS2 is not set
614# CONFIG_SERIO_RAW is not set
615# CONFIG_GAMEPORT is not set
616
617#
508# Character devices 618# Character devices
509# 619#
510CONFIG_VT=y 620CONFIG_VT=y
@@ -522,16 +632,16 @@ CONFIG_SERIAL_8250_EXTENDED=y
522CONFIG_SERIAL_8250_MANY_PORTS=y 632CONFIG_SERIAL_8250_MANY_PORTS=y
523CONFIG_SERIAL_8250_SHARE_IRQ=y 633CONFIG_SERIAL_8250_SHARE_IRQ=y
524# CONFIG_SERIAL_8250_DETECT_IRQ is not set 634# CONFIG_SERIAL_8250_DETECT_IRQ is not set
525# CONFIG_SERIAL_8250_MULTIPORT is not set
526# CONFIG_SERIAL_8250_RSA is not set 635# CONFIG_SERIAL_8250_RSA is not set
527 636
528# 637#
529# Non-8250 serial port support 638# Non-8250 serial port support
530# 639#
531# CONFIG_SERIAL_MUX is not set 640CONFIG_SERIAL_MUX=y
532# CONFIG_PDC_CONSOLE is not set 641CONFIG_SERIAL_MUX_CONSOLE=y
533CONFIG_SERIAL_CORE=y 642CONFIG_SERIAL_CORE=y
534CONFIG_SERIAL_CORE_CONSOLE=y 643CONFIG_SERIAL_CORE_CONSOLE=y
644# CONFIG_SERIAL_JSM is not set
535CONFIG_UNIX98_PTYS=y 645CONFIG_UNIX98_PTYS=y
536CONFIG_LEGACY_PTYS=y 646CONFIG_LEGACY_PTYS=y
537CONFIG_LEGACY_PTY_COUNT=256 647CONFIG_LEGACY_PTY_COUNT=256
@@ -541,12 +651,6 @@ CONFIG_PRINTER=y
541# CONFIG_TIPAR is not set 651# CONFIG_TIPAR is not set
542 652
543# 653#
544# Mice
545#
546# CONFIG_BUSMOUSE is not set
547# CONFIG_QIC02_TAPE is not set
548
549#
550# IPMI 654# IPMI
551# 655#
552# CONFIG_IPMI_HANDLER is not set 656# CONFIG_IPMI_HANDLER is not set
@@ -555,7 +659,6 @@ CONFIG_PRINTER=y
555# Watchdog Cards 659# Watchdog Cards
556# 660#
557# CONFIG_WATCHDOG is not set 661# CONFIG_WATCHDOG is not set
558# CONFIG_NVRAM is not set
559CONFIG_GEN_RTC=y 662CONFIG_GEN_RTC=y
560# CONFIG_GEN_RTC_X is not set 663# CONFIG_GEN_RTC_X is not set
561# CONFIG_DTLK is not set 664# CONFIG_DTLK is not set
@@ -565,21 +668,40 @@ CONFIG_GEN_RTC=y
565# 668#
566# Ftape, the floppy tape device driver 669# Ftape, the floppy tape device driver
567# 670#
568# CONFIG_FTAPE is not set
569# CONFIG_AGP is not set
570# CONFIG_DRM is not set 671# CONFIG_DRM is not set
571# CONFIG_RAW_DRIVER is not set 672# CONFIG_RAW_DRIVER is not set
572 673
573# 674#
675# TPM devices
676#
677# CONFIG_TCG_TPM is not set
678
679#
574# I2C support 680# I2C support
575# 681#
576# CONFIG_I2C is not set 682# CONFIG_I2C is not set
577 683
578# 684#
685# Dallas's 1-wire bus
686#
687# CONFIG_W1 is not set
688
689#
690# Hardware Monitoring support
691#
692CONFIG_HWMON=y
693# CONFIG_HWMON_VID is not set
694# CONFIG_HWMON_DEBUG_CHIP is not set
695
696#
579# Misc devices 697# Misc devices
580# 698#
581 699
582# 700#
701# Multimedia Capabilities Port drivers
702#
703
704#
583# Multimedia devices 705# Multimedia devices
584# 706#
585# CONFIG_VIDEO_DEV is not set 707# CONFIG_VIDEO_DEV is not set
@@ -593,34 +715,45 @@ CONFIG_GEN_RTC=y
593# Graphics support 715# Graphics support
594# 716#
595CONFIG_FB=y 717CONFIG_FB=y
718CONFIG_FB_CFB_FILLRECT=y
719CONFIG_FB_CFB_COPYAREA=y
720CONFIG_FB_CFB_IMAGEBLIT=y
721CONFIG_FB_SOFT_CURSOR=y
722# CONFIG_FB_MACMODES is not set
723# CONFIG_FB_MODE_HELPERS is not set
724# CONFIG_FB_TILEBLITTING is not set
725# CONFIG_FB_CIRRUS is not set
596# CONFIG_FB_PM2 is not set 726# CONFIG_FB_PM2 is not set
597# CONFIG_FB_CYBER2000 is not set 727# CONFIG_FB_CYBER2000 is not set
728# CONFIG_FB_ASILIANT is not set
598# CONFIG_FB_IMSTT is not set 729# CONFIG_FB_IMSTT is not set
599CONFIG_FB_STI=y 730CONFIG_FB_STI=y
731# CONFIG_FB_NVIDIA is not set
600# CONFIG_FB_RIVA is not set 732# CONFIG_FB_RIVA is not set
601# CONFIG_FB_MATROX is not set 733# CONFIG_FB_MATROX is not set
602# CONFIG_FB_RADEON_OLD is not set 734# CONFIG_FB_RADEON_OLD is not set
603# CONFIG_FB_RADEON is not set 735# CONFIG_FB_RADEON is not set
604# CONFIG_FB_ATY128 is not set 736# CONFIG_FB_ATY128 is not set
605# CONFIG_FB_ATY is not set 737# CONFIG_FB_ATY is not set
738# CONFIG_FB_SAVAGE is not set
606# CONFIG_FB_SIS is not set 739# CONFIG_FB_SIS is not set
607# CONFIG_FB_NEOMAGIC is not set 740# CONFIG_FB_NEOMAGIC is not set
608# CONFIG_FB_KYRO is not set 741# CONFIG_FB_KYRO is not set
609# CONFIG_FB_3DFX is not set 742# CONFIG_FB_3DFX is not set
610# CONFIG_FB_VOODOO1 is not set 743# CONFIG_FB_VOODOO1 is not set
744# CONFIG_FB_CYBLA is not set
611# CONFIG_FB_TRIDENT is not set 745# CONFIG_FB_TRIDENT is not set
746# CONFIG_FB_S1D13XXX is not set
612# CONFIG_FB_VIRTUAL is not set 747# CONFIG_FB_VIRTUAL is not set
613 748
614# 749#
615# Console display driver support 750# Console display driver support
616# 751#
617# CONFIG_MDA_CONSOLE is not set 752CONFIG_DUMMY_CONSOLE=y
618CONFIG_STI_CONSOLE=y
619CONFIG_DUMMY_CONSOLE_COLUMNS=160 753CONFIG_DUMMY_CONSOLE_COLUMNS=160
620CONFIG_DUMMY_CONSOLE_ROWS=64 754CONFIG_DUMMY_CONSOLE_ROWS=64
621CONFIG_DUMMY_CONSOLE=y
622CONFIG_FRAMEBUFFER_CONSOLE=y 755CONFIG_FRAMEBUFFER_CONSOLE=y
623CONFIG_PCI_CONSOLE=y 756CONFIG_STI_CONSOLE=y
624# CONFIG_FONTS is not set 757# CONFIG_FONTS is not set
625CONFIG_FONT_8x8=y 758CONFIG_FONT_8x8=y
626CONFIG_FONT_8x16=y 759CONFIG_FONT_8x16=y
@@ -629,6 +762,7 @@ CONFIG_FONT_8x16=y
629# Logo configuration 762# Logo configuration
630# 763#
631# CONFIG_LOGO is not set 764# CONFIG_LOGO is not set
765# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
632 766
633# 767#
634# Sound 768# Sound
@@ -638,17 +772,94 @@ CONFIG_SOUND=y
638# 772#
639# Advanced Linux Sound Architecture 773# Advanced Linux Sound Architecture
640# 774#
641# CONFIG_SND is not set 775CONFIG_SND=y
776CONFIG_SND_TIMER=y
777CONFIG_SND_PCM=y
778CONFIG_SND_SEQUENCER=y
779# CONFIG_SND_SEQ_DUMMY is not set
780CONFIG_SND_OSSEMUL=y
781CONFIG_SND_MIXER_OSS=y
782CONFIG_SND_PCM_OSS=y
783CONFIG_SND_SEQUENCER_OSS=y
784# CONFIG_SND_VERBOSE_PRINTK is not set
785# CONFIG_SND_DEBUG is not set
786
787#
788# Generic devices
789#
790# CONFIG_SND_DUMMY is not set
791# CONFIG_SND_VIRMIDI is not set
792# CONFIG_SND_MTPAV is not set
793# CONFIG_SND_SERIAL_U16550 is not set
794# CONFIG_SND_MPU401 is not set
795CONFIG_SND_AC97_CODEC=y
796CONFIG_SND_AC97_BUS=y
797
798#
799# PCI devices
800#
801# CONFIG_SND_ALI5451 is not set
802# CONFIG_SND_ATIIXP is not set
803# CONFIG_SND_ATIIXP_MODEM is not set
804# CONFIG_SND_AU8810 is not set
805# CONFIG_SND_AU8820 is not set
806# CONFIG_SND_AU8830 is not set
807# CONFIG_SND_AZT3328 is not set
808# CONFIG_SND_BT87X is not set
809# CONFIG_SND_CS46XX is not set
810# CONFIG_SND_CS4281 is not set
811# CONFIG_SND_EMU10K1 is not set
812# CONFIG_SND_EMU10K1X is not set
813# CONFIG_SND_CA0106 is not set
814# CONFIG_SND_KORG1212 is not set
815# CONFIG_SND_MIXART is not set
816# CONFIG_SND_NM256 is not set
817# CONFIG_SND_RME32 is not set
818# CONFIG_SND_RME96 is not set
819# CONFIG_SND_RME9652 is not set
820# CONFIG_SND_HDSP is not set
821# CONFIG_SND_HDSPM is not set
822# CONFIG_SND_TRIDENT is not set
823# CONFIG_SND_YMFPCI is not set
824CONFIG_SND_AD1889=y
825# CONFIG_SND_AD1889_OPL3 is not set
826# CONFIG_SND_CMIPCI is not set
827# CONFIG_SND_ENS1370 is not set
828# CONFIG_SND_ENS1371 is not set
829# CONFIG_SND_ES1938 is not set
830# CONFIG_SND_ES1968 is not set
831# CONFIG_SND_MAESTRO3 is not set
832# CONFIG_SND_FM801 is not set
833# CONFIG_SND_ICE1712 is not set
834# CONFIG_SND_ICE1724 is not set
835# CONFIG_SND_INTEL8X0 is not set
836# CONFIG_SND_INTEL8X0M is not set
837# CONFIG_SND_SONICVIBES is not set
838# CONFIG_SND_VIA82XX is not set
839# CONFIG_SND_VIA82XX_MODEM is not set
840# CONFIG_SND_VX222 is not set
841# CONFIG_SND_HDA_INTEL is not set
842
843#
844# USB devices
845#
846# CONFIG_SND_USB_AUDIO is not set
847
848#
849# GSC devices
850#
851CONFIG_SND_HARMONY=y
642 852
643# 853#
644# Open Sound System 854# Open Sound System
645# 855#
646# CONFIG_SOUND_PRIME is not set 856# CONFIG_SOUND_PRIME is not set
647# CONFIG_SOUND_HARMONY is not set
648 857
649# 858#
650# USB support 859# USB support
651# 860#
861CONFIG_USB_ARCH_HAS_HCD=y
862CONFIG_USB_ARCH_HAS_OHCI=y
652CONFIG_USB=y 863CONFIG_USB=y
653CONFIG_USB_DEBUG=y 864CONFIG_USB_DEBUG=y
654 865
@@ -658,26 +869,36 @@ CONFIG_USB_DEBUG=y
658# CONFIG_USB_DEVICEFS is not set 869# CONFIG_USB_DEVICEFS is not set
659# CONFIG_USB_BANDWIDTH is not set 870# CONFIG_USB_BANDWIDTH is not set
660# CONFIG_USB_DYNAMIC_MINORS is not set 871# CONFIG_USB_DYNAMIC_MINORS is not set
872# CONFIG_USB_OTG is not set
661 873
662# 874#
663# USB Host Controller Drivers 875# USB Host Controller Drivers
664# 876#
665CONFIG_USB_EHCI_HCD=y 877CONFIG_USB_EHCI_HCD=y
878# CONFIG_USB_EHCI_SPLIT_ISO is not set
879# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
880# CONFIG_USB_ISP116X_HCD is not set
666CONFIG_USB_OHCI_HCD=y 881CONFIG_USB_OHCI_HCD=y
882# CONFIG_USB_OHCI_BIG_ENDIAN is not set
883CONFIG_USB_OHCI_LITTLE_ENDIAN=y
667# CONFIG_USB_UHCI_HCD is not set 884# CONFIG_USB_UHCI_HCD is not set
885# CONFIG_USB_SL811_HCD is not set
668 886
669# 887#
670# USB Device Class drivers 888# USB Device Class drivers
671# 889#
672# CONFIG_USB_AUDIO is not set 890# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
673# CONFIG_USB_BLUETOOTH_TTY is not set 891# CONFIG_USB_BLUETOOTH_TTY is not set
674# CONFIG_USB_MIDI is not set
675# CONFIG_USB_ACM is not set 892# CONFIG_USB_ACM is not set
676# CONFIG_USB_PRINTER is not set 893# CONFIG_USB_PRINTER is not set
894
895#
896# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
897#
677# CONFIG_USB_STORAGE is not set 898# CONFIG_USB_STORAGE is not set
678 899
679# 900#
680# USB Human Interface Devices (HID) 901# USB Input Devices
681# 902#
682# CONFIG_USB_HID is not set 903# CONFIG_USB_HID is not set
683 904
@@ -688,16 +909,23 @@ CONFIG_USB_OHCI_HCD=y
688# CONFIG_USB_MOUSE is not set 909# CONFIG_USB_MOUSE is not set
689# CONFIG_USB_AIPTEK is not set 910# CONFIG_USB_AIPTEK is not set
690# CONFIG_USB_WACOM is not set 911# CONFIG_USB_WACOM is not set
912# CONFIG_USB_ACECAD is not set
691# CONFIG_USB_KBTAB is not set 913# CONFIG_USB_KBTAB is not set
692# CONFIG_USB_POWERMATE is not set 914# CONFIG_USB_POWERMATE is not set
915# CONFIG_USB_MTOUCH is not set
916# CONFIG_USB_ITMTOUCH is not set
917# CONFIG_USB_EGALAX is not set
918# CONFIG_USB_YEALINK is not set
693# CONFIG_USB_XPAD is not set 919# CONFIG_USB_XPAD is not set
920# CONFIG_USB_ATI_REMOTE is not set
921# CONFIG_USB_KEYSPAN_REMOTE is not set
922# CONFIG_USB_APPLETOUCH is not set
694 923
695# 924#
696# USB Imaging devices 925# USB Imaging devices
697# 926#
698# CONFIG_USB_MDC800 is not set 927# CONFIG_USB_MDC800 is not set
699# CONFIG_USB_MICROTEK is not set 928# CONFIG_USB_MICROTEK is not set
700# CONFIG_USB_HPUSBSCSI is not set
701 929
702# 930#
703# USB Multimedia devices 931# USB Multimedia devices
@@ -709,13 +937,15 @@ CONFIG_USB_OHCI_HCD=y
709# 937#
710 938
711# 939#
712# USB Network adaptors 940# USB Network Adapters
713# 941#
714# CONFIG_USB_CATC is not set 942# CONFIG_USB_CATC is not set
715# CONFIG_USB_KAWETH is not set 943# CONFIG_USB_KAWETH is not set
716# CONFIG_USB_PEGASUS is not set 944# CONFIG_USB_PEGASUS is not set
717# CONFIG_USB_RTL8150 is not set 945# CONFIG_USB_RTL8150 is not set
718# CONFIG_USB_USBNET is not set 946# CONFIG_USB_USBNET is not set
947# CONFIG_USB_ZD1201 is not set
948CONFIG_USB_MON=y
719 949
720# 950#
721# USB port drivers 951# USB port drivers
@@ -732,12 +962,21 @@ CONFIG_USB_OHCI_HCD=y
732# 962#
733# CONFIG_USB_EMI62 is not set 963# CONFIG_USB_EMI62 is not set
734# CONFIG_USB_EMI26 is not set 964# CONFIG_USB_EMI26 is not set
735# CONFIG_USB_TIGL is not set
736# CONFIG_USB_AUERSWALD is not set 965# CONFIG_USB_AUERSWALD is not set
737# CONFIG_USB_RIO500 is not set 966# CONFIG_USB_RIO500 is not set
738# CONFIG_USB_LEGOTOWER is not set 967# CONFIG_USB_LEGOTOWER is not set
739# CONFIG_USB_LCD is not set 968# CONFIG_USB_LCD is not set
740# CONFIG_USB_LED is not set 969# CONFIG_USB_LED is not set
970# CONFIG_USB_CYTHERM is not set
971# CONFIG_USB_PHIDGETKIT is not set
972# CONFIG_USB_PHIDGETSERVO is not set
973# CONFIG_USB_IDMOUSE is not set
974# CONFIG_USB_SISUSBVGA is not set
975# CONFIG_USB_LD is not set
976
977#
978# USB DSL modem support
979#
741 980
742# 981#
743# USB Gadget Support 982# USB Gadget Support
@@ -745,22 +984,41 @@ CONFIG_USB_OHCI_HCD=y
745# CONFIG_USB_GADGET is not set 984# CONFIG_USB_GADGET is not set
746 985
747# 986#
987# MMC/SD Card support
988#
989# CONFIG_MMC is not set
990
991#
992# InfiniBand support
993#
994# CONFIG_INFINIBAND is not set
995
996#
997# SN Devices
998#
999
1000#
748# File systems 1001# File systems
749# 1002#
750CONFIG_EXT2_FS=y 1003CONFIG_EXT2_FS=y
751# CONFIG_EXT2_FS_XATTR is not set 1004# CONFIG_EXT2_FS_XATTR is not set
1005# CONFIG_EXT2_FS_XIP is not set
752CONFIG_EXT3_FS=y 1006CONFIG_EXT3_FS=y
753# CONFIG_EXT3_FS_XATTR is not set 1007# CONFIG_EXT3_FS_XATTR is not set
754CONFIG_JBD=y 1008CONFIG_JBD=y
755# CONFIG_JBD_DEBUG is not set 1009# CONFIG_JBD_DEBUG is not set
756# CONFIG_REISERFS_FS is not set 1010# CONFIG_REISERFS_FS is not set
757# CONFIG_JFS_FS is not set 1011# CONFIG_JFS_FS is not set
1012# CONFIG_FS_POSIX_ACL is not set
758# CONFIG_XFS_FS is not set 1013# CONFIG_XFS_FS is not set
759# CONFIG_MINIX_FS is not set 1014# CONFIG_MINIX_FS is not set
760# CONFIG_ROMFS_FS is not set 1015# CONFIG_ROMFS_FS is not set
1016CONFIG_INOTIFY=y
761# CONFIG_QUOTA is not set 1017# CONFIG_QUOTA is not set
1018CONFIG_DNOTIFY=y
762# CONFIG_AUTOFS_FS is not set 1019# CONFIG_AUTOFS_FS is not set
763# CONFIG_AUTOFS4_FS is not set 1020# CONFIG_AUTOFS4_FS is not set
1021# CONFIG_FUSE_FS is not set
764 1022
765# 1023#
766# CD-ROM/DVD Filesystems 1024# CD-ROM/DVD Filesystems
@@ -773,7 +1031,8 @@ CONFIG_JOLIET=y
773# 1031#
774# DOS/FAT/NT Filesystems 1032# DOS/FAT/NT Filesystems
775# 1033#
776# CONFIG_FAT_FS is not set 1034# CONFIG_MSDOS_FS is not set
1035# CONFIG_VFAT_FS is not set
777# CONFIG_NTFS_FS is not set 1036# CONFIG_NTFS_FS is not set
778 1037
779# 1038#
@@ -781,11 +1040,11 @@ CONFIG_JOLIET=y
781# 1040#
782CONFIG_PROC_FS=y 1041CONFIG_PROC_FS=y
783CONFIG_PROC_KCORE=y 1042CONFIG_PROC_KCORE=y
784# CONFIG_DEVFS_FS is not set 1043CONFIG_SYSFS=y
785# CONFIG_DEVPTS_FS_XATTR is not set
786CONFIG_TMPFS=y 1044CONFIG_TMPFS=y
787# CONFIG_HUGETLB_PAGE is not set 1045# CONFIG_HUGETLB_PAGE is not set
788CONFIG_RAMFS=y 1046CONFIG_RAMFS=y
1047# CONFIG_RELAYFS_FS is not set
789 1048
790# 1049#
791# Miscellaneous filesystems 1050# Miscellaneous filesystems
@@ -809,23 +1068,28 @@ CONFIG_RAMFS=y
809# 1068#
810CONFIG_NFS_FS=y 1069CONFIG_NFS_FS=y
811CONFIG_NFS_V3=y 1070CONFIG_NFS_V3=y
1071# CONFIG_NFS_V3_ACL is not set
812# CONFIG_NFS_V4 is not set 1072# CONFIG_NFS_V4 is not set
813# CONFIG_NFS_DIRECTIO is not set 1073# CONFIG_NFS_DIRECTIO is not set
814CONFIG_NFSD=y 1074CONFIG_NFSD=y
815CONFIG_NFSD_V3=y 1075CONFIG_NFSD_V3=y
1076# CONFIG_NFSD_V3_ACL is not set
816# CONFIG_NFSD_V4 is not set 1077# CONFIG_NFSD_V4 is not set
817CONFIG_NFSD_TCP=y 1078CONFIG_NFSD_TCP=y
818CONFIG_ROOT_NFS=y 1079CONFIG_ROOT_NFS=y
819CONFIG_LOCKD=y 1080CONFIG_LOCKD=y
820CONFIG_LOCKD_V4=y 1081CONFIG_LOCKD_V4=y
821CONFIG_EXPORTFS=y 1082CONFIG_EXPORTFS=y
1083CONFIG_NFS_COMMON=y
822CONFIG_SUNRPC=y 1084CONFIG_SUNRPC=y
823# CONFIG_SUNRPC_GSS is not set 1085# CONFIG_RPCSEC_GSS_KRB5 is not set
1086# CONFIG_RPCSEC_GSS_SPKM3 is not set
824# CONFIG_SMB_FS is not set 1087# CONFIG_SMB_FS is not set
825# CONFIG_CIFS is not set 1088# CONFIG_CIFS is not set
826# CONFIG_NCP_FS is not set 1089# CONFIG_NCP_FS is not set
827# CONFIG_CODA_FS is not set 1090# CONFIG_CODA_FS is not set
828# CONFIG_AFS_FS is not set 1091# CONFIG_AFS_FS is not set
1092# CONFIG_9P_FS is not set
829 1093
830# 1094#
831# Partition Types 1095# Partition Types
@@ -861,6 +1125,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
861# CONFIG_NLS_ISO8859_8 is not set 1125# CONFIG_NLS_ISO8859_8 is not set
862# CONFIG_NLS_CODEPAGE_1250 is not set 1126# CONFIG_NLS_CODEPAGE_1250 is not set
863# CONFIG_NLS_CODEPAGE_1251 is not set 1127# CONFIG_NLS_CODEPAGE_1251 is not set
1128# CONFIG_NLS_ASCII is not set
864# CONFIG_NLS_ISO8859_1 is not set 1129# CONFIG_NLS_ISO8859_1 is not set
865# CONFIG_NLS_ISO8859_2 is not set 1130# CONFIG_NLS_ISO8859_2 is not set
866# CONFIG_NLS_ISO8859_3 is not set 1131# CONFIG_NLS_ISO8859_3 is not set
@@ -885,17 +1150,24 @@ CONFIG_OPROFILE=y
885# 1150#
886# Kernel hacking 1151# Kernel hacking
887# 1152#
1153# CONFIG_PRINTK_TIME is not set
888CONFIG_DEBUG_KERNEL=y 1154CONFIG_DEBUG_KERNEL=y
889# CONFIG_DEBUG_SLAB is not set
890CONFIG_MAGIC_SYSRQ=y 1155CONFIG_MAGIC_SYSRQ=y
1156CONFIG_LOG_BUF_SHIFT=15
1157CONFIG_DETECT_SOFTLOCKUP=y
1158# CONFIG_SCHEDSTATS is not set
1159# CONFIG_DEBUG_SLAB is not set
891# CONFIG_DEBUG_SPINLOCK is not set 1160# CONFIG_DEBUG_SPINLOCK is not set
892# CONFIG_DEBUG_RWLOCK is not set 1161# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
893CONFIG_FRAME_POINTER=y 1162# CONFIG_DEBUG_KOBJECT is not set
894# CONFIG_DEBUG_INFO is not set 1163# CONFIG_DEBUG_INFO is not set
1164# CONFIG_DEBUG_IOREMAP is not set
1165# CONFIG_DEBUG_FS is not set
895 1166
896# 1167#
897# Security options 1168# Security options
898# 1169#
1170# CONFIG_KEYS is not set
899# CONFIG_SECURITY is not set 1171# CONFIG_SECURITY is not set
900 1172
901# 1173#
@@ -909,6 +1181,8 @@ CONFIG_CRYPTO=y
909# CONFIG_CRYPTO_SHA1 is not set 1181# CONFIG_CRYPTO_SHA1 is not set
910# CONFIG_CRYPTO_SHA256 is not set 1182# CONFIG_CRYPTO_SHA256 is not set
911# CONFIG_CRYPTO_SHA512 is not set 1183# CONFIG_CRYPTO_SHA512 is not set
1184# CONFIG_CRYPTO_WP512 is not set
1185# CONFIG_CRYPTO_TGR192 is not set
912# CONFIG_CRYPTO_DES is not set 1186# CONFIG_CRYPTO_DES is not set
913# CONFIG_CRYPTO_BLOWFISH is not set 1187# CONFIG_CRYPTO_BLOWFISH is not set
914# CONFIG_CRYPTO_TWOFISH is not set 1188# CONFIG_CRYPTO_TWOFISH is not set
@@ -916,11 +1190,23 @@ CONFIG_CRYPTO=y
916# CONFIG_CRYPTO_AES is not set 1190# CONFIG_CRYPTO_AES is not set
917# CONFIG_CRYPTO_CAST5 is not set 1191# CONFIG_CRYPTO_CAST5 is not set
918# CONFIG_CRYPTO_CAST6 is not set 1192# CONFIG_CRYPTO_CAST6 is not set
1193# CONFIG_CRYPTO_TEA is not set
919# CONFIG_CRYPTO_ARC4 is not set 1194# CONFIG_CRYPTO_ARC4 is not set
1195# CONFIG_CRYPTO_KHAZAD is not set
1196# CONFIG_CRYPTO_ANUBIS is not set
920# CONFIG_CRYPTO_DEFLATE is not set 1197# CONFIG_CRYPTO_DEFLATE is not set
1198# CONFIG_CRYPTO_MICHAEL_MIC is not set
1199# CONFIG_CRYPTO_CRC32C is not set
921# CONFIG_CRYPTO_TEST is not set 1200# CONFIG_CRYPTO_TEST is not set
922 1201
923# 1202#
1203# Hardware crypto devices
1204#
1205
1206#
924# Library routines 1207# Library routines
925# 1208#
1209# CONFIG_CRC_CCITT is not set
1210# CONFIG_CRC16 is not set
926CONFIG_CRC32=y 1211CONFIG_CRC32=y
1212# CONFIG_LIBCRC32C is not set
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index f46a07a79218..e15f09eaed12 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -27,6 +27,7 @@
27#include <asm/page.h> 27#include <asm/page.h>
28#include <asm/pgalloc.h> 28#include <asm/pgalloc.h>
29#include <asm/processor.h> 29#include <asm/processor.h>
30#include <asm/sections.h>
30 31
31int split_tlb; 32int split_tlb;
32int dcache_stride; 33int dcache_stride;
@@ -207,6 +208,9 @@ parisc_cache_init(void)
207 208
208 /* "New and Improved" version from Jim Hull 209 /* "New and Improved" version from Jim Hull
209 * (1 << (cc_block-1)) * (cc_line << (4 + cnf.cc_shift)) 210 * (1 << (cc_block-1)) * (cc_line << (4 + cnf.cc_shift))
211 * The following CAFL_STRIDE is an optimized version, see
212 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023625.html
213 * http://lists.parisc-linux.org/pipermail/parisc-linux/2004-June/023671.html
210 */ 214 */
211#define CAFL_STRIDE(cnf) (cnf.cc_line << (3 + cnf.cc_block + cnf.cc_shift)) 215#define CAFL_STRIDE(cnf) (cnf.cc_line << (3 + cnf.cc_block + cnf.cc_shift))
212 dcache_stride = CAFL_STRIDE(cache_info.dc_conf); 216 dcache_stride = CAFL_STRIDE(cache_info.dc_conf);
@@ -339,17 +343,15 @@ int parisc_cache_flush_threshold = FLUSH_THRESHOLD;
339void parisc_setup_cache_timing(void) 343void parisc_setup_cache_timing(void)
340{ 344{
341 unsigned long rangetime, alltime; 345 unsigned long rangetime, alltime;
342 extern char _text; /* start of kernel code, defined by linker */
343 extern char _end; /* end of BSS, defined by linker */
344 unsigned long size; 346 unsigned long size;
345 347
346 alltime = mfctl(16); 348 alltime = mfctl(16);
347 flush_data_cache(); 349 flush_data_cache();
348 alltime = mfctl(16) - alltime; 350 alltime = mfctl(16) - alltime;
349 351
350 size = (unsigned long)(&_end - _text); 352 size = (unsigned long)(_end - _text);
351 rangetime = mfctl(16); 353 rangetime = mfctl(16);
352 flush_kernel_dcache_range((unsigned long)&_text, size); 354 flush_kernel_dcache_range((unsigned long)_text, size);
353 rangetime = mfctl(16) - rangetime; 355 rangetime = mfctl(16) - rangetime;
354 356
355 printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n", 357 printk(KERN_DEBUG "Whole cache flush %lu cycles, flushing %lu bytes %lu cycles\n",
diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index d34bbe7ae0e3..988844a169e6 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -46,36 +46,51 @@ static struct device root = {
46 .bus_id = "parisc", 46 .bus_id = "parisc",
47}; 47};
48 48
49#define for_each_padev(padev) \ 49static inline int check_dev(struct device *dev)
50 for (padev = next_dev(&root); padev != NULL; \ 50{
51 padev = next_dev(&padev->dev)) 51 if (dev->bus == &parisc_bus_type) {
52 struct parisc_device *pdev;
53 pdev = to_parisc_device(dev);
54 return pdev->id.hw_type != HPHW_FAULTY;
55 }
56 return 1;
57}
58
59static struct device *
60parse_tree_node(struct device *parent, int index, struct hardware_path *modpath);
52 61
53#define check_dev(padev) \ 62struct recurse_struct {
54 (padev->id.hw_type != HPHW_FAULTY) ? padev : next_dev(&padev->dev) 63 void * obj;
64 int (*fn)(struct device *, void *);
65};
66
67static int descend_children(struct device * dev, void * data)
68{
69 struct recurse_struct * recurse_data = (struct recurse_struct *)data;
70
71 if (recurse_data->fn(dev, recurse_data->obj))
72 return 1;
73 else
74 return device_for_each_child(dev, recurse_data, descend_children);
75}
55 76
56/** 77/**
57 * next_dev - enumerates registered devices 78 * for_each_padev - Iterate over all devices in the tree
58 * @dev: the previous device returned from next_dev 79 * @fn: Function to call for each device.
80 * @data: Data to pass to the called function.
59 * 81 *
60 * next_dev does a depth-first search of the tree, returning parents 82 * This performs a depth-first traversal of the tree, calling the
61 * before children. Returns NULL when there are no more devices. 83 * function passed for each node. It calls the function for parents
84 * before children.
62 */ 85 */
63static struct parisc_device *next_dev(struct device *dev)
64{
65 if (!list_empty(&dev->children)) {
66 dev = list_to_dev(dev->children.next);
67 return check_dev(to_parisc_device(dev));
68 }
69 86
70 while (dev != &root) { 87static int for_each_padev(int (*fn)(struct device *, void *), void * data)
71 if (dev->node.next != &dev->parent->children) { 88{
72 dev = list_to_dev(dev->node.next); 89 struct recurse_struct recurse_data = {
73 return to_parisc_device(dev); 90 .obj = data,
74 } 91 .fn = fn,
75 dev = dev->parent; 92 };
76 } 93 return device_for_each_child(&root, &recurse_data, descend_children);
77
78 return NULL;
79} 94}
80 95
81/** 96/**
@@ -105,12 +120,6 @@ static int match_device(struct parisc_driver *driver, struct parisc_device *dev)
105 return 0; 120 return 0;
106} 121}
107 122
108static void claim_device(struct parisc_driver *driver, struct parisc_device *dev)
109{
110 dev->driver = driver;
111 request_mem_region(dev->hpa, 0x1000, driver->name);
112}
113
114static int parisc_driver_probe(struct device *dev) 123static int parisc_driver_probe(struct device *dev)
115{ 124{
116 int rc; 125 int rc;
@@ -119,8 +128,8 @@ static int parisc_driver_probe(struct device *dev)
119 128
120 rc = pa_drv->probe(pa_dev); 129 rc = pa_drv->probe(pa_dev);
121 130
122 if(!rc) 131 if (!rc)
123 claim_device(pa_drv, pa_dev); 132 pa_dev->driver = pa_drv;
124 133
125 return rc; 134 return rc;
126} 135}
@@ -131,7 +140,6 @@ static int parisc_driver_remove(struct device *dev)
131 struct parisc_driver *pa_drv = to_parisc_driver(dev->driver); 140 struct parisc_driver *pa_drv = to_parisc_driver(dev->driver);
132 if (pa_drv->remove) 141 if (pa_drv->remove)
133 pa_drv->remove(pa_dev); 142 pa_drv->remove(pa_dev);
134 release_mem_region(pa_dev->hpa, 0x1000);
135 143
136 return 0; 144 return 0;
137} 145}
@@ -173,6 +181,24 @@ int register_parisc_driver(struct parisc_driver *driver)
173} 181}
174EXPORT_SYMBOL(register_parisc_driver); 182EXPORT_SYMBOL(register_parisc_driver);
175 183
184
185struct match_count {
186 struct parisc_driver * driver;
187 int count;
188};
189
190static int match_and_count(struct device * dev, void * data)
191{
192 struct match_count * m = data;
193 struct parisc_device * pdev = to_parisc_device(dev);
194
195 if (check_dev(dev)) {
196 if (match_device(m->driver, pdev))
197 m->count++;
198 }
199 return 0;
200}
201
176/** 202/**
177 * count_parisc_driver - count # of devices this driver would match 203 * count_parisc_driver - count # of devices this driver would match
178 * @driver: the PA-RISC driver to try 204 * @driver: the PA-RISC driver to try
@@ -182,15 +208,14 @@ EXPORT_SYMBOL(register_parisc_driver);
182 */ 208 */
183int count_parisc_driver(struct parisc_driver *driver) 209int count_parisc_driver(struct parisc_driver *driver)
184{ 210{
185 struct parisc_device *device; 211 struct match_count m = {
186 int cnt = 0; 212 .driver = driver,
213 .count = 0,
214 };
187 215
188 for_each_padev(device) { 216 for_each_padev(match_and_count, &m);
189 if (match_device(driver, device))
190 cnt++;
191 }
192 217
193 return cnt; 218 return m.count;
194} 219}
195 220
196 221
@@ -206,14 +231,34 @@ int unregister_parisc_driver(struct parisc_driver *driver)
206} 231}
207EXPORT_SYMBOL(unregister_parisc_driver); 232EXPORT_SYMBOL(unregister_parisc_driver);
208 233
209static struct parisc_device *find_device_by_addr(unsigned long hpa) 234struct find_data {
235 unsigned long hpa;
236 struct parisc_device * dev;
237};
238
239static int find_device(struct device * dev, void * data)
210{ 240{
211 struct parisc_device *dev; 241 struct parisc_device * pdev = to_parisc_device(dev);
212 for_each_padev(dev) { 242 struct find_data * d = (struct find_data*)data;
213 if (dev->hpa == hpa) 243
214 return dev; 244 if (check_dev(dev)) {
245 if (pdev->hpa.start == d->hpa) {
246 d->dev = pdev;
247 return 1;
248 }
215 } 249 }
216 return NULL; 250 return 0;
251}
252
253static struct parisc_device *find_device_by_addr(unsigned long hpa)
254{
255 struct find_data d = {
256 .hpa = hpa,
257 };
258 int ret;
259
260 ret = for_each_padev(find_device, &d);
261 return ret ? d.dev : NULL;
217} 262}
218 263
219/** 264/**
@@ -387,6 +432,23 @@ struct parisc_device * create_tree_node(char id, struct device *parent)
387 return dev; 432 return dev;
388} 433}
389 434
435struct match_id_data {
436 char id;
437 struct parisc_device * dev;
438};
439
440static int match_by_id(struct device * dev, void * data)
441{
442 struct parisc_device * pdev = to_parisc_device(dev);
443 struct match_id_data * d = data;
444
445 if (pdev->hw_path == d->id) {
446 d->dev = pdev;
447 return 1;
448 }
449 return 0;
450}
451
390/** 452/**
391 * alloc_tree_node - returns a device entry in the iotree 453 * alloc_tree_node - returns a device entry in the iotree
392 * @parent: the parent node in the tree 454 * @parent: the parent node in the tree
@@ -397,15 +459,13 @@ struct parisc_device * create_tree_node(char id, struct device *parent)
397 */ 459 */
398static struct parisc_device * alloc_tree_node(struct device *parent, char id) 460static struct parisc_device * alloc_tree_node(struct device *parent, char id)
399{ 461{
400 struct device *dev; 462 struct match_id_data d = {
401 463 .id = id,
402 list_for_each_entry(dev, &parent->children, node) { 464 };
403 struct parisc_device *padev = to_parisc_device(dev); 465 if (device_for_each_child(parent, &d, match_by_id))
404 if (padev->hw_path == id) 466 return d.dev;
405 return padev; 467 else
406 } 468 return create_tree_node(id, parent);
407
408 return create_tree_node(id, parent);
409} 469}
410 470
411static struct parisc_device *create_parisc_device(struct hardware_path *modpath) 471static struct parisc_device *create_parisc_device(struct hardware_path *modpath)
@@ -439,10 +499,8 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
439 499
440 dev = create_parisc_device(mod_path); 500 dev = create_parisc_device(mod_path);
441 if (dev->id.hw_type != HPHW_FAULTY) { 501 if (dev->id.hw_type != HPHW_FAULTY) {
442 char p[64];
443 print_pa_hwpath(dev, p);
444 printk("Two devices have hardware path %s. Please file a bug with HP.\n" 502 printk("Two devices have hardware path %s. Please file a bug with HP.\n"
445 "In the meantime, you could try rearranging your cards.\n", p); 503 "In the meantime, you could try rearranging your cards.\n", parisc_pathname(dev));
446 return NULL; 504 return NULL;
447 } 505 }
448 506
@@ -451,12 +509,27 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
451 dev->id.hversion_rev = iodc_data[1] & 0x0f; 509 dev->id.hversion_rev = iodc_data[1] & 0x0f;
452 dev->id.sversion = ((iodc_data[4] & 0x0f) << 16) | 510 dev->id.sversion = ((iodc_data[4] & 0x0f) << 16) |
453 (iodc_data[5] << 8) | iodc_data[6]; 511 (iodc_data[5] << 8) | iodc_data[6];
454 dev->hpa = hpa; 512 dev->hpa.name = parisc_pathname(dev);
513 dev->hpa.start = hpa;
514 if (hpa == 0xf4000000 || hpa == 0xf6000000 ||
515 hpa == 0xf8000000 || hpa == 0xfa000000) {
516 dev->hpa.end = hpa + 0x01ffffff;
517 } else {
518 dev->hpa.end = hpa + 0xfff;
519 }
520 dev->hpa.flags = IORESOURCE_MEM;
455 name = parisc_hardware_description(&dev->id); 521 name = parisc_hardware_description(&dev->id);
456 if (name) { 522 if (name) {
457 strlcpy(dev->name, name, sizeof(dev->name)); 523 strlcpy(dev->name, name, sizeof(dev->name));
458 } 524 }
459 525
526 /* Silently fail things like mouse ports which are subsumed within
527 * the keyboard controller
528 */
529 if ((hpa & 0xfff) == 0 && insert_resource(&iomem_resource, &dev->hpa))
530 printk("Unable to claim HPA %lx for device %s\n",
531 hpa, name);
532
460 return dev; 533 return dev;
461} 534}
462 535
@@ -555,6 +628,33 @@ static int match_parisc_device(struct device *dev, int index,
555 return (curr->hw_path == id); 628 return (curr->hw_path == id);
556} 629}
557 630
631struct parse_tree_data {
632 int index;
633 struct hardware_path * modpath;
634 struct device * dev;
635};
636
637static int check_parent(struct device * dev, void * data)
638{
639 struct parse_tree_data * d = data;
640
641 if (check_dev(dev)) {
642 if (dev->bus == &parisc_bus_type) {
643 if (match_parisc_device(dev, d->index, d->modpath))
644 d->dev = dev;
645 } else if (is_pci_dev(dev)) {
646 if (match_pci_device(dev, d->index, d->modpath))
647 d->dev = dev;
648 } else if (dev->bus == NULL) {
649 /* we are on a bus bridge */
650 struct device *new = parse_tree_node(dev, d->index, d->modpath);
651 if (new)
652 d->dev = new;
653 }
654 }
655 return d->dev != NULL;
656}
657
558/** 658/**
559 * parse_tree_node - returns a device entry in the iotree 659 * parse_tree_node - returns a device entry in the iotree
560 * @parent: the parent node in the tree 660 * @parent: the parent node in the tree
@@ -568,24 +668,18 @@ static int match_parisc_device(struct device *dev, int index,
568static struct device * 668static struct device *
569parse_tree_node(struct device *parent, int index, struct hardware_path *modpath) 669parse_tree_node(struct device *parent, int index, struct hardware_path *modpath)
570{ 670{
571 struct device *device; 671 struct parse_tree_data d = {
572 672 .index = index,
573 list_for_each_entry(device, &parent->children, node) { 673 .modpath = modpath,
574 if (device->bus == &parisc_bus_type) { 674 };
575 if (match_parisc_device(device, index, modpath))
576 return device;
577 } else if (is_pci_dev(device)) {
578 if (match_pci_device(device, index, modpath))
579 return device;
580 } else if (device->bus == NULL) {
581 /* we are on a bus bridge */
582 struct device *new = parse_tree_node(device, index, modpath);
583 if (new)
584 return new;
585 }
586 }
587 675
588 return NULL; 676 struct recurse_struct recurse_data = {
677 .obj = &d,
678 .fn = check_parent,
679 };
680
681 device_for_each_child(parent, &recurse_data, descend_children);
682 return d.dev;
589} 683}
590 684
591/** 685/**
@@ -636,7 +730,7 @@ EXPORT_SYMBOL(device_to_hwpath);
636 ((dev->id.hw_type == HPHW_IOA) || (dev->id.hw_type == HPHW_BCPORT)) 730 ((dev->id.hw_type == HPHW_IOA) || (dev->id.hw_type == HPHW_BCPORT))
637 731
638#define IS_LOWER_PORT(dev) \ 732#define IS_LOWER_PORT(dev) \
639 ((gsc_readl(dev->hpa + offsetof(struct bc_module, io_status)) \ 733 ((gsc_readl(dev->hpa.start + offsetof(struct bc_module, io_status)) \
640 & BC_PORT_MASK) == BC_LOWER_PORT) 734 & BC_PORT_MASK) == BC_LOWER_PORT)
641 735
642#define MAX_NATIVE_DEVICES 64 736#define MAX_NATIVE_DEVICES 64
@@ -645,8 +739,8 @@ EXPORT_SYMBOL(device_to_hwpath);
645#define FLEX_MASK F_EXTEND(0xfffc0000) 739#define FLEX_MASK F_EXTEND(0xfffc0000)
646#define IO_IO_LOW offsetof(struct bc_module, io_io_low) 740#define IO_IO_LOW offsetof(struct bc_module, io_io_low)
647#define IO_IO_HIGH offsetof(struct bc_module, io_io_high) 741#define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
648#define READ_IO_IO_LOW(dev) (unsigned long)(signed int)gsc_readl(dev->hpa + IO_IO_LOW) 742#define READ_IO_IO_LOW(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_LOW)
649#define READ_IO_IO_HIGH(dev) (unsigned long)(signed int)gsc_readl(dev->hpa + IO_IO_HIGH) 743#define READ_IO_IO_HIGH(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_HIGH)
650 744
651static void walk_native_bus(unsigned long io_io_low, unsigned long io_io_high, 745static void walk_native_bus(unsigned long io_io_low, unsigned long io_io_high,
652 struct device *parent); 746 struct device *parent);
@@ -655,10 +749,10 @@ void walk_lower_bus(struct parisc_device *dev)
655{ 749{
656 unsigned long io_io_low, io_io_high; 750 unsigned long io_io_low, io_io_high;
657 751
658 if(!BUS_CONVERTER(dev) || IS_LOWER_PORT(dev)) 752 if (!BUS_CONVERTER(dev) || IS_LOWER_PORT(dev))
659 return; 753 return;
660 754
661 if(dev->id.hw_type == HPHW_IOA) { 755 if (dev->id.hw_type == HPHW_IOA) {
662 io_io_low = (unsigned long)(signed int)(READ_IO_IO_LOW(dev) << 16); 756 io_io_low = (unsigned long)(signed int)(READ_IO_IO_LOW(dev) << 16);
663 io_io_high = io_io_low + MAX_NATIVE_DEVICES * NATIVE_DEVICE_OFFSET; 757 io_io_high = io_io_low + MAX_NATIVE_DEVICES * NATIVE_DEVICE_OFFSET;
664 } else { 758 } else {
@@ -731,7 +825,7 @@ static void print_parisc_device(struct parisc_device *dev)
731 825
732 print_pa_hwpath(dev, hw_path); 826 print_pa_hwpath(dev, hw_path);
733 printk(KERN_INFO "%d. %s at 0x%lx [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }", 827 printk(KERN_INFO "%d. %s at 0x%lx [%s] { %d, 0x%x, 0x%.3x, 0x%.5x }",
734 ++count, dev->name, dev->hpa, hw_path, dev->id.hw_type, 828 ++count, dev->name, dev->hpa.start, hw_path, dev->id.hw_type,
735 dev->id.hversion_rev, dev->id.hversion, dev->id.sversion); 829 dev->id.hversion_rev, dev->id.hversion, dev->id.sversion);
736 830
737 if (dev->num_addrs) { 831 if (dev->num_addrs) {
@@ -753,13 +847,20 @@ void init_parisc_bus(void)
753 get_device(&root); 847 get_device(&root);
754} 848}
755 849
850
851static int print_one_device(struct device * dev, void * data)
852{
853 struct parisc_device * pdev = to_parisc_device(dev);
854
855 if (check_dev(dev))
856 print_parisc_device(pdev);
857 return 0;
858}
859
756/** 860/**
757 * print_parisc_devices - Print out a list of devices found in this system 861 * print_parisc_devices - Print out a list of devices found in this system
758 */ 862 */
759void print_parisc_devices(void) 863void print_parisc_devices(void)
760{ 864{
761 struct parisc_device *dev; 865 for_each_padev(print_one_device, NULL);
762 for_each_padev(dev) {
763 print_parisc_device(dev);
764 }
765} 866}
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index be0f07f2fa58..c7e66ee5b083 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -30,14 +30,14 @@
30 * - save registers to kernel stack and handle in assembly or C */ 30 * - save registers to kernel stack and handle in assembly or C */
31 31
32 32
33#include <asm/psw.h>
33#include <asm/assembly.h> /* for LDREG/STREG defines */ 34#include <asm/assembly.h> /* for LDREG/STREG defines */
34#include <asm/pgtable.h> 35#include <asm/pgtable.h>
35#include <asm/psw.h>
36#include <asm/signal.h> 36#include <asm/signal.h>
37#include <asm/unistd.h> 37#include <asm/unistd.h>
38#include <asm/thread_info.h> 38#include <asm/thread_info.h>
39 39
40#ifdef __LP64__ 40#ifdef CONFIG_64BIT
41#define CMPIB cmpib,* 41#define CMPIB cmpib,*
42#define CMPB cmpb,* 42#define CMPB cmpb,*
43#define COND(x) *x 43#define COND(x) *x
@@ -67,19 +67,22 @@
67 67
68 /* Switch to virtual mapping, trashing only %r1 */ 68 /* Switch to virtual mapping, trashing only %r1 */
69 .macro virt_map 69 .macro virt_map
70 rsm PSW_SM_Q,%r0 70 /* pcxt_ssm_bug */
71 tovirt_r1 %r29 71 rsm PSW_SM_I, %r0 /* barrier for "Relied upon Translation */
72 mfsp %sr7, %r1
73 or,= %r0,%r1,%r0 /* Only save sr7 in sr3 if sr7 != 0 */
74 mtsp %r1, %sr3
75 mtsp %r0, %sr4 72 mtsp %r0, %sr4
76 mtsp %r0, %sr5 73 mtsp %r0, %sr5
74 mfsp %sr7, %r1
75 or,= %r0,%r1,%r0 /* Only save sr7 in sr3 if sr7 != 0 */
76 mtsp %r1, %sr3
77 tovirt_r1 %r29
78 load32 KERNEL_PSW, %r1
79
80 rsm PSW_SM_QUIET,%r0 /* second "heavy weight" ctl op */
77 mtsp %r0, %sr6 81 mtsp %r0, %sr6
78 mtsp %r0, %sr7 82 mtsp %r0, %sr7
79 load32 KERNEL_PSW, %r1
80 mtctl %r1, %cr22
81 mtctl %r0, %cr17 /* Clear IIASQ tail */ 83 mtctl %r0, %cr17 /* Clear IIASQ tail */
82 mtctl %r0, %cr17 /* Clear IIASQ head */ 84 mtctl %r0, %cr17 /* Clear IIASQ head */
85 mtctl %r1, %ipsw
83 load32 4f, %r1 86 load32 4f, %r1
84 mtctl %r1, %cr18 /* Set IIAOQ tail */ 87 mtctl %r1, %cr18 /* Set IIAOQ tail */
85 ldo 4(%r1), %r1 88 ldo 4(%r1), %r1
@@ -214,7 +217,7 @@
214 va = r8 /* virtual address for which the trap occured */ 217 va = r8 /* virtual address for which the trap occured */
215 spc = r24 /* space for which the trap occured */ 218 spc = r24 /* space for which the trap occured */
216 219
217#ifndef __LP64__ 220#ifndef CONFIG_64BIT
218 221
219 /* 222 /*
220 * itlb miss interruption handler (parisc 1.1 - 32 bit) 223 * itlb miss interruption handler (parisc 1.1 - 32 bit)
@@ -236,7 +239,7 @@
236 239
237 .macro itlb_20 code 240 .macro itlb_20 code
238 mfctl %pcsq, spc 241 mfctl %pcsq, spc
239#ifdef __LP64__ 242#ifdef CONFIG_64BIT
240 b itlb_miss_20w 243 b itlb_miss_20w
241#else 244#else
242 b itlb_miss_20 245 b itlb_miss_20
@@ -246,7 +249,7 @@
246 .align 32 249 .align 32
247 .endm 250 .endm
248 251
249#ifndef __LP64__ 252#ifndef CONFIG_64BIT
250 /* 253 /*
251 * naitlb miss interruption handler (parisc 1.1 - 32 bit) 254 * naitlb miss interruption handler (parisc 1.1 - 32 bit)
252 * 255 *
@@ -283,7 +286,7 @@
283 .macro naitlb_20 code 286 .macro naitlb_20 code
284 287
285 mfctl %isr,spc 288 mfctl %isr,spc
286#ifdef __LP64__ 289#ifdef CONFIG_64BIT
287 b itlb_miss_20w 290 b itlb_miss_20w
288#else 291#else
289 b itlb_miss_20 292 b itlb_miss_20
@@ -296,7 +299,7 @@
296 .align 32 299 .align 32
297 .endm 300 .endm
298 301
299#ifndef __LP64__ 302#ifndef CONFIG_64BIT
300 /* 303 /*
301 * dtlb miss interruption handler (parisc 1.1 - 32 bit) 304 * dtlb miss interruption handler (parisc 1.1 - 32 bit)
302 */ 305 */
@@ -318,7 +321,7 @@
318 .macro dtlb_20 code 321 .macro dtlb_20 code
319 322
320 mfctl %isr, spc 323 mfctl %isr, spc
321#ifdef __LP64__ 324#ifdef CONFIG_64BIT
322 b dtlb_miss_20w 325 b dtlb_miss_20w
323#else 326#else
324 b dtlb_miss_20 327 b dtlb_miss_20
@@ -328,7 +331,7 @@
328 .align 32 331 .align 32
329 .endm 332 .endm
330 333
331#ifndef __LP64__ 334#ifndef CONFIG_64BIT
332 /* nadtlb miss interruption handler (parisc 1.1 - 32 bit) */ 335 /* nadtlb miss interruption handler (parisc 1.1 - 32 bit) */
333 336
334 .macro nadtlb_11 code 337 .macro nadtlb_11 code
@@ -346,7 +349,7 @@
346 .macro nadtlb_20 code 349 .macro nadtlb_20 code
347 350
348 mfctl %isr,spc 351 mfctl %isr,spc
349#ifdef __LP64__ 352#ifdef CONFIG_64BIT
350 b nadtlb_miss_20w 353 b nadtlb_miss_20w
351#else 354#else
352 b nadtlb_miss_20 355 b nadtlb_miss_20
@@ -356,7 +359,7 @@
356 .align 32 359 .align 32
357 .endm 360 .endm
358 361
359#ifndef __LP64__ 362#ifndef CONFIG_64BIT
360 /* 363 /*
361 * dirty bit trap interruption handler (parisc 1.1 - 32 bit) 364 * dirty bit trap interruption handler (parisc 1.1 - 32 bit)
362 */ 365 */
@@ -378,7 +381,7 @@
378 .macro dbit_20 code 381 .macro dbit_20 code
379 382
380 mfctl %isr,spc 383 mfctl %isr,spc
381#ifdef __LP64__ 384#ifdef CONFIG_64BIT
382 b dbit_trap_20w 385 b dbit_trap_20w
383#else 386#else
384 b dbit_trap_20 387 b dbit_trap_20
@@ -391,7 +394,7 @@
391 /* The following are simple 32 vs 64 bit instruction 394 /* The following are simple 32 vs 64 bit instruction
392 * abstractions for the macros */ 395 * abstractions for the macros */
393 .macro EXTR reg1,start,length,reg2 396 .macro EXTR reg1,start,length,reg2
394#ifdef __LP64__ 397#ifdef CONFIG_64BIT
395 extrd,u \reg1,32+\start,\length,\reg2 398 extrd,u \reg1,32+\start,\length,\reg2
396#else 399#else
397 extrw,u \reg1,\start,\length,\reg2 400 extrw,u \reg1,\start,\length,\reg2
@@ -399,7 +402,7 @@
399 .endm 402 .endm
400 403
401 .macro DEP reg1,start,length,reg2 404 .macro DEP reg1,start,length,reg2
402#ifdef __LP64__ 405#ifdef CONFIG_64BIT
403 depd \reg1,32+\start,\length,\reg2 406 depd \reg1,32+\start,\length,\reg2
404#else 407#else
405 depw \reg1,\start,\length,\reg2 408 depw \reg1,\start,\length,\reg2
@@ -407,7 +410,7 @@
407 .endm 410 .endm
408 411
409 .macro DEPI val,start,length,reg 412 .macro DEPI val,start,length,reg
410#ifdef __LP64__ 413#ifdef CONFIG_64BIT
411 depdi \val,32+\start,\length,\reg 414 depdi \val,32+\start,\length,\reg
412#else 415#else
413 depwi \val,\start,\length,\reg 416 depwi \val,\start,\length,\reg
@@ -418,7 +421,7 @@
418 * fault. We have to extract this and place it in the va, 421 * fault. We have to extract this and place it in the va,
419 * zeroing the corresponding bits in the space register */ 422 * zeroing the corresponding bits in the space register */
420 .macro space_adjust spc,va,tmp 423 .macro space_adjust spc,va,tmp
421#ifdef __LP64__ 424#ifdef CONFIG_64BIT
422 extrd,u \spc,63,SPACEID_SHIFT,\tmp 425 extrd,u \spc,63,SPACEID_SHIFT,\tmp
423 depd %r0,63,SPACEID_SHIFT,\spc 426 depd %r0,63,SPACEID_SHIFT,\spc
424 depd \tmp,31,SPACEID_SHIFT,\va 427 depd \tmp,31,SPACEID_SHIFT,\va
@@ -476,7 +479,7 @@
476 bb,>=,n \pmd,_PxD_PRESENT_BIT,\fault 479 bb,>=,n \pmd,_PxD_PRESENT_BIT,\fault
477 DEP %r0,31,PxD_FLAG_SHIFT,\pmd /* clear flags */ 480 DEP %r0,31,PxD_FLAG_SHIFT,\pmd /* clear flags */
478 copy \pmd,%r9 481 copy \pmd,%r9
479#ifdef __LP64__ 482#ifdef CONFIG_64BIT
480 shld %r9,PxD_VALUE_SHIFT,\pmd 483 shld %r9,PxD_VALUE_SHIFT,\pmd
481#else 484#else
482 shlw %r9,PxD_VALUE_SHIFT,\pmd 485 shlw %r9,PxD_VALUE_SHIFT,\pmd
@@ -607,7 +610,7 @@
607 .macro do_alias spc,tmp,tmp1,va,pte,prot,fault 610 .macro do_alias spc,tmp,tmp1,va,pte,prot,fault
608 cmpib,COND(<>),n 0,\spc,\fault 611 cmpib,COND(<>),n 0,\spc,\fault
609 ldil L%(TMPALIAS_MAP_START),\tmp 612 ldil L%(TMPALIAS_MAP_START),\tmp
610#if defined(__LP64__) && (TMPALIAS_MAP_START >= 0x80000000) 613#if defined(CONFIG_64BIT) && (TMPALIAS_MAP_START >= 0x80000000)
611 /* on LP64, ldi will sign extend into the upper 32 bits, 614 /* on LP64, ldi will sign extend into the upper 32 bits,
612 * which is behaviour we don't want */ 615 * which is behaviour we don't want */
613 depdi 0,31,32,\tmp 616 depdi 0,31,32,\tmp
@@ -621,7 +624,7 @@
621 * OK, it is in the temp alias region, check whether "from" or "to". 624 * OK, it is in the temp alias region, check whether "from" or "to".
622 * Check "subtle" note in pacache.S re: r23/r26. 625 * Check "subtle" note in pacache.S re: r23/r26.
623 */ 626 */
624#ifdef __LP64__ 627#ifdef CONFIG_64BIT
625 extrd,u,*= \va,41,1,%r0 628 extrd,u,*= \va,41,1,%r0
626#else 629#else
627 extrw,u,= \va,9,1,%r0 630 extrw,u,= \va,9,1,%r0
@@ -688,7 +691,7 @@ fault_vector_20:
688 def 30 691 def 30
689 def 31 692 def 31
690 693
691#ifndef __LP64__ 694#ifndef CONFIG_64BIT
692 695
693 .export fault_vector_11 696 .export fault_vector_11
694 697
@@ -761,7 +764,7 @@ __kernel_thread:
761 764
762 copy %r30, %r1 765 copy %r30, %r1
763 ldo PT_SZ_ALGN(%r30),%r30 766 ldo PT_SZ_ALGN(%r30),%r30
764#ifdef __LP64__ 767#ifdef CONFIG_64BIT
765 /* Yo, function pointers in wide mode are little structs... -PB */ 768 /* Yo, function pointers in wide mode are little structs... -PB */
766 ldd 24(%r26), %r2 769 ldd 24(%r26), %r2
767 STREG %r2, PT_GR27(%r1) /* Store childs %dp */ 770 STREG %r2, PT_GR27(%r1) /* Store childs %dp */
@@ -777,7 +780,7 @@ __kernel_thread:
777 or %r26, %r24, %r26 /* will have kernel mappings. */ 780 or %r26, %r24, %r26 /* will have kernel mappings. */
778 ldi 1, %r25 /* stack_start, signals kernel thread */ 781 ldi 1, %r25 /* stack_start, signals kernel thread */
779 stw %r0, -52(%r30) /* user_tid */ 782 stw %r0, -52(%r30) /* user_tid */
780#ifdef __LP64__ 783#ifdef CONFIG_64BIT
781 ldo -16(%r30),%r29 /* Reference param save area */ 784 ldo -16(%r30),%r29 /* Reference param save area */
782#endif 785#endif
783 BL do_fork, %r2 786 BL do_fork, %r2
@@ -806,7 +809,7 @@ ret_from_kernel_thread:
806 809
807 LDREG TI_TASK-THREAD_SZ_ALGN(%r30), %r1 810 LDREG TI_TASK-THREAD_SZ_ALGN(%r30), %r1
808 LDREG TASK_PT_GR25(%r1), %r26 811 LDREG TASK_PT_GR25(%r1), %r26
809#ifdef __LP64__ 812#ifdef CONFIG_64BIT
810 LDREG TASK_PT_GR27(%r1), %r27 813 LDREG TASK_PT_GR27(%r1), %r27
811 LDREG TASK_PT_GR22(%r1), %r22 814 LDREG TASK_PT_GR22(%r1), %r22
812#endif 815#endif
@@ -814,11 +817,16 @@ ret_from_kernel_thread:
814 ble 0(%sr7, %r1) 817 ble 0(%sr7, %r1)
815 copy %r31, %r2 818 copy %r31, %r2
816 819
817#ifdef __LP64__ 820#ifdef CONFIG_64BIT
818 ldo -16(%r30),%r29 /* Reference param save area */ 821 ldo -16(%r30),%r29 /* Reference param save area */
819 loadgp /* Thread could have been in a module */ 822 loadgp /* Thread could have been in a module */
820#endif 823#endif
824#ifndef CONFIG_64BIT
821 b sys_exit 825 b sys_exit
826#else
827 load32 sys_exit, %r1
828 bv %r0(%r1)
829#endif
822 ldi 0, %r26 830 ldi 0, %r26
823 831
824 .import sys_execve, code 832 .import sys_execve, code
@@ -830,7 +838,7 @@ __execve:
830 STREG %r26, PT_GR26(%r16) 838 STREG %r26, PT_GR26(%r16)
831 STREG %r25, PT_GR25(%r16) 839 STREG %r25, PT_GR25(%r16)
832 STREG %r24, PT_GR24(%r16) 840 STREG %r24, PT_GR24(%r16)
833#ifdef __LP64__ 841#ifdef CONFIG_64BIT
834 ldo -16(%r30),%r29 /* Reference param save area */ 842 ldo -16(%r30),%r29 /* Reference param save area */
835#endif 843#endif
836 BL sys_execve, %r2 844 BL sys_execve, %r2
@@ -855,6 +863,7 @@ __execve:
855_switch_to: 863_switch_to:
856 STREG %r2, -RP_OFFSET(%r30) 864 STREG %r2, -RP_OFFSET(%r30)
857 865
866 callee_save_float
858 callee_save 867 callee_save
859 868
860 load32 _switch_to_ret, %r2 869 load32 _switch_to_ret, %r2
@@ -871,6 +880,7 @@ _switch_to:
871_switch_to_ret: 880_switch_to_ret:
872 mtctl %r0, %cr0 /* Needed for single stepping */ 881 mtctl %r0, %cr0 /* Needed for single stepping */
873 callee_rest 882 callee_rest
883 callee_rest_float
874 884
875 LDREG -RP_OFFSET(%r30), %r2 885 LDREG -RP_OFFSET(%r30), %r2
876 bv %r0(%r2) 886 bv %r0(%r2)
@@ -888,9 +898,6 @@ _switch_to_ret:
888 * this way, then we will need to copy %sr3 in to PT_SR[3..7], and 898 * this way, then we will need to copy %sr3 in to PT_SR[3..7], and
889 * adjust IASQ[0..1]. 899 * adjust IASQ[0..1].
890 * 900 *
891 * Note that the following code uses a "relied upon translation".
892 * See the parisc ACD for details. The ssm is necessary due to a
893 * PCXT bug.
894 */ 901 */
895 902
896 .align 4096 903 .align 4096
@@ -911,7 +918,7 @@ syscall_exit_rfi:
911 STREG %r19,PT_IAOQ1(%r16) 918 STREG %r19,PT_IAOQ1(%r16)
912 LDREG PT_PSW(%r16),%r19 919 LDREG PT_PSW(%r16),%r19
913 load32 USER_PSW_MASK,%r1 920 load32 USER_PSW_MASK,%r1
914#ifdef __LP64__ 921#ifdef CONFIG_64BIT
915 load32 USER_PSW_HI_MASK,%r20 922 load32 USER_PSW_HI_MASK,%r20
916 depd %r20,31,32,%r1 923 depd %r20,31,32,%r1
917#endif 924#endif
@@ -955,7 +962,7 @@ intr_return:
955 /* shift left ____cacheline_aligned (aka L1_CACHE_BYTES) amount 962 /* shift left ____cacheline_aligned (aka L1_CACHE_BYTES) amount
956 ** irq_stat[] is defined using ____cacheline_aligned. 963 ** irq_stat[] is defined using ____cacheline_aligned.
957 */ 964 */
958#ifdef __LP64__ 965#ifdef CONFIG_64BIT
959 shld %r1, 6, %r20 966 shld %r1, 6, %r20
960#else 967#else
961 shlw %r1, 5, %r20 968 shlw %r1, 5, %r20
@@ -963,9 +970,6 @@ intr_return:
963 add %r19,%r20,%r19 /* now have &irq_stat[smp_processor_id()] */ 970 add %r19,%r20,%r19 /* now have &irq_stat[smp_processor_id()] */
964#endif /* CONFIG_SMP */ 971#endif /* CONFIG_SMP */
965 972
966 LDREG IRQSTAT_SIRQ_PEND(%r19),%r20 /* hardirq.h: unsigned long */
967 cmpib,<>,n 0,%r20,intr_do_softirq /* forward */
968
969intr_check_resched: 973intr_check_resched:
970 974
971 /* check for reschedule */ 975 /* check for reschedule */
@@ -985,24 +989,19 @@ intr_restore:
985 rest_fp %r1 989 rest_fp %r1
986 rest_general %r29 990 rest_general %r29
987 991
988 /* Create a "relied upon translation" PA 2.0 Arch. F-5 */ 992 /* inverse of virt_map */
989 ssm 0,%r0 993 pcxt_ssm_bug
990 nop 994 rsm PSW_SM_QUIET,%r0 /* prepare for rfi */
991 nop
992 nop
993 nop
994 nop
995 nop
996 nop
997 tophys_r1 %r29 995 tophys_r1 %r29
998 rsm (PSW_SM_Q|PSW_SM_P|PSW_SM_D|PSW_SM_I),%r0
999 996
1000 /* Restore space id's and special cr's from PT_REGS 997 /* Restore space id's and special cr's from PT_REGS
1001 * structure pointed to by r29 */ 998 * structure pointed to by r29
999 */
1002 rest_specials %r29 1000 rest_specials %r29
1003 1001
1004 /* Important: Note that rest_stack restores r29 1002 /* IMPORTANT: rest_stack restores r29 last (we are using it)!
1005 * last (we are using it)! It also restores r1 and r30. */ 1003 * It also restores r1 and r30.
1004 */
1006 rest_stack 1005 rest_stack
1007 1006
1008 rfi 1007 rfi
@@ -1015,17 +1014,6 @@ intr_restore:
1015 nop 1014 nop
1016 nop 1015 nop
1017 1016
1018 .import do_softirq,code
1019intr_do_softirq:
1020 bl do_softirq,%r2
1021#ifdef __LP64__
1022 ldo -16(%r30),%r29 /* Reference param save area */
1023#else
1024 nop
1025#endif
1026 b intr_check_resched
1027 nop
1028
1029 .import schedule,code 1017 .import schedule,code
1030intr_do_resched: 1018intr_do_resched:
1031 /* Only do reschedule if we are returning to user space */ 1019 /* Only do reschedule if we are returning to user space */
@@ -1036,12 +1024,17 @@ intr_do_resched:
1036 CMPIB= 0,%r20,intr_restore /* backward */ 1024 CMPIB= 0,%r20,intr_restore /* backward */
1037 nop 1025 nop
1038 1026
1039#ifdef __LP64__ 1027#ifdef CONFIG_64BIT
1040 ldo -16(%r30),%r29 /* Reference param save area */ 1028 ldo -16(%r30),%r29 /* Reference param save area */
1041#endif 1029#endif
1042 1030
1043 ldil L%intr_check_sig, %r2 1031 ldil L%intr_check_sig, %r2
1032#ifndef CONFIG_64BIT
1044 b schedule 1033 b schedule
1034#else
1035 load32 schedule, %r20
1036 bv %r0(%r20)
1037#endif
1045 ldo R%intr_check_sig(%r2), %r2 1038 ldo R%intr_check_sig(%r2), %r2
1046 1039
1047 1040
@@ -1064,7 +1057,7 @@ intr_do_signal:
1064 1057
1065 copy %r0, %r24 /* unsigned long in_syscall */ 1058 copy %r0, %r24 /* unsigned long in_syscall */
1066 copy %r16, %r25 /* struct pt_regs *regs */ 1059 copy %r16, %r25 /* struct pt_regs *regs */
1067#ifdef __LP64__ 1060#ifdef CONFIG_64BIT
1068 ldo -16(%r30),%r29 /* Reference param save area */ 1061 ldo -16(%r30),%r29 /* Reference param save area */
1069#endif 1062#endif
1070 1063
@@ -1088,7 +1081,7 @@ intr_extint:
1088 mfctl %cr31,%r1 1081 mfctl %cr31,%r1
1089 copy %r30,%r17 1082 copy %r30,%r17
1090 /* FIXME! depi below has hardcoded idea of interrupt stack size (32k)*/ 1083 /* FIXME! depi below has hardcoded idea of interrupt stack size (32k)*/
1091#ifdef __LP64__ 1084#ifdef CONFIG_64BIT
1092 depdi 0,63,15,%r17 1085 depdi 0,63,15,%r17
1093#else 1086#else
1094 depi 0,31,15,%r17 1087 depi 0,31,15,%r17
@@ -1115,7 +1108,7 @@ intr_extint:
1115 1108
1116 ldil L%intr_return, %r2 1109 ldil L%intr_return, %r2
1117 1110
1118#ifdef __LP64__ 1111#ifdef CONFIG_64BIT
1119 ldo -16(%r30),%r29 /* Reference param save area */ 1112 ldo -16(%r30),%r29 /* Reference param save area */
1120#endif 1113#endif
1121 1114
@@ -1153,15 +1146,17 @@ intr_save:
1153 1146
1154 CMPIB=,n 6,%r26,skip_save_ior 1147 CMPIB=,n 6,%r26,skip_save_ior
1155 1148
1156 /* save_specials left ipsw value in r8 for us to test */
1157 1149
1158 mfctl %cr20, %r16 /* isr */ 1150 mfctl %cr20, %r16 /* isr */
1151 nop /* serialize mfctl on PA 2.0 to avoid 4 cycle penalty */
1159 mfctl %cr21, %r17 /* ior */ 1152 mfctl %cr21, %r17 /* ior */
1160 1153
1161#ifdef __LP64__ 1154
1155#ifdef CONFIG_64BIT
1162 /* 1156 /*
1163 * If the interrupted code was running with W bit off (32 bit), 1157 * If the interrupted code was running with W bit off (32 bit),
1164 * clear the b bits (bits 0 & 1) in the ior. 1158 * clear the b bits (bits 0 & 1) in the ior.
1159 * save_specials left ipsw value in r8 for us to test.
1165 */ 1160 */
1166 extrd,u,*<> %r8,PSW_W_BIT,1,%r0 1161 extrd,u,*<> %r8,PSW_W_BIT,1,%r0
1167 depdi 0,1,2,%r17 1162 depdi 0,1,2,%r17
@@ -1192,7 +1187,7 @@ skip_save_ior:
1192 loadgp 1187 loadgp
1193 1188
1194 copy %r29, %r25 /* arg1 is pt_regs */ 1189 copy %r29, %r25 /* arg1 is pt_regs */
1195#ifdef __LP64__ 1190#ifdef CONFIG_64BIT
1196 ldo -16(%r30),%r29 /* Reference param save area */ 1191 ldo -16(%r30),%r29 /* Reference param save area */
1197#endif 1192#endif
1198 1193
@@ -1230,7 +1225,7 @@ skip_save_ior:
1230 spc = r24 /* space for which the trap occured */ 1225 spc = r24 /* space for which the trap occured */
1231 ptp = r25 /* page directory/page table pointer */ 1226 ptp = r25 /* page directory/page table pointer */
1232 1227
1233#ifdef __LP64__ 1228#ifdef CONFIG_64BIT
1234 1229
1235dtlb_miss_20w: 1230dtlb_miss_20w:
1236 space_adjust spc,va,t0 1231 space_adjust spc,va,t0
@@ -1487,10 +1482,10 @@ nadtlb_emulate:
1487 add,l %r1,%r24,%r1 /* doesn't affect c/b bits */ 1482 add,l %r1,%r24,%r1 /* doesn't affect c/b bits */
1488 1483
1489nadtlb_nullify: 1484nadtlb_nullify:
1490 mfctl %cr22,%r8 /* Get ipsw */ 1485 mfctl %ipsw,%r8
1491 ldil L%PSW_N,%r9 1486 ldil L%PSW_N,%r9
1492 or %r8,%r9,%r8 /* Set PSW_N */ 1487 or %r8,%r9,%r8 /* Set PSW_N */
1493 mtctl %r8,%cr22 1488 mtctl %r8,%ipsw
1494 1489
1495 rfir 1490 rfir
1496 nop 1491 nop
@@ -1521,7 +1516,7 @@ nadtlb_probe_check:
1521 nop 1516 nop
1522 1517
1523 1518
1524#ifdef __LP64__ 1519#ifdef CONFIG_64BIT
1525itlb_miss_20w: 1520itlb_miss_20w:
1526 1521
1527 /* 1522 /*
@@ -1588,7 +1583,7 @@ itlb_miss_20:
1588 1583
1589#endif 1584#endif
1590 1585
1591#ifdef __LP64__ 1586#ifdef CONFIG_64BIT
1592 1587
1593dbit_trap_20w: 1588dbit_trap_20w:
1594 space_adjust spc,va,t0 1589 space_adjust spc,va,t0
@@ -1797,7 +1792,7 @@ sys_fork_wrapper:
1797 1792
1798 STREG %r2,-RP_OFFSET(%r30) 1793 STREG %r2,-RP_OFFSET(%r30)
1799 ldo FRAME_SIZE(%r30),%r30 1794 ldo FRAME_SIZE(%r30),%r30
1800#ifdef __LP64__ 1795#ifdef CONFIG_64BIT
1801 ldo -16(%r30),%r29 /* Reference param save area */ 1796 ldo -16(%r30),%r29 /* Reference param save area */
1802#endif 1797#endif
1803 1798
@@ -1847,7 +1842,7 @@ sys_clone_wrapper:
1847 1842
1848 STREG %r2,-RP_OFFSET(%r30) 1843 STREG %r2,-RP_OFFSET(%r30)
1849 ldo FRAME_SIZE(%r30),%r30 1844 ldo FRAME_SIZE(%r30),%r30
1850#ifdef __LP64__ 1845#ifdef CONFIG_64BIT
1851 ldo -16(%r30),%r29 /* Reference param save area */ 1846 ldo -16(%r30),%r29 /* Reference param save area */
1852#endif 1847#endif
1853 1848
@@ -1869,7 +1864,7 @@ sys_vfork_wrapper:
1869 1864
1870 STREG %r2,-RP_OFFSET(%r30) 1865 STREG %r2,-RP_OFFSET(%r30)
1871 ldo FRAME_SIZE(%r30),%r30 1866 ldo FRAME_SIZE(%r30),%r30
1872#ifdef __LP64__ 1867#ifdef CONFIG_64BIT
1873 ldo -16(%r30),%r29 /* Reference param save area */ 1868 ldo -16(%r30),%r29 /* Reference param save area */
1874#endif 1869#endif
1875 1870
@@ -1897,10 +1892,10 @@ sys_vfork_wrapper:
1897 1892
1898 STREG %r2,-RP_OFFSET(%r30) 1893 STREG %r2,-RP_OFFSET(%r30)
1899 ldo FRAME_SIZE(%r30),%r30 1894 ldo FRAME_SIZE(%r30),%r30
1900#ifdef __LP64__ 1895#ifdef CONFIG_64BIT
1901 ldo -16(%r30),%r29 /* Reference param save area */ 1896 ldo -16(%r30),%r29 /* Reference param save area */
1902#endif 1897#endif
1903 bl \execve,%r2 1898 BL \execve,%r2
1904 copy %r1,%arg0 1899 copy %r1,%arg0
1905 1900
1906 ldo -FRAME_SIZE(%r30),%r30 1901 ldo -FRAME_SIZE(%r30),%r30
@@ -1923,7 +1918,7 @@ error_\execve:
1923sys_execve_wrapper: 1918sys_execve_wrapper:
1924 execve_wrapper sys_execve 1919 execve_wrapper sys_execve
1925 1920
1926#ifdef __LP64__ 1921#ifdef CONFIG_64BIT
1927 .export sys32_execve_wrapper 1922 .export sys32_execve_wrapper
1928 .import sys32_execve 1923 .import sys32_execve
1929 1924
@@ -1937,7 +1932,7 @@ sys_rt_sigreturn_wrapper:
1937 ldo TASK_REGS(%r26),%r26 /* get pt regs */ 1932 ldo TASK_REGS(%r26),%r26 /* get pt regs */
1938 /* Don't save regs, we are going to restore them from sigcontext. */ 1933 /* Don't save regs, we are going to restore them from sigcontext. */
1939 STREG %r2, -RP_OFFSET(%r30) 1934 STREG %r2, -RP_OFFSET(%r30)
1940#ifdef __LP64__ 1935#ifdef CONFIG_64BIT
1941 ldo FRAME_SIZE(%r30), %r30 1936 ldo FRAME_SIZE(%r30), %r30
1942 BL sys_rt_sigreturn,%r2 1937 BL sys_rt_sigreturn,%r2
1943 ldo -16(%r30),%r29 /* Reference param save area */ 1938 ldo -16(%r30),%r29 /* Reference param save area */
@@ -1968,7 +1963,7 @@ sys_sigaltstack_wrapper:
1968 ldo TASK_REGS(%r1),%r24 /* get pt regs */ 1963 ldo TASK_REGS(%r1),%r24 /* get pt regs */
1969 LDREG TASK_PT_GR30(%r24),%r24 1964 LDREG TASK_PT_GR30(%r24),%r24
1970 STREG %r2, -RP_OFFSET(%r30) 1965 STREG %r2, -RP_OFFSET(%r30)
1971#ifdef __LP64__ 1966#ifdef CONFIG_64BIT
1972 ldo FRAME_SIZE(%r30), %r30 1967 ldo FRAME_SIZE(%r30), %r30
1973 b,l do_sigaltstack,%r2 1968 b,l do_sigaltstack,%r2
1974 ldo -16(%r30),%r29 /* Reference param save area */ 1969 ldo -16(%r30),%r29 /* Reference param save area */
@@ -1982,7 +1977,7 @@ sys_sigaltstack_wrapper:
1982 bv %r0(%r2) 1977 bv %r0(%r2)
1983 nop 1978 nop
1984 1979
1985#ifdef __LP64__ 1980#ifdef CONFIG_64BIT
1986 .export sys32_sigaltstack_wrapper 1981 .export sys32_sigaltstack_wrapper
1987sys32_sigaltstack_wrapper: 1982sys32_sigaltstack_wrapper:
1988 /* Get the user stack pointer */ 1983 /* Get the user stack pointer */
@@ -2006,7 +2001,7 @@ sys_rt_sigsuspend_wrapper:
2006 reg_save %r24 2001 reg_save %r24
2007 2002
2008 STREG %r2, -RP_OFFSET(%r30) 2003 STREG %r2, -RP_OFFSET(%r30)
2009#ifdef __LP64__ 2004#ifdef CONFIG_64BIT
2010 ldo FRAME_SIZE(%r30), %r30 2005 ldo FRAME_SIZE(%r30), %r30
2011 b,l sys_rt_sigsuspend,%r2 2006 b,l sys_rt_sigsuspend,%r2
2012 ldo -16(%r30),%r29 /* Reference param save area */ 2007 ldo -16(%r30),%r29 /* Reference param save area */
@@ -2079,7 +2074,7 @@ syscall_check_bh:
2079 ldw TI_CPU-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r26 /* cpu # */ 2074 ldw TI_CPU-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r26 /* cpu # */
2080 2075
2081 /* shift left ____cacheline_aligned (aka L1_CACHE_BYTES) bits */ 2076 /* shift left ____cacheline_aligned (aka L1_CACHE_BYTES) bits */
2082#ifdef __LP64__ 2077#ifdef CONFIG_64BIT
2083 shld %r26, 6, %r20 2078 shld %r26, 6, %r20
2084#else 2079#else
2085 shlw %r26, 5, %r20 2080 shlw %r26, 5, %r20
@@ -2087,9 +2082,6 @@ syscall_check_bh:
2087 add %r19,%r20,%r19 /* now have &irq_stat[smp_processor_id()] */ 2082 add %r19,%r20,%r19 /* now have &irq_stat[smp_processor_id()] */
2088#endif /* CONFIG_SMP */ 2083#endif /* CONFIG_SMP */
2089 2084
2090 LDREG IRQSTAT_SIRQ_PEND(%r19),%r20 /* hardirq.h: unsigned long */
2091 cmpib,<>,n 0,%r20,syscall_do_softirq /* forward */
2092
2093syscall_check_resched: 2085syscall_check_resched:
2094 2086
2095 /* check for reschedule */ 2087 /* check for reschedule */
@@ -2144,7 +2136,7 @@ syscall_restore:
2144 2136
2145 depi 3,31,2,%r31 /* ensure return to user mode. */ 2137 depi 3,31,2,%r31 /* ensure return to user mode. */
2146 2138
2147#ifdef __LP64__ 2139#ifdef CONFIG_64BIT
2148 /* decide whether to reset the wide mode bit 2140 /* decide whether to reset the wide mode bit
2149 * 2141 *
2150 * For a syscall, the W bit is stored in the lowest bit 2142 * For a syscall, the W bit is stored in the lowest bit
@@ -2227,20 +2219,10 @@ pt_regs_ok:
2227 b intr_restore 2219 b intr_restore
2228 nop 2220 nop
2229 2221
2230 .import do_softirq,code
2231syscall_do_softirq:
2232 bl do_softirq,%r2
2233 nop
2234 /* NOTE: We enable I-bit incase we schedule later,
2235 * and we might be going back to userspace if we were
2236 * traced. */
2237 b syscall_check_resched
2238 ssm PSW_SM_I, %r0 /* do_softirq returns with I bit off */
2239
2240 .import schedule,code 2222 .import schedule,code
2241syscall_do_resched: 2223syscall_do_resched:
2242 BL schedule,%r2 2224 BL schedule,%r2
2243#ifdef __LP64__ 2225#ifdef CONFIG_64BIT
2244 ldo -16(%r30),%r29 /* Reference param save area */ 2226 ldo -16(%r30),%r29 /* Reference param save area */
2245#else 2227#else
2246 nop 2228 nop
@@ -2260,7 +2242,7 @@ syscall_do_signal:
2260 2242
2261 ldi 1, %r24 /* unsigned long in_syscall */ 2243 ldi 1, %r24 /* unsigned long in_syscall */
2262 2244
2263#ifdef __LP64__ 2245#ifdef CONFIG_64BIT
2264 ldo -16(%r30),%r29 /* Reference param save area */ 2246 ldo -16(%r30),%r29 /* Reference param save area */
2265#endif 2247#endif
2266 BL do_signal,%r2 2248 BL do_signal,%r2
diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c
index f244fb200db1..553f8fe03224 100644
--- a/arch/parisc/kernel/firmware.c
+++ b/arch/parisc/kernel/firmware.c
@@ -83,15 +83,15 @@ static unsigned long pdc_result2[32] __attribute__ ((aligned (8)));
83int parisc_narrow_firmware = 1; 83int parisc_narrow_firmware = 1;
84#endif 84#endif
85 85
86/* on all currently-supported platforms, IODC I/O calls are always 86/* On most currently-supported platforms, IODC I/O calls are 32-bit calls
87 * 32-bit calls, and MEM_PDC calls are always the same width as the OS. 87 * and MEM_PDC calls are always the same width as the OS.
88 * This means Cxxx boxes can't run wide kernels right now. -PB 88 * Some PAT boxes may have 64-bit IODC I/O.
89 * 89 *
90 * CONFIG_PDC_NARROW has been added to allow 64-bit kernels to run on 90 * Ryan Bradetich added the now obsolete CONFIG_PDC_NARROW to allow
91 * systems with 32-bit MEM_PDC calls. This will allow wide kernels to 91 * 64-bit kernels to run on systems with 32-bit MEM_PDC calls.
92 * run on Cxxx boxes now. -RB 92 * This allowed wide kernels to run on Cxxx boxes.
93 * 93 * We now detect 32-bit-only PDC and dynamically switch to 32-bit mode
94 * Note that some PAT boxes may have 64-bit IODC I/O... 94 * when running a 64-bit kernel on such boxes (e.g. C200 or C360).
95 */ 95 */
96 96
97#ifdef __LP64__ 97#ifdef __LP64__
diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S
index 28405edf8448..0b47afc20690 100644
--- a/arch/parisc/kernel/head.S
+++ b/arch/parisc/kernel/head.S
@@ -12,7 +12,7 @@
12 * Initial Version 04-23-1999 by Helge Deller <deller@gmx.de> 12 * Initial Version 04-23-1999 by Helge Deller <deller@gmx.de>
13 */ 13 */
14 14
15#include <linux/autoconf.h> /* for CONFIG_SMP */ 15#include <linux/config.h> /* for CONFIG_SMP */
16 16
17#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
18#include <asm/psw.h> 18#include <asm/psw.h>
@@ -36,10 +36,10 @@ boot_args:
36 .align 4 36 .align 4
37 .import init_thread_union,data 37 .import init_thread_union,data
38 .import fault_vector_20,code /* IVA parisc 2.0 32 bit */ 38 .import fault_vector_20,code /* IVA parisc 2.0 32 bit */
39#ifndef __LP64__ 39#ifndef CONFIG_64BIT
40 .import fault_vector_11,code /* IVA parisc 1.1 32 bit */ 40 .import fault_vector_11,code /* IVA parisc 1.1 32 bit */
41 .import $global$ /* forward declaration */ 41 .import $global$ /* forward declaration */
42#endif /*!LP64*/ 42#endif /*!CONFIG_64BIT*/
43 .export stext 43 .export stext
44 .export _stext,data /* Kernel want it this way! */ 44 .export _stext,data /* Kernel want it this way! */
45_stext: 45_stext:
@@ -76,7 +76,7 @@ $bss_loop:
76 mtctl %r4,%cr24 /* Initialize kernel root pointer */ 76 mtctl %r4,%cr24 /* Initialize kernel root pointer */
77 mtctl %r4,%cr25 /* Initialize user root pointer */ 77 mtctl %r4,%cr25 /* Initialize user root pointer */
78 78
79#ifdef __LP64__ 79#ifdef CONFIG_64BIT
80 /* Set pmd in pgd */ 80 /* Set pmd in pgd */
81 load32 PA(pmd0),%r5 81 load32 PA(pmd0),%r5
82 shrd %r5,PxD_VALUE_SHIFT,%r3 82 shrd %r5,PxD_VALUE_SHIFT,%r3
@@ -99,7 +99,7 @@ $bss_loop:
99 stw %r3,0(%r4) 99 stw %r3,0(%r4)
100 ldo (ASM_PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3 100 ldo (ASM_PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3
101 addib,> -1,%r1,1b 101 addib,> -1,%r1,1b
102#ifdef __LP64__ 102#ifdef CONFIG_64BIT
103 ldo ASM_PMD_ENTRY_SIZE(%r4),%r4 103 ldo ASM_PMD_ENTRY_SIZE(%r4),%r4
104#else 104#else
105 ldo ASM_PGD_ENTRY_SIZE(%r4),%r4 105 ldo ASM_PGD_ENTRY_SIZE(%r4),%r4
@@ -170,7 +170,7 @@ common_stext:
170 stw %r0,0x28(%r0) /* MEM_RENDEZ_HI */ 170 stw %r0,0x28(%r0) /* MEM_RENDEZ_HI */
171#endif /*CONFIG_SMP*/ 171#endif /*CONFIG_SMP*/
172 172
173#ifdef __LP64__ 173#ifdef CONFIG_64BIT
174 tophys_r1 %sp 174 tophys_r1 %sp
175 175
176 /* Save the rfi target address */ 176 /* Save the rfi target address */
@@ -224,8 +224,6 @@ stext_pdc_ret:
224 mtctl %r0,%cr12 224 mtctl %r0,%cr12
225 mtctl %r0,%cr13 225 mtctl %r0,%cr13
226 226
227 /* Prepare to RFI! Man all the cannons! */
228
229 /* Initialize the global data pointer */ 227 /* Initialize the global data pointer */
230 loadgp 228 loadgp
231 229
@@ -235,7 +233,7 @@ stext_pdc_ret:
235 * following short sequence of instructions can determine this 233 * following short sequence of instructions can determine this
236 * (without being illegal on a PA1.1 machine). 234 * (without being illegal on a PA1.1 machine).
237 */ 235 */
238#ifndef __LP64__ 236#ifndef CONFIG_64BIT
239 ldi 32,%r10 237 ldi 32,%r10
240 mtctl %r10,%cr11 238 mtctl %r10,%cr11
241 .level 2.0 239 .level 2.0
@@ -248,52 +246,22 @@ stext_pdc_ret:
248 246
249$is_pa20: 247$is_pa20:
250 .level LEVEL /* restore 1.1 || 2.0w */ 248 .level LEVEL /* restore 1.1 || 2.0w */
251#endif /*!LP64*/ 249#endif /*!CONFIG_64BIT*/
252 load32 PA(fault_vector_20),%r10 250 load32 PA(fault_vector_20),%r10
253 251
254$install_iva: 252$install_iva:
255 mtctl %r10,%cr14 253 mtctl %r10,%cr14
256 254
257#ifdef __LP64__ 255 b aligned_rfi /* Prepare to RFI! Man all the cannons! */
258 b aligned_rfi
259 nop 256 nop
260 257
261 .align 256 258 .align 128
262aligned_rfi: 259aligned_rfi:
263 ssm 0,0 260 pcxt_ssm_bug
264 nop /* 1 */
265 nop /* 2 */
266 nop /* 3 */
267 nop /* 4 */
268 nop /* 5 */
269 nop /* 6 */
270 nop /* 7 */
271 nop /* 8 */
272#endif
273 261
274#ifdef __LP64__ /* move to psw.h? */ 262 rsm PSW_SM_QUIET,%r0 /* off troublesome PSW bits */
275#define PSW_BITS PSW_Q+PSW_I+PSW_D+PSW_P+PSW_R 263 /* Don't need NOPs, have 8 compliant insn before rfi */
276#else
277#define PSW_BITS PSW_SM_Q
278#endif
279 264
280$rfi:
281 /* turn off troublesome PSW bits */
282 rsm PSW_BITS,%r0
283
284 /* kernel PSW:
285 * - no interruptions except HPMC and TOC (which are handled by PDC)
286 * - Q bit set (IODC / PDC interruptions)
287 * - big-endian
288 * - virtually mapped
289 */
290 load32 KERNEL_PSW,%r10
291 mtctl %r10,%ipsw
292
293 /* Set the space pointers for the post-RFI world
294 ** Clear the two-level IIA Space Queue, effectively setting
295 ** Kernel space.
296 */
297 mtctl %r0,%cr17 /* Clear IIASQ tail */ 265 mtctl %r0,%cr17 /* Clear IIASQ tail */
298 mtctl %r0,%cr17 /* Clear IIASQ head */ 266 mtctl %r0,%cr17 /* Clear IIASQ head */
299 267
@@ -301,8 +269,11 @@ $rfi:
301 mtctl %r11,%cr18 /* IIAOQ head */ 269 mtctl %r11,%cr18 /* IIAOQ head */
302 ldo 4(%r11),%r11 270 ldo 4(%r11),%r11
303 mtctl %r11,%cr18 /* IIAOQ tail */ 271 mtctl %r11,%cr18 /* IIAOQ tail */
272
273 load32 KERNEL_PSW,%r10
274 mtctl %r10,%ipsw
304 275
305 /* Jump to hyperspace */ 276 /* Jump through hyperspace to Virt Mode */
306 rfi 277 rfi
307 nop 278 nop
308 279
@@ -313,7 +284,7 @@ $rfi:
313 .import smp_init_current_idle_task,data 284 .import smp_init_current_idle_task,data
314 .import smp_callin,code 285 .import smp_callin,code
315 286
316#ifndef __LP64__ 287#ifndef CONFIG_64BIT
317smp_callin_rtn: 288smp_callin_rtn:
318 .proc 289 .proc
319 .callinfo 290 .callinfo
@@ -321,7 +292,7 @@ smp_callin_rtn:
321 nop 292 nop
322 nop 293 nop
323 .procend 294 .procend
324#endif /*!LP64*/ 295#endif /*!CONFIG_64BIT*/
325 296
326/*************************************************************************** 297/***************************************************************************
327* smp_slave_stext is executed by all non-monarch Processors when the Monarch 298* smp_slave_stext is executed by all non-monarch Processors when the Monarch
@@ -356,7 +327,7 @@ smp_slave_stext:
356 mtctl %r4,%cr24 /* Initialize kernel root pointer */ 327 mtctl %r4,%cr24 /* Initialize kernel root pointer */
357 mtctl %r4,%cr25 /* Initialize user root pointer */ 328 mtctl %r4,%cr25 /* Initialize user root pointer */
358 329
359#ifdef __LP64__ 330#ifdef CONFIG_64BIT
360 /* Setup PDCE_PROC entry */ 331 /* Setup PDCE_PROC entry */
361 copy %arg0,%r3 332 copy %arg0,%r3
362#else 333#else
@@ -373,7 +344,7 @@ smp_slave_stext:
373 344
374 .procend 345 .procend
375#endif /* CONFIG_SMP */ 346#endif /* CONFIG_SMP */
376#ifndef __LP64__ 347#ifndef CONFIG_64BIT
377 .data 348 .data
378 349
379 .align 4 350 .align 4
@@ -383,4 +354,4 @@ smp_slave_stext:
383 .size $global$,4 354 .size $global$,4
384$global$: 355$global$:
385 .word 0 356 .word 0
386#endif /*!LP64*/ 357#endif /*!CONFIG_64BIT*/
diff --git a/arch/parisc/kernel/ioctl32.c b/arch/parisc/kernel/ioctl32.c
index 1d3824b670d1..8cad8f004f00 100644
--- a/arch/parisc/kernel/ioctl32.c
+++ b/arch/parisc/kernel/ioctl32.c
@@ -104,12 +104,9 @@ static int drm32_version(unsigned int fd, unsigned int cmd, unsigned long arg)
104 } 104 }
105 105
106out: 106out:
107 if (kversion.name) 107 kfree(kversion.name);
108 kfree(kversion.name); 108 kfree(kversion.date);
109 if (kversion.date) 109 kfree(kversion.desc);
110 kfree(kversion.date);
111 if (kversion.desc)
112 kfree(kversion.desc);
113 return ret; 110 return ret;
114} 111}
115 112
@@ -166,9 +163,7 @@ static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long a
166 ret = -EFAULT; 163 ret = -EFAULT;
167 } 164 }
168 165
169 if (karg.unique != NULL) 166 kfree(karg.unique);
170 kfree(karg.unique);
171
172 return ret; 167 return ret;
173} 168}
174 169
@@ -265,7 +260,6 @@ static int drm32_info_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
265 } 260 }
266 261
267 kfree(karg.list); 262 kfree(karg.list);
268
269 return ret; 263 return ret;
270} 264}
271 265
@@ -305,7 +299,6 @@ static int drm32_free_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
305 299
306out: 300out:
307 kfree(karg.list); 301 kfree(karg.list);
308
309 return ret; 302 return ret;
310} 303}
311 304
@@ -494,15 +487,10 @@ static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
494 } 487 }
495 488
496out: 489out:
497 if (karg.send_indices) 490 kfree(karg.send_indices);
498 kfree(karg.send_indices); 491 kfree(karg.send_sizes);
499 if (karg.send_sizes) 492 kfree(karg.request_indices);
500 kfree(karg.send_sizes); 493 kfree(karg.request_sizes);
501 if (karg.request_indices)
502 kfree(karg.request_indices);
503 if (karg.request_sizes)
504 kfree(karg.request_sizes);
505
506 return ret; 494 return ret;
507} 495}
508 496
@@ -555,9 +543,7 @@ static int drm32_res_ctx(unsigned int fd, unsigned int cmd, unsigned long arg)
555 ret = -EFAULT; 543 ret = -EFAULT;
556 } 544 }
557 545
558 if (karg.contexts) 546 kfree(karg.contexts);
559 kfree(karg.contexts);
560
561 return ret; 547 return ret;
562} 548}
563 549
diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
index 77e03bc0f935..9534ee17b9be 100644
--- a/arch/parisc/kernel/pacache.S
+++ b/arch/parisc/kernel/pacache.S
@@ -26,7 +26,7 @@
26 * can be used. 26 * can be used.
27 */ 27 */
28 28
29#ifdef __LP64__ 29#ifdef CONFIG_64BIT
30#define ADDIB addib,* 30#define ADDIB addib,*
31#define CMPB cmpb,* 31#define CMPB cmpb,*
32#define ANDCM andcm,* 32#define ANDCM andcm,*
@@ -40,8 +40,10 @@
40 .level 2.0 40 .level 2.0
41#endif 41#endif
42 42
43#include <asm/assembly.h> 43#include <linux/config.h>
44
44#include <asm/psw.h> 45#include <asm/psw.h>
46#include <asm/assembly.h>
45#include <asm/pgtable.h> 47#include <asm/pgtable.h>
46#include <asm/cache.h> 48#include <asm/cache.h>
47 49
@@ -62,32 +64,23 @@ flush_tlb_all_local:
62 * to happen in real mode with all interruptions disabled. 64 * to happen in real mode with all interruptions disabled.
63 */ 65 */
64 66
65 /* 67 /* pcxt_ssm_bug - relied upon translation! PA 2.0 Arch. F-4 and F-5 */
66 * Once again, we do the rfi dance ... some day we need examine 68 rsm PSW_SM_I, %r19 /* save I-bit state */
67 * all of our uses of this type of code and see what can be 69 load32 PA(1f), %r1
68 * consolidated.
69 */
70
71 rsm PSW_SM_I, %r19 /* relied upon translation! PA 2.0 Arch. F-5 */
72 nop 70 nop
73 nop 71 nop
74 nop 72 nop
75 nop 73 nop
76 nop 74 nop
77 nop 75
78 nop 76 rsm PSW_SM_Q, %r0 /* prep to load iia queue */
79
80 rsm PSW_SM_Q, %r0 /* Turn off Q bit to load iia queue */
81 ldil L%REAL_MODE_PSW, %r1
82 ldo R%REAL_MODE_PSW(%r1), %r1
83 mtctl %r1, %cr22
84 mtctl %r0, %cr17 /* Clear IIASQ tail */ 77 mtctl %r0, %cr17 /* Clear IIASQ tail */
85 mtctl %r0, %cr17 /* Clear IIASQ head */ 78 mtctl %r0, %cr17 /* Clear IIASQ head */
86 ldil L%PA(1f), %r1
87 ldo R%PA(1f)(%r1), %r1
88 mtctl %r1, %cr18 /* IIAOQ head */ 79 mtctl %r1, %cr18 /* IIAOQ head */
89 ldo 4(%r1), %r1 80 ldo 4(%r1), %r1
90 mtctl %r1, %cr18 /* IIAOQ tail */ 81 mtctl %r1, %cr18 /* IIAOQ tail */
82 load32 REAL_MODE_PSW, %r1
83 mtctl %r1, %ipsw
91 rfi 84 rfi
92 nop 85 nop
93 86
@@ -178,29 +171,36 @@ fdtonemiddle: /* Loop if LOOP = 1 */
178 ADDIB> -1, %r22, fdtoneloop /* Outer loop count decr */ 171 ADDIB> -1, %r22, fdtoneloop /* Outer loop count decr */
179 add %r21, %r20, %r20 /* increment space */ 172 add %r21, %r20, %r20 /* increment space */
180 173
181fdtdone:
182 174
183 /* Switch back to virtual mode */ 175fdtdone:
176 /*
177 * Switch back to virtual mode
178 */
179 /* pcxt_ssm_bug */
180 rsm PSW_SM_I, %r0
181 load32 2f, %r1
182 nop
183 nop
184 nop
185 nop
186 nop
184 187
185 rsm PSW_SM_Q, %r0 /* clear Q bit to load iia queue */ 188 rsm PSW_SM_Q, %r0 /* prep to load iia queue */
186 ldil L%KERNEL_PSW, %r1
187 ldo R%KERNEL_PSW(%r1), %r1
188 or %r1, %r19, %r1 /* Set I bit if set on entry */
189 mtctl %r1, %cr22
190 mtctl %r0, %cr17 /* Clear IIASQ tail */ 189 mtctl %r0, %cr17 /* Clear IIASQ tail */
191 mtctl %r0, %cr17 /* Clear IIASQ head */ 190 mtctl %r0, %cr17 /* Clear IIASQ head */
192 ldil L%(2f), %r1
193 ldo R%(2f)(%r1), %r1
194 mtctl %r1, %cr18 /* IIAOQ head */ 191 mtctl %r1, %cr18 /* IIAOQ head */
195 ldo 4(%r1), %r1 192 ldo 4(%r1), %r1
196 mtctl %r1, %cr18 /* IIAOQ tail */ 193 mtctl %r1, %cr18 /* IIAOQ tail */
194 load32 KERNEL_PSW, %r1
195 or %r1, %r19, %r1 /* I-bit to state on entry */
196 mtctl %r1, %ipsw /* restore I-bit (entire PSW) */
197 rfi 197 rfi
198 nop 198 nop
199 199
2002: bv %r0(%r2) 2002: bv %r0(%r2)
201 nop 201 nop
202 .exit
203 202
203 .exit
204 .procend 204 .procend
205 205
206 .export flush_instruction_cache_local,code 206 .export flush_instruction_cache_local,code
@@ -227,7 +227,7 @@ flush_instruction_cache_local:
227 227
228fimanyloop: /* Loop if LOOP >= 2 */ 228fimanyloop: /* Loop if LOOP >= 2 */
229 ADDIB> -1, %r31, fimanyloop /* Adjusted inner loop decr */ 229 ADDIB> -1, %r31, fimanyloop /* Adjusted inner loop decr */
230 fice 0(%sr1, %arg0) 230 fice %r0(%sr1, %arg0)
231 fice,m %arg1(%sr1, %arg0) /* Last fice and addr adjust */ 231 fice,m %arg1(%sr1, %arg0) /* Last fice and addr adjust */
232 movb,tr %arg3, %r31, fimanyloop /* Re-init inner loop count */ 232 movb,tr %arg3, %r31, fimanyloop /* Re-init inner loop count */
233 ADDIB<=,n -1, %arg2, fisync /* Outer loop decr */ 233 ADDIB<=,n -1, %arg2, fisync /* Outer loop decr */
@@ -238,7 +238,7 @@ fioneloop: /* Loop if LOOP = 1 */
238 238
239fisync: 239fisync:
240 sync 240 sync
241 mtsm %r22 241 mtsm %r22 /* restore I-bit */
242 bv %r0(%r2) 242 bv %r0(%r2)
243 nop 243 nop
244 .exit 244 .exit
@@ -269,7 +269,7 @@ flush_data_cache_local:
269 269
270fdmanyloop: /* Loop if LOOP >= 2 */ 270fdmanyloop: /* Loop if LOOP >= 2 */
271 ADDIB> -1, %r31, fdmanyloop /* Adjusted inner loop decr */ 271 ADDIB> -1, %r31, fdmanyloop /* Adjusted inner loop decr */
272 fdce 0(%sr1, %arg0) 272 fdce %r0(%sr1, %arg0)
273 fdce,m %arg1(%sr1, %arg0) /* Last fdce and addr adjust */ 273 fdce,m %arg1(%sr1, %arg0) /* Last fdce and addr adjust */
274 movb,tr %arg3, %r31, fdmanyloop /* Re-init inner loop count */ 274 movb,tr %arg3, %r31, fdmanyloop /* Re-init inner loop count */
275 ADDIB<=,n -1, %arg2, fdsync /* Outer loop decr */ 275 ADDIB<=,n -1, %arg2, fdsync /* Outer loop decr */
@@ -281,7 +281,7 @@ fdoneloop: /* Loop if LOOP = 1 */
281fdsync: 281fdsync:
282 syncdma 282 syncdma
283 sync 283 sync
284 mtsm %r22 284 mtsm %r22 /* restore I-bit */
285 bv %r0(%r2) 285 bv %r0(%r2)
286 nop 286 nop
287 .exit 287 .exit
@@ -296,7 +296,7 @@ copy_user_page_asm:
296 .callinfo NO_CALLS 296 .callinfo NO_CALLS
297 .entry 297 .entry
298 298
299#ifdef __LP64__ 299#ifdef CONFIG_64BIT
300 /* PA8x00 CPUs can consume 2 loads or 1 store per cycle. 300 /* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
301 * Unroll the loop by hand and arrange insn appropriately. 301 * Unroll the loop by hand and arrange insn appropriately.
302 * GCC probably can do this just as well. 302 * GCC probably can do this just as well.
@@ -351,7 +351,11 @@ copy_user_page_asm:
351 std %r22, 120(%r26) 351 std %r22, 120(%r26)
352 ldo 128(%r26), %r26 352 ldo 128(%r26), %r26
353 353
354 ADDIB> -1, %r1, 1b /* bundle 10 */ 354 /* conditional branches nullify on forward taken branch, and on
355 * non-taken backward branch. Note that .+4 is a backwards branch.
356 * The ldd should only get executed if the branch is taken.
357 */
358 ADDIB>,n -1, %r1, 1b /* bundle 10 */
355 ldd 0(%r25), %r19 /* start next loads */ 359 ldd 0(%r25), %r19 /* start next loads */
356 360
357#else 361#else
@@ -363,10 +367,10 @@ copy_user_page_asm:
363 * the full 64 bit register values on interrupt, we can't 367 * the full 64 bit register values on interrupt, we can't
364 * use ldd/std on a 32 bit kernel. 368 * use ldd/std on a 32 bit kernel.
365 */ 369 */
370 ldw 0(%r25), %r19
366 ldi 64, %r1 /* PAGE_SIZE/64 == 64 */ 371 ldi 64, %r1 /* PAGE_SIZE/64 == 64 */
367 372
3681: 3731:
369 ldw 0(%r25), %r19
370 ldw 4(%r25), %r20 374 ldw 4(%r25), %r20
371 ldw 8(%r25), %r21 375 ldw 8(%r25), %r21
372 ldw 12(%r25), %r22 376 ldw 12(%r25), %r22
@@ -396,11 +400,12 @@ copy_user_page_asm:
396 ldw 60(%r25), %r22 400 ldw 60(%r25), %r22
397 stw %r19, 48(%r26) 401 stw %r19, 48(%r26)
398 stw %r20, 52(%r26) 402 stw %r20, 52(%r26)
403 ldo 64(%r25), %r25
399 stw %r21, 56(%r26) 404 stw %r21, 56(%r26)
400 stw %r22, 60(%r26) 405 stw %r22, 60(%r26)
401 ldo 64(%r26), %r26 406 ldo 64(%r26), %r26
402 ADDIB> -1, %r1, 1b 407 ADDIB>,n -1, %r1, 1b
403 ldo 64(%r25), %r25 408 ldw 0(%r25), %r19
404#endif 409#endif
405 bv %r0(%r2) 410 bv %r0(%r2)
406 nop 411 nop
@@ -456,7 +461,7 @@ copy_user_page_asm:
456 sub %r25, %r1, %r23 /* move physical addr into non shadowed reg */ 461 sub %r25, %r1, %r23 /* move physical addr into non shadowed reg */
457 462
458 ldil L%(TMPALIAS_MAP_START), %r28 463 ldil L%(TMPALIAS_MAP_START), %r28
459#ifdef __LP64__ 464#ifdef CONFIG_64BIT
460 extrd,u %r26,56,32, %r26 /* convert phys addr to tlb insert format */ 465 extrd,u %r26,56,32, %r26 /* convert phys addr to tlb insert format */
461 extrd,u %r23,56,32, %r23 /* convert phys addr to tlb insert format */ 466 extrd,u %r23,56,32, %r23 /* convert phys addr to tlb insert format */
462 depd %r24,63,22, %r28 /* Form aliased virtual address 'to' */ 467 depd %r24,63,22, %r28 /* Form aliased virtual address 'to' */
@@ -543,7 +548,7 @@ __clear_user_page_asm:
543 tophys_r1 %r26 548 tophys_r1 %r26
544 549
545 ldil L%(TMPALIAS_MAP_START), %r28 550 ldil L%(TMPALIAS_MAP_START), %r28
546#ifdef __LP64__ 551#ifdef CONFIG_64BIT
547#if (TMPALIAS_MAP_START >= 0x80000000) 552#if (TMPALIAS_MAP_START >= 0x80000000)
548 depdi 0, 31,32, %r28 /* clear any sign extension */ 553 depdi 0, 31,32, %r28 /* clear any sign extension */
549#endif 554#endif
@@ -560,7 +565,7 @@ __clear_user_page_asm:
560 565
561 pdtlb 0(%r28) 566 pdtlb 0(%r28)
562 567
563#ifdef __LP64__ 568#ifdef CONFIG_64BIT
564 ldi 32, %r1 /* PAGE_SIZE/128 == 32 */ 569 ldi 32, %r1 /* PAGE_SIZE/128 == 32 */
565 570
566 /* PREFETCH (Write) has not (yet) been proven to help here */ 571 /* PREFETCH (Write) has not (yet) been proven to help here */
@@ -585,7 +590,7 @@ __clear_user_page_asm:
585 ADDIB> -1, %r1, 1b 590 ADDIB> -1, %r1, 1b
586 ldo 128(%r28), %r28 591 ldo 128(%r28), %r28
587 592
588#else /* ! __LP64 */ 593#else /* ! CONFIG_64BIT */
589 594
590 ldi 64, %r1 /* PAGE_SIZE/64 == 64 */ 595 ldi 64, %r1 /* PAGE_SIZE/64 == 64 */
591 596
@@ -608,7 +613,7 @@ __clear_user_page_asm:
608 stw %r0, 60(%r28) 613 stw %r0, 60(%r28)
609 ADDIB> -1, %r1, 1b 614 ADDIB> -1, %r1, 1b
610 ldo 64(%r28), %r28 615 ldo 64(%r28), %r28
611#endif /* __LP64 */ 616#endif /* CONFIG_64BIT */
612 617
613 bv %r0(%r2) 618 bv %r0(%r2)
614 nop 619 nop
@@ -626,7 +631,7 @@ flush_kernel_dcache_page:
626 ldil L%dcache_stride, %r1 631 ldil L%dcache_stride, %r1
627 ldw R%dcache_stride(%r1), %r23 632 ldw R%dcache_stride(%r1), %r23
628 633
629#ifdef __LP64__ 634#ifdef CONFIG_64BIT
630 depdi,z 1, 63-PAGE_SHIFT,1, %r25 635 depdi,z 1, 63-PAGE_SHIFT,1, %r25
631#else 636#else
632 depwi,z 1, 31-PAGE_SHIFT,1, %r25 637 depwi,z 1, 31-PAGE_SHIFT,1, %r25
@@ -670,7 +675,7 @@ flush_user_dcache_page:
670 ldil L%dcache_stride, %r1 675 ldil L%dcache_stride, %r1
671 ldw R%dcache_stride(%r1), %r23 676 ldw R%dcache_stride(%r1), %r23
672 677
673#ifdef __LP64__ 678#ifdef CONFIG_64BIT
674 depdi,z 1,63-PAGE_SHIFT,1, %r25 679 depdi,z 1,63-PAGE_SHIFT,1, %r25
675#else 680#else
676 depwi,z 1,31-PAGE_SHIFT,1, %r25 681 depwi,z 1,31-PAGE_SHIFT,1, %r25
@@ -714,7 +719,7 @@ flush_user_icache_page:
714 ldil L%dcache_stride, %r1 719 ldil L%dcache_stride, %r1
715 ldw R%dcache_stride(%r1), %r23 720 ldw R%dcache_stride(%r1), %r23
716 721
717#ifdef __LP64__ 722#ifdef CONFIG_64BIT
718 depdi,z 1, 63-PAGE_SHIFT,1, %r25 723 depdi,z 1, 63-PAGE_SHIFT,1, %r25
719#else 724#else
720 depwi,z 1, 31-PAGE_SHIFT,1, %r25 725 depwi,z 1, 31-PAGE_SHIFT,1, %r25
@@ -759,7 +764,7 @@ purge_kernel_dcache_page:
759 ldil L%dcache_stride, %r1 764 ldil L%dcache_stride, %r1
760 ldw R%dcache_stride(%r1), %r23 765 ldw R%dcache_stride(%r1), %r23
761 766
762#ifdef __LP64__ 767#ifdef CONFIG_64BIT
763 depdi,z 1, 63-PAGE_SHIFT,1, %r25 768 depdi,z 1, 63-PAGE_SHIFT,1, %r25
764#else 769#else
765 depwi,z 1, 31-PAGE_SHIFT,1, %r25 770 depwi,z 1, 31-PAGE_SHIFT,1, %r25
@@ -807,7 +812,7 @@ flush_alias_page:
807 tophys_r1 %r26 812 tophys_r1 %r26
808 813
809 ldil L%(TMPALIAS_MAP_START), %r28 814 ldil L%(TMPALIAS_MAP_START), %r28
810#ifdef __LP64__ 815#ifdef CONFIG_64BIT
811 extrd,u %r26, 56,32, %r26 /* convert phys addr to tlb insert format */ 816 extrd,u %r26, 56,32, %r26 /* convert phys addr to tlb insert format */
812 depd %r25, 63,22, %r28 /* Form aliased virtual address 'to' */ 817 depd %r25, 63,22, %r28 /* Form aliased virtual address 'to' */
813 depdi 0, 63,12, %r28 /* Clear any offset bits */ 818 depdi 0, 63,12, %r28 /* Clear any offset bits */
@@ -824,7 +829,7 @@ flush_alias_page:
824 ldil L%dcache_stride, %r1 829 ldil L%dcache_stride, %r1
825 ldw R%dcache_stride(%r1), %r23 830 ldw R%dcache_stride(%r1), %r23
826 831
827#ifdef __LP64__ 832#ifdef CONFIG_64BIT
828 depdi,z 1, 63-PAGE_SHIFT,1, %r29 833 depdi,z 1, 63-PAGE_SHIFT,1, %r29
829#else 834#else
830 depwi,z 1, 31-PAGE_SHIFT,1, %r29 835 depwi,z 1, 31-PAGE_SHIFT,1, %r29
@@ -935,7 +940,7 @@ flush_kernel_icache_page:
935 ldil L%icache_stride, %r1 940 ldil L%icache_stride, %r1
936 ldw R%icache_stride(%r1), %r23 941 ldw R%icache_stride(%r1), %r23
937 942
938#ifdef __LP64__ 943#ifdef CONFIG_64BIT
939 depdi,z 1, 63-PAGE_SHIFT,1, %r25 944 depdi,z 1, 63-PAGE_SHIFT,1, %r25
940#else 945#else
941 depwi,z 1, 31-PAGE_SHIFT,1, %r25 946 depwi,z 1, 31-PAGE_SHIFT,1, %r25
@@ -944,23 +949,23 @@ flush_kernel_icache_page:
944 sub %r25, %r23, %r25 949 sub %r25, %r23, %r25
945 950
946 951
9471: fic,m %r23(%r26) 9521: fic,m %r23(%sr4, %r26)
948 fic,m %r23(%r26) 953 fic,m %r23(%sr4, %r26)
949 fic,m %r23(%r26) 954 fic,m %r23(%sr4, %r26)
950 fic,m %r23(%r26) 955 fic,m %r23(%sr4, %r26)
951 fic,m %r23(%r26) 956 fic,m %r23(%sr4, %r26)
952 fic,m %r23(%r26) 957 fic,m %r23(%sr4, %r26)
953 fic,m %r23(%r26) 958 fic,m %r23(%sr4, %r26)
954 fic,m %r23(%r26) 959 fic,m %r23(%sr4, %r26)
955 fic,m %r23(%r26) 960 fic,m %r23(%sr4, %r26)
956 fic,m %r23(%r26) 961 fic,m %r23(%sr4, %r26)
957 fic,m %r23(%r26) 962 fic,m %r23(%sr4, %r26)
958 fic,m %r23(%r26) 963 fic,m %r23(%sr4, %r26)
959 fic,m %r23(%r26) 964 fic,m %r23(%sr4, %r26)
960 fic,m %r23(%r26) 965 fic,m %r23(%sr4, %r26)
961 fic,m %r23(%r26) 966 fic,m %r23(%sr4, %r26)
962 CMPB<< %r26, %r25, 1b 967 CMPB<< %r26, %r25, 1b
963 fic,m %r23(%r26) 968 fic,m %r23(%sr4, %r26)
964 969
965 sync 970 sync
966 bv %r0(%r2) 971 bv %r0(%r2)
@@ -982,17 +987,18 @@ flush_kernel_icache_range_asm:
982 ANDCM %r26, %r21, %r26 987 ANDCM %r26, %r21, %r26
983 988
9841: CMPB<<,n %r26, %r25, 1b 9891: CMPB<<,n %r26, %r25, 1b
985 fic,m %r23(%r26) 990 fic,m %r23(%sr4, %r26)
986 991
987 sync 992 sync
988 bv %r0(%r2) 993 bv %r0(%r2)
989 nop 994 nop
990 .exit 995 .exit
991
992 .procend 996 .procend
993 997
994 .align 128 998 /* align should cover use of rfi in disable_sr_hashing_asm and
995 999 * srdis_done.
1000 */
1001 .align 256
996 .export disable_sr_hashing_asm,code 1002 .export disable_sr_hashing_asm,code
997 1003
998disable_sr_hashing_asm: 1004disable_sr_hashing_asm:
@@ -1000,28 +1006,26 @@ disable_sr_hashing_asm:
1000 .callinfo NO_CALLS 1006 .callinfo NO_CALLS
1001 .entry 1007 .entry
1002 1008
1003 /* Switch to real mode */ 1009 /*
1004 1010 * Switch to real mode
1005 ssm 0, %r0 /* relied upon translation! */ 1011 */
1006 nop 1012 /* pcxt_ssm_bug */
1007 nop 1013 rsm PSW_SM_I, %r0
1014 load32 PA(1f), %r1
1008 nop 1015 nop
1009 nop 1016 nop
1010 nop 1017 nop
1011 nop 1018 nop
1012 nop 1019 nop
1013 1020
1014 rsm (PSW_SM_Q|PSW_SM_I), %r0 /* disable Q&I to load the iia queue */ 1021 rsm PSW_SM_Q, %r0 /* prep to load iia queue */
1015 ldil L%REAL_MODE_PSW, %r1
1016 ldo R%REAL_MODE_PSW(%r1), %r1
1017 mtctl %r1, %cr22
1018 mtctl %r0, %cr17 /* Clear IIASQ tail */ 1022 mtctl %r0, %cr17 /* Clear IIASQ tail */
1019 mtctl %r0, %cr17 /* Clear IIASQ head */ 1023 mtctl %r0, %cr17 /* Clear IIASQ head */
1020 ldil L%PA(1f), %r1
1021 ldo R%PA(1f)(%r1), %r1
1022 mtctl %r1, %cr18 /* IIAOQ head */ 1024 mtctl %r1, %cr18 /* IIAOQ head */
1023 ldo 4(%r1), %r1 1025 ldo 4(%r1), %r1
1024 mtctl %r1, %cr18 /* IIAOQ tail */ 1026 mtctl %r1, %cr18 /* IIAOQ tail */
1027 load32 REAL_MODE_PSW, %r1
1028 mtctl %r1, %ipsw
1025 rfi 1029 rfi
1026 nop 1030 nop
1027 1031
@@ -1053,27 +1057,31 @@ srdis_pcxl:
1053 1057
1054srdis_pa20: 1058srdis_pa20:
1055 1059
1056 /* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+ */ 1060 /* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+,PCXW2 */
1057 1061
1058 .word 0x144008bc /* mfdiag %dr2, %r28 */ 1062 .word 0x144008bc /* mfdiag %dr2, %r28 */
1059 depdi 0, 54,1, %r28 /* clear DIAG_SPHASH_ENAB (bit 54) */ 1063 depdi 0, 54,1, %r28 /* clear DIAG_SPHASH_ENAB (bit 54) */
1060 .word 0x145c1840 /* mtdiag %r28, %dr2 */ 1064 .word 0x145c1840 /* mtdiag %r28, %dr2 */
1061 1065
1062srdis_done:
1063 1066
1067srdis_done:
1064 /* Switch back to virtual mode */ 1068 /* Switch back to virtual mode */
1069 rsm PSW_SM_I, %r0 /* prep to load iia queue */
1070 load32 2f, %r1
1071 nop
1072 nop
1073 nop
1074 nop
1075 nop
1065 1076
1066 rsm PSW_SM_Q, %r0 /* clear Q bit to load iia queue */ 1077 rsm PSW_SM_Q, %r0 /* prep to load iia queue */
1067 ldil L%KERNEL_PSW, %r1
1068 ldo R%KERNEL_PSW(%r1), %r1
1069 mtctl %r1, %cr22
1070 mtctl %r0, %cr17 /* Clear IIASQ tail */ 1078 mtctl %r0, %cr17 /* Clear IIASQ tail */
1071 mtctl %r0, %cr17 /* Clear IIASQ head */ 1079 mtctl %r0, %cr17 /* Clear IIASQ head */
1072 ldil L%(2f), %r1
1073 ldo R%(2f)(%r1), %r1
1074 mtctl %r1, %cr18 /* IIAOQ head */ 1080 mtctl %r1, %cr18 /* IIAOQ head */
1075 ldo 4(%r1), %r1 1081 ldo 4(%r1), %r1
1076 mtctl %r1, %cr18 /* IIAOQ tail */ 1082 mtctl %r1, %cr18 /* IIAOQ tail */
1083 load32 KERNEL_PSW, %r1
1084 mtctl %r1, %ipsw
1077 rfi 1085 rfi
1078 nop 1086 nop
1079 1087
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 368cc095c99f..ae6213d71670 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -31,7 +31,7 @@
31#include <asm/page.h> /* get_order */ 31#include <asm/page.h> /* get_order */
32#include <asm/pgalloc.h> 32#include <asm/pgalloc.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34 34#include <asm/tlbflush.h> /* for purge_tlb_*() macros */
35 35
36static struct proc_dir_entry * proc_gsc_root = NULL; 36static struct proc_dir_entry * proc_gsc_root = NULL;
37static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length); 37static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length);
@@ -333,23 +333,33 @@ pcxl_free_range(unsigned long vaddr, size_t size)
333static int __init 333static int __init
334pcxl_dma_init(void) 334pcxl_dma_init(void)
335{ 335{
336 if (pcxl_dma_start == 0) 336 if (pcxl_dma_start == 0)
337 return 0; 337 return 0;
338 338
339 spin_lock_init(&pcxl_res_lock); 339 spin_lock_init(&pcxl_res_lock);
340 pcxl_res_size = PCXL_DMA_MAP_SIZE >> (PAGE_SHIFT + 3); 340 pcxl_res_size = PCXL_DMA_MAP_SIZE >> (PAGE_SHIFT + 3);
341 pcxl_res_hint = 0; 341 pcxl_res_hint = 0;
342 pcxl_res_map = (char *)__get_free_pages(GFP_KERNEL, 342 pcxl_res_map = (char *)__get_free_pages(GFP_KERNEL,
343 get_order(pcxl_res_size)); 343 get_order(pcxl_res_size));
344 memset(pcxl_res_map, 0, pcxl_res_size); 344 memset(pcxl_res_map, 0, pcxl_res_size);
345 proc_gsc_root = proc_mkdir("gsc", 0); 345 proc_gsc_root = proc_mkdir("gsc", 0);
346 create_proc_info_entry("dino", 0, proc_gsc_root, pcxl_proc_info); 346 if (!proc_gsc_root)
347 return 0; 347 printk(KERN_WARNING
348 "pcxl_dma_init: Unable to create gsc /proc dir entry\n");
349 else {
350 struct proc_dir_entry* ent;
351 ent = create_proc_info_entry("pcxl_dma", 0,
352 proc_gsc_root, pcxl_proc_info);
353 if (!ent)
354 printk(KERN_WARNING
355 "pci-dma.c: Unable to create pcxl_dma /proc entry.\n");
356 }
357 return 0;
348} 358}
349 359
350__initcall(pcxl_dma_init); 360__initcall(pcxl_dma_init);
351 361
352static void * pa11_dma_alloc_consistent (struct device *dev, size_t size, dma_addr_t *dma_handle, int flag) 362static void * pa11_dma_alloc_consistent (struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag)
353{ 363{
354 unsigned long vaddr; 364 unsigned long vaddr;
355 unsigned long paddr; 365 unsigned long paddr;
@@ -502,13 +512,13 @@ struct hppa_dma_ops pcxl_dma_ops = {
502}; 512};
503 513
504static void *fail_alloc_consistent(struct device *dev, size_t size, 514static void *fail_alloc_consistent(struct device *dev, size_t size,
505 dma_addr_t *dma_handle, int flag) 515 dma_addr_t *dma_handle, gfp_t flag)
506{ 516{
507 return NULL; 517 return NULL;
508} 518}
509 519
510static void *pa11_dma_alloc_noncoherent(struct device *dev, size_t size, 520static void *pa11_dma_alloc_noncoherent(struct device *dev, size_t size,
511 dma_addr_t *dma_handle, int flag) 521 dma_addr_t *dma_handle, gfp_t flag)
512{ 522{
513 void *addr = NULL; 523 void *addr = NULL;
514 524
@@ -545,16 +555,16 @@ struct hppa_dma_ops pcx_dma_ops = {
545 555
546static int pcxl_proc_info(char *buf, char **start, off_t offset, int len) 556static int pcxl_proc_info(char *buf, char **start, off_t offset, int len)
547{ 557{
558#if 0
548 u_long i = 0; 559 u_long i = 0;
549 unsigned long *res_ptr = (u_long *)pcxl_res_map; 560 unsigned long *res_ptr = (u_long *)pcxl_res_map;
550 unsigned long total_pages = pcxl_res_size << 3; /* 8 bits per byte */ 561#endif
562 unsigned long total_pages = pcxl_res_size << 3; /* 8 bits per byte */
551 563
552 sprintf(buf, "\nDMA Mapping Area size : %d bytes (%d pages)\n", 564 sprintf(buf, "\nDMA Mapping Area size : %d bytes (%ld pages)\n",
553 PCXL_DMA_MAP_SIZE, 565 PCXL_DMA_MAP_SIZE, total_pages);
554 (pcxl_res_size << 3) ); /* 1 bit per page */
555 566
556 sprintf(buf, "%sResource bitmap : %d bytes (%d pages)\n", 567 sprintf(buf, "%sResource bitmap : %d bytes\n", buf, pcxl_res_size);
557 buf, pcxl_res_size, pcxl_res_size << 3); /* 8 bits per byte */
558 568
559 strcat(buf, " total: free: used: % used:\n"); 569 strcat(buf, " total: free: used: % used:\n");
560 sprintf(buf, "%sblocks %8d %8ld %8ld %8ld%%\n", buf, pcxl_res_size, 570 sprintf(buf, "%sblocks %8d %8ld %8ld %8ld%%\n", buf, pcxl_res_size,
@@ -564,7 +574,8 @@ static int pcxl_proc_info(char *buf, char **start, off_t offset, int len)
564 sprintf(buf, "%spages %8ld %8ld %8ld %8ld%%\n", buf, total_pages, 574 sprintf(buf, "%spages %8ld %8ld %8ld %8ld%%\n", buf, total_pages,
565 total_pages - pcxl_used_pages, pcxl_used_pages, 575 total_pages - pcxl_used_pages, pcxl_used_pages,
566 (pcxl_used_pages * 100 / total_pages)); 576 (pcxl_used_pages * 100 / total_pages));
567 577
578#if 0
568 strcat(buf, "\nResource bitmap:"); 579 strcat(buf, "\nResource bitmap:");
569 580
570 for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) { 581 for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) {
@@ -572,6 +583,7 @@ static int pcxl_proc_info(char *buf, char **start, off_t offset, int len)
572 strcat(buf,"\n "); 583 strcat(buf,"\n ");
573 sprintf(buf, "%s %08lx", buf, *res_ptr); 584 sprintf(buf, "%s %08lx", buf, *res_ptr);
574 } 585 }
586#endif
575 strcat(buf, "\n"); 587 strcat(buf, "\n");
576 return strlen(buf); 588 return strlen(buf);
577} 589}
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index e6a891a0cad0..88cba49c5301 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -202,7 +202,8 @@ static void
202pcibios_link_hba_resources( struct resource *hba_res, struct resource *r) 202pcibios_link_hba_resources( struct resource *hba_res, struct resource *r)
203{ 203{
204 if (!r->parent) { 204 if (!r->parent) {
205 printk(KERN_EMERG "PCI: Tell willy he's wrong\n"); 205 printk(KERN_EMERG "PCI: resource not parented! [%lx-%lx]\n",
206 r->start, r->end);
206 r->parent = hba_res; 207 r->parent = hba_res;
207 208
208 /* reverse link is harder *sigh* */ 209 /* reverse link is harder *sigh* */
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 01f676d1673b..215d78c87bc5 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -41,7 +41,7 @@
41 41
42/* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems. 42/* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems.
43 * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */ 43 * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */
44#undef EARLY_BOOTUP_DEBUG 44#define EARLY_BOOTUP_DEBUG
45 45
46 46
47#include <linux/config.h> 47#include <linux/config.h>
@@ -49,14 +49,8 @@
49#include <linux/console.h> 49#include <linux/console.h>
50#include <linux/string.h> 50#include <linux/string.h>
51#include <linux/init.h> 51#include <linux/init.h>
52#include <linux/delay.h>
53#include <linux/sched.h>
54#include <linux/interrupt.h>
55#include <linux/major.h> 52#include <linux/major.h>
56#include <linux/tty.h> 53#include <linux/tty.h>
57#include <asm/page.h>
58#include <asm/types.h>
59#include <asm/system.h>
60#include <asm/pdc.h> /* for iodc_call() proto and friends */ 54#include <asm/pdc.h> /* for iodc_call() proto and friends */
61 55
62 56
@@ -96,7 +90,6 @@ static int pdc_console_setup(struct console *co, char *options)
96} 90}
97 91
98#if defined(CONFIG_PDC_CONSOLE) 92#if defined(CONFIG_PDC_CONSOLE)
99#define PDC_CONSOLE_DEVICE pdc_console_device
100static struct tty_driver * pdc_console_device (struct console *c, int *index) 93static struct tty_driver * pdc_console_device (struct console *c, int *index)
101{ 94{
102 extern struct tty_driver console_driver; 95 extern struct tty_driver console_driver;
@@ -104,22 +97,19 @@ static struct tty_driver * pdc_console_device (struct console *c, int *index)
104 return &console_driver; 97 return &console_driver;
105} 98}
106#else 99#else
107#define PDC_CONSOLE_DEVICE NULL 100#define pdc_console_device NULL
108#endif 101#endif
109 102
110static struct console pdc_cons = { 103static struct console pdc_cons = {
111 .name = "ttyB", 104 .name = "ttyB",
112 .write = pdc_console_write, 105 .write = pdc_console_write,
113 .device = PDC_CONSOLE_DEVICE, 106 .device = pdc_console_device,
114 .setup = pdc_console_setup, 107 .setup = pdc_console_setup,
115 .flags = CON_BOOT|CON_PRINTBUFFER|CON_ENABLED, 108 .flags = CON_BOOT | CON_PRINTBUFFER | CON_ENABLED,
116 .index = -1, 109 .index = -1,
117}; 110};
118 111
119static int pdc_console_initialized; 112static int pdc_console_initialized;
120extern unsigned long con_start; /* kernel/printk.c */
121extern unsigned long log_end; /* kernel/printk.c */
122
123 113
124static void pdc_console_init_force(void) 114static void pdc_console_init_force(void)
125{ 115{
@@ -146,27 +136,11 @@ void __init pdc_console_init(void)
146} 136}
147 137
148 138
149/* Unregister the pdc console with the printk console layer */
150void pdc_console_die(void)
151{
152 if (!pdc_console_initialized)
153 return;
154 --pdc_console_initialized;
155
156 printk(KERN_INFO "Switching from PDC console\n");
157
158 /* Don't repeat what we've already printed */
159 con_start = log_end;
160
161 unregister_console(&pdc_cons);
162}
163
164
165/* 139/*
166 * Used for emergencies. Currently only used if an HPMC occurs. If an 140 * Used for emergencies. Currently only used if an HPMC occurs. If an
167 * HPMC occurs, it is possible that the current console may not be 141 * HPMC occurs, it is possible that the current console may not be
168 * properly initialed after the PDC IO reset. This routine unregisters all 142 * properly initialised after the PDC IO reset. This routine unregisters
169 * of the current consoles, reinitializes the pdc console and 143 * all of the current consoles, reinitializes the pdc console and
170 * registers it. 144 * registers it.
171 */ 145 */
172 146
@@ -177,13 +151,13 @@ void pdc_console_restart(void)
177 if (pdc_console_initialized) 151 if (pdc_console_initialized)
178 return; 152 return;
179 153
154 /* If we've already seen the output, don't bother to print it again */
155 if (console_drivers != NULL)
156 pdc_cons.flags &= ~CON_PRINTBUFFER;
157
180 while ((console = console_drivers) != NULL) 158 while ((console = console_drivers) != NULL)
181 unregister_console(console_drivers); 159 unregister_console(console_drivers);
182 160
183 /* Don't repeat what we've already printed */
184 con_start = log_end;
185
186 /* force registering the pdc console */ 161 /* force registering the pdc console */
187 pdc_console_init_force(); 162 pdc_console_init_force();
188} 163}
189
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index b3ad0a505b87..44670d6e06f4 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -746,7 +746,8 @@ static int perf_write_image(uint64_t *memaddr)
746 uint64_t *bptr; 746 uint64_t *bptr;
747 uint32_t dwords; 747 uint32_t dwords;
748 uint32_t *intrigue_rdr; 748 uint32_t *intrigue_rdr;
749 uint64_t *intrigue_bitmask, tmp64, proc_hpa; 749 uint64_t *intrigue_bitmask, tmp64;
750 void __iomem *runway;
750 struct rdr_tbl_ent *tentry; 751 struct rdr_tbl_ent *tentry;
751 int i; 752 int i;
752 753
@@ -798,15 +799,16 @@ static int perf_write_image(uint64_t *memaddr)
798 return -1; 799 return -1;
799 } 800 }
800 801
801 proc_hpa = cpu_device->hpa; 802 runway = ioremap(cpu_device->hpa.start, 4096);
802 803
803 /* Merge intrigue bits into Runway STATUS 0 */ 804 /* Merge intrigue bits into Runway STATUS 0 */
804 tmp64 = __raw_readq(proc_hpa + RUNWAY_STATUS) & 0xffecfffffffffffful; 805 tmp64 = __raw_readq(runway + RUNWAY_STATUS) & 0xffecfffffffffffful;
805 __raw_writeq(tmp64 | (*memaddr++ & 0x0013000000000000ul), proc_hpa + RUNWAY_STATUS); 806 __raw_writeq(tmp64 | (*memaddr++ & 0x0013000000000000ul),
807 runway + RUNWAY_STATUS);
806 808
807 /* Write RUNWAY DEBUG registers */ 809 /* Write RUNWAY DEBUG registers */
808 for (i = 0; i < 8; i++) { 810 for (i = 0; i < 8; i++) {
809 __raw_writeq(*memaddr++, proc_hpa + RUNWAY_DEBUG + i); 811 __raw_writeq(*memaddr++, runway + RUNWAY_DEBUG);
810 } 812 }
811 813
812 return 0; 814 return 0;
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 46b759385115..7fdca87ef647 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -9,7 +9,7 @@
9 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org> 9 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
10 * Copyright (C) 2000 Philipp Rumpf <prumpf with tux.org> 10 * Copyright (C) 2000 Philipp Rumpf <prumpf with tux.org>
11 * Copyright (C) 2000 David Kennedy <dkennedy with linuxcare.com> 11 * Copyright (C) 2000 David Kennedy <dkennedy with linuxcare.com>
12 * Copyright (C) 2000 Richard Hirst <rhirst with parisc-lixux.org> 12 * Copyright (C) 2000 Richard Hirst <rhirst with parisc-linux.org>
13 * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> 13 * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org>
14 * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org> 14 * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org>
15 * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> 15 * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org>
@@ -245,7 +245,17 @@ int
245sys_clone(unsigned long clone_flags, unsigned long usp, 245sys_clone(unsigned long clone_flags, unsigned long usp,
246 struct pt_regs *regs) 246 struct pt_regs *regs)
247{ 247{
248 int __user *user_tid = (int __user *)regs->gr[26]; 248 /* Arugments from userspace are:
249 r26 = Clone flags.
250 r25 = Child stack.
251 r24 = parent_tidptr.
252 r23 = Is the TLS storage descriptor
253 r22 = child_tidptr
254
255 However, these last 3 args are only examined
256 if the proper flags are set. */
257 int __user *child_tidptr;
258 int __user *parent_tidptr;
249 259
250 /* usp must be word aligned. This also prevents users from 260 /* usp must be word aligned. This also prevents users from
251 * passing in the value 1 (which is the signal for a special 261 * passing in the value 1 (which is the signal for a special
@@ -253,10 +263,20 @@ sys_clone(unsigned long clone_flags, unsigned long usp,
253 usp = ALIGN(usp, 4); 263 usp = ALIGN(usp, 4);
254 264
255 /* A zero value for usp means use the current stack */ 265 /* A zero value for usp means use the current stack */
256 if(usp == 0) 266 if (usp == 0)
257 usp = regs->gr[30]; 267 usp = regs->gr[30];
258 268
259 return do_fork(clone_flags, usp, regs, 0, user_tid, NULL); 269 if (clone_flags & CLONE_PARENT_SETTID)
270 parent_tidptr = (int __user *)regs->gr[24];
271 else
272 parent_tidptr = NULL;
273
274 if (clone_flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID))
275 child_tidptr = (int __user *)regs->gr[22];
276 else
277 child_tidptr = NULL;
278
279 return do_fork(clone_flags, usp, regs, 0, parent_tidptr, child_tidptr);
260} 280}
261 281
262int 282int
@@ -332,6 +352,10 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
332 } else { 352 } else {
333 cregs->kpc = (unsigned long) &child_return; 353 cregs->kpc = (unsigned long) &child_return;
334 } 354 }
355 /* Setup thread TLS area from the 4th parameter in clone */
356 if (clone_flags & CLONE_SETTLS)
357 cregs->cr27 = pregs->gr[23];
358
335 } 359 }
336 360
337 return 0; 361 return 0;
diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
index 13b721cb9f55..4f5bbcf1f5a4 100644
--- a/arch/parisc/kernel/processor.c
+++ b/arch/parisc/kernel/processor.c
@@ -92,7 +92,7 @@ static int __init processor_probe(struct parisc_device *dev)
92 * May get overwritten by PAT code. 92 * May get overwritten by PAT code.
93 */ 93 */
94 cpuid = boot_cpu_data.cpu_count; 94 cpuid = boot_cpu_data.cpu_count;
95 txn_addr = dev->hpa; /* for legacy PDC */ 95 txn_addr = dev->hpa.start; /* for legacy PDC */
96 96
97#ifdef __LP64__ 97#ifdef __LP64__
98 if (is_pdc_pat()) { 98 if (is_pdc_pat()) {
@@ -122,7 +122,7 @@ static int __init processor_probe(struct parisc_device *dev)
122 * boot time (ie shutdown a CPU from an OS perspective). 122 * boot time (ie shutdown a CPU from an OS perspective).
123 */ 123 */
124 /* get the cpu number */ 124 /* get the cpu number */
125 status = pdc_pat_cpu_get_number(&cpu_info, dev->hpa); 125 status = pdc_pat_cpu_get_number(&cpu_info, dev->hpa.start);
126 126
127 BUG_ON(PDC_OK != status); 127 BUG_ON(PDC_OK != status);
128 128
@@ -130,7 +130,7 @@ static int __init processor_probe(struct parisc_device *dev)
130 printk(KERN_WARNING "IGNORING CPU at 0x%x," 130 printk(KERN_WARNING "IGNORING CPU at 0x%x,"
131 " cpu_slot_id > NR_CPUS" 131 " cpu_slot_id > NR_CPUS"
132 " (%ld > %d)\n", 132 " (%ld > %d)\n",
133 dev->hpa, cpu_info.cpu_num, NR_CPUS); 133 dev->hpa.start, cpu_info.cpu_num, NR_CPUS);
134 /* Ignore CPU since it will only crash */ 134 /* Ignore CPU since it will only crash */
135 boot_cpu_data.cpu_count--; 135 boot_cpu_data.cpu_count--;
136 return 1; 136 return 1;
@@ -149,7 +149,7 @@ static int __init processor_probe(struct parisc_device *dev)
149 149
150 p->loops_per_jiffy = loops_per_jiffy; 150 p->loops_per_jiffy = loops_per_jiffy;
151 p->dev = dev; /* Save IODC data in case we need it */ 151 p->dev = dev; /* Save IODC data in case we need it */
152 p->hpa = dev->hpa; /* save CPU hpa */ 152 p->hpa = dev->hpa.start; /* save CPU hpa */
153 p->cpuid = cpuid; /* save CPU id */ 153 p->cpuid = cpuid; /* save CPU id */
154 p->txn_addr = txn_addr; /* save CPU IRQ address */ 154 p->txn_addr = txn_addr; /* save CPU IRQ address */
155#ifdef CONFIG_SMP 155#ifdef CONFIG_SMP
diff --git a/arch/parisc/kernel/real2.S b/arch/parisc/kernel/real2.S
index 8dd5defb7316..8c2859cca77e 100644
--- a/arch/parisc/kernel/real2.S
+++ b/arch/parisc/kernel/real2.S
@@ -7,8 +7,10 @@
7 * Copyright (C) 2000 Hewlett Packard (Paul Bame bame@puffin.external.hp.com) 7 * Copyright (C) 2000 Hewlett Packard (Paul Bame bame@puffin.external.hp.com)
8 * 8 *
9 */ 9 */
10#include <asm/assembly.h> 10#include <linux/config.h>
11
11#include <asm/psw.h> 12#include <asm/psw.h>
13#include <asm/assembly.h>
12 14
13 .section .bss 15 .section .bss
14 .export real_stack 16 .export real_stack
@@ -20,7 +22,7 @@ real32_stack:
20real64_stack: 22real64_stack:
21 .block 8192 23 .block 8192
22 24
23#ifdef __LP64__ 25#ifdef CONFIG_64BIT
24# define REG_SZ 8 26# define REG_SZ 8
25#else 27#else
26# define REG_SZ 4 28# define REG_SZ 4
@@ -50,7 +52,7 @@ save_cr_end:
50 52
51real32_call_asm: 53real32_call_asm:
52 STREG %rp, -RP_OFFSET(%sp) /* save RP */ 54 STREG %rp, -RP_OFFSET(%sp) /* save RP */
53#ifdef __LP64__ 55#ifdef CONFIG_64BIT
54 callee_save 56 callee_save
55 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */ 57 ldo 2*REG_SZ(%sp), %sp /* room for a couple more saves */
56 STREG %r27, -1*REG_SZ(%sp) 58 STREG %r27, -1*REG_SZ(%sp)
@@ -77,7 +79,7 @@ real32_call_asm:
77 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */ 79 b,l save_control_regs,%r2 /* modifies r1, r2, r28 */
78 nop 80 nop
79 81
80#ifdef __LP64__ 82#ifdef CONFIG_64BIT
81 rsm PSW_SM_W, %r0 /* go narrow */ 83 rsm PSW_SM_W, %r0 /* go narrow */
82#endif 84#endif
83 85
@@ -85,7 +87,7 @@ real32_call_asm:
85 bv 0(%r31) 87 bv 0(%r31)
86 nop 88 nop
87ric_ret: 89ric_ret:
88#ifdef __LP64__ 90#ifdef CONFIG_64BIT
89 ssm PSW_SM_W, %r0 /* go wide */ 91 ssm PSW_SM_W, %r0 /* go wide */
90#endif 92#endif
91 /* restore CRs before going virtual in case we page fault */ 93 /* restore CRs before going virtual in case we page fault */
@@ -97,7 +99,7 @@ ric_ret:
97 99
98 tovirt_r1 %sp 100 tovirt_r1 %sp
99 LDREG -REG_SZ(%sp), %sp /* restore SP */ 101 LDREG -REG_SZ(%sp), %sp /* restore SP */
100#ifdef __LP64__ 102#ifdef CONFIG_64BIT
101 LDREG -1*REG_SZ(%sp), %r27 103 LDREG -1*REG_SZ(%sp), %r27
102 LDREG -2*REG_SZ(%sp), %r29 104 LDREG -2*REG_SZ(%sp), %r29
103 ldo -2*REG_SZ(%sp), %sp 105 ldo -2*REG_SZ(%sp), %sp
@@ -143,24 +145,21 @@ restore_control_regs:
143/* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for 145/* rfi_virt2real() and rfi_real2virt() could perhaps be adapted for
144 * more general-purpose use by the several places which need RFIs 146 * more general-purpose use by the several places which need RFIs
145 */ 147 */
146 .align 128
147 .text 148 .text
149 .align 128
148rfi_virt2real: 150rfi_virt2real:
149 /* switch to real mode... */ 151 /* switch to real mode... */
150 ssm 0,0 /* See "relied upon translation" */ 152 rsm PSW_SM_I,%r0
151 nop /* PA 2.0 Arch. F-5 */ 153 load32 PA(rfi_v2r_1), %r1
152 nop
153 nop
154 nop 154 nop
155 nop 155 nop
156 nop 156 nop
157 nop 157 nop
158 nop 158 nop
159 159
160 rsm (PSW_SM_Q|PSW_SM_I),%r0 /* disable Q & I bits to load iia queue */ 160 rsm PSW_SM_Q,%r0 /* disable Q & I bits to load iia queue */
161 mtctl %r0, %cr17 /* Clear IIASQ tail */ 161 mtctl %r0, %cr17 /* Clear IIASQ tail */
162 mtctl %r0, %cr17 /* Clear IIASQ head */ 162 mtctl %r0, %cr17 /* Clear IIASQ head */
163 load32 PA(rfi_v2r_1), %r1
164 mtctl %r1, %cr18 /* IIAOQ head */ 163 mtctl %r1, %cr18 /* IIAOQ head */
165 ldo 4(%r1), %r1 164 ldo 4(%r1), %r1
166 mtctl %r1, %cr18 /* IIAOQ tail */ 165 mtctl %r1, %cr18 /* IIAOQ tail */
@@ -184,10 +183,8 @@ rfi_v2r_1:
184 .text 183 .text
185 .align 128 184 .align 128
186rfi_real2virt: 185rfi_real2virt:
187 ssm 0,0 /* See "relied upon translation" */ 186 rsm PSW_SM_I,%r0
188 nop /* PA 2.0 Arch. F-5 */ 187 load32 (rfi_r2v_1), %r1
189 nop
190 nop
191 nop 188 nop
192 nop 189 nop
193 nop 190 nop
@@ -197,7 +194,6 @@ rfi_real2virt:
197 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */ 194 rsm PSW_SM_Q,%r0 /* disable Q bit to load iia queue */
198 mtctl %r0, %cr17 /* Clear IIASQ tail */ 195 mtctl %r0, %cr17 /* Clear IIASQ tail */
199 mtctl %r0, %cr17 /* Clear IIASQ head */ 196 mtctl %r0, %cr17 /* Clear IIASQ head */
200 load32 (rfi_r2v_1), %r1
201 mtctl %r1, %cr18 /* IIAOQ head */ 197 mtctl %r1, %cr18 /* IIAOQ head */
202 ldo 4(%r1), %r1 198 ldo 4(%r1), %r1
203 mtctl %r1, %cr18 /* IIAOQ tail */ 199 mtctl %r1, %cr18 /* IIAOQ tail */
@@ -218,7 +214,7 @@ rfi_r2v_1:
218 bv 0(%r2) 214 bv 0(%r2)
219 nop 215 nop
220 216
221#ifdef __LP64__ 217#ifdef CONFIG_64BIT
222 218
223/************************ 64-bit real-mode calls ***********************/ 219/************************ 64-bit real-mode calls ***********************/
224/* This is only usable in wide kernels right now and will probably stay so */ 220/* This is only usable in wide kernels right now and will probably stay so */
@@ -296,7 +292,7 @@ pc_in_user_space:
296 ** comparing function pointers. 292 ** comparing function pointers.
297 */ 293 */
298__canonicalize_funcptr_for_compare: 294__canonicalize_funcptr_for_compare:
299#ifdef __LP64__ 295#ifdef CONFIG_64BIT
300 bve (%r2) 296 bve (%r2)
301#else 297#else
302 bv %r0(%r2) 298 bv %r0(%r2)
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 0224651fd8f1..82c24e62ab63 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -490,15 +490,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
490 490
491give_sigsegv: 491give_sigsegv:
492 DBG(1,"setup_rt_frame: sending SIGSEGV\n"); 492 DBG(1,"setup_rt_frame: sending SIGSEGV\n");
493 if (sig == SIGSEGV) 493 force_sigsegv(sig, current);
494 ka->sa.sa_handler = SIG_DFL;
495 si.si_signo = SIGSEGV;
496 si.si_errno = 0;
497 si.si_code = SI_KERNEL;
498 si.si_pid = current->pid;
499 si.si_uid = current->uid;
500 si.si_addr = frame;
501 force_sig_info(SIGSEGV, &si, current);
502 return 0; 494 return 0;
503} 495}
504 496
@@ -633,10 +625,14 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
633 put_user(0xe0008200, &usp[3]); 625 put_user(0xe0008200, &usp[3]);
634 put_user(0x34140000, &usp[4]); 626 put_user(0x34140000, &usp[4]);
635 627
636 /* Stack is 64-byte aligned, and we only 628 /* Stack is 64-byte aligned, and we only need
637 * need to flush 1 cache line */ 629 * to flush 1 cache line.
638 asm("fdc 0(%%sr3, %0)\n" 630 * Flushing one cacheline is cheap.
639 "fic 0(%%sr3, %0)\n" 631 * "sync" on bigger (> 4 way) boxes is not.
632 */
633 asm("fdc %%r0(%%sr3, %0)\n"
634 "sync\n"
635 "fic %%r0(%%sr3, %0)\n"
640 "sync\n" 636 "sync\n"
641 : : "r"(regs->gr[30])); 637 : : "r"(regs->gr[30]));
642 638
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index bcc7e83f5142..5db3be4e2704 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -18,7 +18,7 @@
18*/ 18*/
19#undef ENTRY_SYS_CPUS /* syscall support for iCOD-like functionality */ 19#undef ENTRY_SYS_CPUS /* syscall support for iCOD-like functionality */
20 20
21#include <linux/autoconf.h> 21#include <linux/config.h>
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 8c7a7185cd3b..b29b76b42bb7 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -6,6 +6,7 @@
6 * thanks to Philipp Rumpf, Mike Shaver and various others 6 * thanks to Philipp Rumpf, Mike Shaver and various others
7 * sorry about the wall, puffin.. 7 * sorry about the wall, puffin..
8 */ 8 */
9#include <linux/config.h> /* for CONFIG_SMP */
9 10
10#include <asm/asm-offsets.h> 11#include <asm/asm-offsets.h>
11#include <asm/unistd.h> 12#include <asm/unistd.h>
@@ -22,15 +23,13 @@
22 */ 23 */
23#define KILL_INSN break 0,0 24#define KILL_INSN break 0,0
24 25
25#include <linux/config.h> /* for CONFIG_SMP */ 26#ifdef CONFIG_64BIT
26
27#ifdef __LP64__
28 .level 2.0w 27 .level 2.0w
29#else 28#else
30 .level 1.1 29 .level 1.1
31#endif 30#endif
32 31
33#ifndef __LP64__ 32#ifndef CONFIG_64BIT
34 .macro fixup_branch,lbl 33 .macro fixup_branch,lbl
35 b \lbl 34 b \lbl
36 .endm 35 .endm
@@ -103,7 +102,7 @@ linux_gateway_entry:
103 mfsp %sr7,%r1 /* save user sr7 */ 102 mfsp %sr7,%r1 /* save user sr7 */
104 mtsp %r1,%sr3 /* and store it in sr3 */ 103 mtsp %r1,%sr3 /* and store it in sr3 */
105 104
106#ifdef __LP64__ 105#ifdef CONFIG_64BIT
107 /* for now we can *always* set the W bit on entry to the syscall 106 /* for now we can *always* set the W bit on entry to the syscall
108 * since we don't support wide userland processes. We could 107 * since we don't support wide userland processes. We could
109 * also save the current SM other than in r0 and restore it on 108 * also save the current SM other than in r0 and restore it on
@@ -155,7 +154,7 @@ linux_gateway_entry:
155 STREG %r19, TASK_PT_GR19(%r1) 154 STREG %r19, TASK_PT_GR19(%r1)
156 155
157 LDREGM -FRAME_SIZE(%r30), %r2 /* get users sp back */ 156 LDREGM -FRAME_SIZE(%r30), %r2 /* get users sp back */
158#ifdef __LP64__ 157#ifdef CONFIG_64BIT
159 extrd,u %r2,63,1,%r19 /* W hidden in bottom bit */ 158 extrd,u %r2,63,1,%r19 /* W hidden in bottom bit */
160#if 0 159#if 0
161 xor %r19,%r2,%r2 /* clear bottom bit */ 160 xor %r19,%r2,%r2 /* clear bottom bit */
@@ -186,7 +185,7 @@ linux_gateway_entry:
186 185
187 loadgp 186 loadgp
188 187
189#ifdef __LP64__ 188#ifdef CONFIG_64BIT
190 ldo -16(%r30),%r29 /* Reference param save area */ 189 ldo -16(%r30),%r29 /* Reference param save area */
191 copy %r19,%r2 /* W bit back to r2 */ 190 copy %r19,%r2 /* W bit back to r2 */
192#else 191#else
@@ -205,7 +204,7 @@ linux_gateway_entry:
205 /* Note! We cannot use the syscall table that is mapped 204 /* Note! We cannot use the syscall table that is mapped
206 nearby since the gateway page is mapped execute-only. */ 205 nearby since the gateway page is mapped execute-only. */
207 206
208#ifdef __LP64__ 207#ifdef CONFIG_64BIT
209 ldil L%sys_call_table, %r1 208 ldil L%sys_call_table, %r1
210 or,= %r2,%r2,%r2 209 or,= %r2,%r2,%r2
211 addil L%(sys_call_table64-sys_call_table), %r1 210 addil L%(sys_call_table64-sys_call_table), %r1
@@ -321,7 +320,7 @@ tracesys_next:
321 LDREG TASK_PT_GR25(%r1), %r25 320 LDREG TASK_PT_GR25(%r1), %r25
322 LDREG TASK_PT_GR24(%r1), %r24 321 LDREG TASK_PT_GR24(%r1), %r24
323 LDREG TASK_PT_GR23(%r1), %r23 322 LDREG TASK_PT_GR23(%r1), %r23
324#ifdef __LP64__ 323#ifdef CONFIG_64BIT
325 LDREG TASK_PT_GR22(%r1), %r22 324 LDREG TASK_PT_GR22(%r1), %r22
326 LDREG TASK_PT_GR21(%r1), %r21 325 LDREG TASK_PT_GR21(%r1), %r21
327 ldo -16(%r30),%r29 /* Reference param save area */ 326 ldo -16(%r30),%r29 /* Reference param save area */
@@ -350,7 +349,7 @@ tracesys_next:
350tracesys_exit: 349tracesys_exit:
351 ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */ 350 ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
352 LDREG TI_TASK(%r1), %r1 351 LDREG TI_TASK(%r1), %r1
353#ifdef __LP64__ 352#ifdef CONFIG_64BIT
354 ldo -16(%r30),%r29 /* Reference param save area */ 353 ldo -16(%r30),%r29 /* Reference param save area */
355#endif 354#endif
356 bl syscall_trace, %r2 355 bl syscall_trace, %r2
@@ -371,7 +370,7 @@ tracesys_exit:
371tracesys_sigexit: 370tracesys_sigexit:
372 ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */ 371 ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
373 LDREG 0(%r1), %r1 372 LDREG 0(%r1), %r1
374#ifdef __LP64__ 373#ifdef CONFIG_64BIT
375 ldo -16(%r30),%r29 /* Reference param save area */ 374 ldo -16(%r30),%r29 /* Reference param save area */
376#endif 375#endif
377 bl syscall_trace, %r2 376 bl syscall_trace, %r2
@@ -404,7 +403,7 @@ lws_start:
404 gate .+8, %r0 403 gate .+8, %r0
405 depi 3, 31, 2, %r31 /* Ensure we return to userspace */ 404 depi 3, 31, 2, %r31 /* Ensure we return to userspace */
406 405
407#ifdef __LP64__ 406#ifdef CONFIG_64BIT
408 /* FIXME: If we are a 64-bit kernel just 407 /* FIXME: If we are a 64-bit kernel just
409 * turn this on unconditionally. 408 * turn this on unconditionally.
410 */ 409 */
@@ -440,7 +439,7 @@ lws_exit_nosys:
440 /* Fall through: Return to userspace */ 439 /* Fall through: Return to userspace */
441 440
442lws_exit: 441lws_exit:
443#ifdef __LP64__ 442#ifdef CONFIG_64BIT
444 /* decide whether to reset the wide mode bit 443 /* decide whether to reset the wide mode bit
445 * 444 *
446 * For a syscall, the W bit is stored in the lowest bit 445 * For a syscall, the W bit is stored in the lowest bit
@@ -486,7 +485,7 @@ lws_exit:
486 485
487 /* ELF64 Process entry path */ 486 /* ELF64 Process entry path */
488lws_compare_and_swap64: 487lws_compare_and_swap64:
489#ifdef __LP64__ 488#ifdef CONFIG_64BIT
490 b,n lws_compare_and_swap 489 b,n lws_compare_and_swap
491#else 490#else
492 /* If we are not a 64-bit kernel, then we don't 491 /* If we are not a 64-bit kernel, then we don't
@@ -497,7 +496,7 @@ lws_compare_and_swap64:
497 496
498 /* ELF32 Process entry path */ 497 /* ELF32 Process entry path */
499lws_compare_and_swap32: 498lws_compare_and_swap32:
500#ifdef __LP64__ 499#ifdef CONFIG_64BIT
501 /* Clip all the input registers */ 500 /* Clip all the input registers */
502 depdi 0, 31, 32, %r26 501 depdi 0, 31, 32, %r26
503 depdi 0, 31, 32, %r25 502 depdi 0, 31, 32, %r25
@@ -608,7 +607,7 @@ cas_action:
608 the other for the store. Either return -EFAULT. 607 the other for the store. Either return -EFAULT.
609 Each of the entries must be relocated. */ 608 Each of the entries must be relocated. */
610 .section __ex_table,"aw" 609 .section __ex_table,"aw"
611#ifdef __LP64__ 610#ifdef CONFIG_64BIT
612 /* Pad the address calculation */ 611 /* Pad the address calculation */
613 .word 0,(2b - linux_gateway_page) 612 .word 0,(2b - linux_gateway_page)
614 .word 0,(3b - linux_gateway_page) 613 .word 0,(3b - linux_gateway_page)
@@ -619,7 +618,7 @@ cas_action:
619 .previous 618 .previous
620 619
621 .section __ex_table,"aw" 620 .section __ex_table,"aw"
622#ifdef __LP64__ 621#ifdef CONFIG_64BIT
623 /* Pad the address calculation */ 622 /* Pad the address calculation */
624 .word 0,(1b - linux_gateway_page) 623 .word 0,(1b - linux_gateway_page)
625 .word 0,(3b - linux_gateway_page) 624 .word 0,(3b - linux_gateway_page)
@@ -638,7 +637,7 @@ end_linux_gateway_page:
638 637
639 /* Relocate symbols assuming linux_gateway_page is mapped 638 /* Relocate symbols assuming linux_gateway_page is mapped
640 to virtual address 0x0 */ 639 to virtual address 0x0 */
641#ifdef __LP64__ 640#ifdef CONFIG_64BIT
642 /* FIXME: The code will always be on the gateay page 641 /* FIXME: The code will always be on the gateay page
643 and thus it will be on the first 4k, the 642 and thus it will be on the first 4k, the
644 assembler seems to think that the final 643 assembler seems to think that the final
@@ -666,7 +665,7 @@ lws_table:
666sys_call_table: 665sys_call_table:
667#include "syscall_table.S" 666#include "syscall_table.S"
668 667
669#ifdef __LP64__ 668#ifdef CONFIG_64BIT
670 .align 4096 669 .align 4096
671 .export sys_call_table64 670 .export sys_call_table64
672.Lsys_call_table64: 671.Lsys_call_table64:
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index dcfa4d3d0e7d..32cbc0489324 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -35,7 +35,7 @@
35#undef ENTRY_UHOH 35#undef ENTRY_UHOH
36#undef ENTRY_COMP 36#undef ENTRY_COMP
37#undef ENTRY_OURS 37#undef ENTRY_OURS
38#if defined(__LP64__) && !defined(SYSCALL_TABLE_64BIT) 38#if defined(CONFIG_64BIT) && !defined(SYSCALL_TABLE_64BIT)
39/* Use ENTRY_SAME for 32-bit syscalls which are the same on wide and 39/* Use ENTRY_SAME for 32-bit syscalls which are the same on wide and
40 * narrow palinux. Use ENTRY_DIFF for those where a 32-bit specific 40 * narrow palinux. Use ENTRY_DIFF for those where a 32-bit specific
41 * implementation is required on wide palinux. Use ENTRY_COMP where 41 * implementation is required on wide palinux. Use ENTRY_COMP where
@@ -46,7 +46,7 @@
46#define ENTRY_UHOH(_name_) .dword sys32_##unimplemented 46#define ENTRY_UHOH(_name_) .dword sys32_##unimplemented
47#define ENTRY_OURS(_name_) .dword parisc_##_name_ 47#define ENTRY_OURS(_name_) .dword parisc_##_name_
48#define ENTRY_COMP(_name_) .dword compat_sys_##_name_ 48#define ENTRY_COMP(_name_) .dword compat_sys_##_name_
49#elif defined(__LP64__) && defined(SYSCALL_TABLE_64BIT) 49#elif defined(CONFIG_64BIT) && defined(SYSCALL_TABLE_64BIT)
50#define ENTRY_SAME(_name_) .dword sys_##_name_ 50#define ENTRY_SAME(_name_) .dword sys_##_name_
51#define ENTRY_DIFF(_name_) .dword sys_##_name_ 51#define ENTRY_DIFF(_name_) .dword sys_##_name_
52#define ENTRY_UHOH(_name_) .dword sys_##_name_ 52#define ENTRY_UHOH(_name_) .dword sys_##_name_
@@ -368,5 +368,11 @@
368 ENTRY_COMP(mbind) /* 260 */ 368 ENTRY_COMP(mbind) /* 260 */
369 ENTRY_COMP(get_mempolicy) 369 ENTRY_COMP(get_mempolicy)
370 ENTRY_COMP(set_mempolicy) 370 ENTRY_COMP(set_mempolicy)
371 ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
372 ENTRY_SAME(add_key)
373 ENTRY_SAME(request_key) /* 265 */
374 ENTRY_SAME(keyctl)
375 ENTRY_SAME(ioprio_set)
376 ENTRY_SAME(ioprio_get)
371 /* Nothing yet */ 377 /* Nothing yet */
372 378
diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 7ff67f8e9f8c..bc979e1abdec 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -89,14 +89,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
89 } 89 }
90 } 90 }
91 91
92#ifdef CONFIG_CHASSIS_LCD_LED
93 /* Only schedule the led tasklet on cpu 0, and only if it
94 * is enabled.
95 */
96 if (cpu == 0 && !atomic_read(&led_tasklet.count))
97 tasklet_schedule(&led_tasklet);
98#endif
99
100 /* check soft power switch status */ 92 /* check soft power switch status */
101 if (cpu == 0 && !atomic_read(&power_tasklet.count)) 93 if (cpu == 0 && !atomic_read(&power_tasklet.count))
102 tasklet_schedule(&power_tasklet); 94 tasklet_schedule(&power_tasklet);
@@ -104,6 +96,24 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
104 return IRQ_HANDLED; 96 return IRQ_HANDLED;
105} 97}
106 98
99
100unsigned long profile_pc(struct pt_regs *regs)
101{
102 unsigned long pc = instruction_pointer(regs);
103
104 if (regs->gr[0] & PSW_N)
105 pc -= 4;
106
107#ifdef CONFIG_SMP
108 if (in_lock_functions(pc))
109 pc = regs->gr[2];
110#endif
111
112 return pc;
113}
114EXPORT_SYMBOL(profile_pc);
115
116
107/*** converted from ia64 ***/ 117/*** converted from ia64 ***/
108/* 118/*
109 * Return the number of micro-seconds that elapsed since the last 119 * Return the number of micro-seconds that elapsed since the last
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index d2e5b229a2f4..15914f0235a0 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -74,7 +74,10 @@ void show_regs(struct pt_regs *regs)
74 char *level; 74 char *level;
75 unsigned long cr30; 75 unsigned long cr30;
76 unsigned long cr31; 76 unsigned long cr31;
77 77 /* carlos says that gcc understands better memory in a struct,
78 * and it makes our life easier with fpregs -- T-Bone */
79 struct { u32 sw[2]; } s;
80
78 level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT; 81 level = user_mode(regs) ? KERN_DEBUG : KERN_CRIT;
79 82
80 printk("%s\n", level); /* don't want to have that pretty register dump messed up */ 83 printk("%s\n", level); /* don't want to have that pretty register dump messed up */
@@ -103,11 +106,33 @@ void show_regs(struct pt_regs *regs)
103 printk("%s\n", buf); 106 printk("%s\n", buf);
104 } 107 }
105 108
106#if RIDICULOUSLY_VERBOSE 109 /* FR are 64bit everywhere. Need to use asm to get the content
107 for (i = 0; i < 32; i += 2) 110 * of fpsr/fper1, and we assume that we won't have a FP Identify
108 printk("%sFR%02d : %016lx FR%2d : %016lx", level, i, 111 * in our way, otherwise we're screwed.
109 regs->fr[i], i+1, regs->fr[i+1]); 112 * The fldd is used to restore the T-bit if there was one, as the
110#endif 113 * store clears it anyway.
114 * BTW, PA2.0 book says "thou shall not use fstw on FPSR/FPERs". */
115 __asm__ (
116 "fstd %%fr0,0(%1) \n\t"
117 "fldd 0(%1),%%fr0 \n\t"
118 : "=m" (s) : "r" (&s) : "%r0"
119 );
120
121 printk("%s\n", level);
122 printk("%s VZOUICununcqcqcqcqcqcrmunTDVZOUI\n", level);
123 printbinary(buf, s.sw[0], 32);
124 printk("%sFPSR: %s\n", level, buf);
125 printk("%sFPER1: %08x\n", level, s.sw[1]);
126
127 /* here we'll print fr0 again, tho it'll be meaningless */
128 for (i = 0; i < 32; i += 4) {
129 int j;
130 p = buf;
131 p += sprintf(p, "%sfr%02d-%02d ", level, i, i + 3);
132 for (j = 0; j < 4; j++)
133 p += sprintf(p, " %016llx", (i+j) == 0 ? 0 : regs->fr[i+j]);
134 printk("%s\n", buf);
135 }
111 136
112 cr30 = mfctl(30); 137 cr30 = mfctl(30);
113 cr31 = mfctl(31); 138 cr31 = mfctl(31);
diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c
index 62eea35bcd69..eaae8a021f9f 100644
--- a/arch/parisc/kernel/unaligned.c
+++ b/arch/parisc/kernel/unaligned.c
@@ -513,15 +513,18 @@ void handle_unaligned(struct pt_regs *regs)
513 register int flop=0; /* true if this is a flop */ 513 register int flop=0; /* true if this is a flop */
514 514
515 /* log a message with pacing */ 515 /* log a message with pacing */
516 if (user_mode(regs)) 516 if (user_mode(regs)) {
517 { 517 if (current->thread.flags & PARISC_UAC_SIGBUS) {
518 if (unaligned_count > 5 && jiffies - last_time > 5*HZ) 518 goto force_sigbus;
519 { 519 }
520
521 if (unaligned_count > 5 && jiffies - last_time > 5*HZ) {
520 unaligned_count = 0; 522 unaligned_count = 0;
521 last_time = jiffies; 523 last_time = jiffies;
522 } 524 }
523 if (++unaligned_count < 5) 525
524 { 526 if (!(current->thread.flags & PARISC_UAC_NOPRINT)
527 && ++unaligned_count < 5) {
525 char buf[256]; 528 char buf[256];
526 sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n", 529 sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n",
527 current->comm, current->pid, regs->ior, regs->iaoq[0]); 530 current->comm, current->pid, regs->ior, regs->iaoq[0]);
@@ -530,6 +533,7 @@ void handle_unaligned(struct pt_regs *regs)
530 show_regs(regs); 533 show_regs(regs);
531#endif 534#endif
532 } 535 }
536
533 if (!unaligned_enabled) 537 if (!unaligned_enabled)
534 goto force_sigbus; 538 goto force_sigbus;
535 } 539 }
diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S
index 1b91612ed964..e0661c2978ed 100644
--- a/arch/parisc/lib/fixup.S
+++ b/arch/parisc/lib/fixup.S
@@ -35,7 +35,7 @@
35 extrd,u \t2,63,32,\t2 35 extrd,u \t2,63,32,\t2
36#endif 36#endif
37 /* t2 = &__per_cpu_offset[smp_processor_id()]; */ 37 /* t2 = &__per_cpu_offset[smp_processor_id()]; */
38 LDREG,s \t2(\t1),\t2 38 LDREGX \t2(\t1),\t2
39 addil LT%per_cpu__exception_data,%r27 39 addil LT%per_cpu__exception_data,%r27
40 LDREG RT%per_cpu__exception_data(%r1),\t1 40 LDREG RT%per_cpu__exception_data(%r1),\t1
41 /* t1 = &__get_cpu_var(exception_data) */ 41 /* t1 = &__get_cpu_var(exception_data) */
@@ -53,6 +53,8 @@
53 .endm 53 .endm
54#endif 54#endif
55 55
56 .level LEVEL
57
56 .text 58 .text
57 .section .fixup, "ax" 59 .section .fixup, "ax"
58 60
diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
index feb1b9f42c2b..b7098035321f 100644
--- a/arch/parisc/lib/memcpy.c
+++ b/arch/parisc/lib/memcpy.c
@@ -339,6 +339,7 @@ unsigned long pa_memcpy(void *dstp, const void *srcp, unsigned long len)
339 pds = (double *)pcs; 339 pds = (double *)pcs;
340 pdd = (double *)pcd; 340 pdd = (double *)pcd;
341 341
342#if 0
342 /* Copy 8 doubles at a time */ 343 /* Copy 8 doubles at a time */
343 while (len >= 8*sizeof(double)) { 344 while (len >= 8*sizeof(double)) {
344 register double r1, r2, r3, r4, r5, r6, r7, r8; 345 register double r1, r2, r3, r4, r5, r6, r7, r8;
@@ -366,6 +367,7 @@ unsigned long pa_memcpy(void *dstp, const void *srcp, unsigned long len)
366 fstdma(d_space, r8, pdd, pmc_store_exc); 367 fstdma(d_space, r8, pdd, pmc_store_exc);
367 len -= 8*sizeof(double); 368 len -= 8*sizeof(double);
368 } 369 }
370#endif
369 371
370 pws = (unsigned int *)pds; 372 pws = (unsigned int *)pds;
371 pwd = (unsigned int *)pdd; 373 pwd = (unsigned int *)pdd;
diff --git a/arch/ppc/8xx_io/cs4218.h b/arch/ppc/8xx_io/cs4218.h
index a3c38c5a5db2..f1c7392255f8 100644
--- a/arch/ppc/8xx_io/cs4218.h
+++ b/arch/ppc/8xx_io/cs4218.h
@@ -78,7 +78,7 @@ typedef struct {
78 const char *name2; 78 const char *name2;
79 void (*open)(void); 79 void (*open)(void);
80 void (*release)(void); 80 void (*release)(void);
81 void *(*dma_alloc)(unsigned int, int); 81 void *(*dma_alloc)(unsigned int, gfp_t);
82 void (*dma_free)(void *, unsigned int); 82 void (*dma_free)(void *, unsigned int);
83 int (*irqinit)(void); 83 int (*irqinit)(void);
84#ifdef MODULE 84#ifdef MODULE
diff --git a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
index 2ca9ec7ec3a7..532caa388dc2 100644
--- a/arch/ppc/8xx_io/cs4218_tdm.c
+++ b/arch/ppc/8xx_io/cs4218_tdm.c
@@ -318,7 +318,7 @@ struct cs_sound_settings {
318 318
319static struct cs_sound_settings sound; 319static struct cs_sound_settings sound;
320 320
321static void *CS_Alloc(unsigned int size, int flags); 321static void *CS_Alloc(unsigned int size, gfp_t flags);
322static void CS_Free(void *ptr, unsigned int size); 322static void CS_Free(void *ptr, unsigned int size);
323static int CS_IrqInit(void); 323static int CS_IrqInit(void);
324#ifdef MODULE 324#ifdef MODULE
@@ -959,7 +959,7 @@ static TRANS transCSNormalRead = {
959 959
960/*** Low level stuff *********************************************************/ 960/*** Low level stuff *********************************************************/
961 961
962static void *CS_Alloc(unsigned int size, int flags) 962static void *CS_Alloc(unsigned int size, gfp_t flags)
963{ 963{
964 int order; 964 int order;
965 965
diff --git a/arch/ppc/kernel/dma-mapping.c b/arch/ppc/kernel/dma-mapping.c
index 8edee806dae7..0f710d2baec6 100644
--- a/arch/ppc/kernel/dma-mapping.c
+++ b/arch/ppc/kernel/dma-mapping.c
@@ -115,7 +115,7 @@ static struct vm_region consistent_head = {
115}; 115};
116 116
117static struct vm_region * 117static struct vm_region *
118vm_region_alloc(struct vm_region *head, size_t size, int gfp) 118vm_region_alloc(struct vm_region *head, size_t size, gfp_t gfp)
119{ 119{
120 unsigned long addr = head->vm_start, end = head->vm_end - size; 120 unsigned long addr = head->vm_start, end = head->vm_end - size;
121 unsigned long flags; 121 unsigned long flags;
@@ -173,7 +173,7 @@ static struct vm_region *vm_region_find(struct vm_region *head, unsigned long ad
173 * virtual and bus address for that space. 173 * virtual and bus address for that space.
174 */ 174 */
175void * 175void *
176__dma_alloc_coherent(size_t size, dma_addr_t *handle, int gfp) 176__dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp)
177{ 177{
178 struct page *page; 178 struct page *page;
179 struct vm_region *c; 179 struct vm_region *c;
diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
index 81a3d7446d37..43505b1fc5d8 100644
--- a/arch/ppc/mm/pgtable.c
+++ b/arch/ppc/mm/pgtable.c
@@ -114,9 +114,9 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
114 struct page *ptepage; 114 struct page *ptepage;
115 115
116#ifdef CONFIG_HIGHPTE 116#ifdef CONFIG_HIGHPTE
117 int flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT; 117 gfp_t flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT;
118#else 118#else
119 int flags = GFP_KERNEL | __GFP_REPEAT; 119 gfp_t flags = GFP_KERNEL | __GFP_REPEAT;
120#endif 120#endif
121 121
122 ptepage = alloc_pages(flags, 0); 122 ptepage = alloc_pages(flags, 0);
diff --git a/arch/sh/boards/renesas/rts7751r2d/mach.c b/arch/sh/boards/renesas/rts7751r2d/mach.c
index 1efc18e786d5..610740512d56 100644
--- a/arch/sh/boards/renesas/rts7751r2d/mach.c
+++ b/arch/sh/boards/renesas/rts7751r2d/mach.c
@@ -23,7 +23,7 @@ extern void init_rts7751r2d_IRQ(void);
23extern void *rts7751r2d_ioremap(unsigned long, unsigned long); 23extern void *rts7751r2d_ioremap(unsigned long, unsigned long);
24extern int rts7751r2d_irq_demux(int irq); 24extern int rts7751r2d_irq_demux(int irq);
25 25
26extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, int); 26extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
27extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t); 27extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
28 28
29/* 29/*
diff --git a/arch/sh/cchips/voyagergx/consistent.c b/arch/sh/cchips/voyagergx/consistent.c
index 5b92585a38d2..3d9a02c093a3 100644
--- a/arch/sh/cchips/voyagergx/consistent.c
+++ b/arch/sh/cchips/voyagergx/consistent.c
@@ -31,7 +31,7 @@ static LIST_HEAD(voya_alloc_list);
31#define OHCI_SRAM_SIZE 0x10000 31#define OHCI_SRAM_SIZE 0x10000
32 32
33void *voyagergx_consistent_alloc(struct device *dev, size_t size, 33void *voyagergx_consistent_alloc(struct device *dev, size_t size,
34 dma_addr_t *handle, int flag) 34 dma_addr_t *handle, gfp_t flag)
35{ 35{
36 struct list_head *list = &voya_alloc_list; 36 struct list_head *list = &voya_alloc_list;
37 struct voya_alloc_entry *entry; 37 struct voya_alloc_entry *entry;
diff --git a/arch/sh/drivers/pci/dma-dreamcast.c b/arch/sh/drivers/pci/dma-dreamcast.c
index 83de7ef4e7df..e12418bb1fa5 100644
--- a/arch/sh/drivers/pci/dma-dreamcast.c
+++ b/arch/sh/drivers/pci/dma-dreamcast.c
@@ -33,7 +33,7 @@
33static int gapspci_dma_used = 0; 33static int gapspci_dma_used = 0;
34 34
35void *dreamcast_consistent_alloc(struct device *dev, size_t size, 35void *dreamcast_consistent_alloc(struct device *dev, size_t size,
36 dma_addr_t *dma_handle, int flag) 36 dma_addr_t *dma_handle, gfp_t flag)
37{ 37{
38 unsigned long buf; 38 unsigned long buf;
39 39
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 1f7af0c73cf4..df3a9e452cc5 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -11,7 +11,7 @@
11#include <linux/dma-mapping.h> 11#include <linux/dma-mapping.h>
12#include <asm/io.h> 12#include <asm/io.h>
13 13
14void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle) 14void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
15{ 15{
16 struct page *page, *end, *free; 16 struct page *page, *end, *free;
17 void *ret; 17 void *ret;
diff --git a/arch/sparc64/solaris/socksys.c b/arch/sparc64/solaris/socksys.c
index d7c1c76582cc..fc6669e8dde1 100644
--- a/arch/sparc64/solaris/socksys.c
+++ b/arch/sparc64/solaris/socksys.c
@@ -49,7 +49,7 @@ IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_RAW,
49 49
50#else 50#else
51 51
52extern void * mykmalloc(size_t s, int gfp); 52extern void * mykmalloc(size_t s, gfp_t gfp);
53extern void mykfree(void *); 53extern void mykfree(void *);
54 54
55#endif 55#endif
diff --git a/arch/sparc64/solaris/timod.c b/arch/sparc64/solaris/timod.c
index aaad29c35c83..b84e5456b025 100644
--- a/arch/sparc64/solaris/timod.c
+++ b/arch/sparc64/solaris/timod.c
@@ -39,7 +39,7 @@ static char * page = NULL ;
39 39
40#else 40#else
41 41
42void * mykmalloc(size_t s, int gfp) 42void * mykmalloc(size_t s, gfp_t gfp)
43{ 43{
44 static char * page; 44 static char * page;
45 static size_t free; 45 static size_t free;
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index ea008b031a8f..462cc9d65386 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -252,7 +252,7 @@ void paging_init(void)
252#endif 252#endif
253} 253}
254 254
255struct page *arch_validate(struct page *page, int mask, int order) 255struct page *arch_validate(struct page *page, gfp_t mask, int order)
256{ 256{
257 unsigned long addr, zero = 0; 257 unsigned long addr, zero = 0;
258 int i; 258 int i;
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index ea65db679e9c..0d73ceeece72 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -80,7 +80,7 @@ void free_stack(unsigned long stack, int order)
80unsigned long alloc_stack(int order, int atomic) 80unsigned long alloc_stack(int order, int atomic)
81{ 81{
82 unsigned long page; 82 unsigned long page;
83 int flags = GFP_KERNEL; 83 gfp_t flags = GFP_KERNEL;
84 84
85 if (atomic) 85 if (atomic)
86 flags = GFP_ATOMIC; 86 flags = GFP_ATOMIC;
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index cf0a0315d586..88be97c96987 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -187,7 +187,7 @@ static void flush_gart(struct device *dev)
187 187
188/* Allocate DMA memory on node near device */ 188/* Allocate DMA memory on node near device */
189noinline 189noinline
190static void *dma_alloc_pages(struct device *dev, unsigned gfp, unsigned order) 190static void *dma_alloc_pages(struct device *dev, gfp_t gfp, unsigned order)
191{ 191{
192 struct page *page; 192 struct page *page;
193 int node; 193 int node;
@@ -204,7 +204,7 @@ static void *dma_alloc_pages(struct device *dev, unsigned gfp, unsigned order)
204 */ 204 */
205void * 205void *
206dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 206dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
207 unsigned gfp) 207 gfp_t gfp)
208{ 208{
209 void *memory; 209 void *memory;
210 unsigned long dma_mask = 0; 210 unsigned long dma_mask = 0;
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index 67d90b89af0b..5a981dca87ff 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -24,7 +24,7 @@ EXPORT_SYMBOL(iommu_sac_force);
24 */ 24 */
25 25
26void *dma_alloc_coherent(struct device *hwdev, size_t size, 26void *dma_alloc_coherent(struct device *hwdev, size_t size,
27 dma_addr_t *dma_handle, unsigned gfp) 27 dma_addr_t *dma_handle, gfp_t gfp)
28{ 28{
29 void *ret; 29 void *ret;
30 u64 mask; 30 u64 mask;
diff --git a/arch/xtensa/kernel/pci-dma.c b/arch/xtensa/kernel/pci-dma.c
index 84fde258cf85..1ff82268e8ea 100644
--- a/arch/xtensa/kernel/pci-dma.c
+++ b/arch/xtensa/kernel/pci-dma.c
@@ -29,7 +29,7 @@
29 */ 29 */
30 30
31void * 31void *
32dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, int gfp) 32dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
33{ 33{
34 void *ret; 34 void *ret;
35 35
diff --git a/drivers/Makefile b/drivers/Makefile
index 1a109a6dd953..65670be6ff1a 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -5,7 +5,7 @@
5# Rewritten to use lists instead of if-statements. 5# Rewritten to use lists instead of if-statements.
6# 6#
7 7
8obj-$(CONFIG_PCI) += pci/ 8obj-$(CONFIG_PCI) += pci/ usb/
9obj-$(CONFIG_PARISC) += parisc/ 9obj-$(CONFIG_PARISC) += parisc/
10obj-y += video/ 10obj-y += video/
11obj-$(CONFIG_ACPI) += acpi/ 11obj-$(CONFIG_ACPI) += acpi/
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index 6b2eb6f39b4d..2a7d7ae83e1e 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -19,6 +19,8 @@
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/module.h> 20#include <linux/module.h>
21 21
22#include "base.h"
23
22/* This is a private structure used to tie the classdev and the 24/* This is a private structure used to tie the classdev and the
23 * container .. it should never be visible outside this file */ 25 * container .. it should never be visible outside this file */
24struct internal_container { 26struct internal_container {
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 783752b68a9a..e3b548d46cff 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -1,3 +1,15 @@
1
2/* initialisation functions */
3
4extern int devices_init(void);
5extern int buses_init(void);
6extern int classes_init(void);
7extern int firmware_init(void);
8extern int platform_bus_init(void);
9extern int system_bus_init(void);
10extern int cpu_dev_init(void);
11extern int attribute_container_init(void);
12
1extern int bus_add_device(struct device * dev); 13extern int bus_add_device(struct device * dev);
2extern void bus_remove_device(struct device * dev); 14extern void bus_remove_device(struct device * dev);
3 15
diff --git a/drivers/base/class.c b/drivers/base/class.c
index ce23dc8c18c5..c3e569730afe 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -99,7 +99,8 @@ struct class * class_get(struct class * cls)
99 99
100void class_put(struct class * cls) 100void class_put(struct class * cls)
101{ 101{
102 subsys_put(&cls->subsys); 102 if (cls)
103 subsys_put(&cls->subsys);
103} 104}
104 105
105 106
@@ -165,14 +166,25 @@ void class_unregister(struct class * cls)
165 166
166static void class_create_release(struct class *cls) 167static void class_create_release(struct class *cls)
167{ 168{
169 pr_debug("%s called for %s\n", __FUNCTION__, cls->name);
168 kfree(cls); 170 kfree(cls);
169} 171}
170 172
171static void class_device_create_release(struct class_device *class_dev) 173static void class_device_create_release(struct class_device *class_dev)
172{ 174{
175 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
173 kfree(class_dev); 176 kfree(class_dev);
174} 177}
175 178
179/* needed to allow these devices to have parent class devices */
180static int class_device_create_hotplug(struct class_device *class_dev,
181 char **envp, int num_envp,
182 char *buffer, int buffer_size)
183{
184 pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id);
185 return 0;
186}
187
176/** 188/**
177 * class_create - create a struct class structure 189 * class_create - create a struct class structure
178 * @owner: pointer to the module that is to "own" this struct class 190 * @owner: pointer to the module that is to "own" this struct class
@@ -301,10 +313,12 @@ static void class_dev_release(struct kobject * kobj)
301 kfree(cd->devt_attr); 313 kfree(cd->devt_attr);
302 cd->devt_attr = NULL; 314 cd->devt_attr = NULL;
303 315
304 if (cls->release) 316 if (cd->release)
317 cd->release(cd);
318 else if (cls->release)
305 cls->release(cd); 319 cls->release(cd);
306 else { 320 else {
307 printk(KERN_ERR "Device class '%s' does not have a release() function, " 321 printk(KERN_ERR "Class Device '%s' does not have a release() function, "
308 "it is broken and must be fixed.\n", 322 "it is broken and must be fixed.\n",
309 cd->class_id); 323 cd->class_id);
310 WARN_ON(1); 324 WARN_ON(1);
@@ -382,14 +396,18 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
382 buffer = &buffer[length]; 396 buffer = &buffer[length];
383 buffer_size -= length; 397 buffer_size -= length;
384 398
385 if (class_dev->class->hotplug) { 399 if (class_dev->hotplug) {
386 /* have the bus specific function add its stuff */ 400 /* have the class device specific function add its stuff */
387 retval = class_dev->class->hotplug (class_dev, envp, num_envp, 401 retval = class_dev->hotplug(class_dev, envp, num_envp,
388 buffer, buffer_size); 402 buffer, buffer_size);
389 if (retval) { 403 if (retval)
390 pr_debug ("%s - hotplug() returned %d\n", 404 pr_debug("class_dev->hotplug() returned %d\n", retval);
391 __FUNCTION__, retval); 405 } else if (class_dev->class->hotplug) {
392 } 406 /* have the class specific function add its stuff */
407 retval = class_dev->class->hotplug(class_dev, envp, num_envp,
408 buffer, buffer_size);
409 if (retval)
410 pr_debug("class->hotplug() returned %d\n", retval);
393 } 411 }
394 412
395 return retval; 413 return retval;
@@ -442,6 +460,13 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf)
442 return print_dev_t(buf, class_dev->devt); 460 return print_dev_t(buf, class_dev->devt);
443} 461}
444 462
463static ssize_t store_uevent(struct class_device *class_dev,
464 const char *buf, size_t count)
465{
466 kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
467 return count;
468}
469
445void class_device_initialize(struct class_device *class_dev) 470void class_device_initialize(struct class_device *class_dev)
446{ 471{
447 kobj_set_kset_s(class_dev, class_obj_subsys); 472 kobj_set_kset_s(class_dev, class_obj_subsys);
@@ -469,34 +494,45 @@ static char *make_class_name(struct class_device *class_dev)
469 494
470int class_device_add(struct class_device *class_dev) 495int class_device_add(struct class_device *class_dev)
471{ 496{
472 struct class * parent = NULL; 497 struct class *parent_class = NULL;
473 struct class_interface * class_intf; 498 struct class_device *parent_class_dev = NULL;
499 struct class_interface *class_intf;
474 char *class_name = NULL; 500 char *class_name = NULL;
475 int error; 501 int error = -EINVAL;
476 502
477 class_dev = class_device_get(class_dev); 503 class_dev = class_device_get(class_dev);
478 if (!class_dev) 504 if (!class_dev)
479 return -EINVAL; 505 return -EINVAL;
480 506
481 if (!strlen(class_dev->class_id)) { 507 if (!strlen(class_dev->class_id))
482 error = -EINVAL;
483 goto register_done; 508 goto register_done;
484 }
485 509
486 parent = class_get(class_dev->class); 510 parent_class = class_get(class_dev->class);
511 if (!parent_class)
512 goto register_done;
513 parent_class_dev = class_device_get(class_dev->parent);
487 514
488 pr_debug("CLASS: registering class device: ID = '%s'\n", 515 pr_debug("CLASS: registering class device: ID = '%s'\n",
489 class_dev->class_id); 516 class_dev->class_id);
490 517
491 /* first, register with generic layer. */ 518 /* first, register with generic layer. */
492 kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id); 519 kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id);
493 if (parent) 520 if (parent_class_dev)
494 class_dev->kobj.parent = &parent->subsys.kset.kobj; 521 class_dev->kobj.parent = &parent_class_dev->kobj;
522 else
523 class_dev->kobj.parent = &parent_class->subsys.kset.kobj;
495 524
496 if ((error = kobject_add(&class_dev->kobj))) 525 error = kobject_add(&class_dev->kobj);
526 if (error)
497 goto register_done; 527 goto register_done;
498 528
499 /* add the needed attributes to this device */ 529 /* add the needed attributes to this device */
530 class_dev->uevent_attr.attr.name = "uevent";
531 class_dev->uevent_attr.attr.mode = S_IWUSR;
532 class_dev->uevent_attr.attr.owner = parent_class->owner;
533 class_dev->uevent_attr.store = store_uevent;
534 class_device_create_file(class_dev, &class_dev->uevent_attr);
535
500 if (MAJOR(class_dev->devt)) { 536 if (MAJOR(class_dev->devt)) {
501 struct class_device_attribute *attr; 537 struct class_device_attribute *attr;
502 attr = kzalloc(sizeof(*attr), GFP_KERNEL); 538 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
@@ -505,12 +541,10 @@ int class_device_add(struct class_device *class_dev)
505 kobject_del(&class_dev->kobj); 541 kobject_del(&class_dev->kobj);
506 goto register_done; 542 goto register_done;
507 } 543 }
508
509 attr->attr.name = "dev"; 544 attr->attr.name = "dev";
510 attr->attr.mode = S_IRUGO; 545 attr->attr.mode = S_IRUGO;
511 attr->attr.owner = parent->owner; 546 attr->attr.owner = parent_class->owner;
512 attr->show = show_dev; 547 attr->show = show_dev;
513 attr->store = NULL;
514 class_device_create_file(class_dev, attr); 548 class_device_create_file(class_dev, attr);
515 class_dev->devt_attr = attr; 549 class_dev->devt_attr = attr;
516 } 550 }
@@ -524,20 +558,23 @@ int class_device_add(struct class_device *class_dev)
524 class_name); 558 class_name);
525 } 559 }
526 560
561 kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
562
527 /* notify any interfaces this device is now here */ 563 /* notify any interfaces this device is now here */
528 if (parent) { 564 if (parent_class) {
529 down(&parent->sem); 565 down(&parent_class->sem);
530 list_add_tail(&class_dev->node, &parent->children); 566 list_add_tail(&class_dev->node, &parent_class->children);
531 list_for_each_entry(class_intf, &parent->interfaces, node) 567 list_for_each_entry(class_intf, &parent_class->interfaces, node)
532 if (class_intf->add) 568 if (class_intf->add)
533 class_intf->add(class_dev); 569 class_intf->add(class_dev, class_intf);
534 up(&parent->sem); 570 up(&parent_class->sem);
535 } 571 }
536 kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
537 572
538 register_done: 573 register_done:
539 if (error && parent) 574 if (error) {
540 class_put(parent); 575 class_put(parent_class);
576 class_device_put(parent_class_dev);
577 }
541 class_device_put(class_dev); 578 class_device_put(class_dev);
542 kfree(class_name); 579 kfree(class_name);
543 return error; 580 return error;
@@ -552,21 +589,28 @@ int class_device_register(struct class_device *class_dev)
552/** 589/**
553 * class_device_create - creates a class device and registers it with sysfs 590 * class_device_create - creates a class device and registers it with sysfs
554 * @cs: pointer to the struct class that this device should be registered to. 591 * @cs: pointer to the struct class that this device should be registered to.
592 * @parent: pointer to the parent struct class_device of this new device, if any.
555 * @dev: the dev_t for the char device to be added. 593 * @dev: the dev_t for the char device to be added.
556 * @device: a pointer to a struct device that is assiociated with this class device. 594 * @device: a pointer to a struct device that is assiociated with this class device.
557 * @fmt: string for the class device's name 595 * @fmt: string for the class device's name
558 * 596 *
559 * This function can be used by char device classes. A struct 597 * This function can be used by char device classes. A struct
560 * class_device will be created in sysfs, registered to the specified 598 * class_device will be created in sysfs, registered to the specified
561 * class. A "dev" file will be created, showing the dev_t for the 599 * class.
562 * device. The pointer to the struct class_device will be returned from 600 * A "dev" file will be created, showing the dev_t for the device, if
563 * the call. Any further sysfs files that might be required can be 601 * the dev_t is not 0,0.
564 * created using this pointer. 602 * If a pointer to a parent struct class_device is passed in, the newly
603 * created struct class_device will be a child of that device in sysfs.
604 * The pointer to the struct class_device will be returned from the
605 * call. Any further sysfs files that might be required can be created
606 * using this pointer.
565 * 607 *
566 * Note: the struct class passed to this function must have previously 608 * Note: the struct class passed to this function must have previously
567 * been created with a call to class_create(). 609 * been created with a call to class_create().
568 */ 610 */
569struct class_device *class_device_create(struct class *cls, dev_t devt, 611struct class_device *class_device_create(struct class *cls,
612 struct class_device *parent,
613 dev_t devt,
570 struct device *device, char *fmt, ...) 614 struct device *device, char *fmt, ...)
571{ 615{
572 va_list args; 616 va_list args;
@@ -585,6 +629,9 @@ struct class_device *class_device_create(struct class *cls, dev_t devt,
585 class_dev->devt = devt; 629 class_dev->devt = devt;
586 class_dev->dev = device; 630 class_dev->dev = device;
587 class_dev->class = cls; 631 class_dev->class = cls;
632 class_dev->parent = parent;
633 class_dev->release = class_device_create_release;
634 class_dev->hotplug = class_device_create_hotplug;
588 635
589 va_start(args, fmt); 636 va_start(args, fmt);
590 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); 637 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
@@ -602,17 +649,18 @@ error:
602 649
603void class_device_del(struct class_device *class_dev) 650void class_device_del(struct class_device *class_dev)
604{ 651{
605 struct class * parent = class_dev->class; 652 struct class *parent_class = class_dev->class;
606 struct class_interface * class_intf; 653 struct class_device *parent_device = class_dev->parent;
654 struct class_interface *class_intf;
607 char *class_name = NULL; 655 char *class_name = NULL;
608 656
609 if (parent) { 657 if (parent_class) {
610 down(&parent->sem); 658 down(&parent_class->sem);
611 list_del_init(&class_dev->node); 659 list_del_init(&class_dev->node);
612 list_for_each_entry(class_intf, &parent->interfaces, node) 660 list_for_each_entry(class_intf, &parent_class->interfaces, node)
613 if (class_intf->remove) 661 if (class_intf->remove)
614 class_intf->remove(class_dev); 662 class_intf->remove(class_dev, class_intf);
615 up(&parent->sem); 663 up(&parent_class->sem);
616 } 664 }
617 665
618 if (class_dev->dev) { 666 if (class_dev->dev) {
@@ -620,6 +668,7 @@ void class_device_del(struct class_device *class_dev)
620 sysfs_remove_link(&class_dev->kobj, "device"); 668 sysfs_remove_link(&class_dev->kobj, "device");
621 sysfs_remove_link(&class_dev->dev->kobj, class_name); 669 sysfs_remove_link(&class_dev->dev->kobj, class_name);
622 } 670 }
671 class_device_remove_file(class_dev, &class_dev->uevent_attr);
623 if (class_dev->devt_attr) 672 if (class_dev->devt_attr)
624 class_device_remove_file(class_dev, class_dev->devt_attr); 673 class_device_remove_file(class_dev, class_dev->devt_attr);
625 class_device_remove_attrs(class_dev); 674 class_device_remove_attrs(class_dev);
@@ -627,8 +676,8 @@ void class_device_del(struct class_device *class_dev)
627 kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); 676 kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE);
628 kobject_del(&class_dev->kobj); 677 kobject_del(&class_dev->kobj);
629 678
630 if (parent) 679 class_device_put(parent_device);
631 class_put(parent); 680 class_put(parent_class);
632 kfree(class_name); 681 kfree(class_name);
633} 682}
634 683
@@ -708,7 +757,8 @@ struct class_device * class_device_get(struct class_device *class_dev)
708 757
709void class_device_put(struct class_device *class_dev) 758void class_device_put(struct class_device *class_dev)
710{ 759{
711 kobject_put(&class_dev->kobj); 760 if (class_dev)
761 kobject_put(&class_dev->kobj);
712} 762}
713 763
714 764
@@ -728,7 +778,7 @@ int class_interface_register(struct class_interface *class_intf)
728 list_add_tail(&class_intf->node, &parent->interfaces); 778 list_add_tail(&class_intf->node, &parent->interfaces);
729 if (class_intf->add) { 779 if (class_intf->add) {
730 list_for_each_entry(class_dev, &parent->children, node) 780 list_for_each_entry(class_dev, &parent->children, node)
731 class_intf->add(class_dev); 781 class_intf->add(class_dev, class_intf);
732 } 782 }
733 up(&parent->sem); 783 up(&parent->sem);
734 784
@@ -747,7 +797,7 @@ void class_interface_unregister(struct class_interface *class_intf)
747 list_del_init(&class_intf->node); 797 list_del_init(&class_intf->node);
748 if (class_intf->remove) { 798 if (class_intf->remove) {
749 list_for_each_entry(class_dev, &parent->children, node) 799 list_for_each_entry(class_dev, &parent->children, node)
750 class_intf->remove(class_dev); 800 class_intf->remove(class_dev, class_intf);
751 } 801 }
752 up(&parent->sem); 802 up(&parent->sem);
753 803
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6ab73f5c799a..8615b42b517a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -154,6 +154,13 @@ static struct kset_hotplug_ops device_hotplug_ops = {
154 .hotplug = dev_hotplug, 154 .hotplug = dev_hotplug,
155}; 155};
156 156
157static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
158 const char *buf, size_t count)
159{
160 kobject_hotplug(&dev->kobj, KOBJ_ADD);
161 return count;
162}
163
157/** 164/**
158 * device_subsys - structure to be registered with kobject core. 165 * device_subsys - structure to be registered with kobject core.
159 */ 166 */
@@ -225,6 +232,7 @@ void device_initialize(struct device *dev)
225 klist_children_put); 232 klist_children_put);
226 INIT_LIST_HEAD(&dev->dma_pools); 233 INIT_LIST_HEAD(&dev->dma_pools);
227 init_MUTEX(&dev->sem); 234 init_MUTEX(&dev->sem);
235 device_init_wakeup(dev, 0);
228} 236}
229 237
230/** 238/**
@@ -258,6 +266,14 @@ int device_add(struct device *dev)
258 266
259 if ((error = kobject_add(&dev->kobj))) 267 if ((error = kobject_add(&dev->kobj)))
260 goto Error; 268 goto Error;
269
270 dev->uevent_attr.attr.name = "uevent";
271 dev->uevent_attr.attr.mode = S_IWUSR;
272 if (dev->driver)
273 dev->uevent_attr.attr.owner = dev->driver->owner;
274 dev->uevent_attr.store = store_uevent;
275 device_create_file(dev, &dev->uevent_attr);
276
261 kobject_hotplug(&dev->kobj, KOBJ_ADD); 277 kobject_hotplug(&dev->kobj, KOBJ_ADD);
262 if ((error = device_pm_add(dev))) 278 if ((error = device_pm_add(dev)))
263 goto PMError; 279 goto PMError;
@@ -349,6 +365,7 @@ void device_del(struct device * dev)
349 365
350 if (parent) 366 if (parent)
351 klist_del(&dev->knode_parent); 367 klist_del(&dev->knode_parent);
368 device_remove_file(dev, &dev->uevent_attr);
352 369
353 /* Notify the platform of the removal, in case they 370 /* Notify the platform of the removal, in case they
354 * need to do anything... 371 * need to do anything...
@@ -390,11 +407,11 @@ static struct device * next_device(struct klist_iter * i)
390 407
391/** 408/**
392 * device_for_each_child - device child iterator. 409 * device_for_each_child - device child iterator.
393 * @dev: parent struct device. 410 * @parent: parent struct device.
394 * @data: data for the callback. 411 * @data: data for the callback.
395 * @fn: function to be called for each device. 412 * @fn: function to be called for each device.
396 * 413 *
397 * Iterate over @dev's child devices, and call @fn for each, 414 * Iterate over @parent's child devices, and call @fn for each,
398 * passing it @data. 415 * passing it @data.
399 * 416 *
400 * We check the return of @fn each time. If it returns anything 417 * We check the return of @fn each time. If it returns anything
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index b79badd0f158..081c927b1ed8 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -9,6 +9,7 @@
9#include <linux/topology.h> 9#include <linux/topology.h>
10#include <linux/device.h> 10#include <linux/device.h>
11 11
12#include "base.h"
12 13
13struct sysdev_class cpu_sysdev_class = { 14struct sysdev_class cpu_sysdev_class = {
14 set_kset_name("cpu"), 15 set_kset_name("cpu"),
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index ef3fe513e398..161f3a390d90 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -28,6 +28,7 @@ static struct device * next_device(struct klist_iter * i)
28/** 28/**
29 * driver_for_each_device - Iterator for devices bound to a driver. 29 * driver_for_each_device - Iterator for devices bound to a driver.
30 * @drv: Driver we're iterating. 30 * @drv: Driver we're iterating.
31 * @start: Device to begin with
31 * @data: Data to pass to the callback. 32 * @data: Data to pass to the callback.
32 * @fn: Function to call for each device. 33 * @fn: Function to call for each device.
33 * 34 *
@@ -57,7 +58,7 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
57 58
58/** 59/**
59 * driver_find_device - device iterator for locating a particular device. 60 * driver_find_device - device iterator for locating a particular device.
60 * @driver: The device's driver 61 * @drv: The device's driver
61 * @start: Device to begin with 62 * @start: Device to begin with
62 * @data: Data to pass to match function 63 * @data: Data to pass to match function
63 * @match: Callback function to check device 64 * @match: Callback function to check device
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index 88ab044932f2..cb1b98ae0d58 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -11,6 +11,9 @@
11#include <linux/kobject.h> 11#include <linux/kobject.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/device.h>
15
16#include "base.h"
14 17
15static decl_subsys(firmware, NULL, NULL); 18static decl_subsys(firmware, NULL, NULL);
16 19
diff --git a/drivers/base/init.c b/drivers/base/init.c
index a76ae5a221f3..84e604e25c4f 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -10,14 +10,8 @@
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/init.h> 11#include <linux/init.h>
12 12
13extern int devices_init(void); 13#include "base.h"
14extern int buses_init(void); 14
15extern int classes_init(void);
16extern int firmware_init(void);
17extern int platform_bus_init(void);
18extern int system_bus_init(void);
19extern int cpu_dev_init(void);
20extern int attribute_container_init(void);
21/** 15/**
22 * driver_init - initialize driver model. 16 * driver_init - initialize driver model.
23 * 17 *
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 361e204209eb..75ce8711bca5 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -17,6 +17,8 @@
17#include <linux/bootmem.h> 17#include <linux/bootmem.h>
18#include <linux/err.h> 18#include <linux/err.h>
19 19
20#include "base.h"
21
20struct device platform_bus = { 22struct device platform_bus = {
21 .bus_id = "platform", 23 .bus_id = "platform",
22}; 24};
@@ -279,13 +281,9 @@ static int platform_suspend(struct device * dev, pm_message_t state)
279{ 281{
280 int ret = 0; 282 int ret = 0;
281 283
282 if (dev->driver && dev->driver->suspend) { 284 if (dev->driver && dev->driver->suspend)
283 ret = dev->driver->suspend(dev, state, SUSPEND_DISABLE); 285 ret = dev->driver->suspend(dev, state);
284 if (ret == 0) 286
285 ret = dev->driver->suspend(dev, state, SUSPEND_SAVE_STATE);
286 if (ret == 0)
287 ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN);
288 }
289 return ret; 287 return ret;
290} 288}
291 289
@@ -293,13 +291,9 @@ static int platform_resume(struct device * dev)
293{ 291{
294 int ret = 0; 292 int ret = 0;
295 293
296 if (dev->driver && dev->driver->resume) { 294 if (dev->driver && dev->driver->resume)
297 ret = dev->driver->resume(dev, RESUME_POWER_ON); 295 ret = dev->driver->resume(dev);
298 if (ret == 0) 296
299 ret = dev->driver->resume(dev, RESUME_RESTORE_STATE);
300 if (ret == 0)
301 ret = dev->driver->resume(dev, RESUME_ENABLE);
302 }
303 return ret; 297 return ret;
304} 298}
305 299
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 15e6a8f951f1..0d2e101e4f15 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -30,23 +30,6 @@ LIST_HEAD(dpm_off_irq);
30DECLARE_MUTEX(dpm_sem); 30DECLARE_MUTEX(dpm_sem);
31DECLARE_MUTEX(dpm_list_sem); 31DECLARE_MUTEX(dpm_list_sem);
32 32
33/*
34 * PM Reference Counting.
35 */
36
37static inline void device_pm_hold(struct device * dev)
38{
39 if (dev)
40 atomic_inc(&dev->power.pm_users);
41}
42
43static inline void device_pm_release(struct device * dev)
44{
45 if (dev)
46 atomic_dec(&dev->power.pm_users);
47}
48
49
50/** 33/**
51 * device_pm_set_parent - Specify power dependency. 34 * device_pm_set_parent - Specify power dependency.
52 * @dev: Device who needs power. 35 * @dev: Device who needs power.
@@ -62,10 +45,8 @@ static inline void device_pm_release(struct device * dev)
62 45
63void device_pm_set_parent(struct device * dev, struct device * parent) 46void device_pm_set_parent(struct device * dev, struct device * parent)
64{ 47{
65 struct device * old_parent = dev->power.pm_parent; 48 put_device(dev->power.pm_parent);
66 device_pm_release(old_parent); 49 dev->power.pm_parent = get_device(parent);
67 dev->power.pm_parent = parent;
68 device_pm_hold(parent);
69} 50}
70EXPORT_SYMBOL_GPL(device_pm_set_parent); 51EXPORT_SYMBOL_GPL(device_pm_set_parent);
71 52
@@ -75,7 +56,6 @@ int device_pm_add(struct device * dev)
75 56
76 pr_debug("PM: Adding info for %s:%s\n", 57 pr_debug("PM: Adding info for %s:%s\n",
77 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 58 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
78 atomic_set(&dev->power.pm_users, 0);
79 down(&dpm_list_sem); 59 down(&dpm_list_sem);
80 list_add_tail(&dev->power.entry, &dpm_active); 60 list_add_tail(&dev->power.entry, &dpm_active);
81 device_pm_set_parent(dev, dev->parent); 61 device_pm_set_parent(dev, dev->parent);
@@ -91,7 +71,7 @@ void device_pm_remove(struct device * dev)
91 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name); 71 dev->bus ? dev->bus->name : "No Bus", dev->kobj.name);
92 down(&dpm_list_sem); 72 down(&dpm_list_sem);
93 dpm_sysfs_remove(dev); 73 dpm_sysfs_remove(dev);
94 device_pm_release(dev->power.pm_parent); 74 put_device(dev->power.pm_parent);
95 list_del_init(&dev->power.entry); 75 list_del_init(&dev->power.entry);
96 up(&dpm_list_sem); 76 up(&dpm_list_sem);
97} 77}
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 2e700d795cf1..fb3d35a9e101 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -67,9 +67,6 @@ extern int suspend_device(struct device *, pm_message_t);
67 * runtime.c 67 * runtime.c
68 */ 68 */
69 69
70extern int dpm_runtime_suspend(struct device *, pm_message_t);
71extern void dpm_runtime_resume(struct device *);
72
73#else /* CONFIG_PM */ 70#else /* CONFIG_PM */
74 71
75 72
@@ -82,14 +79,4 @@ static inline void device_pm_remove(struct device * dev)
82 79
83} 80}
84 81
85static inline int dpm_runtime_suspend(struct device * dev, pm_message_t state)
86{
87 return 0;
88}
89
90static inline void dpm_runtime_resume(struct device * dev)
91{
92
93}
94
95#endif 82#endif
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index e8f0519f5dfa..adbc3148c039 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -36,6 +36,7 @@ void dpm_runtime_resume(struct device * dev)
36 runtime_resume(dev); 36 runtime_resume(dev);
37 up(&dpm_sem); 37 up(&dpm_sem);
38} 38}
39EXPORT_SYMBOL(dpm_runtime_resume);
39 40
40 41
41/** 42/**
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 8d04fb435c17..89c57875f3e5 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -48,8 +48,81 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c
48static DEVICE_ATTR(state, 0644, state_show, state_store); 48static DEVICE_ATTR(state, 0644, state_show, state_store);
49 49
50 50
51/*
52 * wakeup - Report/change current wakeup option for device
53 *
54 * Some devices support "wakeup" events, which are hardware signals
55 * used to activate devices from suspended or low power states. Such
56 * devices have one of three values for the sysfs power/wakeup file:
57 *
58 * + "enabled\n" to issue the events;
59 * + "disabled\n" not to do so; or
60 * + "\n" for temporary or permanent inability to issue wakeup.
61 *
62 * (For example, unconfigured USB devices can't issue wakeups.)
63 *
64 * Familiar examples of devices that can issue wakeup events include
65 * keyboards and mice (both PS2 and USB styles), power buttons, modems,
66 * "Wake-On-LAN" Ethernet links, GPIO lines, and more. Some events
67 * will wake the entire system from a suspend state; others may just
68 * wake up the device (if the system as a whole is already active).
69 * Some wakeup events use normal IRQ lines; other use special out
70 * of band signaling.
71 *
72 * It is the responsibility of device drivers to enable (or disable)
73 * wakeup signaling as part of changing device power states, respecting
74 * the policy choices provided through the driver model.
75 *
76 * Devices may not be able to generate wakeup events from all power
77 * states. Also, the events may be ignored in some configurations;
78 * for example, they might need help from other devices that aren't
79 * active, or which may have wakeup disabled. Some drivers rely on
80 * wakeup events internally (unless they are disabled), keeping
81 * their hardware in low power modes whenever they're unused. This
82 * saves runtime power, without requiring system-wide sleep states.
83 */
84
85static const char enabled[] = "enabled";
86static const char disabled[] = "disabled";
87
88static ssize_t
89wake_show(struct device * dev, struct device_attribute *attr, char * buf)
90{
91 return sprintf(buf, "%s\n", device_can_wakeup(dev)
92 ? (device_may_wakeup(dev) ? enabled : disabled)
93 : "");
94}
95
96static ssize_t
97wake_store(struct device * dev, struct device_attribute *attr,
98 const char * buf, size_t n)
99{
100 char *cp;
101 int len = n;
102
103 if (!device_can_wakeup(dev))
104 return -EINVAL;
105
106 cp = memchr(buf, '\n', n);
107 if (cp)
108 len = cp - buf;
109 if (len == sizeof enabled - 1
110 && strncmp(buf, enabled, sizeof enabled - 1) == 0)
111 device_set_wakeup_enable(dev, 1);
112 else if (len == sizeof disabled - 1
113 && strncmp(buf, disabled, sizeof disabled - 1) == 0)
114 device_set_wakeup_enable(dev, 0);
115 else
116 return -EINVAL;
117 return n;
118}
119
120static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
121
122
51static struct attribute * power_attrs[] = { 123static struct attribute * power_attrs[] = {
52 &dev_attr_state.attr, 124 &dev_attr_state.attr,
125 &dev_attr_wakeup.attr,
53 NULL, 126 NULL,
54}; 127};
55static struct attribute_group pm_attr_group = { 128static struct attribute_group pm_attr_group = {
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 0e9e586e9ba3..881c48d941b7 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "12" 2#define VERSION "14"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 45a243096187..41ae0ede619a 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -224,7 +224,7 @@ aoechr_init(void)
224 return PTR_ERR(aoe_class); 224 return PTR_ERR(aoe_class);
225 } 225 }
226 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 226 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
227 class_device_create(aoe_class, 227 class_device_create(aoe_class, NULL,
228 MKDEV(AOE_MAJOR, chardevs[i].minor), 228 MKDEV(AOE_MAJOR, chardevs[i].minor),
229 NULL, chardevs[i].name); 229 NULL, chardevs[i].name);
230 230
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index b5be4b7d7b5b..5c9c7c1a3d4c 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -8,6 +8,7 @@
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/skbuff.h> 9#include <linux/skbuff.h>
10#include <linux/netdevice.h> 10#include <linux/netdevice.h>
11#include <asm/unaligned.h>
11#include "aoe.h" 12#include "aoe.h"
12 13
13#define TIMERTICK (HZ / 10) 14#define TIMERTICK (HZ / 10)
@@ -311,16 +312,16 @@ ataid_complete(struct aoedev *d, unsigned char *id)
311 u16 n; 312 u16 n;
312 313
313 /* word 83: command set supported */ 314 /* word 83: command set supported */
314 n = le16_to_cpup((__le16 *) &id[83<<1]); 315 n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1]));
315 316
316 /* word 86: command set/feature enabled */ 317 /* word 86: command set/feature enabled */
317 n |= le16_to_cpup((__le16 *) &id[86<<1]); 318 n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1]));
318 319
319 if (n & (1<<10)) { /* bit 10: LBA 48 */ 320 if (n & (1<<10)) { /* bit 10: LBA 48 */
320 d->flags |= DEVFL_EXT; 321 d->flags |= DEVFL_EXT;
321 322
322 /* word 100: number lba48 sectors */ 323 /* word 100: number lba48 sectors */
323 ssize = le64_to_cpup((__le64 *) &id[100<<1]); 324 ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1]));
324 325
325 /* set as in ide-disk.c:init_idedisk_capacity */ 326 /* set as in ide-disk.c:init_idedisk_capacity */
326 d->geo.cylinders = ssize; 327 d->geo.cylinders = ssize;
@@ -331,12 +332,12 @@ ataid_complete(struct aoedev *d, unsigned char *id)
331 d->flags &= ~DEVFL_EXT; 332 d->flags &= ~DEVFL_EXT;
332 333
333 /* number lba28 sectors */ 334 /* number lba28 sectors */
334 ssize = le32_to_cpup((__le32 *) &id[60<<1]); 335 ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1]));
335 336
336 /* NOTE: obsolete in ATA 6 */ 337 /* NOTE: obsolete in ATA 6 */
337 d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]); 338 d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1]));
338 d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]); 339 d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1]));
339 d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]); 340 d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1]));
340 } 341 }
341 d->ssize = ssize; 342 d->ssize = ssize;
342 d->geo.start = 0; 343 d->geo.start = 0;
diff --git a/drivers/block/as-iosched.c b/drivers/block/as-iosched.c
index 95c0a3690b0f..4081c36c8c19 100644
--- a/drivers/block/as-iosched.c
+++ b/drivers/block/as-iosched.c
@@ -98,7 +98,6 @@ struct as_data {
98 98
99 struct as_rq *next_arq[2]; /* next in sort order */ 99 struct as_rq *next_arq[2]; /* next in sort order */
100 sector_t last_sector[2]; /* last REQ_SYNC & REQ_ASYNC sectors */ 100 sector_t last_sector[2]; /* last REQ_SYNC & REQ_ASYNC sectors */
101 struct list_head *dispatch; /* driver dispatch queue */
102 struct list_head *hash; /* request hash */ 101 struct list_head *hash; /* request hash */
103 102
104 unsigned long exit_prob; /* probability a task will exit while 103 unsigned long exit_prob; /* probability a task will exit while
@@ -239,6 +238,25 @@ static struct io_context *as_get_io_context(void)
239 return ioc; 238 return ioc;
240} 239}
241 240
241static void as_put_io_context(struct as_rq *arq)
242{
243 struct as_io_context *aic;
244
245 if (unlikely(!arq->io_context))
246 return;
247
248 aic = arq->io_context->aic;
249
250 if (arq->is_sync == REQ_SYNC && aic) {
251 spin_lock(&aic->lock);
252 set_bit(AS_TASK_IORUNNING, &aic->state);
253 aic->last_end_request = jiffies;
254 spin_unlock(&aic->lock);
255 }
256
257 put_io_context(arq->io_context);
258}
259
242/* 260/*
243 * the back merge hash support functions 261 * the back merge hash support functions
244 */ 262 */
@@ -261,14 +279,6 @@ static inline void as_del_arq_hash(struct as_rq *arq)
261 __as_del_arq_hash(arq); 279 __as_del_arq_hash(arq);
262} 280}
263 281
264static void as_remove_merge_hints(request_queue_t *q, struct as_rq *arq)
265{
266 as_del_arq_hash(arq);
267
268 if (q->last_merge == arq->request)
269 q->last_merge = NULL;
270}
271
272static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq) 282static void as_add_arq_hash(struct as_data *ad, struct as_rq *arq)
273{ 283{
274 struct request *rq = arq->request; 284 struct request *rq = arq->request;
@@ -312,7 +322,7 @@ static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset)
312 BUG_ON(!arq->on_hash); 322 BUG_ON(!arq->on_hash);
313 323
314 if (!rq_mergeable(__rq)) { 324 if (!rq_mergeable(__rq)) {
315 as_remove_merge_hints(ad->q, arq); 325 as_del_arq_hash(arq);
316 continue; 326 continue;
317 } 327 }
318 328
@@ -950,23 +960,12 @@ static void as_completed_request(request_queue_t *q, struct request *rq)
950 960
951 WARN_ON(!list_empty(&rq->queuelist)); 961 WARN_ON(!list_empty(&rq->queuelist));
952 962
953 if (arq->state == AS_RQ_PRESCHED) {
954 WARN_ON(arq->io_context);
955 goto out;
956 }
957
958 if (arq->state == AS_RQ_MERGED)
959 goto out_ioc;
960
961 if (arq->state != AS_RQ_REMOVED) { 963 if (arq->state != AS_RQ_REMOVED) {
962 printk("arq->state %d\n", arq->state); 964 printk("arq->state %d\n", arq->state);
963 WARN_ON(1); 965 WARN_ON(1);
964 goto out; 966 goto out;
965 } 967 }
966 968
967 if (!blk_fs_request(rq))
968 goto out;
969
970 if (ad->changed_batch && ad->nr_dispatched == 1) { 969 if (ad->changed_batch && ad->nr_dispatched == 1) {
971 kblockd_schedule_work(&ad->antic_work); 970 kblockd_schedule_work(&ad->antic_work);
972 ad->changed_batch = 0; 971 ad->changed_batch = 0;
@@ -1001,21 +1000,7 @@ static void as_completed_request(request_queue_t *q, struct request *rq)
1001 } 1000 }
1002 } 1001 }
1003 1002
1004out_ioc: 1003 as_put_io_context(arq);
1005 if (!arq->io_context)
1006 goto out;
1007
1008 if (arq->is_sync == REQ_SYNC) {
1009 struct as_io_context *aic = arq->io_context->aic;
1010 if (aic) {
1011 spin_lock(&aic->lock);
1012 set_bit(AS_TASK_IORUNNING, &aic->state);
1013 aic->last_end_request = jiffies;
1014 spin_unlock(&aic->lock);
1015 }
1016 }
1017
1018 put_io_context(arq->io_context);
1019out: 1004out:
1020 arq->state = AS_RQ_POSTSCHED; 1005 arq->state = AS_RQ_POSTSCHED;
1021} 1006}
@@ -1047,73 +1032,11 @@ static void as_remove_queued_request(request_queue_t *q, struct request *rq)
1047 ad->next_arq[data_dir] = as_find_next_arq(ad, arq); 1032 ad->next_arq[data_dir] = as_find_next_arq(ad, arq);
1048 1033
1049 list_del_init(&arq->fifo); 1034 list_del_init(&arq->fifo);
1050 as_remove_merge_hints(q, arq); 1035 as_del_arq_hash(arq);
1051 as_del_arq_rb(ad, arq); 1036 as_del_arq_rb(ad, arq);
1052} 1037}
1053 1038
1054/* 1039/*
1055 * as_remove_dispatched_request is called to remove a request which has gone
1056 * to the dispatch list.
1057 */
1058static void as_remove_dispatched_request(request_queue_t *q, struct request *rq)
1059{
1060 struct as_rq *arq = RQ_DATA(rq);
1061 struct as_io_context *aic;
1062
1063 if (!arq) {
1064 WARN_ON(1);
1065 return;
1066 }
1067
1068 WARN_ON(arq->state != AS_RQ_DISPATCHED);
1069 WARN_ON(ON_RB(&arq->rb_node));
1070 if (arq->io_context && arq->io_context->aic) {
1071 aic = arq->io_context->aic;
1072 if (aic) {
1073 WARN_ON(!atomic_read(&aic->nr_dispatched));
1074 atomic_dec(&aic->nr_dispatched);
1075 }
1076 }
1077}
1078
1079/*
1080 * as_remove_request is called when a driver has finished with a request.
1081 * This should be only called for dispatched requests, but for some reason
1082 * a POWER4 box running hwscan it does not.
1083 */
1084static void as_remove_request(request_queue_t *q, struct request *rq)
1085{
1086 struct as_rq *arq = RQ_DATA(rq);
1087
1088 if (unlikely(arq->state == AS_RQ_NEW))
1089 goto out;
1090
1091 if (ON_RB(&arq->rb_node)) {
1092 if (arq->state != AS_RQ_QUEUED) {
1093 printk("arq->state %d\n", arq->state);
1094 WARN_ON(1);
1095 goto out;
1096 }
1097 /*
1098 * We'll lose the aliased request(s) here. I don't think this
1099 * will ever happen, but if it does, hopefully someone will
1100 * report it.
1101 */
1102 WARN_ON(!list_empty(&rq->queuelist));
1103 as_remove_queued_request(q, rq);
1104 } else {
1105 if (arq->state != AS_RQ_DISPATCHED) {
1106 printk("arq->state %d\n", arq->state);
1107 WARN_ON(1);
1108 goto out;
1109 }
1110 as_remove_dispatched_request(q, rq);
1111 }
1112out:
1113 arq->state = AS_RQ_REMOVED;
1114}
1115
1116/*
1117 * as_fifo_expired returns 0 if there are no expired reads on the fifo, 1040 * as_fifo_expired returns 0 if there are no expired reads on the fifo,
1118 * 1 otherwise. It is ratelimited so that we only perform the check once per 1041 * 1 otherwise. It is ratelimited so that we only perform the check once per
1119 * `fifo_expire' interval. Otherwise a large number of expired requests 1042 * `fifo_expire' interval. Otherwise a large number of expired requests
@@ -1165,7 +1088,6 @@ static inline int as_batch_expired(struct as_data *ad)
1165static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq) 1088static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1166{ 1089{
1167 struct request *rq = arq->request; 1090 struct request *rq = arq->request;
1168 struct list_head *insert;
1169 const int data_dir = arq->is_sync; 1091 const int data_dir = arq->is_sync;
1170 1092
1171 BUG_ON(!ON_RB(&arq->rb_node)); 1093 BUG_ON(!ON_RB(&arq->rb_node));
@@ -1198,13 +1120,13 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1198 /* 1120 /*
1199 * take it off the sort and fifo list, add to dispatch queue 1121 * take it off the sort and fifo list, add to dispatch queue
1200 */ 1122 */
1201 insert = ad->dispatch->prev;
1202
1203 while (!list_empty(&rq->queuelist)) { 1123 while (!list_empty(&rq->queuelist)) {
1204 struct request *__rq = list_entry_rq(rq->queuelist.next); 1124 struct request *__rq = list_entry_rq(rq->queuelist.next);
1205 struct as_rq *__arq = RQ_DATA(__rq); 1125 struct as_rq *__arq = RQ_DATA(__rq);
1206 1126
1207 list_move_tail(&__rq->queuelist, ad->dispatch); 1127 list_del(&__rq->queuelist);
1128
1129 elv_dispatch_add_tail(ad->q, __rq);
1208 1130
1209 if (__arq->io_context && __arq->io_context->aic) 1131 if (__arq->io_context && __arq->io_context->aic)
1210 atomic_inc(&__arq->io_context->aic->nr_dispatched); 1132 atomic_inc(&__arq->io_context->aic->nr_dispatched);
@@ -1218,7 +1140,8 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1218 as_remove_queued_request(ad->q, rq); 1140 as_remove_queued_request(ad->q, rq);
1219 WARN_ON(arq->state != AS_RQ_QUEUED); 1141 WARN_ON(arq->state != AS_RQ_QUEUED);
1220 1142
1221 list_add(&rq->queuelist, insert); 1143 elv_dispatch_sort(ad->q, rq);
1144
1222 arq->state = AS_RQ_DISPATCHED; 1145 arq->state = AS_RQ_DISPATCHED;
1223 if (arq->io_context && arq->io_context->aic) 1146 if (arq->io_context && arq->io_context->aic)
1224 atomic_inc(&arq->io_context->aic->nr_dispatched); 1147 atomic_inc(&arq->io_context->aic->nr_dispatched);
@@ -1230,12 +1153,42 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1230 * read/write expire, batch expire, etc, and moves it to the dispatch 1153 * read/write expire, batch expire, etc, and moves it to the dispatch
1231 * queue. Returns 1 if a request was found, 0 otherwise. 1154 * queue. Returns 1 if a request was found, 0 otherwise.
1232 */ 1155 */
1233static int as_dispatch_request(struct as_data *ad) 1156static int as_dispatch_request(request_queue_t *q, int force)
1234{ 1157{
1158 struct as_data *ad = q->elevator->elevator_data;
1235 struct as_rq *arq; 1159 struct as_rq *arq;
1236 const int reads = !list_empty(&ad->fifo_list[REQ_SYNC]); 1160 const int reads = !list_empty(&ad->fifo_list[REQ_SYNC]);
1237 const int writes = !list_empty(&ad->fifo_list[REQ_ASYNC]); 1161 const int writes = !list_empty(&ad->fifo_list[REQ_ASYNC]);
1238 1162
1163 if (unlikely(force)) {
1164 /*
1165 * Forced dispatch, accounting is useless. Reset
1166 * accounting states and dump fifo_lists. Note that
1167 * batch_data_dir is reset to REQ_SYNC to avoid
1168 * screwing write batch accounting as write batch
1169 * accounting occurs on W->R transition.
1170 */
1171 int dispatched = 0;
1172
1173 ad->batch_data_dir = REQ_SYNC;
1174 ad->changed_batch = 0;
1175 ad->new_batch = 0;
1176
1177 while (ad->next_arq[REQ_SYNC]) {
1178 as_move_to_dispatch(ad, ad->next_arq[REQ_SYNC]);
1179 dispatched++;
1180 }
1181 ad->last_check_fifo[REQ_SYNC] = jiffies;
1182
1183 while (ad->next_arq[REQ_ASYNC]) {
1184 as_move_to_dispatch(ad, ad->next_arq[REQ_ASYNC]);
1185 dispatched++;
1186 }
1187 ad->last_check_fifo[REQ_ASYNC] = jiffies;
1188
1189 return dispatched;
1190 }
1191
1239 /* Signal that the write batch was uncontended, so we can't time it */ 1192 /* Signal that the write batch was uncontended, so we can't time it */
1240 if (ad->batch_data_dir == REQ_ASYNC && !reads) { 1193 if (ad->batch_data_dir == REQ_ASYNC && !reads) {
1241 if (ad->current_write_count == 0 || !writes) 1194 if (ad->current_write_count == 0 || !writes)
@@ -1359,20 +1312,6 @@ fifo_expired:
1359 return 1; 1312 return 1;
1360} 1313}
1361 1314
1362static struct request *as_next_request(request_queue_t *q)
1363{
1364 struct as_data *ad = q->elevator->elevator_data;
1365 struct request *rq = NULL;
1366
1367 /*
1368 * if there are still requests on the dispatch queue, grab the first
1369 */
1370 if (!list_empty(ad->dispatch) || as_dispatch_request(ad))
1371 rq = list_entry_rq(ad->dispatch->next);
1372
1373 return rq;
1374}
1375
1376/* 1315/*
1377 * Add arq to a list behind alias 1316 * Add arq to a list behind alias
1378 */ 1317 */
@@ -1404,17 +1343,25 @@ as_add_aliased_request(struct as_data *ad, struct as_rq *arq, struct as_rq *alia
1404 /* 1343 /*
1405 * Don't want to have to handle merges. 1344 * Don't want to have to handle merges.
1406 */ 1345 */
1407 as_remove_merge_hints(ad->q, arq); 1346 as_del_arq_hash(arq);
1408} 1347}
1409 1348
1410/* 1349/*
1411 * add arq to rbtree and fifo 1350 * add arq to rbtree and fifo
1412 */ 1351 */
1413static void as_add_request(struct as_data *ad, struct as_rq *arq) 1352static void as_add_request(request_queue_t *q, struct request *rq)
1414{ 1353{
1354 struct as_data *ad = q->elevator->elevator_data;
1355 struct as_rq *arq = RQ_DATA(rq);
1415 struct as_rq *alias; 1356 struct as_rq *alias;
1416 int data_dir; 1357 int data_dir;
1417 1358
1359 if (arq->state != AS_RQ_PRESCHED) {
1360 printk("arq->state: %d\n", arq->state);
1361 WARN_ON(1);
1362 }
1363 arq->state = AS_RQ_NEW;
1364
1418 if (rq_data_dir(arq->request) == READ 1365 if (rq_data_dir(arq->request) == READ
1419 || current->flags&PF_SYNCWRITE) 1366 || current->flags&PF_SYNCWRITE)
1420 arq->is_sync = 1; 1367 arq->is_sync = 1;
@@ -1437,12 +1384,8 @@ static void as_add_request(struct as_data *ad, struct as_rq *arq)
1437 arq->expires = jiffies + ad->fifo_expire[data_dir]; 1384 arq->expires = jiffies + ad->fifo_expire[data_dir];
1438 list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]); 1385 list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]);
1439 1386
1440 if (rq_mergeable(arq->request)) { 1387 if (rq_mergeable(arq->request))
1441 as_add_arq_hash(ad, arq); 1388 as_add_arq_hash(ad, arq);
1442
1443 if (!ad->q->last_merge)
1444 ad->q->last_merge = arq->request;
1445 }
1446 as_update_arq(ad, arq); /* keep state machine up to date */ 1389 as_update_arq(ad, arq); /* keep state machine up to date */
1447 1390
1448 } else { 1391 } else {
@@ -1463,96 +1406,24 @@ static void as_add_request(struct as_data *ad, struct as_rq *arq)
1463 arq->state = AS_RQ_QUEUED; 1406 arq->state = AS_RQ_QUEUED;
1464} 1407}
1465 1408
1466static void as_deactivate_request(request_queue_t *q, struct request *rq) 1409static void as_activate_request(request_queue_t *q, struct request *rq)
1467{ 1410{
1468 struct as_data *ad = q->elevator->elevator_data;
1469 struct as_rq *arq = RQ_DATA(rq); 1411 struct as_rq *arq = RQ_DATA(rq);
1470 1412
1471 if (arq) { 1413 WARN_ON(arq->state != AS_RQ_DISPATCHED);
1472 if (arq->state == AS_RQ_REMOVED) { 1414 arq->state = AS_RQ_REMOVED;
1473 arq->state = AS_RQ_DISPATCHED; 1415 if (arq->io_context && arq->io_context->aic)
1474 if (arq->io_context && arq->io_context->aic) 1416 atomic_dec(&arq->io_context->aic->nr_dispatched);
1475 atomic_inc(&arq->io_context->aic->nr_dispatched);
1476 }
1477 } else
1478 WARN_ON(blk_fs_request(rq)
1479 && (!(rq->flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) );
1480
1481 /* Stop anticipating - let this request get through */
1482 as_antic_stop(ad);
1483}
1484
1485/*
1486 * requeue the request. The request has not been completed, nor is it a
1487 * new request, so don't touch accounting.
1488 */
1489static void as_requeue_request(request_queue_t *q, struct request *rq)
1490{
1491 as_deactivate_request(q, rq);
1492 list_add(&rq->queuelist, &q->queue_head);
1493}
1494
1495/*
1496 * Account a request that is inserted directly onto the dispatch queue.
1497 * arq->io_context->aic->nr_dispatched should not need to be incremented
1498 * because only new requests should come through here: requeues go through
1499 * our explicit requeue handler.
1500 */
1501static void as_account_queued_request(struct as_data *ad, struct request *rq)
1502{
1503 if (blk_fs_request(rq)) {
1504 struct as_rq *arq = RQ_DATA(rq);
1505 arq->state = AS_RQ_DISPATCHED;
1506 ad->nr_dispatched++;
1507 }
1508} 1417}
1509 1418
1510static void 1419static void as_deactivate_request(request_queue_t *q, struct request *rq)
1511as_insert_request(request_queue_t *q, struct request *rq, int where)
1512{ 1420{
1513 struct as_data *ad = q->elevator->elevator_data;
1514 struct as_rq *arq = RQ_DATA(rq); 1421 struct as_rq *arq = RQ_DATA(rq);
1515 1422
1516 if (arq) { 1423 WARN_ON(arq->state != AS_RQ_REMOVED);
1517 if (arq->state != AS_RQ_PRESCHED) { 1424 arq->state = AS_RQ_DISPATCHED;
1518 printk("arq->state: %d\n", arq->state); 1425 if (arq->io_context && arq->io_context->aic)
1519 WARN_ON(1); 1426 atomic_inc(&arq->io_context->aic->nr_dispatched);
1520 }
1521 arq->state = AS_RQ_NEW;
1522 }
1523
1524 /* barriers must flush the reorder queue */
1525 if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)
1526 && where == ELEVATOR_INSERT_SORT)) {
1527 WARN_ON(1);
1528 where = ELEVATOR_INSERT_BACK;
1529 }
1530
1531 switch (where) {
1532 case ELEVATOR_INSERT_BACK:
1533 while (ad->next_arq[REQ_SYNC])
1534 as_move_to_dispatch(ad, ad->next_arq[REQ_SYNC]);
1535
1536 while (ad->next_arq[REQ_ASYNC])
1537 as_move_to_dispatch(ad, ad->next_arq[REQ_ASYNC]);
1538
1539 list_add_tail(&rq->queuelist, ad->dispatch);
1540 as_account_queued_request(ad, rq);
1541 as_antic_stop(ad);
1542 break;
1543 case ELEVATOR_INSERT_FRONT:
1544 list_add(&rq->queuelist, ad->dispatch);
1545 as_account_queued_request(ad, rq);
1546 as_antic_stop(ad);
1547 break;
1548 case ELEVATOR_INSERT_SORT:
1549 BUG_ON(!blk_fs_request(rq));
1550 as_add_request(ad, arq);
1551 break;
1552 default:
1553 BUG();
1554 return;
1555 }
1556} 1427}
1557 1428
1558/* 1429/*
@@ -1565,12 +1436,8 @@ static int as_queue_empty(request_queue_t *q)
1565{ 1436{
1566 struct as_data *ad = q->elevator->elevator_data; 1437 struct as_data *ad = q->elevator->elevator_data;
1567 1438
1568 if (!list_empty(&ad->fifo_list[REQ_ASYNC]) 1439 return list_empty(&ad->fifo_list[REQ_ASYNC])
1569 || !list_empty(&ad->fifo_list[REQ_SYNC]) 1440 && list_empty(&ad->fifo_list[REQ_SYNC]);
1570 || !list_empty(ad->dispatch))
1571 return 0;
1572
1573 return 1;
1574} 1441}
1575 1442
1576static struct request * 1443static struct request *
@@ -1608,15 +1475,6 @@ as_merge(request_queue_t *q, struct request **req, struct bio *bio)
1608 int ret; 1475 int ret;
1609 1476
1610 /* 1477 /*
1611 * try last_merge to avoid going to hash
1612 */
1613 ret = elv_try_last_merge(q, bio);
1614 if (ret != ELEVATOR_NO_MERGE) {
1615 __rq = q->last_merge;
1616 goto out_insert;
1617 }
1618
1619 /*
1620 * see if the merge hash can satisfy a back merge 1478 * see if the merge hash can satisfy a back merge
1621 */ 1479 */
1622 __rq = as_find_arq_hash(ad, bio->bi_sector); 1480 __rq = as_find_arq_hash(ad, bio->bi_sector);
@@ -1644,9 +1502,6 @@ as_merge(request_queue_t *q, struct request **req, struct bio *bio)
1644 1502
1645 return ELEVATOR_NO_MERGE; 1503 return ELEVATOR_NO_MERGE;
1646out: 1504out:
1647 if (rq_mergeable(__rq))
1648 q->last_merge = __rq;
1649out_insert:
1650 if (ret) { 1505 if (ret) {
1651 if (rq_mergeable(__rq)) 1506 if (rq_mergeable(__rq))
1652 as_hot_arq_hash(ad, RQ_DATA(__rq)); 1507 as_hot_arq_hash(ad, RQ_DATA(__rq));
@@ -1693,9 +1548,6 @@ static void as_merged_request(request_queue_t *q, struct request *req)
1693 * behind the disk head. We currently don't bother adjusting. 1548 * behind the disk head. We currently don't bother adjusting.
1694 */ 1549 */
1695 } 1550 }
1696
1697 if (arq->on_hash)
1698 q->last_merge = req;
1699} 1551}
1700 1552
1701static void 1553static void
@@ -1763,6 +1615,7 @@ as_merged_requests(request_queue_t *q, struct request *req,
1763 * kill knowledge of next, this one is a goner 1615 * kill knowledge of next, this one is a goner
1764 */ 1616 */
1765 as_remove_queued_request(q, next); 1617 as_remove_queued_request(q, next);
1618 as_put_io_context(anext);
1766 1619
1767 anext->state = AS_RQ_MERGED; 1620 anext->state = AS_RQ_MERGED;
1768} 1621}
@@ -1782,7 +1635,7 @@ static void as_work_handler(void *data)
1782 unsigned long flags; 1635 unsigned long flags;
1783 1636
1784 spin_lock_irqsave(q->queue_lock, flags); 1637 spin_lock_irqsave(q->queue_lock, flags);
1785 if (as_next_request(q)) 1638 if (!as_queue_empty(q))
1786 q->request_fn(q); 1639 q->request_fn(q);
1787 spin_unlock_irqrestore(q->queue_lock, flags); 1640 spin_unlock_irqrestore(q->queue_lock, flags);
1788} 1641}
@@ -1797,7 +1650,9 @@ static void as_put_request(request_queue_t *q, struct request *rq)
1797 return; 1650 return;
1798 } 1651 }
1799 1652
1800 if (arq->state != AS_RQ_POSTSCHED && arq->state != AS_RQ_PRESCHED) { 1653 if (unlikely(arq->state != AS_RQ_POSTSCHED &&
1654 arq->state != AS_RQ_PRESCHED &&
1655 arq->state != AS_RQ_MERGED)) {
1801 printk("arq->state %d\n", arq->state); 1656 printk("arq->state %d\n", arq->state);
1802 WARN_ON(1); 1657 WARN_ON(1);
1803 } 1658 }
@@ -1807,7 +1662,7 @@ static void as_put_request(request_queue_t *q, struct request *rq)
1807} 1662}
1808 1663
1809static int as_set_request(request_queue_t *q, struct request *rq, 1664static int as_set_request(request_queue_t *q, struct request *rq,
1810 struct bio *bio, int gfp_mask) 1665 struct bio *bio, gfp_t gfp_mask)
1811{ 1666{
1812 struct as_data *ad = q->elevator->elevator_data; 1667 struct as_data *ad = q->elevator->elevator_data;
1813 struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask); 1668 struct as_rq *arq = mempool_alloc(ad->arq_pool, gfp_mask);
@@ -1907,7 +1762,6 @@ static int as_init_queue(request_queue_t *q, elevator_t *e)
1907 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]); 1762 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]);
1908 ad->sort_list[REQ_SYNC] = RB_ROOT; 1763 ad->sort_list[REQ_SYNC] = RB_ROOT;
1909 ad->sort_list[REQ_ASYNC] = RB_ROOT; 1764 ad->sort_list[REQ_ASYNC] = RB_ROOT;
1910 ad->dispatch = &q->queue_head;
1911 ad->fifo_expire[REQ_SYNC] = default_read_expire; 1765 ad->fifo_expire[REQ_SYNC] = default_read_expire;
1912 ad->fifo_expire[REQ_ASYNC] = default_write_expire; 1766 ad->fifo_expire[REQ_ASYNC] = default_write_expire;
1913 ad->antic_expire = default_antic_expire; 1767 ad->antic_expire = default_antic_expire;
@@ -2072,10 +1926,9 @@ static struct elevator_type iosched_as = {
2072 .elevator_merge_fn = as_merge, 1926 .elevator_merge_fn = as_merge,
2073 .elevator_merged_fn = as_merged_request, 1927 .elevator_merged_fn = as_merged_request,
2074 .elevator_merge_req_fn = as_merged_requests, 1928 .elevator_merge_req_fn = as_merged_requests,
2075 .elevator_next_req_fn = as_next_request, 1929 .elevator_dispatch_fn = as_dispatch_request,
2076 .elevator_add_req_fn = as_insert_request, 1930 .elevator_add_req_fn = as_add_request,
2077 .elevator_remove_req_fn = as_remove_request, 1931 .elevator_activate_req_fn = as_activate_request,
2078 .elevator_requeue_req_fn = as_requeue_request,
2079 .elevator_deactivate_req_fn = as_deactivate_request, 1932 .elevator_deactivate_req_fn = as_deactivate_request,
2080 .elevator_queue_empty_fn = as_queue_empty, 1933 .elevator_queue_empty_fn = as_queue_empty,
2081 .elevator_completed_req_fn = as_completed_request, 1934 .elevator_completed_req_fn = as_completed_request,
diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c
index cd056e7e64ec..94690e4d41e0 100644
--- a/drivers/block/cfq-iosched.c
+++ b/drivers/block/cfq-iosched.c
@@ -84,7 +84,6 @@ static int cfq_max_depth = 2;
84 (node)->rb_left = NULL; \ 84 (node)->rb_left = NULL; \
85} while (0) 85} while (0)
86#define RB_CLEAR_ROOT(root) ((root)->rb_node = NULL) 86#define RB_CLEAR_ROOT(root) ((root)->rb_node = NULL)
87#define ON_RB(node) ((node)->rb_color != RB_NONE)
88#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node) 87#define rb_entry_crq(node) rb_entry((node), struct cfq_rq, rb_node)
89#define rq_rb_key(rq) (rq)->sector 88#define rq_rb_key(rq) (rq)->sector
90 89
@@ -271,10 +270,7 @@ CFQ_CFQQ_FNS(expired);
271#undef CFQ_CFQQ_FNS 270#undef CFQ_CFQQ_FNS
272 271
273enum cfq_rq_state_flags { 272enum cfq_rq_state_flags {
274 CFQ_CRQ_FLAG_in_flight = 0, 273 CFQ_CRQ_FLAG_is_sync = 0,
275 CFQ_CRQ_FLAG_in_driver,
276 CFQ_CRQ_FLAG_is_sync,
277 CFQ_CRQ_FLAG_requeued,
278}; 274};
279 275
280#define CFQ_CRQ_FNS(name) \ 276#define CFQ_CRQ_FNS(name) \
@@ -291,14 +287,11 @@ static inline int cfq_crq_##name(const struct cfq_rq *crq) \
291 return (crq->crq_flags & (1 << CFQ_CRQ_FLAG_##name)) != 0; \ 287 return (crq->crq_flags & (1 << CFQ_CRQ_FLAG_##name)) != 0; \
292} 288}
293 289
294CFQ_CRQ_FNS(in_flight);
295CFQ_CRQ_FNS(in_driver);
296CFQ_CRQ_FNS(is_sync); 290CFQ_CRQ_FNS(is_sync);
297CFQ_CRQ_FNS(requeued);
298#undef CFQ_CRQ_FNS 291#undef CFQ_CRQ_FNS
299 292
300static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short); 293static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short);
301static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *); 294static void cfq_dispatch_insert(request_queue_t *, struct cfq_rq *);
302static void cfq_put_cfqd(struct cfq_data *cfqd); 295static void cfq_put_cfqd(struct cfq_data *cfqd);
303 296
304#define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE) 297#define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE)
@@ -311,14 +304,6 @@ static inline void cfq_del_crq_hash(struct cfq_rq *crq)
311 hlist_del_init(&crq->hash); 304 hlist_del_init(&crq->hash);
312} 305}
313 306
314static void cfq_remove_merge_hints(request_queue_t *q, struct cfq_rq *crq)
315{
316 cfq_del_crq_hash(crq);
317
318 if (q->last_merge == crq->request)
319 q->last_merge = NULL;
320}
321
322static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq) 307static inline void cfq_add_crq_hash(struct cfq_data *cfqd, struct cfq_rq *crq)
323{ 308{
324 const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request)); 309 const int hash_idx = CFQ_MHASH_FN(rq_hash_key(crq->request));
@@ -347,18 +332,13 @@ static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset)
347 return NULL; 332 return NULL;
348} 333}
349 334
350static inline int cfq_pending_requests(struct cfq_data *cfqd)
351{
352 return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues;
353}
354
355/* 335/*
356 * scheduler run of queue, if there are requests pending and no one in the 336 * scheduler run of queue, if there are requests pending and no one in the
357 * driver that will restart queueing 337 * driver that will restart queueing
358 */ 338 */
359static inline void cfq_schedule_dispatch(struct cfq_data *cfqd) 339static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
360{ 340{
361 if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd)) 341 if (!cfqd->rq_in_driver && cfqd->busy_queues)
362 kblockd_schedule_work(&cfqd->unplug_work); 342 kblockd_schedule_work(&cfqd->unplug_work);
363} 343}
364 344
@@ -366,7 +346,7 @@ static int cfq_queue_empty(request_queue_t *q)
366{ 346{
367 struct cfq_data *cfqd = q->elevator->elevator_data; 347 struct cfq_data *cfqd = q->elevator->elevator_data;
368 348
369 return !cfq_pending_requests(cfqd); 349 return !cfqd->busy_queues;
370} 350}
371 351
372/* 352/*
@@ -386,11 +366,6 @@ cfq_choose_req(struct cfq_data *cfqd, struct cfq_rq *crq1, struct cfq_rq *crq2)
386 if (crq2 == NULL) 366 if (crq2 == NULL)
387 return crq1; 367 return crq1;
388 368
389 if (cfq_crq_requeued(crq1) && !cfq_crq_requeued(crq2))
390 return crq1;
391 else if (cfq_crq_requeued(crq2) && !cfq_crq_requeued(crq1))
392 return crq2;
393
394 if (cfq_crq_is_sync(crq1) && !cfq_crq_is_sync(crq2)) 369 if (cfq_crq_is_sync(crq1) && !cfq_crq_is_sync(crq2))
395 return crq1; 370 return crq1;
396 else if (cfq_crq_is_sync(crq2) && !cfq_crq_is_sync(crq1)) 371 else if (cfq_crq_is_sync(crq2) && !cfq_crq_is_sync(crq1))
@@ -461,10 +436,7 @@ cfq_find_next_crq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
461 struct cfq_rq *crq_next = NULL, *crq_prev = NULL; 436 struct cfq_rq *crq_next = NULL, *crq_prev = NULL;
462 struct rb_node *rbnext, *rbprev; 437 struct rb_node *rbnext, *rbprev;
463 438
464 rbnext = NULL; 439 if (!(rbnext = rb_next(&last->rb_node))) {
465 if (ON_RB(&last->rb_node))
466 rbnext = rb_next(&last->rb_node);
467 if (!rbnext) {
468 rbnext = rb_first(&cfqq->sort_list); 440 rbnext = rb_first(&cfqq->sort_list);
469 if (rbnext == &last->rb_node) 441 if (rbnext == &last->rb_node)
470 rbnext = NULL; 442 rbnext = NULL;
@@ -545,13 +517,13 @@ static void cfq_resort_rr_list(struct cfq_queue *cfqq, int preempted)
545 * the pending list according to last request service 517 * the pending list according to last request service
546 */ 518 */
547static inline void 519static inline void
548cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq, int requeue) 520cfq_add_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
549{ 521{
550 BUG_ON(cfq_cfqq_on_rr(cfqq)); 522 BUG_ON(cfq_cfqq_on_rr(cfqq));
551 cfq_mark_cfqq_on_rr(cfqq); 523 cfq_mark_cfqq_on_rr(cfqq);
552 cfqd->busy_queues++; 524 cfqd->busy_queues++;
553 525
554 cfq_resort_rr_list(cfqq, requeue); 526 cfq_resort_rr_list(cfqq, 0);
555} 527}
556 528
557static inline void 529static inline void
@@ -571,22 +543,19 @@ cfq_del_cfqq_rr(struct cfq_data *cfqd, struct cfq_queue *cfqq)
571static inline void cfq_del_crq_rb(struct cfq_rq *crq) 543static inline void cfq_del_crq_rb(struct cfq_rq *crq)
572{ 544{
573 struct cfq_queue *cfqq = crq->cfq_queue; 545 struct cfq_queue *cfqq = crq->cfq_queue;
546 struct cfq_data *cfqd = cfqq->cfqd;
547 const int sync = cfq_crq_is_sync(crq);
574 548
575 if (ON_RB(&crq->rb_node)) { 549 BUG_ON(!cfqq->queued[sync]);
576 struct cfq_data *cfqd = cfqq->cfqd; 550 cfqq->queued[sync]--;
577 const int sync = cfq_crq_is_sync(crq);
578 551
579 BUG_ON(!cfqq->queued[sync]); 552 cfq_update_next_crq(crq);
580 cfqq->queued[sync]--;
581 553
582 cfq_update_next_crq(crq); 554 rb_erase(&crq->rb_node, &cfqq->sort_list);
555 RB_CLEAR_COLOR(&crq->rb_node);
583 556
584 rb_erase(&crq->rb_node, &cfqq->sort_list); 557 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list))
585 RB_CLEAR_COLOR(&crq->rb_node); 558 cfq_del_cfqq_rr(cfqd, cfqq);
586
587 if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY(&cfqq->sort_list))
588 cfq_del_cfqq_rr(cfqd, cfqq);
589 }
590} 559}
591 560
592static struct cfq_rq * 561static struct cfq_rq *
@@ -627,12 +596,12 @@ static void cfq_add_crq_rb(struct cfq_rq *crq)
627 * if that happens, put the alias on the dispatch list 596 * if that happens, put the alias on the dispatch list
628 */ 597 */
629 while ((__alias = __cfq_add_crq_rb(crq)) != NULL) 598 while ((__alias = __cfq_add_crq_rb(crq)) != NULL)
630 cfq_dispatch_sort(cfqd->queue, __alias); 599 cfq_dispatch_insert(cfqd->queue, __alias);
631 600
632 rb_insert_color(&crq->rb_node, &cfqq->sort_list); 601 rb_insert_color(&crq->rb_node, &cfqq->sort_list);
633 602
634 if (!cfq_cfqq_on_rr(cfqq)) 603 if (!cfq_cfqq_on_rr(cfqq))
635 cfq_add_cfqq_rr(cfqd, cfqq, cfq_crq_requeued(crq)); 604 cfq_add_cfqq_rr(cfqd, cfqq);
636 605
637 /* 606 /*
638 * check if this request is a better next-serve candidate 607 * check if this request is a better next-serve candidate
@@ -643,10 +612,8 @@ static void cfq_add_crq_rb(struct cfq_rq *crq)
643static inline void 612static inline void
644cfq_reposition_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq) 613cfq_reposition_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq)
645{ 614{
646 if (ON_RB(&crq->rb_node)) { 615 rb_erase(&crq->rb_node, &cfqq->sort_list);
647 rb_erase(&crq->rb_node, &cfqq->sort_list); 616 cfqq->queued[cfq_crq_is_sync(crq)]--;
648 cfqq->queued[cfq_crq_is_sync(crq)]--;
649 }
650 617
651 cfq_add_crq_rb(crq); 618 cfq_add_crq_rb(crq);
652} 619}
@@ -676,49 +643,28 @@ out:
676 return NULL; 643 return NULL;
677} 644}
678 645
679static void cfq_deactivate_request(request_queue_t *q, struct request *rq) 646static void cfq_activate_request(request_queue_t *q, struct request *rq)
680{ 647{
681 struct cfq_data *cfqd = q->elevator->elevator_data; 648 struct cfq_data *cfqd = q->elevator->elevator_data;
682 struct cfq_rq *crq = RQ_DATA(rq);
683
684 if (crq) {
685 struct cfq_queue *cfqq = crq->cfq_queue;
686
687 if (cfq_crq_in_driver(crq)) {
688 cfq_clear_crq_in_driver(crq);
689 WARN_ON(!cfqd->rq_in_driver);
690 cfqd->rq_in_driver--;
691 }
692 if (cfq_crq_in_flight(crq)) {
693 const int sync = cfq_crq_is_sync(crq);
694 649
695 cfq_clear_crq_in_flight(crq); 650 cfqd->rq_in_driver++;
696 WARN_ON(!cfqq->on_dispatch[sync]);
697 cfqq->on_dispatch[sync]--;
698 }
699 cfq_mark_crq_requeued(crq);
700 }
701} 651}
702 652
703/* 653static void cfq_deactivate_request(request_queue_t *q, struct request *rq)
704 * make sure the service time gets corrected on reissue of this request
705 */
706static void cfq_requeue_request(request_queue_t *q, struct request *rq)
707{ 654{
708 cfq_deactivate_request(q, rq); 655 struct cfq_data *cfqd = q->elevator->elevator_data;
709 list_add(&rq->queuelist, &q->queue_head); 656
657 WARN_ON(!cfqd->rq_in_driver);
658 cfqd->rq_in_driver--;
710} 659}
711 660
712static void cfq_remove_request(request_queue_t *q, struct request *rq) 661static void cfq_remove_request(struct request *rq)
713{ 662{
714 struct cfq_rq *crq = RQ_DATA(rq); 663 struct cfq_rq *crq = RQ_DATA(rq);
715 664
716 if (crq) { 665 list_del_init(&rq->queuelist);
717 list_del_init(&rq->queuelist); 666 cfq_del_crq_rb(crq);
718 cfq_del_crq_rb(crq); 667 cfq_del_crq_hash(crq);
719 cfq_remove_merge_hints(q, crq);
720
721 }
722} 668}
723 669
724static int 670static int
@@ -728,12 +674,6 @@ cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
728 struct request *__rq; 674 struct request *__rq;
729 int ret; 675 int ret;
730 676
731 ret = elv_try_last_merge(q, bio);
732 if (ret != ELEVATOR_NO_MERGE) {
733 __rq = q->last_merge;
734 goto out_insert;
735 }
736
737 __rq = cfq_find_rq_hash(cfqd, bio->bi_sector); 677 __rq = cfq_find_rq_hash(cfqd, bio->bi_sector);
738 if (__rq && elv_rq_merge_ok(__rq, bio)) { 678 if (__rq && elv_rq_merge_ok(__rq, bio)) {
739 ret = ELEVATOR_BACK_MERGE; 679 ret = ELEVATOR_BACK_MERGE;
@@ -748,8 +688,6 @@ cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
748 688
749 return ELEVATOR_NO_MERGE; 689 return ELEVATOR_NO_MERGE;
750out: 690out:
751 q->last_merge = __rq;
752out_insert:
753 *req = __rq; 691 *req = __rq;
754 return ret; 692 return ret;
755} 693}
@@ -762,14 +700,12 @@ static void cfq_merged_request(request_queue_t *q, struct request *req)
762 cfq_del_crq_hash(crq); 700 cfq_del_crq_hash(crq);
763 cfq_add_crq_hash(cfqd, crq); 701 cfq_add_crq_hash(cfqd, crq);
764 702
765 if (ON_RB(&crq->rb_node) && (rq_rb_key(req) != crq->rb_key)) { 703 if (rq_rb_key(req) != crq->rb_key) {
766 struct cfq_queue *cfqq = crq->cfq_queue; 704 struct cfq_queue *cfqq = crq->cfq_queue;
767 705
768 cfq_update_next_crq(crq); 706 cfq_update_next_crq(crq);
769 cfq_reposition_crq_rb(cfqq, crq); 707 cfq_reposition_crq_rb(cfqq, crq);
770 } 708 }
771
772 q->last_merge = req;
773} 709}
774 710
775static void 711static void
@@ -785,7 +721,7 @@ cfq_merged_requests(request_queue_t *q, struct request *rq,
785 time_before(next->start_time, rq->start_time)) 721 time_before(next->start_time, rq->start_time))
786 list_move(&rq->queuelist, &next->queuelist); 722 list_move(&rq->queuelist, &next->queuelist);
787 723
788 cfq_remove_request(q, next); 724 cfq_remove_request(next);
789} 725}
790 726
791static inline void 727static inline void
@@ -992,53 +928,15 @@ static int cfq_arm_slice_timer(struct cfq_data *cfqd, struct cfq_queue *cfqq)
992 return 1; 928 return 1;
993} 929}
994 930
995/* 931static void cfq_dispatch_insert(request_queue_t *q, struct cfq_rq *crq)
996 * we dispatch cfqd->cfq_quantum requests in total from the rr_list queues,
997 * this function sector sorts the selected request to minimize seeks. we start
998 * at cfqd->last_sector, not 0.
999 */
1000static void cfq_dispatch_sort(request_queue_t *q, struct cfq_rq *crq)
1001{ 932{
1002 struct cfq_data *cfqd = q->elevator->elevator_data; 933 struct cfq_data *cfqd = q->elevator->elevator_data;
1003 struct cfq_queue *cfqq = crq->cfq_queue; 934 struct cfq_queue *cfqq = crq->cfq_queue;
1004 struct list_head *head = &q->queue_head, *entry = head;
1005 struct request *__rq;
1006 sector_t last;
1007
1008 list_del(&crq->request->queuelist);
1009
1010 last = cfqd->last_sector;
1011 list_for_each_entry_reverse(__rq, head, queuelist) {
1012 struct cfq_rq *__crq = RQ_DATA(__rq);
1013
1014 if (blk_barrier_rq(__rq))
1015 break;
1016 if (!blk_fs_request(__rq))
1017 break;
1018 if (cfq_crq_requeued(__crq))
1019 break;
1020
1021 if (__rq->sector <= crq->request->sector)
1022 break;
1023 if (__rq->sector > last && crq->request->sector < last) {
1024 last = crq->request->sector + crq->request->nr_sectors;
1025 break;
1026 }
1027 entry = &__rq->queuelist;
1028 }
1029
1030 cfqd->last_sector = last;
1031 935
1032 cfqq->next_crq = cfq_find_next_crq(cfqd, cfqq, crq); 936 cfqq->next_crq = cfq_find_next_crq(cfqd, cfqq, crq);
1033 937 cfq_remove_request(crq->request);
1034 cfq_del_crq_rb(crq);
1035 cfq_remove_merge_hints(q, crq);
1036
1037 cfq_mark_crq_in_flight(crq);
1038 cfq_clear_crq_requeued(crq);
1039
1040 cfqq->on_dispatch[cfq_crq_is_sync(crq)]++; 938 cfqq->on_dispatch[cfq_crq_is_sync(crq)]++;
1041 list_add_tail(&crq->request->queuelist, entry); 939 elv_dispatch_sort(q, crq->request);
1042} 940}
1043 941
1044/* 942/*
@@ -1159,7 +1057,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1159 /* 1057 /*
1160 * finally, insert request into driver dispatch list 1058 * finally, insert request into driver dispatch list
1161 */ 1059 */
1162 cfq_dispatch_sort(cfqd->queue, crq); 1060 cfq_dispatch_insert(cfqd->queue, crq);
1163 1061
1164 cfqd->dispatch_slice++; 1062 cfqd->dispatch_slice++;
1165 dispatched++; 1063 dispatched++;
@@ -1194,7 +1092,7 @@ __cfq_dispatch_requests(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1194} 1092}
1195 1093
1196static int 1094static int
1197cfq_dispatch_requests(request_queue_t *q, int max_dispatch, int force) 1095cfq_dispatch_requests(request_queue_t *q, int force)
1198{ 1096{
1199 struct cfq_data *cfqd = q->elevator->elevator_data; 1097 struct cfq_data *cfqd = q->elevator->elevator_data;
1200 struct cfq_queue *cfqq; 1098 struct cfq_queue *cfqq;
@@ -1204,12 +1102,25 @@ cfq_dispatch_requests(request_queue_t *q, int max_dispatch, int force)
1204 1102
1205 cfqq = cfq_select_queue(cfqd, force); 1103 cfqq = cfq_select_queue(cfqd, force);
1206 if (cfqq) { 1104 if (cfqq) {
1105 int max_dispatch;
1106
1107 /*
1108 * if idle window is disabled, allow queue buildup
1109 */
1110 if (!cfq_cfqq_idle_window(cfqq) &&
1111 cfqd->rq_in_driver >= cfqd->cfq_max_depth)
1112 return 0;
1113
1207 cfq_clear_cfqq_must_dispatch(cfqq); 1114 cfq_clear_cfqq_must_dispatch(cfqq);
1208 cfq_clear_cfqq_wait_request(cfqq); 1115 cfq_clear_cfqq_wait_request(cfqq);
1209 del_timer(&cfqd->idle_slice_timer); 1116 del_timer(&cfqd->idle_slice_timer);
1210 1117
1211 if (cfq_class_idle(cfqq)) 1118 if (!force) {
1212 max_dispatch = 1; 1119 max_dispatch = cfqd->cfq_quantum;
1120 if (cfq_class_idle(cfqq))
1121 max_dispatch = 1;
1122 } else
1123 max_dispatch = INT_MAX;
1213 1124
1214 return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch); 1125 return __cfq_dispatch_requests(cfqd, cfqq, max_dispatch);
1215 } 1126 }
@@ -1217,93 +1128,6 @@ cfq_dispatch_requests(request_queue_t *q, int max_dispatch, int force)
1217 return 0; 1128 return 0;
1218} 1129}
1219 1130
1220static inline void cfq_account_dispatch(struct cfq_rq *crq)
1221{
1222 struct cfq_queue *cfqq = crq->cfq_queue;
1223 struct cfq_data *cfqd = cfqq->cfqd;
1224
1225 if (unlikely(!blk_fs_request(crq->request)))
1226 return;
1227
1228 /*
1229 * accounted bit is necessary since some drivers will call
1230 * elv_next_request() many times for the same request (eg ide)
1231 */
1232 if (cfq_crq_in_driver(crq))
1233 return;
1234
1235 cfq_mark_crq_in_driver(crq);
1236 cfqd->rq_in_driver++;
1237}
1238
1239static inline void
1240cfq_account_completion(struct cfq_queue *cfqq, struct cfq_rq *crq)
1241{
1242 struct cfq_data *cfqd = cfqq->cfqd;
1243 unsigned long now;
1244
1245 if (!cfq_crq_in_driver(crq))
1246 return;
1247
1248 now = jiffies;
1249
1250 WARN_ON(!cfqd->rq_in_driver);
1251 cfqd->rq_in_driver--;
1252
1253 if (!cfq_class_idle(cfqq))
1254 cfqd->last_end_request = now;
1255
1256 if (!cfq_cfqq_dispatched(cfqq)) {
1257 if (cfq_cfqq_on_rr(cfqq)) {
1258 cfqq->service_last = now;
1259 cfq_resort_rr_list(cfqq, 0);
1260 }
1261 if (cfq_cfqq_expired(cfqq)) {
1262 __cfq_slice_expired(cfqd, cfqq, 0);
1263 cfq_schedule_dispatch(cfqd);
1264 }
1265 }
1266
1267 if (cfq_crq_is_sync(crq))
1268 crq->io_context->last_end_request = now;
1269}
1270
1271static struct request *cfq_next_request(request_queue_t *q)
1272{
1273 struct cfq_data *cfqd = q->elevator->elevator_data;
1274 struct request *rq;
1275
1276 if (!list_empty(&q->queue_head)) {
1277 struct cfq_rq *crq;
1278dispatch:
1279 rq = list_entry_rq(q->queue_head.next);
1280
1281 crq = RQ_DATA(rq);
1282 if (crq) {
1283 struct cfq_queue *cfqq = crq->cfq_queue;
1284
1285 /*
1286 * if idle window is disabled, allow queue buildup
1287 */
1288 if (!cfq_crq_in_driver(crq) &&
1289 !cfq_cfqq_idle_window(cfqq) &&
1290 !blk_barrier_rq(rq) &&
1291 cfqd->rq_in_driver >= cfqd->cfq_max_depth)
1292 return NULL;
1293
1294 cfq_remove_merge_hints(q, crq);
1295 cfq_account_dispatch(crq);
1296 }
1297
1298 return rq;
1299 }
1300
1301 if (cfq_dispatch_requests(q, cfqd->cfq_quantum, 0))
1302 goto dispatch;
1303
1304 return NULL;
1305}
1306
1307/* 1131/*
1308 * task holds one reference to the queue, dropped when task exits. each crq 1132 * task holds one reference to the queue, dropped when task exits. each crq
1309 * in-flight on this queue also holds a reference, dropped when crq is freed. 1133 * in-flight on this queue also holds a reference, dropped when crq is freed.
@@ -1422,7 +1246,7 @@ static void cfq_exit_io_context(struct cfq_io_context *cic)
1422} 1246}
1423 1247
1424static struct cfq_io_context * 1248static struct cfq_io_context *
1425cfq_alloc_io_context(struct cfq_data *cfqd, int gfp_mask) 1249cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
1426{ 1250{
1427 struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask); 1251 struct cfq_io_context *cic = kmem_cache_alloc(cfq_ioc_pool, gfp_mask);
1428 1252
@@ -1517,7 +1341,7 @@ static int cfq_ioc_set_ioprio(struct io_context *ioc, unsigned int ioprio)
1517 1341
1518static struct cfq_queue * 1342static struct cfq_queue *
1519cfq_get_queue(struct cfq_data *cfqd, unsigned int key, unsigned short ioprio, 1343cfq_get_queue(struct cfq_data *cfqd, unsigned int key, unsigned short ioprio,
1520 int gfp_mask) 1344 gfp_t gfp_mask)
1521{ 1345{
1522 const int hashval = hash_long(key, CFQ_QHASH_SHIFT); 1346 const int hashval = hash_long(key, CFQ_QHASH_SHIFT);
1523 struct cfq_queue *cfqq, *new_cfqq = NULL; 1347 struct cfq_queue *cfqq, *new_cfqq = NULL;
@@ -1578,7 +1402,7 @@ out:
1578 * cfqq, so we don't need to worry about it disappearing 1402 * cfqq, so we don't need to worry about it disappearing
1579 */ 1403 */
1580static struct cfq_io_context * 1404static struct cfq_io_context *
1581cfq_get_io_context(struct cfq_data *cfqd, pid_t pid, int gfp_mask) 1405cfq_get_io_context(struct cfq_data *cfqd, pid_t pid, gfp_t gfp_mask)
1582{ 1406{
1583 struct io_context *ioc = NULL; 1407 struct io_context *ioc = NULL;
1584 struct cfq_io_context *cic; 1408 struct cfq_io_context *cic;
@@ -1816,8 +1640,9 @@ cfq_crq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1816 } 1640 }
1817} 1641}
1818 1642
1819static void cfq_enqueue(struct cfq_data *cfqd, struct request *rq) 1643static void cfq_insert_request(request_queue_t *q, struct request *rq)
1820{ 1644{
1645 struct cfq_data *cfqd = q->elevator->elevator_data;
1821 struct cfq_rq *crq = RQ_DATA(rq); 1646 struct cfq_rq *crq = RQ_DATA(rq);
1822 struct cfq_queue *cfqq = crq->cfq_queue; 1647 struct cfq_queue *cfqq = crq->cfq_queue;
1823 1648
@@ -1827,66 +1652,43 @@ static void cfq_enqueue(struct cfq_data *cfqd, struct request *rq)
1827 1652
1828 list_add_tail(&rq->queuelist, &cfqq->fifo); 1653 list_add_tail(&rq->queuelist, &cfqq->fifo);
1829 1654
1830 if (rq_mergeable(rq)) { 1655 if (rq_mergeable(rq))
1831 cfq_add_crq_hash(cfqd, crq); 1656 cfq_add_crq_hash(cfqd, crq);
1832 1657
1833 if (!cfqd->queue->last_merge)
1834 cfqd->queue->last_merge = rq;
1835 }
1836
1837 cfq_crq_enqueued(cfqd, cfqq, crq); 1658 cfq_crq_enqueued(cfqd, cfqq, crq);
1838} 1659}
1839 1660
1840static void
1841cfq_insert_request(request_queue_t *q, struct request *rq, int where)
1842{
1843 struct cfq_data *cfqd = q->elevator->elevator_data;
1844
1845 switch (where) {
1846 case ELEVATOR_INSERT_BACK:
1847 while (cfq_dispatch_requests(q, INT_MAX, 1))
1848 ;
1849 list_add_tail(&rq->queuelist, &q->queue_head);
1850 /*
1851 * If we were idling with pending requests on
1852 * inactive cfqqs, force dispatching will
1853 * remove the idle timer and the queue won't
1854 * be kicked by __make_request() afterward.
1855 * Kick it here.
1856 */
1857 cfq_schedule_dispatch(cfqd);
1858 break;
1859 case ELEVATOR_INSERT_FRONT:
1860 list_add(&rq->queuelist, &q->queue_head);
1861 break;
1862 case ELEVATOR_INSERT_SORT:
1863 BUG_ON(!blk_fs_request(rq));
1864 cfq_enqueue(cfqd, rq);
1865 break;
1866 default:
1867 printk("%s: bad insert point %d\n", __FUNCTION__,where);
1868 return;
1869 }
1870}
1871
1872static void cfq_completed_request(request_queue_t *q, struct request *rq) 1661static void cfq_completed_request(request_queue_t *q, struct request *rq)
1873{ 1662{
1874 struct cfq_rq *crq = RQ_DATA(rq); 1663 struct cfq_rq *crq = RQ_DATA(rq);
1875 struct cfq_queue *cfqq; 1664 struct cfq_queue *cfqq = crq->cfq_queue;
1665 struct cfq_data *cfqd = cfqq->cfqd;
1666 const int sync = cfq_crq_is_sync(crq);
1667 unsigned long now;
1876 1668
1877 if (unlikely(!blk_fs_request(rq))) 1669 now = jiffies;
1878 return;
1879 1670
1880 cfqq = crq->cfq_queue; 1671 WARN_ON(!cfqd->rq_in_driver);
1672 WARN_ON(!cfqq->on_dispatch[sync]);
1673 cfqd->rq_in_driver--;
1674 cfqq->on_dispatch[sync]--;
1881 1675
1882 if (cfq_crq_in_flight(crq)) { 1676 if (!cfq_class_idle(cfqq))
1883 const int sync = cfq_crq_is_sync(crq); 1677 cfqd->last_end_request = now;
1884 1678
1885 WARN_ON(!cfqq->on_dispatch[sync]); 1679 if (!cfq_cfqq_dispatched(cfqq)) {
1886 cfqq->on_dispatch[sync]--; 1680 if (cfq_cfqq_on_rr(cfqq)) {
1681 cfqq->service_last = now;
1682 cfq_resort_rr_list(cfqq, 0);
1683 }
1684 if (cfq_cfqq_expired(cfqq)) {
1685 __cfq_slice_expired(cfqd, cfqq, 0);
1686 cfq_schedule_dispatch(cfqd);
1687 }
1887 } 1688 }
1888 1689
1889 cfq_account_completion(cfqq, crq); 1690 if (cfq_crq_is_sync(crq))
1691 crq->io_context->last_end_request = now;
1890} 1692}
1891 1693
1892static struct request * 1694static struct request *
@@ -2075,7 +1877,7 @@ static void cfq_put_request(request_queue_t *q, struct request *rq)
2075 */ 1877 */
2076static int 1878static int
2077cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio, 1879cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
2078 int gfp_mask) 1880 gfp_t gfp_mask)
2079{ 1881{
2080 struct cfq_data *cfqd = q->elevator->elevator_data; 1882 struct cfq_data *cfqd = q->elevator->elevator_data;
2081 struct task_struct *tsk = current; 1883 struct task_struct *tsk = current;
@@ -2118,9 +1920,6 @@ cfq_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
2118 INIT_HLIST_NODE(&crq->hash); 1920 INIT_HLIST_NODE(&crq->hash);
2119 crq->cfq_queue = cfqq; 1921 crq->cfq_queue = cfqq;
2120 crq->io_context = cic; 1922 crq->io_context = cic;
2121 cfq_clear_crq_in_flight(crq);
2122 cfq_clear_crq_in_driver(crq);
2123 cfq_clear_crq_requeued(crq);
2124 1923
2125 if (rw == READ || process_sync(tsk)) 1924 if (rw == READ || process_sync(tsk))
2126 cfq_mark_crq_is_sync(crq); 1925 cfq_mark_crq_is_sync(crq);
@@ -2201,7 +2000,7 @@ static void cfq_idle_slice_timer(unsigned long data)
2201 * only expire and reinvoke request handler, if there are 2000 * only expire and reinvoke request handler, if there are
2202 * other queues with pending requests 2001 * other queues with pending requests
2203 */ 2002 */
2204 if (!cfq_pending_requests(cfqd)) { 2003 if (!cfqd->busy_queues) {
2205 cfqd->idle_slice_timer.expires = min(now + cfqd->cfq_slice_idle, cfqq->slice_end); 2004 cfqd->idle_slice_timer.expires = min(now + cfqd->cfq_slice_idle, cfqq->slice_end);
2206 add_timer(&cfqd->idle_slice_timer); 2005 add_timer(&cfqd->idle_slice_timer);
2207 goto out_cont; 2006 goto out_cont;
@@ -2576,10 +2375,9 @@ static struct elevator_type iosched_cfq = {
2576 .elevator_merge_fn = cfq_merge, 2375 .elevator_merge_fn = cfq_merge,
2577 .elevator_merged_fn = cfq_merged_request, 2376 .elevator_merged_fn = cfq_merged_request,
2578 .elevator_merge_req_fn = cfq_merged_requests, 2377 .elevator_merge_req_fn = cfq_merged_requests,
2579 .elevator_next_req_fn = cfq_next_request, 2378 .elevator_dispatch_fn = cfq_dispatch_requests,
2580 .elevator_add_req_fn = cfq_insert_request, 2379 .elevator_add_req_fn = cfq_insert_request,
2581 .elevator_remove_req_fn = cfq_remove_request, 2380 .elevator_activate_req_fn = cfq_activate_request,
2582 .elevator_requeue_req_fn = cfq_requeue_request,
2583 .elevator_deactivate_req_fn = cfq_deactivate_request, 2381 .elevator_deactivate_req_fn = cfq_deactivate_request,
2584 .elevator_queue_empty_fn = cfq_queue_empty, 2382 .elevator_queue_empty_fn = cfq_queue_empty,
2585 .elevator_completed_req_fn = cfq_completed_request, 2383 .elevator_completed_req_fn = cfq_completed_request,
diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c
index 52a3ae5289a0..7929471d7df7 100644
--- a/drivers/block/deadline-iosched.c
+++ b/drivers/block/deadline-iosched.c
@@ -50,7 +50,6 @@ struct deadline_data {
50 * next in sort order. read, write or both are NULL 50 * next in sort order. read, write or both are NULL
51 */ 51 */
52 struct deadline_rq *next_drq[2]; 52 struct deadline_rq *next_drq[2];
53 struct list_head *dispatch; /* driver dispatch queue */
54 struct list_head *hash; /* request hash */ 53 struct list_head *hash; /* request hash */
55 unsigned int batching; /* number of sequential requests made */ 54 unsigned int batching; /* number of sequential requests made */
56 sector_t last_sector; /* head position */ 55 sector_t last_sector; /* head position */
@@ -113,15 +112,6 @@ static inline void deadline_del_drq_hash(struct deadline_rq *drq)
113 __deadline_del_drq_hash(drq); 112 __deadline_del_drq_hash(drq);
114} 113}
115 114
116static void
117deadline_remove_merge_hints(request_queue_t *q, struct deadline_rq *drq)
118{
119 deadline_del_drq_hash(drq);
120
121 if (q->last_merge == drq->request)
122 q->last_merge = NULL;
123}
124
125static inline void 115static inline void
126deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq) 116deadline_add_drq_hash(struct deadline_data *dd, struct deadline_rq *drq)
127{ 117{
@@ -239,10 +229,9 @@ deadline_del_drq_rb(struct deadline_data *dd, struct deadline_rq *drq)
239 dd->next_drq[data_dir] = rb_entry_drq(rbnext); 229 dd->next_drq[data_dir] = rb_entry_drq(rbnext);
240 } 230 }
241 231
242 if (ON_RB(&drq->rb_node)) { 232 BUG_ON(!ON_RB(&drq->rb_node));
243 rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq)); 233 rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq));
244 RB_CLEAR(&drq->rb_node); 234 RB_CLEAR(&drq->rb_node);
245 }
246} 235}
247 236
248static struct request * 237static struct request *
@@ -286,7 +275,7 @@ deadline_find_first_drq(struct deadline_data *dd, int data_dir)
286/* 275/*
287 * add drq to rbtree and fifo 276 * add drq to rbtree and fifo
288 */ 277 */
289static inline void 278static void
290deadline_add_request(struct request_queue *q, struct request *rq) 279deadline_add_request(struct request_queue *q, struct request *rq)
291{ 280{
292 struct deadline_data *dd = q->elevator->elevator_data; 281 struct deadline_data *dd = q->elevator->elevator_data;
@@ -301,12 +290,8 @@ deadline_add_request(struct request_queue *q, struct request *rq)
301 drq->expires = jiffies + dd->fifo_expire[data_dir]; 290 drq->expires = jiffies + dd->fifo_expire[data_dir];
302 list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]); 291 list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]);
303 292
304 if (rq_mergeable(rq)) { 293 if (rq_mergeable(rq))
305 deadline_add_drq_hash(dd, drq); 294 deadline_add_drq_hash(dd, drq);
306
307 if (!q->last_merge)
308 q->last_merge = rq;
309 }
310} 295}
311 296
312/* 297/*
@@ -315,14 +300,11 @@ deadline_add_request(struct request_queue *q, struct request *rq)
315static void deadline_remove_request(request_queue_t *q, struct request *rq) 300static void deadline_remove_request(request_queue_t *q, struct request *rq)
316{ 301{
317 struct deadline_rq *drq = RQ_DATA(rq); 302 struct deadline_rq *drq = RQ_DATA(rq);
303 struct deadline_data *dd = q->elevator->elevator_data;
318 304
319 if (drq) { 305 list_del_init(&drq->fifo);
320 struct deadline_data *dd = q->elevator->elevator_data; 306 deadline_del_drq_rb(dd, drq);
321 307 deadline_del_drq_hash(drq);
322 list_del_init(&drq->fifo);
323 deadline_remove_merge_hints(q, drq);
324 deadline_del_drq_rb(dd, drq);
325 }
326} 308}
327 309
328static int 310static int
@@ -333,15 +315,6 @@ deadline_merge(request_queue_t *q, struct request **req, struct bio *bio)
333 int ret; 315 int ret;
334 316
335 /* 317 /*
336 * try last_merge to avoid going to hash
337 */
338 ret = elv_try_last_merge(q, bio);
339 if (ret != ELEVATOR_NO_MERGE) {
340 __rq = q->last_merge;
341 goto out_insert;
342 }
343
344 /*
345 * see if the merge hash can satisfy a back merge 318 * see if the merge hash can satisfy a back merge
346 */ 319 */
347 __rq = deadline_find_drq_hash(dd, bio->bi_sector); 320 __rq = deadline_find_drq_hash(dd, bio->bi_sector);
@@ -373,8 +346,6 @@ deadline_merge(request_queue_t *q, struct request **req, struct bio *bio)
373 346
374 return ELEVATOR_NO_MERGE; 347 return ELEVATOR_NO_MERGE;
375out: 348out:
376 q->last_merge = __rq;
377out_insert:
378 if (ret) 349 if (ret)
379 deadline_hot_drq_hash(dd, RQ_DATA(__rq)); 350 deadline_hot_drq_hash(dd, RQ_DATA(__rq));
380 *req = __rq; 351 *req = __rq;
@@ -399,8 +370,6 @@ static void deadline_merged_request(request_queue_t *q, struct request *req)
399 deadline_del_drq_rb(dd, drq); 370 deadline_del_drq_rb(dd, drq);
400 deadline_add_drq_rb(dd, drq); 371 deadline_add_drq_rb(dd, drq);
401 } 372 }
402
403 q->last_merge = req;
404} 373}
405 374
406static void 375static void
@@ -452,7 +421,7 @@ deadline_move_to_dispatch(struct deadline_data *dd, struct deadline_rq *drq)
452 request_queue_t *q = drq->request->q; 421 request_queue_t *q = drq->request->q;
453 422
454 deadline_remove_request(q, drq->request); 423 deadline_remove_request(q, drq->request);
455 list_add_tail(&drq->request->queuelist, dd->dispatch); 424 elv_dispatch_add_tail(q, drq->request);
456} 425}
457 426
458/* 427/*
@@ -502,8 +471,9 @@ static inline int deadline_check_fifo(struct deadline_data *dd, int ddir)
502 * deadline_dispatch_requests selects the best request according to 471 * deadline_dispatch_requests selects the best request according to
503 * read/write expire, fifo_batch, etc 472 * read/write expire, fifo_batch, etc
504 */ 473 */
505static int deadline_dispatch_requests(struct deadline_data *dd) 474static int deadline_dispatch_requests(request_queue_t *q, int force)
506{ 475{
476 struct deadline_data *dd = q->elevator->elevator_data;
507 const int reads = !list_empty(&dd->fifo_list[READ]); 477 const int reads = !list_empty(&dd->fifo_list[READ]);
508 const int writes = !list_empty(&dd->fifo_list[WRITE]); 478 const int writes = !list_empty(&dd->fifo_list[WRITE]);
509 struct deadline_rq *drq; 479 struct deadline_rq *drq;
@@ -597,65 +567,12 @@ dispatch_request:
597 return 1; 567 return 1;
598} 568}
599 569
600static struct request *deadline_next_request(request_queue_t *q)
601{
602 struct deadline_data *dd = q->elevator->elevator_data;
603 struct request *rq;
604
605 /*
606 * if there are still requests on the dispatch queue, grab the first one
607 */
608 if (!list_empty(dd->dispatch)) {
609dispatch:
610 rq = list_entry_rq(dd->dispatch->next);
611 return rq;
612 }
613
614 if (deadline_dispatch_requests(dd))
615 goto dispatch;
616
617 return NULL;
618}
619
620static void
621deadline_insert_request(request_queue_t *q, struct request *rq, int where)
622{
623 struct deadline_data *dd = q->elevator->elevator_data;
624
625 /* barriers must flush the reorder queue */
626 if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)
627 && where == ELEVATOR_INSERT_SORT))
628 where = ELEVATOR_INSERT_BACK;
629
630 switch (where) {
631 case ELEVATOR_INSERT_BACK:
632 while (deadline_dispatch_requests(dd))
633 ;
634 list_add_tail(&rq->queuelist, dd->dispatch);
635 break;
636 case ELEVATOR_INSERT_FRONT:
637 list_add(&rq->queuelist, dd->dispatch);
638 break;
639 case ELEVATOR_INSERT_SORT:
640 BUG_ON(!blk_fs_request(rq));
641 deadline_add_request(q, rq);
642 break;
643 default:
644 printk("%s: bad insert point %d\n", __FUNCTION__,where);
645 return;
646 }
647}
648
649static int deadline_queue_empty(request_queue_t *q) 570static int deadline_queue_empty(request_queue_t *q)
650{ 571{
651 struct deadline_data *dd = q->elevator->elevator_data; 572 struct deadline_data *dd = q->elevator->elevator_data;
652 573
653 if (!list_empty(&dd->fifo_list[WRITE]) 574 return list_empty(&dd->fifo_list[WRITE])
654 || !list_empty(&dd->fifo_list[READ]) 575 && list_empty(&dd->fifo_list[READ]);
655 || !list_empty(dd->dispatch))
656 return 0;
657
658 return 1;
659} 576}
660 577
661static struct request * 578static struct request *
@@ -733,7 +650,6 @@ static int deadline_init_queue(request_queue_t *q, elevator_t *e)
733 INIT_LIST_HEAD(&dd->fifo_list[WRITE]); 650 INIT_LIST_HEAD(&dd->fifo_list[WRITE]);
734 dd->sort_list[READ] = RB_ROOT; 651 dd->sort_list[READ] = RB_ROOT;
735 dd->sort_list[WRITE] = RB_ROOT; 652 dd->sort_list[WRITE] = RB_ROOT;
736 dd->dispatch = &q->queue_head;
737 dd->fifo_expire[READ] = read_expire; 653 dd->fifo_expire[READ] = read_expire;
738 dd->fifo_expire[WRITE] = write_expire; 654 dd->fifo_expire[WRITE] = write_expire;
739 dd->writes_starved = writes_starved; 655 dd->writes_starved = writes_starved;
@@ -748,15 +664,13 @@ static void deadline_put_request(request_queue_t *q, struct request *rq)
748 struct deadline_data *dd = q->elevator->elevator_data; 664 struct deadline_data *dd = q->elevator->elevator_data;
749 struct deadline_rq *drq = RQ_DATA(rq); 665 struct deadline_rq *drq = RQ_DATA(rq);
750 666
751 if (drq) { 667 mempool_free(drq, dd->drq_pool);
752 mempool_free(drq, dd->drq_pool); 668 rq->elevator_private = NULL;
753 rq->elevator_private = NULL;
754 }
755} 669}
756 670
757static int 671static int
758deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio, 672deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
759 int gfp_mask) 673 gfp_t gfp_mask)
760{ 674{
761 struct deadline_data *dd = q->elevator->elevator_data; 675 struct deadline_data *dd = q->elevator->elevator_data;
762 struct deadline_rq *drq; 676 struct deadline_rq *drq;
@@ -917,9 +831,8 @@ static struct elevator_type iosched_deadline = {
917 .elevator_merge_fn = deadline_merge, 831 .elevator_merge_fn = deadline_merge,
918 .elevator_merged_fn = deadline_merged_request, 832 .elevator_merged_fn = deadline_merged_request,
919 .elevator_merge_req_fn = deadline_merged_requests, 833 .elevator_merge_req_fn = deadline_merged_requests,
920 .elevator_next_req_fn = deadline_next_request, 834 .elevator_dispatch_fn = deadline_dispatch_requests,
921 .elevator_add_req_fn = deadline_insert_request, 835 .elevator_add_req_fn = deadline_add_request,
922 .elevator_remove_req_fn = deadline_remove_request,
923 .elevator_queue_empty_fn = deadline_queue_empty, 836 .elevator_queue_empty_fn = deadline_queue_empty,
924 .elevator_former_req_fn = deadline_former_request, 837 .elevator_former_req_fn = deadline_former_request,
925 .elevator_latter_req_fn = deadline_latter_request, 838 .elevator_latter_req_fn = deadline_latter_request,
diff --git a/drivers/block/elevator.c b/drivers/block/elevator.c
index 98f0126a2deb..55621d5c5774 100644
--- a/drivers/block/elevator.c
+++ b/drivers/block/elevator.c
@@ -34,6 +34,7 @@
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/compiler.h> 36#include <linux/compiler.h>
37#include <linux/delay.h>
37 38
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39 40
@@ -83,21 +84,11 @@ inline int elv_try_merge(struct request *__rq, struct bio *bio)
83} 84}
84EXPORT_SYMBOL(elv_try_merge); 85EXPORT_SYMBOL(elv_try_merge);
85 86
86inline int elv_try_last_merge(request_queue_t *q, struct bio *bio)
87{
88 if (q->last_merge)
89 return elv_try_merge(q->last_merge, bio);
90
91 return ELEVATOR_NO_MERGE;
92}
93EXPORT_SYMBOL(elv_try_last_merge);
94
95static struct elevator_type *elevator_find(const char *name) 87static struct elevator_type *elevator_find(const char *name)
96{ 88{
97 struct elevator_type *e = NULL; 89 struct elevator_type *e = NULL;
98 struct list_head *entry; 90 struct list_head *entry;
99 91
100 spin_lock_irq(&elv_list_lock);
101 list_for_each(entry, &elv_list) { 92 list_for_each(entry, &elv_list) {
102 struct elevator_type *__e; 93 struct elevator_type *__e;
103 94
@@ -108,7 +99,6 @@ static struct elevator_type *elevator_find(const char *name)
108 break; 99 break;
109 } 100 }
110 } 101 }
111 spin_unlock_irq(&elv_list_lock);
112 102
113 return e; 103 return e;
114} 104}
@@ -120,12 +110,15 @@ static void elevator_put(struct elevator_type *e)
120 110
121static struct elevator_type *elevator_get(const char *name) 111static struct elevator_type *elevator_get(const char *name)
122{ 112{
123 struct elevator_type *e = elevator_find(name); 113 struct elevator_type *e;
124 114
125 if (!e) 115 spin_lock_irq(&elv_list_lock);
126 return NULL; 116
127 if (!try_module_get(e->elevator_owner)) 117 e = elevator_find(name);
128 return NULL; 118 if (e && !try_module_get(e->elevator_owner))
119 e = NULL;
120
121 spin_unlock_irq(&elv_list_lock);
129 122
130 return e; 123 return e;
131} 124}
@@ -139,8 +132,6 @@ static int elevator_attach(request_queue_t *q, struct elevator_type *e,
139 eq->ops = &e->ops; 132 eq->ops = &e->ops;
140 eq->elevator_type = e; 133 eq->elevator_type = e;
141 134
142 INIT_LIST_HEAD(&q->queue_head);
143 q->last_merge = NULL;
144 q->elevator = eq; 135 q->elevator = eq;
145 136
146 if (eq->ops->elevator_init_fn) 137 if (eq->ops->elevator_init_fn)
@@ -153,11 +144,15 @@ static char chosen_elevator[16];
153 144
154static void elevator_setup_default(void) 145static void elevator_setup_default(void)
155{ 146{
147 struct elevator_type *e;
148
156 /* 149 /*
157 * check if default is set and exists 150 * check if default is set and exists
158 */ 151 */
159 if (chosen_elevator[0] && elevator_find(chosen_elevator)) 152 if (chosen_elevator[0] && (e = elevator_get(chosen_elevator))) {
153 elevator_put(e);
160 return; 154 return;
155 }
161 156
162#if defined(CONFIG_IOSCHED_AS) 157#if defined(CONFIG_IOSCHED_AS)
163 strcpy(chosen_elevator, "anticipatory"); 158 strcpy(chosen_elevator, "anticipatory");
@@ -186,6 +181,11 @@ int elevator_init(request_queue_t *q, char *name)
186 struct elevator_queue *eq; 181 struct elevator_queue *eq;
187 int ret = 0; 182 int ret = 0;
188 183
184 INIT_LIST_HEAD(&q->queue_head);
185 q->last_merge = NULL;
186 q->end_sector = 0;
187 q->boundary_rq = NULL;
188
189 elevator_setup_default(); 189 elevator_setup_default();
190 190
191 if (!name) 191 if (!name)
@@ -220,9 +220,52 @@ void elevator_exit(elevator_t *e)
220 kfree(e); 220 kfree(e);
221} 221}
222 222
223/*
224 * Insert rq into dispatch queue of q. Queue lock must be held on
225 * entry. If sort != 0, rq is sort-inserted; otherwise, rq will be
226 * appended to the dispatch queue. To be used by specific elevators.
227 */
228void elv_dispatch_sort(request_queue_t *q, struct request *rq)
229{
230 sector_t boundary;
231 struct list_head *entry;
232
233 if (q->last_merge == rq)
234 q->last_merge = NULL;
235
236 boundary = q->end_sector;
237
238 list_for_each_prev(entry, &q->queue_head) {
239 struct request *pos = list_entry_rq(entry);
240
241 if (pos->flags & (REQ_SOFTBARRIER|REQ_HARDBARRIER|REQ_STARTED))
242 break;
243 if (rq->sector >= boundary) {
244 if (pos->sector < boundary)
245 continue;
246 } else {
247 if (pos->sector >= boundary)
248 break;
249 }
250 if (rq->sector >= pos->sector)
251 break;
252 }
253
254 list_add(&rq->queuelist, entry);
255}
256
223int elv_merge(request_queue_t *q, struct request **req, struct bio *bio) 257int elv_merge(request_queue_t *q, struct request **req, struct bio *bio)
224{ 258{
225 elevator_t *e = q->elevator; 259 elevator_t *e = q->elevator;
260 int ret;
261
262 if (q->last_merge) {
263 ret = elv_try_merge(q->last_merge, bio);
264 if (ret != ELEVATOR_NO_MERGE) {
265 *req = q->last_merge;
266 return ret;
267 }
268 }
226 269
227 if (e->ops->elevator_merge_fn) 270 if (e->ops->elevator_merge_fn)
228 return e->ops->elevator_merge_fn(q, req, bio); 271 return e->ops->elevator_merge_fn(q, req, bio);
@@ -236,6 +279,8 @@ void elv_merged_request(request_queue_t *q, struct request *rq)
236 279
237 if (e->ops->elevator_merged_fn) 280 if (e->ops->elevator_merged_fn)
238 e->ops->elevator_merged_fn(q, rq); 281 e->ops->elevator_merged_fn(q, rq);
282
283 q->last_merge = rq;
239} 284}
240 285
241void elv_merge_requests(request_queue_t *q, struct request *rq, 286void elv_merge_requests(request_queue_t *q, struct request *rq,
@@ -243,20 +288,13 @@ void elv_merge_requests(request_queue_t *q, struct request *rq,
243{ 288{
244 elevator_t *e = q->elevator; 289 elevator_t *e = q->elevator;
245 290
246 if (q->last_merge == next)
247 q->last_merge = NULL;
248
249 if (e->ops->elevator_merge_req_fn) 291 if (e->ops->elevator_merge_req_fn)
250 e->ops->elevator_merge_req_fn(q, rq, next); 292 e->ops->elevator_merge_req_fn(q, rq, next);
293
294 q->last_merge = rq;
251} 295}
252 296
253/* 297void elv_requeue_request(request_queue_t *q, struct request *rq)
254 * For careful internal use by the block layer. Essentially the same as
255 * a requeue in that it tells the io scheduler that this request is not
256 * active in the driver or hardware anymore, but we don't want the request
257 * added back to the scheduler. Function is not exported.
258 */
259void elv_deactivate_request(request_queue_t *q, struct request *rq)
260{ 298{
261 elevator_t *e = q->elevator; 299 elevator_t *e = q->elevator;
262 300
@@ -264,19 +302,14 @@ void elv_deactivate_request(request_queue_t *q, struct request *rq)
264 * it already went through dequeue, we need to decrement the 302 * it already went through dequeue, we need to decrement the
265 * in_flight count again 303 * in_flight count again
266 */ 304 */
267 if (blk_account_rq(rq)) 305 if (blk_account_rq(rq)) {
268 q->in_flight--; 306 q->in_flight--;
307 if (blk_sorted_rq(rq) && e->ops->elevator_deactivate_req_fn)
308 e->ops->elevator_deactivate_req_fn(q, rq);
309 }
269 310
270 rq->flags &= ~REQ_STARTED; 311 rq->flags &= ~REQ_STARTED;
271 312
272 if (e->ops->elevator_deactivate_req_fn)
273 e->ops->elevator_deactivate_req_fn(q, rq);
274}
275
276void elv_requeue_request(request_queue_t *q, struct request *rq)
277{
278 elv_deactivate_request(q, rq);
279
280 /* 313 /*
281 * if this is the flush, requeue the original instead and drop the flush 314 * if this is the flush, requeue the original instead and drop the flush
282 */ 315 */
@@ -285,31 +318,27 @@ void elv_requeue_request(request_queue_t *q, struct request *rq)
285 rq = rq->end_io_data; 318 rq = rq->end_io_data;
286 } 319 }
287 320
288 /* 321 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
289 * the request is prepped and may have some resources allocated.
290 * allowing unprepped requests to pass this one may cause resource
291 * deadlock. turn on softbarrier.
292 */
293 rq->flags |= REQ_SOFTBARRIER;
294
295 /*
296 * if iosched has an explicit requeue hook, then use that. otherwise
297 * just put the request at the front of the queue
298 */
299 if (q->elevator->ops->elevator_requeue_req_fn)
300 q->elevator->ops->elevator_requeue_req_fn(q, rq);
301 else
302 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0);
303} 322}
304 323
305void __elv_add_request(request_queue_t *q, struct request *rq, int where, 324void __elv_add_request(request_queue_t *q, struct request *rq, int where,
306 int plug) 325 int plug)
307{ 326{
308 /* 327 if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) {
309 * barriers implicitly indicate back insertion 328 /*
310 */ 329 * barriers implicitly indicate back insertion
311 if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) && 330 */
312 where == ELEVATOR_INSERT_SORT) 331 if (where == ELEVATOR_INSERT_SORT)
332 where = ELEVATOR_INSERT_BACK;
333
334 /*
335 * this request is scheduling boundary, update end_sector
336 */
337 if (blk_fs_request(rq)) {
338 q->end_sector = rq_end_sector(rq);
339 q->boundary_rq = rq;
340 }
341 } else if (!(rq->flags & REQ_ELVPRIV) && where == ELEVATOR_INSERT_SORT)
313 where = ELEVATOR_INSERT_BACK; 342 where = ELEVATOR_INSERT_BACK;
314 343
315 if (plug) 344 if (plug)
@@ -317,23 +346,54 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
317 346
318 rq->q = q; 347 rq->q = q;
319 348
320 if (!test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)) { 349 switch (where) {
321 q->elevator->ops->elevator_add_req_fn(q, rq, where); 350 case ELEVATOR_INSERT_FRONT:
351 rq->flags |= REQ_SOFTBARRIER;
322 352
323 if (blk_queue_plugged(q)) { 353 list_add(&rq->queuelist, &q->queue_head);
324 int nrq = q->rq.count[READ] + q->rq.count[WRITE] 354 break;
325 - q->in_flight;
326 355
327 if (nrq >= q->unplug_thresh) 356 case ELEVATOR_INSERT_BACK:
328 __generic_unplug_device(q); 357 rq->flags |= REQ_SOFTBARRIER;
329 } 358
330 } else 359 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
360 ;
361 list_add_tail(&rq->queuelist, &q->queue_head);
331 /* 362 /*
332 * if drain is set, store the request "locally". when the drain 363 * We kick the queue here for the following reasons.
333 * is finished, the requests will be handed ordered to the io 364 * - The elevator might have returned NULL previously
334 * scheduler 365 * to delay requests and returned them now. As the
366 * queue wasn't empty before this request, ll_rw_blk
367 * won't run the queue on return, resulting in hang.
368 * - Usually, back inserted requests won't be merged
369 * with anything. There's no point in delaying queue
370 * processing.
335 */ 371 */
336 list_add_tail(&rq->queuelist, &q->drain_list); 372 blk_remove_plug(q);
373 q->request_fn(q);
374 break;
375
376 case ELEVATOR_INSERT_SORT:
377 BUG_ON(!blk_fs_request(rq));
378 rq->flags |= REQ_SORTED;
379 q->elevator->ops->elevator_add_req_fn(q, rq);
380 if (q->last_merge == NULL && rq_mergeable(rq))
381 q->last_merge = rq;
382 break;
383
384 default:
385 printk(KERN_ERR "%s: bad insertion point %d\n",
386 __FUNCTION__, where);
387 BUG();
388 }
389
390 if (blk_queue_plugged(q)) {
391 int nrq = q->rq.count[READ] + q->rq.count[WRITE]
392 - q->in_flight;
393
394 if (nrq >= q->unplug_thresh)
395 __generic_unplug_device(q);
396 }
337} 397}
338 398
339void elv_add_request(request_queue_t *q, struct request *rq, int where, 399void elv_add_request(request_queue_t *q, struct request *rq, int where,
@@ -348,13 +408,19 @@ void elv_add_request(request_queue_t *q, struct request *rq, int where,
348 408
349static inline struct request *__elv_next_request(request_queue_t *q) 409static inline struct request *__elv_next_request(request_queue_t *q)
350{ 410{
351 struct request *rq = q->elevator->ops->elevator_next_req_fn(q); 411 struct request *rq;
412
413 if (unlikely(list_empty(&q->queue_head) &&
414 !q->elevator->ops->elevator_dispatch_fn(q, 0)))
415 return NULL;
416
417 rq = list_entry_rq(q->queue_head.next);
352 418
353 /* 419 /*
354 * if this is a barrier write and the device has to issue a 420 * if this is a barrier write and the device has to issue a
355 * flush sequence to support it, check how far we are 421 * flush sequence to support it, check how far we are
356 */ 422 */
357 if (rq && blk_fs_request(rq) && blk_barrier_rq(rq)) { 423 if (blk_fs_request(rq) && blk_barrier_rq(rq)) {
358 BUG_ON(q->ordered == QUEUE_ORDERED_NONE); 424 BUG_ON(q->ordered == QUEUE_ORDERED_NONE);
359 425
360 if (q->ordered == QUEUE_ORDERED_FLUSH && 426 if (q->ordered == QUEUE_ORDERED_FLUSH &&
@@ -371,15 +437,30 @@ struct request *elv_next_request(request_queue_t *q)
371 int ret; 437 int ret;
372 438
373 while ((rq = __elv_next_request(q)) != NULL) { 439 while ((rq = __elv_next_request(q)) != NULL) {
374 /* 440 if (!(rq->flags & REQ_STARTED)) {
375 * just mark as started even if we don't start it, a request 441 elevator_t *e = q->elevator;
376 * that has been delayed should not be passed by new incoming
377 * requests
378 */
379 rq->flags |= REQ_STARTED;
380 442
381 if (rq == q->last_merge) 443 /*
382 q->last_merge = NULL; 444 * This is the first time the device driver
445 * sees this request (possibly after
446 * requeueing). Notify IO scheduler.
447 */
448 if (blk_sorted_rq(rq) &&
449 e->ops->elevator_activate_req_fn)
450 e->ops->elevator_activate_req_fn(q, rq);
451
452 /*
453 * just mark as started even if we don't start
454 * it, a request that has been delayed should
455 * not be passed by new incoming requests
456 */
457 rq->flags |= REQ_STARTED;
458 }
459
460 if (!q->boundary_rq || q->boundary_rq == rq) {
461 q->end_sector = rq_end_sector(rq);
462 q->boundary_rq = NULL;
463 }
383 464
384 if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn) 465 if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn)
385 break; 466 break;
@@ -391,9 +472,9 @@ struct request *elv_next_request(request_queue_t *q)
391 /* 472 /*
392 * the request may have been (partially) prepped. 473 * the request may have been (partially) prepped.
393 * we need to keep this request in the front to 474 * we need to keep this request in the front to
394 * avoid resource deadlock. turn on softbarrier. 475 * avoid resource deadlock. REQ_STARTED will
476 * prevent other fs requests from passing this one.
395 */ 477 */
396 rq->flags |= REQ_SOFTBARRIER;
397 rq = NULL; 478 rq = NULL;
398 break; 479 break;
399 } else if (ret == BLKPREP_KILL) { 480 } else if (ret == BLKPREP_KILL) {
@@ -416,42 +497,32 @@ struct request *elv_next_request(request_queue_t *q)
416 return rq; 497 return rq;
417} 498}
418 499
419void elv_remove_request(request_queue_t *q, struct request *rq) 500void elv_dequeue_request(request_queue_t *q, struct request *rq)
420{ 501{
421 elevator_t *e = q->elevator; 502 BUG_ON(list_empty(&rq->queuelist));
503
504 list_del_init(&rq->queuelist);
422 505
423 /* 506 /*
424 * the time frame between a request being removed from the lists 507 * the time frame between a request being removed from the lists
425 * and to it is freed is accounted as io that is in progress at 508 * and to it is freed is accounted as io that is in progress at
426 * the driver side. note that we only account requests that the 509 * the driver side.
427 * driver has seen (REQ_STARTED set), to avoid false accounting
428 * for request-request merges
429 */ 510 */
430 if (blk_account_rq(rq)) 511 if (blk_account_rq(rq))
431 q->in_flight++; 512 q->in_flight++;
432
433 /*
434 * the main clearing point for q->last_merge is on retrieval of
435 * request by driver (it calls elv_next_request()), but it _can_
436 * also happen here if a request is added to the queue but later
437 * deleted without ever being given to driver (merged with another
438 * request).
439 */
440 if (rq == q->last_merge)
441 q->last_merge = NULL;
442
443 if (e->ops->elevator_remove_req_fn)
444 e->ops->elevator_remove_req_fn(q, rq);
445} 513}
446 514
447int elv_queue_empty(request_queue_t *q) 515int elv_queue_empty(request_queue_t *q)
448{ 516{
449 elevator_t *e = q->elevator; 517 elevator_t *e = q->elevator;
450 518
519 if (!list_empty(&q->queue_head))
520 return 0;
521
451 if (e->ops->elevator_queue_empty_fn) 522 if (e->ops->elevator_queue_empty_fn)
452 return e->ops->elevator_queue_empty_fn(q); 523 return e->ops->elevator_queue_empty_fn(q);
453 524
454 return list_empty(&q->queue_head); 525 return 1;
455} 526}
456 527
457struct request *elv_latter_request(request_queue_t *q, struct request *rq) 528struct request *elv_latter_request(request_queue_t *q, struct request *rq)
@@ -487,7 +558,7 @@ struct request *elv_former_request(request_queue_t *q, struct request *rq)
487} 558}
488 559
489int elv_set_request(request_queue_t *q, struct request *rq, struct bio *bio, 560int elv_set_request(request_queue_t *q, struct request *rq, struct bio *bio,
490 int gfp_mask) 561 gfp_t gfp_mask)
491{ 562{
492 elevator_t *e = q->elevator; 563 elevator_t *e = q->elevator;
493 564
@@ -523,11 +594,11 @@ void elv_completed_request(request_queue_t *q, struct request *rq)
523 /* 594 /*
524 * request is released from the driver, io must be done 595 * request is released from the driver, io must be done
525 */ 596 */
526 if (blk_account_rq(rq)) 597 if (blk_account_rq(rq)) {
527 q->in_flight--; 598 q->in_flight--;
528 599 if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn)
529 if (e->ops->elevator_completed_req_fn) 600 e->ops->elevator_completed_req_fn(q, rq);
530 e->ops->elevator_completed_req_fn(q, rq); 601 }
531} 602}
532 603
533int elv_register_queue(struct request_queue *q) 604int elv_register_queue(struct request_queue *q)
@@ -555,10 +626,9 @@ void elv_unregister_queue(struct request_queue *q)
555 626
556int elv_register(struct elevator_type *e) 627int elv_register(struct elevator_type *e)
557{ 628{
629 spin_lock_irq(&elv_list_lock);
558 if (elevator_find(e->elevator_name)) 630 if (elevator_find(e->elevator_name))
559 BUG(); 631 BUG();
560
561 spin_lock_irq(&elv_list_lock);
562 list_add_tail(&e->list, &elv_list); 632 list_add_tail(&e->list, &elv_list);
563 spin_unlock_irq(&elv_list_lock); 633 spin_unlock_irq(&elv_list_lock);
564 634
@@ -582,25 +652,36 @@ EXPORT_SYMBOL_GPL(elv_unregister);
582 * switch to new_e io scheduler. be careful not to introduce deadlocks - 652 * switch to new_e io scheduler. be careful not to introduce deadlocks -
583 * we don't free the old io scheduler, before we have allocated what we 653 * we don't free the old io scheduler, before we have allocated what we
584 * need for the new one. this way we have a chance of going back to the old 654 * need for the new one. this way we have a chance of going back to the old
585 * one, if the new one fails init for some reason. we also do an intermediate 655 * one, if the new one fails init for some reason.
586 * switch to noop to ensure safety with stack-allocated requests, since they
587 * don't originate from the block layer allocator. noop is safe here, because
588 * it never needs to touch the elevator itself for completion events. DRAIN
589 * flags will make sure we don't touch it for additions either.
590 */ 656 */
591static void elevator_switch(request_queue_t *q, struct elevator_type *new_e) 657static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
592{ 658{
593 elevator_t *e = kmalloc(sizeof(elevator_t), GFP_KERNEL); 659 elevator_t *old_elevator, *e;
594 struct elevator_type *noop_elevator = NULL;
595 elevator_t *old_elevator;
596 660
661 /*
662 * Allocate new elevator
663 */
664 e = kmalloc(sizeof(elevator_t), GFP_KERNEL);
597 if (!e) 665 if (!e)
598 goto error; 666 goto error;
599 667
600 /* 668 /*
601 * first step, drain requests from the block freelist 669 * Turn on BYPASS and drain all requests w/ elevator private data
602 */ 670 */
603 blk_wait_queue_drained(q, 0); 671 spin_lock_irq(q->queue_lock);
672
673 set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
674
675 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
676 ;
677
678 while (q->rq.elvpriv) {
679 spin_unlock_irq(q->queue_lock);
680 msleep(10);
681 spin_lock_irq(q->queue_lock);
682 }
683
684 spin_unlock_irq(q->queue_lock);
604 685
605 /* 686 /*
606 * unregister old elevator data 687 * unregister old elevator data
@@ -609,18 +690,6 @@ static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
609 old_elevator = q->elevator; 690 old_elevator = q->elevator;
610 691
611 /* 692 /*
612 * next step, switch to noop since it uses no private rq structures
613 * and doesn't allocate any memory for anything. then wait for any
614 * non-fs requests in-flight
615 */
616 noop_elevator = elevator_get("noop");
617 spin_lock_irq(q->queue_lock);
618 elevator_attach(q, noop_elevator, e);
619 spin_unlock_irq(q->queue_lock);
620
621 blk_wait_queue_drained(q, 1);
622
623 /*
624 * attach and start new elevator 693 * attach and start new elevator
625 */ 694 */
626 if (elevator_attach(q, new_e, e)) 695 if (elevator_attach(q, new_e, e))
@@ -630,11 +699,10 @@ static void elevator_switch(request_queue_t *q, struct elevator_type *new_e)
630 goto fail_register; 699 goto fail_register;
631 700
632 /* 701 /*
633 * finally exit old elevator and start queue again 702 * finally exit old elevator and turn off BYPASS.
634 */ 703 */
635 elevator_exit(old_elevator); 704 elevator_exit(old_elevator);
636 blk_finish_queue_drain(q); 705 clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
637 elevator_put(noop_elevator);
638 return; 706 return;
639 707
640fail_register: 708fail_register:
@@ -643,13 +711,13 @@ fail_register:
643 * one again (along with re-adding the sysfs dir) 711 * one again (along with re-adding the sysfs dir)
644 */ 712 */
645 elevator_exit(e); 713 elevator_exit(e);
714 e = NULL;
646fail: 715fail:
647 q->elevator = old_elevator; 716 q->elevator = old_elevator;
648 elv_register_queue(q); 717 elv_register_queue(q);
649 blk_finish_queue_drain(q); 718 clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
719 kfree(e);
650error: 720error:
651 if (noop_elevator)
652 elevator_put(noop_elevator);
653 elevator_put(new_e); 721 elevator_put(new_e);
654 printk(KERN_ERR "elevator: switch to %s failed\n",new_e->elevator_name); 722 printk(KERN_ERR "elevator: switch to %s failed\n",new_e->elevator_name);
655} 723}
@@ -701,11 +769,12 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
701 return len; 769 return len;
702} 770}
703 771
772EXPORT_SYMBOL(elv_dispatch_sort);
704EXPORT_SYMBOL(elv_add_request); 773EXPORT_SYMBOL(elv_add_request);
705EXPORT_SYMBOL(__elv_add_request); 774EXPORT_SYMBOL(__elv_add_request);
706EXPORT_SYMBOL(elv_requeue_request); 775EXPORT_SYMBOL(elv_requeue_request);
707EXPORT_SYMBOL(elv_next_request); 776EXPORT_SYMBOL(elv_next_request);
708EXPORT_SYMBOL(elv_remove_request); 777EXPORT_SYMBOL(elv_dequeue_request);
709EXPORT_SYMBOL(elv_queue_empty); 778EXPORT_SYMBOL(elv_queue_empty);
710EXPORT_SYMBOL(elv_completed_request); 779EXPORT_SYMBOL(elv_completed_request);
711EXPORT_SYMBOL(elevator_exit); 780EXPORT_SYMBOL(elevator_exit);
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index d42840cc0d1d..486ce1fdeb8c 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -337,10 +337,30 @@ static ssize_t disk_attr_show(struct kobject *kobj, struct attribute *attr,
337 return ret; 337 return ret;
338} 338}
339 339
340static ssize_t disk_attr_store(struct kobject * kobj, struct attribute * attr,
341 const char *page, size_t count)
342{
343 struct gendisk *disk = to_disk(kobj);
344 struct disk_attribute *disk_attr =
345 container_of(attr,struct disk_attribute,attr);
346 ssize_t ret = 0;
347
348 if (disk_attr->store)
349 ret = disk_attr->store(disk, page, count);
350 return ret;
351}
352
340static struct sysfs_ops disk_sysfs_ops = { 353static struct sysfs_ops disk_sysfs_ops = {
341 .show = &disk_attr_show, 354 .show = &disk_attr_show,
355 .store = &disk_attr_store,
342}; 356};
343 357
358static ssize_t disk_uevent_store(struct gendisk * disk,
359 const char *buf, size_t count)
360{
361 kobject_hotplug(&disk->kobj, KOBJ_ADD);
362 return count;
363}
344static ssize_t disk_dev_read(struct gendisk * disk, char *page) 364static ssize_t disk_dev_read(struct gendisk * disk, char *page)
345{ 365{
346 dev_t base = MKDEV(disk->major, disk->first_minor); 366 dev_t base = MKDEV(disk->major, disk->first_minor);
@@ -382,6 +402,10 @@ static ssize_t disk_stats_read(struct gendisk * disk, char *page)
382 jiffies_to_msecs(disk_stat_read(disk, io_ticks)), 402 jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
383 jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); 403 jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
384} 404}
405static struct disk_attribute disk_attr_uevent = {
406 .attr = {.name = "uevent", .mode = S_IWUSR },
407 .store = disk_uevent_store
408};
385static struct disk_attribute disk_attr_dev = { 409static struct disk_attribute disk_attr_dev = {
386 .attr = {.name = "dev", .mode = S_IRUGO }, 410 .attr = {.name = "dev", .mode = S_IRUGO },
387 .show = disk_dev_read 411 .show = disk_dev_read
@@ -404,6 +428,7 @@ static struct disk_attribute disk_attr_stat = {
404}; 428};
405 429
406static struct attribute * default_attrs[] = { 430static struct attribute * default_attrs[] = {
431 &disk_attr_uevent.attr,
407 &disk_attr_dev.attr, 432 &disk_attr_dev.attr,
408 &disk_attr_range.attr, 433 &disk_attr_range.attr,
409 &disk_attr_removable.attr, 434 &disk_attr_removable.attr,
diff --git a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c
index baedac522945..0af73512b9a8 100644
--- a/drivers/block/ll_rw_blk.c
+++ b/drivers/block/ll_rw_blk.c
@@ -263,8 +263,6 @@ void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn)
263 blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); 263 blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH);
264 264
265 blk_queue_activity_fn(q, NULL, NULL); 265 blk_queue_activity_fn(q, NULL, NULL);
266
267 INIT_LIST_HEAD(&q->drain_list);
268} 266}
269 267
270EXPORT_SYMBOL(blk_queue_make_request); 268EXPORT_SYMBOL(blk_queue_make_request);
@@ -353,6 +351,8 @@ static void blk_pre_flush_end_io(struct request *flush_rq)
353 struct request *rq = flush_rq->end_io_data; 351 struct request *rq = flush_rq->end_io_data;
354 request_queue_t *q = rq->q; 352 request_queue_t *q = rq->q;
355 353
354 elv_completed_request(q, flush_rq);
355
356 rq->flags |= REQ_BAR_PREFLUSH; 356 rq->flags |= REQ_BAR_PREFLUSH;
357 357
358 if (!flush_rq->errors) 358 if (!flush_rq->errors)
@@ -369,6 +369,8 @@ static void blk_post_flush_end_io(struct request *flush_rq)
369 struct request *rq = flush_rq->end_io_data; 369 struct request *rq = flush_rq->end_io_data;
370 request_queue_t *q = rq->q; 370 request_queue_t *q = rq->q;
371 371
372 elv_completed_request(q, flush_rq);
373
372 rq->flags |= REQ_BAR_POSTFLUSH; 374 rq->flags |= REQ_BAR_POSTFLUSH;
373 375
374 q->end_flush_fn(q, flush_rq); 376 q->end_flush_fn(q, flush_rq);
@@ -408,8 +410,6 @@ struct request *blk_start_pre_flush(request_queue_t *q, struct request *rq)
408 if (!list_empty(&rq->queuelist)) 410 if (!list_empty(&rq->queuelist))
409 blkdev_dequeue_request(rq); 411 blkdev_dequeue_request(rq);
410 412
411 elv_deactivate_request(q, rq);
412
413 flush_rq->end_io_data = rq; 413 flush_rq->end_io_data = rq;
414 flush_rq->end_io = blk_pre_flush_end_io; 414 flush_rq->end_io = blk_pre_flush_end_io;
415 415
@@ -1040,6 +1040,7 @@ EXPORT_SYMBOL(blk_queue_invalidate_tags);
1040static char *rq_flags[] = { 1040static char *rq_flags[] = {
1041 "REQ_RW", 1041 "REQ_RW",
1042 "REQ_FAILFAST", 1042 "REQ_FAILFAST",
1043 "REQ_SORTED",
1043 "REQ_SOFTBARRIER", 1044 "REQ_SOFTBARRIER",
1044 "REQ_HARDBARRIER", 1045 "REQ_HARDBARRIER",
1045 "REQ_CMD", 1046 "REQ_CMD",
@@ -1047,6 +1048,7 @@ static char *rq_flags[] = {
1047 "REQ_STARTED", 1048 "REQ_STARTED",
1048 "REQ_DONTPREP", 1049 "REQ_DONTPREP",
1049 "REQ_QUEUED", 1050 "REQ_QUEUED",
1051 "REQ_ELVPRIV",
1050 "REQ_PC", 1052 "REQ_PC",
1051 "REQ_BLOCK_PC", 1053 "REQ_BLOCK_PC",
1052 "REQ_SENSE", 1054 "REQ_SENSE",
@@ -1637,9 +1639,9 @@ static int blk_init_free_list(request_queue_t *q)
1637 1639
1638 rl->count[READ] = rl->count[WRITE] = 0; 1640 rl->count[READ] = rl->count[WRITE] = 0;
1639 rl->starved[READ] = rl->starved[WRITE] = 0; 1641 rl->starved[READ] = rl->starved[WRITE] = 0;
1642 rl->elvpriv = 0;
1640 init_waitqueue_head(&rl->wait[READ]); 1643 init_waitqueue_head(&rl->wait[READ]);
1641 init_waitqueue_head(&rl->wait[WRITE]); 1644 init_waitqueue_head(&rl->wait[WRITE]);
1642 init_waitqueue_head(&rl->drain);
1643 1645
1644 rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab, 1646 rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
1645 mempool_free_slab, request_cachep, q->node); 1647 mempool_free_slab, request_cachep, q->node);
@@ -1652,13 +1654,13 @@ static int blk_init_free_list(request_queue_t *q)
1652 1654
1653static int __make_request(request_queue_t *, struct bio *); 1655static int __make_request(request_queue_t *, struct bio *);
1654 1656
1655request_queue_t *blk_alloc_queue(int gfp_mask) 1657request_queue_t *blk_alloc_queue(gfp_t gfp_mask)
1656{ 1658{
1657 return blk_alloc_queue_node(gfp_mask, -1); 1659 return blk_alloc_queue_node(gfp_mask, -1);
1658} 1660}
1659EXPORT_SYMBOL(blk_alloc_queue); 1661EXPORT_SYMBOL(blk_alloc_queue);
1660 1662
1661request_queue_t *blk_alloc_queue_node(int gfp_mask, int node_id) 1663request_queue_t *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
1662{ 1664{
1663 request_queue_t *q; 1665 request_queue_t *q;
1664 1666
@@ -1782,12 +1784,14 @@ EXPORT_SYMBOL(blk_get_queue);
1782 1784
1783static inline void blk_free_request(request_queue_t *q, struct request *rq) 1785static inline void blk_free_request(request_queue_t *q, struct request *rq)
1784{ 1786{
1785 elv_put_request(q, rq); 1787 if (rq->flags & REQ_ELVPRIV)
1788 elv_put_request(q, rq);
1786 mempool_free(rq, q->rq.rq_pool); 1789 mempool_free(rq, q->rq.rq_pool);
1787} 1790}
1788 1791
1789static inline struct request * 1792static inline struct request *
1790blk_alloc_request(request_queue_t *q, int rw, struct bio *bio, int gfp_mask) 1793blk_alloc_request(request_queue_t *q, int rw, struct bio *bio,
1794 int priv, gfp_t gfp_mask)
1791{ 1795{
1792 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask); 1796 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask);
1793 1797
@@ -1800,11 +1804,15 @@ blk_alloc_request(request_queue_t *q, int rw, struct bio *bio, int gfp_mask)
1800 */ 1804 */
1801 rq->flags = rw; 1805 rq->flags = rw;
1802 1806
1803 if (!elv_set_request(q, rq, bio, gfp_mask)) 1807 if (priv) {
1804 return rq; 1808 if (unlikely(elv_set_request(q, rq, bio, gfp_mask))) {
1809 mempool_free(rq, q->rq.rq_pool);
1810 return NULL;
1811 }
1812 rq->flags |= REQ_ELVPRIV;
1813 }
1805 1814
1806 mempool_free(rq, q->rq.rq_pool); 1815 return rq;
1807 return NULL;
1808} 1816}
1809 1817
1810/* 1818/*
@@ -1860,22 +1868,18 @@ static void __freed_request(request_queue_t *q, int rw)
1860 * A request has just been released. Account for it, update the full and 1868 * A request has just been released. Account for it, update the full and
1861 * congestion status, wake up any waiters. Called under q->queue_lock. 1869 * congestion status, wake up any waiters. Called under q->queue_lock.
1862 */ 1870 */
1863static void freed_request(request_queue_t *q, int rw) 1871static void freed_request(request_queue_t *q, int rw, int priv)
1864{ 1872{
1865 struct request_list *rl = &q->rq; 1873 struct request_list *rl = &q->rq;
1866 1874
1867 rl->count[rw]--; 1875 rl->count[rw]--;
1876 if (priv)
1877 rl->elvpriv--;
1868 1878
1869 __freed_request(q, rw); 1879 __freed_request(q, rw);
1870 1880
1871 if (unlikely(rl->starved[rw ^ 1])) 1881 if (unlikely(rl->starved[rw ^ 1]))
1872 __freed_request(q, rw ^ 1); 1882 __freed_request(q, rw ^ 1);
1873
1874 if (!rl->count[READ] && !rl->count[WRITE]) {
1875 smp_mb();
1876 if (unlikely(waitqueue_active(&rl->drain)))
1877 wake_up(&rl->drain);
1878 }
1879} 1883}
1880 1884
1881#define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist) 1885#define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
@@ -1885,14 +1889,12 @@ static void freed_request(request_queue_t *q, int rw)
1885 * Returns !NULL on success, with queue_lock *not held*. 1889 * Returns !NULL on success, with queue_lock *not held*.
1886 */ 1890 */
1887static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, 1891static struct request *get_request(request_queue_t *q, int rw, struct bio *bio,
1888 int gfp_mask) 1892 gfp_t gfp_mask)
1889{ 1893{
1890 struct request *rq = NULL; 1894 struct request *rq = NULL;
1891 struct request_list *rl = &q->rq; 1895 struct request_list *rl = &q->rq;
1892 struct io_context *ioc = current_io_context(GFP_ATOMIC); 1896 struct io_context *ioc = current_io_context(GFP_ATOMIC);
1893 1897 int priv;
1894 if (unlikely(test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)))
1895 goto out;
1896 1898
1897 if (rl->count[rw]+1 >= q->nr_requests) { 1899 if (rl->count[rw]+1 >= q->nr_requests) {
1898 /* 1900 /*
@@ -1937,9 +1939,14 @@ get_rq:
1937 rl->starved[rw] = 0; 1939 rl->starved[rw] = 0;
1938 if (rl->count[rw] >= queue_congestion_on_threshold(q)) 1940 if (rl->count[rw] >= queue_congestion_on_threshold(q))
1939 set_queue_congested(q, rw); 1941 set_queue_congested(q, rw);
1942
1943 priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
1944 if (priv)
1945 rl->elvpriv++;
1946
1940 spin_unlock_irq(q->queue_lock); 1947 spin_unlock_irq(q->queue_lock);
1941 1948
1942 rq = blk_alloc_request(q, rw, bio, gfp_mask); 1949 rq = blk_alloc_request(q, rw, bio, priv, gfp_mask);
1943 if (!rq) { 1950 if (!rq) {
1944 /* 1951 /*
1945 * Allocation failed presumably due to memory. Undo anything 1952 * Allocation failed presumably due to memory. Undo anything
@@ -1949,7 +1956,7 @@ get_rq:
1949 * wait queue, but this is pretty rare. 1956 * wait queue, but this is pretty rare.
1950 */ 1957 */
1951 spin_lock_irq(q->queue_lock); 1958 spin_lock_irq(q->queue_lock);
1952 freed_request(q, rw); 1959 freed_request(q, rw, priv);
1953 1960
1954 /* 1961 /*
1955 * in the very unlikely event that allocation failed and no 1962 * in the very unlikely event that allocation failed and no
@@ -2019,7 +2026,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw,
2019 return rq; 2026 return rq;
2020} 2027}
2021 2028
2022struct request *blk_get_request(request_queue_t *q, int rw, int gfp_mask) 2029struct request *blk_get_request(request_queue_t *q, int rw, gfp_t gfp_mask)
2023{ 2030{
2024 struct request *rq; 2031 struct request *rq;
2025 2032
@@ -2251,7 +2258,7 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
2251 * @gfp_mask: memory allocation flags 2258 * @gfp_mask: memory allocation flags
2252 */ 2259 */
2253int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, 2260int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf,
2254 unsigned int len, unsigned int gfp_mask) 2261 unsigned int len, gfp_t gfp_mask)
2255{ 2262{
2256 struct bio *bio; 2263 struct bio *bio;
2257 2264
@@ -2433,13 +2440,15 @@ void disk_round_stats(struct gendisk *disk)
2433{ 2440{
2434 unsigned long now = jiffies; 2441 unsigned long now = jiffies;
2435 2442
2436 __disk_stat_add(disk, time_in_queue, 2443 if (now == disk->stamp)
2437 disk->in_flight * (now - disk->stamp)); 2444 return;
2438 disk->stamp = now;
2439 2445
2440 if (disk->in_flight) 2446 if (disk->in_flight) {
2441 __disk_stat_add(disk, io_ticks, (now - disk->stamp_idle)); 2447 __disk_stat_add(disk, time_in_queue,
2442 disk->stamp_idle = now; 2448 disk->in_flight * (now - disk->stamp));
2449 __disk_stat_add(disk, io_ticks, (now - disk->stamp));
2450 }
2451 disk->stamp = now;
2443} 2452}
2444 2453
2445/* 2454/*
@@ -2454,6 +2463,8 @@ static void __blk_put_request(request_queue_t *q, struct request *req)
2454 if (unlikely(--req->ref_count)) 2463 if (unlikely(--req->ref_count))
2455 return; 2464 return;
2456 2465
2466 elv_completed_request(q, req);
2467
2457 req->rq_status = RQ_INACTIVE; 2468 req->rq_status = RQ_INACTIVE;
2458 req->rl = NULL; 2469 req->rl = NULL;
2459 2470
@@ -2463,26 +2474,25 @@ static void __blk_put_request(request_queue_t *q, struct request *req)
2463 */ 2474 */
2464 if (rl) { 2475 if (rl) {
2465 int rw = rq_data_dir(req); 2476 int rw = rq_data_dir(req);
2466 2477 int priv = req->flags & REQ_ELVPRIV;
2467 elv_completed_request(q, req);
2468 2478
2469 BUG_ON(!list_empty(&req->queuelist)); 2479 BUG_ON(!list_empty(&req->queuelist));
2470 2480
2471 blk_free_request(q, req); 2481 blk_free_request(q, req);
2472 freed_request(q, rw); 2482 freed_request(q, rw, priv);
2473 } 2483 }
2474} 2484}
2475 2485
2476void blk_put_request(struct request *req) 2486void blk_put_request(struct request *req)
2477{ 2487{
2488 unsigned long flags;
2489 request_queue_t *q = req->q;
2490
2478 /* 2491 /*
2479 * if req->rl isn't set, this request didnt originate from the 2492 * Gee, IDE calls in w/ NULL q. Fix IDE and remove the
2480 * block layer, so it's safe to just disregard it 2493 * following if (q) test.
2481 */ 2494 */
2482 if (req->rl) { 2495 if (q) {
2483 unsigned long flags;
2484 request_queue_t *q = req->q;
2485
2486 spin_lock_irqsave(q->queue_lock, flags); 2496 spin_lock_irqsave(q->queue_lock, flags);
2487 __blk_put_request(q, req); 2497 __blk_put_request(q, req);
2488 spin_unlock_irqrestore(q->queue_lock, flags); 2498 spin_unlock_irqrestore(q->queue_lock, flags);
@@ -2797,97 +2807,6 @@ static inline void blk_partition_remap(struct bio *bio)
2797 } 2807 }
2798} 2808}
2799 2809
2800void blk_finish_queue_drain(request_queue_t *q)
2801{
2802 struct request_list *rl = &q->rq;
2803 struct request *rq;
2804 int requeued = 0;
2805
2806 spin_lock_irq(q->queue_lock);
2807 clear_bit(QUEUE_FLAG_DRAIN, &q->queue_flags);
2808
2809 while (!list_empty(&q->drain_list)) {
2810 rq = list_entry_rq(q->drain_list.next);
2811
2812 list_del_init(&rq->queuelist);
2813 elv_requeue_request(q, rq);
2814 requeued++;
2815 }
2816
2817 if (requeued)
2818 q->request_fn(q);
2819
2820 spin_unlock_irq(q->queue_lock);
2821
2822 wake_up(&rl->wait[0]);
2823 wake_up(&rl->wait[1]);
2824 wake_up(&rl->drain);
2825}
2826
2827static int wait_drain(request_queue_t *q, struct request_list *rl, int dispatch)
2828{
2829 int wait = rl->count[READ] + rl->count[WRITE];
2830
2831 if (dispatch)
2832 wait += !list_empty(&q->queue_head);
2833
2834 return wait;
2835}
2836
2837/*
2838 * We rely on the fact that only requests allocated through blk_alloc_request()
2839 * have io scheduler private data structures associated with them. Any other
2840 * type of request (allocated on stack or through kmalloc()) should not go
2841 * to the io scheduler core, but be attached to the queue head instead.
2842 */
2843void blk_wait_queue_drained(request_queue_t *q, int wait_dispatch)
2844{
2845 struct request_list *rl = &q->rq;
2846 DEFINE_WAIT(wait);
2847
2848 spin_lock_irq(q->queue_lock);
2849 set_bit(QUEUE_FLAG_DRAIN, &q->queue_flags);
2850
2851 while (wait_drain(q, rl, wait_dispatch)) {
2852 prepare_to_wait(&rl->drain, &wait, TASK_UNINTERRUPTIBLE);
2853
2854 if (wait_drain(q, rl, wait_dispatch)) {
2855 __generic_unplug_device(q);
2856 spin_unlock_irq(q->queue_lock);
2857 io_schedule();
2858 spin_lock_irq(q->queue_lock);
2859 }
2860
2861 finish_wait(&rl->drain, &wait);
2862 }
2863
2864 spin_unlock_irq(q->queue_lock);
2865}
2866
2867/*
2868 * block waiting for the io scheduler being started again.
2869 */
2870static inline void block_wait_queue_running(request_queue_t *q)
2871{
2872 DEFINE_WAIT(wait);
2873
2874 while (unlikely(test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags))) {
2875 struct request_list *rl = &q->rq;
2876
2877 prepare_to_wait_exclusive(&rl->drain, &wait,
2878 TASK_UNINTERRUPTIBLE);
2879
2880 /*
2881 * re-check the condition. avoids using prepare_to_wait()
2882 * in the fast path (queue is running)
2883 */
2884 if (test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags))
2885 io_schedule();
2886
2887 finish_wait(&rl->drain, &wait);
2888 }
2889}
2890
2891static void handle_bad_sector(struct bio *bio) 2810static void handle_bad_sector(struct bio *bio)
2892{ 2811{
2893 char b[BDEVNAME_SIZE]; 2812 char b[BDEVNAME_SIZE];
@@ -2983,8 +2902,6 @@ end_io:
2983 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) 2902 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
2984 goto end_io; 2903 goto end_io;
2985 2904
2986 block_wait_queue_running(q);
2987
2988 /* 2905 /*
2989 * If this device has partitions, remap block n 2906 * If this device has partitions, remap block n
2990 * of partition p to block n+start(p) of the disk. 2907 * of partition p to block n+start(p) of the disk.
@@ -3393,7 +3310,7 @@ void exit_io_context(void)
3393 * but since the current task itself holds a reference, the context can be 3310 * but since the current task itself holds a reference, the context can be
3394 * used in general code, so long as it stays within `current` context. 3311 * used in general code, so long as it stays within `current` context.
3395 */ 3312 */
3396struct io_context *current_io_context(int gfp_flags) 3313struct io_context *current_io_context(gfp_t gfp_flags)
3397{ 3314{
3398 struct task_struct *tsk = current; 3315 struct task_struct *tsk = current;
3399 struct io_context *ret; 3316 struct io_context *ret;
@@ -3424,7 +3341,7 @@ EXPORT_SYMBOL(current_io_context);
3424 * 3341 *
3425 * This is always called in the context of the task which submitted the I/O. 3342 * This is always called in the context of the task which submitted the I/O.
3426 */ 3343 */
3427struct io_context *get_io_context(int gfp_flags) 3344struct io_context *get_io_context(gfp_t gfp_flags)
3428{ 3345{
3429 struct io_context *ret; 3346 struct io_context *ret;
3430 ret = current_io_context(gfp_flags); 3347 ret = current_io_context(gfp_flags);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index b35e08876dd4..96c664af8d06 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -881,7 +881,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
881static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev) 881static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
882{ 882{
883 struct file *filp = lo->lo_backing_file; 883 struct file *filp = lo->lo_backing_file;
884 int gfp = lo->old_gfp_mask; 884 gfp_t gfp = lo->old_gfp_mask;
885 885
886 if (lo->lo_state != Lo_bound) 886 if (lo->lo_state != Lo_bound)
887 return -ENXIO; 887 return -ENXIO;
diff --git a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c
index b1730b62c37e..f56b8edb06e4 100644
--- a/drivers/block/noop-iosched.c
+++ b/drivers/block/noop-iosched.c
@@ -7,57 +7,19 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/init.h> 8#include <linux/init.h>
9 9
10/* 10static void elevator_noop_add_request(request_queue_t *q, struct request *rq)
11 * See if we can find a request that this buffer can be coalesced with.
12 */
13static int elevator_noop_merge(request_queue_t *q, struct request **req,
14 struct bio *bio)
15{
16 int ret;
17
18 ret = elv_try_last_merge(q, bio);
19 if (ret != ELEVATOR_NO_MERGE)
20 *req = q->last_merge;
21
22 return ret;
23}
24
25static void elevator_noop_merge_requests(request_queue_t *q, struct request *req,
26 struct request *next)
27{
28 list_del_init(&next->queuelist);
29}
30
31static void elevator_noop_add_request(request_queue_t *q, struct request *rq,
32 int where)
33{ 11{
34 if (where == ELEVATOR_INSERT_FRONT) 12 elv_dispatch_add_tail(q, rq);
35 list_add(&rq->queuelist, &q->queue_head);
36 else
37 list_add_tail(&rq->queuelist, &q->queue_head);
38
39 /*
40 * new merges must not precede this barrier
41 */
42 if (rq->flags & REQ_HARDBARRIER)
43 q->last_merge = NULL;
44 else if (!q->last_merge)
45 q->last_merge = rq;
46} 13}
47 14
48static struct request *elevator_noop_next_request(request_queue_t *q) 15static int elevator_noop_dispatch(request_queue_t *q, int force)
49{ 16{
50 if (!list_empty(&q->queue_head)) 17 return 0;
51 return list_entry_rq(q->queue_head.next);
52
53 return NULL;
54} 18}
55 19
56static struct elevator_type elevator_noop = { 20static struct elevator_type elevator_noop = {
57 .ops = { 21 .ops = {
58 .elevator_merge_fn = elevator_noop_merge, 22 .elevator_dispatch_fn = elevator_noop_dispatch,
59 .elevator_merge_req_fn = elevator_noop_merge_requests,
60 .elevator_next_req_fn = elevator_noop_next_request,
61 .elevator_add_req_fn = elevator_noop_add_request, 23 .elevator_add_req_fn = elevator_noop_add_request,
62 }, 24 },
63 .elevator_name = "noop", 25 .elevator_name = "noop",
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index b3982395f22b..82f2d6d2eeef 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -674,7 +674,7 @@ static int __init pg_init(void)
674 for (unit = 0; unit < PG_UNITS; unit++) { 674 for (unit = 0; unit < PG_UNITS; unit++) {
675 struct pg *dev = &devices[unit]; 675 struct pg *dev = &devices[unit];
676 if (dev->present) { 676 if (dev->present) {
677 class_device_create(pg_class, MKDEV(major, unit), 677 class_device_create(pg_class, NULL, MKDEV(major, unit),
678 NULL, "pg%u", unit); 678 NULL, "pg%u", unit);
679 err = devfs_mk_cdev(MKDEV(major, unit), 679 err = devfs_mk_cdev(MKDEV(major, unit),
680 S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u", 680 S_IFCHR | S_IRUSR | S_IWUSR, "pg/%u",
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index d8d35233cf49..686c95573452 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -971,7 +971,7 @@ static int __init pt_init(void)
971 devfs_mk_dir("pt"); 971 devfs_mk_dir("pt");
972 for (unit = 0; unit < PT_UNITS; unit++) 972 for (unit = 0; unit < PT_UNITS; unit++)
973 if (pt[unit].present) { 973 if (pt[unit].present) {
974 class_device_create(pt_class, MKDEV(major, unit), 974 class_device_create(pt_class, NULL, MKDEV(major, unit),
975 NULL, "pt%d", unit); 975 NULL, "pt%d", unit);
976 err = devfs_mk_cdev(MKDEV(major, unit), 976 err = devfs_mk_cdev(MKDEV(major, unit),
977 S_IFCHR | S_IRUSR | S_IWUSR, 977 S_IFCHR | S_IRUSR | S_IWUSR,
@@ -980,7 +980,7 @@ static int __init pt_init(void)
980 class_device_destroy(pt_class, MKDEV(major, unit)); 980 class_device_destroy(pt_class, MKDEV(major, unit));
981 goto out_class; 981 goto out_class;
982 } 982 }
983 class_device_create(pt_class, MKDEV(major, unit + 128), 983 class_device_create(pt_class, NULL, MKDEV(major, unit + 128),
984 NULL, "pt%dn", unit); 984 NULL, "pt%dn", unit);
985 err = devfs_mk_cdev(MKDEV(major, unit + 128), 985 err = devfs_mk_cdev(MKDEV(major, unit + 128),
986 S_IFCHR | S_IRUSR | S_IWUSR, 986 S_IFCHR | S_IRUSR | S_IWUSR,
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 145c1fbffe01..68c60a5bcdab 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -348,7 +348,7 @@ static int rd_open(struct inode *inode, struct file *filp)
348 struct block_device *bdev = inode->i_bdev; 348 struct block_device *bdev = inode->i_bdev;
349 struct address_space *mapping; 349 struct address_space *mapping;
350 unsigned bsize; 350 unsigned bsize;
351 int gfp_mask; 351 gfp_t gfp_mask;
352 352
353 inode = igrab(bdev->bd_inode); 353 inode = igrab(bdev->bd_inode);
354 rd_bdev[unit] = bdev; 354 rd_bdev[unit] = bdev;
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index d57007b92f77..1ded3b433459 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * sx8.c: Driver for Promise SATA SX8 looks-like-I2O hardware 2 * sx8.c: Driver for Promise SATA SX8 looks-like-I2O hardware
3 * 3 *
4 * Copyright 2004 Red Hat, Inc. 4 * Copyright 2004-2005 Red Hat, Inc.
5 * 5 *
6 * Author/maintainer: Jeff Garzik <jgarzik@pobox.com> 6 * Author/maintainer: Jeff Garzik <jgarzik@pobox.com>
7 * 7 *
@@ -31,10 +31,6 @@
31#include <asm/semaphore.h> 31#include <asm/semaphore.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34MODULE_AUTHOR("Jeff Garzik");
35MODULE_LICENSE("GPL");
36MODULE_DESCRIPTION("Promise SATA SX8 block driver");
37
38#if 0 34#if 0
39#define CARM_DEBUG 35#define CARM_DEBUG
40#define CARM_VERBOSE_DEBUG 36#define CARM_VERBOSE_DEBUG
@@ -45,9 +41,35 @@ MODULE_DESCRIPTION("Promise SATA SX8 block driver");
45#undef CARM_NDEBUG 41#undef CARM_NDEBUG
46 42
47#define DRV_NAME "sx8" 43#define DRV_NAME "sx8"
48#define DRV_VERSION "0.8" 44#define DRV_VERSION "1.0"
49#define PFX DRV_NAME ": " 45#define PFX DRV_NAME ": "
50 46
47MODULE_AUTHOR("Jeff Garzik");
48MODULE_LICENSE("GPL");
49MODULE_DESCRIPTION("Promise SATA SX8 block driver");
50MODULE_VERSION(DRV_VERSION);
51
52/*
53 * SX8 hardware has a single message queue for all ATA ports.
54 * When this driver was written, the hardware (firmware?) would
55 * corrupt data eventually, if more than one request was outstanding.
56 * As one can imagine, having 8 ports bottlenecking on a single
57 * command hurts performance.
58 *
59 * Based on user reports, later versions of the hardware (firmware?)
60 * seem to be able to survive with more than one command queued.
61 *
62 * Therefore, we default to the safe option -- 1 command -- but
63 * allow the user to increase this.
64 *
65 * SX8 should be able to support up to ~60 queued commands (CARM_MAX_REQ),
66 * but problems seem to occur when you exceed ~30, even on newer hardware.
67 */
68static int max_queue = 1;
69module_param(max_queue, int, 0444);
70MODULE_PARM_DESC(max_queue, "Maximum number of queued commands. (min==1, max==30, safe==1)");
71
72
51#define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN) 73#define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN)
52 74
53/* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */ 75/* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */
@@ -90,12 +112,10 @@ enum {
90 112
91 /* command message queue limits */ 113 /* command message queue limits */
92 CARM_MAX_REQ = 64, /* max command msgs per host */ 114 CARM_MAX_REQ = 64, /* max command msgs per host */
93 CARM_MAX_Q = 1, /* one command at a time */
94 CARM_MSG_LOW_WATER = (CARM_MAX_REQ / 4), /* refill mark */ 115 CARM_MSG_LOW_WATER = (CARM_MAX_REQ / 4), /* refill mark */
95 116
96 /* S/G limits, host-wide and per-request */ 117 /* S/G limits, host-wide and per-request */
97 CARM_MAX_REQ_SG = 32, /* max s/g entries per request */ 118 CARM_MAX_REQ_SG = 32, /* max s/g entries per request */
98 CARM_SG_BOUNDARY = 0xffffUL, /* s/g segment boundary */
99 CARM_MAX_HOST_SG = 600, /* max s/g entries per host */ 119 CARM_MAX_HOST_SG = 600, /* max s/g entries per host */
100 CARM_SG_LOW_WATER = (CARM_MAX_HOST_SG / 4), /* re-fill mark */ 120 CARM_SG_LOW_WATER = (CARM_MAX_HOST_SG / 4), /* re-fill mark */
101 121
@@ -181,6 +201,10 @@ enum {
181 FL_DYN_MAJOR = (1 << 17), 201 FL_DYN_MAJOR = (1 << 17),
182}; 202};
183 203
204enum {
205 CARM_SG_BOUNDARY = 0xffffUL, /* s/g segment boundary */
206};
207
184enum scatter_gather_types { 208enum scatter_gather_types {
185 SGT_32BIT = 0, 209 SGT_32BIT = 0,
186 SGT_64BIT = 1, 210 SGT_64BIT = 1,
@@ -218,7 +242,6 @@ static const char *state_name[] = {
218 242
219struct carm_port { 243struct carm_port {
220 unsigned int port_no; 244 unsigned int port_no;
221 unsigned int n_queued;
222 struct gendisk *disk; 245 struct gendisk *disk;
223 struct carm_host *host; 246 struct carm_host *host;
224 247
@@ -448,7 +471,7 @@ static inline int carm_lookup_bucket(u32 msg_size)
448 for (i = 0; i < ARRAY_SIZE(msg_sizes); i++) 471 for (i = 0; i < ARRAY_SIZE(msg_sizes); i++)
449 if (msg_size <= msg_sizes[i]) 472 if (msg_size <= msg_sizes[i])
450 return i; 473 return i;
451 474
452 return -ENOENT; 475 return -ENOENT;
453} 476}
454 477
@@ -509,7 +532,7 @@ static struct carm_request *carm_get_request(struct carm_host *host)
509 if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG)) 532 if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG))
510 return NULL; 533 return NULL;
511 534
512 for (i = 0; i < CARM_MAX_Q; i++) 535 for (i = 0; i < max_queue; i++)
513 if ((host->msg_alloc & (1ULL << i)) == 0) { 536 if ((host->msg_alloc & (1ULL << i)) == 0) {
514 struct carm_request *crq = &host->req[i]; 537 struct carm_request *crq = &host->req[i];
515 crq->port = NULL; 538 crq->port = NULL;
@@ -521,14 +544,14 @@ static struct carm_request *carm_get_request(struct carm_host *host)
521 assert(host->n_msgs <= CARM_MAX_REQ); 544 assert(host->n_msgs <= CARM_MAX_REQ);
522 return crq; 545 return crq;
523 } 546 }
524 547
525 DPRINTK("no request available, returning NULL\n"); 548 DPRINTK("no request available, returning NULL\n");
526 return NULL; 549 return NULL;
527} 550}
528 551
529static int carm_put_request(struct carm_host *host, struct carm_request *crq) 552static int carm_put_request(struct carm_host *host, struct carm_request *crq)
530{ 553{
531 assert(crq->tag < CARM_MAX_Q); 554 assert(crq->tag < max_queue);
532 555
533 if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0)) 556 if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0))
534 return -EINVAL; /* tried to clear a tag that was not active */ 557 return -EINVAL; /* tried to clear a tag that was not active */
@@ -791,7 +814,7 @@ static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq,
791 int is_ok) 814 int is_ok)
792{ 815{
793 carm_end_request_queued(host, crq, is_ok); 816 carm_end_request_queued(host, crq, is_ok);
794 if (CARM_MAX_Q == 1) 817 if (max_queue == 1)
795 carm_round_robin(host); 818 carm_round_robin(host);
796 else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && 819 else if ((host->n_msgs <= CARM_MSG_LOW_WATER) &&
797 (host->hw_sg_used <= CARM_SG_LOW_WATER)) { 820 (host->hw_sg_used <= CARM_SG_LOW_WATER)) {
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index ed4d5006fe62..bfb23d543ff7 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1512,7 +1512,7 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1512 scmd->nsg = 1; 1512 scmd->nsg = 1;
1513 sg = &scmd->sgv[0]; 1513 sg = &scmd->sgv[0];
1514 sg->page = virt_to_page(sc->top_sense); 1514 sg->page = virt_to_page(sc->top_sense);
1515 sg->offset = (unsigned int)sc->top_sense & (PAGE_SIZE-1); 1515 sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1);
1516 sg->length = UB_SENSE_SIZE; 1516 sg->length = UB_SENSE_SIZE;
1517 scmd->len = UB_SENSE_SIZE; 1517 scmd->len = UB_SENSE_SIZE;
1518 scmd->lun = cmd->lun; 1518 scmd->lun = cmd->lun;
@@ -1891,7 +1891,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
1891 cmd->nsg = 1; 1891 cmd->nsg = 1;
1892 sg = &cmd->sgv[0]; 1892 sg = &cmd->sgv[0];
1893 sg->page = virt_to_page(p); 1893 sg->page = virt_to_page(p);
1894 sg->offset = (unsigned int)p & (PAGE_SIZE-1); 1894 sg->offset = (unsigned long)p & (PAGE_SIZE-1);
1895 sg->length = 8; 1895 sg->length = 8;
1896 cmd->len = 8; 1896 cmd->len = 8;
1897 cmd->lun = lun; 1897 cmd->lun = lun;
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 543f93e0f23f..b9fbe6e7f9ae 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -55,14 +55,6 @@ config BT_HCIUART_BCSP
55 55
56 Say Y here to compile support for HCI BCSP protocol. 56 Say Y here to compile support for HCI BCSP protocol.
57 57
58config BT_HCIUART_BCSP_TXCRC
59 bool "Transmit CRC with every BCSP packet"
60 depends on BT_HCIUART_BCSP
61 help
62 If you say Y here, a 16-bit CRC checksum will be transmitted along with
63 every BCSP (BlueCore Serial Protocol) packet sent to the Bluetooth chip.
64 This increases reliability, but slightly reduces efficiency.
65
66config BT_HCIBCM203X 58config BT_HCIBCM203X
67 tristate "HCI BCM203x USB driver" 59 tristate "HCI BCM203x USB driver"
68 depends on USB 60 depends on USB
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 4fa85234d8b5..0db0400519c9 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -550,6 +550,9 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
550 if (ignore) 550 if (ignore)
551 return -ENODEV; 551 return -ENODEV;
552 552
553 if (intf->cur_altsetting->desc.bInterfaceNumber > 0)
554 return -ENODEV;
555
553 data = kmalloc(sizeof(*data), GFP_KERNEL); 556 data = kmalloc(sizeof(*data), GFP_KERNEL);
554 if (!data) { 557 if (!data) {
555 BT_ERR("Can't allocate data structure"); 558 BT_ERR("Can't allocate data structure");
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 0ee324e1265d..0a4761415ac3 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -1,35 +1,27 @@
1/*
2 BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ).
3 Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com>
4
5 Based on
6 hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com>
7 ABCSP by Carl Orsborn <cjo@csr.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation;
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
16 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
17 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
18 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
24 SOFTWARE IS DISCLAIMED.
25*/
26
27/* 1/*
28 * $Id: hci_bcsp.c,v 1.2 2002/09/26 05:05:14 maxk Exp $ 2 *
3 * Bluetooth HCI UART driver
4 *
5 * Copyright (C) 2002-2003 Fabrizio Gennari <fabrizio.gennari@philips.com>
6 * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
29 */ 23 */
30 24
31#define VERSION "0.2"
32
33#include <linux/config.h> 25#include <linux/config.h>
34#include <linux/module.h> 26#include <linux/module.h>
35 27
@@ -52,16 +44,56 @@
52 44
53#include <net/bluetooth/bluetooth.h> 45#include <net/bluetooth/bluetooth.h>
54#include <net/bluetooth/hci_core.h> 46#include <net/bluetooth/hci_core.h>
47
55#include "hci_uart.h" 48#include "hci_uart.h"
56#include "hci_bcsp.h"
57 49
58#ifndef CONFIG_BT_HCIUART_DEBUG 50#ifndef CONFIG_BT_HCIUART_DEBUG
59#undef BT_DBG 51#undef BT_DBG
60#define BT_DBG( A... ) 52#define BT_DBG( A... )
61#endif 53#endif
62 54
55#define VERSION "0.3"
56
57static int txcrc = 1;
63static int hciextn = 1; 58static int hciextn = 1;
64 59
60#define BCSP_TXWINSIZE 4
61
62#define BCSP_ACK_PKT 0x05
63#define BCSP_LE_PKT 0x06
64
65struct bcsp_struct {
66 struct sk_buff_head unack; /* Unack'ed packets queue */
67 struct sk_buff_head rel; /* Reliable packets queue */
68 struct sk_buff_head unrel; /* Unreliable packets queue */
69
70 unsigned long rx_count;
71 struct sk_buff *rx_skb;
72 u8 rxseq_txack; /* rxseq == txack. */
73 u8 rxack; /* Last packet sent by us that the peer ack'ed */
74 struct timer_list tbcsp;
75
76 enum {
77 BCSP_W4_PKT_DELIMITER,
78 BCSP_W4_PKT_START,
79 BCSP_W4_BCSP_HDR,
80 BCSP_W4_DATA,
81 BCSP_W4_CRC
82 } rx_state;
83
84 enum {
85 BCSP_ESCSTATE_NOESC,
86 BCSP_ESCSTATE_ESC
87 } rx_esc_state;
88
89 u8 use_crc;
90 u16 message_crc;
91 u8 txack_req; /* Do we need to send ack's to the peer? */
92
93 /* Reliable packet sequence number - used to assign seq to each rel pkt. */
94 u8 msgq_txseq;
95};
96
65/* ---- BCSP CRC calculation ---- */ 97/* ---- BCSP CRC calculation ---- */
66 98
67/* Table for calculating CRC for polynomial 0x1021, LSB processed first, 99/* Table for calculating CRC for polynomial 0x1021, LSB processed first,
@@ -111,6 +143,7 @@ static u16 bcsp_crc_reverse(u16 crc)
111 rev |= (crc & 1); 143 rev |= (crc & 1);
112 crc = crc >> 1; 144 crc = crc >> 1;
113 } 145 }
146
114 return (rev); 147 return (rev);
115} 148}
116 149
@@ -119,6 +152,7 @@ static u16 bcsp_crc_reverse(u16 crc)
119static void bcsp_slip_msgdelim(struct sk_buff *skb) 152static void bcsp_slip_msgdelim(struct sk_buff *skb)
120{ 153{
121 const char pkt_delim = 0xc0; 154 const char pkt_delim = 0xc0;
155
122 memcpy(skb_put(skb, 1), &pkt_delim, 1); 156 memcpy(skb_put(skb, 1), &pkt_delim, 1);
123} 157}
124 158
@@ -173,11 +207,8 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
173{ 207{
174 struct sk_buff *nskb; 208 struct sk_buff *nskb;
175 u8 hdr[4], chan; 209 u8 hdr[4], chan;
176 int rel, i;
177
178#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC
179 u16 BCSP_CRC_INIT(bcsp_txmsg_crc); 210 u16 BCSP_CRC_INIT(bcsp_txmsg_crc);
180#endif 211 int rel, i;
181 212
182 switch (pkt_type) { 213 switch (pkt_type) {
183 case HCI_ACLDATA_PKT: 214 case HCI_ACLDATA_PKT:
@@ -240,9 +271,9 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
240 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq); 271 BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq);
241 bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07; 272 bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07;
242 } 273 }
243#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC 274
244 hdr[0] |= 0x40; 275 if (bcsp->use_crc)
245#endif 276 hdr[0] |= 0x40;
246 277
247 hdr[1] = ((len << 4) & 0xff) | chan; 278 hdr[1] = ((len << 4) & 0xff) | chan;
248 hdr[2] = len >> 4; 279 hdr[2] = len >> 4;
@@ -251,25 +282,25 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
251 /* Put BCSP header */ 282 /* Put BCSP header */
252 for (i = 0; i < 4; i++) { 283 for (i = 0; i < 4; i++) {
253 bcsp_slip_one_byte(nskb, hdr[i]); 284 bcsp_slip_one_byte(nskb, hdr[i]);
254#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC 285
255 bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]); 286 if (bcsp->use_crc)
256#endif 287 bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]);
257 } 288 }
258 289
259 /* Put payload */ 290 /* Put payload */
260 for (i = 0; i < len; i++) { 291 for (i = 0; i < len; i++) {
261 bcsp_slip_one_byte(nskb, data[i]); 292 bcsp_slip_one_byte(nskb, data[i]);
262#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC 293
263 bcsp_crc_update(&bcsp_txmsg_crc, data[i]); 294 if (bcsp->use_crc)
264#endif 295 bcsp_crc_update(&bcsp_txmsg_crc, data[i]);
265 } 296 }
266 297
267#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC
268 /* Put CRC */ 298 /* Put CRC */
269 bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc); 299 if (bcsp->use_crc) {
270 bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff)); 300 bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc);
271 bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff)); 301 bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff));
272#endif 302 bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff));
303 }
273 304
274 bcsp_slip_msgdelim(nskb); 305 bcsp_slip_msgdelim(nskb);
275 return nskb; 306 return nskb;
@@ -317,7 +348,6 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
317 348
318 spin_unlock_irqrestore(&bcsp->unack.lock, flags); 349 spin_unlock_irqrestore(&bcsp->unack.lock, flags);
319 350
320
321 /* We could not send a reliable packet, either because there are 351 /* We could not send a reliable packet, either because there are
322 none or because there are too many unack'ed pkts. Did we receive 352 none or because there are too many unack'ed pkts. Did we receive
323 any packets we have not acknowledged yet ? */ 353 any packets we have not acknowledged yet ? */
@@ -363,7 +393,7 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp)
363 BT_ERR("Peer acked invalid packet"); 393 BT_ERR("Peer acked invalid packet");
364 394
365 BT_DBG("Removing %u pkts out of %u, up to seqno %u", 395 BT_DBG("Removing %u pkts out of %u, up to seqno %u",
366 pkts_to_be_removed, bcsp->unack.qlen, (seqno - 1) & 0x07); 396 pkts_to_be_removed, bcsp->unack.qlen, (seqno - 1) & 0x07);
367 397
368 for (i = 0, skb = ((struct sk_buff *) &bcsp->unack)->next; i < pkts_to_be_removed 398 for (i = 0, skb = ((struct sk_buff *) &bcsp->unack)->next; i < pkts_to_be_removed
369 && skb != (struct sk_buff *) &bcsp->unack; i++) { 399 && skb != (struct sk_buff *) &bcsp->unack; i++) {
@@ -374,8 +404,10 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp)
374 kfree_skb(skb); 404 kfree_skb(skb);
375 skb = nskb; 405 skb = nskb;
376 } 406 }
407
377 if (bcsp->unack.qlen == 0) 408 if (bcsp->unack.qlen == 0)
378 del_timer(&bcsp->tbcsp); 409 del_timer(&bcsp->tbcsp);
410
379 spin_unlock_irqrestore(&bcsp->unack.lock, flags); 411 spin_unlock_irqrestore(&bcsp->unack.lock, flags);
380 412
381 if (i != pkts_to_be_removed) 413 if (i != pkts_to_be_removed)
@@ -530,6 +562,7 @@ static inline void bcsp_complete_rx_pkt(struct hci_uart *hu)
530 562
531 hci_recv_frame(bcsp->rx_skb); 563 hci_recv_frame(bcsp->rx_skb);
532 } 564 }
565
533 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 566 bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
534 bcsp->rx_skb = NULL; 567 bcsp->rx_skb = NULL;
535} 568}
@@ -598,8 +631,8 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
598 631
599 BT_ERR ("Checksum failed: computed %04x received %04x", 632 BT_ERR ("Checksum failed: computed %04x received %04x",
600 bcsp_crc_reverse(bcsp->message_crc), 633 bcsp_crc_reverse(bcsp->message_crc),
601 (bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) + 634 (bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) +
602 bcsp->rx_skb->data[bcsp->rx_skb->len - 1]); 635 bcsp->rx_skb->data[bcsp->rx_skb->len - 1]);
603 636
604 kfree_skb(bcsp->rx_skb); 637 kfree_skb(bcsp->rx_skb);
605 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 638 bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
@@ -633,7 +666,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
633 bcsp->rx_count = 4; 666 bcsp->rx_count = 4;
634 bcsp->rx_esc_state = BCSP_ESCSTATE_NOESC; 667 bcsp->rx_esc_state = BCSP_ESCSTATE_NOESC;
635 BCSP_CRC_INIT(bcsp->message_crc); 668 BCSP_CRC_INIT(bcsp->message_crc);
636 669
637 /* Do not increment ptr or decrement count 670 /* Do not increment ptr or decrement count
638 * Allocate packet. Max len of a BCSP pkt= 671 * Allocate packet. Max len of a BCSP pkt=
639 * 0xFFF (payload) +4 (header) +2 (crc) */ 672 * 0xFFF (payload) +4 (header) +2 (crc) */
@@ -698,6 +731,9 @@ static int bcsp_open(struct hci_uart *hu)
698 731
699 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 732 bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
700 733
734 if (txcrc)
735 bcsp->use_crc = 1;
736
701 return 0; 737 return 0;
702} 738}
703 739
@@ -718,18 +754,19 @@ static int bcsp_close(struct hci_uart *hu)
718} 754}
719 755
720static struct hci_uart_proto bcsp = { 756static struct hci_uart_proto bcsp = {
721 .id = HCI_UART_BCSP, 757 .id = HCI_UART_BCSP,
722 .open = bcsp_open, 758 .open = bcsp_open,
723 .close = bcsp_close, 759 .close = bcsp_close,
724 .enqueue = bcsp_enqueue, 760 .enqueue = bcsp_enqueue,
725 .dequeue = bcsp_dequeue, 761 .dequeue = bcsp_dequeue,
726 .recv = bcsp_recv, 762 .recv = bcsp_recv,
727 .flush = bcsp_flush 763 .flush = bcsp_flush
728}; 764};
729 765
730int bcsp_init(void) 766int bcsp_init(void)
731{ 767{
732 int err = hci_uart_register_proto(&bcsp); 768 int err = hci_uart_register_proto(&bcsp);
769
733 if (!err) 770 if (!err)
734 BT_INFO("HCI BCSP protocol initialized"); 771 BT_INFO("HCI BCSP protocol initialized");
735 else 772 else
@@ -743,5 +780,8 @@ int bcsp_deinit(void)
743 return hci_uart_unregister_proto(&bcsp); 780 return hci_uart_unregister_proto(&bcsp);
744} 781}
745 782
783module_param(txcrc, bool, 0644);
784MODULE_PARM_DESC(txcrc, "Transmit CRC with every BCSP packet");
785
746module_param(hciextn, bool, 0644); 786module_param(hciextn, bool, 0644);
747MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets"); 787MODULE_PARM_DESC(hciextn, "Convert HCI Extensions into BCSP packets");
diff --git a/drivers/bluetooth/hci_bcsp.h b/drivers/bluetooth/hci_bcsp.h
deleted file mode 100644
index a2b3bb92274b..000000000000
--- a/drivers/bluetooth/hci_bcsp.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 BlueCore Serial Protocol (BCSP) for Linux Bluetooth stack (BlueZ).
3 Copyright 2002 by Fabrizio Gennari <fabrizio.gennari@philips.com>
4
5 Based on
6 hci_h4.c by Maxim Krasnyansky <maxk@qualcomm.com>
7 ABCSP by Carl Orsborn <cjo@csr.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation;
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
16 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
17 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
18 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
22 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
23 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
24 SOFTWARE IS DISCLAIMED.
25*/
26
27/*
28 * $Id: hci_bcsp.h,v 1.2 2002/09/26 05:05:14 maxk Exp $
29 */
30
31#ifndef __HCI_BCSP_H__
32#define __HCI_BCSP_H__
33
34#define BCSP_TXWINSIZE 4
35
36#define BCSP_ACK_PKT 0x05
37#define BCSP_LE_PKT 0x06
38
39struct bcsp_struct {
40 struct sk_buff_head unack; /* Unack'ed packets queue */
41 struct sk_buff_head rel; /* Reliable packets queue */
42 struct sk_buff_head unrel; /* Unreliable packets queue */
43
44 unsigned long rx_count;
45 struct sk_buff *rx_skb;
46 u8 rxseq_txack; /* rxseq == txack. */
47 u8 rxack; /* Last packet sent by us that the peer ack'ed */
48 struct timer_list tbcsp;
49
50 enum {
51 BCSP_W4_PKT_DELIMITER,
52 BCSP_W4_PKT_START,
53 BCSP_W4_BCSP_HDR,
54 BCSP_W4_DATA,
55 BCSP_W4_CRC
56 } rx_state;
57
58 enum {
59 BCSP_ESCSTATE_NOESC,
60 BCSP_ESCSTATE_ESC
61 } rx_esc_state;
62
63 u16 message_crc;
64 u8 txack_req; /* Do we need to send ack's to the peer? */
65
66 /* Reliable packet sequence number - used to assign seq to each rel pkt. */
67 u8 msgq_txseq;
68};
69
70#endif /* __HCI_BCSP_H__ */
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index cf8a22d58d96..12e369a66fc2 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -1,33 +1,27 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
23*/
24
25/* 1/*
26 * Bluetooth HCI UART(H4) protocol.
27 * 2 *
28 * $Id: hci_h4.c,v 1.3 2002/09/09 01:17:32 maxk Exp $ 3 * Bluetooth HCI UART driver
4 *
5 * Copyright (C) 2000-2001 Qualcomm Incorporated
6 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7 * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
29 */ 24 */
30#define VERSION "1.2"
31 25
32#include <linux/config.h> 26#include <linux/config.h>
33#include <linux/module.h> 27#include <linux/module.h>
@@ -51,24 +45,41 @@
51 45
52#include <net/bluetooth/bluetooth.h> 46#include <net/bluetooth/bluetooth.h>
53#include <net/bluetooth/hci_core.h> 47#include <net/bluetooth/hci_core.h>
48
54#include "hci_uart.h" 49#include "hci_uart.h"
55#include "hci_h4.h"
56 50
57#ifndef CONFIG_BT_HCIUART_DEBUG 51#ifndef CONFIG_BT_HCIUART_DEBUG
58#undef BT_DBG 52#undef BT_DBG
59#define BT_DBG( A... ) 53#define BT_DBG( A... )
60#endif 54#endif
61 55
56#define VERSION "1.2"
57
58struct h4_struct {
59 unsigned long rx_state;
60 unsigned long rx_count;
61 struct sk_buff *rx_skb;
62 struct sk_buff_head txq;
63};
64
65/* H4 receiver States */
66#define H4_W4_PACKET_TYPE 0
67#define H4_W4_EVENT_HDR 1
68#define H4_W4_ACL_HDR 2
69#define H4_W4_SCO_HDR 3
70#define H4_W4_DATA 4
71
62/* Initialize protocol */ 72/* Initialize protocol */
63static int h4_open(struct hci_uart *hu) 73static int h4_open(struct hci_uart *hu)
64{ 74{
65 struct h4_struct *h4; 75 struct h4_struct *h4;
66 76
67 BT_DBG("hu %p", hu); 77 BT_DBG("hu %p", hu);
68 78
69 h4 = kmalloc(sizeof(*h4), GFP_ATOMIC); 79 h4 = kmalloc(sizeof(*h4), GFP_ATOMIC);
70 if (!h4) 80 if (!h4)
71 return -ENOMEM; 81 return -ENOMEM;
82
72 memset(h4, 0, sizeof(*h4)); 83 memset(h4, 0, sizeof(*h4));
73 84
74 skb_queue_head_init(&h4->txq); 85 skb_queue_head_init(&h4->txq);
@@ -83,7 +94,9 @@ static int h4_flush(struct hci_uart *hu)
83 struct h4_struct *h4 = hu->priv; 94 struct h4_struct *h4 = hu->priv;
84 95
85 BT_DBG("hu %p", hu); 96 BT_DBG("hu %p", hu);
97
86 skb_queue_purge(&h4->txq); 98 skb_queue_purge(&h4->txq);
99
87 return 0; 100 return 0;
88} 101}
89 102
@@ -91,16 +104,19 @@ static int h4_flush(struct hci_uart *hu)
91static int h4_close(struct hci_uart *hu) 104static int h4_close(struct hci_uart *hu)
92{ 105{
93 struct h4_struct *h4 = hu->priv; 106 struct h4_struct *h4 = hu->priv;
107
94 hu->priv = NULL; 108 hu->priv = NULL;
95 109
96 BT_DBG("hu %p", hu); 110 BT_DBG("hu %p", hu);
97 111
98 skb_queue_purge(&h4->txq); 112 skb_queue_purge(&h4->txq);
113
99 if (h4->rx_skb) 114 if (h4->rx_skb)
100 kfree_skb(h4->rx_skb); 115 kfree_skb(h4->rx_skb);
101 116
102 hu->priv = NULL; 117 hu->priv = NULL;
103 kfree(h4); 118 kfree(h4);
119
104 return 0; 120 return 0;
105} 121}
106 122
@@ -114,6 +130,7 @@ static int h4_enqueue(struct hci_uart *hu, struct sk_buff *skb)
114 /* Prepend skb with frame type */ 130 /* Prepend skb with frame type */
115 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); 131 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
116 skb_queue_tail(&h4->txq, skb); 132 skb_queue_tail(&h4->txq, skb);
133
117 return 0; 134 return 0;
118} 135}
119 136
@@ -122,6 +139,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len)
122 register int room = skb_tailroom(h4->rx_skb); 139 register int room = skb_tailroom(h4->rx_skb);
123 140
124 BT_DBG("len %d room %d", len, room); 141 BT_DBG("len %d room %d", len, room);
142
125 if (!len) { 143 if (!len) {
126 hci_recv_frame(h4->rx_skb); 144 hci_recv_frame(h4->rx_skb);
127 } else if (len > room) { 145 } else if (len > room) {
@@ -136,6 +154,7 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len)
136 h4->rx_state = H4_W4_PACKET_TYPE; 154 h4->rx_state = H4_W4_PACKET_TYPE;
137 h4->rx_skb = NULL; 155 h4->rx_skb = NULL;
138 h4->rx_count = 0; 156 h4->rx_count = 0;
157
139 return 0; 158 return 0;
140} 159}
141 160
@@ -228,6 +247,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
228 ptr++; count--; 247 ptr++; count--;
229 continue; 248 continue;
230 }; 249 };
250
231 ptr++; count--; 251 ptr++; count--;
232 252
233 /* Allocate packet */ 253 /* Allocate packet */
@@ -238,9 +258,11 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
238 h4->rx_count = 0; 258 h4->rx_count = 0;
239 return 0; 259 return 0;
240 } 260 }
261
241 h4->rx_skb->dev = (void *) hu->hdev; 262 h4->rx_skb->dev = (void *) hu->hdev;
242 bt_cb(h4->rx_skb)->pkt_type = type; 263 bt_cb(h4->rx_skb)->pkt_type = type;
243 } 264 }
265
244 return count; 266 return count;
245} 267}
246 268
@@ -251,23 +273,24 @@ static struct sk_buff *h4_dequeue(struct hci_uart *hu)
251} 273}
252 274
253static struct hci_uart_proto h4p = { 275static struct hci_uart_proto h4p = {
254 .id = HCI_UART_H4, 276 .id = HCI_UART_H4,
255 .open = h4_open, 277 .open = h4_open,
256 .close = h4_close, 278 .close = h4_close,
257 .recv = h4_recv, 279 .recv = h4_recv,
258 .enqueue = h4_enqueue, 280 .enqueue = h4_enqueue,
259 .dequeue = h4_dequeue, 281 .dequeue = h4_dequeue,
260 .flush = h4_flush, 282 .flush = h4_flush,
261}; 283};
262 284
263int h4_init(void) 285int h4_init(void)
264{ 286{
265 int err = hci_uart_register_proto(&h4p); 287 int err = hci_uart_register_proto(&h4p);
288
266 if (!err) 289 if (!err)
267 BT_INFO("HCI H4 protocol initialized"); 290 BT_INFO("HCI H4 protocol initialized");
268 else 291 else
269 BT_ERR("HCI H4 protocol registration failed"); 292 BT_ERR("HCI H4 protocol registration failed");
270 293
271 return err; 294 return err;
272} 295}
273 296
diff --git a/drivers/bluetooth/hci_h4.h b/drivers/bluetooth/hci_h4.h
deleted file mode 100644
index b95ff54bfd47..000000000000
--- a/drivers/bluetooth/hci_h4.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
23*/
24
25/*
26 * $Id: hci_h4.h,v 1.2 2002/09/09 01:17:32 maxk Exp $
27 */
28
29#ifdef __KERNEL__
30struct h4_struct {
31 unsigned long rx_state;
32 unsigned long rx_count;
33 struct sk_buff *rx_skb;
34 struct sk_buff_head txq;
35};
36
37/* H4 receiver States */
38#define H4_W4_PACKET_TYPE 0
39#define H4_W4_EVENT_HDR 1
40#define H4_W4_ACL_HDR 2
41#define H4_W4_SCO_HDR 3
42#define H4_W4_DATA 4
43
44#endif /* __KERNEL__ */
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index aed80cc22890..4a775f6ea390 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -1,33 +1,27 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
23*/
24
25/* 1/*
26 * Bluetooth HCI UART driver.
27 * 2 *
28 * $Id: hci_ldisc.c,v 1.5 2002/10/02 18:37:20 maxk Exp $ 3 * Bluetooth HCI UART driver
4 *
5 * Copyright (C) 2000-2001 Qualcomm Incorporated
6 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7 * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
29 */ 24 */
30#define VERSION "2.1"
31 25
32#include <linux/config.h> 26#include <linux/config.h>
33#include <linux/module.h> 27#include <linux/module.h>
@@ -59,6 +53,8 @@
59#define BT_DBG( A... ) 53#define BT_DBG( A... )
60#endif 54#endif
61 55
56#define VERSION "2.2"
57
62static int reset = 0; 58static int reset = 0;
63 59
64static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO]; 60static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO];
@@ -72,6 +68,7 @@ int hci_uart_register_proto(struct hci_uart_proto *p)
72 return -EEXIST; 68 return -EEXIST;
73 69
74 hup[p->id] = p; 70 hup[p->id] = p;
71
75 return 0; 72 return 0;
76} 73}
77 74
@@ -84,6 +81,7 @@ int hci_uart_unregister_proto(struct hci_uart_proto *p)
84 return -EINVAL; 81 return -EINVAL;
85 82
86 hup[p->id] = NULL; 83 hup[p->id] = NULL;
84
87 return 0; 85 return 0;
88} 86}
89 87
@@ -91,13 +89,14 @@ static struct hci_uart_proto *hci_uart_get_proto(unsigned int id)
91{ 89{
92 if (id >= HCI_UART_MAX_PROTO) 90 if (id >= HCI_UART_MAX_PROTO)
93 return NULL; 91 return NULL;
92
94 return hup[id]; 93 return hup[id];
95} 94}
96 95
97static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) 96static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type)
98{ 97{
99 struct hci_dev *hdev = hu->hdev; 98 struct hci_dev *hdev = hu->hdev;
100 99
101 /* Update HCI stat counters */ 100 /* Update HCI stat counters */
102 switch (pkt_type) { 101 switch (pkt_type) {
103 case HCI_COMMAND_PKT: 102 case HCI_COMMAND_PKT:
@@ -117,10 +116,12 @@ static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type)
117static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu) 116static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
118{ 117{
119 struct sk_buff *skb = hu->tx_skb; 118 struct sk_buff *skb = hu->tx_skb;
119
120 if (!skb) 120 if (!skb)
121 skb = hu->proto->dequeue(hu); 121 skb = hu->proto->dequeue(hu);
122 else 122 else
123 hu->tx_skb = NULL; 123 hu->tx_skb = NULL;
124
124 return skb; 125 return skb;
125} 126}
126 127
@@ -129,7 +130,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
129 struct tty_struct *tty = hu->tty; 130 struct tty_struct *tty = hu->tty;
130 struct hci_dev *hdev = hu->hdev; 131 struct hci_dev *hdev = hu->hdev;
131 struct sk_buff *skb; 132 struct sk_buff *skb;
132 133
133 if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { 134 if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
134 set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); 135 set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
135 return 0; 136 return 0;
@@ -142,7 +143,7 @@ restart:
142 143
143 while ((skb = hci_uart_dequeue(hu))) { 144 while ((skb = hci_uart_dequeue(hu))) {
144 int len; 145 int len;
145 146
146 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 147 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
147 len = tty->driver->write(tty, skb->data, skb->len); 148 len = tty->driver->write(tty, skb->data, skb->len);
148 hdev->stat.byte_tx += len; 149 hdev->stat.byte_tx += len;
@@ -152,11 +153,11 @@ restart:
152 hu->tx_skb = skb; 153 hu->tx_skb = skb;
153 break; 154 break;
154 } 155 }
155 156
156 hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type); 157 hci_uart_tx_complete(hu, bt_cb(skb)->pkt_type);
157 kfree_skb(skb); 158 kfree_skb(skb);
158 } 159 }
159 160
160 if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) 161 if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state))
161 goto restart; 162 goto restart;
162 163
@@ -173,6 +174,7 @@ static int hci_uart_open(struct hci_dev *hdev)
173 /* Nothing to do for UART driver */ 174 /* Nothing to do for UART driver */
174 175
175 set_bit(HCI_RUNNING, &hdev->flags); 176 set_bit(HCI_RUNNING, &hdev->flags);
177
176 return 0; 178 return 0;
177} 179}
178 180
@@ -234,6 +236,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)
234 hu->proto->enqueue(hu, skb); 236 hu->proto->enqueue(hu, skb);
235 237
236 hci_uart_tx_wakeup(hu); 238 hci_uart_tx_wakeup(hu);
239
237 return 0; 240 return 0;
238} 241}
239 242
@@ -241,7 +244,8 @@ static void hci_uart_destruct(struct hci_dev *hdev)
241{ 244{
242 struct hci_uart *hu; 245 struct hci_uart *hu;
243 246
244 if (!hdev) return; 247 if (!hdev)
248 return;
245 249
246 BT_DBG("%s", hdev->name); 250 BT_DBG("%s", hdev->name);
247 251
@@ -272,6 +276,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
272 BT_ERR("Can't allocate controll structure"); 276 BT_ERR("Can't allocate controll structure");
273 return -ENFILE; 277 return -ENFILE;
274 } 278 }
279
275 memset(hu, 0, sizeof(struct hci_uart)); 280 memset(hu, 0, sizeof(struct hci_uart));
276 281
277 tty->disc_data = hu; 282 tty->disc_data = hu;
@@ -280,8 +285,10 @@ static int hci_uart_tty_open(struct tty_struct *tty)
280 spin_lock_init(&hu->rx_lock); 285 spin_lock_init(&hu->rx_lock);
281 286
282 /* Flush any pending characters in the driver and line discipline. */ 287 /* Flush any pending characters in the driver and line discipline. */
288
283 /* FIXME: why is this needed. Note don't use ldisc_ref here as the 289 /* FIXME: why is this needed. Note don't use ldisc_ref here as the
284 open path is before the ldisc is referencable */ 290 open path is before the ldisc is referencable */
291
285 if (tty->ldisc.flush_buffer) 292 if (tty->ldisc.flush_buffer)
286 tty->ldisc.flush_buffer(tty); 293 tty->ldisc.flush_buffer(tty);
287 294
@@ -372,13 +379,13 @@ static int hci_uart_tty_room (struct tty_struct *tty)
372static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count) 379static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count)
373{ 380{
374 struct hci_uart *hu = (void *)tty->disc_data; 381 struct hci_uart *hu = (void *)tty->disc_data;
375 382
376 if (!hu || tty != hu->tty) 383 if (!hu || tty != hu->tty)
377 return; 384 return;
378 385
379 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) 386 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
380 return; 387 return;
381 388
382 spin_lock(&hu->rx_lock); 389 spin_lock(&hu->rx_lock);
383 hu->proto->recv(hu, (void *) data, count); 390 hu->proto->recv(hu, (void *) data, count);
384 hu->hdev->stat.byte_rx += count; 391 hu->hdev->stat.byte_rx += count;
@@ -429,8 +436,8 @@ static int hci_uart_register_dev(struct hci_uart *hu)
429static int hci_uart_set_proto(struct hci_uart *hu, int id) 436static int hci_uart_set_proto(struct hci_uart *hu, int id)
430{ 437{
431 struct hci_uart_proto *p; 438 struct hci_uart_proto *p;
432 int err; 439 int err;
433 440
434 p = hci_uart_get_proto(id); 441 p = hci_uart_get_proto(id);
435 if (!p) 442 if (!p)
436 return -EPROTONOSUPPORT; 443 return -EPROTONOSUPPORT;
@@ -446,6 +453,7 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
446 p->close(hu); 453 p->close(hu);
447 return err; 454 return err;
448 } 455 }
456
449 return 0; 457 return 0;
450} 458}
451 459
@@ -463,7 +471,7 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
463 * Return Value: Command dependent 471 * Return Value: Command dependent
464 */ 472 */
465static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, 473static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
466 unsigned int cmd, unsigned long arg) 474 unsigned int cmd, unsigned long arg)
467{ 475{
468 struct hci_uart *hu = (void *)tty->disc_data; 476 struct hci_uart *hu = (void *)tty->disc_data;
469 int err = 0; 477 int err = 0;
@@ -483,14 +491,14 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
483 return err; 491 return err;
484 } 492 }
485 tty->low_latency = 1; 493 tty->low_latency = 1;
486 } else 494 } else
487 return -EBUSY; 495 return -EBUSY;
488 496
489 case HCIUARTGETPROTO: 497 case HCIUARTGETPROTO:
490 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) 498 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
491 return hu->proto->id; 499 return hu->proto->id;
492 return -EUNATCH; 500 return -EUNATCH;
493 501
494 default: 502 default:
495 err = n_tty_ioctl(tty, file, cmd, arg); 503 err = n_tty_ioctl(tty, file, cmd, arg);
496 break; 504 break;
@@ -502,28 +510,24 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
502/* 510/*
503 * We don't provide read/write/poll interface for user space. 511 * We don't provide read/write/poll interface for user space.
504 */ 512 */
505static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char __user *buf, size_t nr) 513static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file,
514 unsigned char __user *buf, size_t nr)
506{ 515{
507 return 0; 516 return 0;
508} 517}
509static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, const unsigned char *data, size_t count) 518
519static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file,
520 const unsigned char *data, size_t count)
510{ 521{
511 return 0; 522 return 0;
512} 523}
513static unsigned int hci_uart_tty_poll(struct tty_struct *tty, struct file *filp, poll_table *wait) 524
525static unsigned int hci_uart_tty_poll(struct tty_struct *tty,
526 struct file *filp, poll_table *wait)
514{ 527{
515 return 0; 528 return 0;
516} 529}
517 530
518#ifdef CONFIG_BT_HCIUART_H4
519int h4_init(void);
520int h4_deinit(void);
521#endif
522#ifdef CONFIG_BT_HCIUART_BCSP
523int bcsp_init(void);
524int bcsp_deinit(void);
525#endif
526
527static int __init hci_uart_init(void) 531static int __init hci_uart_init(void)
528{ 532{
529 static struct tty_ldisc hci_uart_ldisc; 533 static struct tty_ldisc hci_uart_ldisc;
@@ -534,18 +538,18 @@ static int __init hci_uart_init(void)
534 /* Register the tty discipline */ 538 /* Register the tty discipline */
535 539
536 memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc)); 540 memset(&hci_uart_ldisc, 0, sizeof (hci_uart_ldisc));
537 hci_uart_ldisc.magic = TTY_LDISC_MAGIC; 541 hci_uart_ldisc.magic = TTY_LDISC_MAGIC;
538 hci_uart_ldisc.name = "n_hci"; 542 hci_uart_ldisc.name = "n_hci";
539 hci_uart_ldisc.open = hci_uart_tty_open; 543 hci_uart_ldisc.open = hci_uart_tty_open;
540 hci_uart_ldisc.close = hci_uart_tty_close; 544 hci_uart_ldisc.close = hci_uart_tty_close;
541 hci_uart_ldisc.read = hci_uart_tty_read; 545 hci_uart_ldisc.read = hci_uart_tty_read;
542 hci_uart_ldisc.write = hci_uart_tty_write; 546 hci_uart_ldisc.write = hci_uart_tty_write;
543 hci_uart_ldisc.ioctl = hci_uart_tty_ioctl; 547 hci_uart_ldisc.ioctl = hci_uart_tty_ioctl;
544 hci_uart_ldisc.poll = hci_uart_tty_poll; 548 hci_uart_ldisc.poll = hci_uart_tty_poll;
545 hci_uart_ldisc.receive_room= hci_uart_tty_room; 549 hci_uart_ldisc.receive_room = hci_uart_tty_room;
546 hci_uart_ldisc.receive_buf = hci_uart_tty_receive; 550 hci_uart_ldisc.receive_buf = hci_uart_tty_receive;
547 hci_uart_ldisc.write_wakeup= hci_uart_tty_wakeup; 551 hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
548 hci_uart_ldisc.owner = THIS_MODULE; 552 hci_uart_ldisc.owner = THIS_MODULE;
549 553
550 if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) { 554 if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
551 BT_ERR("HCI line discipline registration failed. (%d)", err); 555 BT_ERR("HCI line discipline registration failed. (%d)", err);
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 0a57d72790ec..b250e6789dee 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -1,32 +1,29 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation;
10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
23*/
24
25/* 1/*
26 * $Id: hci_uart.h,v 1.2 2002/09/09 01:17:32 maxk Exp $ 2 *
3 * Bluetooth HCI UART driver
4 *
5 * Copyright (C) 2000-2001 Qualcomm Incorporated
6 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
7 * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org>
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
27 */ 24 */
28 25
29#ifndef N_HCI 26#ifndef N_HCI
30#define N_HCI 15 27#define N_HCI 15
31#endif 28#endif
32 29
@@ -42,7 +39,6 @@
42#define HCI_UART_3WIRE 2 39#define HCI_UART_3WIRE 2
43#define HCI_UART_H4DS 3 40#define HCI_UART_H4DS 3
44 41
45#ifdef __KERNEL__
46struct hci_uart; 42struct hci_uart;
47 43
48struct hci_uart_proto { 44struct hci_uart_proto {
@@ -56,27 +52,35 @@ struct hci_uart_proto {
56}; 52};
57 53
58struct hci_uart { 54struct hci_uart {
59 struct tty_struct *tty; 55 struct tty_struct *tty;
60 struct hci_dev *hdev; 56 struct hci_dev *hdev;
61 unsigned long flags; 57 unsigned long flags;
62 58
63 struct hci_uart_proto *proto; 59 struct hci_uart_proto *proto;
64 void *priv; 60 void *priv;
65 61
66 struct sk_buff *tx_skb; 62 struct sk_buff *tx_skb;
67 unsigned long tx_state; 63 unsigned long tx_state;
68 spinlock_t rx_lock; 64 spinlock_t rx_lock;
69}; 65};
70 66
71/* HCI_UART flag bits */ 67/* HCI_UART flag bits */
72#define HCI_UART_PROTO_SET 0 68#define HCI_UART_PROTO_SET 0
73 69
74/* TX states */ 70/* TX states */
75#define HCI_UART_SENDING 1 71#define HCI_UART_SENDING 1
76#define HCI_UART_TX_WAKEUP 2 72#define HCI_UART_TX_WAKEUP 2
77 73
78int hci_uart_register_proto(struct hci_uart_proto *p); 74int hci_uart_register_proto(struct hci_uart_proto *p);
79int hci_uart_unregister_proto(struct hci_uart_proto *p); 75int hci_uart_unregister_proto(struct hci_uart_proto *p);
80int hci_uart_tx_wakeup(struct hci_uart *hu); 76int hci_uart_tx_wakeup(struct hci_uart *hu);
81 77
82#endif /* __KERNEL__ */ 78#ifdef CONFIG_BT_HCIUART_H4
79int h4_init(void);
80int h4_deinit(void);
81#endif
82
83#ifdef CONFIG_BT_HCIUART_BCSP
84int bcsp_init(void);
85int bcsp_deinit(void);
86#endif
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 26271e3ca823..8693835cb2d5 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -515,7 +515,7 @@ static int __init dsp56k_init_driver(void)
515 err = PTR_ERR(dsp56k_class); 515 err = PTR_ERR(dsp56k_class);
516 goto out_chrdev; 516 goto out_chrdev;
517 } 517 }
518 class_device_create(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); 518 class_device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
519 519
520 err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0), 520 err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
521 S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k"); 521 S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
index 5745b74044ec..821357ce7e0e 100644
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ b/drivers/char/ftape/zftape/zftape-init.c
@@ -331,27 +331,27 @@ KERN_INFO
331 331
332 zft_class = class_create(THIS_MODULE, "zft"); 332 zft_class = class_create(THIS_MODULE, "zft");
333 for (i = 0; i < 4; i++) { 333 for (i = 0; i < 4; i++) {
334 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i); 334 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
335 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i), 335 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
336 S_IFCHR | S_IRUSR | S_IWUSR, 336 S_IFCHR | S_IRUSR | S_IWUSR,
337 "qft%i", i); 337 "qft%i", i);
338 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i); 338 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
339 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4), 339 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
340 S_IFCHR | S_IRUSR | S_IWUSR, 340 S_IFCHR | S_IRUSR | S_IWUSR,
341 "nqft%i", i); 341 "nqft%i", i);
342 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i); 342 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
343 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16), 343 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
344 S_IFCHR | S_IRUSR | S_IWUSR, 344 S_IFCHR | S_IRUSR | S_IWUSR,
345 "zqft%i", i); 345 "zqft%i", i);
346 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i); 346 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
347 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20), 347 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
348 S_IFCHR | S_IRUSR | S_IWUSR, 348 S_IFCHR | S_IRUSR | S_IWUSR,
349 "nzqft%i", i); 349 "nzqft%i", i);
350 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i); 350 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
351 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32), 351 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
352 S_IFCHR | S_IRUSR | S_IWUSR, 352 S_IFCHR | S_IRUSR | S_IWUSR,
353 "rawqft%i", i); 353 "rawqft%i", i);
354 class_device_create(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i); 354 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
355 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36), 355 devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
356 S_IFCHR | S_IRUSR | S_IWUSR, 356 S_IFCHR | S_IRUSR | S_IWUSR,
357 "nrawqft%i", i); 357 "nrawqft%i", i);
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c
index 9e4e26aef94e..d815d197dc3e 100644
--- a/drivers/char/ip2main.c
+++ b/drivers/char/ip2main.c
@@ -721,8 +721,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
721 } 721 }
722 722
723 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) { 723 if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
724 class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR, 724 class_device_create(ip2_class, NULL,
725 4 * i), NULL, "ipl%d", i); 725 MKDEV(IP2_IPL_MAJOR, 4 * i),
726 NULL, "ipl%d", i);
726 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i), 727 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i),
727 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, 728 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
728 "ip2/ipl%d", i); 729 "ip2/ipl%d", i);
@@ -732,8 +733,9 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
732 goto out_class; 733 goto out_class;
733 } 734 }
734 735
735 class_device_create(ip2_class, MKDEV(IP2_IPL_MAJOR, 736 class_device_create(ip2_class, NULL,
736 4 * i + 1), NULL, "stat%d", i); 737 MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
738 NULL, "stat%d", i);
737 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 739 err = devfs_mk_cdev(MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
738 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR, 740 S_IRUSR | S_IWUSR | S_IRGRP | S_IFCHR,
739 "ip2/stat%d", i); 741 "ip2/stat%d", i);
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index a09ff1080687..7c0684deea06 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -798,7 +798,7 @@ static void ipmi_new_smi(int if_num)
798 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR, 798 devfs_mk_cdev(dev, S_IFCHR | S_IRUSR | S_IWUSR,
799 "ipmidev/%d", if_num); 799 "ipmidev/%d", if_num);
800 800
801 class_device_create(ipmi_class, dev, NULL, "ipmi%d", if_num); 801 class_device_create(ipmi_class, NULL, dev, NULL, "ipmi%d", if_num);
802} 802}
803 803
804static void ipmi_smi_gone(int if_num) 804static void ipmi_smi_gone(int if_num)
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 9c19e5435a11..e3ddbdb85a2f 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -5246,7 +5246,8 @@ int __init stli_init(void)
5246 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), 5246 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
5247 S_IFCHR | S_IRUSR | S_IWUSR, 5247 S_IFCHR | S_IRUSR | S_IWUSR,
5248 "staliomem/%d", i); 5248 "staliomem/%d", i);
5249 class_device_create(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), 5249 class_device_create(istallion_class, NULL,
5250 MKDEV(STL_SIOMEMMAJOR, i),
5250 NULL, "staliomem%d", i); 5251 NULL, "staliomem%d", i);
5251 } 5252 }
5252 5253
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 2afb9038dbc5..e57260525293 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -805,7 +805,7 @@ static int lp_register(int nr, struct parport *port)
805 if (reset) 805 if (reset)
806 lp_reset(nr); 806 lp_reset(nr);
807 807
808 class_device_create(lp_class, MKDEV(LP_MAJOR, nr), NULL, 808 class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL,
809 "lp%d", nr); 809 "lp%d", nr);
810 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, 810 devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
811 "printers/%d", nr); 811 "printers/%d", nr);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index f182752fe918..38be4b0dbd1c 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -920,7 +920,8 @@ static int __init chr_dev_init(void)
920 920
921 mem_class = class_create(THIS_MODULE, "mem"); 921 mem_class = class_create(THIS_MODULE, "mem");
922 for (i = 0; i < ARRAY_SIZE(devlist); i++) { 922 for (i = 0; i < ARRAY_SIZE(devlist); i++) {
923 class_device_create(mem_class, MKDEV(MEM_MAJOR, devlist[i].minor), 923 class_device_create(mem_class, NULL,
924 MKDEV(MEM_MAJOR, devlist[i].minor),
924 NULL, devlist[i].name); 925 NULL, devlist[i].name);
925 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor), 926 devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
926 S_IFCHR | devlist[i].mode, devlist[i].name); 927 S_IFCHR | devlist[i].mode, devlist[i].name);
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 0c8375165e29..3e4c0414a01a 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -234,7 +234,7 @@ int misc_register(struct miscdevice * misc)
234 } 234 }
235 dev = MKDEV(MISC_MAJOR, misc->minor); 235 dev = MKDEV(MISC_MAJOR, misc->minor);
236 236
237 misc->class = class_device_create(misc_class, dev, misc->dev, 237 misc->class = class_device_create(misc_class, NULL, dev, misc->dev,
238 "%s", misc->name); 238 "%s", misc->name);
239 if (IS_ERR(misc->class)) { 239 if (IS_ERR(misc->class)) {
240 err = PTR_ERR(misc->class); 240 err = PTR_ERR(misc->class);
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index c9bdf544ed2c..c556f4d3ccd7 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -62,7 +62,7 @@
62 62
63static inline unsigned char *alloc_buf(void) 63static inline unsigned char *alloc_buf(void)
64{ 64{
65 unsigned int prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 65 gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
66 66
67 if (PAGE_SIZE != N_TTY_BUF_SIZE) 67 if (PAGE_SIZE != N_TTY_BUF_SIZE)
68 return kmalloc(N_TTY_BUF_SIZE, prio); 68 return kmalloc(N_TTY_BUF_SIZE, prio);
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 1af733d07321..9e24bbd4090c 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -32,9 +32,11 @@
32 * added changelog 32 * added changelog
33 * 1.2 Erik Gilling: Cobalt Networks support 33 * 1.2 Erik Gilling: Cobalt Networks support
34 * Tim Hockin: general cleanup, Cobalt support 34 * Tim Hockin: general cleanup, Cobalt support
35 * 1.3 Jon Ringle: Comdial MP1000 support
36 *
35 */ 37 */
36 38
37#define NVRAM_VERSION "1.2" 39#define NVRAM_VERSION "1.3"
38 40
39#include <linux/module.h> 41#include <linux/module.h>
40#include <linux/config.h> 42#include <linux/config.h>
@@ -45,6 +47,7 @@
45#define PC 1 47#define PC 1
46#define ATARI 2 48#define ATARI 2
47#define COBALT 3 49#define COBALT 3
50#define MP1000 4
48 51
49/* select machine configuration */ 52/* select machine configuration */
50#if defined(CONFIG_ATARI) 53#if defined(CONFIG_ATARI)
@@ -54,6 +57,9 @@
54# if defined(CONFIG_COBALT) 57# if defined(CONFIG_COBALT)
55# include <linux/cobalt-nvram.h> 58# include <linux/cobalt-nvram.h>
56# define MACH COBALT 59# define MACH COBALT
60# elif defined(CONFIG_MACH_MP1000)
61# undef MACH
62# define MACH MP1000
57# else 63# else
58# define MACH PC 64# define MACH PC
59# endif 65# endif
@@ -112,6 +118,23 @@
112 118
113#endif 119#endif
114 120
121#if MACH == MP1000
122
123/* RTC in a MP1000 */
124#define CHECK_DRIVER_INIT() 1
125
126#define MP1000_CKS_RANGE_START 0
127#define MP1000_CKS_RANGE_END 111
128#define MP1000_CKS_LOC 112
129
130#define NVRAM_BYTES (128-NVRAM_FIRST_BYTE)
131
132#define mach_check_checksum mp1000_check_checksum
133#define mach_set_checksum mp1000_set_checksum
134#define mach_proc_infos mp1000_proc_infos
135
136#endif
137
115/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with 138/* Note that *all* calls to CMOS_READ and CMOS_WRITE must be done with
116 * rtc_lock held. Due to the index-port/data-port design of the RTC, we 139 * rtc_lock held. Due to the index-port/data-port design of the RTC, we
117 * don't want two different things trying to get to it at once. (e.g. the 140 * don't want two different things trying to get to it at once. (e.g. the
@@ -915,6 +938,91 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len,
915 938
916#endif /* MACH == ATARI */ 939#endif /* MACH == ATARI */
917 940
941#if MACH == MP1000
942
943static int
944mp1000_check_checksum(void)
945{
946 int i;
947 unsigned short sum = 0;
948 unsigned short expect;
949
950 for (i = MP1000_CKS_RANGE_START; i <= MP1000_CKS_RANGE_END; ++i)
951 sum += __nvram_read_byte(i);
952
953 expect = __nvram_read_byte(MP1000_CKS_LOC+1)<<8 |
954 __nvram_read_byte(MP1000_CKS_LOC);
955 return ((sum & 0xffff) == expect);
956}
957
958static void
959mp1000_set_checksum(void)
960{
961 int i;
962 unsigned short sum = 0;
963
964 for (i = MP1000_CKS_RANGE_START; i <= MP1000_CKS_RANGE_END; ++i)
965 sum += __nvram_read_byte(i);
966 __nvram_write_byte(sum >> 8, MP1000_CKS_LOC + 1);
967 __nvram_write_byte(sum & 0xff, MP1000_CKS_LOC);
968}
969
970#ifdef CONFIG_PROC_FS
971
972#define SERVER_N_LEN 32
973#define PATH_N_LEN 32
974#define FILE_N_LEN 32
975#define NVRAM_MAGIC_SIG 0xdead
976
977typedef struct NvRamImage
978{
979 unsigned short int magic;
980 unsigned short int mode;
981 char fname[FILE_N_LEN];
982 char path[PATH_N_LEN];
983 char server[SERVER_N_LEN];
984 char pad[12];
985} NvRam;
986
987static int
988mp1000_proc_infos(unsigned char *nvram, char *buffer, int *len,
989 off_t *begin, off_t offset, int size)
990{
991 int checksum;
992 NvRam* nv = (NvRam*)nvram;
993
994 spin_lock_irq(&rtc_lock);
995 checksum = __nvram_check_checksum();
996 spin_unlock_irq(&rtc_lock);
997
998 PRINT_PROC("Checksum status: %svalid\n", checksum ? "" : "not ");
999
1000 switch( nv->mode )
1001 {
1002 case 0 :
1003 PRINT_PROC( "\tMode 0, tftp prompt\n" );
1004 break;
1005 case 1 :
1006 PRINT_PROC( "\tMode 1, booting from disk\n" );
1007 break;
1008 case 2 :
1009 PRINT_PROC( "\tMode 2, Alternate boot from disk /boot/%s\n", nv->fname );
1010 break;
1011 case 3 :
1012 PRINT_PROC( "\tMode 3, Booting from net:\n" );
1013 PRINT_PROC( "\t\t%s:%s%s\n",nv->server, nv->path, nv->fname );
1014 break;
1015 default:
1016 PRINT_PROC( "\tInconsistant nvram?\n" );
1017 break;
1018 }
1019
1020 return 1;
1021}
1022#endif
1023
1024#endif /* MACH == MP1000 */
1025
918MODULE_LICENSE("GPL"); 1026MODULE_LICENSE("GPL");
919 1027
920EXPORT_SYMBOL(__nvram_read_byte); 1028EXPORT_SYMBOL(__nvram_read_byte);
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 0e22880432bc..306ee0f091a4 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -752,7 +752,7 @@ static struct file_operations pp_fops = {
752 752
753static void pp_attach(struct parport *port) 753static void pp_attach(struct parport *port)
754{ 754{
755 class_device_create(ppdev_class, MKDEV(PP_MAJOR, port->number), 755 class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
756 NULL, "parport%d", port->number); 756 NULL, "parport%d", port->number);
757} 757}
758 758
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index f13e5de02207..30e4cbe16bb0 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -128,7 +128,7 @@ raw_ioctl(struct inode *inode, struct file *filp,
128static void bind_device(struct raw_config_request *rq) 128static void bind_device(struct raw_config_request *rq)
129{ 129{
130 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 130 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
131 class_device_create(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor), 131 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
132 NULL, "raw%d", rq->raw_minor); 132 NULL, "raw%d", rq->raw_minor);
133} 133}
134 134
@@ -307,7 +307,7 @@ static int __init raw_init(void)
307 unregister_chrdev_region(dev, MAX_RAW_MINORS); 307 unregister_chrdev_region(dev, MAX_RAW_MINORS);
308 goto error; 308 goto error;
309 } 309 }
310 class_device_create(raw_class, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 310 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl");
311 311
312 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0), 312 devfs_mk_cdev(MKDEV(RAW_MAJOR, 0),
313 S_IFCHR | S_IRUGO | S_IWUGO, 313 S_IFCHR | S_IRUGO | S_IWUGO,
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index e1a90d9a8756..887b8b2d7882 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -519,30 +519,28 @@ static struct timespec s3c2410_rtc_delta;
519 519
520static int ticnt_save; 520static int ticnt_save;
521 521
522static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state, u32 level) 522static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state)
523{ 523{
524 struct rtc_time tm; 524 struct rtc_time tm;
525 struct timespec time; 525 struct timespec time;
526 526
527 time.tv_nsec = 0; 527 time.tv_nsec = 0;
528 528
529 if (level == SUSPEND_POWER_DOWN) { 529 /* save TICNT for anyone using periodic interrupts */
530 /* save TICNT for anyone using periodic interrupts */
531 530
532 ticnt_save = readb(S3C2410_TICNT); 531 ticnt_save = readb(S3C2410_TICNT);
533 532
534 /* calculate time delta for suspend */ 533 /* calculate time delta for suspend */
535 534
536 s3c2410_rtc_gettime(&tm); 535 s3c2410_rtc_gettime(&tm);
537 rtc_tm_to_time(&tm, &time.tv_sec); 536 rtc_tm_to_time(&tm, &time.tv_sec);
538 save_time_delta(&s3c2410_rtc_delta, &time); 537 save_time_delta(&s3c2410_rtc_delta, &time);
539 s3c2410_rtc_enable(dev, 0); 538 s3c2410_rtc_enable(dev, 0);
540 }
541 539
542 return 0; 540 return 0;
543} 541}
544 542
545static int s3c2410_rtc_resume(struct device *dev, u32 level) 543static int s3c2410_rtc_resume(struct device *dev)
546{ 544{
547 struct rtc_time tm; 545 struct rtc_time tm;
548 struct timespec time; 546 struct timespec time;
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index a025a89ea70a..0e7d216e7eb0 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -437,7 +437,7 @@ scdrv_init(void)
437 continue; 437 continue;
438 } 438 }
439 439
440 class_device_create(snsc_class, dev, NULL, 440 class_device_create(snsc_class, NULL, dev, NULL,
441 "%s", devname); 441 "%s", devname);
442 442
443 ia64_sn_irtr_intr_enable(scd->scd_nasid, 443 ia64_sn_irtr_intr_enable(scd->scd_nasid,
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 36ae9ad2598c..f86c15587238 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -424,10 +424,6 @@ static struct sonypi_eventtypes {
424 424
425#define SONYPI_BUF_SIZE 128 425#define SONYPI_BUF_SIZE 128
426 426
427/* The name of the devices for the input device drivers */
428#define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial"
429#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys"
430
431/* Correspondance table between sonypi events and input layer events */ 427/* Correspondance table between sonypi events and input layer events */
432static struct { 428static struct {
433 int sonypiev; 429 int sonypiev;
@@ -490,8 +486,8 @@ static struct sonypi_device {
490 struct fasync_struct *fifo_async; 486 struct fasync_struct *fifo_async;
491 int open_count; 487 int open_count;
492 int model; 488 int model;
493 struct input_dev input_jog_dev; 489 struct input_dev *input_jog_dev;
494 struct input_dev input_key_dev; 490 struct input_dev *input_key_dev;
495 struct work_struct input_work; 491 struct work_struct input_work;
496 struct kfifo *input_fifo; 492 struct kfifo *input_fifo;
497 spinlock_t input_fifo_lock; 493 spinlock_t input_fifo_lock;
@@ -779,8 +775,8 @@ static void input_keyrelease(void *data)
779 775
780static void sonypi_report_input_event(u8 event) 776static void sonypi_report_input_event(u8 event)
781{ 777{
782 struct input_dev *jog_dev = &sonypi_device.input_jog_dev; 778 struct input_dev *jog_dev = sonypi_device.input_jog_dev;
783 struct input_dev *key_dev = &sonypi_device.input_key_dev; 779 struct input_dev *key_dev = sonypi_device.input_key_dev;
784 struct sonypi_keypress kp = { NULL }; 780 struct sonypi_keypress kp = { NULL };
785 int i; 781 int i;
786 782
@@ -1171,19 +1167,17 @@ static int sonypi_disable(void)
1171#ifdef CONFIG_PM 1167#ifdef CONFIG_PM
1172static int old_camera_power; 1168static int old_camera_power;
1173 1169
1174static int sonypi_suspend(struct device *dev, pm_message_t state, u32 level) 1170static int sonypi_suspend(struct device *dev, pm_message_t state)
1175{ 1171{
1176 if (level == SUSPEND_DISABLE) { 1172 old_camera_power = sonypi_device.camera_power;
1177 old_camera_power = sonypi_device.camera_power; 1173 sonypi_disable();
1178 sonypi_disable(); 1174
1179 }
1180 return 0; 1175 return 0;
1181} 1176}
1182 1177
1183static int sonypi_resume(struct device *dev, u32 level) 1178static int sonypi_resume(struct device *dev)
1184{ 1179{
1185 if (level == RESUME_ENABLE) 1180 sonypi_enable(old_camera_power);
1186 sonypi_enable(old_camera_power);
1187 return 0; 1181 return 0;
1188} 1182}
1189#endif 1183#endif
@@ -1203,6 +1197,47 @@ static struct device_driver sonypi_driver = {
1203 .shutdown = sonypi_shutdown, 1197 .shutdown = sonypi_shutdown,
1204}; 1198};
1205 1199
1200static int __devinit sonypi_create_input_devices(void)
1201{
1202 struct input_dev *jog_dev;
1203 struct input_dev *key_dev;
1204 int i;
1205
1206 sonypi_device.input_jog_dev = jog_dev = input_allocate_device();
1207 if (!jog_dev)
1208 return -ENOMEM;
1209
1210 jog_dev->name = "Sony Vaio Jogdial";
1211 jog_dev->id.bustype = BUS_ISA;
1212 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
1213
1214 jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
1215 jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
1216 jog_dev->relbit[0] = BIT(REL_WHEEL);
1217
1218 sonypi_device.input_key_dev = key_dev = input_allocate_device();
1219 if (!key_dev) {
1220 input_free_device(jog_dev);
1221 sonypi_device.input_jog_dev = NULL;
1222 return -ENOMEM;
1223 }
1224
1225 key_dev->name = "Sony Vaio Keys";
1226 key_dev->id.bustype = BUS_ISA;
1227 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
1228
1229 /* Initialize the Input Drivers: special keys */
1230 key_dev->evbit[0] = BIT(EV_KEY);
1231 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
1232 if (sonypi_inputkeys[i].inputev)
1233 set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit);
1234
1235 input_register_device(jog_dev);
1236 input_register_device(key_dev);
1237
1238 return 0;
1239}
1240
1206static int __devinit sonypi_probe(void) 1241static int __devinit sonypi_probe(void)
1207{ 1242{
1208 int i, ret; 1243 int i, ret;
@@ -1298,34 +1333,10 @@ static int __devinit sonypi_probe(void)
1298 } 1333 }
1299 1334
1300 if (useinput) { 1335 if (useinput) {
1301 /* Initialize the Input Drivers: jogdial */
1302 int i;
1303 sonypi_device.input_jog_dev.evbit[0] =
1304 BIT(EV_KEY) | BIT(EV_REL);
1305 sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
1306 BIT(BTN_MIDDLE);
1307 sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
1308 sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
1309 sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
1310 sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
1311
1312 input_register_device(&sonypi_device.input_jog_dev);
1313 printk(KERN_INFO "%s input method installed.\n",
1314 sonypi_device.input_jog_dev.name);
1315
1316 /* Initialize the Input Drivers: special keys */
1317 sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);
1318 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
1319 if (sonypi_inputkeys[i].inputev)
1320 set_bit(sonypi_inputkeys[i].inputev,
1321 sonypi_device.input_key_dev.keybit);
1322 sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
1323 sonypi_device.input_key_dev.id.bustype = BUS_ISA;
1324 sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
1325 1336
1326 input_register_device(&sonypi_device.input_key_dev); 1337 ret = sonypi_create_input_devices();
1327 printk(KERN_INFO "%s input method installed.\n", 1338 if (ret)
1328 sonypi_device.input_key_dev.name); 1339 goto out_inputdevices;
1329 1340
1330 spin_lock_init(&sonypi_device.input_fifo_lock); 1341 spin_lock_init(&sonypi_device.input_fifo_lock);
1331 sonypi_device.input_fifo = 1342 sonypi_device.input_fifo =
@@ -1375,8 +1386,9 @@ static int __devinit sonypi_probe(void)
1375out_platformdev: 1386out_platformdev:
1376 kfifo_free(sonypi_device.input_fifo); 1387 kfifo_free(sonypi_device.input_fifo);
1377out_infifo: 1388out_infifo:
1378 input_unregister_device(&sonypi_device.input_key_dev); 1389 input_unregister_device(sonypi_device.input_key_dev);
1379 input_unregister_device(&sonypi_device.input_jog_dev); 1390 input_unregister_device(sonypi_device.input_jog_dev);
1391out_inputdevices:
1380 free_irq(sonypi_device.irq, sonypi_irq); 1392 free_irq(sonypi_device.irq, sonypi_irq);
1381out_reqirq: 1393out_reqirq:
1382 release_region(sonypi_device.ioport1, sonypi_device.region_size); 1394 release_region(sonypi_device.ioport1, sonypi_device.region_size);
@@ -1402,8 +1414,8 @@ static void __devexit sonypi_remove(void)
1402 platform_device_unregister(sonypi_device.pdev); 1414 platform_device_unregister(sonypi_device.pdev);
1403 1415
1404 if (useinput) { 1416 if (useinput) {
1405 input_unregister_device(&sonypi_device.input_key_dev); 1417 input_unregister_device(sonypi_device.input_key_dev);
1406 input_unregister_device(&sonypi_device.input_jog_dev); 1418 input_unregister_device(sonypi_device.input_jog_dev);
1407 kfifo_free(sonypi_device.input_fifo); 1419 kfifo_free(sonypi_device.input_fifo);
1408 } 1420 }
1409 1421
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 951545a6ef2d..1c686414e0a1 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -3095,7 +3095,9 @@ static int __init stl_init(void)
3095 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i), 3095 devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
3096 S_IFCHR|S_IRUSR|S_IWUSR, 3096 S_IFCHR|S_IRUSR|S_IWUSR,
3097 "staliomem/%d", i); 3097 "staliomem/%d", i);
3098 class_device_create(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i); 3098 class_device_create(stallion_class, NULL,
3099 MKDEV(STL_SIOMEMMAJOR, i), NULL,
3100 "staliomem%d", i);
3099 } 3101 }
3100 3102
3101 stl_serial->owner = THIS_MODULE; 3103 stl_serial->owner = THIS_MODULE;
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c
index ec78d2f161f7..41a94bc79f67 100644
--- a/drivers/char/tipar.c
+++ b/drivers/char/tipar.c
@@ -436,7 +436,7 @@ tipar_register(int nr, struct parport *port)
436 goto out; 436 goto out;
437 } 437 }
438 438
439 class_device_create(tipar_class, MKDEV(TIPAR_MAJOR, 439 class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR,
440 TIPAR_MINOR + nr), NULL, "par%d", nr); 440 TIPAR_MINOR + nr), NULL, "par%d", nr);
441 /* Use devfs, tree: /dev/ticables/par/[0..2] */ 441 /* Use devfs, tree: /dev/ticables/par/[0..2] */
442 err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), 442 err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index e5953f3433f3..f5649a337743 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2728,7 +2728,7 @@ void tty_register_device(struct tty_driver *driver, unsigned index,
2728 pty_line_name(driver, index, name); 2728 pty_line_name(driver, index, name);
2729 else 2729 else
2730 tty_line_name(driver, index, name); 2730 tty_line_name(driver, index, name);
2731 class_device_create(tty_class, dev, device, name); 2731 class_device_create(tty_class, NULL, dev, device, "%s", name);
2732} 2732}
2733 2733
2734/** 2734/**
@@ -2983,14 +2983,14 @@ static int __init tty_init(void)
2983 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 2983 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
2984 panic("Couldn't register /dev/tty driver\n"); 2984 panic("Couldn't register /dev/tty driver\n");
2985 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty"); 2985 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 0), S_IFCHR|S_IRUGO|S_IWUGO, "tty");
2986 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); 2986 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
2987 2987
2988 cdev_init(&console_cdev, &console_fops); 2988 cdev_init(&console_cdev, &console_fops);
2989 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 2989 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
2990 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 2990 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
2991 panic("Couldn't register /dev/console driver\n"); 2991 panic("Couldn't register /dev/console driver\n");
2992 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console"); 2992 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
2993 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); 2993 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
2994 2994
2995#ifdef CONFIG_UNIX98_PTYS 2995#ifdef CONFIG_UNIX98_PTYS
2996 cdev_init(&ptmx_cdev, &ptmx_fops); 2996 cdev_init(&ptmx_cdev, &ptmx_fops);
@@ -2998,7 +2998,7 @@ static int __init tty_init(void)
2998 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 2998 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
2999 panic("Couldn't register /dev/ptmx driver\n"); 2999 panic("Couldn't register /dev/ptmx driver\n");
3000 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx"); 3000 devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 2), S_IFCHR|S_IRUGO|S_IWUGO, "ptmx");
3001 class_device_create(tty_class, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); 3001 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
3002#endif 3002#endif
3003 3003
3004#ifdef CONFIG_VT 3004#ifdef CONFIG_VT
@@ -3007,7 +3007,7 @@ static int __init tty_init(void)
3007 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 3007 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3008 panic("Couldn't register /dev/tty0 driver\n"); 3008 panic("Couldn't register /dev/tty0 driver\n");
3009 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0"); 3009 devfs_mk_cdev(MKDEV(TTY_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vc/0");
3010 class_device_create(tty_class, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 3010 class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
3011 3011
3012 vty_init(); 3012 vty_init();
3013#endif 3013#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 79c2928a8817..f66c7ad6fd38 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -484,8 +484,10 @@ void vcs_make_devfs(struct tty_struct *tty)
484 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129), 484 devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
485 S_IFCHR|S_IRUSR|S_IWUSR, 485 S_IFCHR|S_IRUSR|S_IWUSR,
486 "vcc/a%u", tty->index + 1); 486 "vcc/a%u", tty->index + 1);
487 class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1); 487 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
488 class_device_create(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1); 488 NULL, "vcs%u", tty->index + 1);
489 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
490 NULL, "vcsa%u", tty->index + 1);
489} 491}
490void vcs_remove_devfs(struct tty_struct *tty) 492void vcs_remove_devfs(struct tty_struct *tty)
491{ 493{
@@ -503,7 +505,7 @@ int __init vcs_init(void)
503 505
504 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0"); 506 devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
505 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0"); 507 devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
506 class_device_create(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 508 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
507 class_device_create(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 509 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
508 return 0; 510 return 0;
509} 511}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 0aff45fac2e6..a5e104f428f8 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -956,9 +956,9 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
956 state[i].cur_part = 0; 956 state[i].cur_part = 0;
957 for (j = 0; j < MAX_PARTITIONS; ++j) 957 for (j = 0; j < MAX_PARTITIONS; ++j)
958 state[i].part_stat_rwi[j] = VIOT_IDLE; 958 state[i].part_stat_rwi[j] = VIOT_IDLE;
959 class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i), NULL, 959 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL,
960 "iseries!vt%d", i); 960 "iseries!vt%d", i);
961 class_device_create(tape_class, MKDEV(VIOTAPE_MAJOR, i | 0x80), 961 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
962 NULL, "iseries!nvt%d", i); 962 NULL, "iseries!nvt%d", i);
963 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR, 963 devfs_mk_cdev(MKDEV(VIOTAPE_MAJOR, i), S_IFCHR | S_IRUSR | S_IWUSR,
964 "iseries/vt%d", i); 964 "iseries/vt%d", i);
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 3625b2601b42..b732020acadb 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -464,32 +464,28 @@ static void s3c2410wdt_shutdown(struct device *dev)
464static unsigned long wtcon_save; 464static unsigned long wtcon_save;
465static unsigned long wtdat_save; 465static unsigned long wtdat_save;
466 466
467static int s3c2410wdt_suspend(struct device *dev, pm_message_t state, u32 level) 467static int s3c2410wdt_suspend(struct device *dev, pm_message_t state)
468{ 468{
469 if (level == SUSPEND_POWER_DOWN) { 469 /* Save watchdog state, and turn it off. */
470 /* Save watchdog state, and turn it off. */ 470 wtcon_save = readl(wdt_base + S3C2410_WTCON);
471 wtcon_save = readl(wdt_base + S3C2410_WTCON); 471 wtdat_save = readl(wdt_base + S3C2410_WTDAT);
472 wtdat_save = readl(wdt_base + S3C2410_WTDAT);
473 472
474 /* Note that WTCNT doesn't need to be saved. */ 473 /* Note that WTCNT doesn't need to be saved. */
475 s3c2410wdt_stop(); 474 s3c2410wdt_stop();
476 }
477 475
478 return 0; 476 return 0;
479} 477}
480 478
481static int s3c2410wdt_resume(struct device *dev, u32 level) 479static int s3c2410wdt_resume(struct device *dev)
482{ 480{
483 if (level == RESUME_POWER_ON) { 481 /* Restore watchdog state. */
484 /* Restore watchdog state. */
485 482
486 writel(wtdat_save, wdt_base + S3C2410_WTDAT); 483 writel(wtdat_save, wdt_base + S3C2410_WTDAT);
487 writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ 484 writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */
488 writel(wtcon_save, wdt_base + S3C2410_WTCON); 485 writel(wtcon_save, wdt_base + S3C2410_WTCON);
489 486
490 printk(KERN_INFO PFX "watchdog %sabled\n", 487 printk(KERN_INFO PFX "watchdog %sabled\n",
491 (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); 488 (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis");
492 }
493 489
494 return 0; 490 return 0;
495} 491}
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index e928cdb041cb..8102876c7c3f 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -121,7 +121,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg,
121static struct adm1021_data *adm1021_update_device(struct device *dev); 121static struct adm1021_data *adm1021_update_device(struct device *dev);
122 122
123/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ 123/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */
124static int read_only = 0; 124static int read_only;
125 125
126 126
127/* This is the driver that will be inserted */ 127/* This is the driver that will be inserted */
@@ -204,11 +204,10 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
204 client structure, even though we cannot fill it completely yet. 204 client structure, even though we cannot fill it completely yet.
205 But it allows us to access adm1021_{read,write}_value. */ 205 But it allows us to access adm1021_{read,write}_value. */
206 206
207 if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) { 207 if (!(data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL))) {
208 err = -ENOMEM; 208 err = -ENOMEM;
209 goto error0; 209 goto error0;
210 } 210 }
211 memset(data, 0, sizeof(struct adm1021_data));
212 211
213 new_client = &data->client; 212 new_client = &data->client;
214 i2c_set_clientdata(new_client, data); 213 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 526b7ff179eb..3ec12421694f 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -331,11 +331,10 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
331 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 331 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
332 goto exit; 332 goto exit;
333 333
334 if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) { 334 if (!(data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL))) {
335 err = -ENOMEM; 335 err = -ENOMEM;
336 goto exit; 336 goto exit;
337 } 337 }
338 memset(data, 0, sizeof(struct adm1025_data));
339 338
340 /* The common I2C client data is placed right before the 339 /* The common I2C client data is placed right before the
341 ADM1025-specific data. */ 340 ADM1025-specific data. */
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index 625158110fd4..e0f56549d1d8 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -315,7 +315,7 @@ static struct i2c_driver adm1026_driver = {
315 .detach_client = adm1026_detach_client, 315 .detach_client = adm1026_detach_client,
316}; 316};
317 317
318int adm1026_attach_adapter(struct i2c_adapter *adapter) 318static int adm1026_attach_adapter(struct i2c_adapter *adapter)
319{ 319{
320 if (!(adapter->class & I2C_CLASS_HWMON)) { 320 if (!(adapter->class & I2C_CLASS_HWMON)) {
321 return 0; 321 return 0;
@@ -323,7 +323,7 @@ int adm1026_attach_adapter(struct i2c_adapter *adapter)
323 return i2c_probe(adapter, &addr_data, adm1026_detect); 323 return i2c_probe(adapter, &addr_data, adm1026_detect);
324} 324}
325 325
326int adm1026_detach_client(struct i2c_client *client) 326static int adm1026_detach_client(struct i2c_client *client)
327{ 327{
328 struct adm1026_data *data = i2c_get_clientdata(client); 328 struct adm1026_data *data = i2c_get_clientdata(client);
329 hwmon_device_unregister(data->class_dev); 329 hwmon_device_unregister(data->class_dev);
@@ -332,7 +332,7 @@ int adm1026_detach_client(struct i2c_client *client)
332 return 0; 332 return 0;
333} 333}
334 334
335int adm1026_read_value(struct i2c_client *client, u8 reg) 335static int adm1026_read_value(struct i2c_client *client, u8 reg)
336{ 336{
337 int res; 337 int res;
338 338
@@ -346,7 +346,7 @@ int adm1026_read_value(struct i2c_client *client, u8 reg)
346 return res; 346 return res;
347} 347}
348 348
349int adm1026_write_value(struct i2c_client *client, u8 reg, int value) 349static int adm1026_write_value(struct i2c_client *client, u8 reg, int value)
350{ 350{
351 int res; 351 int res;
352 352
@@ -360,7 +360,7 @@ int adm1026_write_value(struct i2c_client *client, u8 reg, int value)
360 return res; 360 return res;
361} 361}
362 362
363void adm1026_init_client(struct i2c_client *client) 363static void adm1026_init_client(struct i2c_client *client)
364{ 364{
365 int value, i; 365 int value, i;
366 struct adm1026_data *data = i2c_get_clientdata(client); 366 struct adm1026_data *data = i2c_get_clientdata(client);
@@ -460,7 +460,7 @@ void adm1026_init_client(struct i2c_client *client)
460 } 460 }
461} 461}
462 462
463void adm1026_print_gpio(struct i2c_client *client) 463static void adm1026_print_gpio(struct i2c_client *client)
464{ 464{
465 struct adm1026_data *data = i2c_get_clientdata(client); 465 struct adm1026_data *data = i2c_get_clientdata(client);
466 int i; 466 int i;
@@ -492,7 +492,7 @@ void adm1026_print_gpio(struct i2c_client *client)
492 } 492 }
493} 493}
494 494
495void adm1026_fixup_gpio(struct i2c_client *client) 495static void adm1026_fixup_gpio(struct i2c_client *client)
496{ 496{
497 struct adm1026_data *data = i2c_get_clientdata(client); 497 struct adm1026_data *data = i2c_get_clientdata(client);
498 int i; 498 int i;
@@ -1452,8 +1452,8 @@ static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
1452static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); 1452static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
1453static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); 1453static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL);
1454 1454
1455int adm1026_detect(struct i2c_adapter *adapter, int address, 1455static int adm1026_detect(struct i2c_adapter *adapter, int address,
1456 int kind) 1456 int kind)
1457{ 1457{
1458 int company, verstep; 1458 int company, verstep;
1459 struct i2c_client *new_client; 1459 struct i2c_client *new_client;
@@ -1470,13 +1470,11 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1470 client structure, even though we cannot fill it completely yet. 1470 client structure, even though we cannot fill it completely yet.
1471 But it allows us to access adm1026_{read,write}_value. */ 1471 But it allows us to access adm1026_{read,write}_value. */
1472 1472
1473 if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) { 1473 if (!(data = kzalloc(sizeof(struct adm1026_data), GFP_KERNEL))) {
1474 err = -ENOMEM; 1474 err = -ENOMEM;
1475 goto exit; 1475 goto exit;
1476 } 1476 }
1477 1477
1478 memset(data, 0, sizeof(struct adm1026_data));
1479
1480 new_client = &data->client; 1478 new_client = &data->client;
1481 i2c_set_clientdata(new_client, data); 1479 i2c_set_clientdata(new_client, data);
1482 new_client->addr = address; 1480 new_client->addr = address;
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index 58338ed7c8a1..7c545d5eee45 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -740,11 +740,10 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
740 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 740 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
741 goto exit; 741 goto exit;
742 742
743 if (!(data = kmalloc(sizeof(struct adm1031_data), GFP_KERNEL))) { 743 if (!(data = kzalloc(sizeof(struct adm1031_data), GFP_KERNEL))) {
744 err = -ENOMEM; 744 err = -ENOMEM;
745 goto exit; 745 goto exit;
746 } 746 }
747 memset(data, 0, sizeof(struct adm1031_data));
748 747
749 new_client = &data->client; 748 new_client = &data->client;
750 i2c_set_clientdata(new_client, data); 749 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index bc7faef162f7..11dc95f8a17e 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -45,6 +45,7 @@
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/i2c.h> 47#include <linux/i2c.h>
48#include <linux/hwmon-sysfs.h>
48#include <linux/hwmon.h> 49#include <linux/hwmon.h>
49#include <linux/hwmon-vid.h> 50#include <linux/hwmon-vid.h>
50#include <linux/err.h> 51#include <linux/err.h>
@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81);
69#define ADM9240_REG_INT(nr) (0x41 + (nr)) 70#define ADM9240_REG_INT(nr) (0x41 + (nr))
70#define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) 71#define ADM9240_REG_INT_MASK(nr) (0x43 + (nr))
71#define ADM9240_REG_TEMP 0x27 72#define ADM9240_REG_TEMP 0x27
72#define ADM9240_REG_TEMP_HIGH 0x39 73#define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */
73#define ADM9240_REG_TEMP_HYST 0x3a
74#define ADM9240_REG_ANALOG_OUT 0x19 74#define ADM9240_REG_ANALOG_OUT 0x19
75#define ADM9240_REG_CHASSIS_CLEAR 0x46 75#define ADM9240_REG_CHASSIS_CLEAR 0x46
76#define ADM9240_REG_VID_FAN_DIV 0x47 76#define ADM9240_REG_VID_FAN_DIV 0x47
@@ -162,177 +162,155 @@ struct adm9240_data {
162 u8 fan_min[2]; /* rw fan1_min */ 162 u8 fan_min[2]; /* rw fan1_min */
163 u8 fan_div[2]; /* rw fan1_div, read-only accessor */ 163 u8 fan_div[2]; /* rw fan1_div, read-only accessor */
164 s16 temp; /* ro temp1_input, 9-bit sign-extended */ 164 s16 temp; /* ro temp1_input, 9-bit sign-extended */
165 s8 temp_high; /* rw temp1_max */ 165 s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */
166 s8 temp_hyst; /* rw temp1_max_hyst */
167 u16 alarms; /* ro alarms */ 166 u16 alarms; /* ro alarms */
168 u8 aout; /* rw aout_output */ 167 u8 aout; /* rw aout_output */
169 u8 vid; /* ro vid */ 168 u8 vid; /* ro vid */
170 u8 vrm; /* -- vrm set on startup, no accessor */ 169 u8 vrm; /* -- vrm set on startup, no accessor */
171}; 170};
172 171
173/* i2c byte read/write interface */ 172/*** sysfs accessors ***/
174static int adm9240_read_value(struct i2c_client *client, u8 reg) 173
174/* temperature */
175static ssize_t show_temp(struct device *dev, struct device_attribute *dummy,
176 char *buf)
175{ 177{
176 return i2c_smbus_read_byte_data(client, reg); 178 struct adm9240_data *data = adm9240_update_device(dev);
179 return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */
177} 180}
178 181
179static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) 182static ssize_t show_max(struct device *dev, struct device_attribute *devattr,
183 char *buf)
180{ 184{
181 return i2c_smbus_write_byte_data(client, reg, value); 185 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
186 struct adm9240_data *data = adm9240_update_device(dev);
187 return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000);
182} 188}
183 189
184/*** sysfs accessors ***/ 190static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
191 const char *buf, size_t count)
192{
193 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
194 struct i2c_client *client = to_i2c_client(dev);
195 struct adm9240_data *data = i2c_get_clientdata(client);
196 long val = simple_strtol(buf, NULL, 10);
197
198 down(&data->update_lock);
199 data->temp_max[attr->index] = TEMP_TO_REG(val);
200 i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
201 data->temp_max[attr->index]);
202 up(&data->update_lock);
203 return count;
204}
185 205
186/* temperature */
187#define show_temp(value, scale) \
188static ssize_t show_##value(struct device *dev, \
189 struct device_attribute *attr, \
190 char *buf) \
191{ \
192 struct adm9240_data *data = adm9240_update_device(dev); \
193 return sprintf(buf, "%d\n", data->value * scale); \
194}
195show_temp(temp_high, 1000);
196show_temp(temp_hyst, 1000);
197show_temp(temp, 500); /* 0.5'C per bit */
198
199#define set_temp(value, reg) \
200static ssize_t set_##value(struct device *dev, \
201 struct device_attribute *attr, \
202 const char *buf, size_t count) \
203{ \
204 struct i2c_client *client = to_i2c_client(dev); \
205 struct adm9240_data *data = adm9240_update_device(dev); \
206 long temp = simple_strtoul(buf, NULL, 10); \
207 \
208 down(&data->update_lock); \
209 data->value = TEMP_TO_REG(temp); \
210 adm9240_write_value(client, reg, data->value); \
211 up(&data->update_lock); \
212 return count; \
213}
214
215set_temp(temp_high, ADM9240_REG_TEMP_HIGH);
216set_temp(temp_hyst, ADM9240_REG_TEMP_HYST);
217
218static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
219 show_temp_high, set_temp_high);
220static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
221 show_temp_hyst, set_temp_hyst);
222static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); 206static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
207static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
208 show_max, set_max, 0);
209static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
210 show_max, set_max, 1);
223 211
224/* voltage */ 212/* voltage */
225static ssize_t show_in(struct device *dev, char *buf, int nr) 213static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
214 char *buf)
226{ 215{
216 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
227 struct adm9240_data *data = adm9240_update_device(dev); 217 struct adm9240_data *data = adm9240_update_device(dev);
228 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); 218 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index],
219 attr->index));
229} 220}
230 221
231static ssize_t show_in_min(struct device *dev, char *buf, int nr) 222static ssize_t show_in_min(struct device *dev,
223 struct device_attribute *devattr, char *buf)
232{ 224{
225 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
233 struct adm9240_data *data = adm9240_update_device(dev); 226 struct adm9240_data *data = adm9240_update_device(dev);
234 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); 227 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index],
228 attr->index));
235} 229}
236 230
237static ssize_t show_in_max(struct device *dev, char *buf, int nr) 231static ssize_t show_in_max(struct device *dev,
232 struct device_attribute *devattr, char *buf)
238{ 233{
234 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
239 struct adm9240_data *data = adm9240_update_device(dev); 235 struct adm9240_data *data = adm9240_update_device(dev);
240 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); 236 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index],
237 attr->index));
241} 238}
242 239
243static ssize_t set_in_min(struct device *dev, const char *buf, 240static ssize_t set_in_min(struct device *dev,
244 size_t count, int nr) 241 struct device_attribute *devattr,
242 const char *buf, size_t count)
245{ 243{
244 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
246 struct i2c_client *client = to_i2c_client(dev); 245 struct i2c_client *client = to_i2c_client(dev);
247 struct adm9240_data *data = i2c_get_clientdata(client); 246 struct adm9240_data *data = i2c_get_clientdata(client);
248 unsigned long val = simple_strtoul(buf, NULL, 10); 247 unsigned long val = simple_strtoul(buf, NULL, 10);
249 248
250 down(&data->update_lock); 249 down(&data->update_lock);
251 data->in_min[nr] = IN_TO_REG(val, nr); 250 data->in_min[attr->index] = IN_TO_REG(val, attr->index);
252 adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); 251 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
252 data->in_min[attr->index]);
253 up(&data->update_lock); 253 up(&data->update_lock);
254 return count; 254 return count;
255} 255}
256 256
257static ssize_t set_in_max(struct device *dev, const char *buf, 257static ssize_t set_in_max(struct device *dev,
258 size_t count, int nr) 258 struct device_attribute *devattr,
259 const char *buf, size_t count)
259{ 260{
261 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
260 struct i2c_client *client = to_i2c_client(dev); 262 struct i2c_client *client = to_i2c_client(dev);
261 struct adm9240_data *data = i2c_get_clientdata(client); 263 struct adm9240_data *data = i2c_get_clientdata(client);
262 unsigned long val = simple_strtoul(buf, NULL, 10); 264 unsigned long val = simple_strtoul(buf, NULL, 10);
263 265
264 down(&data->update_lock); 266 down(&data->update_lock);
265 data->in_max[nr] = IN_TO_REG(val, nr); 267 data->in_max[attr->index] = IN_TO_REG(val, attr->index);
266 adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); 268 i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
269 data->in_max[attr->index]);
267 up(&data->update_lock); 270 up(&data->update_lock);
268 return count; 271 return count;
269} 272}
270 273
271#define show_in_offset(offset) \ 274#define vin(nr) \
272static ssize_t show_in##offset(struct device *dev, \ 275static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \
273 struct device_attribute *attr, \ 276 show_in, NULL, nr); \
274 char *buf) \ 277static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \
275{ \ 278 show_in_min, set_in_min, nr); \
276 return show_in(dev, buf, offset); \ 279static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \
277} \ 280 show_in_max, set_in_max, nr);
278static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ 281
279static ssize_t show_in##offset##_min(struct device *dev, \ 282vin(0);
280 struct device_attribute *attr, \ 283vin(1);
281 char *buf) \ 284vin(2);
282{ \ 285vin(3);
283 return show_in_min(dev, buf, offset); \ 286vin(4);
284} \ 287vin(5);
285static ssize_t show_in##offset##_max(struct device *dev, \
286 struct device_attribute *attr, \
287 char *buf) \
288{ \
289 return show_in_max(dev, buf, offset); \
290} \
291static ssize_t \
292set_in##offset##_min(struct device *dev, \
293 struct device_attribute *attr, const char *buf, \
294 size_t count) \
295{ \
296 return set_in_min(dev, buf, count, offset); \
297} \
298static ssize_t \
299set_in##offset##_max(struct device *dev, \
300 struct device_attribute *attr, const char *buf, \
301 size_t count) \
302{ \
303 return set_in_max(dev, buf, count, offset); \
304} \
305static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
306 show_in##offset##_min, set_in##offset##_min); \
307static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
308 show_in##offset##_max, set_in##offset##_max);
309
310show_in_offset(0);
311show_in_offset(1);
312show_in_offset(2);
313show_in_offset(3);
314show_in_offset(4);
315show_in_offset(5);
316 288
317/* fans */ 289/* fans */
318static ssize_t show_fan(struct device *dev, char *buf, int nr) 290static ssize_t show_fan(struct device *dev,
291 struct device_attribute *devattr, char *buf)
319{ 292{
293 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
320 struct adm9240_data *data = adm9240_update_device(dev); 294 struct adm9240_data *data = adm9240_update_device(dev);
321 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 295 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
322 1 << data->fan_div[nr])); 296 1 << data->fan_div[attr->index]));
323} 297}
324 298
325static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 299static ssize_t show_fan_min(struct device *dev,
300 struct device_attribute *devattr, char *buf)
326{ 301{
302 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
327 struct adm9240_data *data = adm9240_update_device(dev); 303 struct adm9240_data *data = adm9240_update_device(dev);
328 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], 304 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index],
329 1 << data->fan_div[nr])); 305 1 << data->fan_div[attr->index]));
330} 306}
331 307
332static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 308static ssize_t show_fan_div(struct device *dev,
309 struct device_attribute *devattr, char *buf)
333{ 310{
311 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
334 struct adm9240_data *data = adm9240_update_device(dev); 312 struct adm9240_data *data = adm9240_update_device(dev);
335 return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); 313 return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]);
336} 314}
337 315
338/* write new fan div, callers must hold data->update_lock */ 316/* write new fan div, callers must hold data->update_lock */
@@ -341,16 +319,16 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr,
341{ 319{
342 u8 reg, old, shift = (nr + 2) * 2; 320 u8 reg, old, shift = (nr + 2) * 2;
343 321
344 reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); 322 reg = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
345 old = (reg >> shift) & 3; 323 old = (reg >> shift) & 3;
346 reg &= ~(3 << shift); 324 reg &= ~(3 << shift);
347 reg |= (fan_div << shift); 325 reg |= (fan_div << shift);
348 adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); 326 i2c_smbus_write_byte_data(client, ADM9240_REG_VID_FAN_DIV, reg);
349 dev_dbg(&client->dev, "fan%d clock divider changed from %u " 327 dev_dbg(&client->dev, "fan%d clock divider changed from %u "
350 "to %u\n", nr + 1, 1 << old, 1 << fan_div); 328 "to %u\n", nr + 1, 1 << old, 1 << fan_div);
351} 329}
352 330
353/* 331/*
354 * set fan speed low limit: 332 * set fan speed low limit:
355 * 333 *
356 * - value is zero: disable fan speed low limit alarm 334 * - value is zero: disable fan speed low limit alarm
@@ -361,12 +339,15 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr,
361 * - otherwise: select fan clock divider to suit fan speed low limit, 339 * - otherwise: select fan clock divider to suit fan speed low limit,
362 * measurement code may adjust registers to ensure fan speed reading 340 * measurement code may adjust registers to ensure fan speed reading
363 */ 341 */
364static ssize_t set_fan_min(struct device *dev, const char *buf, 342static ssize_t set_fan_min(struct device *dev,
365 size_t count, int nr) 343 struct device_attribute *devattr,
344 const char *buf, size_t count)
366{ 345{
346 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
367 struct i2c_client *client = to_i2c_client(dev); 347 struct i2c_client *client = to_i2c_client(dev);
368 struct adm9240_data *data = i2c_get_clientdata(client); 348 struct adm9240_data *data = i2c_get_clientdata(client);
369 unsigned long val = simple_strtoul(buf, NULL, 10); 349 unsigned long val = simple_strtoul(buf, NULL, 10);
350 int nr = attr->index;
370 u8 new_div; 351 u8 new_div;
371 352
372 down(&data->update_lock); 353 down(&data->update_lock);
@@ -406,50 +387,27 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
406 data->fan_div[nr] = new_div; 387 data->fan_div[nr] = new_div;
407 adm9240_write_fan_div(client, nr, new_div); 388 adm9240_write_fan_div(client, nr, new_div);
408 } 389 }
409 adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), 390 i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
410 data->fan_min[nr]); 391 data->fan_min[nr]);
411 392
412 up(&data->update_lock); 393 up(&data->update_lock);
413 return count; 394 return count;
414} 395}
415 396
416#define show_fan_offset(offset) \ 397#define fan(nr) \
417static ssize_t show_fan_##offset (struct device *dev, \ 398static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \
418 struct device_attribute *attr, \ 399 show_fan, NULL, nr - 1); \
419 char *buf) \ 400static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \
420{ \ 401 show_fan_div, NULL, nr - 1); \
421return show_fan(dev, buf, offset - 1); \ 402static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \
422} \ 403 show_fan_min, set_fan_min, nr - 1);
423static ssize_t show_fan_##offset##_div (struct device *dev, \ 404
424 struct device_attribute *attr, \ 405fan(1);
425 char *buf) \ 406fan(2);
426{ \
427return show_fan_div(dev, buf, offset - 1); \
428} \
429static ssize_t show_fan_##offset##_min (struct device *dev, \
430 struct device_attribute *attr, \
431 char *buf) \
432{ \
433return show_fan_min(dev, buf, offset - 1); \
434} \
435static ssize_t set_fan_##offset##_min (struct device *dev, \
436 struct device_attribute *attr, \
437 const char *buf, size_t count) \
438{ \
439return set_fan_min(dev, buf, count, offset - 1); \
440} \
441static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
442 show_fan_##offset, NULL); \
443static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
444 show_fan_##offset##_div, NULL); \
445static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
446 show_fan_##offset##_min, set_fan_##offset##_min);
447
448show_fan_offset(1);
449show_fan_offset(2);
450 407
451/* alarms */ 408/* alarms */
452static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 409static ssize_t show_alarms(struct device *dev,
410 struct device_attribute *attr, char *buf)
453{ 411{
454 struct adm9240_data *data = adm9240_update_device(dev); 412 struct adm9240_data *data = adm9240_update_device(dev);
455 return sprintf(buf, "%u\n", data->alarms); 413 return sprintf(buf, "%u\n", data->alarms);
@@ -457,7 +415,8 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
457static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 415static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
458 416
459/* vid */ 417/* vid */
460static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 418static ssize_t show_vid(struct device *dev,
419 struct device_attribute *attr, char *buf)
461{ 420{
462 struct adm9240_data *data = adm9240_update_device(dev); 421 struct adm9240_data *data = adm9240_update_device(dev);
463 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); 422 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
@@ -465,13 +424,16 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char
465static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 424static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
466 425
467/* analog output */ 426/* analog output */
468static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) 427static ssize_t show_aout(struct device *dev,
428 struct device_attribute *attr, char *buf)
469{ 429{
470 struct adm9240_data *data = adm9240_update_device(dev); 430 struct adm9240_data *data = adm9240_update_device(dev);
471 return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); 431 return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout));
472} 432}
473 433
474static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 434static ssize_t set_aout(struct device *dev,
435 struct device_attribute *attr,
436 const char *buf, size_t count)
475{ 437{
476 struct i2c_client *client = to_i2c_client(dev); 438 struct i2c_client *client = to_i2c_client(dev);
477 struct adm9240_data *data = i2c_get_clientdata(client); 439 struct adm9240_data *data = i2c_get_clientdata(client);
@@ -479,20 +441,23 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
479 441
480 down(&data->update_lock); 442 down(&data->update_lock);
481 data->aout = AOUT_TO_REG(val); 443 data->aout = AOUT_TO_REG(val);
482 adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); 444 i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
483 up(&data->update_lock); 445 up(&data->update_lock);
484 return count; 446 return count;
485} 447}
486static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 448static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
487 449
488/* chassis_clear */ 450/* chassis_clear */
489static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 451static ssize_t chassis_clear(struct device *dev,
452 struct device_attribute *attr,
453 const char *buf, size_t count)
490{ 454{
491 struct i2c_client *client = to_i2c_client(dev); 455 struct i2c_client *client = to_i2c_client(dev);
492 unsigned long val = simple_strtol(buf, NULL, 10); 456 unsigned long val = simple_strtol(buf, NULL, 10);
493 457
494 if (val == 1) { 458 if (val == 1) {
495 adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); 459 i2c_smbus_write_byte_data(client,
460 ADM9240_REG_CHASSIS_CLEAR, 0x80);
496 dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); 461 dev_dbg(&client->dev, "chassis intrusion latch cleared\n");
497 } 462 }
498 return count; 463 return count;
@@ -513,11 +478,10 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
513 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 478 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
514 goto exit; 479 goto exit;
515 480
516 if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { 481 if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {
517 err = -ENOMEM; 482 err = -ENOMEM;
518 goto exit; 483 goto exit;
519 } 484 }
520 memset(data, 0, sizeof(struct adm9240_data));
521 485
522 new_client = &data->client; 486 new_client = &data->client;
523 i2c_set_clientdata(new_client, data); 487 i2c_set_clientdata(new_client, data);
@@ -533,7 +497,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
533 if (kind < 0) { 497 if (kind < 0) {
534 498
535 /* verify chip: reg address should match i2c address */ 499 /* verify chip: reg address should match i2c address */
536 if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) 500 if (i2c_smbus_read_byte_data(new_client, ADM9240_REG_I2C_ADDR)
537 != address) { 501 != address) {
538 dev_err(&adapter->dev, "detect fail: address match, " 502 dev_err(&adapter->dev, "detect fail: address match, "
539 "0x%02x\n", address); 503 "0x%02x\n", address);
@@ -541,8 +505,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
541 } 505 }
542 506
543 /* check known chip manufacturer */ 507 /* check known chip manufacturer */
544 man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); 508 man_id = i2c_smbus_read_byte_data(new_client,
545 509 ADM9240_REG_MAN_ID);
546 if (man_id == 0x23) { 510 if (man_id == 0x23) {
547 kind = adm9240; 511 kind = adm9240;
548 } else if (man_id == 0xda) { 512 } else if (man_id == 0xda) {
@@ -556,7 +520,8 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
556 } 520 }
557 521
558 /* successful detect, print chip info */ 522 /* successful detect, print chip info */
559 die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); 523 die_rev = i2c_smbus_read_byte_data(new_client,
524 ADM9240_REG_DIE_REV);
560 dev_info(&adapter->dev, "found %s revision %u\n", 525 dev_info(&adapter->dev, "found %s revision %u\n",
561 man_id == 0x23 ? "ADM9240" : 526 man_id == 0x23 ? "ADM9240" :
562 man_id == 0xda ? "DS1780" : "LM81", die_rev); 527 man_id == 0xda ? "DS1780" : "LM81", die_rev);
@@ -588,33 +553,59 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
588 goto exit_detach; 553 goto exit_detach;
589 } 554 }
590 555
591 device_create_file(&new_client->dev, &dev_attr_in0_input); 556 device_create_file(&new_client->dev,
592 device_create_file(&new_client->dev, &dev_attr_in0_min); 557 &sensor_dev_attr_in0_input.dev_attr);
593 device_create_file(&new_client->dev, &dev_attr_in0_max); 558 device_create_file(&new_client->dev,
594 device_create_file(&new_client->dev, &dev_attr_in1_input); 559 &sensor_dev_attr_in0_min.dev_attr);
595 device_create_file(&new_client->dev, &dev_attr_in1_min); 560 device_create_file(&new_client->dev,
596 device_create_file(&new_client->dev, &dev_attr_in1_max); 561 &sensor_dev_attr_in0_max.dev_attr);
597 device_create_file(&new_client->dev, &dev_attr_in2_input); 562 device_create_file(&new_client->dev,
598 device_create_file(&new_client->dev, &dev_attr_in2_min); 563 &sensor_dev_attr_in1_input.dev_attr);
599 device_create_file(&new_client->dev, &dev_attr_in2_max); 564 device_create_file(&new_client->dev,
600 device_create_file(&new_client->dev, &dev_attr_in3_input); 565 &sensor_dev_attr_in1_min.dev_attr);
601 device_create_file(&new_client->dev, &dev_attr_in3_min); 566 device_create_file(&new_client->dev,
602 device_create_file(&new_client->dev, &dev_attr_in3_max); 567 &sensor_dev_attr_in1_max.dev_attr);
603 device_create_file(&new_client->dev, &dev_attr_in4_input); 568 device_create_file(&new_client->dev,
604 device_create_file(&new_client->dev, &dev_attr_in4_min); 569 &sensor_dev_attr_in2_input.dev_attr);
605 device_create_file(&new_client->dev, &dev_attr_in4_max); 570 device_create_file(&new_client->dev,
606 device_create_file(&new_client->dev, &dev_attr_in5_input); 571 &sensor_dev_attr_in2_min.dev_attr);
607 device_create_file(&new_client->dev, &dev_attr_in5_min); 572 device_create_file(&new_client->dev,
608 device_create_file(&new_client->dev, &dev_attr_in5_max); 573 &sensor_dev_attr_in2_max.dev_attr);
609 device_create_file(&new_client->dev, &dev_attr_temp1_max); 574 device_create_file(&new_client->dev,
610 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 575 &sensor_dev_attr_in3_input.dev_attr);
576 device_create_file(&new_client->dev,
577 &sensor_dev_attr_in3_min.dev_attr);
578 device_create_file(&new_client->dev,
579 &sensor_dev_attr_in3_max.dev_attr);
580 device_create_file(&new_client->dev,
581 &sensor_dev_attr_in4_input.dev_attr);
582 device_create_file(&new_client->dev,
583 &sensor_dev_attr_in4_min.dev_attr);
584 device_create_file(&new_client->dev,
585 &sensor_dev_attr_in4_max.dev_attr);
586 device_create_file(&new_client->dev,
587 &sensor_dev_attr_in5_input.dev_attr);
588 device_create_file(&new_client->dev,
589 &sensor_dev_attr_in5_min.dev_attr);
590 device_create_file(&new_client->dev,
591 &sensor_dev_attr_in5_max.dev_attr);
611 device_create_file(&new_client->dev, &dev_attr_temp1_input); 592 device_create_file(&new_client->dev, &dev_attr_temp1_input);
612 device_create_file(&new_client->dev, &dev_attr_fan1_input); 593 device_create_file(&new_client->dev,
613 device_create_file(&new_client->dev, &dev_attr_fan1_div); 594 &sensor_dev_attr_temp1_max.dev_attr);
614 device_create_file(&new_client->dev, &dev_attr_fan1_min); 595 device_create_file(&new_client->dev,
615 device_create_file(&new_client->dev, &dev_attr_fan2_input); 596 &sensor_dev_attr_temp1_max_hyst.dev_attr);
616 device_create_file(&new_client->dev, &dev_attr_fan2_div); 597 device_create_file(&new_client->dev,
617 device_create_file(&new_client->dev, &dev_attr_fan2_min); 598 &sensor_dev_attr_fan1_input.dev_attr);
599 device_create_file(&new_client->dev,
600 &sensor_dev_attr_fan1_div.dev_attr);
601 device_create_file(&new_client->dev,
602 &sensor_dev_attr_fan1_min.dev_attr);
603 device_create_file(&new_client->dev,
604 &sensor_dev_attr_fan2_input.dev_attr);
605 device_create_file(&new_client->dev,
606 &sensor_dev_attr_fan2_div.dev_attr);
607 device_create_file(&new_client->dev,
608 &sensor_dev_attr_fan2_min.dev_attr);
618 device_create_file(&new_client->dev, &dev_attr_alarms); 609 device_create_file(&new_client->dev, &dev_attr_alarms);
619 device_create_file(&new_client->dev, &dev_attr_aout_output); 610 device_create_file(&new_client->dev, &dev_attr_aout_output);
620 device_create_file(&new_client->dev, &dev_attr_chassis_clear); 611 device_create_file(&new_client->dev, &dev_attr_chassis_clear);
@@ -654,8 +645,8 @@ static int adm9240_detach_client(struct i2c_client *client)
654static void adm9240_init_client(struct i2c_client *client) 645static void adm9240_init_client(struct i2c_client *client)
655{ 646{
656 struct adm9240_data *data = i2c_get_clientdata(client); 647 struct adm9240_data *data = i2c_get_clientdata(client);
657 u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); 648 u8 conf = i2c_smbus_read_byte_data(client, ADM9240_REG_CONFIG);
658 u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; 649 u8 mode = i2c_smbus_read_byte_data(client, ADM9240_REG_TEMP_CONF) & 3;
659 650
660 data->vrm = vid_which_vrm(); /* need this to report vid as mV */ 651 data->vrm = vid_which_vrm(); /* need this to report vid as mV */
661 652
@@ -672,18 +663,22 @@ static void adm9240_init_client(struct i2c_client *client)
672 663
673 for (i = 0; i < 6; i++) 664 for (i = 0; i < 6; i++)
674 { 665 {
675 adm9240_write_value(client, 666 i2c_smbus_write_byte_data(client,
676 ADM9240_REG_IN_MIN(i), 0); 667 ADM9240_REG_IN_MIN(i), 0);
677 adm9240_write_value(client, 668 i2c_smbus_write_byte_data(client,
678 ADM9240_REG_IN_MAX(i), 255); 669 ADM9240_REG_IN_MAX(i), 255);
679 } 670 }
680 adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); 671 i2c_smbus_write_byte_data(client,
681 adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); 672 ADM9240_REG_FAN_MIN(0), 255);
682 adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); 673 i2c_smbus_write_byte_data(client,
683 adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); 674 ADM9240_REG_FAN_MIN(1), 255);
675 i2c_smbus_write_byte_data(client,
676 ADM9240_REG_TEMP_MAX(0), 127);
677 i2c_smbus_write_byte_data(client,
678 ADM9240_REG_TEMP_MAX(1), 127);
684 679
685 /* start measurement cycle */ 680 /* start measurement cycle */
686 adm9240_write_value(client, ADM9240_REG_CONFIG, 1); 681 i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1);
687 682
688 dev_info(&client->dev, "cold start: config was 0x%02x " 683 dev_info(&client->dev, "cold start: config was 0x%02x "
689 "mode %u\n", conf, mode); 684 "mode %u\n", conf, mode);
@@ -704,25 +699,25 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
704 699
705 for (i = 0; i < 6; i++) /* read voltages */ 700 for (i = 0; i < 6; i++) /* read voltages */
706 { 701 {
707 data->in[i] = adm9240_read_value(client, 702 data->in[i] = i2c_smbus_read_byte_data(client,
708 ADM9240_REG_IN(i)); 703 ADM9240_REG_IN(i));
709 } 704 }
710 data->alarms = adm9240_read_value(client, 705 data->alarms = i2c_smbus_read_byte_data(client,
711 ADM9240_REG_INT(0)) | 706 ADM9240_REG_INT(0)) |
712 adm9240_read_value(client, 707 i2c_smbus_read_byte_data(client,
713 ADM9240_REG_INT(1)) << 8; 708 ADM9240_REG_INT(1)) << 8;
714 709
715 /* read temperature: assume temperature changes less than 710 /* read temperature: assume temperature changes less than
716 * 0.5'C per two measurement cycles thus ignore possible 711 * 0.5'C per two measurement cycles thus ignore possible
717 * but unlikely aliasing error on lsb reading. --Grant */ 712 * but unlikely aliasing error on lsb reading. --Grant */
718 data->temp = ((adm9240_read_value(client, 713 data->temp = ((i2c_smbus_read_byte_data(client,
719 ADM9240_REG_TEMP) << 8) | 714 ADM9240_REG_TEMP) << 8) |
720 adm9240_read_value(client, 715 i2c_smbus_read_byte_data(client,
721 ADM9240_REG_TEMP_CONF)) / 128; 716 ADM9240_REG_TEMP_CONF)) / 128;
722 717
723 for (i = 0; i < 2; i++) /* read fans */ 718 for (i = 0; i < 2; i++) /* read fans */
724 { 719 {
725 data->fan[i] = adm9240_read_value(client, 720 data->fan[i] = i2c_smbus_read_byte_data(client,
726 ADM9240_REG_FAN(i)); 721 ADM9240_REG_FAN(i));
727 722
728 /* adjust fan clock divider on overflow */ 723 /* adjust fan clock divider on overflow */
@@ -747,30 +742,30 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
747 742
748 for (i = 0; i < 6; i++) 743 for (i = 0; i < 6; i++)
749 { 744 {
750 data->in_min[i] = adm9240_read_value(client, 745 data->in_min[i] = i2c_smbus_read_byte_data(client,
751 ADM9240_REG_IN_MIN(i)); 746 ADM9240_REG_IN_MIN(i));
752 data->in_max[i] = adm9240_read_value(client, 747 data->in_max[i] = i2c_smbus_read_byte_data(client,
753 ADM9240_REG_IN_MAX(i)); 748 ADM9240_REG_IN_MAX(i));
754 } 749 }
755 for (i = 0; i < 2; i++) 750 for (i = 0; i < 2; i++)
756 { 751 {
757 data->fan_min[i] = adm9240_read_value(client, 752 data->fan_min[i] = i2c_smbus_read_byte_data(client,
758 ADM9240_REG_FAN_MIN(i)); 753 ADM9240_REG_FAN_MIN(i));
759 } 754 }
760 data->temp_high = adm9240_read_value(client, 755 data->temp_max[0] = i2c_smbus_read_byte_data(client,
761 ADM9240_REG_TEMP_HIGH); 756 ADM9240_REG_TEMP_MAX(0));
762 data->temp_hyst = adm9240_read_value(client, 757 data->temp_max[1] = i2c_smbus_read_byte_data(client,
763 ADM9240_REG_TEMP_HYST); 758 ADM9240_REG_TEMP_MAX(1));
764 759
765 /* read fan divs and 5-bit VID */ 760 /* read fan divs and 5-bit VID */
766 i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); 761 i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV);
767 data->fan_div[0] = (i >> 4) & 3; 762 data->fan_div[0] = (i >> 4) & 3;
768 data->fan_div[1] = (i >> 6) & 3; 763 data->fan_div[1] = (i >> 6) & 3;
769 data->vid = i & 0x0f; 764 data->vid = i & 0x0f;
770 data->vid |= (adm9240_read_value(client, 765 data->vid |= (i2c_smbus_read_byte_data(client,
771 ADM9240_REG_VID4) & 1) << 4; 766 ADM9240_REG_VID4) & 1) << 4;
772 /* read analog out */ 767 /* read analog out */
773 data->aout = adm9240_read_value(client, 768 data->aout = i2c_smbus_read_byte_data(client,
774 ADM9240_REG_ANALOG_OUT); 769 ADM9240_REG_ANALOG_OUT);
775 770
776 data->last_updated_config = jiffies; 771 data->last_updated_config = jiffies;
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 8e34855a6274..52c469722a65 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -629,19 +629,17 @@ static int asb100_detect_subclients(struct i2c_adapter *adapter, int address,
629 int i, id, err; 629 int i, id, err;
630 struct asb100_data *data = i2c_get_clientdata(new_client); 630 struct asb100_data *data = i2c_get_clientdata(new_client);
631 631
632 data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 632 data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
633 if (!(data->lm75[0])) { 633 if (!(data->lm75[0])) {
634 err = -ENOMEM; 634 err = -ENOMEM;
635 goto ERROR_SC_0; 635 goto ERROR_SC_0;
636 } 636 }
637 memset(data->lm75[0], 0x00, sizeof(struct i2c_client));
638 637
639 data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 638 data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
640 if (!(data->lm75[1])) { 639 if (!(data->lm75[1])) {
641 err = -ENOMEM; 640 err = -ENOMEM;
642 goto ERROR_SC_1; 641 goto ERROR_SC_1;
643 } 642 }
644 memset(data->lm75[1], 0x00, sizeof(struct i2c_client));
645 643
646 id = i2c_adapter_id(adapter); 644 id = i2c_adapter_id(adapter);
647 645
@@ -724,12 +722,11 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
724 client structure, even though we cannot fill it completely yet. 722 client structure, even though we cannot fill it completely yet.
725 But it allows us to access asb100_{read,write}_value. */ 723 But it allows us to access asb100_{read,write}_value. */
726 724
727 if (!(data = kmalloc(sizeof(struct asb100_data), GFP_KERNEL))) { 725 if (!(data = kzalloc(sizeof(struct asb100_data), GFP_KERNEL))) {
728 pr_debug("asb100.o: detect failed, kmalloc failed!\n"); 726 pr_debug("asb100.o: detect failed, kzalloc failed!\n");
729 err = -ENOMEM; 727 err = -ENOMEM;
730 goto ERROR0; 728 goto ERROR0;
731 } 729 }
732 memset(data, 0, sizeof(struct asb100_data));
733 730
734 new_client = &data->client; 731 new_client = &data->client;
735 init_MUTEX(&data->lock); 732 init_MUTEX(&data->lock);
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index deb4d34c9539..53324f56404e 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -253,6 +253,8 @@ static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
253 253
254static int atxp1_attach_adapter(struct i2c_adapter *adapter) 254static int atxp1_attach_adapter(struct i2c_adapter *adapter)
255{ 255{
256 if (!(adapter->class & I2C_CLASS_HWMON))
257 return 0;
256 return i2c_probe(adapter, &addr_data, &atxp1_detect); 258 return i2c_probe(adapter, &addr_data, &atxp1_detect);
257}; 259};
258 260
@@ -266,12 +268,11 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
266 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 268 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
267 goto exit; 269 goto exit;
268 270
269 if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { 271 if (!(data = kzalloc(sizeof(struct atxp1_data), GFP_KERNEL))) {
270 err = -ENOMEM; 272 err = -ENOMEM;
271 goto exit; 273 goto exit;
272 } 274 }
273 275
274 memset(data, 0, sizeof(struct atxp1_data));
275 new_client = &data->client; 276 new_client = &data->client;
276 i2c_set_clientdata(new_client, data); 277 i2c_set_clientdata(new_client, data);
277 278
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index b0199e063d0e..34f71b7c7f37 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -180,12 +180,14 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
180 180
181static int ds1621_attach_adapter(struct i2c_adapter *adapter) 181static int ds1621_attach_adapter(struct i2c_adapter *adapter)
182{ 182{
183 if (!(adapter->class & I2C_CLASS_HWMON))
184 return 0;
183 return i2c_probe(adapter, &addr_data, ds1621_detect); 185 return i2c_probe(adapter, &addr_data, ds1621_detect);
184} 186}
185 187
186/* This function is called by i2c_probe */ 188/* This function is called by i2c_probe */
187int ds1621_detect(struct i2c_adapter *adapter, int address, 189static int ds1621_detect(struct i2c_adapter *adapter, int address,
188 int kind) 190 int kind)
189{ 191{
190 int conf, temp; 192 int conf, temp;
191 struct i2c_client *new_client; 193 struct i2c_client *new_client;
@@ -200,11 +202,10 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
200 /* OK. For now, we presume we have a valid client. We now create the 202 /* OK. For now, we presume we have a valid client. We now create the
201 client structure, even though we cannot fill it completely yet. 203 client structure, even though we cannot fill it completely yet.
202 But it allows us to access ds1621_{read,write}_value. */ 204 But it allows us to access ds1621_{read,write}_value. */
203 if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) { 205 if (!(data = kzalloc(sizeof(struct ds1621_data), GFP_KERNEL))) {
204 err = -ENOMEM; 206 err = -ENOMEM;
205 goto exit; 207 goto exit;
206 } 208 }
207 memset(data, 0, sizeof(struct ds1621_data));
208 209
209 new_client = &data->client; 210 new_client = &data->client;
210 i2c_set_clientdata(new_client, data); 211 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index eef6061d786b..a02e1c34c757 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -303,11 +303,10 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
303 /* OK. For now, we presume we have a valid client. We now create the 303 /* OK. For now, we presume we have a valid client. We now create the
304 * client structure, even though we cannot fill it completely yet. 304 * client structure, even though we cannot fill it completely yet.
305 * But it allows us to access i2c_smbus_read_byte_data. */ 305 * But it allows us to access i2c_smbus_read_byte_data. */
306 if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) { 306 if (!(data = kzalloc(sizeof(struct fscher_data), GFP_KERNEL))) {
307 err = -ENOMEM; 307 err = -ENOMEM;
308 goto exit; 308 goto exit;
309 } 309 }
310 memset(data, 0, sizeof(struct fscher_data));
311 310
312 /* The common I2C client data is placed right before the 311 /* The common I2C client data is placed right before the
313 * Hermes-specific data. */ 312 * Hermes-specific data. */
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 5fc77a5fed07..64e4edc64f8d 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -438,7 +438,7 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter)
438 return i2c_probe(adapter, &addr_data, fscpos_detect); 438 return i2c_probe(adapter, &addr_data, fscpos_detect);
439} 439}
440 440
441int fscpos_detect(struct i2c_adapter *adapter, int address, int kind) 441static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
442{ 442{
443 struct i2c_client *new_client; 443 struct i2c_client *new_client;
444 struct fscpos_data *data; 444 struct fscpos_data *data;
@@ -453,11 +453,10 @@ int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
453 * But it allows us to access fscpos_{read,write}_value. 453 * But it allows us to access fscpos_{read,write}_value.
454 */ 454 */
455 455
456 if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) { 456 if (!(data = kzalloc(sizeof(struct fscpos_data), GFP_KERNEL))) {
457 err = -ENOMEM; 457 err = -ENOMEM;
458 goto exit; 458 goto exit;
459 } 459 }
460 memset(data, 0, sizeof(struct fscpos_data));
461 460
462 new_client = &data->client; 461 new_client = &data->client;
463 i2c_set_clientdata(new_client, data); 462 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 256b9323c84b..2f178dbe3d87 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -365,11 +365,10 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
365 client structure, even though we cannot fill it completely yet. 365 client structure, even though we cannot fill it completely yet.
366 But it allows us to access gl518_{read,write}_value. */ 366 But it allows us to access gl518_{read,write}_value. */
367 367
368 if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) { 368 if (!(data = kzalloc(sizeof(struct gl518_data), GFP_KERNEL))) {
369 err = -ENOMEM; 369 err = -ENOMEM;
370 goto exit; 370 goto exit;
371 } 371 }
372 memset(data, 0, sizeof(struct gl518_data));
373 372
374 new_client = &data->client; 373 new_client = &data->client;
375 i2c_set_clientdata(new_client, data); 374 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index 12fd757066fc..c39ba1239426 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -536,11 +536,10 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
536 client structure, even though we cannot fill it completely yet. 536 client structure, even though we cannot fill it completely yet.
537 But it allows us to access gl520_{read,write}_value. */ 537 But it allows us to access gl520_{read,write}_value. */
538 538
539 if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) { 539 if (!(data = kzalloc(sizeof(struct gl520_data), GFP_KERNEL))) {
540 err = -ENOMEM; 540 err = -ENOMEM;
541 goto exit; 541 goto exit;
542 } 542 }
543 memset(data, 0, sizeof(struct gl520_data));
544 543
545 new_client = &data->client; 544 new_client = &data->client;
546 i2c_set_clientdata(new_client, data); 545 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 7f0107613827..0015da5668a1 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -296,11 +296,9 @@ static int hdaps_probe(struct device *dev)
296 return 0; 296 return 0;
297} 297}
298 298
299static int hdaps_resume(struct device *dev, u32 level) 299static int hdaps_resume(struct device *dev)
300{ 300{
301 if (level == RESUME_ENABLE) 301 return hdaps_device_init();
302 return hdaps_device_init();
303 return 0;
304} 302}
305 303
306static struct device_driver hdaps_driver = { 304static struct device_driver hdaps_driver = {
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 9b41c9bd805f..6f48579799b5 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -45,7 +45,7 @@ struct class_device *hwmon_device_register(struct device *dev)
45 return ERR_PTR(-ENOMEM); 45 return ERR_PTR(-ENOMEM);
46 46
47 id = id & MAX_ID_MASK; 47 id = id & MAX_ID_MASK;
48 cdev = class_device_create(hwmon_class, MKDEV(0,0), dev, 48 cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev,
49 HWMON_ID_FORMAT, id); 49 HWMON_ID_FORMAT, id);
50 50
51 if (IS_ERR(cdev)) 51 if (IS_ERR(cdev))
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 53cc2b6d6385..6c41e25e670b 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -2,7 +2,7 @@
2 it87.c - Part of lm_sensors, Linux kernel modules for hardware 2 it87.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring. 3 monitoring.
4 4
5 Supports: IT8705F Super I/O chip w/LPC interface & SMBus 5 Supports: IT8705F Super I/O chip w/LPC interface
6 IT8712F Super I/O chip w/LPC interface & SMBus 6 IT8712F Super I/O chip w/LPC interface & SMBus
7 Sis950 A clone of the IT8705F 7 Sis950 A clone of the IT8705F
8 8
@@ -47,7 +47,7 @@
47/* Addresses to scan */ 47/* Addresses to scan */
48static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 48static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
49 0x2e, 0x2f, I2C_CLIENT_END }; 49 0x2e, 0x2f, I2C_CLIENT_END };
50static unsigned short isa_address = 0x290; 50static unsigned short isa_address;
51 51
52/* Insmod parameters */ 52/* Insmod parameters */
53I2C_CLIENT_INSMOD_2(it87, it8712); 53I2C_CLIENT_INSMOD_2(it87, it8712);
@@ -706,7 +706,7 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter)
706} 706}
707 707
708/* SuperIO detection - will change isa_address if a chip is found */ 708/* SuperIO detection - will change isa_address if a chip is found */
709static int __init it87_find(int *address) 709static int __init it87_find(unsigned short *address)
710{ 710{
711 int err = -ENODEV; 711 int err = -ENODEV;
712 712
@@ -738,7 +738,7 @@ exit:
738} 738}
739 739
740/* This function is called by i2c_probe */ 740/* This function is called by i2c_probe */
741int it87_detect(struct i2c_adapter *adapter, int address, int kind) 741static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
742{ 742{
743 int i; 743 int i;
744 struct i2c_client *new_client; 744 struct i2c_client *new_client;
@@ -757,42 +757,14 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
757 if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) 757 if (!request_region(address, IT87_EXTENT, it87_isa_driver.name))
758 goto ERROR0; 758 goto ERROR0;
759 759
760 /* Probe whether there is anything available on this address. Already 760 /* For now, we presume we have a valid client. We create the
761 done for SMBus and Super-I/O clients */
762 if (kind < 0) {
763 if (is_isa && !chip_type) {
764#define REALLY_SLOW_IO
765 /* We need the timeouts for at least some IT87-like chips. But only
766 if we read 'undefined' registers. */
767 i = inb_p(address + 1);
768 if (inb_p(address + 2) != i
769 || inb_p(address + 3) != i
770 || inb_p(address + 7) != i) {
771 err = -ENODEV;
772 goto ERROR1;
773 }
774#undef REALLY_SLOW_IO
775
776 /* Let's just hope nothing breaks here */
777 i = inb_p(address + 5) & 0x7f;
778 outb_p(~i & 0x7f, address + 5);
779 if ((inb_p(address + 5) & 0x7f) != (~i & 0x7f)) {
780 outb_p(i, address + 5);
781 err = -ENODEV;
782 goto ERROR1;
783 }
784 }
785 }
786
787 /* OK. For now, we presume we have a valid client. We now create the
788 client structure, even though we cannot fill it completely yet. 761 client structure, even though we cannot fill it completely yet.
789 But it allows us to access it87_{read,write}_value. */ 762 But it allows us to access it87_{read,write}_value. */
790 763
791 if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) { 764 if (!(data = kzalloc(sizeof(struct it87_data), GFP_KERNEL))) {
792 err = -ENOMEM; 765 err = -ENOMEM;
793 goto ERROR1; 766 goto ERROR1;
794 } 767 }
795 memset(data, 0, sizeof(struct it87_data));
796 768
797 new_client = &data->client; 769 new_client = &data->client;
798 if (is_isa) 770 if (is_isa)
@@ -1182,20 +1154,18 @@ static struct it87_data *it87_update_device(struct device *dev)
1182 1154
1183static int __init sm_it87_init(void) 1155static int __init sm_it87_init(void)
1184{ 1156{
1185 int addr, res; 1157 int res;
1186
1187 if (!it87_find(&addr)) {
1188 isa_address = addr;
1189 }
1190 1158
1191 res = i2c_add_driver(&it87_driver); 1159 res = i2c_add_driver(&it87_driver);
1192 if (res) 1160 if (res)
1193 return res; 1161 return res;
1194 1162
1195 res = i2c_isa_add_driver(&it87_isa_driver); 1163 if (!it87_find(&isa_address)) {
1196 if (res) { 1164 res = i2c_isa_add_driver(&it87_isa_driver);
1197 i2c_del_driver(&it87_driver); 1165 if (res) {
1198 return res; 1166 i2c_del_driver(&it87_driver);
1167 return res;
1168 }
1199 } 1169 }
1200 1170
1201 return 0; 1171 return 0;
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index be5c7095ecbb..954ec2497249 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -375,11 +375,10 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
375 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 375 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
376 goto exit; 376 goto exit;
377 377
378 if (!(data = kmalloc(sizeof(struct lm63_data), GFP_KERNEL))) { 378 if (!(data = kzalloc(sizeof(struct lm63_data), GFP_KERNEL))) {
379 err = -ENOMEM; 379 err = -ENOMEM;
380 goto exit; 380 goto exit;
381 } 381 }
382 memset(data, 0, sizeof(struct lm63_data));
383 382
384 /* The common I2C client data is placed right before the 383 /* The common I2C client data is placed right before the
385 LM63-specific data. */ 384 LM63-specific data. */
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 9a3ebdf583f4..d70f4c8fc1e6 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -127,11 +127,10 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
127 /* OK. For now, we presume we have a valid client. We now create the 127 /* OK. For now, we presume we have a valid client. We now create the
128 client structure, even though we cannot fill it completely yet. 128 client structure, even though we cannot fill it completely yet.
129 But it allows us to access lm75_{read,write}_value. */ 129 But it allows us to access lm75_{read,write}_value. */
130 if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) { 130 if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) {
131 err = -ENOMEM; 131 err = -ENOMEM;
132 goto exit; 132 goto exit;
133 } 133 }
134 memset(data, 0, sizeof(struct lm75_data));
135 134
136 new_client = &data->client; 135 new_client = &data->client;
137 i2c_set_clientdata(new_client, data); 136 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index 866eab96a6f6..9380fda7dcd1 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -226,11 +226,10 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
226 /* OK. For now, we presume we have a valid client. We now create the 226 /* OK. For now, we presume we have a valid client. We now create the
227 client structure, even though we cannot fill it completely yet. 227 client structure, even though we cannot fill it completely yet.
228 But it allows us to access lm77_{read,write}_value. */ 228 But it allows us to access lm77_{read,write}_value. */
229 if (!(data = kmalloc(sizeof(struct lm77_data), GFP_KERNEL))) { 229 if (!(data = kzalloc(sizeof(struct lm77_data), GFP_KERNEL))) {
230 err = -ENOMEM; 230 err = -ENOMEM;
231 goto exit; 231 goto exit;
232 } 232 }
233 memset(data, 0, sizeof(struct lm77_data));
234 233
235 new_client = &data->client; 234 new_client = &data->client;
236 i2c_set_clientdata(new_client, data); 235 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index f6730dc3573b..bde0cda9477e 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -480,7 +480,7 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
480} 480}
481 481
482/* This function is called by i2c_probe */ 482/* This function is called by i2c_probe */
483int lm78_detect(struct i2c_adapter *adapter, int address, int kind) 483static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
484{ 484{
485 int i, err; 485 int i, err;
486 struct i2c_client *new_client; 486 struct i2c_client *new_client;
@@ -540,11 +540,10 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
540 client structure, even though we cannot fill it completely yet. 540 client structure, even though we cannot fill it completely yet.
541 But it allows us to access lm78_{read,write}_value. */ 541 But it allows us to access lm78_{read,write}_value. */
542 542
543 if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) { 543 if (!(data = kzalloc(sizeof(struct lm78_data), GFP_KERNEL))) {
544 err = -ENOMEM; 544 err = -ENOMEM;
545 goto ERROR1; 545 goto ERROR1;
546 } 546 }
547 memset(data, 0, sizeof(struct lm78_data));
548 547
549 new_client = &data->client; 548 new_client = &data->client;
550 if (is_isa) 549 if (is_isa)
@@ -726,7 +725,6 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
726 return i2c_smbus_write_byte_data(client, reg, value); 725 return i2c_smbus_write_byte_data(client, reg, value);
727} 726}
728 727
729/* Called when we have found a new LM78. It should set limits, etc. */
730static void lm78_init_client(struct i2c_client *client) 728static void lm78_init_client(struct i2c_client *client)
731{ 729{
732 u8 config = lm78_read_value(client, LM78_REG_CONFIG); 730 u8 config = lm78_read_value(client, LM78_REG_CONFIG);
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index 83af8b3a0cac..c359fdea211e 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -393,7 +393,7 @@ static int lm80_attach_adapter(struct i2c_adapter *adapter)
393 return i2c_probe(adapter, &addr_data, lm80_detect); 393 return i2c_probe(adapter, &addr_data, lm80_detect);
394} 394}
395 395
396int lm80_detect(struct i2c_adapter *adapter, int address, int kind) 396static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
397{ 397{
398 int i, cur; 398 int i, cur;
399 struct i2c_client *new_client; 399 struct i2c_client *new_client;
@@ -407,11 +407,10 @@ int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
407 /* OK. For now, we presume we have a valid client. We now create the 407 /* OK. For now, we presume we have a valid client. We now create the
408 client structure, even though we cannot fill it completely yet. 408 client structure, even though we cannot fill it completely yet.
409 But it allows us to access lm80_{read,write}_value. */ 409 But it allows us to access lm80_{read,write}_value. */
410 if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) { 410 if (!(data = kzalloc(sizeof(struct lm80_data), GFP_KERNEL))) {
411 err = -ENOMEM; 411 err = -ENOMEM;
412 goto exit; 412 goto exit;
413 } 413 }
414 memset(data, 0, sizeof(struct lm80_data));
415 414
416 new_client = &data->client; 415 new_client = &data->client;
417 i2c_set_clientdata(new_client, data); 416 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index d74b2c20c719..9a70611a9f69 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -230,11 +230,10 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
230 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 230 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
231 goto exit; 231 goto exit;
232 232
233 if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL))) { 233 if (!(data = kzalloc(sizeof(struct lm83_data), GFP_KERNEL))) {
234 err = -ENOMEM; 234 err = -ENOMEM;
235 goto exit; 235 goto exit;
236 } 236 }
237 memset(data, 0, sizeof(struct lm83_data));
238 237
239 /* The common I2C client data is placed right after the 238 /* The common I2C client data is placed right after the
240 * LM83-specific data. */ 239 * LM83-specific data. */
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index ab214df9624b..d1070ed2bee6 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -1007,14 +1007,14 @@ temp_auto(1);
1007temp_auto(2); 1007temp_auto(2);
1008temp_auto(3); 1008temp_auto(3);
1009 1009
1010int lm85_attach_adapter(struct i2c_adapter *adapter) 1010static int lm85_attach_adapter(struct i2c_adapter *adapter)
1011{ 1011{
1012 if (!(adapter->class & I2C_CLASS_HWMON)) 1012 if (!(adapter->class & I2C_CLASS_HWMON))
1013 return 0; 1013 return 0;
1014 return i2c_probe(adapter, &addr_data, lm85_detect); 1014 return i2c_probe(adapter, &addr_data, lm85_detect);
1015} 1015}
1016 1016
1017int lm85_detect(struct i2c_adapter *adapter, int address, 1017static int lm85_detect(struct i2c_adapter *adapter, int address,
1018 int kind) 1018 int kind)
1019{ 1019{
1020 int company, verstep ; 1020 int company, verstep ;
@@ -1033,11 +1033,10 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1033 client structure, even though we cannot fill it completely yet. 1033 client structure, even though we cannot fill it completely yet.
1034 But it allows us to access lm85_{read,write}_value. */ 1034 But it allows us to access lm85_{read,write}_value. */
1035 1035
1036 if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) { 1036 if (!(data = kzalloc(sizeof(struct lm85_data), GFP_KERNEL))) {
1037 err = -ENOMEM; 1037 err = -ENOMEM;
1038 goto ERROR0; 1038 goto ERROR0;
1039 } 1039 }
1040 memset(data, 0, sizeof(struct lm85_data));
1041 1040
1042 new_client = &data->client; 1041 new_client = &data->client;
1043 i2c_set_clientdata(new_client, data); 1042 i2c_set_clientdata(new_client, data);
@@ -1236,7 +1235,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
1236 return err; 1235 return err;
1237} 1236}
1238 1237
1239int lm85_detach_client(struct i2c_client *client) 1238static int lm85_detach_client(struct i2c_client *client)
1240{ 1239{
1241 struct lm85_data *data = i2c_get_clientdata(client); 1240 struct lm85_data *data = i2c_get_clientdata(client);
1242 hwmon_device_unregister(data->class_dev); 1241 hwmon_device_unregister(data->class_dev);
@@ -1246,7 +1245,7 @@ int lm85_detach_client(struct i2c_client *client)
1246} 1245}
1247 1246
1248 1247
1249int lm85_read_value(struct i2c_client *client, u8 reg) 1248static int lm85_read_value(struct i2c_client *client, u8 reg)
1250{ 1249{
1251 int res; 1250 int res;
1252 1251
@@ -1276,7 +1275,7 @@ int lm85_read_value(struct i2c_client *client, u8 reg)
1276 return res ; 1275 return res ;
1277} 1276}
1278 1277
1279int lm85_write_value(struct i2c_client *client, u8 reg, int value) 1278static int lm85_write_value(struct i2c_client *client, u8 reg, int value)
1280{ 1279{
1281 int res ; 1280 int res ;
1282 1281
@@ -1305,7 +1304,7 @@ int lm85_write_value(struct i2c_client *client, u8 reg, int value)
1305 return res ; 1304 return res ;
1306} 1305}
1307 1306
1308void lm85_init_client(struct i2c_client *client) 1307static void lm85_init_client(struct i2c_client *client)
1309{ 1308{
1310 int value; 1309 int value;
1311 struct lm85_data *data = i2c_get_clientdata(client); 1310 struct lm85_data *data = i2c_get_clientdata(client);
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index dca996de4c33..eeec18177861 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -554,11 +554,10 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
554 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 554 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
555 goto exit; 555 goto exit;
556 556
557 if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) { 557 if (!(data = kzalloc(sizeof(struct lm87_data), GFP_KERNEL))) {
558 err = -ENOMEM; 558 err = -ENOMEM;
559 goto exit; 559 goto exit;
560 } 560 }
561 memset(data, 0, sizeof(struct lm87_data));
562 561
563 /* The common I2C client data is placed right before the 562 /* The common I2C client data is placed right before the
564 LM87-specific data. */ 563 LM87-specific data. */
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 14de05fcd431..83cf2e1b09f5 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -31,7 +31,7 @@
31 * Devices. That chip is similar to the LM90, with a few differences 31 * Devices. That chip is similar to the LM90, with a few differences
32 * that are not handled by this driver. Complete datasheet can be 32 * that are not handled by this driver. Complete datasheet can be
33 * obtained from Analog's website at: 33 * obtained from Analog's website at:
34 * http://products.analog.com/products/info.asp?product=ADM1032 34 * http://www.analog.com/en/prod/0,2877,ADM1032,00.html
35 * Among others, it has a higher accuracy than the LM90, much like the 35 * Among others, it has a higher accuracy than the LM90, much like the
36 * LM86 does. 36 * LM86 does.
37 * 37 *
@@ -49,7 +49,7 @@
49 * register values are decoded differently) it is ignored by this 49 * register values are decoded differently) it is ignored by this
50 * driver. Complete datasheet can be obtained from Analog's website 50 * driver. Complete datasheet can be obtained from Analog's website
51 * at: 51 * at:
52 * http://products.analog.com/products/info.asp?product=ADT7461 52 * http://www.analog.com/en/prod/0,2877,ADT7461,00.html
53 * 53 *
54 * Since the LM90 was the first chipset supported by this driver, most 54 * Since the LM90 was the first chipset supported by this driver, most
55 * comments will refer to this chipset, but are actually general and 55 * comments will refer to this chipset, but are actually general and
@@ -83,10 +83,10 @@
83 * Addresses to scan 83 * Addresses to scan
84 * Address is fully defined internally and cannot be changed except for 84 * Address is fully defined internally and cannot be changed except for
85 * MAX6659. 85 * MAX6659.
86 * LM86, LM89, LM90, LM99, ADM1032, MAX6657 and MAX6658 have address 0x4c. 86 * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658
87 * LM89-1, and LM99-1 have address 0x4d. 87 * have address 0x4c.
88 * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d.
88 * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). 89 * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported).
89 * ADT7461 always has address 0x4c.
90 */ 90 */
91 91
92static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END }; 92static unsigned short normal_i2c[] = { 0x4c, 0x4d, I2C_CLIENT_END };
@@ -345,10 +345,74 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,
345static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); 345static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4);
346static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 346static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
347 347
348/* pec used for ADM1032 only */
349static ssize_t show_pec(struct device *dev, struct device_attribute *dummy,
350 char *buf)
351{
352 struct i2c_client *client = to_i2c_client(dev);
353 return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC));
354}
355
356static ssize_t set_pec(struct device *dev, struct device_attribute *dummy,
357 const char *buf, size_t count)
358{
359 struct i2c_client *client = to_i2c_client(dev);
360 long val = simple_strtol(buf, NULL, 10);
361
362 switch (val) {
363 case 0:
364 client->flags &= ~I2C_CLIENT_PEC;
365 break;
366 case 1:
367 client->flags |= I2C_CLIENT_PEC;
368 break;
369 default:
370 return -EINVAL;
371 }
372
373 return count;
374}
375
376static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
377
348/* 378/*
349 * Real code 379 * Real code
350 */ 380 */
351 381
382/* The ADM1032 supports PEC but not on write byte transactions, so we need
383 to explicitely ask for a transaction without PEC. */
384static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value)
385{
386 return i2c_smbus_xfer(client->adapter, client->addr,
387 client->flags & ~I2C_CLIENT_PEC,
388 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
389}
390
391/* It is assumed that client->update_lock is held (unless we are in
392 detection or initialization steps). This matters when PEC is enabled,
393 because we don't want the address pointer to change between the write
394 byte and the read byte transactions. */
395static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value)
396{
397 int err;
398
399 if (client->flags & I2C_CLIENT_PEC) {
400 err = adm1032_write_byte(client, reg);
401 if (err >= 0)
402 err = i2c_smbus_read_byte(client);
403 } else
404 err = i2c_smbus_read_byte_data(client, reg);
405
406 if (err < 0) {
407 dev_warn(&client->dev, "Register %#02x read failed (%d)\n",
408 reg, err);
409 return err;
410 }
411 *value = err;
412
413 return 0;
414}
415
352static int lm90_attach_adapter(struct i2c_adapter *adapter) 416static int lm90_attach_adapter(struct i2c_adapter *adapter)
353{ 417{
354 if (!(adapter->class & I2C_CLASS_HWMON)) 418 if (!(adapter->class & I2C_CLASS_HWMON))
@@ -370,11 +434,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
370 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 434 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
371 goto exit; 435 goto exit;
372 436
373 if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { 437 if (!(data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL))) {
374 err = -ENOMEM; 438 err = -ENOMEM;
375 goto exit; 439 goto exit;
376 } 440 }
377 memset(data, 0, sizeof(struct lm90_data));
378 441
379 /* The common I2C client data is placed right before the 442 /* The common I2C client data is placed right before the
380 LM90-specific data. */ 443 LM90-specific data. */
@@ -403,20 +466,22 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
403 if (kind < 0) { /* detection and identification */ 466 if (kind < 0) { /* detection and identification */
404 u8 man_id, chip_id, reg_config1, reg_convrate; 467 u8 man_id, chip_id, reg_config1, reg_convrate;
405 468
406 man_id = i2c_smbus_read_byte_data(new_client, 469 if (lm90_read_reg(new_client, LM90_REG_R_MAN_ID,
407 LM90_REG_R_MAN_ID); 470 &man_id) < 0
408 chip_id = i2c_smbus_read_byte_data(new_client, 471 || lm90_read_reg(new_client, LM90_REG_R_CHIP_ID,
409 LM90_REG_R_CHIP_ID); 472 &chip_id) < 0
410 reg_config1 = i2c_smbus_read_byte_data(new_client, 473 || lm90_read_reg(new_client, LM90_REG_R_CONFIG1,
411 LM90_REG_R_CONFIG1); 474 &reg_config1) < 0
412 reg_convrate = i2c_smbus_read_byte_data(new_client, 475 || lm90_read_reg(new_client, LM90_REG_R_CONVRATE,
413 LM90_REG_R_CONVRATE); 476 &reg_convrate) < 0)
477 goto exit_free;
414 478
415 if (man_id == 0x01) { /* National Semiconductor */ 479 if (man_id == 0x01) { /* National Semiconductor */
416 u8 reg_config2; 480 u8 reg_config2;
417 481
418 reg_config2 = i2c_smbus_read_byte_data(new_client, 482 if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2,
419 LM90_REG_R_CONFIG2); 483 &reg_config2) < 0)
484 goto exit_free;
420 485
421 if ((reg_config1 & 0x2A) == 0x00 486 if ((reg_config1 & 0x2A) == 0x00
422 && (reg_config2 & 0xF8) == 0x00 487 && (reg_config2 & 0xF8) == 0x00
@@ -435,14 +500,12 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
435 } 500 }
436 } else 501 } else
437 if (man_id == 0x41) { /* Analog Devices */ 502 if (man_id == 0x41) { /* Analog Devices */
438 if (address == 0x4C 503 if ((chip_id & 0xF0) == 0x40 /* ADM1032 */
439 && (chip_id & 0xF0) == 0x40 /* ADM1032 */
440 && (reg_config1 & 0x3F) == 0x00 504 && (reg_config1 & 0x3F) == 0x00
441 && reg_convrate <= 0x0A) { 505 && reg_convrate <= 0x0A) {
442 kind = adm1032; 506 kind = adm1032;
443 } else 507 } else
444 if (address == 0x4c 508 if (chip_id == 0x51 /* ADT7461 */
445 && chip_id == 0x51 /* ADT7461 */
446 && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ 509 && (reg_config1 & 0x1F) == 0x00 /* check compat mode */
447 && reg_convrate <= 0x0A) { 510 && reg_convrate <= 0x0A) {
448 kind = adt7461; 511 kind = adt7461;
@@ -477,6 +540,10 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
477 name = "lm90"; 540 name = "lm90";
478 } else if (kind == adm1032) { 541 } else if (kind == adm1032) {
479 name = "adm1032"; 542 name = "adm1032";
543 /* The ADM1032 supports PEC, but only if combined
544 transactions are not used. */
545 if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
546 new_client->flags |= I2C_CLIENT_PEC;
480 } else if (kind == lm99) { 547 } else if (kind == lm99) {
481 name = "lm99"; 548 name = "lm99";
482 } else if (kind == lm86) { 549 } else if (kind == lm86) {
@@ -529,6 +596,9 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
529 &sensor_dev_attr_temp2_crit_hyst.dev_attr); 596 &sensor_dev_attr_temp2_crit_hyst.dev_attr);
530 device_create_file(&new_client->dev, &dev_attr_alarms); 597 device_create_file(&new_client->dev, &dev_attr_alarms);
531 598
599 if (new_client->flags & I2C_CLIENT_PEC)
600 device_create_file(&new_client->dev, &dev_attr_pec);
601
532 return 0; 602 return 0;
533 603
534exit_detach: 604exit_detach:
@@ -548,7 +618,10 @@ static void lm90_init_client(struct i2c_client *client)
548 */ 618 */
549 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, 619 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
550 5); /* 2 Hz */ 620 5); /* 2 Hz */
551 config = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1); 621 if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) {
622 dev_warn(&client->dev, "Initialization failed!\n");
623 return;
624 }
552 if (config & 0x40) 625 if (config & 0x40)
553 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, 626 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
554 config & 0xBF); /* run */ 627 config & 0xBF); /* run */
@@ -576,21 +649,15 @@ static struct lm90_data *lm90_update_device(struct device *dev)
576 down(&data->update_lock); 649 down(&data->update_lock);
577 650
578 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { 651 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
579 u8 oldh, newh; 652 u8 oldh, newh, l;
580 653
581 dev_dbg(&client->dev, "Updating lm90 data.\n"); 654 dev_dbg(&client->dev, "Updating lm90 data.\n");
582 data->temp8[0] = i2c_smbus_read_byte_data(client, 655 lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, &data->temp8[0]);
583 LM90_REG_R_LOCAL_TEMP); 656 lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[1]);
584 data->temp8[1] = i2c_smbus_read_byte_data(client, 657 lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[2]);
585 LM90_REG_R_LOCAL_LOW); 658 lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[3]);
586 data->temp8[2] = i2c_smbus_read_byte_data(client, 659 lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[4]);
587 LM90_REG_R_LOCAL_HIGH); 660 lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst);
588 data->temp8[3] = i2c_smbus_read_byte_data(client,
589 LM90_REG_R_LOCAL_CRIT);
590 data->temp8[4] = i2c_smbus_read_byte_data(client,
591 LM90_REG_R_REMOTE_CRIT);
592 data->temp_hyst = i2c_smbus_read_byte_data(client,
593 LM90_REG_R_TCRIT_HYST);
594 661
595 /* 662 /*
596 * There is a trick here. We have to read two registers to 663 * There is a trick here. We have to read two registers to
@@ -606,36 +673,20 @@ static struct lm90_data *lm90_update_device(struct device *dev)
606 * then we have a valid reading. Else we have to read the low 673 * then we have a valid reading. Else we have to read the low
607 * byte again, and now we believe we have a correct reading. 674 * byte again, and now we believe we have a correct reading.
608 */ 675 */
609 oldh = i2c_smbus_read_byte_data(client, 676 if (lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &oldh) == 0
610 LM90_REG_R_REMOTE_TEMPH); 677 && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0
611 data->temp11[0] = i2c_smbus_read_byte_data(client, 678 && lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPH, &newh) == 0
612 LM90_REG_R_REMOTE_TEMPL); 679 && (newh == oldh
613 newh = i2c_smbus_read_byte_data(client, 680 || lm90_read_reg(client, LM90_REG_R_REMOTE_TEMPL, &l) == 0))
614 LM90_REG_R_REMOTE_TEMPH); 681 data->temp11[0] = (newh << 8) | l;
615 if (newh != oldh) { 682
616 data->temp11[0] = i2c_smbus_read_byte_data(client, 683 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &newh) == 0
617 LM90_REG_R_REMOTE_TEMPL); 684 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, &l) == 0)
618#ifdef DEBUG 685 data->temp11[1] = (newh << 8) | l;
619 oldh = i2c_smbus_read_byte_data(client, 686 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &newh) == 0
620 LM90_REG_R_REMOTE_TEMPH); 687 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, &l) == 0)
621 /* oldh is actually newer */ 688 data->temp11[2] = (newh << 8) | l;
622 if (newh != oldh) 689 lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms);
623 dev_warn(&client->dev, "Remote temperature may be "
624 "wrong.\n");
625#endif
626 }
627 data->temp11[0] |= (newh << 8);
628
629 data->temp11[1] = (i2c_smbus_read_byte_data(client,
630 LM90_REG_R_REMOTE_LOWH) << 8) +
631 i2c_smbus_read_byte_data(client,
632 LM90_REG_R_REMOTE_LOWL);
633 data->temp11[2] = (i2c_smbus_read_byte_data(client,
634 LM90_REG_R_REMOTE_HIGHH) << 8) +
635 i2c_smbus_read_byte_data(client,
636 LM90_REG_R_REMOTE_HIGHL);
637 data->alarms = i2c_smbus_read_byte_data(client,
638 LM90_REG_R_STATUS);
639 690
640 data->last_updated = jiffies; 691 data->last_updated = jiffies;
641 data->valid = 1; 692 data->valid = 1;
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 647b7c7cd575..7a4b3701ed1a 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -300,11 +300,10 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
300 | I2C_FUNC_SMBUS_WORD_DATA)) 300 | I2C_FUNC_SMBUS_WORD_DATA))
301 goto exit; 301 goto exit;
302 302
303 if (!(data = kmalloc(sizeof(struct lm92_data), GFP_KERNEL))) { 303 if (!(data = kzalloc(sizeof(struct lm92_data), GFP_KERNEL))) {
304 err = -ENOMEM; 304 err = -ENOMEM;
305 goto exit; 305 goto exit;
306 } 306 }
307 memset(data, 0, sizeof(struct lm92_data));
308 307
309 /* Fill in enough client fields so that we can read from the chip, 308 /* Fill in enough client fields so that we can read from the chip,
310 which is required for identication */ 309 which is required for identication */
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 16bf71f3a04d..6a82ffae1bfd 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -197,11 +197,10 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
198 goto exit; 198 goto exit;
199 199
200 if (!(data = kmalloc(sizeof(struct max1619_data), GFP_KERNEL))) { 200 if (!(data = kzalloc(sizeof(struct max1619_data), GFP_KERNEL))) {
201 err = -ENOMEM; 201 err = -ENOMEM;
202 goto exit; 202 goto exit;
203 } 203 }
204 memset(data, 0, sizeof(struct max1619_data));
205 204
206 /* The common I2C client data is placed right before the 205 /* The common I2C client data is placed right before the
207 MAX1619-specific data. */ 206 MAX1619-specific data. */
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index cf2a35799c7c..17f745a23d04 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -754,9 +754,8 @@ static int pc87360_detect(struct i2c_adapter *adapter)
754 const char *name = "pc87360"; 754 const char *name = "pc87360";
755 int use_thermistors = 0; 755 int use_thermistors = 0;
756 756
757 if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) 757 if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
758 return -ENOMEM; 758 return -ENOMEM;
759 memset(data, 0x00, sizeof(struct pc87360_data));
760 759
761 new_client = &data->client; 760 new_client = &data->client;
762 i2c_set_clientdata(new_client, data); 761 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 21aa9a41f62c..9c6cadec1087 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -518,11 +518,10 @@ static int sis5595_detect(struct i2c_adapter *adapter)
518 goto exit_release; 518 goto exit_release;
519 } 519 }
520 520
521 if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) { 521 if (!(data = kzalloc(sizeof(struct sis5595_data), GFP_KERNEL))) {
522 err = -ENOMEM; 522 err = -ENOMEM;
523 goto exit_release; 523 goto exit_release;
524 } 524 }
525 memset(data, 0, sizeof(struct sis5595_data));
526 525
527 new_client = &data->client; 526 new_client = &data->client;
528 new_client->addr = address; 527 new_client->addr = address;
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 7fe71576dea4..2a3e21b5b6b4 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -244,11 +244,10 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
244 return -EBUSY; 244 return -EBUSY;
245 } 245 }
246 246
247 if (!(data = kmalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { 247 if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) {
248 err = -ENOMEM; 248 err = -ENOMEM;
249 goto error_release; 249 goto error_release;
250 } 250 }
251 memset(data, 0x00, sizeof(struct smsc47b397_data));
252 251
253 new_client = &data->client; 252 new_client = &data->client;
254 i2c_set_clientdata(new_client, data); 253 i2c_set_clientdata(new_client, data);
@@ -299,7 +298,7 @@ static int __init smsc47b397_find(unsigned short *addr)
299 superio_enter(); 298 superio_enter();
300 id = superio_inb(SUPERIO_REG_DEVID); 299 id = superio_inb(SUPERIO_REG_DEVID);
301 300
302 if (id != 0x6f) { 301 if ((id != 0x6f) && (id != 0x81)) {
303 superio_exit(); 302 superio_exit();
304 return -ENODEV; 303 return -ENODEV;
305 } 304 }
@@ -310,8 +309,9 @@ static int __init smsc47b397_find(unsigned short *addr)
310 *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8) 309 *addr = (superio_inb(SUPERIO_REG_BASE_MSB) << 8)
311 | superio_inb(SUPERIO_REG_BASE_LSB); 310 | superio_inb(SUPERIO_REG_BASE_LSB);
312 311
313 printk(KERN_INFO "smsc47b397: found SMSC LPC47B397-NC " 312 printk(KERN_INFO "smsc47b397: found SMSC %s "
314 "(base address 0x%04x, revision %u)\n", *addr, rev); 313 "(base address 0x%04x, revision %u)\n",
314 id == 0x81 ? "SCH5307-NS" : "LPC47B397-NC", *addr, rev);
315 315
316 superio_exit(); 316 superio_exit();
317 return 0; 317 return 0;
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index c9cc683eba4a..5905c1af88f2 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -3,7 +3,7 @@
3 for hardware monitoring 3 for hardware monitoring
4 4
5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, 5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x,
6 LPC47M15x and LPC47M192 Super-I/O chips. 6 LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips.
7 7
8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
@@ -356,6 +356,8 @@ static int __init smsc47m1_find(unsigned short *addr)
356 * 0x5F) and LPC47B27x (device id 0x51) have fan control. 356 * 0x5F) and LPC47B27x (device id 0x51) have fan control.
357 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" 357 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block"
358 * can do much more besides (device id 0x60). 358 * can do much more besides (device id 0x60).
359 * The LPC47M997 is undocumented, but seems to be compatible with
360 * the LPC47M192, and has the same device id.
359 */ 361 */
360 if (val == 0x51) 362 if (val == 0x51)
361 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); 363 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n");
@@ -364,7 +366,8 @@ static int __init smsc47m1_find(unsigned short *addr)
364 else if (val == 0x5F) 366 else if (val == 0x5F)
365 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); 367 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n");
366 else if (val == 0x60) 368 else if (val == 0x60)
367 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); 369 printk(KERN_INFO "smsc47m1: Found SMSC "
370 "LPC47M15x/LPC47M192/LPC47M997\n");
368 else { 371 else {
369 superio_exit(); 372 superio_exit();
370 return -ENODEV; 373 return -ENODEV;
@@ -396,11 +399,10 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
396 return -EBUSY; 399 return -EBUSY;
397 } 400 }
398 401
399 if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) { 402 if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) {
400 err = -ENOMEM; 403 err = -ENOMEM;
401 goto error_release; 404 goto error_release;
402 } 405 }
403 memset(data, 0x00, sizeof(struct smsc47m1_data));
404 406
405 new_client = &data->client; 407 new_client = &data->client;
406 i2c_set_clientdata(new_client, data); 408 i2c_set_clientdata(new_client, data);
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 05ddc88e7dd2..6f696f897176 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -44,7 +44,7 @@
44 44
45/* If force_addr is set to anything different from 0, we forcibly enable 45/* If force_addr is set to anything different from 0, we forcibly enable
46 the device at the given address. */ 46 the device at the given address. */
47static unsigned short force_addr = 0; 47static unsigned short force_addr;
48module_param(force_addr, ushort, 0); 48module_param(force_addr, ushort, 0);
49MODULE_PARM_DESC(force_addr, 49MODULE_PARM_DESC(force_addr,
50 "Initialize the base address of the sensors"); 50 "Initialize the base address of the sensors");
@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
198 but the function is very linear in the useful range (0-80 deg C), so 198 but the function is very linear in the useful range (0-80 deg C), so
199 we'll just use linear interpolation for 10-bit readings.) So, tempLUT 199 we'll just use linear interpolation for 10-bit readings.) So, tempLUT
200 is the temp at via register values 0-255: */ 200 is the temp at via register values 0-255: */
201static const long tempLUT[] = 201static const s16 tempLUT[] =
202{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, 202{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
203 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, 203 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
204 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, 204 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val)
270} 270}
271 271
272/* for 8-bit temperature hyst and over registers */ 272/* for 8-bit temperature hyst and over registers */
273#define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) 273#define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100)
274 274
275/* for 10-bit temperature readings */ 275/* for 10-bit temperature readings */
276static inline long TEMP_FROM_REG10(u16 val) 276static inline long TEMP_FROM_REG10(u16 val)
@@ -589,10 +589,8 @@ static int via686a_detect(struct i2c_adapter *adapter)
589 u16 val; 589 u16 val;
590 590
591 /* 8231 requires multiple of 256, we enforce that on 686 as well */ 591 /* 8231 requires multiple of 256, we enforce that on 686 as well */
592 if (force_addr)
593 address = force_addr & 0xFF00;
594
595 if (force_addr) { 592 if (force_addr) {
593 address = force_addr & 0xFF00;
596 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", 594 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
597 address); 595 address);
598 if (PCIBIOS_SUCCESSFUL != 596 if (PCIBIOS_SUCCESSFUL !=
@@ -603,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter)
603 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) 601 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))
604 return -ENODEV; 602 return -ENODEV;
605 if (!(val & 0x0001)) { 603 if (!(val & 0x0001)) {
606 dev_warn(&adapter->dev, "enabling sensors\n"); 604 if (force_addr) {
607 if (PCIBIOS_SUCCESSFUL != 605 dev_info(&adapter->dev, "enabling sensors\n");
608 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, 606 if (PCIBIOS_SUCCESSFUL !=
609 val | 0x0001)) 607 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
608 val | 0x0001))
609 return -ENODEV;
610 } else {
611 dev_warn(&adapter->dev, "sensors disabled - enable "
612 "with force_addr=0x%x\n", address);
610 return -ENODEV; 613 return -ENODEV;
614 }
611 } 615 }
612 616
613 /* Reserve the ISA region */ 617 /* Reserve the ISA region */
@@ -617,11 +621,10 @@ static int via686a_detect(struct i2c_adapter *adapter)
617 return -ENODEV; 621 return -ENODEV;
618 } 622 }
619 623
620 if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { 624 if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
621 err = -ENOMEM; 625 err = -ENOMEM;
622 goto exit_release; 626 goto exit_release;
623 } 627 }
624 memset(data, 0, sizeof(struct via686a_data));
625 628
626 new_client = &data->client; 629 new_client = &data->client;
627 i2c_set_clientdata(new_client, data); 630 i2c_set_clientdata(new_client, data);
@@ -708,7 +711,6 @@ static int via686a_detach_client(struct i2c_client *client)
708 return 0; 711 return 0;
709} 712}
710 713
711/* Called when we have found a new VIA686A. Set limits, etc. */
712static void via686a_init_client(struct i2c_client *client) 714static void via686a_init_client(struct i2c_client *client)
713{ 715{
714 u8 reg; 716 u8 reg;
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index b60efe8f8b26..eee22a57e929 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -105,7 +105,9 @@ superio_exit(void)
105 * ISA constants 105 * ISA constants
106 */ 106 */
107 107
108#define REGION_LENGTH 8 108#define REGION_ALIGNMENT ~7
109#define REGION_OFFSET 5
110#define REGION_LENGTH 2
109#define ADDR_REG_OFFSET 5 111#define ADDR_REG_OFFSET 5
110#define DATA_REG_OFFSET 6 112#define DATA_REG_OFFSET 6
111 113
@@ -673,16 +675,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
673 struct w83627ehf_data *data; 675 struct w83627ehf_data *data;
674 int i, err = 0; 676 int i, err = 0;
675 677
676 if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { 678 if (!request_region(address + REGION_OFFSET, REGION_LENGTH,
679 w83627ehf_driver.name)) {
677 err = -EBUSY; 680 err = -EBUSY;
678 goto exit; 681 goto exit;
679 } 682 }
680 683
681 if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { 684 if (!(data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) {
682 err = -ENOMEM; 685 err = -ENOMEM;
683 goto exit_release; 686 goto exit_release;
684 } 687 }
685 memset(data, 0, sizeof(struct w83627ehf_data));
686 688
687 client = &data->client; 689 client = &data->client;
688 i2c_set_clientdata(client, data); 690 i2c_set_clientdata(client, data);
@@ -762,7 +764,7 @@ exit_detach:
762exit_free: 764exit_free:
763 kfree(data); 765 kfree(data);
764exit_release: 766exit_release:
765 release_region(address, REGION_LENGTH); 767 release_region(address + REGION_OFFSET, REGION_LENGTH);
766exit: 768exit:
767 return err; 769 return err;
768} 770}
@@ -776,7 +778,7 @@ static int w83627ehf_detach_client(struct i2c_client *client)
776 778
777 if ((err = i2c_detach_client(client))) 779 if ((err = i2c_detach_client(client)))
778 return err; 780 return err;
779 release_region(client->addr, REGION_LENGTH); 781 release_region(client->addr + REGION_OFFSET, REGION_LENGTH);
780 kfree(data); 782 kfree(data);
781 783
782 return 0; 784 return 0;
@@ -807,7 +809,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr)
807 superio_select(W83627EHF_LD_HWM); 809 superio_select(W83627EHF_LD_HWM);
808 val = (superio_inb(SIO_REG_ADDR) << 8) 810 val = (superio_inb(SIO_REG_ADDR) << 8)
809 | superio_inb(SIO_REG_ADDR + 1); 811 | superio_inb(SIO_REG_ADDR + 1);
810 *addr = val & ~(REGION_LENGTH - 1); 812 *addr = val & REGION_ALIGNMENT;
811 if (*addr == 0) { 813 if (*addr == 0) {
812 superio_exit(); 814 superio_exit();
813 return -ENODEV; 815 return -ENODEV;
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 3479dc5208e2..70ef926c3bd8 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -142,10 +142,14 @@ superio_exit(void)
142#define WINB_BASE_REG 0x60 142#define WINB_BASE_REG 0x60
143/* Constants specified below */ 143/* Constants specified below */
144 144
145/* Length of ISA address segment */ 145/* Alignment of the base address */
146#define WINB_EXTENT 8 146#define WINB_ALIGNMENT ~7
147 147
148/* Where are the ISA address/data registers relative to the base address */ 148/* Offset & size of I/O region we are interested in */
149#define WINB_REGION_OFFSET 5
150#define WINB_REGION_SIZE 2
151
152/* Where are the sensors address/data registers relative to the base address */
149#define W83781D_ADDR_REG_OFFSET 5 153#define W83781D_ADDR_REG_OFFSET 5
150#define W83781D_DATA_REG_OFFSET 6 154#define W83781D_DATA_REG_OFFSET 6
151 155
@@ -197,7 +201,6 @@ superio_exit(void)
197 201
198#define W83627HF_REG_PWM1 0x5A 202#define W83627HF_REG_PWM1 0x5A
199#define W83627HF_REG_PWM2 0x5B 203#define W83627HF_REG_PWM2 0x5B
200#define W83627HF_REG_PWMCLK12 0x5C
201 204
202#define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ 205#define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */
203#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ 206#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */
@@ -981,7 +984,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr)
981 superio_select(W83627HF_LD_HWM); 984 superio_select(W83627HF_LD_HWM);
982 val = (superio_inb(WINB_BASE_REG) << 8) | 985 val = (superio_inb(WINB_BASE_REG) << 8) |
983 superio_inb(WINB_BASE_REG + 1); 986 superio_inb(WINB_BASE_REG + 1);
984 *addr = val & ~(WINB_EXTENT - 1); 987 *addr = val & WINB_ALIGNMENT;
985 if (*addr == 0 && force_addr == 0) { 988 if (*addr == 0 && force_addr == 0) {
986 superio_exit(); 989 superio_exit();
987 return -ENODEV; 990 return -ENODEV;
@@ -1000,9 +1003,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1000 const char *client_name = ""; 1003 const char *client_name = "";
1001 1004
1002 if(force_addr) 1005 if(force_addr)
1003 address = force_addr & ~(WINB_EXTENT - 1); 1006 address = force_addr & WINB_ALIGNMENT;
1004 1007
1005 if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { 1008 if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE,
1009 w83627hf_driver.name)) {
1006 err = -EBUSY; 1010 err = -EBUSY;
1007 goto ERROR0; 1011 goto ERROR0;
1008 } 1012 }
@@ -1041,11 +1045,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1041 client structure, even though we cannot fill it completely yet. 1045 client structure, even though we cannot fill it completely yet.
1042 But it allows us to access w83627hf_{read,write}_value. */ 1046 But it allows us to access w83627hf_{read,write}_value. */
1043 1047
1044 if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { 1048 if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) {
1045 err = -ENOMEM; 1049 err = -ENOMEM;
1046 goto ERROR1; 1050 goto ERROR1;
1047 } 1051 }
1048 memset(data, 0, sizeof(struct w83627hf_data));
1049 1052
1050 new_client = &data->client; 1053 new_client = &data->client;
1051 i2c_set_clientdata(new_client, data); 1054 i2c_set_clientdata(new_client, data);
@@ -1148,7 +1151,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1148 ERROR2: 1151 ERROR2:
1149 kfree(data); 1152 kfree(data);
1150 ERROR1: 1153 ERROR1:
1151 release_region(address, WINB_EXTENT); 1154 release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE);
1152 ERROR0: 1155 ERROR0:
1153 return err; 1156 return err;
1154} 1157}
@@ -1163,7 +1166,7 @@ static int w83627hf_detach_client(struct i2c_client *client)
1163 if ((err = i2c_detach_client(client))) 1166 if ((err = i2c_detach_client(client)))
1164 return err; 1167 return err;
1165 1168
1166 release_region(client->addr, WINB_EXTENT); 1169 release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE);
1167 kfree(data); 1170 kfree(data);
1168 1171
1169 return 0; 1172 return 0;
@@ -1275,7 +1278,6 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1275 return 0; 1278 return 0;
1276} 1279}
1277 1280
1278/* Called when we have found a new W83781D. It should set limits, etc. */
1279static void w83627hf_init_client(struct i2c_client *client) 1281static void w83627hf_init_client(struct i2c_client *client)
1280{ 1282{
1281 struct w83627hf_data *data = i2c_get_clientdata(client); 1283 struct w83627hf_data *data = i2c_get_clientdata(client);
@@ -1369,12 +1371,6 @@ static void w83627hf_init_client(struct i2c_client *client)
1369 } 1371 }
1370 } 1372 }
1371 1373
1372 if (type == w83627hf) {
1373 /* enable PWM2 control (can't hurt since PWM reg
1374 should have been reset to 0xff) */
1375 w83627hf_write_value(client, W83627HF_REG_PWMCLK12,
1376 0x19);
1377 }
1378 /* enable comparator mode for temp2 and temp3 so 1374 /* enable comparator mode for temp2 and temp3 so
1379 alarm indication will work correctly */ 1375 alarm indication will work correctly */
1380 i = w83627hf_read_value(client, W83781D_REG_IRQ); 1376 i = w83627hf_read_value(client, W83781D_REG_IRQ);
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 4c43337ca780..9265f32122fa 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -889,12 +889,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
889 const char *client_name = ""; 889 const char *client_name = "";
890 struct w83781d_data *data = i2c_get_clientdata(new_client); 890 struct w83781d_data *data = i2c_get_clientdata(new_client);
891 891
892 data->lm75[0] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 892 data->lm75[0] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
893 if (!(data->lm75[0])) { 893 if (!(data->lm75[0])) {
894 err = -ENOMEM; 894 err = -ENOMEM;
895 goto ERROR_SC_0; 895 goto ERROR_SC_0;
896 } 896 }
897 memset(data->lm75[0], 0x00, sizeof (struct i2c_client));
898 897
899 id = i2c_adapter_id(adapter); 898 id = i2c_adapter_id(adapter);
900 899
@@ -919,13 +918,11 @@ w83781d_detect_subclients(struct i2c_adapter *adapter, int address, int kind,
919 } 918 }
920 919
921 if (kind != w83783s) { 920 if (kind != w83783s) {
922 921 data->lm75[1] = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
923 data->lm75[1] = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
924 if (!(data->lm75[1])) { 922 if (!(data->lm75[1])) {
925 err = -ENOMEM; 923 err = -ENOMEM;
926 goto ERROR_SC_1; 924 goto ERROR_SC_1;
927 } 925 }
928 memset(data->lm75[1], 0x0, sizeof(struct i2c_client));
929 926
930 if (force_subclients[0] == id && 927 if (force_subclients[0] == id &&
931 force_subclients[1] == address) { 928 force_subclients[1] == address) {
@@ -1064,11 +1061,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1064 client structure, even though we cannot fill it completely yet. 1061 client structure, even though we cannot fill it completely yet.
1065 But it allows us to access w83781d_{read,write}_value. */ 1062 But it allows us to access w83781d_{read,write}_value. */
1066 1063
1067 if (!(data = kmalloc(sizeof(struct w83781d_data), GFP_KERNEL))) { 1064 if (!(data = kzalloc(sizeof(struct w83781d_data), GFP_KERNEL))) {
1068 err = -ENOMEM; 1065 err = -ENOMEM;
1069 goto ERROR1; 1066 goto ERROR1;
1070 } 1067 }
1071 memset(data, 0, sizeof(struct w83781d_data));
1072 1068
1073 new_client = &data->client; 1069 new_client = &data->client;
1074 i2c_set_clientdata(new_client, data); 1070 i2c_set_clientdata(new_client, data);
@@ -1451,7 +1447,6 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
1451 return 0; 1447 return 0;
1452} 1448}
1453 1449
1454/* Called when we have found a new W83781D. It should set limits, etc. */
1455static void 1450static void
1456w83781d_init_client(struct i2c_client *client) 1451w83781d_init_client(struct i2c_client *client)
1457{ 1452{
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index ba0c28015f6a..4be59dbb78c4 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -1086,11 +1086,10 @@ w83792d_create_subclient(struct i2c_adapter *adapter,
1086 int err; 1086 int err;
1087 struct i2c_client *sub_client; 1087 struct i2c_client *sub_client;
1088 1088
1089 (*sub_cli) = sub_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 1089 (*sub_cli) = sub_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1090 if (!(sub_client)) { 1090 if (!(sub_client)) {
1091 return -ENOMEM; 1091 return -ENOMEM;
1092 } 1092 }
1093 memset(sub_client, 0x00, sizeof(struct i2c_client));
1094 sub_client->addr = 0x48 + addr; 1093 sub_client->addr = 0x48 + addr;
1095 i2c_set_clientdata(sub_client, NULL); 1094 i2c_set_clientdata(sub_client, NULL);
1096 sub_client->adapter = adapter; 1095 sub_client->adapter = adapter;
@@ -1184,11 +1183,10 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1184 client structure, even though we cannot fill it completely yet. 1183 client structure, even though we cannot fill it completely yet.
1185 But it allows us to access w83792d_{read,write}_value. */ 1184 But it allows us to access w83792d_{read,write}_value. */
1186 1185
1187 if (!(data = kmalloc(sizeof(struct w83792d_data), GFP_KERNEL))) { 1186 if (!(data = kzalloc(sizeof(struct w83792d_data), GFP_KERNEL))) {
1188 err = -ENOMEM; 1187 err = -ENOMEM;
1189 goto ERROR0; 1188 goto ERROR0;
1190 } 1189 }
1191 memset(data, 0, sizeof(struct w83792d_data));
1192 1190
1193 new_client = &data->client; 1191 new_client = &data->client;
1194 i2c_set_clientdata(new_client, data); 1192 i2c_set_clientdata(new_client, data);
@@ -1429,7 +1427,6 @@ w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
1429 return 0; 1427 return 0;
1430} 1428}
1431 1429
1432/* Called when we have found a new W83792D. It should set limits, etc. */
1433static void 1430static void
1434w83792d_init_client(struct i2c_client *client) 1431w83792d_init_client(struct i2c_client *client)
1435{ 1432{
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 133e34ab1d0a..f495b6378668 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -37,6 +37,7 @@
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h>
40#include <linux/err.h> 41#include <linux/err.h>
41 42
42/* How many retries on register read error */ 43/* How many retries on register read error */
@@ -73,7 +74,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts);
73 * The W83L785TS-S uses signed 8-bit values. 74 * The W83L785TS-S uses signed 8-bit values.
74 */ 75 */
75 76
76#define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) 77#define TEMP_FROM_REG(val) ((val) * 1000)
77 78
78/* 79/*
79 * Functions declaration 80 * Functions declaration
@@ -111,27 +112,24 @@ struct w83l785ts_data {
111 unsigned long last_updated; /* in jiffies */ 112 unsigned long last_updated; /* in jiffies */
112 113
113 /* registers values */ 114 /* registers values */
114 u8 temp, temp_over; 115 s8 temp[2]; /* 0: input
116 1: critical limit */
115}; 117};
116 118
117/* 119/*
118 * Sysfs stuff 120 * Sysfs stuff
119 */ 121 */
120 122
121static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf) 123static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
124 char *buf)
122{ 125{
126 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
123 struct w83l785ts_data *data = w83l785ts_update_device(dev); 127 struct w83l785ts_data *data = w83l785ts_update_device(dev);
124 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); 128 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
125} 129}
126 130
127static ssize_t show_temp_over(struct device *dev, struct device_attribute *attr, char *buf) 131static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
128{ 132static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1);
129 struct w83l785ts_data *data = w83l785ts_update_device(dev);
130 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
131}
132
133static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
134static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL);
135 133
136/* 134/*
137 * Real code 135 * Real code
@@ -158,12 +156,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
158 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 156 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
159 goto exit; 157 goto exit;
160 158
161 if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) { 159 if (!(data = kzalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) {
162 err = -ENOMEM; 160 err = -ENOMEM;
163 goto exit; 161 goto exit;
164 } 162 }
165 memset(data, 0, sizeof(struct w83l785ts_data));
166
167 163
168 /* The common I2C client data is placed right before the 164 /* The common I2C client data is placed right before the
169 * W83L785TS-specific data. */ 165 * W83L785TS-specific data. */
@@ -228,7 +224,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
228 init_MUTEX(&data->update_lock); 224 init_MUTEX(&data->update_lock);
229 225
230 /* Default values in case the first read fails (unlikely). */ 226 /* Default values in case the first read fails (unlikely). */
231 data->temp_over = data->temp = 0; 227 data->temp[1] = data->temp[0] = 0;
232 228
233 /* Tell the I2C layer a new client has arrived. */ 229 /* Tell the I2C layer a new client has arrived. */
234 if ((err = i2c_attach_client(new_client))) 230 if ((err = i2c_attach_client(new_client)))
@@ -246,8 +242,10 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
246 goto exit_detach; 242 goto exit_detach;
247 } 243 }
248 244
249 device_create_file(&new_client->dev, &dev_attr_temp1_input); 245 device_create_file(&new_client->dev,
250 device_create_file(&new_client->dev, &dev_attr_temp1_max); 246 &sensor_dev_attr_temp1_input.dev_attr);
247 device_create_file(&new_client->dev,
248 &sensor_dev_attr_temp1_max.dev_attr);
251 249
252 return 0; 250 return 0;
253 251
@@ -305,10 +303,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
305 303
306 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) { 304 if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
307 dev_dbg(&client->dev, "Updating w83l785ts data.\n"); 305 dev_dbg(&client->dev, "Updating w83l785ts data.\n");
308 data->temp = w83l785ts_read_value(client, 306 data->temp[0] = w83l785ts_read_value(client,
309 W83L785TS_REG_TEMP, data->temp); 307 W83L785TS_REG_TEMP, data->temp[0]);
310 data->temp_over = w83l785ts_read_value(client, 308 data->temp[1] = w83l785ts_read_value(client,
311 W83L785TS_REG_TEMP_OVER, data->temp_over); 309 W83L785TS_REG_TEMP_OVER, data->temp[1]);
312 310
313 data->last_updated = jiffies; 311 data->last_updated = jiffies;
314 data->valid = 1; 312 data->valid = 1;
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index beb10edfe9c1..82946acab4c7 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -34,7 +34,7 @@
34#define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0) 34#define DEB2(fmt, args...) do { if (i2c_debug>=2) printk(fmt, ## args); } while(0)
35#define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0) 35#define DEB3(fmt, args...) do { if (i2c_debug>=3) printk(fmt, ## args); } while(0)
36 36
37static int i2c_debug=0; 37static int i2c_debug;
38 38
39#define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val) 39#define pca_outw(adap, reg, val) adap->write_byte(adap, reg, val)
40#define pca_inw(adap, reg) adap->read_byte(adap, reg) 40#define pca_inw(adap, reg) adap->read_byte(adap, reg)
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c
index 8ed5ad12552f..938848ae162d 100644
--- a/drivers/i2c/algos/i2c-algo-sibyte.c
+++ b/drivers/i2c/algos/i2c-algo-sibyte.c
@@ -42,7 +42,7 @@
42 42
43/* module parameters: 43/* module parameters:
44 */ 44 */
45static int bit_scan=0; /* have a look at what's hanging 'round */ 45static int bit_scan; /* have a look at what's hanging 'round */
46 46
47 47
48static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr, 48static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 3badfec75b1c..4010fe92e72b 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -135,11 +135,12 @@ config I2C_I810
135 help 135 help
136 If you say yes to this option, support will be included for the Intel 136 If you say yes to this option, support will be included for the Intel
137 810/815 family of mainboard I2C interfaces. Specifically, the 137 810/815 family of mainboard I2C interfaces. Specifically, the
138 following versions of the chipset is supported: 138 following versions of the chipset are supported:
139 i810AA 139 i810AA
140 i810AB 140 i810AB
141 i810E 141 i810E
142 i815 142 i815
143 i845G
143 144
144 This driver can also be built as a module. If so, the module 145 This driver can also be built as a module. If so, the module
145 will be called i2c-i810. 146 will be called i2c-i810.
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index f021acd2674e..ba90f5140af6 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -134,7 +134,7 @@
134 /* -> Read = 1 */ 134 /* -> Read = 1 */
135#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */ 135#define ALI1535_SMBIO_EN 0x04 /* SMB I/O Space enable */
136 136
137 137static struct pci_driver ali1535_driver;
138static unsigned short ali1535_smba; 138static unsigned short ali1535_smba;
139static DECLARE_MUTEX(i2c_ali1535_sem); 139static DECLARE_MUTEX(i2c_ali1535_sem);
140 140
@@ -162,7 +162,8 @@ static int ali1535_setup(struct pci_dev *dev)
162 goto exit; 162 goto exit;
163 } 163 }
164 164
165 if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, "ali1535-smb")) { 165 if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
166 ali1535_driver.name)) {
166 dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", 167 dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
167 ali1535_smba); 168 ali1535_smba);
168 goto exit; 169 goto exit;
@@ -480,7 +481,6 @@ static struct i2c_adapter ali1535_adapter = {
480 .owner = THIS_MODULE, 481 .owner = THIS_MODULE,
481 .class = I2C_CLASS_HWMON, 482 .class = I2C_CLASS_HWMON,
482 .algo = &smbus_algorithm, 483 .algo = &smbus_algorithm,
483 .name = "unset",
484}; 484};
485 485
486static struct pci_device_id ali1535_ids[] = { 486static struct pci_device_id ali1535_ids[] = {
@@ -513,6 +513,7 @@ static void __devexit ali1535_remove(struct pci_dev *dev)
513} 513}
514 514
515static struct pci_driver ali1535_driver = { 515static struct pci_driver ali1535_driver = {
516 .owner = THIS_MODULE,
516 .name = "ali1535_smbus", 517 .name = "ali1535_smbus",
517 .id_table = ali1535_ids, 518 .id_table = ali1535_ids,
518 .probe = ali1535_probe, 519 .probe = ali1535_probe,
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 86947504aea1..f1a62d892425 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -60,6 +60,7 @@
60 60
61#define HST_CNTL2_SIZEMASK 0x38 61#define HST_CNTL2_SIZEMASK 0x38
62 62
63static struct pci_driver ali1563_pci_driver;
63static unsigned short ali1563_smba; 64static unsigned short ali1563_smba;
64 65
65static int ali1563_transaction(struct i2c_adapter * a, int size) 66static int ali1563_transaction(struct i2c_adapter * a, int size)
@@ -350,7 +351,8 @@ static int __devinit ali1563_setup(struct pci_dev * dev)
350 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); 351 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n");
351 goto Err; 352 goto Err;
352 } 353 }
353 if (!request_region(ali1563_smba,ALI1563_SMB_IOSIZE,"i2c-ali1563")) { 354 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
355 ali1563_pci_driver.name)) {
354 dev_warn(&dev->dev,"Could not allocate I/O space"); 356 dev_warn(&dev->dev,"Could not allocate I/O space");
355 goto Err; 357 goto Err;
356 } 358 }
@@ -406,7 +408,8 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = {
406MODULE_DEVICE_TABLE (pci, ali1563_id_table); 408MODULE_DEVICE_TABLE (pci, ali1563_id_table);
407 409
408static struct pci_driver ali1563_pci_driver = { 410static struct pci_driver ali1563_pci_driver = {
409 .name = "ali1563_i2c", 411 .owner = THIS_MODULE,
412 .name = "ali1563_smbus",
410 .id_table = ali1563_id_table, 413 .id_table = ali1563_id_table,
411 .probe = ali1563_probe, 414 .probe = ali1563_probe,
412 .remove = __devexit_p(ali1563_remove), 415 .remove = __devexit_p(ali1563_remove),
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index b3f50bff39a0..400b08ed4299 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -125,12 +125,13 @@
125 125
126/* If force_addr is set to anything different from 0, we forcibly enable 126/* If force_addr is set to anything different from 0, we forcibly enable
127 the device at the given address. */ 127 the device at the given address. */
128static u16 force_addr = 0; 128static u16 force_addr;
129module_param(force_addr, ushort, 0); 129module_param(force_addr, ushort, 0);
130MODULE_PARM_DESC(force_addr, 130MODULE_PARM_DESC(force_addr,
131 "Initialize the base address of the i2c controller"); 131 "Initialize the base address of the i2c controller");
132 132
133static unsigned short ali15x3_smba = 0; 133static struct pci_driver ali15x3_driver;
134static unsigned short ali15x3_smba;
134 135
135static int ali15x3_setup(struct pci_dev *ALI15X3_dev) 136static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
136{ 137{
@@ -166,7 +167,8 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
166 if(force_addr) 167 if(force_addr)
167 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); 168 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
168 169
169 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { 170 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
171 ali15x3_driver.name)) {
170 dev_err(&ALI15X3_dev->dev, 172 dev_err(&ALI15X3_dev->dev,
171 "ALI15X3_smb region 0x%x already in use!\n", 173 "ALI15X3_smb region 0x%x already in use!\n",
172 ali15x3_smba); 174 ali15x3_smba);
@@ -470,7 +472,6 @@ static struct i2c_adapter ali15x3_adapter = {
470 .owner = THIS_MODULE, 472 .owner = THIS_MODULE,
471 .class = I2C_CLASS_HWMON, 473 .class = I2C_CLASS_HWMON,
472 .algo = &smbus_algorithm, 474 .algo = &smbus_algorithm,
473 .name = "unset",
474}; 475};
475 476
476static struct pci_device_id ali15x3_ids[] = { 477static struct pci_device_id ali15x3_ids[] = {
@@ -503,6 +504,7 @@ static void __devexit ali15x3_remove(struct pci_dev *dev)
503} 504}
504 505
505static struct pci_driver ali15x3_driver = { 506static struct pci_driver ali15x3_driver = {
507 .owner = THIS_MODULE,
506 .name = "ali15x3_smbus", 508 .name = "ali15x3_smbus",
507 .id_table = ali15x3_ids, 509 .id_table = ali15x3_ids,
508 .probe = ali15x3_probe, 510 .probe = ali15x3_probe,
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 4e553e8c5cba..f51ab652300a 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void)
169 init_MUTEX(&amd756_lock); 169 init_MUTEX(&amd756_lock);
170 170
171 /* Define the 5 virtual adapters and algorithms structures */ 171 /* Define the 5 virtual adapters and algorithms structures */
172 if (!(s4882_adapter = kmalloc(5 * sizeof(struct i2c_adapter), 172 if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
173 GFP_KERNEL))) { 173 GFP_KERNEL))) {
174 error = -ENOMEM; 174 error = -ENOMEM;
175 goto ERROR1; 175 goto ERROR1;
176 } 176 }
177 if (!(s4882_algo = kmalloc(5 * sizeof(struct i2c_algorithm), 177 if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm),
178 GFP_KERNEL))) { 178 GFP_KERNEL))) {
179 error = -ENOMEM; 179 error = -ENOMEM;
180 goto ERROR2; 180 goto ERROR2;
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 6ad0603384b8..de035d137c3f 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -85,8 +85,8 @@
85#define AMD756_PROCESS_CALL 0x04 85#define AMD756_PROCESS_CALL 0x04
86#define AMD756_BLOCK_DATA 0x05 86#define AMD756_BLOCK_DATA 0x05
87 87
88 88static struct pci_driver amd756_driver;
89static unsigned short amd756_ioport = 0; 89static unsigned short amd756_ioport;
90 90
91/* 91/*
92 SMBUS event = I/O 28-29 bit 11 92 SMBUS event = I/O 28-29 bit 11
@@ -303,7 +303,6 @@ struct i2c_adapter amd756_smbus = {
303 .owner = THIS_MODULE, 303 .owner = THIS_MODULE,
304 .class = I2C_CLASS_HWMON, 304 .class = I2C_CLASS_HWMON,
305 .algo = &smbus_algorithm, 305 .algo = &smbus_algorithm,
306 .name = "unset",
307}; 306};
308 307
309enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 }; 308enum chiptype { AMD756, AMD766, AMD768, NFORCE, AMD8111 };
@@ -365,7 +364,7 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
365 amd756_ioport += SMB_ADDR_OFFSET; 364 amd756_ioport += SMB_ADDR_OFFSET;
366 } 365 }
367 366
368 if (!request_region(amd756_ioport, SMB_IOSIZE, "amd756-smbus")) { 367 if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) {
369 dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", 368 dev_err(&pdev->dev, "SMB region 0x%x already in use!\n",
370 amd756_ioport); 369 amd756_ioport);
371 return -ENODEV; 370 return -ENODEV;
@@ -402,6 +401,7 @@ static void __devexit amd756_remove(struct pci_dev *dev)
402} 401}
403 402
404static struct pci_driver amd756_driver = { 403static struct pci_driver amd756_driver = {
404 .owner = THIS_MODULE,
405 .name = "amd756_smbus", 405 .name = "amd756_smbus",
406 .id_table = amd756_ids, 406 .id_table = amd756_ids,
407 .probe = amd756_probe, 407 .probe = amd756_probe,
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index 45ea24ba14d5..f3b79a68dbec 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -30,6 +30,8 @@ struct amd_smbus {
30 int size; 30 int size;
31}; 31};
32 32
33static struct pci_driver amd8111_driver;
34
33/* 35/*
34 * AMD PCI control registers definitions. 36 * AMD PCI control registers definitions.
35 */ 37 */
@@ -242,7 +244,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
242 break; 244 break;
243 245
244 case I2C_SMBUS_BLOCK_PROC_CALL: 246 case I2C_SMBUS_BLOCK_PROC_CALL:
245 protocol |= pec;
246 len = min_t(u8, data->block[0], 31); 247 len = min_t(u8, data->block[0], 31);
247 amd_ec_write(smbus, AMD_SMB_CMD, command); 248 amd_ec_write(smbus, AMD_SMB_CMD, command);
248 amd_ec_write(smbus, AMD_SMB_BCNT, len); 249 amd_ec_write(smbus, AMD_SMB_BCNT, len);
@@ -252,13 +253,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
252 read_write = I2C_SMBUS_READ; 253 read_write = I2C_SMBUS_READ;
253 break; 254 break;
254 255
255 case I2C_SMBUS_WORD_DATA_PEC:
256 case I2C_SMBUS_BLOCK_DATA_PEC:
257 case I2C_SMBUS_PROC_CALL_PEC:
258 case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
259 dev_warn(&adap->dev, "Unexpected software PEC transaction %d\n.", size);
260 return -1;
261
262 default: 256 default:
263 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 257 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
264 return -1; 258 return -1;
@@ -343,16 +337,15 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
343 if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) 337 if (~pci_resource_flags(dev, 0) & IORESOURCE_IO)
344 return -ENODEV; 338 return -ENODEV;
345 339
346 smbus = kmalloc(sizeof(struct amd_smbus), GFP_KERNEL); 340 smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL);
347 if (!smbus) 341 if (!smbus)
348 return -ENOMEM; 342 return -ENOMEM;
349 memset(smbus, 0, sizeof(struct amd_smbus));
350 343
351 smbus->dev = dev; 344 smbus->dev = dev;
352 smbus->base = pci_resource_start(dev, 0); 345 smbus->base = pci_resource_start(dev, 0);
353 smbus->size = pci_resource_len(dev, 0); 346 smbus->size = pci_resource_len(dev, 0);
354 347
355 if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) 348 if (!request_region(smbus->base, smbus->size, amd8111_driver.name))
356 goto out_kfree; 349 goto out_kfree;
357 350
358 smbus->adapter.owner = THIS_MODULE; 351 smbus->adapter.owner = THIS_MODULE;
@@ -391,6 +384,7 @@ static void __devexit amd8111_remove(struct pci_dev *dev)
391} 384}
392 385
393static struct pci_driver amd8111_driver = { 386static struct pci_driver amd8111_driver = {
387 .owner = THIS_MODULE,
394 .name = "amd8111_smbus2", 388 .name = "amd8111_smbus2",
395 .id_table = amd8111_ids, 389 .id_table = amd8111_ids,
396 .probe = amd8111_probe, 390 .probe = amd8111_probe,
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 6930b660e508..59f8308c2356 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -22,7 +22,7 @@
22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl> */ 23 Frodo Looijaard <frodol@dds.nl> */
24 24
25/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 25/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of
26 for Alpha Processor Inc. UP-2000(+) boards */ 26 for Alpha Processor Inc. UP-2000(+) boards */
27 27
28#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -46,12 +46,14 @@
46#define DEFAULT_BASE 0x330 46#define DEFAULT_BASE 0x330
47 47
48static int base; 48static int base;
49static u8 __iomem *base_iomem;
50
49static int irq; 51static int irq;
50static int clock = 0x1c; 52static int clock = 0x1c;
51static int own = 0x55; 53static int own = 0x55;
52static int mmapped; 54static int mmapped;
53 55
54/* vdovikin: removed static struct i2c_pcf_isa gpi; code - 56/* vdovikin: removed static struct i2c_pcf_isa gpi; code -
55 this module in real supports only one device, due to missing arguments 57 this module in real supports only one device, due to missing arguments
56 in some functions, called from the algo-pcf module. Sometimes it's 58 in some functions, called from the algo-pcf module. Sometimes it's
57 need to be rewriten - but for now just remove this for simpler reading */ 59 need to be rewriten - but for now just remove this for simpler reading */
@@ -60,40 +62,33 @@ static wait_queue_head_t pcf_wait;
60static int pcf_pending; 62static int pcf_pending;
61static spinlock_t lock; 63static spinlock_t lock;
62 64
65static struct i2c_adapter pcf_isa_ops;
66
63/* ----- local functions ---------------------------------------------- */ 67/* ----- local functions ---------------------------------------------- */
64 68
65static void pcf_isa_setbyte(void *data, int ctl, int val) 69static void pcf_isa_setbyte(void *data, int ctl, int val)
66{ 70{
67 int address = ctl ? (base + 1) : base; 71 u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem;
68 72
69 /* enable irq if any specified for serial operation */ 73 /* enable irq if any specified for serial operation */
70 if (ctl && irq && (val & I2C_PCF_ESO)) { 74 if (ctl && irq && (val & I2C_PCF_ESO)) {
71 val |= I2C_PCF_ENI; 75 val |= I2C_PCF_ENI;
72 } 76 }
73 77
74 pr_debug("i2c-elektor: Write 0x%X 0x%02X\n", address, val & 255); 78 pr_debug("%s: Write %p 0x%02X\n", pcf_isa_ops.name, address, val);
75 79 iowrite8(val, address);
76 switch (mmapped) { 80#ifdef __alpha__
77 case 0: /* regular I/O */ 81 /* API UP2000 needs some hardware fudging to make the write stick */
78 outb(val, address); 82 iowrite8(val, address);
79 break; 83#endif
80 case 2: /* double mapped I/O needed for UP2000 board,
81 I don't know why this... */
82 writeb(val, (void *)address);
83 /* fall */
84 case 1: /* memory mapped I/O */
85 writeb(val, (void *)address);
86 break;
87 }
88} 84}
89 85
90static int pcf_isa_getbyte(void *data, int ctl) 86static int pcf_isa_getbyte(void *data, int ctl)
91{ 87{
92 int address = ctl ? (base + 1) : base; 88 u8 __iomem *address = ctl ? (base_iomem + 1) : base_iomem;
93 int val = mmapped ? readb((void *)address) : inb(address); 89 int val = ioread8(address);
94
95 pr_debug("i2c-elektor: Read 0x%X 0x%02X\n", address, val);
96 90
91 pr_debug("%s: Read %p 0x%02X\n", pcf_isa_ops.name, address, val);
97 return (val); 92 return (val);
98} 93}
99 94
@@ -149,16 +144,40 @@ static int pcf_isa_init(void)
149{ 144{
150 spin_lock_init(&lock); 145 spin_lock_init(&lock);
151 if (!mmapped) { 146 if (!mmapped) {
152 if (!request_region(base, 2, "i2c (isa bus adapter)")) { 147 if (!request_region(base, 2, pcf_isa_ops.name)) {
153 printk(KERN_ERR 148 printk(KERN_ERR "%s: requested I/O region (%#x:2) is "
154 "i2c-elektor: requested I/O region (0x%X:2) " 149 "in use\n", pcf_isa_ops.name, base);
155 "is in use.\n", base); 150 return -ENODEV;
151 }
152 base_iomem = ioport_map(base, 2);
153 if (!base_iomem) {
154 printk(KERN_ERR "%s: remap of I/O region %#x failed\n",
155 pcf_isa_ops.name, base);
156 release_region(base, 2);
157 return -ENODEV;
158 }
159 } else {
160 if (!request_mem_region(base, 2, pcf_isa_ops.name)) {
161 printk(KERN_ERR "%s: requested memory region (%#x:2) "
162 "is in use\n", pcf_isa_ops.name, base);
163 return -ENODEV;
164 }
165 base_iomem = ioremap(base, 2);
166 if (base_iomem == NULL) {
167 printk(KERN_ERR "%s: remap of memory region %#x "
168 "failed\n", pcf_isa_ops.name, base);
169 release_mem_region(base, 2);
156 return -ENODEV; 170 return -ENODEV;
157 } 171 }
158 } 172 }
173 pr_debug("%s: registers %#x remapped to %p\n", pcf_isa_ops.name, base,
174 base_iomem);
175
159 if (irq > 0) { 176 if (irq > 0) {
160 if (request_irq(irq, pcf_isa_handler, 0, "PCF8584", NULL) < 0) { 177 if (request_irq(irq, pcf_isa_handler, 0, pcf_isa_ops.name,
161 printk(KERN_ERR "i2c-elektor: Request irq%d failed\n", irq); 178 NULL) < 0) {
179 printk(KERN_ERR "%s: Request irq%d failed\n",
180 pcf_isa_ops.name, irq);
162 irq = 0; 181 irq = 0;
163 } else 182 } else
164 enable_irq(irq); 183 enable_irq(irq);
@@ -186,47 +205,49 @@ static struct i2c_adapter pcf_isa_ops = {
186 .class = I2C_CLASS_HWMON, 205 .class = I2C_CLASS_HWMON,
187 .id = I2C_HW_P_ELEK, 206 .id = I2C_HW_P_ELEK,
188 .algo_data = &pcf_isa_data, 207 .algo_data = &pcf_isa_data,
189 .name = "PCF8584 ISA adapter", 208 .name = "i2c-elektor",
190}; 209};
191 210
192static int __init i2c_pcfisa_init(void) 211static int __init i2c_pcfisa_init(void)
193{ 212{
194#ifdef __alpha__ 213#ifdef __alpha__
195 /* check to see we have memory mapped PCF8584 connected to the 214 /* check to see we have memory mapped PCF8584 connected to the
196 Cypress cy82c693 PCI-ISA bridge as on UP2000 board */ 215 Cypress cy82c693 PCI-ISA bridge as on UP2000 board */
197 if (base == 0) { 216 if (base == 0) {
198 struct pci_dev *cy693_dev; 217 struct pci_dev *cy693_dev;
199 218
200 cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ, 219 cy693_dev = pci_get_device(PCI_VENDOR_ID_CONTAQ,
201 PCI_DEVICE_ID_CONTAQ_82C693, NULL); 220 PCI_DEVICE_ID_CONTAQ_82C693, NULL);
202 if (cy693_dev) { 221 if (cy693_dev) {
203 char config; 222 unsigned char config;
204 /* yeap, we've found cypress, let's check config */ 223 /* yeap, we've found cypress, let's check config */
205 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) { 224 if (!pci_read_config_byte(cy693_dev, 0x47, &config)) {
206 225
207 pr_debug("i2c-elektor: found cy82c693, config register 0x47 = 0x%02x.\n", config); 226 pr_debug("%s: found cy82c693, config "
227 "register 0x47 = 0x%02x\n",
228 pcf_isa_ops.name, config);
208 229
209 /* UP2000 board has this register set to 0xe1, 230 /* UP2000 board has this register set to 0xe1,
210 but the most significant bit as seems can be 231 but the most significant bit as seems can be
211 reset during the proper initialisation 232 reset during the proper initialisation
212 sequence if guys from API decides to do that 233 sequence if guys from API decides to do that
213 (so, we can even enable Tsunami Pchip 234 (so, we can even enable Tsunami Pchip
214 window for the upper 1 Gb) */ 235 window for the upper 1 Gb) */
215 236
216 /* so just check for ROMCS at 0xe0000, 237 /* so just check for ROMCS at 0xe0000,
217 ROMCS enabled for writes 238 ROMCS enabled for writes
218 and external XD Bus buffer in use. */ 239 and external XD Bus buffer in use. */
219 if ((config & 0x7f) == 0x61) { 240 if ((config & 0x7f) == 0x61) {
220 /* seems to be UP2000 like board */ 241 /* seems to be UP2000 like board */
221 base = 0xe0000; 242 base = 0xe0000;
222 /* I don't know why we need to 243 mmapped = 1;
223 write twice */ 244 /* UP2000 drives ISA with
224 mmapped = 2;
225 /* UP2000 drives ISA with
226 8.25 MHz (PCI/4) clock 245 8.25 MHz (PCI/4) clock
227 (this can be read from cypress) */ 246 (this can be read from cypress) */
228 clock = I2C_PCF_CLK | I2C_PCF_TRNS90; 247 clock = I2C_PCF_CLK | I2C_PCF_TRNS90;
229 printk(KERN_INFO "i2c-elektor: found API UP2000 like board, will probe PCF8584 later.\n"); 248 pr_info("%s: found API UP2000 like "
249 "board, will probe PCF8584 "
250 "later\n", pcf_isa_ops.name);
230 } 251 }
231 } 252 }
232 pci_dev_put(cy693_dev); 253 pci_dev_put(cy693_dev);
@@ -236,12 +257,11 @@ static int __init i2c_pcfisa_init(void)
236 257
237 /* sanity checks for mmapped I/O */ 258 /* sanity checks for mmapped I/O */
238 if (mmapped && base < 0xc8000) { 259 if (mmapped && base < 0xc8000) {
239 printk(KERN_ERR "i2c-elektor: incorrect base address (0x%0X) specified for mmapped I/O.\n", base); 260 printk(KERN_ERR "%s: incorrect base address (%#x) specified "
261 "for mmapped I/O\n", pcf_isa_ops.name, base);
240 return -ENODEV; 262 return -ENODEV;
241 } 263 }
242 264
243 printk(KERN_INFO "i2c-elektor: i2c pcf8584-isa adapter driver\n");
244
245 if (base == 0) { 265 if (base == 0) {
246 base = DEFAULT_BASE; 266 base = DEFAULT_BASE;
247 } 267 }
@@ -251,8 +271,8 @@ static int __init i2c_pcfisa_init(void)
251 return -ENODEV; 271 return -ENODEV;
252 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) 272 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0)
253 goto fail; 273 goto fail;
254 274
255 printk(KERN_ERR "i2c-elektor: found device at %#x.\n", base); 275 dev_info(&pcf_isa_ops.dev, "found device at %#x\n", base);
256 276
257 return 0; 277 return 0;
258 278
@@ -262,8 +282,13 @@ static int __init i2c_pcfisa_init(void)
262 free_irq(irq, NULL); 282 free_irq(irq, NULL);
263 } 283 }
264 284
265 if (!mmapped) 285 if (!mmapped) {
266 release_region(base , 2); 286 ioport_unmap(base_iomem);
287 release_region(base, 2);
288 } else {
289 iounmap(base_iomem);
290 release_mem_region(base, 2);
291 }
267 return -ENODEV; 292 return -ENODEV;
268} 293}
269 294
@@ -276,8 +301,13 @@ static void i2c_pcfisa_exit(void)
276 free_irq(irq, NULL); 301 free_irq(irq, NULL);
277 } 302 }
278 303
279 if (!mmapped) 304 if (!mmapped) {
280 release_region(base , 2); 305 ioport_unmap(base_iomem);
306 release_region(base, 2);
307 } else {
308 iounmap(base_iomem);
309 release_mem_region(base, 2);
310 }
281} 311}
282 312
283MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 313MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index e0cb3b0f92fa..1b5354e24bf5 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -155,6 +155,7 @@ static void __devexit hydra_remove(struct pci_dev *dev)
155 155
156 156
157static struct pci_driver hydra_driver = { 157static struct pci_driver hydra_driver = {
158 .owner = THIS_MODULE,
158 .name = "hydra_smbus", 159 .name = "hydra_smbus",
159 .id_table = hydra_ids, 160 .id_table = hydra_ids,
160 .probe = hydra_probe, 161 .probe = hydra_probe,
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 709beab76609..4f63195069da 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -52,10 +52,6 @@
52#include <linux/i2c.h> 52#include <linux/i2c.h>
53#include <asm/io.h> 53#include <asm/io.h>
54 54
55#ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC
56#define HAVE_PEC
57#endif
58
59/* I801 SMBus address offsets */ 55/* I801 SMBus address offsets */
60#define SMBHSTSTS (0 + i801_smba) 56#define SMBHSTSTS (0 + i801_smba)
61#define SMBHSTCNT (2 + i801_smba) 57#define SMBHSTCNT (2 + i801_smba)
@@ -106,10 +102,11 @@ MODULE_PARM_DESC(force_addr,
106 "EXTREMELY DANGEROUS!"); 102 "EXTREMELY DANGEROUS!");
107 103
108static int i801_transaction(void); 104static int i801_transaction(void);
109static int i801_block_transaction(union i2c_smbus_data *data, 105static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
110 char read_write, int command); 106 int command, int hwpec);
111 107
112static unsigned short i801_smba; 108static unsigned short i801_smba;
109static struct pci_driver i801_driver;
113static struct pci_dev *I801_dev; 110static struct pci_dev *I801_dev;
114static int isich4; 111static int isich4;
115 112
@@ -143,7 +140,7 @@ static int i801_setup(struct pci_dev *dev)
143 } 140 }
144 } 141 }
145 142
146 if (!request_region(i801_smba, (isich4 ? 16 : 8), "i801-smbus")) { 143 if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) {
147 dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", 144 dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n",
148 i801_smba); 145 i801_smba);
149 error_return = -EBUSY; 146 error_return = -EBUSY;
@@ -252,7 +249,7 @@ static int i801_transaction(void)
252 249
253/* All-inclusive block transaction function */ 250/* All-inclusive block transaction function */
254static int i801_block_transaction(union i2c_smbus_data *data, char read_write, 251static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
255 int command) 252 int command, int hwpec)
256{ 253{
257 int i, len; 254 int i, len;
258 int smbcmd; 255 int smbcmd;
@@ -391,8 +388,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
391 goto END; 388 goto END;
392 } 389 }
393 390
394#ifdef HAVE_PEC 391 if (hwpec) {
395 if(isich4 && command == I2C_SMBUS_BLOCK_DATA_PEC) {
396 /* wait for INTR bit as advised by Intel */ 392 /* wait for INTR bit as advised by Intel */
397 timeout = 0; 393 timeout = 0;
398 do { 394 do {
@@ -406,7 +402,6 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
406 } 402 }
407 outb_p(temp, SMBHSTSTS); 403 outb_p(temp, SMBHSTSTS);
408 } 404 }
409#endif
410 result = 0; 405 result = 0;
411END: 406END:
412 if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 407 if (command == I2C_SMBUS_I2C_BLOCK_DATA) {
@@ -421,14 +416,13 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
421 unsigned short flags, char read_write, u8 command, 416 unsigned short flags, char read_write, u8 command,
422 int size, union i2c_smbus_data * data) 417 int size, union i2c_smbus_data * data)
423{ 418{
424 int hwpec = 0; 419 int hwpec;
425 int block = 0; 420 int block = 0;
426 int ret, xact = 0; 421 int ret, xact = 0;
427 422
428#ifdef HAVE_PEC 423 hwpec = isich4 && (flags & I2C_CLIENT_PEC)
429 if(isich4) 424 && size != I2C_SMBUS_QUICK
430 hwpec = (flags & I2C_CLIENT_PEC) != 0; 425 && size != I2C_SMBUS_I2C_BLOCK_DATA;
431#endif
432 426
433 switch (size) { 427 switch (size) {
434 case I2C_SMBUS_QUICK: 428 case I2C_SMBUS_QUICK:
@@ -463,11 +457,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
463 break; 457 break;
464 case I2C_SMBUS_BLOCK_DATA: 458 case I2C_SMBUS_BLOCK_DATA:
465 case I2C_SMBUS_I2C_BLOCK_DATA: 459 case I2C_SMBUS_I2C_BLOCK_DATA:
466#ifdef HAVE_PEC
467 case I2C_SMBUS_BLOCK_DATA_PEC:
468 if(hwpec && size == I2C_SMBUS_BLOCK_DATA)
469 size = I2C_SMBUS_BLOCK_DATA_PEC;
470#endif
471 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 460 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
472 SMBHSTADD); 461 SMBHSTADD);
473 outb_p(command, SMBHSTCMD); 462 outb_p(command, SMBHSTCMD);
@@ -479,27 +468,18 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
479 return -1; 468 return -1;
480 } 469 }
481 470
482#ifdef HAVE_PEC 471 if (hwpec)
483 if(isich4 && hwpec) { 472 outb_p(1, SMBAUXCTL); /* enable hardware PEC */
484 if(size != I2C_SMBUS_QUICK && 473
485 size != I2C_SMBUS_I2C_BLOCK_DATA)
486 outb_p(1, SMBAUXCTL); /* enable HW PEC */
487 }
488#endif
489 if(block) 474 if(block)
490 ret = i801_block_transaction(data, read_write, size); 475 ret = i801_block_transaction(data, read_write, size, hwpec);
491 else { 476 else {
492 outb_p(xact | ENABLE_INT9, SMBHSTCNT); 477 outb_p(xact | ENABLE_INT9, SMBHSTCNT);
493 ret = i801_transaction(); 478 ret = i801_transaction();
494 } 479 }
495 480
496#ifdef HAVE_PEC 481 if (hwpec)
497 if(isich4 && hwpec) { 482 outb_p(0, SMBAUXCTL); /* disable hardware PEC */
498 if(size != I2C_SMBUS_QUICK &&
499 size != I2C_SMBUS_I2C_BLOCK_DATA)
500 outb_p(0, SMBAUXCTL);
501 }
502#endif
503 483
504 if(block) 484 if(block)
505 return ret; 485 return ret;
@@ -526,12 +506,7 @@ static u32 i801_func(struct i2c_adapter *adapter)
526 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 506 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
527 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 507 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
528 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 508 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
529#ifdef HAVE_PEC 509 | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0);
530 | (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC |
531 I2C_FUNC_SMBUS_HWPEC_CALC
532 : 0)
533#endif
534 ;
535} 510}
536 511
537static struct i2c_algorithm smbus_algorithm = { 512static struct i2c_algorithm smbus_algorithm = {
@@ -543,7 +518,6 @@ static struct i2c_adapter i801_adapter = {
543 .owner = THIS_MODULE, 518 .owner = THIS_MODULE,
544 .class = I2C_CLASS_HWMON, 519 .class = I2C_CLASS_HWMON,
545 .algo = &smbus_algorithm, 520 .algo = &smbus_algorithm,
546 .name = "unset",
547}; 521};
548 522
549static struct pci_device_id i801_ids[] = { 523static struct pci_device_id i801_ids[] = {
@@ -586,6 +560,7 @@ static void __devexit i801_remove(struct pci_dev *dev)
586} 560}
587 561
588static struct pci_driver i801_driver = { 562static struct pci_driver i801_driver = {
563 .owner = THIS_MODULE,
589 .name = "i801_smbus", 564 .name = "i801_smbus",
590 .id_table = i801_ids, 565 .id_table = i801_ids,
591 .probe = i801_probe, 566 .probe = i801_probe,
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index 0ff7016e0629..52bc30593bd7 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -32,6 +32,7 @@
32 i810AB 7123 32 i810AB 7123
33 i810E 7125 33 i810E 7125
34 i815 1132 34 i815 1132
35 i845G 2562
35*/ 36*/
36 37
37#include <linux/kernel.h> 38#include <linux/kernel.h>
@@ -232,6 +233,7 @@ static void __devexit i810_remove(struct pci_dev *dev)
232} 233}
233 234
234static struct pci_driver i810_driver = { 235static struct pci_driver i810_driver = {
236 .owner = THIS_MODULE,
235 .name = "i810_smbus", 237 .name = "i810_smbus",
236 .id_table = i810_ids, 238 .id_table = i810_ids,
237 .probe = i810_probe, 239 .probe = i810_probe,
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index a3ed9590f028..1a587253d716 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -672,13 +672,12 @@ static int __devinit iic_probe(struct ocp_device *ocp){
672 printk(KERN_WARNING"ibm-iic%d: missing additional data!\n", 672 printk(KERN_WARNING"ibm-iic%d: missing additional data!\n",
673 ocp->def->index); 673 ocp->def->index);
674 674
675 if (!(dev = kmalloc(sizeof(*dev), GFP_KERNEL))){ 675 if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) {
676 printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n", 676 printk(KERN_CRIT "ibm-iic%d: failed to allocate device data\n",
677 ocp->def->index); 677 ocp->def->index);
678 return -ENOMEM; 678 return -ENOMEM;
679 } 679 }
680 680
681 memset(dev, 0, sizeof(*dev));
682 dev->idx = ocp->def->index; 681 dev->idx = ocp->def->index;
683 ocp_set_drvdata(ocp, dev); 682 ocp_set_drvdata(ocp, dev);
684 683
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 7bd9102db701..9888fae1f37a 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -43,7 +43,7 @@
43#include "i2c-iop3xx.h" 43#include "i2c-iop3xx.h"
44 44
45/* global unit counter */ 45/* global unit counter */
46static int i2c_id = 0; 46static int i2c_id;
47 47
48static inline unsigned char 48static inline unsigned char
49iic_cook_addr(struct i2c_msg *msg) 49iic_cook_addr(struct i2c_msg *msg)
@@ -440,19 +440,17 @@ iop3xx_i2c_probe(struct device *dev)
440 struct i2c_adapter *new_adapter; 440 struct i2c_adapter *new_adapter;
441 struct i2c_algo_iop3xx_data *adapter_data; 441 struct i2c_algo_iop3xx_data *adapter_data;
442 442
443 new_adapter = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); 443 new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL);
444 if (!new_adapter) { 444 if (!new_adapter) {
445 ret = -ENOMEM; 445 ret = -ENOMEM;
446 goto out; 446 goto out;
447 } 447 }
448 memset((void*)new_adapter, 0, sizeof(*new_adapter));
449 448
450 adapter_data = kmalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); 449 adapter_data = kzalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL);
451 if (!adapter_data) { 450 if (!adapter_data) {
452 ret = -ENOMEM; 451 ret = -ENOMEM;
453 goto free_adapter; 452 goto free_adapter;
454 } 453 }
455 memset((void*)adapter_data, 0, sizeof(*adapter_data));
456 454
457 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 455 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
458 if (!res) { 456 if (!res) {
@@ -525,6 +523,7 @@ out:
525 523
526 524
527static struct device_driver iop3xx_i2c_driver = { 525static struct device_driver iop3xx_i2c_driver = {
526 .owner = THIS_MODULE,
528 .name = "IOP3xx-I2C", 527 .name = "IOP3xx-I2C",
529 .bus = &platform_bus_type, 528 .bus = &platform_bus_type,
530 .probe = iop3xx_i2c_probe, 529 .probe = iop3xx_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index bdc6806dafae..4fdc02411609 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -92,6 +92,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
92 92
93 /* Add the driver to the list of i2c drivers in the driver core */ 93 /* Add the driver to the list of i2c drivers in the driver core */
94 driver->driver.name = driver->name; 94 driver->driver.name = driver->name;
95 driver->driver.owner = driver->owner;
95 driver->driver.bus = &i2c_bus_type; 96 driver->driver.bus = &i2c_bus_type;
96 driver->driver.probe = i2c_isa_device_probe; 97 driver->driver.probe = i2c_isa_device_probe;
97 driver->driver.remove = i2c_isa_device_remove; 98 driver->driver.remove = i2c_isa_device_remove;
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index 1956af382cd8..42016ee6ef13 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -36,6 +36,8 @@
36#include <asm/hardware.h> /* Pick up IXP2000-specific bits */ 36#include <asm/hardware.h> /* Pick up IXP2000-specific bits */
37#include <asm/arch/gpio.h> 37#include <asm/arch/gpio.h>
38 38
39static struct device_driver ixp2000_i2c_driver;
40
39static inline int ixp2000_scl_pin(void *data) 41static inline int ixp2000_scl_pin(void *data)
40{ 42{
41 return ((struct ixp2000_i2c_pins*)data)->scl_pin; 43 return ((struct ixp2000_i2c_pins*)data)->scl_pin;
@@ -104,11 +106,10 @@ static int ixp2000_i2c_probe(struct device *dev)
104 struct platform_device *plat_dev = to_platform_device(dev); 106 struct platform_device *plat_dev = to_platform_device(dev);
105 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; 107 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data;
106 struct ixp2000_i2c_data *drv_data = 108 struct ixp2000_i2c_data *drv_data =
107 kmalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); 109 kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL);
108 110
109 if (!drv_data) 111 if (!drv_data)
110 return -ENOMEM; 112 return -ENOMEM;
111 memzero(drv_data, sizeof(*drv_data));
112 drv_data->gpio_pins = gpio; 113 drv_data->gpio_pins = gpio;
113 114
114 drv_data->algo_data.data = gpio; 115 drv_data->algo_data.data = gpio;
@@ -121,6 +122,8 @@ static int ixp2000_i2c_probe(struct device *dev)
121 drv_data->algo_data.timeout = 100; 122 drv_data->algo_data.timeout = 100;
122 123
123 drv_data->adapter.id = I2C_HW_B_IXP2000, 124 drv_data->adapter.id = I2C_HW_B_IXP2000,
125 strlcpy(drv_data->adapter.name, ixp2000_i2c_driver.name,
126 I2C_NAME_SIZE);
124 drv_data->adapter.algo_data = &drv_data->algo_data, 127 drv_data->adapter.algo_data = &drv_data->algo_data,
125 128
126 drv_data->adapter.dev.parent = &plat_dev->dev; 129 drv_data->adapter.dev.parent = &plat_dev->dev;
@@ -142,6 +145,7 @@ static int ixp2000_i2c_probe(struct device *dev)
142} 145}
143 146
144static struct device_driver ixp2000_i2c_driver = { 147static struct device_driver ixp2000_i2c_driver = {
148 .owner = THIS_MODULE,
145 .name = "IXP2000-I2C", 149 .name = "IXP2000-I2C",
146 .bus = &platform_bus_type, 150 .bus = &platform_bus_type,
147 .probe = ixp2000_i2c_probe, 151 .probe = ixp2000_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index f6f5ca31fdba..69303ab65e04 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -35,6 +35,8 @@
35 35
36#include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ 36#include <asm/hardware.h> /* Pick up IXP4xx-specific bits */
37 37
38static struct device_driver ixp4xx_i2c_driver;
39
38static inline int ixp4xx_scl_pin(void *data) 40static inline int ixp4xx_scl_pin(void *data)
39{ 41{
40 return ((struct ixp4xx_i2c_pins*)data)->scl_pin; 42 return ((struct ixp4xx_i2c_pins*)data)->scl_pin;
@@ -105,12 +107,11 @@ static int ixp4xx_i2c_probe(struct device *dev)
105 struct platform_device *plat_dev = to_platform_device(dev); 107 struct platform_device *plat_dev = to_platform_device(dev);
106 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; 108 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data;
107 struct ixp4xx_i2c_data *drv_data = 109 struct ixp4xx_i2c_data *drv_data =
108 kmalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); 110 kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL);
109 111
110 if(!drv_data) 112 if(!drv_data)
111 return -ENOMEM; 113 return -ENOMEM;
112 114
113 memzero(drv_data, sizeof(struct ixp4xx_i2c_data));
114 drv_data->gpio_pins = gpio; 115 drv_data->gpio_pins = gpio;
115 116
116 /* 117 /*
@@ -129,6 +130,8 @@ static int ixp4xx_i2c_probe(struct device *dev)
129 drv_data->algo_data.timeout = 100; 130 drv_data->algo_data.timeout = 100;
130 131
131 drv_data->adapter.id = I2C_HW_B_IXP4XX; 132 drv_data->adapter.id = I2C_HW_B_IXP4XX;
133 strlcpy(drv_data->adapter.name, ixp4xx_i2c_driver.name,
134 I2C_NAME_SIZE);
132 drv_data->adapter.algo_data = &drv_data->algo_data; 135 drv_data->adapter.algo_data = &drv_data->algo_data;
133 136
134 drv_data->adapter.dev.parent = &plat_dev->dev; 137 drv_data->adapter.dev.parent = &plat_dev->dev;
@@ -151,6 +154,7 @@ static int ixp4xx_i2c_probe(struct device *dev)
151} 154}
152 155
153static struct device_driver ixp4xx_i2c_driver = { 156static struct device_driver ixp4xx_i2c_driver = {
157 .owner = THIS_MODULE,
154 .name = "IXP4XX-I2C", 158 .name = "IXP4XX-I2C",
155 .bus = &platform_bus_type, 159 .bus = &platform_bus_type,
156 .probe = ixp4xx_i2c_probe, 160 .probe = ixp4xx_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index eff5896ce865..d61f748278fc 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -535,13 +535,12 @@ create_iface(struct device_node *np, struct device *dev)
535 535
536 tsize = sizeof(struct keywest_iface) + 536 tsize = sizeof(struct keywest_iface) +
537 (sizeof(struct keywest_chan) + 4) * nchan; 537 (sizeof(struct keywest_chan) + 4) * nchan;
538 iface = (struct keywest_iface *) kmalloc(tsize, GFP_KERNEL); 538 iface = kzalloc(tsize, GFP_KERNEL);
539 if (iface == NULL) { 539 if (iface == NULL) {
540 printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n"); 540 printk(KERN_ERR "i2c-keywest: can't allocate inteface !\n");
541 pmac_low_i2c_unlock(np); 541 pmac_low_i2c_unlock(np);
542 return -ENOMEM; 542 return -ENOMEM;
543 } 543 }
544 memset(iface, 0, tsize);
545 spin_lock_init(&iface->lock); 544 spin_lock_init(&iface->lock);
546 init_completion(&iface->complete); 545 init_completion(&iface->complete);
547 iface->node = of_node_get(np); 546 iface->node = of_node_get(np);
@@ -716,6 +715,7 @@ static struct of_device_id i2c_keywest_match[] =
716 715
717static struct macio_driver i2c_keywest_macio_driver = 716static struct macio_driver i2c_keywest_macio_driver =
718{ 717{
718 .owner = THIS_MODULE,
719 .name = "i2c-keywest", 719 .name = "i2c-keywest",
720 .match_table = i2c_keywest_match, 720 .match_table = i2c_keywest_match,
721 .probe = create_iface_macio, 721 .probe = create_iface_macio,
@@ -724,6 +724,7 @@ static struct macio_driver i2c_keywest_macio_driver =
724 724
725static struct of_platform_driver i2c_keywest_of_platform_driver = 725static struct of_platform_driver i2c_keywest_of_platform_driver =
726{ 726{
727 .owner = THIS_MODULE,
727 .name = "i2c-keywest", 728 .name = "i2c-keywest",
728 .match_table = i2c_keywest_match, 729 .match_table = i2c_keywest_match,
729 .probe = create_iface_of_platform, 730 .probe = create_iface_of_platform,
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index f065583ddcf1..8491633005b8 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -296,10 +296,9 @@ static int fsl_i2c_probe(struct device *device)
296 296
297 pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; 297 pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
298 298
299 if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { 299 if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
300 return -ENOMEM; 300 return -ENOMEM;
301 } 301 }
302 memset(i2c, 0, sizeof(*i2c));
303 302
304 i2c->irq = platform_get_irq(pdev, 0); 303 i2c->irq = platform_get_irq(pdev, 0);
305 i2c->flags = pdata->device_flags; 304 i2c->flags = pdata->device_flags;
@@ -361,6 +360,7 @@ static int fsl_i2c_remove(struct device *device)
361 360
362/* Structure for a device driver */ 361/* Structure for a device driver */
363static struct device_driver fsl_i2c_driver = { 362static struct device_driver fsl_i2c_driver = {
363 .owner = THIS_MODULE,
364 .name = "fsl-i2c", 364 .name = "fsl-i2c",
365 .bus = &platform_bus_type, 365 .bus = &platform_bus_type,
366 .probe = fsl_i2c_probe, 366 .probe = fsl_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 99abca45fece..d0d2a6f1386e 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -500,13 +500,10 @@ mv64xxx_i2c_probe(struct device *dev)
500 if ((pd->id != 0) || !pdata) 500 if ((pd->id != 0) || !pdata)
501 return -ENODEV; 501 return -ENODEV;
502 502
503 drv_data = kmalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL); 503 drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL);
504
505 if (!drv_data) 504 if (!drv_data)
506 return -ENOMEM; 505 return -ENOMEM;
507 506
508 memset(drv_data, 0, sizeof(struct mv64xxx_i2c_data));
509
510 if (mv64xxx_i2c_map_regs(pd, drv_data)) { 507 if (mv64xxx_i2c_map_regs(pd, drv_data)) {
511 rc = -ENODEV; 508 rc = -ENODEV;
512 goto exit_kfree; 509 goto exit_kfree;
@@ -570,6 +567,7 @@ mv64xxx_i2c_remove(struct device *dev)
570} 567}
571 568
572static struct device_driver mv64xxx_i2c_driver = { 569static struct device_driver mv64xxx_i2c_driver = {
570 .owner = THIS_MODULE,
573 .name = MV64XXX_I2C_CTLR_NAME, 571 .name = MV64XXX_I2C_CTLR_NAME,
574 .bus = &platform_bus_type, 572 .bus = &platform_bus_type,
575 .probe = mv64xxx_i2c_probe, 573 .probe = mv64xxx_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index fe9c0f42a2b7..fd26036e68a3 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -97,6 +97,7 @@ struct nforce2_smbus {
97#define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a 97#define NVIDIA_SMB_PRTCL_I2C_BLOCK_DATA 0x4a
98#define NVIDIA_SMB_PRTCL_PEC 0x80 98#define NVIDIA_SMB_PRTCL_PEC 0x80
99 99
100static struct pci_driver nforce2_driver;
100 101
101static s32 nforce2_access(struct i2c_adapter *adap, u16 addr, 102static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
102 unsigned short flags, char read_write, 103 unsigned short flags, char read_write,
@@ -113,7 +114,6 @@ static struct i2c_adapter nforce2_adapter = {
113 .owner = THIS_MODULE, 114 .owner = THIS_MODULE,
114 .class = I2C_CLASS_HWMON, 115 .class = I2C_CLASS_HWMON,
115 .algo = &smbus_algorithm, 116 .algo = &smbus_algorithm,
116 .name = "unset",
117}; 117};
118 118
119/* Return -1 on error. See smbus.h for more information */ 119/* Return -1 on error. See smbus.h for more information */
@@ -188,13 +188,6 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
188 dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n"); 188 dev_err(&adap->dev, "I2C_SMBUS_BLOCK_PROC_CALL not supported!\n");
189 return -1; 189 return -1;
190 190
191 case I2C_SMBUS_WORD_DATA_PEC:
192 case I2C_SMBUS_BLOCK_DATA_PEC:
193 case I2C_SMBUS_PROC_CALL_PEC:
194 case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
195 dev_err(&adap->dev, "Unexpected software PEC transaction %d\n.", size);
196 return -1;
197
198 default: 191 default:
199 dev_err(&adap->dev, "Unsupported transaction %d\n", size); 192 dev_err(&adap->dev, "Unsupported transaction %d\n", size);
200 return -1; 193 return -1;
@@ -285,7 +278,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int reg,
285 smbus->base = iobase & 0xfffc; 278 smbus->base = iobase & 0xfffc;
286 smbus->size = 8; 279 smbus->size = 8;
287 280
288 if (!request_region(smbus->base, smbus->size, "nForce2 SMBus")) { 281 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
289 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", 282 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
290 smbus->base, smbus->base+smbus->size-1, name); 283 smbus->base, smbus->base+smbus->size-1, name);
291 return -1; 284 return -1;
@@ -313,10 +306,8 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
313 int res1, res2; 306 int res1, res2;
314 307
315 /* we support 2 SMBus adapters */ 308 /* we support 2 SMBus adapters */
316 if (!(smbuses = (void *)kmalloc(2*sizeof(struct nforce2_smbus), 309 if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
317 GFP_KERNEL)))
318 return -ENOMEM; 310 return -ENOMEM;
319 memset (smbuses, 0, 2*sizeof(struct nforce2_smbus));
320 pci_set_drvdata(dev, smbuses); 311 pci_set_drvdata(dev, smbuses);
321 312
322 /* SMBus adapter 1 */ 313 /* SMBus adapter 1 */
@@ -356,6 +347,7 @@ static void __devexit nforce2_remove(struct pci_dev *dev)
356} 347}
357 348
358static struct pci_driver nforce2_driver = { 349static struct pci_driver nforce2_driver = {
350 .owner = THIS_MODULE,
359 .name = "nForce2_smbus", 351 .name = "nForce2_smbus",
360 .id_table = nforce2_ids, 352 .id_table = nforce2_ids,
361 .probe = nforce2_probe, 353 .probe = nforce2_probe,
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 71a2502fe069..2854d858fc9b 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -155,12 +155,11 @@ static void i2c_parport_attach (struct parport *port)
155{ 155{
156 struct i2c_par *adapter; 156 struct i2c_par *adapter;
157 157
158 adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL); 158 adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
159 if (adapter == NULL) { 159 if (adapter == NULL) {
160 printk(KERN_ERR "i2c-parport: Failed to kmalloc\n"); 160 printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
161 return; 161 return;
162 } 162 }
163 memset(adapter, 0x00, sizeof(struct i2c_par));
164 163
165 pr_debug("i2c-parport: attaching to %s\n", port->name); 164 pr_debug("i2c-parport: attaching to %s\n", port->name);
166 adapter->pdev = parport_register_device(port, "i2c-parport", 165 adapter->pdev = parport_register_device(port, "i2c-parport",
@@ -232,7 +231,7 @@ static void i2c_parport_detach (struct parport *port)
232 } 231 }
233} 232}
234 233
235static struct parport_driver i2c_driver = { 234static struct parport_driver i2c_parport_driver = {
236 .name = "i2c-parport", 235 .name = "i2c-parport",
237 .attach = i2c_parport_attach, 236 .attach = i2c_parport_attach,
238 .detach = i2c_parport_detach, 237 .detach = i2c_parport_detach,
@@ -250,12 +249,12 @@ static int __init i2c_parport_init(void)
250 type = 0; 249 type = 0;
251 } 250 }
252 251
253 return parport_register_driver(&i2c_driver); 252 return parport_register_driver(&i2c_parport_driver);
254} 253}
255 254
256static void __exit i2c_parport_exit(void) 255static void __exit i2c_parport_exit(void)
257{ 256{
258 parport_unregister_driver(&i2c_driver); 257 parport_unregister_driver(&i2c_parport_driver);
259} 258}
260 259
261MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); 260MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 6d48a4da7bed..7d63eec423fe 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -90,13 +90,13 @@ struct sd {
90 90
91/* If force is set to anything different from 0, we forcibly enable the 91/* If force is set to anything different from 0, we forcibly enable the
92 PIIX4. DANGEROUS! */ 92 PIIX4. DANGEROUS! */
93static int force = 0; 93static int force;
94module_param (force, int, 0); 94module_param (force, int, 0);
95MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!"); 95MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!");
96 96
97/* If force_addr is set to anything different from 0, we forcibly enable 97/* If force_addr is set to anything different from 0, we forcibly enable
98 the PIIX4 at the given address. VERY DANGEROUS! */ 98 the PIIX4 at the given address. VERY DANGEROUS! */
99static int force_addr = 0; 99static int force_addr;
100module_param (force_addr, int, 0); 100module_param (force_addr, int, 0);
101MODULE_PARM_DESC(force_addr, 101MODULE_PARM_DESC(force_addr,
102 "Forcibly enable the PIIX4 at the given address. " 102 "Forcibly enable the PIIX4 at the given address. "
@@ -104,14 +104,15 @@ MODULE_PARM_DESC(force_addr,
104 104
105/* If fix_hstcfg is set to anything different from 0, we reset one of the 105/* If fix_hstcfg is set to anything different from 0, we reset one of the
106 registers to be a valid value. */ 106 registers to be a valid value. */
107static int fix_hstcfg = 0; 107static int fix_hstcfg;
108module_param (fix_hstcfg, int, 0); 108module_param (fix_hstcfg, int, 0);
109MODULE_PARM_DESC(fix_hstcfg, 109MODULE_PARM_DESC(fix_hstcfg,
110 "Fix config register. Needed on some boards (Force CPCI735)."); 110 "Fix config register. Needed on some boards (Force CPCI735).");
111 111
112static int piix4_transaction(void); 112static int piix4_transaction(void);
113 113
114static unsigned short piix4_smba = 0; 114static unsigned short piix4_smba;
115static struct pci_driver piix4_driver;
115static struct i2c_adapter piix4_adapter; 116static struct i2c_adapter piix4_adapter;
116 117
117static struct dmi_system_id __devinitdata piix4_dmi_table[] = { 118static struct dmi_system_id __devinitdata piix4_dmi_table[] = {
@@ -157,7 +158,7 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
157 } 158 }
158 } 159 }
159 160
160 if (!request_region(piix4_smba, SMBIOSIZE, "piix4-smbus")) { 161 if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
161 dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", 162 dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n",
162 piix4_smba); 163 piix4_smba);
163 return -ENODEV; 164 return -ENODEV;
@@ -407,7 +408,6 @@ static struct i2c_adapter piix4_adapter = {
407 .owner = THIS_MODULE, 408 .owner = THIS_MODULE,
408 .class = I2C_CLASS_HWMON, 409 .class = I2C_CLASS_HWMON,
409 .algo = &smbus_algorithm, 410 .algo = &smbus_algorithm,
410 .name = "unset",
411}; 411};
412 412
413static struct pci_device_id piix4_ids[] = { 413static struct pci_device_id piix4_ids[] = {
@@ -462,6 +462,7 @@ static void __devexit piix4_remove(struct pci_dev *dev)
462} 462}
463 463
464static struct pci_driver piix4_driver = { 464static struct pci_driver piix4_driver = {
465 .owner = THIS_MODULE,
465 .name = "piix4_smbus", 466 .name = "piix4_smbus",
466 .id_table = piix4_ids, 467 .id_table = piix4_ids,
467 .probe = piix4_probe, 468 .probe = piix4_probe,
diff --git a/drivers/i2c/busses/i2c-pmac-smu.c b/drivers/i2c/busses/i2c-pmac-smu.c
index 8a9f5648a23d..bfefe7f7a53d 100644
--- a/drivers/i2c/busses/i2c-pmac-smu.c
+++ b/drivers/i2c/busses/i2c-pmac-smu.c
@@ -211,12 +211,11 @@ static int create_iface(struct device_node *np, struct device *dev)
211 } 211 }
212 busid = *reg; 212 busid = *reg;
213 213
214 iface = kmalloc(sizeof(struct smu_iface), GFP_KERNEL); 214 iface = kzalloc(sizeof(struct smu_iface), GFP_KERNEL);
215 if (iface == NULL) { 215 if (iface == NULL) {
216 printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n"); 216 printk(KERN_ERR "i2c-pmac-smu: can't allocate inteface !\n");
217 return -ENOMEM; 217 return -ENOMEM;
218 } 218 }
219 memset(iface, 0, sizeof(struct smu_iface));
220 init_completion(&iface->complete); 219 init_completion(&iface->complete);
221 iface->busid = busid; 220 iface->busid = busid;
222 221
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
index 83fd16d61ce5..42cb1d8ca659 100644
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ b/drivers/i2c/busses/i2c-prosavage.c
@@ -83,11 +83,6 @@ struct s_i2c_chip {
83/* 83/*
84 * i2c configuration 84 * i2c configuration
85 */ 85 */
86#ifndef I2C_HW_B_S3VIA
87#define I2C_HW_B_S3VIA 0x18 /* S3VIA ProSavage adapter */
88#endif
89
90/* delays */
91#define CYCLE_DELAY 10 86#define CYCLE_DELAY 10
92#define TIMEOUT (HZ / 2) 87#define TIMEOUT (HZ / 2)
93 88
@@ -241,14 +236,12 @@ static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_devic
241 struct s_i2c_chip *chip; 236 struct s_i2c_chip *chip;
242 struct s_i2c_bus *bus; 237 struct s_i2c_bus *bus;
243 238
244 pci_set_drvdata(dev, kmalloc(sizeof(struct s_i2c_chip), GFP_KERNEL)); 239 pci_set_drvdata(dev, kzalloc(sizeof(struct s_i2c_chip), GFP_KERNEL));
245 chip = (struct s_i2c_chip *)pci_get_drvdata(dev); 240 chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
246 if (chip == NULL) { 241 if (chip == NULL) {
247 return -ENOMEM; 242 return -ENOMEM;
248 } 243 }
249 244
250 memset(chip, 0, sizeof(struct s_i2c_chip));
251
252 base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK; 245 base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK;
253 len = dev->resource[0].end - base + 1; 246 len = dev->resource[0].end - base + 1;
254 chip->mmio = ioremap_nocache(base, len); 247 chip->mmio = ioremap_nocache(base, len);
@@ -308,6 +301,7 @@ static struct pci_device_id prosavage_pci_tbl[] = {
308MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); 301MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl);
309 302
310static struct pci_driver prosavage_driver = { 303static struct pci_driver prosavage_driver = {
304 .owner = THIS_MODULE,
311 .name = "prosavage_smbus", 305 .name = "prosavage_smbus",
312 .id_table = prosavage_pci_tbl, 306 .id_table = prosavage_pci_tbl,
313 .probe = prosavage_probe, 307 .probe = prosavage_probe,
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 73a092fb0e7e..6ced28e90070 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -879,14 +879,12 @@ static int s3c24xx_i2c_remove(struct device *dev)
879} 879}
880 880
881#ifdef CONFIG_PM 881#ifdef CONFIG_PM
882static int s3c24xx_i2c_resume(struct device *dev, u32 level) 882static int s3c24xx_i2c_resume(struct device *dev)
883{ 883{
884 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 884 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
885 885
886 if (i2c != NULL && level == RESUME_ENABLE) { 886 if (i2c != NULL)
887 dev_dbg(dev, "resume: level %d\n", level);
888 s3c24xx_i2c_init(i2c); 887 s3c24xx_i2c_init(i2c);
889 }
890 888
891 return 0; 889 return 0;
892} 890}
@@ -898,6 +896,7 @@ static int s3c24xx_i2c_resume(struct device *dev, u32 level)
898/* device driver for platform bus bits */ 896/* device driver for platform bus bits */
899 897
900static struct device_driver s3c2410_i2c_driver = { 898static struct device_driver s3c2410_i2c_driver = {
899 .owner = THIS_MODULE,
901 .name = "s3c2410-i2c", 900 .name = "s3c2410-i2c",
902 .bus = &platform_bus_type, 901 .bus = &platform_bus_type,
903 .probe = s3c24xx_i2c_probe, 902 .probe = s3c24xx_i2c_probe,
@@ -906,6 +905,7 @@ static struct device_driver s3c2410_i2c_driver = {
906}; 905};
907 906
908static struct device_driver s3c2440_i2c_driver = { 907static struct device_driver s3c2440_i2c_driver = {
908 .owner = THIS_MODULE,
909 .name = "s3c2440-i2c", 909 .name = "s3c2440-i2c",
910 .bus = &platform_bus_type, 910 .bus = &platform_bus_type,
911 .probe = s3c24xx_i2c_probe, 911 .probe = s3c24xx_i2c_probe,
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index 0c8518298e4d..aebe87ba4033 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -179,6 +179,7 @@ static void __devexit savage4_remove(struct pci_dev *dev)
179} 179}
180 180
181static struct pci_driver savage4_driver = { 181static struct pci_driver savage4_driver = {
182 .owner = THIS_MODULE,
182 .name = "savage4_smbus", 183 .name = "savage4_smbus",
183 .id_table = savage4_ids, 184 .id_table = savage4_ids,
184 .probe = savage4_probe, 185 .probe = savage4_probe,
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 080318d6f54b..3ad27c3ba15b 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -123,11 +123,12 @@ static int blacklist[] = {
123 123
124/* If force_addr is set to anything different from 0, we forcibly enable 124/* If force_addr is set to anything different from 0, we forcibly enable
125 the device at the given address. */ 125 the device at the given address. */
126static u16 force_addr = 0; 126static u16 force_addr;
127module_param(force_addr, ushort, 0); 127module_param(force_addr, ushort, 0);
128MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller"); 128MODULE_PARM_DESC(force_addr, "Initialize the base address of the i2c controller");
129 129
130static unsigned short sis5595_base = 0; 130static struct pci_driver sis5595_driver;
131static unsigned short sis5595_base;
131 132
132static u8 sis5595_read(u8 reg) 133static u8 sis5595_read(u8 reg)
133{ 134{
@@ -172,7 +173,8 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
172 173
173 /* NB: We grab just the two SMBus registers here, but this may still 174 /* NB: We grab just the two SMBus registers here, but this may still
174 * interfere with ACPI :-( */ 175 * interfere with ACPI :-( */
175 if (!request_region(sis5595_base + SMB_INDEX, 2, "sis5595-smbus")) { 176 if (!request_region(sis5595_base + SMB_INDEX, 2,
177 sis5595_driver.name)) {
176 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", 178 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n",
177 sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1); 179 sis5595_base + SMB_INDEX, sis5595_base + SMB_INDEX + 1);
178 return -ENODEV; 180 return -ENODEV;
@@ -364,7 +366,6 @@ static struct i2c_algorithm smbus_algorithm = {
364static struct i2c_adapter sis5595_adapter = { 366static struct i2c_adapter sis5595_adapter = {
365 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
366 .class = I2C_CLASS_HWMON, 368 .class = I2C_CLASS_HWMON,
367 .name = "unset",
368 .algo = &smbus_algorithm, 369 .algo = &smbus_algorithm,
369}; 370};
370 371
@@ -397,6 +398,7 @@ static void __devexit sis5595_remove(struct pci_dev *dev)
397} 398}
398 399
399static struct pci_driver sis5595_driver = { 400static struct pci_driver sis5595_driver = {
401 .owner = THIS_MODULE,
400 .name = "sis5595_smbus", 402 .name = "sis5595_smbus",
401 .id_table = sis5595_ids, 403 .id_table = sis5595_ids,
402 .probe = sis5595_probe, 404 .probe = sis5595_probe,
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 86f0f448fa0b..7f49e5fd3ff0 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -92,6 +92,8 @@
92#define SIS630_PCALL 0x04 92#define SIS630_PCALL 0x04
93#define SIS630_BLOCK_DATA 0x05 93#define SIS630_BLOCK_DATA 0x05
94 94
95static struct pci_driver sis630_driver;
96
95/* insmod parameters */ 97/* insmod parameters */
96static int high_clock; 98static int high_clock;
97static int force; 99static int force;
@@ -101,7 +103,7 @@ module_param(force, bool, 0);
101MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!"); 103MODULE_PARM_DESC(force, "Forcibly enable the SIS630. DANGEROUS!");
102 104
103/* acpi base address */ 105/* acpi base address */
104static unsigned short acpi_base = 0; 106static unsigned short acpi_base;
105 107
106/* supported chips */ 108/* supported chips */
107static int supported[] = { 109static int supported[] = {
@@ -432,7 +434,8 @@ static int sis630_setup(struct pci_dev *sis630_dev)
432 dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); 434 dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
433 435
434 /* Everything is happy, let's grab the memory and set things up. */ 436 /* Everything is happy, let's grab the memory and set things up. */
435 if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, "sis630-smbus")) { 437 if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION,
438 sis630_driver.name)) {
436 dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already " 439 dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already "
437 "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA); 440 "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA);
438 goto exit; 441 goto exit;
@@ -455,7 +458,6 @@ static struct i2c_algorithm smbus_algorithm = {
455static struct i2c_adapter sis630_adapter = { 458static struct i2c_adapter sis630_adapter = {
456 .owner = THIS_MODULE, 459 .owner = THIS_MODULE,
457 .class = I2C_CLASS_HWMON, 460 .class = I2C_CLASS_HWMON,
458 .name = "unset",
459 .algo = &smbus_algorithm, 461 .algo = &smbus_algorithm,
460}; 462};
461 463
@@ -494,6 +496,7 @@ static void __devexit sis630_remove(struct pci_dev *dev)
494 496
495 497
496static struct pci_driver sis630_driver = { 498static struct pci_driver sis630_driver = {
499 .owner = THIS_MODULE,
497 .name = "sis630_smbus", 500 .name = "sis630_smbus",
498 .id_table = sis630_ids, 501 .id_table = sis630_ids,
499 .probe = sis630_probe, 502 .probe = sis630_probe,
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index ead2ff3cf60e..6a134c091324 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -82,8 +82,9 @@
82#define SIS96x_PROC_CALL 0x04 82#define SIS96x_PROC_CALL 0x04
83#define SIS96x_BLOCK_DATA 0x05 83#define SIS96x_BLOCK_DATA 0x05
84 84
85static struct pci_driver sis96x_driver;
85static struct i2c_adapter sis96x_adapter; 86static struct i2c_adapter sis96x_adapter;
86static u16 sis96x_smbus_base = 0; 87static u16 sis96x_smbus_base;
87 88
88static inline u8 sis96x_read(u8 reg) 89static inline u8 sis96x_read(u8 reg)
89{ 90{
@@ -257,7 +258,6 @@ static struct i2c_adapter sis96x_adapter = {
257 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
258 .class = I2C_CLASS_HWMON, 259 .class = I2C_CLASS_HWMON,
259 .algo = &smbus_algorithm, 260 .algo = &smbus_algorithm,
260 .name = "unset",
261}; 261};
262 262
263static struct pci_device_id sis96x_ids[] = { 263static struct pci_device_id sis96x_ids[] = {
@@ -294,7 +294,8 @@ static int __devinit sis96x_probe(struct pci_dev *dev,
294 sis96x_smbus_base); 294 sis96x_smbus_base);
295 295
296 /* Everything is happy, let's grab the memory and set things up. */ 296 /* Everything is happy, let's grab the memory and set things up. */
297 if (!request_region(sis96x_smbus_base, SMB_IOSIZE, "sis96x-smbus")) { 297 if (!request_region(sis96x_smbus_base, SMB_IOSIZE,
298 sis96x_driver.name)) {
298 dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x " 299 dev_err(&dev->dev, "SMBus registers 0x%04x-0x%04x "
299 "already in use!\n", sis96x_smbus_base, 300 "already in use!\n", sis96x_smbus_base,
300 sis96x_smbus_base + SMB_IOSIZE - 1); 301 sis96x_smbus_base + SMB_IOSIZE - 1);
@@ -328,6 +329,7 @@ static void __devexit sis96x_remove(struct pci_dev *dev)
328} 329}
329 330
330static struct pci_driver sis96x_driver = { 331static struct pci_driver sis96x_driver = {
332 .owner = THIS_MODULE,
331 .name = "sis96x_smbus", 333 .name = "sis96x_smbus",
332 .id_table = sis96x_ids, 334 .id_table = sis96x_ids,
333 .probe = sis96x_probe, 335 .probe = sis96x_probe,
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 040b8abeabba..544a38e64394 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -43,9 +43,9 @@
43 43
44/* io-region reservation */ 44/* io-region reservation */
45#define IOSPACE 0x06 45#define IOSPACE 0x06
46#define IOTEXT "via-i2c"
47 46
48static u16 pm_io_base = 0; 47static struct pci_driver vt586b_driver;
48static u16 pm_io_base;
49 49
50/* 50/*
51 It does not appear from the datasheet that the GPIO pins are 51 It does not appear from the datasheet that the GPIO pins are
@@ -130,7 +130,7 @@ static int __devinit vt586b_probe(struct pci_dev *dev, const struct pci_device_i
130 pci_read_config_word(dev, base, &pm_io_base); 130 pci_read_config_word(dev, base, &pm_io_base);
131 pm_io_base &= (0xff << 8); 131 pm_io_base &= (0xff << 8);
132 132
133 if (!request_region(I2C_DIR, IOSPACE, IOTEXT)) { 133 if (!request_region(I2C_DIR, IOSPACE, vt586b_driver.name)) {
134 dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE); 134 dev_err(&dev->dev, "IO 0x%x-0x%x already in use\n", I2C_DIR, I2C_DIR + IOSPACE);
135 return -ENODEV; 135 return -ENODEV;
136 } 136 }
@@ -159,6 +159,7 @@ static void __devexit vt586b_remove(struct pci_dev *dev)
159 159
160 160
161static struct pci_driver vt586b_driver = { 161static struct pci_driver vt586b_driver = {
162 .owner = THIS_MODULE,
162 .name = "vt586b_smbus", 163 .name = "vt586b_smbus",
163 .id_table = vt586b_ids, 164 .id_table = vt586b_ids,
164 .probe = vt586b_probe, 165 .probe = vt586b_probe,
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 99d209e0485a..c9366b504833 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -1,9 +1,10 @@
1/* 1/*
2 i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware 2 i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 monitoring
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, 5 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
6 Mark D. Studebaker <mdsxyz123@yahoo.com> 6 Mark D. Studebaker <mdsxyz123@yahoo.com>
7 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
7 8
8 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
@@ -21,15 +22,19 @@
21*/ 22*/
22 23
23/* 24/*
24 Supports Via devices: 25 Supports the following VIA south bridges:
25 82C596A/B (0x3050) 26
26 82C596B (0x3051) 27 Chip name PCI ID REV I2C block
27 82C686A/B 28 VT82C596A 0x3050 no
28 8231 29 VT82C596B 0x3051 no
29 8233 30 VT82C686A 0x3057 0x30 no
30 8233A (0x3147 and 0x3177) 31 VT82C686B 0x3057 0x40 yes
31 8235 32 VT8231 0x8235 no?
32 8237 33 VT8233 0x3074 yes
34 VT8233A 0x3147 yes?
35 VT8235 0x3177 yes
36 VT8237R 0x3227 yes
37
33 Note: we assume there can only be one device, with one SMBus interface. 38 Note: we assume there can only be one device, with one SMBus interface.
34*/ 39*/
35 40
@@ -38,7 +43,6 @@
38#include <linux/pci.h> 43#include <linux/pci.h>
39#include <linux/kernel.h> 44#include <linux/kernel.h>
40#include <linux/stddef.h> 45#include <linux/stddef.h>
41#include <linux/sched.h>
42#include <linux/ioport.h> 46#include <linux/ioport.h>
43#include <linux/i2c.h> 47#include <linux/i2c.h>
44#include <linux/init.h> 48#include <linux/init.h>
@@ -46,48 +50,37 @@
46 50
47static struct pci_dev *vt596_pdev; 51static struct pci_dev *vt596_pdev;
48 52
49#define SMBBA1 0x90 53#define SMBBA1 0x90
50#define SMBBA2 0x80 54#define SMBBA2 0x80
51#define SMBBA3 0xD0 55#define SMBBA3 0xD0
52 56
53/* SMBus address offsets */ 57/* SMBus address offsets */
54static unsigned short vt596_smba; 58static unsigned short vt596_smba;
55#define SMBHSTSTS (vt596_smba + 0) 59#define SMBHSTSTS (vt596_smba + 0)
56#define SMBHSLVSTS (vt596_smba + 1)
57#define SMBHSTCNT (vt596_smba + 2) 60#define SMBHSTCNT (vt596_smba + 2)
58#define SMBHSTCMD (vt596_smba + 3) 61#define SMBHSTCMD (vt596_smba + 3)
59#define SMBHSTADD (vt596_smba + 4) 62#define SMBHSTADD (vt596_smba + 4)
60#define SMBHSTDAT0 (vt596_smba + 5) 63#define SMBHSTDAT0 (vt596_smba + 5)
61#define SMBHSTDAT1 (vt596_smba + 6) 64#define SMBHSTDAT1 (vt596_smba + 6)
62#define SMBBLKDAT (vt596_smba + 7) 65#define SMBBLKDAT (vt596_smba + 7)
63#define SMBSLVCNT (vt596_smba + 8)
64#define SMBSHDWCMD (vt596_smba + 9)
65#define SMBSLVEVT (vt596_smba + 0xA)
66#define SMBSLVDAT (vt596_smba + 0xC)
67 66
68/* PCI Address Constants */ 67/* PCI Address Constants */
69 68
70/* SMBus data in configuration space can be found in two places, 69/* SMBus data in configuration space can be found in two places,
71 We try to select the better one*/ 70 We try to select the better one */
72
73static unsigned short smb_cf_hstcfg = 0xD2;
74 71
75#define SMBHSTCFG (smb_cf_hstcfg) 72static unsigned short SMBHSTCFG = 0xD2;
76#define SMBSLVC (smb_cf_hstcfg + 1)
77#define SMBSHDW1 (smb_cf_hstcfg + 2)
78#define SMBSHDW2 (smb_cf_hstcfg + 3)
79#define SMBREV (smb_cf_hstcfg + 4)
80 73
81/* Other settings */ 74/* Other settings */
82#define MAX_TIMEOUT 500 75#define MAX_TIMEOUT 500
83#define ENABLE_INT9 0
84 76
85/* VT82C596 constants */ 77/* VT82C596 constants */
86#define VT596_QUICK 0x00 78#define VT596_QUICK 0x00
87#define VT596_BYTE 0x04 79#define VT596_BYTE 0x04
88#define VT596_BYTE_DATA 0x08 80#define VT596_BYTE_DATA 0x08
89#define VT596_WORD_DATA 0x0C 81#define VT596_WORD_DATA 0x0C
90#define VT596_BLOCK_DATA 0x14 82#define VT596_BLOCK_DATA 0x14
83#define VT596_I2C_BLOCK_DATA 0x34
91 84
92 85
93/* If force is set to anything different from 0, we forcibly enable the 86/* If force is set to anything different from 0, we forcibly enable the
@@ -105,40 +98,65 @@ MODULE_PARM_DESC(force_addr,
105 "EXTREMELY DANGEROUS!"); 98 "EXTREMELY DANGEROUS!");
106 99
107 100
101static struct pci_driver vt596_driver;
108static struct i2c_adapter vt596_adapter; 102static struct i2c_adapter vt596_adapter;
109 103
110/* Another internally used function */ 104#define FEATURE_I2CBLOCK (1<<0)
111static int vt596_transaction(void) 105static unsigned int vt596_features;
106
107#ifdef DEBUG
108static void vt596_dump_regs(const char *msg, u8 size)
109{
110 dev_dbg(&vt596_adapter.dev, "%s: STS=%02x CNT=%02x CMD=%02x ADD=%02x "
111 "DAT=%02x,%02x\n", msg, inb_p(SMBHSTSTS), inb_p(SMBHSTCNT),
112 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
113 inb_p(SMBHSTDAT1));
114
115 if (size == VT596_BLOCK_DATA
116 || size == VT596_I2C_BLOCK_DATA) {
117 int i;
118
119 dev_dbg(&vt596_adapter.dev, "BLK=");
120 for (i = 0; i < I2C_SMBUS_BLOCK_MAX / 2; i++)
121 printk("%02x,", inb_p(SMBBLKDAT));
122 printk("\n");
123 dev_dbg(&vt596_adapter.dev, " ");
124 for (; i < I2C_SMBUS_BLOCK_MAX - 1; i++)
125 printk("%02x,", inb_p(SMBBLKDAT));
126 printk("%02x\n", inb_p(SMBBLKDAT));
127 }
128}
129#else
130static inline void vt596_dump_regs(const char *msg, u8 size) { }
131#endif
132
133/* Return -1 on error, 0 on success */
134static int vt596_transaction(u8 size)
112{ 135{
113 int temp; 136 int temp;
114 int result = 0; 137 int result = 0;
115 int timeout = 0; 138 int timeout = 0;
116 139
117 dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " 140 vt596_dump_regs("Transaction (pre)", size);
118 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
119 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
120 inb_p(SMBHSTDAT1));
121 141
122 /* Make sure the SMBus host is ready to start transmitting */ 142 /* Make sure the SMBus host is ready to start transmitting */
123 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 143 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
124 dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). " 144 dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
125 "Resetting...\n", temp); 145 "Resetting... ", temp);
126 146
127 outb_p(temp, SMBHSTSTS); 147 outb_p(temp, SMBHSTSTS);
128 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 148 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
129 dev_dbg(&vt596_adapter.dev, "Failed! (0x%02x)\n", temp); 149 printk("Failed! (0x%02x)\n", temp);
130
131 return -1; 150 return -1;
132 } else { 151 } else {
133 dev_dbg(&vt596_adapter.dev, "Successfull!\n"); 152 printk("Successful!\n");
134 } 153 }
135 } 154 }
136 155
137 /* start the transaction by setting bit 6 */ 156 /* Start the transaction by setting bit 6 */
138 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 157 outb_p(0x40 | (size & 0x3C), SMBHSTCNT);
139 158
140 /* We will always wait for a fraction of a second! 159 /* We will always wait for a fraction of a second */
141 I don't know if VIA needs this, Intel did */
142 do { 160 do {
143 msleep(1); 161 msleep(1);
144 temp = inb_p(SMBHSTSTS); 162 temp = inb_p(SMBHSTSTS);
@@ -147,77 +165,61 @@ static int vt596_transaction(void)
147 /* If the SMBus is still busy, we give up */ 165 /* If the SMBus is still busy, we give up */
148 if (timeout >= MAX_TIMEOUT) { 166 if (timeout >= MAX_TIMEOUT) {
149 result = -1; 167 result = -1;
150 dev_dbg(&vt596_adapter.dev, "SMBus Timeout!\n"); 168 dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
151 } 169 }
152 170
153 if (temp & 0x10) { 171 if (temp & 0x10) {
154 result = -1; 172 result = -1;
155 dev_dbg(&vt596_adapter.dev, "Error: Failed bus transaction\n"); 173 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
174 inb_p(SMBHSTCNT) & 0x3C);
156 } 175 }
157 176
158 if (temp & 0x08) { 177 if (temp & 0x08) {
159 result = -1; 178 result = -1;
160 dev_info(&vt596_adapter.dev, "Bus collision! SMBus may be " 179 dev_err(&vt596_adapter.dev, "SMBus collision!\n");
161 "locked until next hard\nreset. (sorry!)\n");
162 /* Clock stops and slave is stuck in mid-transmission */
163 } 180 }
164 181
165 if (temp & 0x04) { 182 if (temp & 0x04) {
166 result = -1; 183 result = -1;
167 dev_dbg(&vt596_adapter.dev, "Error: no response!\n"); 184 /* Quick commands are used to probe for chips, so
185 errors are expected, and we don't want to frighten the
186 user. */
187 if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK)
188 dev_err(&vt596_adapter.dev, "Transaction error!\n");
168 } 189 }
169 190
170 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 191 /* Resetting status register */
192 if (temp & 0x1F)
171 outb_p(temp, SMBHSTSTS); 193 outb_p(temp, SMBHSTSTS);
172 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
173 dev_warn(&vt596_adapter.dev, "Failed reset at end "
174 "of transaction (%02x)\n", temp);
175 }
176 }
177 194
178 dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " 195 vt596_dump_regs("Transaction (post)", size);
179 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 196
180 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
181 inb_p(SMBHSTDAT1));
182
183 return result; 197 return result;
184} 198}
185 199
186/* Return -1 on error. */ 200/* Return -1 on error, 0 on success */
187static s32 vt596_access(struct i2c_adapter *adap, u16 addr, 201static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
188 unsigned short flags, char read_write, u8 command, 202 unsigned short flags, char read_write, u8 command,
189 int size, union i2c_smbus_data *data) 203 int size, union i2c_smbus_data *data)
190{ 204{
191 int i, len; 205 int i;
192 206
193 switch (size) { 207 switch (size) {
194 case I2C_SMBUS_PROC_CALL:
195 dev_info(&vt596_adapter.dev,
196 "I2C_SMBUS_PROC_CALL not supported!\n");
197 return -1;
198 case I2C_SMBUS_QUICK: 208 case I2C_SMBUS_QUICK:
199 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
200 SMBHSTADD);
201 size = VT596_QUICK; 209 size = VT596_QUICK;
202 break; 210 break;
203 case I2C_SMBUS_BYTE: 211 case I2C_SMBUS_BYTE:
204 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
205 SMBHSTADD);
206 if (read_write == I2C_SMBUS_WRITE) 212 if (read_write == I2C_SMBUS_WRITE)
207 outb_p(command, SMBHSTCMD); 213 outb_p(command, SMBHSTCMD);
208 size = VT596_BYTE; 214 size = VT596_BYTE;
209 break; 215 break;
210 case I2C_SMBUS_BYTE_DATA: 216 case I2C_SMBUS_BYTE_DATA:
211 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
212 SMBHSTADD);
213 outb_p(command, SMBHSTCMD); 217 outb_p(command, SMBHSTCMD);
214 if (read_write == I2C_SMBUS_WRITE) 218 if (read_write == I2C_SMBUS_WRITE)
215 outb_p(data->byte, SMBHSTDAT0); 219 outb_p(data->byte, SMBHSTDAT0);
216 size = VT596_BYTE_DATA; 220 size = VT596_BYTE_DATA;
217 break; 221 break;
218 case I2C_SMBUS_WORD_DATA: 222 case I2C_SMBUS_WORD_DATA:
219 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
220 SMBHSTADD);
221 outb_p(command, SMBHSTCMD); 223 outb_p(command, SMBHSTCMD);
222 if (read_write == I2C_SMBUS_WRITE) { 224 if (read_write == I2C_SMBUS_WRITE) {
223 outb_p(data->word & 0xff, SMBHSTDAT0); 225 outb_p(data->word & 0xff, SMBHSTDAT0);
@@ -225,28 +227,33 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
225 } 227 }
226 size = VT596_WORD_DATA; 228 size = VT596_WORD_DATA;
227 break; 229 break;
230 case I2C_SMBUS_I2C_BLOCK_DATA:
231 if (!(vt596_features & FEATURE_I2CBLOCK))
232 goto exit_unsupported;
233 if (read_write == I2C_SMBUS_READ)
234 outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0);
235 /* Fall through */
228 case I2C_SMBUS_BLOCK_DATA: 236 case I2C_SMBUS_BLOCK_DATA:
229 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
230 SMBHSTADD);
231 outb_p(command, SMBHSTCMD); 237 outb_p(command, SMBHSTCMD);
232 if (read_write == I2C_SMBUS_WRITE) { 238 if (read_write == I2C_SMBUS_WRITE) {
233 len = data->block[0]; 239 u8 len = data->block[0];
234 if (len < 0)
235 len = 0;
236 if (len > I2C_SMBUS_BLOCK_MAX) 240 if (len > I2C_SMBUS_BLOCK_MAX)
237 len = I2C_SMBUS_BLOCK_MAX; 241 len = I2C_SMBUS_BLOCK_MAX;
238 outb_p(len, SMBHSTDAT0); 242 outb_p(len, SMBHSTDAT0);
239 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ 243 inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
240 for (i = 1; i <= len; i++) 244 for (i = 1; i <= len; i++)
241 outb_p(data->block[i], SMBBLKDAT); 245 outb_p(data->block[i], SMBBLKDAT);
242 } 246 }
243 size = VT596_BLOCK_DATA; 247 size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ?
248 VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA;
244 break; 249 break;
250 default:
251 goto exit_unsupported;
245 } 252 }
246 253
247 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 254 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
248 255
249 if (vt596_transaction()) /* Error in transaction */ 256 if (vt596_transaction(size)) /* Error in transaction */
250 return -1; 257 return -1;
251 258
252 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) 259 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
@@ -254,35 +261,39 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
254 261
255 switch (size) { 262 switch (size) {
256 case VT596_BYTE: 263 case VT596_BYTE:
257 /* Where is the result put? I assume here it is in
258 * SMBHSTDAT0 but it might just as well be in the
259 * SMBHSTCMD. No clue in the docs
260 */
261 data->byte = inb_p(SMBHSTDAT0);
262 break;
263 case VT596_BYTE_DATA: 264 case VT596_BYTE_DATA:
264 data->byte = inb_p(SMBHSTDAT0); 265 data->byte = inb_p(SMBHSTDAT0);
265 break; 266 break;
266 case VT596_WORD_DATA: 267 case VT596_WORD_DATA:
267 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8); 268 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
268 break; 269 break;
270 case VT596_I2C_BLOCK_DATA:
269 case VT596_BLOCK_DATA: 271 case VT596_BLOCK_DATA:
270 data->block[0] = inb_p(SMBHSTDAT0); 272 data->block[0] = inb_p(SMBHSTDAT0);
271 if (data->block[0] > I2C_SMBUS_BLOCK_MAX) 273 if (data->block[0] > I2C_SMBUS_BLOCK_MAX)
272 data->block[0] = I2C_SMBUS_BLOCK_MAX; 274 data->block[0] = I2C_SMBUS_BLOCK_MAX;
273 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ 275 inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
274 for (i = 1; i <= data->block[0]; i++) 276 for (i = 1; i <= data->block[0]; i++)
275 data->block[i] = inb_p(SMBBLKDAT); 277 data->block[i] = inb_p(SMBBLKDAT);
276 break; 278 break;
277 } 279 }
278 return 0; 280 return 0;
281
282exit_unsupported:
283 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n",
284 size);
285 return -1;
279} 286}
280 287
281static u32 vt596_func(struct i2c_adapter *adapter) 288static u32 vt596_func(struct i2c_adapter *adapter)
282{ 289{
283 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 290 u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
284 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 291 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
285 I2C_FUNC_SMBUS_BLOCK_DATA; 292 I2C_FUNC_SMBUS_BLOCK_DATA;
293
294 if (vt596_features & FEATURE_I2CBLOCK)
295 func |= I2C_FUNC_SMBUS_I2C_BLOCK;
296 return func;
286} 297}
287 298
288static struct i2c_algorithm smbus_algorithm = { 299static struct i2c_algorithm smbus_algorithm = {
@@ -294,7 +305,6 @@ static struct i2c_adapter vt596_adapter = {
294 .owner = THIS_MODULE, 305 .owner = THIS_MODULE,
295 .class = I2C_CLASS_HWMON, 306 .class = I2C_CLASS_HWMON,
296 .algo = &smbus_algorithm, 307 .algo = &smbus_algorithm,
297 .name = "unset",
298}; 308};
299 309
300static int __devinit vt596_probe(struct pci_dev *pdev, 310static int __devinit vt596_probe(struct pci_dev *pdev,
@@ -302,7 +312,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
302{ 312{
303 unsigned char temp; 313 unsigned char temp;
304 int error = -ENODEV; 314 int error = -ENODEV;
305 315
306 /* Determine the address of the SMBus areas */ 316 /* Determine the address of the SMBus areas */
307 if (force_addr) { 317 if (force_addr) {
308 vt596_smba = force_addr & 0xfff0; 318 vt596_smba = force_addr & 0xfff0;
@@ -311,12 +321,12 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
311 } 321 }
312 322
313 if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) || 323 if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) ||
314 !(vt596_smba & 0x1)) { 324 !(vt596_smba & 0x0001)) {
315 /* try 2nd address and config reg. for 596 */ 325 /* try 2nd address and config reg. for 596 */
316 if (id->device == PCI_DEVICE_ID_VIA_82C596_3 && 326 if (id->device == PCI_DEVICE_ID_VIA_82C596_3 &&
317 !pci_read_config_word(pdev, SMBBA2, &vt596_smba) && 327 !pci_read_config_word(pdev, SMBBA2, &vt596_smba) &&
318 (vt596_smba & 0x1)) { 328 (vt596_smba & 0x0001)) {
319 smb_cf_hstcfg = 0x84; 329 SMBHSTCFG = 0x84;
320 } else { 330 } else {
321 /* no matches at all */ 331 /* no matches at all */
322 dev_err(&pdev->dev, "Cannot configure " 332 dev_err(&pdev->dev, "Cannot configure "
@@ -333,10 +343,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
333 return -ENODEV; 343 return -ENODEV;
334 } 344 }
335 345
336 found: 346found:
337 if (!request_region(vt596_smba, 8, "viapro-smbus")) { 347 if (!request_region(vt596_smba, 8, vt596_driver.name)) {
338 dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", 348 dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
339 vt596_smba); 349 vt596_smba);
340 return -ENODEV; 350 return -ENODEV;
341 } 351 }
342 352
@@ -348,16 +358,16 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
348 pci_write_config_word(pdev, id->driver_data, vt596_smba); 358 pci_write_config_word(pdev, id->driver_data, vt596_smba);
349 pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01); 359 pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
350 dev_warn(&pdev->dev, "WARNING: SMBus interface set to new " 360 dev_warn(&pdev->dev, "WARNING: SMBus interface set to new "
351 "address 0x%04x!\n", vt596_smba); 361 "address 0x%04x!\n", vt596_smba);
352 } else if ((temp & 1) == 0) { 362 } else if (!(temp & 0x01)) {
353 if (force) { 363 if (force) {
354 /* NOTE: This assumes I/O space and other allocations 364 /* NOTE: This assumes I/O space and other allocations
355 * WERE done by the Bios! Don't complain if your 365 * WERE done by the Bios! Don't complain if your
356 * hardware does weird things after enabling this. 366 * hardware does weird things after enabling this.
357 * :') Check for Bios updates before resorting to 367 * :') Check for Bios updates before resorting to
358 * this. 368 * this.
359 */ 369 */
360 pci_write_config_byte(pdev, SMBHSTCFG, temp | 1); 370 pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
361 dev_info(&pdev->dev, "Enabling SMBus device\n"); 371 dev_info(&pdev->dev, "Enabling SMBus device\n");
362 } else { 372 } else {
363 dev_err(&pdev->dev, "SMBUS: Error: Host SMBus " 373 dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
@@ -367,22 +377,28 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
367 } 377 }
368 } 378 }
369 379
370 if ((temp & 0x0E) == 8)
371 dev_dbg(&pdev->dev, "using Interrupt 9 for SMBus.\n");
372 else if ((temp & 0x0E) == 0)
373 dev_dbg(&pdev->dev, "using Interrupt SMI# for SMBus.\n");
374 else
375 dev_dbg(&pdev->dev, "Illegal Interrupt configuration "
376 "(or code out of date)!\n");
377
378 pci_read_config_byte(pdev, SMBREV, &temp);
379 dev_dbg(&pdev->dev, "SMBREV = 0x%X\n", temp);
380 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); 380 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
381 381
382 switch (pdev->device) {
383 case PCI_DEVICE_ID_VIA_8237:
384 case PCI_DEVICE_ID_VIA_8235:
385 case PCI_DEVICE_ID_VIA_8233A:
386 case PCI_DEVICE_ID_VIA_8233_0:
387 vt596_features |= FEATURE_I2CBLOCK;
388 break;
389 case PCI_DEVICE_ID_VIA_82C686_4:
390 /* The VT82C686B (rev 0x40) does support I2C block
391 transactions, but the VT82C686A (rev 0x30) doesn't */
392 if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp)
393 && temp >= 0x40)
394 vt596_features |= FEATURE_I2CBLOCK;
395 break;
396 }
397
382 vt596_adapter.dev.parent = &pdev->dev; 398 vt596_adapter.dev.parent = &pdev->dev;
383 snprintf(vt596_adapter.name, I2C_NAME_SIZE, 399 snprintf(vt596_adapter.name, I2C_NAME_SIZE,
384 "SMBus Via Pro adapter at %04x", vt596_smba); 400 "SMBus Via Pro adapter at %04x", vt596_smba);
385 401
386 vt596_pdev = pci_dev_get(pdev); 402 vt596_pdev = pci_dev_get(pdev);
387 if (i2c_add_adapter(&vt596_adapter)) { 403 if (i2c_add_adapter(&vt596_adapter)) {
388 pci_dev_put(vt596_pdev); 404 pci_dev_put(vt596_pdev);
@@ -395,7 +411,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
395 */ 411 */
396 return -ENODEV; 412 return -ENODEV;
397 413
398 release_region: 414release_region:
399 release_region(vt596_smba, 8); 415 release_region(vt596_smba, 8);
400 return error; 416 return error;
401} 417}
@@ -420,9 +436,10 @@ static struct pci_device_id vt596_ids[] = {
420 { 0, } 436 { 0, }
421}; 437};
422 438
423MODULE_DEVICE_TABLE (pci, vt596_ids); 439MODULE_DEVICE_TABLE(pci, vt596_ids);
424 440
425static struct pci_driver vt596_driver = { 441static struct pci_driver vt596_driver = {
442 .owner = THIS_MODULE,
426 .name = "vt596_smbus", 443 .name = "vt596_smbus",
427 .id_table = vt596_ids, 444 .id_table = vt596_ids,
428 .probe = vt596_probe, 445 .probe = vt596_probe,
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index b675773b0cc1..650c3ebde84c 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -225,6 +225,7 @@ static void __devexit voodoo3_remove(struct pci_dev *dev)
225} 225}
226 226
227static struct pci_driver voodoo3_driver = { 227static struct pci_driver voodoo3_driver = {
228 .owner = THIS_MODULE,
228 .name = "voodoo3_smbus", 229 .name = "voodoo3_smbus",
229 .id_table = voodoo3_ids, 230 .id_table = voodoo3_ids,
230 .probe = voodoo3_probe, 231 .probe = voodoo3_probe,
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index a1d580e05361..d3478e084522 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -442,14 +442,13 @@ static int __init scx200_acb_create(int base, int index)
442 int rc = 0; 442 int rc = 0;
443 char description[64]; 443 char description[64];
444 444
445 iface = kmalloc(sizeof(*iface), GFP_KERNEL); 445 iface = kzalloc(sizeof(*iface), GFP_KERNEL);
446 if (!iface) { 446 if (!iface) {
447 printk(KERN_ERR NAME ": can't allocate memory\n"); 447 printk(KERN_ERR NAME ": can't allocate memory\n");
448 rc = -ENOMEM; 448 rc = -ENOMEM;
449 goto errout; 449 goto errout;
450 } 450 }
451 451
452 memset(iface, 0, sizeof(*iface));
453 adapter = &iface->adapter; 452 adapter = &iface->adapter;
454 i2c_set_adapdata(adapter, iface); 453 i2c_set_adapdata(adapter, iface);
455 snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index); 454 snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 6bd44a44cd28..f9fae28f5612 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -126,4 +126,13 @@ config SENSORS_MAX6875
126 This driver can also be built as a module. If so, the module 126 This driver can also be built as a module. If so, the module
127 will be called max6875. 127 will be called max6875.
128 128
129config RTC_X1205_I2C
130 tristate "Xicor X1205 RTC chip"
131 depends on I2C && EXPERIMENTAL
132 help
133 If you say yes here you get support for the Xicor X1205 RTC chip.
134
135 This driver can also be built as a module. If so, the module
136 will be called x1205.
137
129endmenu 138endmenu
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index a876dd42b860..46178b57b1f1 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
13obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o 13obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
14obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 14obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
15obj-$(CONFIG_TPS65010) += tps65010.o 15obj-$(CONFIG_TPS65010) += tps65010.o
16obj-$(CONFIG_RTC_X1205_I2C) += x1205.o
16 17
17ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 18ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
18EXTRA_CFLAGS += -DDEBUG 19EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 9d3175c03395..01b037007410 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -243,11 +243,10 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind)
243 I2C_FUNC_I2C)) 243 I2C_FUNC_I2C))
244 goto exit; 244 goto exit;
245 245
246 if (!(data = kmalloc(sizeof(struct ds1337_data), GFP_KERNEL))) { 246 if (!(data = kzalloc(sizeof(struct ds1337_data), GFP_KERNEL))) {
247 err = -ENOMEM; 247 err = -ENOMEM;
248 goto exit; 248 goto exit;
249 } 249 }
250 memset(data, 0, sizeof(struct ds1337_data));
251 INIT_LIST_HEAD(&data->list); 250 INIT_LIST_HEAD(&data->list);
252 251
253 /* The common I2C client data is placed right before the 252 /* The common I2C client data is placed right before the
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index 0936327a946d..da488b735abf 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -167,7 +167,8 @@ static void ds1374_set_tlet(ulong arg)
167 167
168static ulong new_time; 168static ulong new_time;
169 169
170DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); 170static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet,
171 (ulong) & new_time);
171 172
172int ds1374_set_rtc_time(ulong nowtime) 173int ds1374_set_rtc_time(ulong nowtime)
173{ 174{
@@ -193,13 +194,11 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)
193 struct i2c_client *client; 194 struct i2c_client *client;
194 int rc; 195 int rc;
195 196
196 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 197 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
197 if (!client) 198 if (!client)
198 return -ENOMEM; 199 return -ENOMEM;
199 200
200 memset(client, 0, sizeof(struct i2c_client));
201 strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); 201 strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE);
202 client->flags = I2C_DF_NOTIFY;
203 client->addr = addr; 202 client->addr = addr;
204 client->adapter = adap; 203 client->adapter = adap;
205 client->driver = &ds1374_driver; 204 client->driver = &ds1374_driver;
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index d58403a47908..4baf573fa04f 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -88,8 +88,8 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
88 dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); 88 dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
89 89
90 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 90 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
91 for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_I2C_BLOCK_MAX) 91 for (i = slice << 5; i < (slice + 1) << 5; i += I2C_SMBUS_BLOCK_MAX)
92 if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_I2C_BLOCK_MAX) 92 if (i2c_smbus_read_i2c_block_data(client, i, data->data + i) != I2C_SMBUS_BLOCK_MAX)
93 goto exit; 93 goto exit;
94 } else { 94 } else {
95 if (i2c_smbus_write_byte(client, slice << 5)) { 95 if (i2c_smbus_write_byte(client, slice << 5)) {
@@ -155,7 +155,7 @@ static int eeprom_attach_adapter(struct i2c_adapter *adapter)
155} 155}
156 156
157/* This function is called by i2c_probe */ 157/* This function is called by i2c_probe */
158int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) 158static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
159{ 159{
160 struct i2c_client *new_client; 160 struct i2c_client *new_client;
161 struct eeprom_data *data; 161 struct eeprom_data *data;
@@ -171,11 +171,10 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
171 | I2C_FUNC_SMBUS_BYTE)) 171 | I2C_FUNC_SMBUS_BYTE))
172 goto exit; 172 goto exit;
173 173
174 if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { 174 if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
175 err = -ENOMEM; 175 err = -ENOMEM;
176 goto exit; 176 goto exit;
177 } 177 }
178 memset(data, 0, sizeof(struct eeprom_data));
179 178
180 new_client = &data->client; 179 new_client = &data->client;
181 memset(data->data, 0xff, EEPROM_SIZE); 180 memset(data->data, 0xff, EEPROM_SIZE);
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 8ee56d4b3891..eaa4742e04fa 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -888,6 +888,7 @@ static int otg_remove(struct device *dev)
888} 888}
889 889
890struct device_driver omap_otg_driver = { 890struct device_driver omap_otg_driver = {
891 .owner = THIS_MODULE,
891 .name = "omap_otg", 892 .name = "omap_otg",
892 .bus = &platform_bus_type, 893 .bus = &platform_bus_type,
893 .probe = otg_probe, 894 .probe = otg_probe,
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 3f14528a52a9..3df309ae44a6 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -174,13 +174,11 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind)
174 struct i2c_client *client; 174 struct i2c_client *client;
175 int rc; 175 int rc;
176 176
177 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 177 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
178 if (!client) 178 if (!client)
179 return -ENOMEM; 179 return -ENOMEM;
180 180
181 memset(client, 0, sizeof(struct i2c_client));
182 strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE); 181 strncpy(client->name, M41T00_DRV_NAME, I2C_NAME_SIZE);
183 client->flags = I2C_DF_NOTIFY;
184 client->addr = addr; 182 client->addr = addr;
185 client->adapter = adap; 183 client->adapter = adap;
186 client->driver = &m41t00_driver; 184 client->driver = &m41t00_driver;
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 9e1aeb69abf9..b376a006883c 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -179,16 +179,14 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
179 if (address & 1) 179 if (address & 1)
180 return 0; 180 return 0;
181 181
182 if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) 182 if (!(data = kzalloc(sizeof(struct max6875_data), GFP_KERNEL)))
183 return -ENOMEM; 183 return -ENOMEM;
184 memset(data, 0, sizeof(struct max6875_data));
185 184
186 /* A fake client is created on the odd address */ 185 /* A fake client is created on the odd address */
187 if (!(fake_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 186 if (!(fake_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
188 err = -ENOMEM; 187 err = -ENOMEM;
189 goto exit_kfree1; 188 goto exit_kfree1;
190 } 189 }
191 memset(fake_client, 0, sizeof(struct i2c_client));
192 190
193 /* Init real i2c_client */ 191 /* Init real i2c_client */
194 real_client = &data->client; 192 real_client = &data->client;
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index 225577fdda4d..59a930346229 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -122,11 +122,10 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
122 122
123 /* OK. For now, we presume we have a valid client. We now create the 123 /* OK. For now, we presume we have a valid client. We now create the
124 client structure, even though we cannot fill it completely yet. */ 124 client structure, even though we cannot fill it completely yet. */
125 if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { 125 if (!(data = kzalloc(sizeof(struct pca9539_data), GFP_KERNEL))) {
126 err = -ENOMEM; 126 err = -ENOMEM;
127 goto exit; 127 goto exit;
128 } 128 }
129 memset(data, 0, sizeof(struct pca9539_data));
130 129
131 new_client = &data->client; 130 new_client = &data->client;
132 i2c_set_clientdata(new_client, data); 131 i2c_set_clientdata(new_client, data);
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index 6525743ff9fd..c323c2de236c 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -115,7 +115,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
115} 115}
116 116
117/* This function is called by i2c_probe */ 117/* This function is called by i2c_probe */
118int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) 118static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
119{ 119{
120 struct i2c_client *new_client; 120 struct i2c_client *new_client;
121 struct pcf8574_data *data; 121 struct pcf8574_data *data;
@@ -127,11 +127,10 @@ int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
127 127
128 /* OK. For now, we presume we have a valid client. We now create the 128 /* OK. For now, we presume we have a valid client. We now create the
129 client structure, even though we cannot fill it completely yet. */ 129 client structure, even though we cannot fill it completely yet. */
130 if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) { 130 if (!(data = kzalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) {
131 err = -ENOMEM; 131 err = -ENOMEM;
132 goto exit; 132 goto exit;
133 } 133 }
134 memset(data, 0, sizeof(struct pcf8574_data));
135 134
136 new_client = &data->client; 135 new_client = &data->client;
137 i2c_set_clientdata(new_client, data); 136 i2c_set_clientdata(new_client, data);
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 80f1df9a4500..ce420a67560b 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -166,7 +166,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
166} 166}
167 167
168/* This function is called by i2c_probe */ 168/* This function is called by i2c_probe */
169int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 169static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
170{ 170{
171 struct i2c_client *new_client; 171 struct i2c_client *new_client;
172 struct pcf8591_data *data; 172 struct pcf8591_data *data;
@@ -178,11 +178,10 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
178 178
179 /* OK. For now, we presume we have a valid client. We now create the 179 /* OK. For now, we presume we have a valid client. We now create the
180 client structure, even though we cannot fill it completely yet. */ 180 client structure, even though we cannot fill it completely yet. */
181 if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) { 181 if (!(data = kzalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
182 err = -ENOMEM; 182 err = -ENOMEM;
183 goto exit; 183 goto exit;
184 } 184 }
185 memset(data, 0, sizeof(struct pcf8591_data));
186 185
187 new_client = &data->client; 186 new_client = &data->client;
188 i2c_set_clientdata(new_client, data); 187 i2c_set_clientdata(new_client, data);
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 0b5385c892b1..916cdc1af23c 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -148,17 +148,16 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind)
148 {addr, I2C_M_RD, 2, data} 148 {addr, I2C_M_RD, 2, data}
149 }; 149 };
150 150
151 d = kmalloc(sizeof(struct rtc8564_data), GFP_KERNEL); 151 d = kzalloc(sizeof(struct rtc8564_data), GFP_KERNEL);
152 if (!d) { 152 if (!d) {
153 ret = -ENOMEM; 153 ret = -ENOMEM;
154 goto done; 154 goto done;
155 } 155 }
156 memset(d, 0, sizeof(struct rtc8564_data));
157 new_client = &d->client; 156 new_client = &d->client;
158 157
159 strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); 158 strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE);
160 i2c_set_clientdata(new_client, d); 159 i2c_set_clientdata(new_client, d);
161 new_client->flags = I2C_CLIENT_ALLOW_USE | I2C_DF_NOTIFY; 160 new_client->flags = I2C_CLIENT_ALLOW_USE;
162 new_client->addr = addr; 161 new_client->addr = addr;
163 new_client->adapter = adap; 162 new_client->adapter = adap;
164 new_client->driver = &rtc8564_driver; 163 new_client->driver = &rtc8564_driver;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 280e9638c0f8..280dd7a45db6 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -500,11 +500,10 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
500 return 0; 500 return 0;
501 } 501 }
502 502
503 tps = kmalloc(sizeof *tps, GFP_KERNEL); 503 tps = kzalloc(sizeof *tps, GFP_KERNEL);
504 if (!tps) 504 if (!tps)
505 return 0; 505 return 0;
506 506
507 memset(tps, 0, sizeof *tps);
508 init_MUTEX(&tps->lock); 507 init_MUTEX(&tps->lock);
509 INIT_WORK(&tps->work, tps65010_work, tps); 508 INIT_WORK(&tps->work, tps65010_work, tps);
510 tps->irq = -1; 509 tps->irq = -1;
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c
new file mode 100644
index 000000000000..7da366cdc18c
--- /dev/null
+++ b/drivers/i2c/chips/x1205.c
@@ -0,0 +1,698 @@
1/*
2 * x1205.c - An i2c driver for the Xicor X1205 RTC
3 * Copyright 2004 Karen Spearel
4 * Copyright 2005 Alessandro Zummo
5 *
6 * please send all reports to:
7 * kas11 at tampabay dot rr dot com
8 * a dot zummo at towertech dot it
9 *
10 * based on the other drivers in this same directory.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */
17
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/i2c.h>
22#include <linux/string.h>
23#include <linux/bcd.h>
24#include <linux/rtc.h>
25#include <linux/list.h>
26
27#include <linux/x1205.h>
28
29#define DRV_VERSION "0.9.9"
30
31/* Addresses to scan: none. This chip is located at
32 * 0x6f and uses a two bytes register addressing.
33 * Two bytes need to be written to read a single register,
34 * while most other chips just require one and take the second
35 * one as the data to be written. To prevent corrupting
36 * unknown chips, the user must explicitely set the probe parameter.
37 */
38
39static unsigned short normal_i2c[] = { I2C_CLIENT_END };
40
41/* Insmod parameters */
42I2C_CLIENT_INSMOD;
43I2C_CLIENT_MODULE_PARM(hctosys,
44 "Set the system time from the hardware clock upon initialization");
45
46/* offsets into CCR area */
47
48#define CCR_SEC 0
49#define CCR_MIN 1
50#define CCR_HOUR 2
51#define CCR_MDAY 3
52#define CCR_MONTH 4
53#define CCR_YEAR 5
54#define CCR_WDAY 6
55#define CCR_Y2K 7
56
57#define X1205_REG_SR 0x3F /* status register */
58#define X1205_REG_Y2K 0x37
59#define X1205_REG_DW 0x36
60#define X1205_REG_YR 0x35
61#define X1205_REG_MO 0x34
62#define X1205_REG_DT 0x33
63#define X1205_REG_HR 0x32
64#define X1205_REG_MN 0x31
65#define X1205_REG_SC 0x30
66#define X1205_REG_DTR 0x13
67#define X1205_REG_ATR 0x12
68#define X1205_REG_INT 0x11
69#define X1205_REG_0 0x10
70#define X1205_REG_Y2K1 0x0F
71#define X1205_REG_DWA1 0x0E
72#define X1205_REG_YRA1 0x0D
73#define X1205_REG_MOA1 0x0C
74#define X1205_REG_DTA1 0x0B
75#define X1205_REG_HRA1 0x0A
76#define X1205_REG_MNA1 0x09
77#define X1205_REG_SCA1 0x08
78#define X1205_REG_Y2K0 0x07
79#define X1205_REG_DWA0 0x06
80#define X1205_REG_YRA0 0x05
81#define X1205_REG_MOA0 0x04
82#define X1205_REG_DTA0 0x03
83#define X1205_REG_HRA0 0x02
84#define X1205_REG_MNA0 0x01
85#define X1205_REG_SCA0 0x00
86
87#define X1205_CCR_BASE 0x30 /* Base address of CCR */
88#define X1205_ALM0_BASE 0x00 /* Base address of ALARM0 */
89
90#define X1205_SR_RTCF 0x01 /* Clock failure */
91#define X1205_SR_WEL 0x02 /* Write Enable Latch */
92#define X1205_SR_RWEL 0x04 /* Register Write Enable */
93
94#define X1205_DTR_DTR0 0x01
95#define X1205_DTR_DTR1 0x02
96#define X1205_DTR_DTR2 0x04
97
98#define X1205_HR_MIL 0x80 /* Set in ccr.hour for 24 hr mode */
99
100/* Prototypes */
101static int x1205_attach(struct i2c_adapter *adapter);
102static int x1205_detach(struct i2c_client *client);
103static int x1205_probe(struct i2c_adapter *adapter, int address, int kind);
104static int x1205_command(struct i2c_client *client, unsigned int cmd,
105 void *arg);
106
107static struct i2c_driver x1205_driver = {
108 .owner = THIS_MODULE,
109 .name = "x1205",
110 .flags = I2C_DF_NOTIFY,
111 .attach_adapter = &x1205_attach,
112 .detach_client = &x1205_detach,
113};
114
115struct x1205_data {
116 struct i2c_client client;
117 struct list_head list;
118 unsigned int epoch;
119};
120
121static const unsigned char days_in_mo[] =
122 { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
123
124static LIST_HEAD(x1205_clients);
125
126/* Workaround until the I2C subsytem will allow to send
127 * commands to a specific client. This function will send the command
128 * to the first client.
129 */
130int x1205_do_command(unsigned int cmd, void *arg)
131{
132 struct list_head *walk;
133 struct list_head *tmp;
134 struct x1205_data *data;
135
136 list_for_each_safe(walk, tmp, &x1205_clients) {
137 data = list_entry(walk, struct x1205_data, list);
138 return x1205_command(&data->client, cmd, arg);
139 }
140
141 return -ENODEV;
142}
143
144#define is_leap(year) \
145 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
146
147/* make sure the rtc_time values are in bounds */
148static int x1205_validate_tm(struct rtc_time *tm)
149{
150 int year = tm->tm_year + 1900;
151
152 if ((tm->tm_year < 70) || (tm->tm_year > 255))
153 return -EINVAL;
154
155 if ((tm->tm_mon > 11) || (tm->tm_mday == 0))
156 return -EINVAL;
157
158 if (tm->tm_mday > days_in_mo[tm->tm_mon]
159 + ((tm->tm_mon == 1) && is_leap(year)))
160 return -EINVAL;
161
162 if ((tm->tm_hour >= 24) || (tm->tm_min >= 60) || (tm->tm_sec >= 60))
163 return -EINVAL;
164
165 return 0;
166}
167
168/*
169 * In the routines that deal directly with the x1205 hardware, we use
170 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch
171 * Epoch is initialized as 2000. Time is set to UTC.
172 */
173static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm,
174 u8 reg_base)
175{
176 unsigned char dt_addr[2] = { 0, reg_base };
177 static unsigned char sr_addr[2] = { 0, X1205_REG_SR };
178
179 unsigned char buf[8], sr;
180
181 struct i2c_msg msgs[] = {
182 { client->addr, 0, 2, sr_addr }, /* setup read ptr */
183 { client->addr, I2C_M_RD, 1, &sr }, /* read status */
184 { client->addr, 0, 2, dt_addr }, /* setup read ptr */
185 { client->addr, I2C_M_RD, 8, buf }, /* read date */
186 };
187
188 struct x1205_data *data = i2c_get_clientdata(client);
189
190 /* read status register */
191 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
192 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
193 return -EIO;
194 }
195
196 /* check for battery failure */
197 if (sr & X1205_SR_RTCF) {
198 dev_warn(&client->dev,
199 "Clock had a power failure, you must set the date.\n");
200 return -EINVAL;
201 }
202
203 /* read date registers */
204 if ((i2c_transfer(client->adapter, &msgs[2], 2)) != 2) {
205 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
206 return -EIO;
207 }
208
209 dev_dbg(&client->dev,
210 "%s: raw read data - sec=%02x, min=%02x, hr=%02x, "
211 "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n",
212 __FUNCTION__,
213 buf[0], buf[1], buf[2], buf[3],
214 buf[4], buf[5], buf[6], buf[7]);
215
216 tm->tm_sec = BCD2BIN(buf[CCR_SEC]);
217 tm->tm_min = BCD2BIN(buf[CCR_MIN]);
218 tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */
219 tm->tm_mday = BCD2BIN(buf[CCR_MDAY]);
220 tm->tm_mon = BCD2BIN(buf[CCR_MONTH]);
221 data->epoch = BCD2BIN(buf[CCR_Y2K]) * 100;
222 tm->tm_year = BCD2BIN(buf[CCR_YEAR]) + data->epoch - 1900;
223 tm->tm_wday = buf[CCR_WDAY];
224
225 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
226 "mday=%d, mon=%d, year=%d, wday=%d\n",
227 __FUNCTION__,
228 tm->tm_sec, tm->tm_min, tm->tm_hour,
229 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
230
231 return 0;
232}
233
234static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
235 int datetoo, u8 reg_base)
236{
237 int i, err, xfer;
238
239 unsigned char buf[8];
240
241 static const unsigned char wel[3] = { 0, X1205_REG_SR,
242 X1205_SR_WEL };
243
244 static const unsigned char rwel[3] = { 0, X1205_REG_SR,
245 X1205_SR_WEL | X1205_SR_RWEL };
246
247 static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 };
248
249 struct x1205_data *data = i2c_get_clientdata(client);
250
251 /* check if all values in the tm struct are correct */
252 if ((err = x1205_validate_tm(tm)) < 0)
253 return err;
254
255 dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
256 "mday=%d, mon=%d, year=%d, wday=%d\n",
257 __FUNCTION__,
258 tm->tm_sec, tm->tm_min, tm->tm_hour,
259 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
260
261 buf[CCR_SEC] = BIN2BCD(tm->tm_sec);
262 buf[CCR_MIN] = BIN2BCD(tm->tm_min);
263
264 /* set hour and 24hr bit */
265 buf[CCR_HOUR] = BIN2BCD(tm->tm_hour) | X1205_HR_MIL;
266
267 /* should we also set the date? */
268 if (datetoo) {
269 buf[CCR_MDAY] = BIN2BCD(tm->tm_mday);
270
271 /* month, 0 - 11 */
272 buf[CCR_MONTH] = BIN2BCD(tm->tm_mon);
273
274 /* year, since 1900 */
275 buf[CCR_YEAR] = BIN2BCD(tm->tm_year + 1900 - data->epoch);
276 buf[CCR_WDAY] = tm->tm_wday & 0x07;
277 buf[CCR_Y2K] = BIN2BCD(data->epoch / 100);
278 }
279
280 /* this sequence is required to unlock the chip */
281 xfer = i2c_master_send(client, wel, 3);
282 if (xfer != 3) {
283 dev_err(&client->dev, "%s: wel - %d\n", __FUNCTION__, xfer);
284 return -EIO;
285 }
286
287 xfer = i2c_master_send(client, rwel, 3);
288 if (xfer != 3) {
289 dev_err(&client->dev, "%s: rwel - %d\n", __FUNCTION__, xfer);
290 return -EIO;
291 }
292
293 /* write register's data */
294 for (i = 0; i < (datetoo ? 8 : 3); i++) {
295 unsigned char rdata[3] = { 0, reg_base + i, buf[i] };
296
297 xfer = i2c_master_send(client, rdata, 3);
298 if (xfer != 3) {
299 dev_err(&client->dev,
300 "%s: xfer=%d addr=%02x, data=%02x\n",
301 __FUNCTION__,
302 xfer, rdata[1], rdata[2]);
303 return -EIO;
304 }
305 };
306
307 /* disable further writes */
308 xfer = i2c_master_send(client, diswe, 3);
309 if (xfer != 3) {
310 dev_err(&client->dev, "%s: diswe - %d\n", __FUNCTION__, xfer);
311 return -EIO;
312 }
313
314 return 0;
315}
316
317static int x1205_get_dtrim(struct i2c_client *client, int *trim)
318{
319 unsigned char dtr;
320 static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR };
321
322 struct i2c_msg msgs[] = {
323 { client->addr, 0, 2, dtr_addr }, /* setup read ptr */
324 { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */
325 };
326
327 /* read dtr register */
328 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
329 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
330 return -EIO;
331 }
332
333 dev_dbg(&client->dev, "%s: raw dtr=%x\n", __FUNCTION__, dtr);
334
335 *trim = 0;
336
337 if (dtr & X1205_DTR_DTR0)
338 *trim += 20;
339
340 if (dtr & X1205_DTR_DTR1)
341 *trim += 10;
342
343 if (dtr & X1205_DTR_DTR2)
344 *trim = -*trim;
345
346 return 0;
347}
348
349static int x1205_get_atrim(struct i2c_client *client, int *trim)
350{
351 s8 atr;
352 static unsigned char atr_addr[2] = { 0, X1205_REG_ATR };
353
354 struct i2c_msg msgs[] = {
355 { client->addr, 0, 2, atr_addr }, /* setup read ptr */
356 { client->addr, I2C_M_RD, 1, &atr }, /* read atr */
357 };
358
359 /* read atr register */
360 if ((i2c_transfer(client->adapter, &msgs[0], 2)) != 2) {
361 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
362 return -EIO;
363 }
364
365 dev_dbg(&client->dev, "%s: raw atr=%x\n", __FUNCTION__, atr);
366
367 /* atr is a two's complement value on 6 bits,
368 * perform sign extension. The formula is
369 * Catr = (atr * 0.25pF) + 11.00pF.
370 */
371 if (atr & 0x20)
372 atr |= 0xC0;
373
374 dev_dbg(&client->dev, "%s: raw atr=%x (%d)\n", __FUNCTION__, atr, atr);
375
376 *trim = (atr * 250) + 11000;
377
378 dev_dbg(&client->dev, "%s: real=%d\n", __FUNCTION__, *trim);
379
380 return 0;
381}
382
383static int x1205_hctosys(struct i2c_client *client)
384{
385 int err;
386
387 struct rtc_time tm;
388 struct timespec tv;
389
390 err = x1205_command(client, X1205_CMD_GETDATETIME, &tm);
391
392 if (err) {
393 dev_err(&client->dev,
394 "Unable to set the system clock\n");
395 return err;
396 }
397
398 /* IMPORTANT: the RTC only stores whole seconds. It is arbitrary
399 * whether it stores the most close value or the value with partial
400 * seconds truncated. However, it is important that we use it to store
401 * the truncated value. This is because otherwise it is necessary,
402 * in an rtc sync function, to read both xtime.tv_sec and
403 * xtime.tv_nsec. On some processors (i.e. ARM), an atomic read
404 * of >32bits is not possible. So storing the most close value would
405 * slow down the sync API. So here we have the truncated value and
406 * the best guess is to add 0.5s.
407 */
408
409 tv.tv_nsec = NSEC_PER_SEC >> 1;
410
411 /* WARNING: this is not the C library 'mktime' call, it is a built in
412 * inline function from include/linux/time.h. It expects (requires)
413 * the month to be in the range 1-12
414 */
415
416 tv.tv_sec = mktime(tm.tm_year + 1900, tm.tm_mon + 1,
417 tm.tm_mday, tm.tm_hour,
418 tm.tm_min, tm.tm_sec);
419
420 do_settimeofday(&tv);
421
422 dev_info(&client->dev,
423 "setting the system clock to %d-%d-%d %d:%d:%d\n",
424 tm.tm_year + 1900, tm.tm_mon + 1,
425 tm.tm_mday, tm.tm_hour, tm.tm_min,
426 tm.tm_sec);
427
428 return 0;
429}
430
431struct x1205_limit
432{
433 unsigned char reg;
434 unsigned char mask;
435 unsigned char min;
436 unsigned char max;
437};
438
439static int x1205_validate_client(struct i2c_client *client)
440{
441 int i, xfer;
442
443 /* Probe array. We will read the register at the specified
444 * address and check if the given bits are zero.
445 */
446 static const unsigned char probe_zero_pattern[] = {
447 /* register, mask */
448 X1205_REG_SR, 0x18,
449 X1205_REG_DTR, 0xF8,
450 X1205_REG_ATR, 0xC0,
451 X1205_REG_INT, 0x18,
452 X1205_REG_0, 0xFF,
453 };
454
455 static const struct x1205_limit probe_limits_pattern[] = {
456 /* register, mask, min, max */
457 { X1205_REG_Y2K, 0xFF, 19, 20 },
458 { X1205_REG_DW, 0xFF, 0, 6 },
459 { X1205_REG_YR, 0xFF, 0, 99 },
460 { X1205_REG_MO, 0xFF, 0, 12 },
461 { X1205_REG_DT, 0xFF, 0, 31 },
462 { X1205_REG_HR, 0x7F, 0, 23 },
463 { X1205_REG_MN, 0xFF, 0, 59 },
464 { X1205_REG_SC, 0xFF, 0, 59 },
465 { X1205_REG_Y2K1, 0xFF, 19, 20 },
466 { X1205_REG_Y2K0, 0xFF, 19, 20 },
467 };
468
469 /* check that registers have bits a 0 where expected */
470 for (i = 0; i < ARRAY_SIZE(probe_zero_pattern); i += 2) {
471 unsigned char buf;
472
473 unsigned char addr[2] = { 0, probe_zero_pattern[i] };
474
475 struct i2c_msg msgs[2] = {
476 { client->addr, 0, 2, addr },
477 { client->addr, I2C_M_RD, 1, &buf },
478 };
479
480 xfer = i2c_transfer(client->adapter, msgs, 2);
481 if (xfer != 2) {
482 dev_err(&client->adapter->dev,
483 "%s: could not read register %x\n",
484 __FUNCTION__, addr[1]);
485
486 return -EIO;
487 }
488
489 if ((buf & probe_zero_pattern[i+1]) != 0) {
490 dev_err(&client->adapter->dev,
491 "%s: register=%02x, zero pattern=%d, value=%x\n",
492 __FUNCTION__, addr[1], i, buf);
493
494 return -ENODEV;
495 }
496 }
497
498 /* check limits (only registers with bcd values) */
499 for (i = 0; i < ARRAY_SIZE(probe_limits_pattern); i++) {
500 unsigned char reg, value;
501
502 unsigned char addr[2] = { 0, probe_limits_pattern[i].reg };
503
504 struct i2c_msg msgs[2] = {
505 { client->addr, 0, 2, addr },
506 { client->addr, I2C_M_RD, 1, &reg },
507 };
508
509 xfer = i2c_transfer(client->adapter, msgs, 2);
510
511 if (xfer != 2) {
512 dev_err(&client->adapter->dev,
513 "%s: could not read register %x\n",
514 __FUNCTION__, addr[1]);
515
516 return -EIO;
517 }
518
519 value = BCD2BIN(reg & probe_limits_pattern[i].mask);
520
521 if (value > probe_limits_pattern[i].max ||
522 value < probe_limits_pattern[i].min) {
523 dev_dbg(&client->adapter->dev,
524 "%s: register=%x, lim pattern=%d, value=%d\n",
525 __FUNCTION__, addr[1], i, value);
526
527 return -ENODEV;
528 }
529 }
530
531 return 0;
532}
533
534static int x1205_attach(struct i2c_adapter *adapter)
535{
536 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
537
538 return i2c_probe(adapter, &addr_data, x1205_probe);
539}
540
541int x1205_direct_attach(int adapter_id,
542 struct i2c_client_address_data *address_data)
543{
544 int err;
545 struct i2c_adapter *adapter = i2c_get_adapter(adapter_id);
546
547 if (adapter) {
548 err = i2c_probe(adapter,
549 address_data, x1205_probe);
550
551 i2c_put_adapter(adapter);
552
553 return err;
554 }
555
556 return -ENODEV;
557}
558
559static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
560{
561 struct i2c_client *client;
562 struct x1205_data *data;
563
564 int err = 0;
565
566 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
567
568 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
569 err = -ENODEV;
570 goto exit;
571 }
572
573 if (!(data = kzalloc(sizeof(struct x1205_data), GFP_KERNEL))) {
574 err = -ENOMEM;
575 goto exit;
576 }
577
578 /* Initialize our structures */
579 data->epoch = 2000;
580
581 client = &data->client;
582 client->addr = address;
583 client->driver = &x1205_driver;
584 client->adapter = adapter;
585
586 strlcpy(client->name, "x1205", I2C_NAME_SIZE);
587
588 i2c_set_clientdata(client, data);
589
590 /* Verify the chip is really an X1205 */
591 if (kind < 0) {
592 if (x1205_validate_client(client) < 0) {
593 err = -ENODEV;
594 goto exit_kfree;
595 }
596 }
597
598 /* Inform the i2c layer */
599 if ((err = i2c_attach_client(client)))
600 goto exit_kfree;
601
602 list_add(&data->list, &x1205_clients);
603
604 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
605
606 /* If requested, set the system time */
607 if (hctosys)
608 x1205_hctosys(client);
609
610 return 0;
611
612exit_kfree:
613 kfree(data);
614
615exit:
616 return err;
617}
618
619static int x1205_detach(struct i2c_client *client)
620{
621 int err;
622 struct x1205_data *data = i2c_get_clientdata(client);
623
624 dev_dbg(&client->dev, "%s\n", __FUNCTION__);
625
626 if ((err = i2c_detach_client(client)))
627 return err;
628
629 list_del(&data->list);
630
631 kfree(data);
632
633 return 0;
634}
635
636static int x1205_command(struct i2c_client *client, unsigned int cmd,
637 void *param)
638{
639 if (param == NULL)
640 return -EINVAL;
641
642 if (!capable(CAP_SYS_TIME))
643 return -EACCES;
644
645 dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd);
646
647 switch (cmd) {
648 case X1205_CMD_GETDATETIME:
649 return x1205_get_datetime(client, param, X1205_CCR_BASE);
650
651 case X1205_CMD_SETTIME:
652 return x1205_set_datetime(client, param, 0,
653 X1205_CCR_BASE);
654
655 case X1205_CMD_SETDATETIME:
656 return x1205_set_datetime(client, param, 1,
657 X1205_CCR_BASE);
658
659 case X1205_CMD_GETALARM:
660 return x1205_get_datetime(client, param, X1205_ALM0_BASE);
661
662 case X1205_CMD_SETALARM:
663 return x1205_set_datetime(client, param, 1,
664 X1205_ALM0_BASE);
665
666 case X1205_CMD_GETDTRIM:
667 return x1205_get_dtrim(client, param);
668
669 case X1205_CMD_GETATRIM:
670 return x1205_get_atrim(client, param);
671
672 default:
673 return -EINVAL;
674 }
675}
676
677static int __init x1205_init(void)
678{
679 return i2c_add_driver(&x1205_driver);
680}
681
682static void __exit x1205_exit(void)
683{
684 i2c_del_driver(&x1205_driver);
685}
686
687MODULE_AUTHOR(
688 "Karen Spearel <kas11@tampabay.rr.com>, "
689 "Alessandro Zummo <a.zummo@towertech.it>");
690MODULE_DESCRIPTION("Xicor X1205 RTC driver");
691MODULE_LICENSE("GPL");
692MODULE_VERSION(DRV_VERSION);
693
694EXPORT_SYMBOL_GPL(x1205_do_command);
695EXPORT_SYMBOL_GPL(x1205_direct_attach);
696
697module_init(x1205_init);
698module_exit(x1205_exit);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index dda472e5e8be..02e335a04f09 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -19,7 +19,8 @@
19 19
20/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. 20/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>.
21 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> 21 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl>
22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ 22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
23 Jean Delvare <khali@linux-fr.org> */
23 24
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
@@ -48,7 +49,7 @@ static int i2c_bus_suspend(struct device * dev, pm_message_t state)
48 int rc = 0; 49 int rc = 0;
49 50
50 if (dev->driver && dev->driver->suspend) 51 if (dev->driver && dev->driver->suspend)
51 rc = dev->driver->suspend(dev,state,0); 52 rc = dev->driver->suspend(dev, state);
52 return rc; 53 return rc;
53} 54}
54 55
@@ -57,7 +58,7 @@ static int i2c_bus_resume(struct device * dev)
57 int rc = 0; 58 int rc = 0;
58 59
59 if (dev->driver && dev->driver->resume) 60 if (dev->driver && dev->driver->resume)
60 rc = dev->driver->resume(dev,0); 61 rc = dev->driver->resume(dev);
61 return rc; 62 return rc;
62} 63}
63 64
@@ -85,6 +86,7 @@ void i2c_adapter_dev_release(struct device *dev)
85} 86}
86 87
87struct device_driver i2c_adapter_driver = { 88struct device_driver i2c_adapter_driver = {
89 .owner = THIS_MODULE,
88 .name = "i2c_adapter", 90 .name = "i2c_adapter",
89 .bus = &i2c_bus_type, 91 .bus = &i2c_bus_type,
90 .probe = i2c_device_probe, 92 .probe = i2c_device_probe,
@@ -98,6 +100,7 @@ static void i2c_adapter_class_dev_release(struct class_device *dev)
98} 100}
99 101
100struct class i2c_adapter_class = { 102struct class i2c_adapter_class = {
103 .owner = THIS_MODULE,
101 .name = "i2c-adapter", 104 .name = "i2c-adapter",
102 .release = &i2c_adapter_class_dev_release, 105 .release = &i2c_adapter_class_dev_release,
103}; 106};
@@ -291,6 +294,7 @@ int i2c_add_driver(struct i2c_driver *driver)
291 down(&core_lists); 294 down(&core_lists);
292 295
293 /* add the driver to the list of i2c drivers in the driver core */ 296 /* add the driver to the list of i2c drivers in the driver core */
297 driver->driver.owner = driver->owner;
294 driver->driver.name = driver->name; 298 driver->driver.name = driver->name;
295 driver->driver.bus = &i2c_bus_type; 299 driver->driver.bus = &i2c_bus_type;
296 driver->driver.probe = i2c_device_probe; 300 driver->driver.probe = i2c_device_probe;
@@ -706,10 +710,6 @@ int i2c_probe(struct i2c_adapter *adapter,
706 int i, err; 710 int i, err;
707 int adap_id = i2c_adapter_id(adapter); 711 int adap_id = i2c_adapter_id(adapter);
708 712
709 /* Forget it if we can't probe using SMBUS_QUICK */
710 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK))
711 return -1;
712
713 /* Force entries are done first, and are not affected by ignore 713 /* Force entries are done first, and are not affected by ignore
714 entries */ 714 entries */
715 if (address_data->forces) { 715 if (address_data->forces) {
@@ -736,6 +736,17 @@ int i2c_probe(struct i2c_adapter *adapter,
736 } 736 }
737 } 737 }
738 738
739 /* Stop here if we can't use SMBUS_QUICK */
740 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
741 if (address_data->probe[0] == I2C_CLIENT_END
742 && address_data->normal_i2c[0] == I2C_CLIENT_END)
743 return 0;
744
745 dev_warn(&adapter->dev, "SMBus Quick command not supported, "
746 "can't probe for chips\n");
747 return -1;
748 }
749
739 /* Probe entries are done second, and are not affected by ignore 750 /* Probe entries are done second, and are not affected by ignore
740 entries either */ 751 entries either */
741 for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) { 752 for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) {
@@ -820,101 +831,44 @@ crc8(u16 data)
820 return (u8)(data >> 8); 831 return (u8)(data >> 8);
821} 832}
822 833
823/* CRC over count bytes in the first array plus the bytes in the rest 834/* Incremental CRC8 over count bytes in the array pointed to by p */
824 array if it is non-null. rest[0] is the (length of rest) - 1 835static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
825 and is included. */
826static u8 i2c_smbus_partial_pec(u8 crc, int count, u8 *first, u8 *rest)
827{ 836{
828 int i; 837 int i;
829 838
830 for(i = 0; i < count; i++) 839 for(i = 0; i < count; i++)
831 crc = crc8((crc ^ first[i]) << 8); 840 crc = crc8((crc ^ p[i]) << 8);
832 if(rest != NULL)
833 for(i = 0; i <= rest[0]; i++)
834 crc = crc8((crc ^ rest[i]) << 8);
835 return crc; 841 return crc;
836} 842}
837 843
838static u8 i2c_smbus_pec(int count, u8 *first, u8 *rest) 844/* Assume a 7-bit address, which is reasonable for SMBus */
845static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
839{ 846{
840 return i2c_smbus_partial_pec(0, count, first, rest); 847 /* The address will be sent first */
848 u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
849 pec = i2c_smbus_pec(pec, &addr, 1);
850
851 /* The data buffer follows */
852 return i2c_smbus_pec(pec, msg->buf, msg->len);
841} 853}
842 854
843/* Returns new "size" (transaction type) 855/* Used for write only transactions */
844 Note that we convert byte to byte_data and byte_data to word_data 856static inline void i2c_smbus_add_pec(struct i2c_msg *msg)
845 rather than invent new xxx_PEC transactions. */
846static int i2c_smbus_add_pec(u16 addr, u8 command, int size,
847 union i2c_smbus_data *data)
848{ 857{
849 u8 buf[3]; 858 msg->buf[msg->len] = i2c_smbus_msg_pec(0, msg);
850 859 msg->len++;
851 buf[0] = addr << 1;
852 buf[1] = command;
853 switch(size) {
854 case I2C_SMBUS_BYTE:
855 data->byte = i2c_smbus_pec(2, buf, NULL);
856 size = I2C_SMBUS_BYTE_DATA;
857 break;
858 case I2C_SMBUS_BYTE_DATA:
859 buf[2] = data->byte;
860 data->word = buf[2] ||
861 (i2c_smbus_pec(3, buf, NULL) << 8);
862 size = I2C_SMBUS_WORD_DATA;
863 break;
864 case I2C_SMBUS_WORD_DATA:
865 /* unsupported */
866 break;
867 case I2C_SMBUS_BLOCK_DATA:
868 data->block[data->block[0] + 1] =
869 i2c_smbus_pec(2, buf, data->block);
870 size = I2C_SMBUS_BLOCK_DATA_PEC;
871 break;
872 }
873 return size;
874} 860}
875 861
876static int i2c_smbus_check_pec(u16 addr, u8 command, int size, u8 partial, 862/* Return <0 on CRC error
877 union i2c_smbus_data *data) 863 If there was a write before this read (most cases) we need to take the
864 partial CRC from the write part into account.
865 Note that this function does modify the message (we need to decrease the
866 message length to hide the CRC byte from the caller). */
867static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
878{ 868{
879 u8 buf[3], rpec, cpec; 869 u8 rpec = msg->buf[--msg->len];
870 cpec = i2c_smbus_msg_pec(cpec, msg);
880 871
881 buf[1] = command;
882 switch(size) {
883 case I2C_SMBUS_BYTE_DATA:
884 buf[0] = (addr << 1) | 1;
885 cpec = i2c_smbus_pec(2, buf, NULL);
886 rpec = data->byte;
887 break;
888 case I2C_SMBUS_WORD_DATA:
889 buf[0] = (addr << 1) | 1;
890 buf[2] = data->word & 0xff;
891 cpec = i2c_smbus_pec(3, buf, NULL);
892 rpec = data->word >> 8;
893 break;
894 case I2C_SMBUS_WORD_DATA_PEC:
895 /* unsupported */
896 cpec = rpec = 0;
897 break;
898 case I2C_SMBUS_PROC_CALL_PEC:
899 /* unsupported */
900 cpec = rpec = 0;
901 break;
902 case I2C_SMBUS_BLOCK_DATA_PEC:
903 buf[0] = (addr << 1);
904 buf[2] = (addr << 1) | 1;
905 cpec = i2c_smbus_pec(3, buf, data->block);
906 rpec = data->block[data->block[0] + 1];
907 break;
908 case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
909 buf[0] = (addr << 1) | 1;
910 rpec = i2c_smbus_partial_pec(partial, 1,
911 buf, data->block);
912 cpec = data->block[data->block[0] + 1];
913 break;
914 default:
915 cpec = rpec = 0;
916 break;
917 }
918 if (rpec != cpec) { 872 if (rpec != cpec) {
919 pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", 873 pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n",
920 rpec, cpec); 874 rpec, cpec);
@@ -941,9 +895,8 @@ s32 i2c_smbus_read_byte(struct i2c_client *client)
941 895
942s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 896s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
943{ 897{
944 union i2c_smbus_data data; /* only for PEC */
945 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 898 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
946 I2C_SMBUS_WRITE,value, I2C_SMBUS_BYTE,&data); 899 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
947} 900}
948 901
949s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) 902s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command)
@@ -1026,13 +979,14 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1026 need to use only one message; when reading, we need two. We initialize 979 need to use only one message; when reading, we need two. We initialize
1027 most things with sane defaults, to keep the code below somewhat 980 most things with sane defaults, to keep the code below somewhat
1028 simpler. */ 981 simpler. */
1029 unsigned char msgbuf0[34]; 982 unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3];
1030 unsigned char msgbuf1[34]; 983 unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2];
1031 int num = read_write == I2C_SMBUS_READ?2:1; 984 int num = read_write == I2C_SMBUS_READ?2:1;
1032 struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 }, 985 struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
1033 { addr, flags | I2C_M_RD, 0, msgbuf1 } 986 { addr, flags | I2C_M_RD, 0, msgbuf1 }
1034 }; 987 };
1035 int i; 988 int i;
989 u8 partial_pec = 0;
1036 990
1037 msgbuf0[0] = command; 991 msgbuf0[0] = command;
1038 switch(size) { 992 switch(size) {
@@ -1075,7 +1029,6 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1075 msgbuf0[2] = (data->word >> 8) & 0xff; 1029 msgbuf0[2] = (data->word >> 8) & 0xff;
1076 break; 1030 break;
1077 case I2C_SMBUS_BLOCK_DATA: 1031 case I2C_SMBUS_BLOCK_DATA:
1078 case I2C_SMBUS_BLOCK_DATA_PEC:
1079 if (read_write == I2C_SMBUS_READ) { 1032 if (read_write == I2C_SMBUS_READ) {
1080 dev_err(&adapter->dev, "Block read not supported " 1033 dev_err(&adapter->dev, "Block read not supported "
1081 "under I2C emulation!\n"); 1034 "under I2C emulation!\n");
@@ -1088,23 +1041,20 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1088 data->block[0]); 1041 data->block[0]);
1089 return -1; 1042 return -1;
1090 } 1043 }
1091 if(size == I2C_SMBUS_BLOCK_DATA_PEC) 1044 for (i = 1; i < msg[0].len; i++)
1092 (msg[0].len)++;
1093 for (i = 1; i <= msg[0].len; i++)
1094 msgbuf0[i] = data->block[i-1]; 1045 msgbuf0[i] = data->block[i-1];
1095 } 1046 }
1096 break; 1047 break;
1097 case I2C_SMBUS_BLOCK_PROC_CALL: 1048 case I2C_SMBUS_BLOCK_PROC_CALL:
1098 case I2C_SMBUS_BLOCK_PROC_CALL_PEC:
1099 dev_dbg(&adapter->dev, "Block process call not supported " 1049 dev_dbg(&adapter->dev, "Block process call not supported "
1100 "under I2C emulation!\n"); 1050 "under I2C emulation!\n");
1101 return -1; 1051 return -1;
1102 case I2C_SMBUS_I2C_BLOCK_DATA: 1052 case I2C_SMBUS_I2C_BLOCK_DATA:
1103 if (read_write == I2C_SMBUS_READ) { 1053 if (read_write == I2C_SMBUS_READ) {
1104 msg[1].len = I2C_SMBUS_I2C_BLOCK_MAX; 1054 msg[1].len = I2C_SMBUS_BLOCK_MAX;
1105 } else { 1055 } else {
1106 msg[0].len = data->block[0] + 1; 1056 msg[0].len = data->block[0] + 1;
1107 if (msg[0].len > I2C_SMBUS_I2C_BLOCK_MAX + 1) { 1057 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) {
1108 dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " 1058 dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with "
1109 "invalid block write size (%d)\n", 1059 "invalid block write size (%d)\n",
1110 data->block[0]); 1060 data->block[0]);
@@ -1120,9 +1070,30 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1120 return -1; 1070 return -1;
1121 } 1071 }
1122 1072
1073 i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK
1074 && size != I2C_SMBUS_I2C_BLOCK_DATA);
1075 if (i) {
1076 /* Compute PEC if first message is a write */
1077 if (!(msg[0].flags & I2C_M_RD)) {
1078 if (num == 1) /* Write only */
1079 i2c_smbus_add_pec(&msg[0]);
1080 else /* Write followed by read */
1081 partial_pec = i2c_smbus_msg_pec(0, &msg[0]);
1082 }
1083 /* Ask for PEC if last message is a read */
1084 if (msg[num-1].flags & I2C_M_RD)
1085 msg[num-1].len++;
1086 }
1087
1123 if (i2c_transfer(adapter, msg, num) < 0) 1088 if (i2c_transfer(adapter, msg, num) < 0)
1124 return -1; 1089 return -1;
1125 1090
1091 /* Check PEC if last message is a read */
1092 if (i && (msg[num-1].flags & I2C_M_RD)) {
1093 if (i2c_smbus_check_pec(partial_pec, &msg[num-1]) < 0)
1094 return -1;
1095 }
1096
1126 if (read_write == I2C_SMBUS_READ) 1097 if (read_write == I2C_SMBUS_READ)
1127 switch(size) { 1098 switch(size) {
1128 case I2C_SMBUS_BYTE: 1099 case I2C_SMBUS_BYTE:
@@ -1137,8 +1108,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1137 break; 1108 break;
1138 case I2C_SMBUS_I2C_BLOCK_DATA: 1109 case I2C_SMBUS_I2C_BLOCK_DATA:
1139 /* fixed at 32 for now */ 1110 /* fixed at 32 for now */
1140 data->block[0] = I2C_SMBUS_I2C_BLOCK_MAX; 1111 data->block[0] = I2C_SMBUS_BLOCK_MAX;
1141 for (i = 0; i < I2C_SMBUS_I2C_BLOCK_MAX; i++) 1112 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
1142 data->block[i+1] = msgbuf1[i]; 1113 data->block[i+1] = msgbuf1[i];
1143 break; 1114 break;
1144 } 1115 }
@@ -1151,28 +1122,8 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1151 union i2c_smbus_data * data) 1122 union i2c_smbus_data * data)
1152{ 1123{
1153 s32 res; 1124 s32 res;
1154 int swpec = 0;
1155 u8 partial = 0;
1156 1125
1157 flags &= I2C_M_TEN | I2C_CLIENT_PEC; 1126 flags &= I2C_M_TEN | I2C_CLIENT_PEC;
1158 if((flags & I2C_CLIENT_PEC) &&
1159 !(i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HWPEC_CALC))) {
1160 swpec = 1;
1161 if(read_write == I2C_SMBUS_READ &&
1162 size == I2C_SMBUS_BLOCK_DATA)
1163 size = I2C_SMBUS_BLOCK_DATA_PEC;
1164 else if(size == I2C_SMBUS_PROC_CALL)
1165 size = I2C_SMBUS_PROC_CALL_PEC;
1166 else if(size == I2C_SMBUS_BLOCK_PROC_CALL) {
1167 i2c_smbus_add_pec(addr, command,
1168 I2C_SMBUS_BLOCK_DATA, data);
1169 partial = data->block[data->block[0] + 1];
1170 size = I2C_SMBUS_BLOCK_PROC_CALL_PEC;
1171 } else if(read_write == I2C_SMBUS_WRITE &&
1172 size != I2C_SMBUS_QUICK &&
1173 size != I2C_SMBUS_I2C_BLOCK_DATA)
1174 size = i2c_smbus_add_pec(addr, command, size, data);
1175 }
1176 1127
1177 if (adapter->algo->smbus_xfer) { 1128 if (adapter->algo->smbus_xfer) {
1178 down(&adapter->bus_lock); 1129 down(&adapter->bus_lock);
@@ -1183,13 +1134,6 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1183 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, 1134 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
1184 command,size,data); 1135 command,size,data);
1185 1136
1186 if(res >= 0 && swpec &&
1187 size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA &&
1188 (read_write == I2C_SMBUS_READ || size == I2C_SMBUS_PROC_CALL_PEC ||
1189 size == I2C_SMBUS_BLOCK_PROC_CALL_PEC)) {
1190 if(i2c_smbus_check_pec(addr, command, size, partial, data))
1191 return -1;
1192 }
1193 return res; 1137 return res;
1194} 1138}
1195 1139
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index aa7a4fadef64..ea14c8f1c82b 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -26,15 +26,11 @@
26 26
27/* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */ 27/* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */
28 28
29/* The devfs code is contributed by Philipp Matthias Hahn
30 <pmhahn@titan.lahn.de> */
31
32#include <linux/kernel.h> 29#include <linux/kernel.h>
33#include <linux/module.h> 30#include <linux/module.h>
34#include <linux/fs.h> 31#include <linux/fs.h>
35#include <linux/slab.h> 32#include <linux/slab.h>
36#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
37#include <linux/devfs_fs_kernel.h>
38#include <linux/init.h> 34#include <linux/init.h>
39#include <linux/i2c.h> 35#include <linux/i2c.h>
40#include <linux/i2c-dev.h> 36#include <linux/i2c-dev.h>
@@ -80,10 +76,9 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
80{ 76{
81 struct i2c_dev *i2c_dev; 77 struct i2c_dev *i2c_dev;
82 78
83 i2c_dev = kmalloc(sizeof(*i2c_dev), GFP_KERNEL); 79 i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL);
84 if (!i2c_dev) 80 if (!i2c_dev)
85 return ERR_PTR(-ENOMEM); 81 return ERR_PTR(-ENOMEM);
86 memset(i2c_dev, 0x00, sizeof(*i2c_dev));
87 82
88 spin_lock(&i2c_dev_array_lock); 83 spin_lock(&i2c_dev_array_lock);
89 if (i2c_dev_array[adap->nr]) { 84 if (i2c_dev_array[adap->nr]) {
@@ -177,8 +172,8 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
177 int i,datasize,res; 172 int i,datasize,res;
178 unsigned long funcs; 173 unsigned long funcs;
179 174
180 dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", 175 dev_dbg(&client->adapter->dev, "ioctl, cmd=0x%02x, arg=0x%02lx\n",
181 iminor(inode),cmd, arg); 176 cmd, arg);
182 177
183 switch ( cmd ) { 178 switch ( cmd ) {
184 case I2C_SLAVE: 179 case I2C_SLAVE:
@@ -432,8 +427,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
432 if (IS_ERR(i2c_dev)) 427 if (IS_ERR(i2c_dev))
433 return PTR_ERR(i2c_dev); 428 return PTR_ERR(i2c_dev);
434 429
435 devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor),
436 S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor);
437 pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", 430 pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
438 adap->name, i2c_dev->minor); 431 adap->name, i2c_dev->minor);
439 432
@@ -466,7 +459,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
466 return -ENODEV; 459 return -ENODEV;
467 460
468 init_completion(&i2c_dev->released); 461 init_completion(&i2c_dev->released);
469 devfs_remove("i2c/%d", i2c_dev->minor);
470 return_i2c_dev(i2c_dev); 462 return_i2c_dev(i2c_dev);
471 class_device_unregister(&i2c_dev->class_dev); 463 class_device_unregister(&i2c_dev->class_dev);
472 wait_for_completion(&i2c_dev->released); 464 wait_for_completion(&i2c_dev->released);
@@ -522,8 +514,6 @@ static int __init i2c_dev_init(void)
522 if (res) 514 if (res)
523 goto out_unreg_class; 515 goto out_unreg_class;
524 516
525 devfs_mk_dir("i2c");
526
527 return 0; 517 return 0;
528 518
529out_unreg_class: 519out_unreg_class:
@@ -539,7 +529,6 @@ static void __exit i2c_dev_exit(void)
539{ 529{
540 i2c_del_driver(&i2cdev_driver); 530 i2c_del_driver(&i2cdev_driver);
541 class_unregister(&i2c_dev_class); 531 class_unregister(&i2c_dev_class);
542 devfs_remove("i2c");
543 unregister_chrdev(I2C_MAJOR,"i2c"); 532 unregister_chrdev(I2C_MAJOR,"i2c");
544} 533}
545 534
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ee38e6b143a4..47f2b832555f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1013,6 +1013,8 @@ typedef struct ide_tape_obj {
1013 1013
1014static DECLARE_MUTEX(idetape_ref_sem); 1014static DECLARE_MUTEX(idetape_ref_sem);
1015 1015
1016static struct class *idetape_sysfs_class;
1017
1016#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) 1018#define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref)
1017 1019
1018#define ide_tape_g(disk) \ 1020#define ide_tape_g(disk) \
@@ -4704,6 +4706,10 @@ static void ide_tape_release(struct kref *kref)
4704 4706
4705 drive->dsc_overlap = 0; 4707 drive->dsc_overlap = 0;
4706 drive->driver_data = NULL; 4708 drive->driver_data = NULL;
4709 class_device_destroy(idetape_sysfs_class,
4710 MKDEV(IDETAPE_MAJOR, tape->minor));
4711 class_device_destroy(idetape_sysfs_class,
4712 MKDEV(IDETAPE_MAJOR, tape->minor + 128));
4707 devfs_remove("%s/mt", drive->devfs_name); 4713 devfs_remove("%s/mt", drive->devfs_name);
4708 devfs_remove("%s/mtn", drive->devfs_name); 4714 devfs_remove("%s/mtn", drive->devfs_name);
4709 devfs_unregister_tape(g->number); 4715 devfs_unregister_tape(g->number);
@@ -4878,6 +4884,11 @@ static int ide_tape_probe(struct device *dev)
4878 4884
4879 idetape_setup(drive, tape, minor); 4885 idetape_setup(drive, tape, minor);
4880 4886
4887 class_device_create(idetape_sysfs_class, NULL,
4888 MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name);
4889 class_device_create(idetape_sysfs_class, NULL,
4890 MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name);
4891
4881 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), 4892 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
4882 S_IFCHR | S_IRUGO | S_IWUGO, 4893 S_IFCHR | S_IRUGO | S_IWUGO,
4883 "%s/mt", drive->devfs_name); 4894 "%s/mt", drive->devfs_name);
@@ -4903,6 +4914,7 @@ MODULE_LICENSE("GPL");
4903static void __exit idetape_exit (void) 4914static void __exit idetape_exit (void)
4904{ 4915{
4905 driver_unregister(&idetape_driver.gen_driver); 4916 driver_unregister(&idetape_driver.gen_driver);
4917 class_destroy(idetape_sysfs_class);
4906 unregister_chrdev(IDETAPE_MAJOR, "ht"); 4918 unregister_chrdev(IDETAPE_MAJOR, "ht");
4907} 4919}
4908 4920
@@ -4911,11 +4923,33 @@ static void __exit idetape_exit (void)
4911 */ 4923 */
4912static int idetape_init (void) 4924static int idetape_init (void)
4913{ 4925{
4926 int error = 1;
4927 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape");
4928 if (IS_ERR(idetape_sysfs_class)) {
4929 idetape_sysfs_class = NULL;
4930 printk(KERN_ERR "Unable to create sysfs class for ide tapes\n");
4931 error = -EBUSY;
4932 goto out;
4933 }
4934
4914 if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { 4935 if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) {
4915 printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); 4936 printk(KERN_ERR "ide-tape: Failed to register character device interface\n");
4916 return -EBUSY; 4937 error = -EBUSY;
4938 goto out_free_class;
4917 } 4939 }
4918 return driver_register(&idetape_driver.gen_driver); 4940
4941 error = driver_register(&idetape_driver.gen_driver);
4942 if (error)
4943 goto out_free_driver;
4944
4945 return 0;
4946
4947out_free_driver:
4948 driver_unregister(&idetape_driver.gen_driver);
4949out_free_class:
4950 class_destroy(idetape_sysfs_class);
4951out:
4952 return error;
4919} 4953}
4920 4954
4921module_init(idetape_init); 4955module_init(idetape_init);
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index e34730c7a874..cbbbe14b8849 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -2361,7 +2361,7 @@ static void dv1394_add_host (struct hpsb_host *host)
2361 2361
2362 ohci = (struct ti_ohci *)host->hostdata; 2362 ohci = (struct ti_ohci *)host->hostdata;
2363 2363
2364 class_device_create(hpsb_protocol_class, MKDEV( 2364 class_device_create(hpsb_protocol_class, NULL, MKDEV(
2365 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2365 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
2366 NULL, "dv1394-%d", id); 2366 NULL, "dv1394-%d", id);
2367 devfs_mk_dir("ieee1394/dv/host%d", id); 2367 devfs_mk_dir("ieee1394/dv/host%d", id);
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 4802bbbb6dc9..c9e92d85c893 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -1630,7 +1630,7 @@ static void ether1394_complete_cb(void *__ptask)
1630/* Transmit a packet (called by kernel) */ 1630/* Transmit a packet (called by kernel) */
1631static int ether1394_tx (struct sk_buff *skb, struct net_device *dev) 1631static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1632{ 1632{
1633 int kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 1633 gfp_t kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
1634 struct eth1394hdr *eth; 1634 struct eth1394hdr *eth;
1635 struct eth1394_priv *priv = netdev_priv(dev); 1635 struct eth1394_priv *priv = netdev_priv(dev);
1636 int proto; 1636 int proto;
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 347ece6b583c..7fff5a1d2ea4 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -1292,7 +1292,7 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1292 1292
1293 if (ud->device.driver && 1293 if (ud->device.driver &&
1294 (!ud->device.driver->suspend || 1294 (!ud->device.driver->suspend ||
1295 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND, 0))) 1295 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND)))
1296 device_release_driver(&ud->device); 1296 device_release_driver(&ud->device);
1297 } 1297 }
1298 up_write(&ne->device.bus->subsys.rwsem); 1298 up_write(&ne->device.bus->subsys.rwsem);
@@ -1315,7 +1315,7 @@ static void nodemgr_resume_ne(struct node_entry *ne)
1315 continue; 1315 continue;
1316 1316
1317 if (ud->device.driver && ud->device.driver->resume) 1317 if (ud->device.driver && ud->device.driver->resume)
1318 ud->device.driver->resume(&ud->device, 0); 1318 ud->device.driver->resume(&ud->device);
1319 } 1319 }
1320 up_read(&ne->device.bus->subsys.rwsem); 1320 up_read(&ne->device.bus->subsys.rwsem);
1321 1321
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 0470f77a9cd1..24411e666b21 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2912,7 +2912,7 @@ static int __init init_raw1394(void)
2912 2912
2913 hpsb_register_highlevel(&raw1394_highlevel); 2913 hpsb_register_highlevel(&raw1394_highlevel);
2914 2914
2915 if (IS_ERR(class_device_create(hpsb_protocol_class, MKDEV( 2915 if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV(
2916 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2916 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
2917 NULL, RAW1394_DEVICE_NAME))) { 2917 NULL, RAW1394_DEVICE_NAME))) {
2918 ret = -EFAULT; 2918 ret = -EFAULT;
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 11be9c9c82a8..23911da50154 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1370,7 +1370,7 @@ static void video1394_add_host (struct hpsb_host *host)
1370 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1370 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
1371 1371
1372 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1372 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
1373 class_device_create(hpsb_protocol_class, MKDEV( 1373 class_device_create(hpsb_protocol_class, NULL, MKDEV(
1374 IEEE1394_MAJOR, minor), 1374 IEEE1394_MAJOR, minor),
1375 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1375 NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
1376 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor), 1376 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, minor),
diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index 5ac86f566dc0..0c3c6952faae 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -37,58 +37,41 @@
37 * $Id: agent.c 1389 2004-12-27 22:56:47Z roland $ 37 * $Id: agent.c 1389 2004-12-27 22:56:47Z roland $
38 */ 38 */
39 39
40#include <linux/dma-mapping.h> 40#include "agent.h"
41 41#include "smi.h"
42#include <asm/bug.h>
43 42
44#include <rdma/ib_smi.h> 43#define SPFX "ib_agent: "
45 44
46#include "smi.h" 45struct ib_agent_port_private {
47#include "agent_priv.h" 46 struct list_head port_list;
48#include "mad_priv.h" 47 struct ib_mad_agent *agent[2];
49#include "agent.h" 48};
50 49
51spinlock_t ib_agent_port_list_lock; 50static DEFINE_SPINLOCK(ib_agent_port_list_lock);
52static LIST_HEAD(ib_agent_port_list); 51static LIST_HEAD(ib_agent_port_list);
53 52
54/* 53static struct ib_agent_port_private *
55 * Caller must hold ib_agent_port_list_lock 54__ib_get_agent_port(struct ib_device *device, int port_num)
56 */
57static inline struct ib_agent_port_private *
58__ib_get_agent_port(struct ib_device *device, int port_num,
59 struct ib_mad_agent *mad_agent)
60{ 55{
61 struct ib_agent_port_private *entry; 56 struct ib_agent_port_private *entry;
62 57
63 BUG_ON(!(!!device ^ !!mad_agent)); /* Exactly one MUST be (!NULL) */ 58 list_for_each_entry(entry, &ib_agent_port_list, port_list) {
64 59 if (entry->agent[0]->device == device &&
65 if (device) { 60 entry->agent[0]->port_num == port_num)
66 list_for_each_entry(entry, &ib_agent_port_list, port_list) { 61 return entry;
67 if (entry->smp_agent->device == device &&
68 entry->port_num == port_num)
69 return entry;
70 }
71 } else {
72 list_for_each_entry(entry, &ib_agent_port_list, port_list) {
73 if ((entry->smp_agent == mad_agent) ||
74 (entry->perf_mgmt_agent == mad_agent))
75 return entry;
76 }
77 } 62 }
78 return NULL; 63 return NULL;
79} 64}
80 65
81static inline struct ib_agent_port_private * 66static struct ib_agent_port_private *
82ib_get_agent_port(struct ib_device *device, int port_num, 67ib_get_agent_port(struct ib_device *device, int port_num)
83 struct ib_mad_agent *mad_agent)
84{ 68{
85 struct ib_agent_port_private *entry; 69 struct ib_agent_port_private *entry;
86 unsigned long flags; 70 unsigned long flags;
87 71
88 spin_lock_irqsave(&ib_agent_port_list_lock, flags); 72 spin_lock_irqsave(&ib_agent_port_list_lock, flags);
89 entry = __ib_get_agent_port(device, port_num, mad_agent); 73 entry = __ib_get_agent_port(device, port_num);
90 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags); 74 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
91
92 return entry; 75 return entry;
93} 76}
94 77
@@ -100,192 +83,76 @@ int smi_check_local_dr_smp(struct ib_smp *smp,
100 83
101 if (smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 84 if (smp->mgmt_class != IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
102 return 1; 85 return 1;
103 port_priv = ib_get_agent_port(device, port_num, NULL); 86
87 port_priv = ib_get_agent_port(device, port_num);
104 if (!port_priv) { 88 if (!port_priv) {
105 printk(KERN_DEBUG SPFX "smi_check_local_dr_smp %s port %d " 89 printk(KERN_DEBUG SPFX "smi_check_local_dr_smp %s port %d "
106 "not open\n", 90 "not open\n", device->name, port_num);
107 device->name, port_num);
108 return 1; 91 return 1;
109 } 92 }
110 93
111 return smi_check_local_smp(port_priv->smp_agent, smp); 94 return smi_check_local_smp(port_priv->agent[0], smp);
112} 95}
113 96
114static int agent_mad_send(struct ib_mad_agent *mad_agent, 97int agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
115 struct ib_agent_port_private *port_priv, 98 struct ib_wc *wc, struct ib_device *device,
116 struct ib_mad_private *mad_priv, 99 int port_num, int qpn)
117 struct ib_grh *grh,
118 struct ib_wc *wc)
119{ 100{
120 struct ib_agent_send_wr *agent_send_wr; 101 struct ib_agent_port_private *port_priv;
121 struct ib_sge gather_list; 102 struct ib_mad_agent *agent;
122 struct ib_send_wr send_wr; 103 struct ib_mad_send_buf *send_buf;
123 struct ib_send_wr *bad_send_wr; 104 struct ib_ah *ah;
124 struct ib_ah_attr ah_attr; 105 int ret;
125 unsigned long flags;
126 int ret = 1;
127
128 agent_send_wr = kmalloc(sizeof(*agent_send_wr), GFP_KERNEL);
129 if (!agent_send_wr)
130 goto out;
131 agent_send_wr->mad = mad_priv;
132
133 gather_list.addr = dma_map_single(mad_agent->device->dma_device,
134 &mad_priv->mad,
135 sizeof(mad_priv->mad),
136 DMA_TO_DEVICE);
137 gather_list.length = sizeof(mad_priv->mad);
138 gather_list.lkey = mad_agent->mr->lkey;
139
140 send_wr.next = NULL;
141 send_wr.opcode = IB_WR_SEND;
142 send_wr.sg_list = &gather_list;
143 send_wr.num_sge = 1;
144 send_wr.wr.ud.remote_qpn = wc->src_qp; /* DQPN */
145 send_wr.wr.ud.timeout_ms = 0;
146 send_wr.send_flags = IB_SEND_SIGNALED | IB_SEND_SOLICITED;
147 106
148 ah_attr.dlid = wc->slid; 107 port_priv = ib_get_agent_port(device, port_num);
149 ah_attr.port_num = mad_agent->port_num; 108 if (!port_priv) {
150 ah_attr.src_path_bits = wc->dlid_path_bits; 109 printk(KERN_ERR SPFX "Unable to find port agent\n");
151 ah_attr.sl = wc->sl; 110 return -ENODEV;
152 ah_attr.static_rate = 0;
153 ah_attr.ah_flags = 0; /* No GRH */
154 if (mad_priv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) {
155 if (wc->wc_flags & IB_WC_GRH) {
156 ah_attr.ah_flags = IB_AH_GRH;
157 /* Should sgid be looked up ? */
158 ah_attr.grh.sgid_index = 0;
159 ah_attr.grh.hop_limit = grh->hop_limit;
160 ah_attr.grh.flow_label = be32_to_cpu(
161 grh->version_tclass_flow) & 0xfffff;
162 ah_attr.grh.traffic_class = (be32_to_cpu(
163 grh->version_tclass_flow) >> 20) & 0xff;
164 memcpy(ah_attr.grh.dgid.raw,
165 grh->sgid.raw,
166 sizeof(ah_attr.grh.dgid));
167 }
168 } 111 }
169 112
170 agent_send_wr->ah = ib_create_ah(mad_agent->qp->pd, &ah_attr); 113 agent = port_priv->agent[qpn];
171 if (IS_ERR(agent_send_wr->ah)) { 114 ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num);
172 printk(KERN_ERR SPFX "No memory for address handle\n"); 115 if (IS_ERR(ah)) {
173 kfree(agent_send_wr); 116 ret = PTR_ERR(ah);
174 goto out; 117 printk(KERN_ERR SPFX "ib_create_ah_from_wc error:%d\n", ret);
118 return ret;
175 } 119 }
176 120
177 send_wr.wr.ud.ah = agent_send_wr->ah; 121 send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
178 if (mad_priv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT) { 122 IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
179 send_wr.wr.ud.pkey_index = wc->pkey_index; 123 GFP_KERNEL);
180 send_wr.wr.ud.remote_qkey = IB_QP1_QKEY; 124 if (IS_ERR(send_buf)) {
181 } else { /* for SMPs */ 125 ret = PTR_ERR(send_buf);
182 send_wr.wr.ud.pkey_index = 0; 126 printk(KERN_ERR SPFX "ib_create_send_mad error:%d\n", ret);
183 send_wr.wr.ud.remote_qkey = 0; 127 goto err1;
184 } 128 }
185 send_wr.wr.ud.mad_hdr = &mad_priv->mad.mad.mad_hdr;
186 send_wr.wr_id = (unsigned long)agent_send_wr;
187 129
188 pci_unmap_addr_set(agent_send_wr, mapping, gather_list.addr); 130 memcpy(send_buf->mad, mad, sizeof *mad);
189 131 send_buf->ah = ah;
190 /* Send */ 132 if ((ret = ib_post_send_mad(send_buf, NULL))) {
191 spin_lock_irqsave(&port_priv->send_list_lock, flags); 133 printk(KERN_ERR SPFX "ib_post_send_mad error:%d\n", ret);
192 if (ib_post_send_mad(mad_agent, &send_wr, &bad_send_wr)) { 134 goto err2;
193 spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
194 dma_unmap_single(mad_agent->device->dma_device,
195 pci_unmap_addr(agent_send_wr, mapping),
196 sizeof(mad_priv->mad),
197 DMA_TO_DEVICE);
198 ib_destroy_ah(agent_send_wr->ah);
199 kfree(agent_send_wr);
200 } else {
201 list_add_tail(&agent_send_wr->send_list,
202 &port_priv->send_posted_list);
203 spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
204 ret = 0;
205 } 135 }
206 136 return 0;
207out: 137err2:
138 ib_free_send_mad(send_buf);
139err1:
140 ib_destroy_ah(ah);
208 return ret; 141 return ret;
209} 142}
210 143
211int agent_send(struct ib_mad_private *mad,
212 struct ib_grh *grh,
213 struct ib_wc *wc,
214 struct ib_device *device,
215 int port_num)
216{
217 struct ib_agent_port_private *port_priv;
218 struct ib_mad_agent *mad_agent;
219
220 port_priv = ib_get_agent_port(device, port_num, NULL);
221 if (!port_priv) {
222 printk(KERN_DEBUG SPFX "agent_send %s port %d not open\n",
223 device->name, port_num);
224 return 1;
225 }
226
227 /* Get mad agent based on mgmt_class in MAD */
228 switch (mad->mad.mad.mad_hdr.mgmt_class) {
229 case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
230 case IB_MGMT_CLASS_SUBN_LID_ROUTED:
231 mad_agent = port_priv->smp_agent;
232 break;
233 case IB_MGMT_CLASS_PERF_MGMT:
234 mad_agent = port_priv->perf_mgmt_agent;
235 break;
236 default:
237 return 1;
238 }
239
240 return agent_mad_send(mad_agent, port_priv, mad, grh, wc);
241}
242
243static void agent_send_handler(struct ib_mad_agent *mad_agent, 144static void agent_send_handler(struct ib_mad_agent *mad_agent,
244 struct ib_mad_send_wc *mad_send_wc) 145 struct ib_mad_send_wc *mad_send_wc)
245{ 146{
246 struct ib_agent_port_private *port_priv; 147 ib_destroy_ah(mad_send_wc->send_buf->ah);
247 struct ib_agent_send_wr *agent_send_wr; 148 ib_free_send_mad(mad_send_wc->send_buf);
248 unsigned long flags;
249
250 /* Find matching MAD agent */
251 port_priv = ib_get_agent_port(NULL, 0, mad_agent);
252 if (!port_priv) {
253 printk(KERN_ERR SPFX "agent_send_handler: no matching MAD "
254 "agent %p\n", mad_agent);
255 return;
256 }
257
258 agent_send_wr = (struct ib_agent_send_wr *)(unsigned long)mad_send_wc->wr_id;
259 spin_lock_irqsave(&port_priv->send_list_lock, flags);
260 /* Remove completed send from posted send MAD list */
261 list_del(&agent_send_wr->send_list);
262 spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
263
264 dma_unmap_single(mad_agent->device->dma_device,
265 pci_unmap_addr(agent_send_wr, mapping),
266 sizeof(agent_send_wr->mad->mad),
267 DMA_TO_DEVICE);
268
269 ib_destroy_ah(agent_send_wr->ah);
270
271 /* Release allocated memory */
272 kmem_cache_free(ib_mad_cache, agent_send_wr->mad);
273 kfree(agent_send_wr);
274} 149}
275 150
276int ib_agent_port_open(struct ib_device *device, int port_num) 151int ib_agent_port_open(struct ib_device *device, int port_num)
277{ 152{
278 int ret;
279 struct ib_agent_port_private *port_priv; 153 struct ib_agent_port_private *port_priv;
280 unsigned long flags; 154 unsigned long flags;
281 155 int ret;
282 /* First, check if port already open for SMI */
283 port_priv = ib_get_agent_port(device, port_num, NULL);
284 if (port_priv) {
285 printk(KERN_DEBUG SPFX "%s port %d already open\n",
286 device->name, port_num);
287 return 0;
288 }
289 156
290 /* Create new device info */ 157 /* Create new device info */
291 port_priv = kmalloc(sizeof *port_priv, GFP_KERNEL); 158 port_priv = kmalloc(sizeof *port_priv, GFP_KERNEL);
@@ -294,32 +161,25 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
294 ret = -ENOMEM; 161 ret = -ENOMEM;
295 goto error1; 162 goto error1;
296 } 163 }
297
298 memset(port_priv, 0, sizeof *port_priv); 164 memset(port_priv, 0, sizeof *port_priv);
299 port_priv->port_num = port_num;
300 spin_lock_init(&port_priv->send_list_lock);
301 INIT_LIST_HEAD(&port_priv->send_posted_list);
302 165
303 /* Obtain send only MAD agent for SM class (SMI QP) */ 166 /* Obtain send only MAD agent for SMI QP */
304 port_priv->smp_agent = ib_register_mad_agent(device, port_num, 167 port_priv->agent[0] = ib_register_mad_agent(device, port_num,
305 IB_QPT_SMI, 168 IB_QPT_SMI, NULL, 0,
306 NULL, 0,
307 &agent_send_handler, 169 &agent_send_handler,
308 NULL, NULL); 170 NULL, NULL);
309 171 if (IS_ERR(port_priv->agent[0])) {
310 if (IS_ERR(port_priv->smp_agent)) { 172 ret = PTR_ERR(port_priv->agent[0]);
311 ret = PTR_ERR(port_priv->smp_agent);
312 goto error2; 173 goto error2;
313 } 174 }
314 175
315 /* Obtain send only MAD agent for PerfMgmt class (GSI QP) */ 176 /* Obtain send only MAD agent for GSI QP */
316 port_priv->perf_mgmt_agent = ib_register_mad_agent(device, port_num, 177 port_priv->agent[1] = ib_register_mad_agent(device, port_num,
317 IB_QPT_GSI, 178 IB_QPT_GSI, NULL, 0,
318 NULL, 0, 179 &agent_send_handler,
319 &agent_send_handler, 180 NULL, NULL);
320 NULL, NULL); 181 if (IS_ERR(port_priv->agent[1])) {
321 if (IS_ERR(port_priv->perf_mgmt_agent)) { 182 ret = PTR_ERR(port_priv->agent[1]);
322 ret = PTR_ERR(port_priv->perf_mgmt_agent);
323 goto error3; 183 goto error3;
324 } 184 }
325 185
@@ -330,7 +190,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
330 return 0; 190 return 0;
331 191
332error3: 192error3:
333 ib_unregister_mad_agent(port_priv->smp_agent); 193 ib_unregister_mad_agent(port_priv->agent[0]);
334error2: 194error2:
335 kfree(port_priv); 195 kfree(port_priv);
336error1: 196error1:
@@ -343,7 +203,7 @@ int ib_agent_port_close(struct ib_device *device, int port_num)
343 unsigned long flags; 203 unsigned long flags;
344 204
345 spin_lock_irqsave(&ib_agent_port_list_lock, flags); 205 spin_lock_irqsave(&ib_agent_port_list_lock, flags);
346 port_priv = __ib_get_agent_port(device, port_num, NULL); 206 port_priv = __ib_get_agent_port(device, port_num);
347 if (port_priv == NULL) { 207 if (port_priv == NULL) {
348 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags); 208 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
349 printk(KERN_ERR SPFX "Port %d not found\n", port_num); 209 printk(KERN_ERR SPFX "Port %d not found\n", port_num);
@@ -352,9 +212,8 @@ int ib_agent_port_close(struct ib_device *device, int port_num)
352 list_del(&port_priv->port_list); 212 list_del(&port_priv->port_list);
353 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags); 213 spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
354 214
355 ib_unregister_mad_agent(port_priv->perf_mgmt_agent); 215 ib_unregister_mad_agent(port_priv->agent[1]);
356 ib_unregister_mad_agent(port_priv->smp_agent); 216 ib_unregister_mad_agent(port_priv->agent[0]);
357 kfree(port_priv); 217 kfree(port_priv);
358
359 return 0; 218 return 0;
360} 219}
diff --git a/drivers/infiniband/core/agent.h b/drivers/infiniband/core/agent.h
index d9426842254a..c5f3cfec942a 100644
--- a/drivers/infiniband/core/agent.h
+++ b/drivers/infiniband/core/agent.h
@@ -39,17 +39,14 @@
39#ifndef __AGENT_H_ 39#ifndef __AGENT_H_
40#define __AGENT_H_ 40#define __AGENT_H_
41 41
42extern spinlock_t ib_agent_port_list_lock; 42#include <rdma/ib_mad.h>
43 43
44extern int ib_agent_port_open(struct ib_device *device, 44extern int ib_agent_port_open(struct ib_device *device, int port_num);
45 int port_num);
46 45
47extern int ib_agent_port_close(struct ib_device *device, int port_num); 46extern int ib_agent_port_close(struct ib_device *device, int port_num);
48 47
49extern int agent_send(struct ib_mad_private *mad, 48extern int agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
50 struct ib_grh *grh, 49 struct ib_wc *wc, struct ib_device *device,
51 struct ib_wc *wc, 50 int port_num, int qpn);
52 struct ib_device *device,
53 int port_num);
54 51
55#endif /* __AGENT_H_ */ 52#endif /* __AGENT_H_ */
diff --git a/drivers/infiniband/core/agent_priv.h b/drivers/infiniband/core/agent_priv.h
deleted file mode 100644
index 2ec6d7f1b7d0..000000000000
--- a/drivers/infiniband/core/agent_priv.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
3 * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
4 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
6 * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
7 *
8 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU
10 * General Public License (GPL) Version 2, available from the file
11 * COPYING in the main directory of this source tree, or the
12 * OpenIB.org BSD license below:
13 *
14 * Redistribution and use in source and binary forms, with or
15 * without modification, are permitted provided that the following
16 * conditions are met:
17 *
18 * - Redistributions of source code must retain the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer.
21 *
22 * - Redistributions in binary form must reproduce the above
23 * copyright notice, this list of conditions and the following
24 * disclaimer in the documentation and/or other materials
25 * provided with the distribution.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE.
35 *
36 * $Id: agent_priv.h 1640 2005-01-24 22:39:02Z halr $
37 */
38
39#ifndef __IB_AGENT_PRIV_H__
40#define __IB_AGENT_PRIV_H__
41
42#include <linux/pci.h>
43
44#define SPFX "ib_agent: "
45
46struct ib_agent_send_wr {
47 struct list_head send_list;
48 struct ib_ah *ah;
49 struct ib_mad_private *mad;
50 DECLARE_PCI_UNMAP_ADDR(mapping)
51};
52
53struct ib_agent_port_private {
54 struct list_head port_list;
55 struct list_head send_posted_list;
56 spinlock_t send_list_lock;
57 int port_num;
58 struct ib_mad_agent *smp_agent; /* SM class */
59 struct ib_mad_agent *perf_mgmt_agent; /* PerfMgmt class */
60};
61
62#endif /* __IB_AGENT_PRIV_H__ */
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 54db6d4831f1..580c3a2bb102 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -135,6 +135,7 @@ struct cm_id_private {
135 __be64 tid; 135 __be64 tid;
136 __be32 local_qpn; 136 __be32 local_qpn;
137 __be32 remote_qpn; 137 __be32 remote_qpn;
138 enum ib_qp_type qp_type;
138 __be32 sq_psn; 139 __be32 sq_psn;
139 __be32 rq_psn; 140 __be32 rq_psn;
140 int timeout_ms; 141 int timeout_ms;
@@ -175,8 +176,7 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
175 176
176 m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn, 177 m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn,
177 cm_id_priv->av.pkey_index, 178 cm_id_priv->av.pkey_index,
178 ah, 0, sizeof(struct ib_mad_hdr), 179 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
179 sizeof(struct ib_mad)-sizeof(struct ib_mad_hdr),
180 GFP_ATOMIC); 180 GFP_ATOMIC);
181 if (IS_ERR(m)) { 181 if (IS_ERR(m)) {
182 ib_destroy_ah(ah); 182 ib_destroy_ah(ah);
@@ -184,7 +184,8 @@ static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
184 } 184 }
185 185
186 /* Timeout set by caller if response is expected. */ 186 /* Timeout set by caller if response is expected. */
187 m->send_wr.wr.ud.retries = cm_id_priv->max_cm_retries; 187 m->ah = ah;
188 m->retries = cm_id_priv->max_cm_retries;
188 189
189 atomic_inc(&cm_id_priv->refcount); 190 atomic_inc(&cm_id_priv->refcount);
190 m->context[0] = cm_id_priv; 191 m->context[0] = cm_id_priv;
@@ -205,20 +206,20 @@ static int cm_alloc_response_msg(struct cm_port *port,
205 return PTR_ERR(ah); 206 return PTR_ERR(ah);
206 207
207 m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index, 208 m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index,
208 ah, 0, sizeof(struct ib_mad_hdr), 209 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
209 sizeof(struct ib_mad)-sizeof(struct ib_mad_hdr),
210 GFP_ATOMIC); 210 GFP_ATOMIC);
211 if (IS_ERR(m)) { 211 if (IS_ERR(m)) {
212 ib_destroy_ah(ah); 212 ib_destroy_ah(ah);
213 return PTR_ERR(m); 213 return PTR_ERR(m);
214 } 214 }
215 m->ah = ah;
215 *msg = m; 216 *msg = m;
216 return 0; 217 return 0;
217} 218}
218 219
219static void cm_free_msg(struct ib_mad_send_buf *msg) 220static void cm_free_msg(struct ib_mad_send_buf *msg)
220{ 221{
221 ib_destroy_ah(msg->send_wr.wr.ud.ah); 222 ib_destroy_ah(msg->ah);
222 if (msg->context[0]) 223 if (msg->context[0])
223 cm_deref_id(msg->context[0]); 224 cm_deref_id(msg->context[0]);
224 ib_free_send_mad(msg); 225 ib_free_send_mad(msg);
@@ -366,9 +367,15 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
366 cur_cm_id_priv = rb_entry(parent, struct cm_id_private, 367 cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
367 service_node); 368 service_node);
368 if ((cur_cm_id_priv->id.service_mask & service_id) == 369 if ((cur_cm_id_priv->id.service_mask & service_id) ==
369 (service_mask & cur_cm_id_priv->id.service_id)) 370 (service_mask & cur_cm_id_priv->id.service_id) &&
370 return cm_id_priv; 371 (cm_id_priv->id.device == cur_cm_id_priv->id.device))
371 if (service_id < cur_cm_id_priv->id.service_id) 372 return cur_cm_id_priv;
373
374 if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
375 link = &(*link)->rb_left;
376 else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
377 link = &(*link)->rb_right;
378 else if (service_id < cur_cm_id_priv->id.service_id)
372 link = &(*link)->rb_left; 379 link = &(*link)->rb_left;
373 else 380 else
374 link = &(*link)->rb_right; 381 link = &(*link)->rb_right;
@@ -378,7 +385,8 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
378 return NULL; 385 return NULL;
379} 386}
380 387
381static struct cm_id_private * cm_find_listen(__be64 service_id) 388static struct cm_id_private * cm_find_listen(struct ib_device *device,
389 __be64 service_id)
382{ 390{
383 struct rb_node *node = cm.listen_service_table.rb_node; 391 struct rb_node *node = cm.listen_service_table.rb_node;
384 struct cm_id_private *cm_id_priv; 392 struct cm_id_private *cm_id_priv;
@@ -386,9 +394,15 @@ static struct cm_id_private * cm_find_listen(__be64 service_id)
386 while (node) { 394 while (node) {
387 cm_id_priv = rb_entry(node, struct cm_id_private, service_node); 395 cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
388 if ((cm_id_priv->id.service_mask & service_id) == 396 if ((cm_id_priv->id.service_mask & service_id) ==
389 (cm_id_priv->id.service_mask & cm_id_priv->id.service_id)) 397 cm_id_priv->id.service_id &&
398 (cm_id_priv->id.device == device))
390 return cm_id_priv; 399 return cm_id_priv;
391 if (service_id < cm_id_priv->id.service_id) 400
401 if (device < cm_id_priv->id.device)
402 node = node->rb_left;
403 else if (device > cm_id_priv->id.device)
404 node = node->rb_right;
405 else if (service_id < cm_id_priv->id.service_id)
392 node = node->rb_left; 406 node = node->rb_left;
393 else 407 else
394 node = node->rb_right; 408 node = node->rb_right;
@@ -523,7 +537,8 @@ static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv,
523 ib_send_cm_sidr_rep(&cm_id_priv->id, &param); 537 ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
524} 538}
525 539
526struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, 540struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
541 ib_cm_handler cm_handler,
527 void *context) 542 void *context)
528{ 543{
529 struct cm_id_private *cm_id_priv; 544 struct cm_id_private *cm_id_priv;
@@ -535,6 +550,7 @@ struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler,
535 550
536 memset(cm_id_priv, 0, sizeof *cm_id_priv); 551 memset(cm_id_priv, 0, sizeof *cm_id_priv);
537 cm_id_priv->id.state = IB_CM_IDLE; 552 cm_id_priv->id.state = IB_CM_IDLE;
553 cm_id_priv->id.device = device;
538 cm_id_priv->id.cm_handler = cm_handler; 554 cm_id_priv->id.cm_handler = cm_handler;
539 cm_id_priv->id.context = context; 555 cm_id_priv->id.context = context;
540 cm_id_priv->id.remote_cm_qpn = 1; 556 cm_id_priv->id.remote_cm_qpn = 1;
@@ -662,8 +678,7 @@ retest:
662 break; 678 break;
663 case IB_CM_SIDR_REQ_SENT: 679 case IB_CM_SIDR_REQ_SENT:
664 cm_id->state = IB_CM_IDLE; 680 cm_id->state = IB_CM_IDLE;
665 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 681 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
666 (unsigned long) cm_id_priv->msg);
667 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 682 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
668 break; 683 break;
669 case IB_CM_SIDR_REQ_RCVD: 684 case IB_CM_SIDR_REQ_RCVD:
@@ -674,8 +689,7 @@ retest:
674 case IB_CM_MRA_REQ_RCVD: 689 case IB_CM_MRA_REQ_RCVD:
675 case IB_CM_REP_SENT: 690 case IB_CM_REP_SENT:
676 case IB_CM_MRA_REP_RCVD: 691 case IB_CM_MRA_REP_RCVD:
677 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 692 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
678 (unsigned long) cm_id_priv->msg);
679 /* Fall through */ 693 /* Fall through */
680 case IB_CM_REQ_RCVD: 694 case IB_CM_REQ_RCVD:
681 case IB_CM_MRA_REQ_SENT: 695 case IB_CM_MRA_REQ_SENT:
@@ -692,8 +706,7 @@ retest:
692 ib_send_cm_dreq(cm_id, NULL, 0); 706 ib_send_cm_dreq(cm_id, NULL, 0);
693 goto retest; 707 goto retest;
694 case IB_CM_DREQ_SENT: 708 case IB_CM_DREQ_SENT:
695 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 709 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
696 (unsigned long) cm_id_priv->msg);
697 cm_enter_timewait(cm_id_priv); 710 cm_enter_timewait(cm_id_priv);
698 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 711 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
699 break; 712 break;
@@ -867,7 +880,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
867 struct ib_cm_req_param *param) 880 struct ib_cm_req_param *param)
868{ 881{
869 struct cm_id_private *cm_id_priv; 882 struct cm_id_private *cm_id_priv;
870 struct ib_send_wr *bad_send_wr;
871 struct cm_req_msg *req_msg; 883 struct cm_req_msg *req_msg;
872 unsigned long flags; 884 unsigned long flags;
873 int ret; 885 int ret;
@@ -911,6 +923,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
911 cm_id_priv->responder_resources = param->responder_resources; 923 cm_id_priv->responder_resources = param->responder_resources;
912 cm_id_priv->retry_count = param->retry_count; 924 cm_id_priv->retry_count = param->retry_count;
913 cm_id_priv->path_mtu = param->primary_path->mtu; 925 cm_id_priv->path_mtu = param->primary_path->mtu;
926 cm_id_priv->qp_type = param->qp_type;
914 927
915 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg); 928 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg);
916 if (ret) 929 if (ret)
@@ -919,7 +932,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
919 req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad; 932 req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad;
920 cm_format_req(req_msg, cm_id_priv, param); 933 cm_format_req(req_msg, cm_id_priv, param);
921 cm_id_priv->tid = req_msg->hdr.tid; 934 cm_id_priv->tid = req_msg->hdr.tid;
922 cm_id_priv->msg->send_wr.wr.ud.timeout_ms = cm_id_priv->timeout_ms; 935 cm_id_priv->msg->timeout_ms = cm_id_priv->timeout_ms;
923 cm_id_priv->msg->context[1] = (void *) (unsigned long) IB_CM_REQ_SENT; 936 cm_id_priv->msg->context[1] = (void *) (unsigned long) IB_CM_REQ_SENT;
924 937
925 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg); 938 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg);
@@ -928,8 +941,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
928 cm_req_get_primary_local_ack_timeout(req_msg); 941 cm_req_get_primary_local_ack_timeout(req_msg);
929 942
930 spin_lock_irqsave(&cm_id_priv->lock, flags); 943 spin_lock_irqsave(&cm_id_priv->lock, flags);
931 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 944 ret = ib_post_send_mad(cm_id_priv->msg, NULL);
932 &cm_id_priv->msg->send_wr, &bad_send_wr);
933 if (ret) { 945 if (ret) {
934 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 946 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
935 goto error2; 947 goto error2;
@@ -952,7 +964,6 @@ static int cm_issue_rej(struct cm_port *port,
952 void *ari, u8 ari_length) 964 void *ari, u8 ari_length)
953{ 965{
954 struct ib_mad_send_buf *msg = NULL; 966 struct ib_mad_send_buf *msg = NULL;
955 struct ib_send_wr *bad_send_wr;
956 struct cm_rej_msg *rej_msg, *rcv_msg; 967 struct cm_rej_msg *rej_msg, *rcv_msg;
957 int ret; 968 int ret;
958 969
@@ -975,7 +986,7 @@ static int cm_issue_rej(struct cm_port *port,
975 memcpy(rej_msg->ari, ari, ari_length); 986 memcpy(rej_msg->ari, ari, ari_length);
976 } 987 }
977 988
978 ret = ib_post_send_mad(port->mad_agent, &msg->send_wr, &bad_send_wr); 989 ret = ib_post_send_mad(msg, NULL);
979 if (ret) 990 if (ret)
980 cm_free_msg(msg); 991 cm_free_msg(msg);
981 992
@@ -1047,7 +1058,6 @@ static void cm_format_req_event(struct cm_work *work,
1047 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1058 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
1048 param = &work->cm_event.param.req_rcvd; 1059 param = &work->cm_event.param.req_rcvd;
1049 param->listen_id = listen_id; 1060 param->listen_id = listen_id;
1050 param->device = cm_id_priv->av.port->mad_agent->device;
1051 param->port = cm_id_priv->av.port->port_num; 1061 param->port = cm_id_priv->av.port->port_num;
1052 param->primary_path = &work->path[0]; 1062 param->primary_path = &work->path[0];
1053 if (req_msg->alt_local_lid) 1063 if (req_msg->alt_local_lid)
@@ -1156,7 +1166,6 @@ static void cm_dup_req_handler(struct cm_work *work,
1156 struct cm_id_private *cm_id_priv) 1166 struct cm_id_private *cm_id_priv)
1157{ 1167{
1158 struct ib_mad_send_buf *msg = NULL; 1168 struct ib_mad_send_buf *msg = NULL;
1159 struct ib_send_wr *bad_send_wr;
1160 unsigned long flags; 1169 unsigned long flags;
1161 int ret; 1170 int ret;
1162 1171
@@ -1185,8 +1194,7 @@ static void cm_dup_req_handler(struct cm_work *work,
1185 } 1194 }
1186 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1195 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1187 1196
1188 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, &msg->send_wr, 1197 ret = ib_post_send_mad(msg, NULL);
1189 &bad_send_wr);
1190 if (ret) 1198 if (ret)
1191 goto free; 1199 goto free;
1192 return; 1200 return;
@@ -1226,7 +1234,8 @@ static struct cm_id_private * cm_match_req(struct cm_work *work,
1226 } 1234 }
1227 1235
1228 /* Find matching listen request. */ 1236 /* Find matching listen request. */
1229 listen_cm_id_priv = cm_find_listen(req_msg->service_id); 1237 listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device,
1238 req_msg->service_id);
1230 if (!listen_cm_id_priv) { 1239 if (!listen_cm_id_priv) {
1231 spin_unlock_irqrestore(&cm.lock, flags); 1240 spin_unlock_irqrestore(&cm.lock, flags);
1232 cm_issue_rej(work->port, work->mad_recv_wc, 1241 cm_issue_rej(work->port, work->mad_recv_wc,
@@ -1254,7 +1263,7 @@ static int cm_req_handler(struct cm_work *work)
1254 1263
1255 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad; 1264 req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
1256 1265
1257 cm_id = ib_create_cm_id(NULL, NULL); 1266 cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
1258 if (IS_ERR(cm_id)) 1267 if (IS_ERR(cm_id))
1259 return PTR_ERR(cm_id); 1268 return PTR_ERR(cm_id);
1260 1269
@@ -1305,6 +1314,7 @@ static int cm_req_handler(struct cm_work *work)
1305 cm_req_get_primary_local_ack_timeout(req_msg); 1314 cm_req_get_primary_local_ack_timeout(req_msg);
1306 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg); 1315 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg);
1307 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg); 1316 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
1317 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg);
1308 1318
1309 cm_format_req_event(work, cm_id_priv, &listen_cm_id_priv->id); 1319 cm_format_req_event(work, cm_id_priv, &listen_cm_id_priv->id);
1310 cm_process_work(cm_id_priv, work); 1320 cm_process_work(cm_id_priv, work);
@@ -1349,7 +1359,6 @@ int ib_send_cm_rep(struct ib_cm_id *cm_id,
1349 struct cm_id_private *cm_id_priv; 1359 struct cm_id_private *cm_id_priv;
1350 struct ib_mad_send_buf *msg; 1360 struct ib_mad_send_buf *msg;
1351 struct cm_rep_msg *rep_msg; 1361 struct cm_rep_msg *rep_msg;
1352 struct ib_send_wr *bad_send_wr;
1353 unsigned long flags; 1362 unsigned long flags;
1354 int ret; 1363 int ret;
1355 1364
@@ -1371,11 +1380,10 @@ int ib_send_cm_rep(struct ib_cm_id *cm_id,
1371 1380
1372 rep_msg = (struct cm_rep_msg *) msg->mad; 1381 rep_msg = (struct cm_rep_msg *) msg->mad;
1373 cm_format_rep(rep_msg, cm_id_priv, param); 1382 cm_format_rep(rep_msg, cm_id_priv, param);
1374 msg->send_wr.wr.ud.timeout_ms = cm_id_priv->timeout_ms; 1383 msg->timeout_ms = cm_id_priv->timeout_ms;
1375 msg->context[1] = (void *) (unsigned long) IB_CM_REP_SENT; 1384 msg->context[1] = (void *) (unsigned long) IB_CM_REP_SENT;
1376 1385
1377 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 1386 ret = ib_post_send_mad(msg, NULL);
1378 &msg->send_wr, &bad_send_wr);
1379 if (ret) { 1387 if (ret) {
1380 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1388 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1381 cm_free_msg(msg); 1389 cm_free_msg(msg);
@@ -1413,7 +1421,6 @@ int ib_send_cm_rtu(struct ib_cm_id *cm_id,
1413{ 1421{
1414 struct cm_id_private *cm_id_priv; 1422 struct cm_id_private *cm_id_priv;
1415 struct ib_mad_send_buf *msg; 1423 struct ib_mad_send_buf *msg;
1416 struct ib_send_wr *bad_send_wr;
1417 unsigned long flags; 1424 unsigned long flags;
1418 void *data; 1425 void *data;
1419 int ret; 1426 int ret;
@@ -1440,8 +1447,7 @@ int ib_send_cm_rtu(struct ib_cm_id *cm_id,
1440 cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv, 1447 cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv,
1441 private_data, private_data_len); 1448 private_data, private_data_len);
1442 1449
1443 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 1450 ret = ib_post_send_mad(msg, NULL);
1444 &msg->send_wr, &bad_send_wr);
1445 if (ret) { 1451 if (ret) {
1446 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1452 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1447 cm_free_msg(msg); 1453 cm_free_msg(msg);
@@ -1486,7 +1492,6 @@ static void cm_dup_rep_handler(struct cm_work *work)
1486 struct cm_id_private *cm_id_priv; 1492 struct cm_id_private *cm_id_priv;
1487 struct cm_rep_msg *rep_msg; 1493 struct cm_rep_msg *rep_msg;
1488 struct ib_mad_send_buf *msg = NULL; 1494 struct ib_mad_send_buf *msg = NULL;
1489 struct ib_send_wr *bad_send_wr;
1490 unsigned long flags; 1495 unsigned long flags;
1491 int ret; 1496 int ret;
1492 1497
@@ -1514,8 +1519,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
1514 goto unlock; 1519 goto unlock;
1515 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1520 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1516 1521
1517 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, &msg->send_wr, 1522 ret = ib_post_send_mad(msg, NULL);
1518 &bad_send_wr);
1519 if (ret) 1523 if (ret)
1520 goto free; 1524 goto free;
1521 goto deref; 1525 goto deref;
@@ -1583,8 +1587,7 @@ static int cm_rep_handler(struct cm_work *work)
1583 1587
1584 /* todo: handle peer_to_peer */ 1588 /* todo: handle peer_to_peer */
1585 1589
1586 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 1590 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
1587 (unsigned long) cm_id_priv->msg);
1588 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1591 ret = atomic_inc_and_test(&cm_id_priv->work_count);
1589 if (!ret) 1592 if (!ret)
1590 list_add_tail(&work->list, &cm_id_priv->work_list); 1593 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -1618,8 +1621,7 @@ static int cm_establish_handler(struct cm_work *work)
1618 goto out; 1621 goto out;
1619 } 1622 }
1620 1623
1621 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 1624 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
1622 (unsigned long) cm_id_priv->msg);
1623 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1625 ret = atomic_inc_and_test(&cm_id_priv->work_count);
1624 if (!ret) 1626 if (!ret)
1625 list_add_tail(&work->list, &cm_id_priv->work_list); 1627 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -1658,8 +1660,7 @@ static int cm_rtu_handler(struct cm_work *work)
1658 } 1660 }
1659 cm_id_priv->id.state = IB_CM_ESTABLISHED; 1661 cm_id_priv->id.state = IB_CM_ESTABLISHED;
1660 1662
1661 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 1663 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
1662 (unsigned long) cm_id_priv->msg);
1663 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1664 ret = atomic_inc_and_test(&cm_id_priv->work_count);
1664 if (!ret) 1665 if (!ret)
1665 list_add_tail(&work->list, &cm_id_priv->work_list); 1666 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -1696,7 +1697,6 @@ int ib_send_cm_dreq(struct ib_cm_id *cm_id,
1696{ 1697{
1697 struct cm_id_private *cm_id_priv; 1698 struct cm_id_private *cm_id_priv;
1698 struct ib_mad_send_buf *msg; 1699 struct ib_mad_send_buf *msg;
1699 struct ib_send_wr *bad_send_wr;
1700 unsigned long flags; 1700 unsigned long flags;
1701 int ret; 1701 int ret;
1702 1702
@@ -1718,11 +1718,10 @@ int ib_send_cm_dreq(struct ib_cm_id *cm_id,
1718 1718
1719 cm_format_dreq((struct cm_dreq_msg *) msg->mad, cm_id_priv, 1719 cm_format_dreq((struct cm_dreq_msg *) msg->mad, cm_id_priv,
1720 private_data, private_data_len); 1720 private_data, private_data_len);
1721 msg->send_wr.wr.ud.timeout_ms = cm_id_priv->timeout_ms; 1721 msg->timeout_ms = cm_id_priv->timeout_ms;
1722 msg->context[1] = (void *) (unsigned long) IB_CM_DREQ_SENT; 1722 msg->context[1] = (void *) (unsigned long) IB_CM_DREQ_SENT;
1723 1723
1724 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 1724 ret = ib_post_send_mad(msg, NULL);
1725 &msg->send_wr, &bad_send_wr);
1726 if (ret) { 1725 if (ret) {
1727 cm_enter_timewait(cm_id_priv); 1726 cm_enter_timewait(cm_id_priv);
1728 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1727 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
@@ -1756,7 +1755,6 @@ int ib_send_cm_drep(struct ib_cm_id *cm_id,
1756{ 1755{
1757 struct cm_id_private *cm_id_priv; 1756 struct cm_id_private *cm_id_priv;
1758 struct ib_mad_send_buf *msg; 1757 struct ib_mad_send_buf *msg;
1759 struct ib_send_wr *bad_send_wr;
1760 unsigned long flags; 1758 unsigned long flags;
1761 void *data; 1759 void *data;
1762 int ret; 1760 int ret;
@@ -1786,8 +1784,7 @@ int ib_send_cm_drep(struct ib_cm_id *cm_id,
1786 cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv, 1784 cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv,
1787 private_data, private_data_len); 1785 private_data, private_data_len);
1788 1786
1789 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, &msg->send_wr, 1787 ret = ib_post_send_mad(msg, NULL);
1790 &bad_send_wr);
1791 if (ret) { 1788 if (ret) {
1792 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1789 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1793 cm_free_msg(msg); 1790 cm_free_msg(msg);
@@ -1804,7 +1801,6 @@ static int cm_dreq_handler(struct cm_work *work)
1804 struct cm_id_private *cm_id_priv; 1801 struct cm_id_private *cm_id_priv;
1805 struct cm_dreq_msg *dreq_msg; 1802 struct cm_dreq_msg *dreq_msg;
1806 struct ib_mad_send_buf *msg = NULL; 1803 struct ib_mad_send_buf *msg = NULL;
1807 struct ib_send_wr *bad_send_wr;
1808 unsigned long flags; 1804 unsigned long flags;
1809 int ret; 1805 int ret;
1810 1806
@@ -1823,8 +1819,7 @@ static int cm_dreq_handler(struct cm_work *work)
1823 switch (cm_id_priv->id.state) { 1819 switch (cm_id_priv->id.state) {
1824 case IB_CM_REP_SENT: 1820 case IB_CM_REP_SENT:
1825 case IB_CM_DREQ_SENT: 1821 case IB_CM_DREQ_SENT:
1826 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 1822 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
1827 (unsigned long) cm_id_priv->msg);
1828 break; 1823 break;
1829 case IB_CM_ESTABLISHED: 1824 case IB_CM_ESTABLISHED:
1830 case IB_CM_MRA_REP_RCVD: 1825 case IB_CM_MRA_REP_RCVD:
@@ -1838,8 +1833,7 @@ static int cm_dreq_handler(struct cm_work *work)
1838 cm_id_priv->private_data_len); 1833 cm_id_priv->private_data_len);
1839 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 1834 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
1840 1835
1841 if (ib_post_send_mad(cm_id_priv->av.port->mad_agent, 1836 if (ib_post_send_mad(msg, NULL))
1842 &msg->send_wr, &bad_send_wr))
1843 cm_free_msg(msg); 1837 cm_free_msg(msg);
1844 goto deref; 1838 goto deref;
1845 default: 1839 default:
@@ -1886,8 +1880,7 @@ static int cm_drep_handler(struct cm_work *work)
1886 } 1880 }
1887 cm_enter_timewait(cm_id_priv); 1881 cm_enter_timewait(cm_id_priv);
1888 1882
1889 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 1883 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
1890 (unsigned long) cm_id_priv->msg);
1891 ret = atomic_inc_and_test(&cm_id_priv->work_count); 1884 ret = atomic_inc_and_test(&cm_id_priv->work_count);
1892 if (!ret) 1885 if (!ret)
1893 list_add_tail(&work->list, &cm_id_priv->work_list); 1886 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -1912,7 +1905,6 @@ int ib_send_cm_rej(struct ib_cm_id *cm_id,
1912{ 1905{
1913 struct cm_id_private *cm_id_priv; 1906 struct cm_id_private *cm_id_priv;
1914 struct ib_mad_send_buf *msg; 1907 struct ib_mad_send_buf *msg;
1915 struct ib_send_wr *bad_send_wr;
1916 unsigned long flags; 1908 unsigned long flags;
1917 int ret; 1909 int ret;
1918 1910
@@ -1956,8 +1948,7 @@ int ib_send_cm_rej(struct ib_cm_id *cm_id,
1956 if (ret) 1948 if (ret)
1957 goto out; 1949 goto out;
1958 1950
1959 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 1951 ret = ib_post_send_mad(msg, NULL);
1960 &msg->send_wr, &bad_send_wr);
1961 if (ret) 1952 if (ret)
1962 cm_free_msg(msg); 1953 cm_free_msg(msg);
1963 1954
@@ -2033,8 +2024,7 @@ static int cm_rej_handler(struct cm_work *work)
2033 case IB_CM_MRA_REQ_RCVD: 2024 case IB_CM_MRA_REQ_RCVD:
2034 case IB_CM_REP_SENT: 2025 case IB_CM_REP_SENT:
2035 case IB_CM_MRA_REP_RCVD: 2026 case IB_CM_MRA_REP_RCVD:
2036 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 2027 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
2037 (unsigned long) cm_id_priv->msg);
2038 /* fall through */ 2028 /* fall through */
2039 case IB_CM_REQ_RCVD: 2029 case IB_CM_REQ_RCVD:
2040 case IB_CM_MRA_REQ_SENT: 2030 case IB_CM_MRA_REQ_SENT:
@@ -2044,8 +2034,7 @@ static int cm_rej_handler(struct cm_work *work)
2044 cm_reset_to_idle(cm_id_priv); 2034 cm_reset_to_idle(cm_id_priv);
2045 break; 2035 break;
2046 case IB_CM_DREQ_SENT: 2036 case IB_CM_DREQ_SENT:
2047 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 2037 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
2048 (unsigned long) cm_id_priv->msg);
2049 /* fall through */ 2038 /* fall through */
2050 case IB_CM_REP_RCVD: 2039 case IB_CM_REP_RCVD:
2051 case IB_CM_MRA_REP_SENT: 2040 case IB_CM_MRA_REP_SENT:
@@ -2080,7 +2069,6 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2080{ 2069{
2081 struct cm_id_private *cm_id_priv; 2070 struct cm_id_private *cm_id_priv;
2082 struct ib_mad_send_buf *msg; 2071 struct ib_mad_send_buf *msg;
2083 struct ib_send_wr *bad_send_wr;
2084 void *data; 2072 void *data;
2085 unsigned long flags; 2073 unsigned long flags;
2086 int ret; 2074 int ret;
@@ -2104,8 +2092,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2104 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, 2092 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2105 CM_MSG_RESPONSE_REQ, service_timeout, 2093 CM_MSG_RESPONSE_REQ, service_timeout,
2106 private_data, private_data_len); 2094 private_data, private_data_len);
2107 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2095 ret = ib_post_send_mad(msg, NULL);
2108 &msg->send_wr, &bad_send_wr);
2109 if (ret) 2096 if (ret)
2110 goto error2; 2097 goto error2;
2111 cm_id->state = IB_CM_MRA_REQ_SENT; 2098 cm_id->state = IB_CM_MRA_REQ_SENT;
@@ -2118,8 +2105,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2118 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, 2105 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2119 CM_MSG_RESPONSE_REP, service_timeout, 2106 CM_MSG_RESPONSE_REP, service_timeout,
2120 private_data, private_data_len); 2107 private_data, private_data_len);
2121 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2108 ret = ib_post_send_mad(msg, NULL);
2122 &msg->send_wr, &bad_send_wr);
2123 if (ret) 2109 if (ret)
2124 goto error2; 2110 goto error2;
2125 cm_id->state = IB_CM_MRA_REP_SENT; 2111 cm_id->state = IB_CM_MRA_REP_SENT;
@@ -2132,8 +2118,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
2132 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv, 2118 cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
2133 CM_MSG_RESPONSE_OTHER, service_timeout, 2119 CM_MSG_RESPONSE_OTHER, service_timeout,
2134 private_data, private_data_len); 2120 private_data, private_data_len);
2135 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2121 ret = ib_post_send_mad(msg, NULL);
2136 &msg->send_wr, &bad_send_wr);
2137 if (ret) 2122 if (ret)
2138 goto error2; 2123 goto error2;
2139 cm_id->lap_state = IB_CM_MRA_LAP_SENT; 2124 cm_id->lap_state = IB_CM_MRA_LAP_SENT;
@@ -2195,14 +2180,14 @@ static int cm_mra_handler(struct cm_work *work)
2195 case IB_CM_REQ_SENT: 2180 case IB_CM_REQ_SENT:
2196 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REQ || 2181 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REQ ||
2197 ib_modify_mad(cm_id_priv->av.port->mad_agent, 2182 ib_modify_mad(cm_id_priv->av.port->mad_agent,
2198 (unsigned long) cm_id_priv->msg, timeout)) 2183 cm_id_priv->msg, timeout))
2199 goto out; 2184 goto out;
2200 cm_id_priv->id.state = IB_CM_MRA_REQ_RCVD; 2185 cm_id_priv->id.state = IB_CM_MRA_REQ_RCVD;
2201 break; 2186 break;
2202 case IB_CM_REP_SENT: 2187 case IB_CM_REP_SENT:
2203 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REP || 2188 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REP ||
2204 ib_modify_mad(cm_id_priv->av.port->mad_agent, 2189 ib_modify_mad(cm_id_priv->av.port->mad_agent,
2205 (unsigned long) cm_id_priv->msg, timeout)) 2190 cm_id_priv->msg, timeout))
2206 goto out; 2191 goto out;
2207 cm_id_priv->id.state = IB_CM_MRA_REP_RCVD; 2192 cm_id_priv->id.state = IB_CM_MRA_REP_RCVD;
2208 break; 2193 break;
@@ -2210,7 +2195,7 @@ static int cm_mra_handler(struct cm_work *work)
2210 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_OTHER || 2195 if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_OTHER ||
2211 cm_id_priv->id.lap_state != IB_CM_LAP_SENT || 2196 cm_id_priv->id.lap_state != IB_CM_LAP_SENT ||
2212 ib_modify_mad(cm_id_priv->av.port->mad_agent, 2197 ib_modify_mad(cm_id_priv->av.port->mad_agent,
2213 (unsigned long) cm_id_priv->msg, timeout)) 2198 cm_id_priv->msg, timeout))
2214 goto out; 2199 goto out;
2215 cm_id_priv->id.lap_state = IB_CM_MRA_LAP_RCVD; 2200 cm_id_priv->id.lap_state = IB_CM_MRA_LAP_RCVD;
2216 break; 2201 break;
@@ -2273,7 +2258,6 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id,
2273{ 2258{
2274 struct cm_id_private *cm_id_priv; 2259 struct cm_id_private *cm_id_priv;
2275 struct ib_mad_send_buf *msg; 2260 struct ib_mad_send_buf *msg;
2276 struct ib_send_wr *bad_send_wr;
2277 unsigned long flags; 2261 unsigned long flags;
2278 int ret; 2262 int ret;
2279 2263
@@ -2294,11 +2278,10 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id,
2294 2278
2295 cm_format_lap((struct cm_lap_msg *) msg->mad, cm_id_priv, 2279 cm_format_lap((struct cm_lap_msg *) msg->mad, cm_id_priv,
2296 alternate_path, private_data, private_data_len); 2280 alternate_path, private_data, private_data_len);
2297 msg->send_wr.wr.ud.timeout_ms = cm_id_priv->timeout_ms; 2281 msg->timeout_ms = cm_id_priv->timeout_ms;
2298 msg->context[1] = (void *) (unsigned long) IB_CM_ESTABLISHED; 2282 msg->context[1] = (void *) (unsigned long) IB_CM_ESTABLISHED;
2299 2283
2300 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2284 ret = ib_post_send_mad(msg, NULL);
2301 &msg->send_wr, &bad_send_wr);
2302 if (ret) { 2285 if (ret) {
2303 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2286 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2304 cm_free_msg(msg); 2287 cm_free_msg(msg);
@@ -2342,7 +2325,6 @@ static int cm_lap_handler(struct cm_work *work)
2342 struct cm_lap_msg *lap_msg; 2325 struct cm_lap_msg *lap_msg;
2343 struct ib_cm_lap_event_param *param; 2326 struct ib_cm_lap_event_param *param;
2344 struct ib_mad_send_buf *msg = NULL; 2327 struct ib_mad_send_buf *msg = NULL;
2345 struct ib_send_wr *bad_send_wr;
2346 unsigned long flags; 2328 unsigned long flags;
2347 int ret; 2329 int ret;
2348 2330
@@ -2376,8 +2358,7 @@ static int cm_lap_handler(struct cm_work *work)
2376 cm_id_priv->private_data_len); 2358 cm_id_priv->private_data_len);
2377 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2359 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2378 2360
2379 if (ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2361 if (ib_post_send_mad(msg, NULL))
2380 &msg->send_wr, &bad_send_wr))
2381 cm_free_msg(msg); 2362 cm_free_msg(msg);
2382 goto deref; 2363 goto deref;
2383 default: 2364 default:
@@ -2433,7 +2414,6 @@ int ib_send_cm_apr(struct ib_cm_id *cm_id,
2433{ 2414{
2434 struct cm_id_private *cm_id_priv; 2415 struct cm_id_private *cm_id_priv;
2435 struct ib_mad_send_buf *msg; 2416 struct ib_mad_send_buf *msg;
2436 struct ib_send_wr *bad_send_wr;
2437 unsigned long flags; 2417 unsigned long flags;
2438 int ret; 2418 int ret;
2439 2419
@@ -2456,8 +2436,7 @@ int ib_send_cm_apr(struct ib_cm_id *cm_id,
2456 2436
2457 cm_format_apr((struct cm_apr_msg *) msg->mad, cm_id_priv, status, 2437 cm_format_apr((struct cm_apr_msg *) msg->mad, cm_id_priv, status,
2458 info, info_length, private_data, private_data_len); 2438 info, info_length, private_data, private_data_len);
2459 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2439 ret = ib_post_send_mad(msg, NULL);
2460 &msg->send_wr, &bad_send_wr);
2461 if (ret) { 2440 if (ret) {
2462 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2441 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2463 cm_free_msg(msg); 2442 cm_free_msg(msg);
@@ -2496,8 +2475,7 @@ static int cm_apr_handler(struct cm_work *work)
2496 goto out; 2475 goto out;
2497 } 2476 }
2498 cm_id_priv->id.lap_state = IB_CM_LAP_IDLE; 2477 cm_id_priv->id.lap_state = IB_CM_LAP_IDLE;
2499 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 2478 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
2500 (unsigned long) cm_id_priv->msg);
2501 cm_id_priv->msg = NULL; 2479 cm_id_priv->msg = NULL;
2502 2480
2503 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2481 ret = atomic_inc_and_test(&cm_id_priv->work_count);
@@ -2572,7 +2550,6 @@ int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
2572{ 2550{
2573 struct cm_id_private *cm_id_priv; 2551 struct cm_id_private *cm_id_priv;
2574 struct ib_mad_send_buf *msg; 2552 struct ib_mad_send_buf *msg;
2575 struct ib_send_wr *bad_send_wr;
2576 unsigned long flags; 2553 unsigned long flags;
2577 int ret; 2554 int ret;
2578 2555
@@ -2595,13 +2572,12 @@ int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
2595 2572
2596 cm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv, 2573 cm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv,
2597 param); 2574 param);
2598 msg->send_wr.wr.ud.timeout_ms = cm_id_priv->timeout_ms; 2575 msg->timeout_ms = cm_id_priv->timeout_ms;
2599 msg->context[1] = (void *) (unsigned long) IB_CM_SIDR_REQ_SENT; 2576 msg->context[1] = (void *) (unsigned long) IB_CM_SIDR_REQ_SENT;
2600 2577
2601 spin_lock_irqsave(&cm_id_priv->lock, flags); 2578 spin_lock_irqsave(&cm_id_priv->lock, flags);
2602 if (cm_id->state == IB_CM_IDLE) 2579 if (cm_id->state == IB_CM_IDLE)
2603 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2580 ret = ib_post_send_mad(msg, NULL);
2604 &msg->send_wr, &bad_send_wr);
2605 else 2581 else
2606 ret = -EINVAL; 2582 ret = -EINVAL;
2607 2583
@@ -2629,7 +2605,6 @@ static void cm_format_sidr_req_event(struct cm_work *work,
2629 param = &work->cm_event.param.sidr_req_rcvd; 2605 param = &work->cm_event.param.sidr_req_rcvd;
2630 param->pkey = __be16_to_cpu(sidr_req_msg->pkey); 2606 param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
2631 param->listen_id = listen_id; 2607 param->listen_id = listen_id;
2632 param->device = work->port->mad_agent->device;
2633 param->port = work->port->port_num; 2608 param->port = work->port->port_num;
2634 work->cm_event.private_data = &sidr_req_msg->private_data; 2609 work->cm_event.private_data = &sidr_req_msg->private_data;
2635} 2610}
@@ -2642,7 +2617,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
2642 struct ib_wc *wc; 2617 struct ib_wc *wc;
2643 unsigned long flags; 2618 unsigned long flags;
2644 2619
2645 cm_id = ib_create_cm_id(NULL, NULL); 2620 cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
2646 if (IS_ERR(cm_id)) 2621 if (IS_ERR(cm_id))
2647 return PTR_ERR(cm_id); 2622 return PTR_ERR(cm_id);
2648 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 2623 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
@@ -2666,7 +2641,8 @@ static int cm_sidr_req_handler(struct cm_work *work)
2666 spin_unlock_irqrestore(&cm.lock, flags); 2641 spin_unlock_irqrestore(&cm.lock, flags);
2667 goto out; /* Duplicate message. */ 2642 goto out; /* Duplicate message. */
2668 } 2643 }
2669 cur_cm_id_priv = cm_find_listen(sidr_req_msg->service_id); 2644 cur_cm_id_priv = cm_find_listen(cm_id->device,
2645 sidr_req_msg->service_id);
2670 if (!cur_cm_id_priv) { 2646 if (!cur_cm_id_priv) {
2671 rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table); 2647 rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
2672 spin_unlock_irqrestore(&cm.lock, flags); 2648 spin_unlock_irqrestore(&cm.lock, flags);
@@ -2715,7 +2691,6 @@ int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
2715{ 2691{
2716 struct cm_id_private *cm_id_priv; 2692 struct cm_id_private *cm_id_priv;
2717 struct ib_mad_send_buf *msg; 2693 struct ib_mad_send_buf *msg;
2718 struct ib_send_wr *bad_send_wr;
2719 unsigned long flags; 2694 unsigned long flags;
2720 int ret; 2695 int ret;
2721 2696
@@ -2737,8 +2712,7 @@ int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
2737 2712
2738 cm_format_sidr_rep((struct cm_sidr_rep_msg *) msg->mad, cm_id_priv, 2713 cm_format_sidr_rep((struct cm_sidr_rep_msg *) msg->mad, cm_id_priv,
2739 param); 2714 param);
2740 ret = ib_post_send_mad(cm_id_priv->av.port->mad_agent, 2715 ret = ib_post_send_mad(msg, NULL);
2741 &msg->send_wr, &bad_send_wr);
2742 if (ret) { 2716 if (ret) {
2743 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2717 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2744 cm_free_msg(msg); 2718 cm_free_msg(msg);
@@ -2791,8 +2765,7 @@ static int cm_sidr_rep_handler(struct cm_work *work)
2791 goto out; 2765 goto out;
2792 } 2766 }
2793 cm_id_priv->id.state = IB_CM_IDLE; 2767 cm_id_priv->id.state = IB_CM_IDLE;
2794 ib_cancel_mad(cm_id_priv->av.port->mad_agent, 2768 ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
2795 (unsigned long) cm_id_priv->msg);
2796 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 2769 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2797 2770
2798 cm_format_sidr_rep_event(work); 2771 cm_format_sidr_rep_event(work);
@@ -2860,9 +2833,7 @@ discard:
2860static void cm_send_handler(struct ib_mad_agent *mad_agent, 2833static void cm_send_handler(struct ib_mad_agent *mad_agent,
2861 struct ib_mad_send_wc *mad_send_wc) 2834 struct ib_mad_send_wc *mad_send_wc)
2862{ 2835{
2863 struct ib_mad_send_buf *msg; 2836 struct ib_mad_send_buf *msg = mad_send_wc->send_buf;
2864
2865 msg = (struct ib_mad_send_buf *)(unsigned long)mad_send_wc->wr_id;
2866 2837
2867 switch (mad_send_wc->status) { 2838 switch (mad_send_wc->status) {
2868 case IB_WC_SUCCESS: 2839 case IB_WC_SUCCESS:
@@ -3064,10 +3035,10 @@ static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
3064 case IB_CM_ESTABLISHED: 3035 case IB_CM_ESTABLISHED:
3065 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS | 3036 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS |
3066 IB_QP_PKEY_INDEX | IB_QP_PORT; 3037 IB_QP_PKEY_INDEX | IB_QP_PORT;
3067 qp_attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE; 3038 qp_attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE |
3039 IB_ACCESS_REMOTE_WRITE;
3068 if (cm_id_priv->responder_resources) 3040 if (cm_id_priv->responder_resources)
3069 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_WRITE | 3041 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ;
3070 IB_ACCESS_REMOTE_READ;
3071 qp_attr->pkey_index = cm_id_priv->av.pkey_index; 3042 qp_attr->pkey_index = cm_id_priv->av.pkey_index;
3072 qp_attr->port_num = cm_id_priv->av.port->port_num; 3043 qp_attr->port_num = cm_id_priv->av.port->port_num;
3073 ret = 0; 3044 ret = 0;
@@ -3097,14 +3068,18 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
3097 case IB_CM_MRA_REP_RCVD: 3068 case IB_CM_MRA_REP_RCVD:
3098 case IB_CM_ESTABLISHED: 3069 case IB_CM_ESTABLISHED:
3099 *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU | 3070 *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
3100 IB_QP_DEST_QPN | IB_QP_RQ_PSN | 3071 IB_QP_DEST_QPN | IB_QP_RQ_PSN;
3101 IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER;
3102 qp_attr->ah_attr = cm_id_priv->av.ah_attr; 3072 qp_attr->ah_attr = cm_id_priv->av.ah_attr;
3103 qp_attr->path_mtu = cm_id_priv->path_mtu; 3073 qp_attr->path_mtu = cm_id_priv->path_mtu;
3104 qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn); 3074 qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn);
3105 qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn); 3075 qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn);
3106 qp_attr->max_dest_rd_atomic = cm_id_priv->responder_resources; 3076 if (cm_id_priv->qp_type == IB_QPT_RC) {
3107 qp_attr->min_rnr_timer = 0; 3077 *qp_attr_mask |= IB_QP_MAX_DEST_RD_ATOMIC |
3078 IB_QP_MIN_RNR_TIMER;
3079 qp_attr->max_dest_rd_atomic =
3080 cm_id_priv->responder_resources;
3081 qp_attr->min_rnr_timer = 0;
3082 }
3108 if (cm_id_priv->alt_av.ah_attr.dlid) { 3083 if (cm_id_priv->alt_av.ah_attr.dlid) {
3109 *qp_attr_mask |= IB_QP_ALT_PATH; 3084 *qp_attr_mask |= IB_QP_ALT_PATH;
3110 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; 3085 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
@@ -3133,14 +3108,17 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
3133 case IB_CM_REP_SENT: 3108 case IB_CM_REP_SENT:
3134 case IB_CM_MRA_REP_RCVD: 3109 case IB_CM_MRA_REP_RCVD:
3135 case IB_CM_ESTABLISHED: 3110 case IB_CM_ESTABLISHED:
3136 *qp_attr_mask = IB_QP_STATE | IB_QP_TIMEOUT | IB_QP_RETRY_CNT | 3111 *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN;
3137 IB_QP_RNR_RETRY | IB_QP_SQ_PSN |
3138 IB_QP_MAX_QP_RD_ATOMIC;
3139 qp_attr->timeout = cm_id_priv->local_ack_timeout;
3140 qp_attr->retry_cnt = cm_id_priv->retry_count;
3141 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
3142 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn); 3112 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn);
3143 qp_attr->max_rd_atomic = cm_id_priv->initiator_depth; 3113 if (cm_id_priv->qp_type == IB_QPT_RC) {
3114 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT |
3115 IB_QP_RNR_RETRY |
3116 IB_QP_MAX_QP_RD_ATOMIC;
3117 qp_attr->timeout = cm_id_priv->local_ack_timeout;
3118 qp_attr->retry_cnt = cm_id_priv->retry_count;
3119 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
3120 qp_attr->max_rd_atomic = cm_id_priv->initiator_depth;
3121 }
3144 if (cm_id_priv->alt_av.ah_attr.dlid) { 3122 if (cm_id_priv->alt_av.ah_attr.dlid) {
3145 *qp_attr_mask |= IB_QP_PATH_MIG_STATE; 3123 *qp_attr_mask |= IB_QP_PATH_MIG_STATE;
3146 qp_attr->path_mig_state = IB_MIG_REARM; 3124 qp_attr->path_mig_state = IB_MIG_REARM;
@@ -3323,6 +3301,7 @@ static void __exit ib_cm_cleanup(void)
3323 flush_workqueue(cm.wq); 3301 flush_workqueue(cm.wq);
3324 destroy_workqueue(cm.wq); 3302 destroy_workqueue(cm.wq);
3325 ib_unregister_client(&cm_client); 3303 ib_unregister_client(&cm_client);
3304 idr_destroy(&cm.local_id_table);
3326} 3305}
3327 3306
3328module_init(ib_cm_init); 3307module_init(ib_cm_init);
diff --git a/drivers/infiniband/core/cm_msgs.h b/drivers/infiniband/core/cm_msgs.h
index 813ab70bf6d5..4d3aee90c249 100644
--- a/drivers/infiniband/core/cm_msgs.h
+++ b/drivers/infiniband/core/cm_msgs.h
@@ -186,6 +186,7 @@ static inline void cm_req_set_qp_type(struct cm_req_msg *req_msg,
186 req_msg->offset40 = cpu_to_be32((be32_to_cpu( 186 req_msg->offset40 = cpu_to_be32((be32_to_cpu(
187 req_msg->offset40) & 187 req_msg->offset40) &
188 0xFFFFFFF9) | 0x2); 188 0xFFFFFFF9) | 0x2);
189 break;
189 default: 190 default:
190 req_msg->offset40 = cpu_to_be32(be32_to_cpu( 191 req_msg->offset40 = cpu_to_be32(be32_to_cpu(
191 req_msg->offset40) & 192 req_msg->offset40) &
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index d3cf84e01587..5a6e44976405 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -514,6 +514,12 @@ int ib_query_port(struct ib_device *device,
514 u8 port_num, 514 u8 port_num,
515 struct ib_port_attr *port_attr) 515 struct ib_port_attr *port_attr)
516{ 516{
517 if (device->node_type == IB_NODE_SWITCH) {
518 if (port_num)
519 return -EINVAL;
520 } else if (port_num < 1 || port_num > device->phys_port_cnt)
521 return -EINVAL;
522
517 return device->query_port(device, port_num, port_attr); 523 return device->query_port(device, port_num, port_attr);
518} 524}
519EXPORT_SYMBOL(ib_query_port); 525EXPORT_SYMBOL(ib_query_port);
@@ -583,6 +589,12 @@ int ib_modify_port(struct ib_device *device,
583 u8 port_num, int port_modify_mask, 589 u8 port_num, int port_modify_mask,
584 struct ib_port_modify *port_modify) 590 struct ib_port_modify *port_modify)
585{ 591{
592 if (device->node_type == IB_NODE_SWITCH) {
593 if (port_num)
594 return -EINVAL;
595 } else if (port_num < 1 || port_num > device->phys_port_cnt)
596 return -EINVAL;
597
586 return device->modify_port(device, port_num, port_modify_mask, 598 return device->modify_port(device, port_num, port_modify_mask,
587 port_modify); 599 port_modify);
588} 600}
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index a14ca87fda18..88f9f8c9eacc 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -579,7 +579,7 @@ static void dequeue_mad(struct ib_mad_list_head *mad_list)
579} 579}
580 580
581static void snoop_send(struct ib_mad_qp_info *qp_info, 581static void snoop_send(struct ib_mad_qp_info *qp_info,
582 struct ib_send_wr *send_wr, 582 struct ib_mad_send_buf *send_buf,
583 struct ib_mad_send_wc *mad_send_wc, 583 struct ib_mad_send_wc *mad_send_wc,
584 int mad_snoop_flags) 584 int mad_snoop_flags)
585{ 585{
@@ -597,7 +597,7 @@ static void snoop_send(struct ib_mad_qp_info *qp_info,
597 atomic_inc(&mad_snoop_priv->refcount); 597 atomic_inc(&mad_snoop_priv->refcount);
598 spin_unlock_irqrestore(&qp_info->snoop_lock, flags); 598 spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
599 mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent, 599 mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent,
600 send_wr, mad_send_wc); 600 send_buf, mad_send_wc);
601 if (atomic_dec_and_test(&mad_snoop_priv->refcount)) 601 if (atomic_dec_and_test(&mad_snoop_priv->refcount))
602 wake_up(&mad_snoop_priv->wait); 602 wake_up(&mad_snoop_priv->wait);
603 spin_lock_irqsave(&qp_info->snoop_lock, flags); 603 spin_lock_irqsave(&qp_info->snoop_lock, flags);
@@ -654,10 +654,10 @@ static void build_smp_wc(u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
654 * Return < 0 if error 654 * Return < 0 if error
655 */ 655 */
656static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv, 656static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
657 struct ib_smp *smp, 657 struct ib_mad_send_wr_private *mad_send_wr)
658 struct ib_send_wr *send_wr)
659{ 658{
660 int ret; 659 int ret;
660 struct ib_smp *smp = mad_send_wr->send_buf.mad;
661 unsigned long flags; 661 unsigned long flags;
662 struct ib_mad_local_private *local; 662 struct ib_mad_local_private *local;
663 struct ib_mad_private *mad_priv; 663 struct ib_mad_private *mad_priv;
@@ -666,6 +666,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
666 struct ib_device *device = mad_agent_priv->agent.device; 666 struct ib_device *device = mad_agent_priv->agent.device;
667 u8 port_num = mad_agent_priv->agent.port_num; 667 u8 port_num = mad_agent_priv->agent.port_num;
668 struct ib_wc mad_wc; 668 struct ib_wc mad_wc;
669 struct ib_send_wr *send_wr = &mad_send_wr->send_wr;
669 670
670 if (!smi_handle_dr_smp_send(smp, device->node_type, port_num)) { 671 if (!smi_handle_dr_smp_send(smp, device->node_type, port_num)) {
671 ret = -EINVAL; 672 ret = -EINVAL;
@@ -745,13 +746,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
745 goto out; 746 goto out;
746 } 747 }
747 748
748 local->send_wr = *send_wr; 749 local->mad_send_wr = mad_send_wr;
749 local->send_wr.sg_list = local->sg_list;
750 memcpy(local->sg_list, send_wr->sg_list,
751 sizeof *send_wr->sg_list * send_wr->num_sge);
752 local->send_wr.next = NULL;
753 local->tid = send_wr->wr.ud.mad_hdr->tid;
754 local->wr_id = send_wr->wr_id;
755 /* Reference MAD agent until send side of local completion handled */ 750 /* Reference MAD agent until send side of local completion handled */
756 atomic_inc(&mad_agent_priv->refcount); 751 atomic_inc(&mad_agent_priv->refcount);
757 /* Queue local completion to local list */ 752 /* Queue local completion to local list */
@@ -781,17 +776,17 @@ static int get_buf_length(int hdr_len, int data_len)
781 776
782struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, 777struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
783 u32 remote_qpn, u16 pkey_index, 778 u32 remote_qpn, u16 pkey_index,
784 struct ib_ah *ah, int rmpp_active, 779 int rmpp_active,
785 int hdr_len, int data_len, 780 int hdr_len, int data_len,
786 gfp_t gfp_mask) 781 gfp_t gfp_mask)
787{ 782{
788 struct ib_mad_agent_private *mad_agent_priv; 783 struct ib_mad_agent_private *mad_agent_priv;
789 struct ib_mad_send_buf *send_buf; 784 struct ib_mad_send_wr_private *mad_send_wr;
790 int buf_size; 785 int buf_size;
791 void *buf; 786 void *buf;
792 787
793 mad_agent_priv = container_of(mad_agent, 788 mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
794 struct ib_mad_agent_private, agent); 789 agent);
795 buf_size = get_buf_length(hdr_len, data_len); 790 buf_size = get_buf_length(hdr_len, data_len);
796 791
797 if ((!mad_agent->rmpp_version && 792 if ((!mad_agent->rmpp_version &&
@@ -799,45 +794,40 @@ struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
799 (!rmpp_active && buf_size > sizeof(struct ib_mad))) 794 (!rmpp_active && buf_size > sizeof(struct ib_mad)))
800 return ERR_PTR(-EINVAL); 795 return ERR_PTR(-EINVAL);
801 796
802 buf = kmalloc(sizeof *send_buf + buf_size, gfp_mask); 797 buf = kmalloc(sizeof *mad_send_wr + buf_size, gfp_mask);
803 if (!buf) 798 if (!buf)
804 return ERR_PTR(-ENOMEM); 799 return ERR_PTR(-ENOMEM);
805 memset(buf, 0, sizeof *send_buf + buf_size); 800 memset(buf, 0, sizeof *mad_send_wr + buf_size);
806 801
807 send_buf = buf + buf_size; 802 mad_send_wr = buf + buf_size;
808 send_buf->mad = buf; 803 mad_send_wr->send_buf.mad = buf;
809 804
810 send_buf->sge.addr = dma_map_single(mad_agent->device->dma_device, 805 mad_send_wr->mad_agent_priv = mad_agent_priv;
811 buf, buf_size, DMA_TO_DEVICE); 806 mad_send_wr->sg_list[0].length = buf_size;
812 pci_unmap_addr_set(send_buf, mapping, send_buf->sge.addr); 807 mad_send_wr->sg_list[0].lkey = mad_agent->mr->lkey;
813 send_buf->sge.length = buf_size; 808
814 send_buf->sge.lkey = mad_agent->mr->lkey; 809 mad_send_wr->send_wr.wr_id = (unsigned long) mad_send_wr;
815 810 mad_send_wr->send_wr.sg_list = mad_send_wr->sg_list;
816 send_buf->send_wr.wr_id = (unsigned long) send_buf; 811 mad_send_wr->send_wr.num_sge = 1;
817 send_buf->send_wr.sg_list = &send_buf->sge; 812 mad_send_wr->send_wr.opcode = IB_WR_SEND;
818 send_buf->send_wr.num_sge = 1; 813 mad_send_wr->send_wr.send_flags = IB_SEND_SIGNALED;
819 send_buf->send_wr.opcode = IB_WR_SEND; 814 mad_send_wr->send_wr.wr.ud.remote_qpn = remote_qpn;
820 send_buf->send_wr.send_flags = IB_SEND_SIGNALED; 815 mad_send_wr->send_wr.wr.ud.remote_qkey = IB_QP_SET_QKEY;
821 send_buf->send_wr.wr.ud.ah = ah; 816 mad_send_wr->send_wr.wr.ud.pkey_index = pkey_index;
822 send_buf->send_wr.wr.ud.mad_hdr = &send_buf->mad->mad_hdr;
823 send_buf->send_wr.wr.ud.remote_qpn = remote_qpn;
824 send_buf->send_wr.wr.ud.remote_qkey = IB_QP_SET_QKEY;
825 send_buf->send_wr.wr.ud.pkey_index = pkey_index;
826 817
827 if (rmpp_active) { 818 if (rmpp_active) {
828 struct ib_rmpp_mad *rmpp_mad; 819 struct ib_rmpp_mad *rmpp_mad = mad_send_wr->send_buf.mad;
829 rmpp_mad = (struct ib_rmpp_mad *)send_buf->mad;
830 rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(hdr_len - 820 rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(hdr_len -
831 offsetof(struct ib_rmpp_mad, data) + data_len); 821 IB_MGMT_RMPP_HDR + data_len);
832 rmpp_mad->rmpp_hdr.rmpp_version = mad_agent->rmpp_version; 822 rmpp_mad->rmpp_hdr.rmpp_version = mad_agent->rmpp_version;
833 rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA; 823 rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA;
834 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, 824 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr,
835 IB_MGMT_RMPP_FLAG_ACTIVE); 825 IB_MGMT_RMPP_FLAG_ACTIVE);
836 } 826 }
837 827
838 send_buf->mad_agent = mad_agent; 828 mad_send_wr->send_buf.mad_agent = mad_agent;
839 atomic_inc(&mad_agent_priv->refcount); 829 atomic_inc(&mad_agent_priv->refcount);
840 return send_buf; 830 return &mad_send_wr->send_buf;
841} 831}
842EXPORT_SYMBOL(ib_create_send_mad); 832EXPORT_SYMBOL(ib_create_send_mad);
843 833
@@ -847,10 +837,6 @@ void ib_free_send_mad(struct ib_mad_send_buf *send_buf)
847 837
848 mad_agent_priv = container_of(send_buf->mad_agent, 838 mad_agent_priv = container_of(send_buf->mad_agent,
849 struct ib_mad_agent_private, agent); 839 struct ib_mad_agent_private, agent);
850
851 dma_unmap_single(send_buf->mad_agent->device->dma_device,
852 pci_unmap_addr(send_buf, mapping),
853 send_buf->sge.length, DMA_TO_DEVICE);
854 kfree(send_buf->mad); 840 kfree(send_buf->mad);
855 841
856 if (atomic_dec_and_test(&mad_agent_priv->refcount)) 842 if (atomic_dec_and_test(&mad_agent_priv->refcount))
@@ -861,8 +847,10 @@ EXPORT_SYMBOL(ib_free_send_mad);
861int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr) 847int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
862{ 848{
863 struct ib_mad_qp_info *qp_info; 849 struct ib_mad_qp_info *qp_info;
864 struct ib_send_wr *bad_send_wr;
865 struct list_head *list; 850 struct list_head *list;
851 struct ib_send_wr *bad_send_wr;
852 struct ib_mad_agent *mad_agent;
853 struct ib_sge *sge;
866 unsigned long flags; 854 unsigned long flags;
867 int ret; 855 int ret;
868 856
@@ -871,10 +859,17 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
871 mad_send_wr->send_wr.wr_id = (unsigned long)&mad_send_wr->mad_list; 859 mad_send_wr->send_wr.wr_id = (unsigned long)&mad_send_wr->mad_list;
872 mad_send_wr->mad_list.mad_queue = &qp_info->send_queue; 860 mad_send_wr->mad_list.mad_queue = &qp_info->send_queue;
873 861
862 mad_agent = mad_send_wr->send_buf.mad_agent;
863 sge = mad_send_wr->sg_list;
864 sge->addr = dma_map_single(mad_agent->device->dma_device,
865 mad_send_wr->send_buf.mad, sge->length,
866 DMA_TO_DEVICE);
867 pci_unmap_addr_set(mad_send_wr, mapping, sge->addr);
868
874 spin_lock_irqsave(&qp_info->send_queue.lock, flags); 869 spin_lock_irqsave(&qp_info->send_queue.lock, flags);
875 if (qp_info->send_queue.count < qp_info->send_queue.max_active) { 870 if (qp_info->send_queue.count < qp_info->send_queue.max_active) {
876 ret = ib_post_send(mad_send_wr->mad_agent_priv->agent.qp, 871 ret = ib_post_send(mad_agent->qp, &mad_send_wr->send_wr,
877 &mad_send_wr->send_wr, &bad_send_wr); 872 &bad_send_wr);
878 list = &qp_info->send_queue.list; 873 list = &qp_info->send_queue.list;
879 } else { 874 } else {
880 ret = 0; 875 ret = 0;
@@ -886,6 +881,11 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
886 list_add_tail(&mad_send_wr->mad_list.list, list); 881 list_add_tail(&mad_send_wr->mad_list.list, list);
887 } 882 }
888 spin_unlock_irqrestore(&qp_info->send_queue.lock, flags); 883 spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
884 if (ret)
885 dma_unmap_single(mad_agent->device->dma_device,
886 pci_unmap_addr(mad_send_wr, mapping),
887 sge->length, DMA_TO_DEVICE);
888
889 return ret; 889 return ret;
890} 890}
891 891
@@ -893,45 +893,28 @@ int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
893 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated 893 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
894 * with the registered client 894 * with the registered client
895 */ 895 */
896int ib_post_send_mad(struct ib_mad_agent *mad_agent, 896int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
897 struct ib_send_wr *send_wr, 897 struct ib_mad_send_buf **bad_send_buf)
898 struct ib_send_wr **bad_send_wr)
899{ 898{
900 int ret = -EINVAL;
901 struct ib_mad_agent_private *mad_agent_priv; 899 struct ib_mad_agent_private *mad_agent_priv;
902 900 struct ib_mad_send_buf *next_send_buf;
903 /* Validate supplied parameters */ 901 struct ib_mad_send_wr_private *mad_send_wr;
904 if (!bad_send_wr) 902 unsigned long flags;
905 goto error1; 903 int ret = -EINVAL;
906
907 if (!mad_agent || !send_wr)
908 goto error2;
909
910 if (!mad_agent->send_handler)
911 goto error2;
912
913 mad_agent_priv = container_of(mad_agent,
914 struct ib_mad_agent_private,
915 agent);
916 904
917 /* Walk list of send WRs and post each on send list */ 905 /* Walk list of send WRs and post each on send list */
918 while (send_wr) { 906 for (; send_buf; send_buf = next_send_buf) {
919 unsigned long flags;
920 struct ib_send_wr *next_send_wr;
921 struct ib_mad_send_wr_private *mad_send_wr;
922 struct ib_smp *smp;
923
924 /* Validate more parameters */
925 if (send_wr->num_sge > IB_MAD_SEND_REQ_MAX_SG)
926 goto error2;
927 907
928 if (send_wr->wr.ud.timeout_ms && !mad_agent->recv_handler) 908 mad_send_wr = container_of(send_buf,
929 goto error2; 909 struct ib_mad_send_wr_private,
930 910 send_buf);
931 if (!send_wr->wr.ud.mad_hdr) { 911 mad_agent_priv = mad_send_wr->mad_agent_priv;
932 printk(KERN_ERR PFX "MAD header must be supplied " 912
933 "in WR %p\n", send_wr); 913 if (!send_buf->mad_agent->send_handler ||
934 goto error2; 914 (send_buf->timeout_ms &&
915 !send_buf->mad_agent->recv_handler)) {
916 ret = -EINVAL;
917 goto error;
935 } 918 }
936 919
937 /* 920 /*
@@ -939,40 +922,24 @@ int ib_post_send_mad(struct ib_mad_agent *mad_agent,
939 * current one completes, and the user modifies the work 922 * current one completes, and the user modifies the work
940 * request associated with the completion 923 * request associated with the completion
941 */ 924 */
942 next_send_wr = (struct ib_send_wr *)send_wr->next; 925 next_send_buf = send_buf->next;
926 mad_send_wr->send_wr.wr.ud.ah = send_buf->ah;
943 927
944 smp = (struct ib_smp *)send_wr->wr.ud.mad_hdr; 928 if (((struct ib_mad_hdr *) send_buf->mad)->mgmt_class ==
945 if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { 929 IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
946 ret = handle_outgoing_dr_smp(mad_agent_priv, smp, 930 ret = handle_outgoing_dr_smp(mad_agent_priv,
947 send_wr); 931 mad_send_wr);
948 if (ret < 0) /* error */ 932 if (ret < 0) /* error */
949 goto error2; 933 goto error;
950 else if (ret == 1) /* locally consumed */ 934 else if (ret == 1) /* locally consumed */
951 goto next; 935 continue;
952 } 936 }
953 937
954 /* Allocate MAD send WR tracking structure */ 938 mad_send_wr->tid = ((struct ib_mad_hdr *) send_buf->mad)->tid;
955 mad_send_wr = kmalloc(sizeof *mad_send_wr, GFP_ATOMIC);
956 if (!mad_send_wr) {
957 printk(KERN_ERR PFX "No memory for "
958 "ib_mad_send_wr_private\n");
959 ret = -ENOMEM;
960 goto error2;
961 }
962 memset(mad_send_wr, 0, sizeof *mad_send_wr);
963
964 mad_send_wr->send_wr = *send_wr;
965 mad_send_wr->send_wr.sg_list = mad_send_wr->sg_list;
966 memcpy(mad_send_wr->sg_list, send_wr->sg_list,
967 sizeof *send_wr->sg_list * send_wr->num_sge);
968 mad_send_wr->wr_id = send_wr->wr_id;
969 mad_send_wr->tid = send_wr->wr.ud.mad_hdr->tid;
970 mad_send_wr->mad_agent_priv = mad_agent_priv;
971 /* Timeout will be updated after send completes */ 939 /* Timeout will be updated after send completes */
972 mad_send_wr->timeout = msecs_to_jiffies(send_wr->wr. 940 mad_send_wr->timeout = msecs_to_jiffies(send_buf->timeout_ms);
973 ud.timeout_ms); 941 mad_send_wr->retries = send_buf->retries;
974 mad_send_wr->retries = mad_send_wr->send_wr.wr.ud.retries; 942 /* Reference for work request to QP + response */
975 /* One reference for each work request to QP + response */
976 mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0); 943 mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
977 mad_send_wr->status = IB_WC_SUCCESS; 944 mad_send_wr->status = IB_WC_SUCCESS;
978 945
@@ -995,16 +962,13 @@ int ib_post_send_mad(struct ib_mad_agent *mad_agent,
995 list_del(&mad_send_wr->agent_list); 962 list_del(&mad_send_wr->agent_list);
996 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 963 spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
997 atomic_dec(&mad_agent_priv->refcount); 964 atomic_dec(&mad_agent_priv->refcount);
998 goto error2; 965 goto error;
999 } 966 }
1000next:
1001 send_wr = next_send_wr;
1002 } 967 }
1003 return 0; 968 return 0;
1004 969error:
1005error2: 970 if (bad_send_buf)
1006 *bad_send_wr = send_wr; 971 *bad_send_buf = send_buf;
1007error1:
1008 return ret; 972 return ret;
1009} 973}
1010EXPORT_SYMBOL(ib_post_send_mad); 974EXPORT_SYMBOL(ib_post_send_mad);
@@ -1447,8 +1411,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
1447 * of MAD. 1411 * of MAD.
1448 */ 1412 */
1449 hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32; 1413 hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32;
1450 list_for_each_entry(entry, &port_priv->agent_list, 1414 list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
1451 agent_list) {
1452 if (entry->agent.hi_tid == hi_tid) { 1415 if (entry->agent.hi_tid == hi_tid) {
1453 mad_agent = entry; 1416 mad_agent = entry;
1454 break; 1417 break;
@@ -1571,8 +1534,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, __be64 tid)
1571 */ 1534 */
1572 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list, 1535 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
1573 agent_list) { 1536 agent_list) {
1574 if (is_data_mad(mad_agent_priv, 1537 if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) &&
1575 mad_send_wr->send_wr.wr.ud.mad_hdr) &&
1576 mad_send_wr->tid == tid && mad_send_wr->timeout) { 1538 mad_send_wr->tid == tid && mad_send_wr->timeout) {
1577 /* Verify request has not been canceled */ 1539 /* Verify request has not been canceled */
1578 return (mad_send_wr->status == IB_WC_SUCCESS) ? 1540 return (mad_send_wr->status == IB_WC_SUCCESS) ?
@@ -1628,14 +1590,14 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
1628 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1590 spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
1629 1591
1630 /* Defined behavior is to complete response before request */ 1592 /* Defined behavior is to complete response before request */
1631 mad_recv_wc->wc->wr_id = mad_send_wr->wr_id; 1593 mad_recv_wc->wc->wr_id = (unsigned long) &mad_send_wr->send_buf;
1632 mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1594 mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
1633 mad_recv_wc); 1595 mad_recv_wc);
1634 atomic_dec(&mad_agent_priv->refcount); 1596 atomic_dec(&mad_agent_priv->refcount);
1635 1597
1636 mad_send_wc.status = IB_WC_SUCCESS; 1598 mad_send_wc.status = IB_WC_SUCCESS;
1637 mad_send_wc.vendor_err = 0; 1599 mad_send_wc.vendor_err = 0;
1638 mad_send_wc.wr_id = mad_send_wr->wr_id; 1600 mad_send_wc.send_buf = &mad_send_wr->send_buf;
1639 ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc); 1601 ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
1640 } else { 1602 } else {
1641 mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, 1603 mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
@@ -1728,11 +1690,11 @@ local:
1728 if (ret & IB_MAD_RESULT_CONSUMED) 1690 if (ret & IB_MAD_RESULT_CONSUMED)
1729 goto out; 1691 goto out;
1730 if (ret & IB_MAD_RESULT_REPLY) { 1692 if (ret & IB_MAD_RESULT_REPLY) {
1731 /* Send response */ 1693 agent_send_response(&response->mad.mad,
1732 if (!agent_send(response, &recv->grh, wc, 1694 &recv->grh, wc,
1733 port_priv->device, 1695 port_priv->device,
1734 port_priv->port_num)) 1696 port_priv->port_num,
1735 response = NULL; 1697 qp_info->qp->qp_num);
1736 goto out; 1698 goto out;
1737 } 1699 }
1738 } 1700 }
@@ -1866,15 +1828,15 @@ void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
1866 1828
1867 if (mad_send_wr->status != IB_WC_SUCCESS ) 1829 if (mad_send_wr->status != IB_WC_SUCCESS )
1868 mad_send_wc->status = mad_send_wr->status; 1830 mad_send_wc->status = mad_send_wr->status;
1869 if (ret != IB_RMPP_RESULT_INTERNAL) 1831 if (ret == IB_RMPP_RESULT_INTERNAL)
1832 ib_rmpp_send_handler(mad_send_wc);
1833 else
1870 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, 1834 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
1871 mad_send_wc); 1835 mad_send_wc);
1872 1836
1873 /* Release reference on agent taken when sending */ 1837 /* Release reference on agent taken when sending */
1874 if (atomic_dec_and_test(&mad_agent_priv->refcount)) 1838 if (atomic_dec_and_test(&mad_agent_priv->refcount))
1875 wake_up(&mad_agent_priv->wait); 1839 wake_up(&mad_agent_priv->wait);
1876
1877 kfree(mad_send_wr);
1878 return; 1840 return;
1879done: 1841done:
1880 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 1842 spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
@@ -1888,6 +1850,7 @@ static void ib_mad_send_done_handler(struct ib_mad_port_private *port_priv,
1888 struct ib_mad_qp_info *qp_info; 1850 struct ib_mad_qp_info *qp_info;
1889 struct ib_mad_queue *send_queue; 1851 struct ib_mad_queue *send_queue;
1890 struct ib_send_wr *bad_send_wr; 1852 struct ib_send_wr *bad_send_wr;
1853 struct ib_mad_send_wc mad_send_wc;
1891 unsigned long flags; 1854 unsigned long flags;
1892 int ret; 1855 int ret;
1893 1856
@@ -1898,6 +1861,9 @@ static void ib_mad_send_done_handler(struct ib_mad_port_private *port_priv,
1898 qp_info = send_queue->qp_info; 1861 qp_info = send_queue->qp_info;
1899 1862
1900retry: 1863retry:
1864 dma_unmap_single(mad_send_wr->send_buf.mad_agent->device->dma_device,
1865 pci_unmap_addr(mad_send_wr, mapping),
1866 mad_send_wr->sg_list[0].length, DMA_TO_DEVICE);
1901 queued_send_wr = NULL; 1867 queued_send_wr = NULL;
1902 spin_lock_irqsave(&send_queue->lock, flags); 1868 spin_lock_irqsave(&send_queue->lock, flags);
1903 list_del(&mad_list->list); 1869 list_del(&mad_list->list);
@@ -1914,17 +1880,17 @@ retry:
1914 } 1880 }
1915 spin_unlock_irqrestore(&send_queue->lock, flags); 1881 spin_unlock_irqrestore(&send_queue->lock, flags);
1916 1882
1917 /* Restore client wr_id in WC and complete send */ 1883 mad_send_wc.send_buf = &mad_send_wr->send_buf;
1918 wc->wr_id = mad_send_wr->wr_id; 1884 mad_send_wc.status = wc->status;
1885 mad_send_wc.vendor_err = wc->vendor_err;
1919 if (atomic_read(&qp_info->snoop_count)) 1886 if (atomic_read(&qp_info->snoop_count))
1920 snoop_send(qp_info, &mad_send_wr->send_wr, 1887 snoop_send(qp_info, &mad_send_wr->send_buf, &mad_send_wc,
1921 (struct ib_mad_send_wc *)wc,
1922 IB_MAD_SNOOP_SEND_COMPLETIONS); 1888 IB_MAD_SNOOP_SEND_COMPLETIONS);
1923 ib_mad_complete_send_wr(mad_send_wr, (struct ib_mad_send_wc *)wc); 1889 ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
1924 1890
1925 if (queued_send_wr) { 1891 if (queued_send_wr) {
1926 ret = ib_post_send(qp_info->qp, &queued_send_wr->send_wr, 1892 ret = ib_post_send(qp_info->qp, &queued_send_wr->send_wr,
1927 &bad_send_wr); 1893 &bad_send_wr);
1928 if (ret) { 1894 if (ret) {
1929 printk(KERN_ERR PFX "ib_post_send failed: %d\n", ret); 1895 printk(KERN_ERR PFX "ib_post_send failed: %d\n", ret);
1930 mad_send_wr = queued_send_wr; 1896 mad_send_wr = queued_send_wr;
@@ -2066,38 +2032,37 @@ static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv)
2066 2032
2067 list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr, 2033 list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
2068 &cancel_list, agent_list) { 2034 &cancel_list, agent_list) {
2069 mad_send_wc.wr_id = mad_send_wr->wr_id; 2035 mad_send_wc.send_buf = &mad_send_wr->send_buf;
2036 list_del(&mad_send_wr->agent_list);
2070 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, 2037 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
2071 &mad_send_wc); 2038 &mad_send_wc);
2072
2073 list_del(&mad_send_wr->agent_list);
2074 kfree(mad_send_wr);
2075 atomic_dec(&mad_agent_priv->refcount); 2039 atomic_dec(&mad_agent_priv->refcount);
2076 } 2040 }
2077} 2041}
2078 2042
2079static struct ib_mad_send_wr_private* 2043static struct ib_mad_send_wr_private*
2080find_send_by_wr_id(struct ib_mad_agent_private *mad_agent_priv, u64 wr_id) 2044find_send_wr(struct ib_mad_agent_private *mad_agent_priv,
2045 struct ib_mad_send_buf *send_buf)
2081{ 2046{
2082 struct ib_mad_send_wr_private *mad_send_wr; 2047 struct ib_mad_send_wr_private *mad_send_wr;
2083 2048
2084 list_for_each_entry(mad_send_wr, &mad_agent_priv->wait_list, 2049 list_for_each_entry(mad_send_wr, &mad_agent_priv->wait_list,
2085 agent_list) { 2050 agent_list) {
2086 if (mad_send_wr->wr_id == wr_id) 2051 if (&mad_send_wr->send_buf == send_buf)
2087 return mad_send_wr; 2052 return mad_send_wr;
2088 } 2053 }
2089 2054
2090 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list, 2055 list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
2091 agent_list) { 2056 agent_list) {
2092 if (is_data_mad(mad_agent_priv, 2057 if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) &&
2093 mad_send_wr->send_wr.wr.ud.mad_hdr) && 2058 &mad_send_wr->send_buf == send_buf)
2094 mad_send_wr->wr_id == wr_id)
2095 return mad_send_wr; 2059 return mad_send_wr;
2096 } 2060 }
2097 return NULL; 2061 return NULL;
2098} 2062}
2099 2063
2100int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms) 2064int ib_modify_mad(struct ib_mad_agent *mad_agent,
2065 struct ib_mad_send_buf *send_buf, u32 timeout_ms)
2101{ 2066{
2102 struct ib_mad_agent_private *mad_agent_priv; 2067 struct ib_mad_agent_private *mad_agent_priv;
2103 struct ib_mad_send_wr_private *mad_send_wr; 2068 struct ib_mad_send_wr_private *mad_send_wr;
@@ -2107,7 +2072,7 @@ int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms)
2107 mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private, 2072 mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
2108 agent); 2073 agent);
2109 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2074 spin_lock_irqsave(&mad_agent_priv->lock, flags);
2110 mad_send_wr = find_send_by_wr_id(mad_agent_priv, wr_id); 2075 mad_send_wr = find_send_wr(mad_agent_priv, send_buf);
2111 if (!mad_send_wr || mad_send_wr->status != IB_WC_SUCCESS) { 2076 if (!mad_send_wr || mad_send_wr->status != IB_WC_SUCCESS) {
2112 spin_unlock_irqrestore(&mad_agent_priv->lock, flags); 2077 spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
2113 return -EINVAL; 2078 return -EINVAL;
@@ -2119,7 +2084,7 @@ int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms)
2119 mad_send_wr->refcount -= (mad_send_wr->timeout > 0); 2084 mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
2120 } 2085 }
2121 2086
2122 mad_send_wr->send_wr.wr.ud.timeout_ms = timeout_ms; 2087 mad_send_wr->send_buf.timeout_ms = timeout_ms;
2123 if (active) 2088 if (active)
2124 mad_send_wr->timeout = msecs_to_jiffies(timeout_ms); 2089 mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
2125 else 2090 else
@@ -2130,9 +2095,10 @@ int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms)
2130} 2095}
2131EXPORT_SYMBOL(ib_modify_mad); 2096EXPORT_SYMBOL(ib_modify_mad);
2132 2097
2133void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id) 2098void ib_cancel_mad(struct ib_mad_agent *mad_agent,
2099 struct ib_mad_send_buf *send_buf)
2134{ 2100{
2135 ib_modify_mad(mad_agent, wr_id, 0); 2101 ib_modify_mad(mad_agent, send_buf, 0);
2136} 2102}
2137EXPORT_SYMBOL(ib_cancel_mad); 2103EXPORT_SYMBOL(ib_cancel_mad);
2138 2104
@@ -2166,10 +2132,9 @@ static void local_completions(void *data)
2166 * Defined behavior is to complete response 2132 * Defined behavior is to complete response
2167 * before request 2133 * before request
2168 */ 2134 */
2169 build_smp_wc(local->wr_id, 2135 build_smp_wc((unsigned long) local->mad_send_wr,
2170 be16_to_cpu(IB_LID_PERMISSIVE), 2136 be16_to_cpu(IB_LID_PERMISSIVE),
2171 0 /* pkey index */, 2137 0, recv_mad_agent->agent.port_num, &wc);
2172 recv_mad_agent->agent.port_num, &wc);
2173 2138
2174 local->mad_priv->header.recv_wc.wc = &wc; 2139 local->mad_priv->header.recv_wc.wc = &wc;
2175 local->mad_priv->header.recv_wc.mad_len = 2140 local->mad_priv->header.recv_wc.mad_len =
@@ -2196,11 +2161,11 @@ local_send_completion:
2196 /* Complete send */ 2161 /* Complete send */
2197 mad_send_wc.status = IB_WC_SUCCESS; 2162 mad_send_wc.status = IB_WC_SUCCESS;
2198 mad_send_wc.vendor_err = 0; 2163 mad_send_wc.vendor_err = 0;
2199 mad_send_wc.wr_id = local->wr_id; 2164 mad_send_wc.send_buf = &local->mad_send_wr->send_buf;
2200 if (atomic_read(&mad_agent_priv->qp_info->snoop_count)) 2165 if (atomic_read(&mad_agent_priv->qp_info->snoop_count))
2201 snoop_send(mad_agent_priv->qp_info, &local->send_wr, 2166 snoop_send(mad_agent_priv->qp_info,
2202 &mad_send_wc, 2167 &local->mad_send_wr->send_buf,
2203 IB_MAD_SNOOP_SEND_COMPLETIONS); 2168 &mad_send_wc, IB_MAD_SNOOP_SEND_COMPLETIONS);
2204 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, 2169 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
2205 &mad_send_wc); 2170 &mad_send_wc);
2206 2171
@@ -2221,8 +2186,7 @@ static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
2221 if (!mad_send_wr->retries--) 2186 if (!mad_send_wr->retries--)
2222 return -ETIMEDOUT; 2187 return -ETIMEDOUT;
2223 2188
2224 mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_wr. 2189 mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
2225 wr.ud.timeout_ms);
2226 2190
2227 if (mad_send_wr->mad_agent_priv->agent.rmpp_version) { 2191 if (mad_send_wr->mad_agent_priv->agent.rmpp_version) {
2228 ret = ib_retry_rmpp(mad_send_wr); 2192 ret = ib_retry_rmpp(mad_send_wr);
@@ -2285,11 +2249,10 @@ static void timeout_sends(void *data)
2285 mad_send_wc.status = IB_WC_RESP_TIMEOUT_ERR; 2249 mad_send_wc.status = IB_WC_RESP_TIMEOUT_ERR;
2286 else 2250 else
2287 mad_send_wc.status = mad_send_wr->status; 2251 mad_send_wc.status = mad_send_wr->status;
2288 mad_send_wc.wr_id = mad_send_wr->wr_id; 2252 mad_send_wc.send_buf = &mad_send_wr->send_buf;
2289 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, 2253 mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
2290 &mad_send_wc); 2254 &mad_send_wc);
2291 2255
2292 kfree(mad_send_wr);
2293 atomic_dec(&mad_agent_priv->refcount); 2256 atomic_dec(&mad_agent_priv->refcount);
2294 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2257 spin_lock_irqsave(&mad_agent_priv->lock, flags);
2295 } 2258 }
@@ -2683,40 +2646,47 @@ static int ib_mad_port_close(struct ib_device *device, int port_num)
2683 2646
2684static void ib_mad_init_device(struct ib_device *device) 2647static void ib_mad_init_device(struct ib_device *device)
2685{ 2648{
2686 int num_ports, cur_port, i; 2649 int start, end, i;
2687 2650
2688 if (device->node_type == IB_NODE_SWITCH) { 2651 if (device->node_type == IB_NODE_SWITCH) {
2689 num_ports = 1; 2652 start = 0;
2690 cur_port = 0; 2653 end = 0;
2691 } else { 2654 } else {
2692 num_ports = device->phys_port_cnt; 2655 start = 1;
2693 cur_port = 1; 2656 end = device->phys_port_cnt;
2694 } 2657 }
2695 for (i = 0; i < num_ports; i++, cur_port++) { 2658
2696 if (ib_mad_port_open(device, cur_port)) { 2659 for (i = start; i <= end; i++) {
2660 if (ib_mad_port_open(device, i)) {
2697 printk(KERN_ERR PFX "Couldn't open %s port %d\n", 2661 printk(KERN_ERR PFX "Couldn't open %s port %d\n",
2698 device->name, cur_port); 2662 device->name, i);
2699 goto error_device_open; 2663 goto error;
2700 } 2664 }
2701 if (ib_agent_port_open(device, cur_port)) { 2665 if (ib_agent_port_open(device, i)) {
2702 printk(KERN_ERR PFX "Couldn't open %s port %d " 2666 printk(KERN_ERR PFX "Couldn't open %s port %d "
2703 "for agents\n", 2667 "for agents\n",
2704 device->name, cur_port); 2668 device->name, i);
2705 goto error_device_open; 2669 goto error_agent;
2706 } 2670 }
2707 } 2671 }
2708 return; 2672 return;
2709 2673
2710error_device_open: 2674error_agent:
2711 while (i > 0) { 2675 if (ib_mad_port_close(device, i))
2712 cur_port--; 2676 printk(KERN_ERR PFX "Couldn't close %s port %d\n",
2713 if (ib_agent_port_close(device, cur_port)) 2677 device->name, i);
2678
2679error:
2680 i--;
2681
2682 while (i >= start) {
2683 if (ib_agent_port_close(device, i))
2714 printk(KERN_ERR PFX "Couldn't close %s port %d " 2684 printk(KERN_ERR PFX "Couldn't close %s port %d "
2715 "for agents\n", 2685 "for agents\n",
2716 device->name, cur_port); 2686 device->name, i);
2717 if (ib_mad_port_close(device, cur_port)) 2687 if (ib_mad_port_close(device, i))
2718 printk(KERN_ERR PFX "Couldn't close %s port %d\n", 2688 printk(KERN_ERR PFX "Couldn't close %s port %d\n",
2719 device->name, cur_port); 2689 device->name, i);
2720 i--; 2690 i--;
2721 } 2691 }
2722} 2692}
@@ -2754,7 +2724,6 @@ static int __init ib_mad_init_module(void)
2754 int ret; 2724 int ret;
2755 2725
2756 spin_lock_init(&ib_mad_port_list_lock); 2726 spin_lock_init(&ib_mad_port_list_lock);
2757 spin_lock_init(&ib_agent_port_list_lock);
2758 2727
2759 ib_mad_cache = kmem_cache_create("ib_mad", 2728 ib_mad_cache = kmem_cache_create("ib_mad",
2760 sizeof(struct ib_mad_private), 2729 sizeof(struct ib_mad_private),
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index f1ba794e0daa..570f78682af3 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -118,9 +118,10 @@ struct ib_mad_send_wr_private {
118 struct ib_mad_list_head mad_list; 118 struct ib_mad_list_head mad_list;
119 struct list_head agent_list; 119 struct list_head agent_list;
120 struct ib_mad_agent_private *mad_agent_priv; 120 struct ib_mad_agent_private *mad_agent_priv;
121 struct ib_mad_send_buf send_buf;
122 DECLARE_PCI_UNMAP_ADDR(mapping)
121 struct ib_send_wr send_wr; 123 struct ib_send_wr send_wr;
122 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; 124 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
123 u64 wr_id; /* client WR ID */
124 __be64 tid; 125 __be64 tid;
125 unsigned long timeout; 126 unsigned long timeout;
126 int retries; 127 int retries;
@@ -141,10 +142,7 @@ struct ib_mad_local_private {
141 struct list_head completion_list; 142 struct list_head completion_list;
142 struct ib_mad_private *mad_priv; 143 struct ib_mad_private *mad_priv;
143 struct ib_mad_agent_private *recv_mad_agent; 144 struct ib_mad_agent_private *recv_mad_agent;
144 struct ib_send_wr send_wr; 145 struct ib_mad_send_wr_private *mad_send_wr;
145 struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
146 u64 wr_id; /* client WR ID */
147 __be64 tid;
148}; 146};
149 147
150struct ib_mad_mgmt_method_table { 148struct ib_mad_mgmt_method_table {
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index e23836d0e21b..3249e1d8c07b 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -103,12 +103,12 @@ void ib_cancel_rmpp_recvs(struct ib_mad_agent_private *agent)
103static int data_offset(u8 mgmt_class) 103static int data_offset(u8 mgmt_class)
104{ 104{
105 if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM) 105 if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
106 return offsetof(struct ib_sa_mad, data); 106 return IB_MGMT_SA_HDR;
107 else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) && 107 else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
108 (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) 108 (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
109 return offsetof(struct ib_vendor_mad, data); 109 return IB_MGMT_VENDOR_HDR;
110 else 110 else
111 return offsetof(struct ib_rmpp_mad, data); 111 return IB_MGMT_RMPP_HDR;
112} 112}
113 113
114static void format_ack(struct ib_rmpp_mad *ack, 114static void format_ack(struct ib_rmpp_mad *ack,
@@ -135,55 +135,52 @@ static void ack_recv(struct mad_rmpp_recv *rmpp_recv,
135 struct ib_mad_recv_wc *recv_wc) 135 struct ib_mad_recv_wc *recv_wc)
136{ 136{
137 struct ib_mad_send_buf *msg; 137 struct ib_mad_send_buf *msg;
138 struct ib_send_wr *bad_send_wr; 138 int ret;
139 int hdr_len, ret;
140 139
141 hdr_len = sizeof(struct ib_mad_hdr) + sizeof(struct ib_rmpp_hdr);
142 msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp, 140 msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
143 recv_wc->wc->pkey_index, rmpp_recv->ah, 1, 141 recv_wc->wc->pkey_index, 1, IB_MGMT_RMPP_HDR,
144 hdr_len, sizeof(struct ib_rmpp_mad) - hdr_len, 142 IB_MGMT_RMPP_DATA, GFP_KERNEL);
145 GFP_KERNEL);
146 if (!msg) 143 if (!msg)
147 return; 144 return;
148 145
149 format_ack((struct ib_rmpp_mad *) msg->mad, 146 format_ack(msg->mad, (struct ib_rmpp_mad *) recv_wc->recv_buf.mad,
150 (struct ib_rmpp_mad *) recv_wc->recv_buf.mad, rmpp_recv); 147 rmpp_recv);
151 ret = ib_post_send_mad(&rmpp_recv->agent->agent, &msg->send_wr, 148 msg->ah = rmpp_recv->ah;
152 &bad_send_wr); 149 ret = ib_post_send_mad(msg, NULL);
153 if (ret) 150 if (ret)
154 ib_free_send_mad(msg); 151 ib_free_send_mad(msg);
155} 152}
156 153
157static int alloc_response_msg(struct ib_mad_agent *agent, 154static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
158 struct ib_mad_recv_wc *recv_wc, 155 struct ib_mad_recv_wc *recv_wc)
159 struct ib_mad_send_buf **msg)
160{ 156{
161 struct ib_mad_send_buf *m; 157 struct ib_mad_send_buf *msg;
162 struct ib_ah *ah; 158 struct ib_ah *ah;
163 int hdr_len;
164 159
165 ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc, 160 ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
166 recv_wc->recv_buf.grh, agent->port_num); 161 recv_wc->recv_buf.grh, agent->port_num);
167 if (IS_ERR(ah)) 162 if (IS_ERR(ah))
168 return PTR_ERR(ah); 163 return (void *) ah;
169 164
170 hdr_len = sizeof(struct ib_mad_hdr) + sizeof(struct ib_rmpp_hdr); 165 msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
171 m = ib_create_send_mad(agent, recv_wc->wc->src_qp, 166 recv_wc->wc->pkey_index, 1,
172 recv_wc->wc->pkey_index, ah, 1, hdr_len, 167 IB_MGMT_RMPP_HDR, IB_MGMT_RMPP_DATA,
173 sizeof(struct ib_rmpp_mad) - hdr_len, 168 GFP_KERNEL);
174 GFP_KERNEL); 169 if (IS_ERR(msg))
175 if (IS_ERR(m)) {
176 ib_destroy_ah(ah); 170 ib_destroy_ah(ah);
177 return PTR_ERR(m); 171 else
178 } 172 msg->ah = ah;
179 *msg = m; 173
180 return 0; 174 return msg;
181} 175}
182 176
183static void free_msg(struct ib_mad_send_buf *msg) 177void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
184{ 178{
185 ib_destroy_ah(msg->send_wr.wr.ud.ah); 179 struct ib_rmpp_mad *rmpp_mad = mad_send_wc->send_buf->mad;
186 ib_free_send_mad(msg); 180
181 if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_ACK)
182 ib_destroy_ah(mad_send_wc->send_buf->ah);
183 ib_free_send_mad(mad_send_wc->send_buf);
187} 184}
188 185
189static void nack_recv(struct ib_mad_agent_private *agent, 186static void nack_recv(struct ib_mad_agent_private *agent,
@@ -191,14 +188,13 @@ static void nack_recv(struct ib_mad_agent_private *agent,
191{ 188{
192 struct ib_mad_send_buf *msg; 189 struct ib_mad_send_buf *msg;
193 struct ib_rmpp_mad *rmpp_mad; 190 struct ib_rmpp_mad *rmpp_mad;
194 struct ib_send_wr *bad_send_wr;
195 int ret; 191 int ret;
196 192
197 ret = alloc_response_msg(&agent->agent, recv_wc, &msg); 193 msg = alloc_response_msg(&agent->agent, recv_wc);
198 if (ret) 194 if (IS_ERR(msg))
199 return; 195 return;
200 196
201 rmpp_mad = (struct ib_rmpp_mad *) msg->mad; 197 rmpp_mad = msg->mad;
202 memcpy(rmpp_mad, recv_wc->recv_buf.mad, 198 memcpy(rmpp_mad, recv_wc->recv_buf.mad,
203 data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class)); 199 data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class));
204 200
@@ -210,9 +206,11 @@ static void nack_recv(struct ib_mad_agent_private *agent,
210 rmpp_mad->rmpp_hdr.seg_num = 0; 206 rmpp_mad->rmpp_hdr.seg_num = 0;
211 rmpp_mad->rmpp_hdr.paylen_newwin = 0; 207 rmpp_mad->rmpp_hdr.paylen_newwin = 0;
212 208
213 ret = ib_post_send_mad(&agent->agent, &msg->send_wr, &bad_send_wr); 209 ret = ib_post_send_mad(msg, NULL);
214 if (ret) 210 if (ret) {
215 free_msg(msg); 211 ib_destroy_ah(msg->ah);
212 ib_free_send_mad(msg);
213 }
216} 214}
217 215
218static void recv_timeout_handler(void *data) 216static void recv_timeout_handler(void *data)
@@ -585,7 +583,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
585 int timeout; 583 int timeout;
586 u32 paylen; 584 u32 paylen;
587 585
588 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; 586 rmpp_mad = mad_send_wr->send_buf.mad;
589 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE); 587 ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
590 rmpp_mad->rmpp_hdr.seg_num = cpu_to_be32(mad_send_wr->seg_num); 588 rmpp_mad->rmpp_hdr.seg_num = cpu_to_be32(mad_send_wr->seg_num);
591 589
@@ -612,7 +610,7 @@ static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
612 } 610 }
613 611
614 /* 2 seconds for an ACK until we can find the packet lifetime */ 612 /* 2 seconds for an ACK until we can find the packet lifetime */
615 timeout = mad_send_wr->send_wr.wr.ud.timeout_ms; 613 timeout = mad_send_wr->send_buf.timeout_ms;
616 if (!timeout || timeout > 2000) 614 if (!timeout || timeout > 2000)
617 mad_send_wr->timeout = msecs_to_jiffies(2000); 615 mad_send_wr->timeout = msecs_to_jiffies(2000);
618 mad_send_wr->seg_num++; 616 mad_send_wr->seg_num++;
@@ -640,7 +638,7 @@ static void abort_send(struct ib_mad_agent_private *agent, __be64 tid,
640 638
641 wc.status = IB_WC_REM_ABORT_ERR; 639 wc.status = IB_WC_REM_ABORT_ERR;
642 wc.vendor_err = rmpp_status; 640 wc.vendor_err = rmpp_status;
643 wc.wr_id = mad_send_wr->wr_id; 641 wc.send_buf = &mad_send_wr->send_buf;
644 ib_mad_complete_send_wr(mad_send_wr, &wc); 642 ib_mad_complete_send_wr(mad_send_wr, &wc);
645 return; 643 return;
646out: 644out:
@@ -694,12 +692,12 @@ static void process_rmpp_ack(struct ib_mad_agent_private *agent,
694 692
695 if (seg_num > mad_send_wr->last_ack) { 693 if (seg_num > mad_send_wr->last_ack) {
696 mad_send_wr->last_ack = seg_num; 694 mad_send_wr->last_ack = seg_num;
697 mad_send_wr->retries = mad_send_wr->send_wr.wr.ud.retries; 695 mad_send_wr->retries = mad_send_wr->send_buf.retries;
698 } 696 }
699 mad_send_wr->newwin = newwin; 697 mad_send_wr->newwin = newwin;
700 if (mad_send_wr->last_ack == mad_send_wr->total_seg) { 698 if (mad_send_wr->last_ack == mad_send_wr->total_seg) {
701 /* If no response is expected, the ACK completes the send */ 699 /* If no response is expected, the ACK completes the send */
702 if (!mad_send_wr->send_wr.wr.ud.timeout_ms) { 700 if (!mad_send_wr->send_buf.timeout_ms) {
703 struct ib_mad_send_wc wc; 701 struct ib_mad_send_wc wc;
704 702
705 ib_mark_mad_done(mad_send_wr); 703 ib_mark_mad_done(mad_send_wr);
@@ -707,13 +705,13 @@ static void process_rmpp_ack(struct ib_mad_agent_private *agent,
707 705
708 wc.status = IB_WC_SUCCESS; 706 wc.status = IB_WC_SUCCESS;
709 wc.vendor_err = 0; 707 wc.vendor_err = 0;
710 wc.wr_id = mad_send_wr->wr_id; 708 wc.send_buf = &mad_send_wr->send_buf;
711 ib_mad_complete_send_wr(mad_send_wr, &wc); 709 ib_mad_complete_send_wr(mad_send_wr, &wc);
712 return; 710 return;
713 } 711 }
714 if (mad_send_wr->refcount == 1) 712 if (mad_send_wr->refcount == 1)
715 ib_reset_mad_timeout(mad_send_wr, mad_send_wr-> 713 ib_reset_mad_timeout(mad_send_wr,
716 send_wr.wr.ud.timeout_ms); 714 mad_send_wr->send_buf.timeout_ms);
717 } else if (mad_send_wr->refcount == 1 && 715 } else if (mad_send_wr->refcount == 1 &&
718 mad_send_wr->seg_num < mad_send_wr->newwin && 716 mad_send_wr->seg_num < mad_send_wr->newwin &&
719 mad_send_wr->seg_num <= mad_send_wr->total_seg) { 717 mad_send_wr->seg_num <= mad_send_wr->total_seg) {
@@ -842,7 +840,7 @@ int ib_send_rmpp_mad(struct ib_mad_send_wr_private *mad_send_wr)
842 struct ib_rmpp_mad *rmpp_mad; 840 struct ib_rmpp_mad *rmpp_mad;
843 int i, total_len, ret; 841 int i, total_len, ret;
844 842
845 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; 843 rmpp_mad = mad_send_wr->send_buf.mad;
846 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 844 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
847 IB_MGMT_RMPP_FLAG_ACTIVE)) 845 IB_MGMT_RMPP_FLAG_ACTIVE))
848 return IB_RMPP_RESULT_UNHANDLED; 846 return IB_RMPP_RESULT_UNHANDLED;
@@ -863,7 +861,7 @@ int ib_send_rmpp_mad(struct ib_mad_send_wr_private *mad_send_wr)
863 861
864 mad_send_wr->total_seg = (total_len - mad_send_wr->data_offset) / 862 mad_send_wr->total_seg = (total_len - mad_send_wr->data_offset) /
865 (sizeof(struct ib_rmpp_mad) - mad_send_wr->data_offset); 863 (sizeof(struct ib_rmpp_mad) - mad_send_wr->data_offset);
866 mad_send_wr->pad = total_len - offsetof(struct ib_rmpp_mad, data) - 864 mad_send_wr->pad = total_len - IB_MGMT_RMPP_HDR -
867 be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin); 865 be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
868 866
869 /* We need to wait for the final ACK even if there isn't a response */ 867 /* We need to wait for the final ACK even if there isn't a response */
@@ -878,23 +876,15 @@ int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
878 struct ib_mad_send_wc *mad_send_wc) 876 struct ib_mad_send_wc *mad_send_wc)
879{ 877{
880 struct ib_rmpp_mad *rmpp_mad; 878 struct ib_rmpp_mad *rmpp_mad;
881 struct ib_mad_send_buf *msg;
882 int ret; 879 int ret;
883 880
884 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; 881 rmpp_mad = mad_send_wr->send_buf.mad;
885 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 882 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
886 IB_MGMT_RMPP_FLAG_ACTIVE)) 883 IB_MGMT_RMPP_FLAG_ACTIVE))
887 return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */ 884 return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
888 885
889 if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA) { 886 if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA)
890 msg = (struct ib_mad_send_buf *) (unsigned long)
891 mad_send_wc->wr_id;
892 if (rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_ACK)
893 ib_free_send_mad(msg);
894 else
895 free_msg(msg);
896 return IB_RMPP_RESULT_INTERNAL; /* ACK, STOP, or ABORT */ 887 return IB_RMPP_RESULT_INTERNAL; /* ACK, STOP, or ABORT */
897 }
898 888
899 if (mad_send_wc->status != IB_WC_SUCCESS || 889 if (mad_send_wc->status != IB_WC_SUCCESS ||
900 mad_send_wr->status != IB_WC_SUCCESS) 890 mad_send_wr->status != IB_WC_SUCCESS)
@@ -905,7 +895,7 @@ int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
905 895
906 if (mad_send_wr->last_ack == mad_send_wr->total_seg) { 896 if (mad_send_wr->last_ack == mad_send_wr->total_seg) {
907 mad_send_wr->timeout = 897 mad_send_wr->timeout =
908 msecs_to_jiffies(mad_send_wr->send_wr.wr.ud.timeout_ms); 898 msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
909 return IB_RMPP_RESULT_PROCESSED; /* Send done */ 899 return IB_RMPP_RESULT_PROCESSED; /* Send done */
910 } 900 }
911 901
@@ -926,7 +916,7 @@ int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr)
926 struct ib_rmpp_mad *rmpp_mad; 916 struct ib_rmpp_mad *rmpp_mad;
927 int ret; 917 int ret;
928 918
929 rmpp_mad = (struct ib_rmpp_mad *)mad_send_wr->send_wr.wr.ud.mad_hdr; 919 rmpp_mad = mad_send_wr->send_buf.mad;
930 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & 920 if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
931 IB_MGMT_RMPP_FLAG_ACTIVE)) 921 IB_MGMT_RMPP_FLAG_ACTIVE))
932 return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */ 922 return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
diff --git a/drivers/infiniband/core/mad_rmpp.h b/drivers/infiniband/core/mad_rmpp.h
index c4924dfb8e75..f0616fd22494 100644
--- a/drivers/infiniband/core/mad_rmpp.h
+++ b/drivers/infiniband/core/mad_rmpp.h
@@ -51,6 +51,8 @@ ib_process_rmpp_recv_wc(struct ib_mad_agent_private *agent,
51int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr, 51int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
52 struct ib_mad_send_wc *mad_send_wc); 52 struct ib_mad_send_wc *mad_send_wc);
53 53
54void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc);
55
54void ib_cancel_rmpp_recvs(struct ib_mad_agent_private *agent); 56void ib_cancel_rmpp_recvs(struct ib_mad_agent_private *agent);
55 57
56int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr); 58int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 262618210c1c..89ce9dc210d4 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -73,11 +73,10 @@ struct ib_sa_device {
73struct ib_sa_query { 73struct ib_sa_query {
74 void (*callback)(struct ib_sa_query *, int, struct ib_sa_mad *); 74 void (*callback)(struct ib_sa_query *, int, struct ib_sa_mad *);
75 void (*release)(struct ib_sa_query *); 75 void (*release)(struct ib_sa_query *);
76 struct ib_sa_port *port; 76 struct ib_sa_port *port;
77 struct ib_sa_mad *mad; 77 struct ib_mad_send_buf *mad_buf;
78 struct ib_sa_sm_ah *sm_ah; 78 struct ib_sa_sm_ah *sm_ah;
79 DECLARE_PCI_UNMAP_ADDR(mapping) 79 int id;
80 int id;
81}; 80};
82 81
83struct ib_sa_service_query { 82struct ib_sa_service_query {
@@ -426,6 +425,7 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query)
426{ 425{
427 unsigned long flags; 426 unsigned long flags;
428 struct ib_mad_agent *agent; 427 struct ib_mad_agent *agent;
428 struct ib_mad_send_buf *mad_buf;
429 429
430 spin_lock_irqsave(&idr_lock, flags); 430 spin_lock_irqsave(&idr_lock, flags);
431 if (idr_find(&query_idr, id) != query) { 431 if (idr_find(&query_idr, id) != query) {
@@ -433,9 +433,10 @@ void ib_sa_cancel_query(int id, struct ib_sa_query *query)
433 return; 433 return;
434 } 434 }
435 agent = query->port->agent; 435 agent = query->port->agent;
436 mad_buf = query->mad_buf;
436 spin_unlock_irqrestore(&idr_lock, flags); 437 spin_unlock_irqrestore(&idr_lock, flags);
437 438
438 ib_cancel_mad(agent, id); 439 ib_cancel_mad(agent, mad_buf);
439} 440}
440EXPORT_SYMBOL(ib_sa_cancel_query); 441EXPORT_SYMBOL(ib_sa_cancel_query);
441 442
@@ -457,71 +458,46 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
457 458
458static int send_mad(struct ib_sa_query *query, int timeout_ms) 459static int send_mad(struct ib_sa_query *query, int timeout_ms)
459{ 460{
460 struct ib_sa_port *port = query->port;
461 unsigned long flags; 461 unsigned long flags;
462 int ret; 462 int ret, id;
463 struct ib_sge gather_list;
464 struct ib_send_wr *bad_wr, wr = {
465 .opcode = IB_WR_SEND,
466 .sg_list = &gather_list,
467 .num_sge = 1,
468 .send_flags = IB_SEND_SIGNALED,
469 .wr = {
470 .ud = {
471 .mad_hdr = &query->mad->mad_hdr,
472 .remote_qpn = 1,
473 .remote_qkey = IB_QP1_QKEY,
474 .timeout_ms = timeout_ms,
475 }
476 }
477 };
478 463
479retry: 464retry:
480 if (!idr_pre_get(&query_idr, GFP_ATOMIC)) 465 if (!idr_pre_get(&query_idr, GFP_ATOMIC))
481 return -ENOMEM; 466 return -ENOMEM;
482 spin_lock_irqsave(&idr_lock, flags); 467 spin_lock_irqsave(&idr_lock, flags);
483 ret = idr_get_new(&query_idr, query, &query->id); 468 ret = idr_get_new(&query_idr, query, &id);
484 spin_unlock_irqrestore(&idr_lock, flags); 469 spin_unlock_irqrestore(&idr_lock, flags);
485 if (ret == -EAGAIN) 470 if (ret == -EAGAIN)
486 goto retry; 471 goto retry;
487 if (ret) 472 if (ret)
488 return ret; 473 return ret;
489 474
490 wr.wr_id = query->id; 475 query->mad_buf->timeout_ms = timeout_ms;
476 query->mad_buf->context[0] = query;
477 query->id = id;
491 478
492 spin_lock_irqsave(&port->ah_lock, flags); 479 spin_lock_irqsave(&query->port->ah_lock, flags);
493 kref_get(&port->sm_ah->ref); 480 kref_get(&query->port->sm_ah->ref);
494 query->sm_ah = port->sm_ah; 481 query->sm_ah = query->port->sm_ah;
495 wr.wr.ud.ah = port->sm_ah->ah; 482 spin_unlock_irqrestore(&query->port->ah_lock, flags);
496 spin_unlock_irqrestore(&port->ah_lock, flags);
497 483
498 gather_list.addr = dma_map_single(port->agent->device->dma_device, 484 query->mad_buf->ah = query->sm_ah->ah;
499 query->mad,
500 sizeof (struct ib_sa_mad),
501 DMA_TO_DEVICE);
502 gather_list.length = sizeof (struct ib_sa_mad);
503 gather_list.lkey = port->agent->mr->lkey;
504 pci_unmap_addr_set(query, mapping, gather_list.addr);
505 485
506 ret = ib_post_send_mad(port->agent, &wr, &bad_wr); 486 ret = ib_post_send_mad(query->mad_buf, NULL);
507 if (ret) { 487 if (ret) {
508 dma_unmap_single(port->agent->device->dma_device,
509 pci_unmap_addr(query, mapping),
510 sizeof (struct ib_sa_mad),
511 DMA_TO_DEVICE);
512 kref_put(&query->sm_ah->ref, free_sm_ah);
513 spin_lock_irqsave(&idr_lock, flags); 488 spin_lock_irqsave(&idr_lock, flags);
514 idr_remove(&query_idr, query->id); 489 idr_remove(&query_idr, id);
515 spin_unlock_irqrestore(&idr_lock, flags); 490 spin_unlock_irqrestore(&idr_lock, flags);
491
492 kref_put(&query->sm_ah->ref, free_sm_ah);
516 } 493 }
517 494
518 /* 495 /*
519 * It's not safe to dereference query any more, because the 496 * It's not safe to dereference query any more, because the
520 * send may already have completed and freed the query in 497 * send may already have completed and freed the query in
521 * another context. So use wr.wr_id, which has a copy of the 498 * another context.
522 * query's id.
523 */ 499 */
524 return ret ? ret : wr.wr_id; 500 return ret ? ret : id;
525} 501}
526 502
527static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query, 503static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
@@ -543,7 +519,6 @@ static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
543 519
544static void ib_sa_path_rec_release(struct ib_sa_query *sa_query) 520static void ib_sa_path_rec_release(struct ib_sa_query *sa_query)
545{ 521{
546 kfree(sa_query->mad);
547 kfree(container_of(sa_query, struct ib_sa_path_query, sa_query)); 522 kfree(container_of(sa_query, struct ib_sa_path_query, sa_query));
548} 523}
549 524
@@ -583,43 +558,58 @@ int ib_sa_path_rec_get(struct ib_device *device, u8 port_num,
583{ 558{
584 struct ib_sa_path_query *query; 559 struct ib_sa_path_query *query;
585 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); 560 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
586 struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; 561 struct ib_sa_port *port;
587 struct ib_mad_agent *agent = port->agent; 562 struct ib_mad_agent *agent;
563 struct ib_sa_mad *mad;
588 int ret; 564 int ret;
589 565
566 if (!sa_dev)
567 return -ENODEV;
568
569 port = &sa_dev->port[port_num - sa_dev->start_port];
570 agent = port->agent;
571
590 query = kmalloc(sizeof *query, gfp_mask); 572 query = kmalloc(sizeof *query, gfp_mask);
591 if (!query) 573 if (!query)
592 return -ENOMEM; 574 return -ENOMEM;
593 query->sa_query.mad = kmalloc(sizeof *query->sa_query.mad, gfp_mask); 575
594 if (!query->sa_query.mad) { 576 query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0,
595 kfree(query); 577 0, IB_MGMT_SA_HDR,
596 return -ENOMEM; 578 IB_MGMT_SA_DATA, gfp_mask);
579 if (!query->sa_query.mad_buf) {
580 ret = -ENOMEM;
581 goto err1;
597 } 582 }
598 583
599 query->callback = callback; 584 query->callback = callback;
600 query->context = context; 585 query->context = context;
601 586
602 init_mad(query->sa_query.mad, agent); 587 mad = query->sa_query.mad_buf->mad;
588 init_mad(mad, agent);
603 589
604 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL; 590 query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
605 query->sa_query.release = ib_sa_path_rec_release; 591 query->sa_query.release = ib_sa_path_rec_release;
606 query->sa_query.port = port; 592 query->sa_query.port = port;
607 query->sa_query.mad->mad_hdr.method = IB_MGMT_METHOD_GET; 593 mad->mad_hdr.method = IB_MGMT_METHOD_GET;
608 query->sa_query.mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC); 594 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC);
609 query->sa_query.mad->sa_hdr.comp_mask = comp_mask; 595 mad->sa_hdr.comp_mask = comp_mask;
610 596
611 ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), 597 ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, mad->data);
612 rec, query->sa_query.mad->data);
613 598
614 *sa_query = &query->sa_query; 599 *sa_query = &query->sa_query;
615 600
616 ret = send_mad(&query->sa_query, timeout_ms); 601 ret = send_mad(&query->sa_query, timeout_ms);
617 if (ret < 0) { 602 if (ret < 0)
618 *sa_query = NULL; 603 goto err2;
619 kfree(query->sa_query.mad); 604
620 kfree(query); 605 return ret;
621 }
622 606
607err2:
608 *sa_query = NULL;
609 ib_free_send_mad(query->sa_query.mad_buf);
610
611err1:
612 kfree(query);
623 return ret; 613 return ret;
624} 614}
625EXPORT_SYMBOL(ib_sa_path_rec_get); 615EXPORT_SYMBOL(ib_sa_path_rec_get);
@@ -643,7 +633,6 @@ static void ib_sa_service_rec_callback(struct ib_sa_query *sa_query,
643 633
644static void ib_sa_service_rec_release(struct ib_sa_query *sa_query) 634static void ib_sa_service_rec_release(struct ib_sa_query *sa_query)
645{ 635{
646 kfree(sa_query->mad);
647 kfree(container_of(sa_query, struct ib_sa_service_query, sa_query)); 636 kfree(container_of(sa_query, struct ib_sa_service_query, sa_query));
648} 637}
649 638
@@ -685,10 +674,17 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
685{ 674{
686 struct ib_sa_service_query *query; 675 struct ib_sa_service_query *query;
687 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); 676 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
688 struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; 677 struct ib_sa_port *port;
689 struct ib_mad_agent *agent = port->agent; 678 struct ib_mad_agent *agent;
679 struct ib_sa_mad *mad;
690 int ret; 680 int ret;
691 681
682 if (!sa_dev)
683 return -ENODEV;
684
685 port = &sa_dev->port[port_num - sa_dev->start_port];
686 agent = port->agent;
687
692 if (method != IB_MGMT_METHOD_GET && 688 if (method != IB_MGMT_METHOD_GET &&
693 method != IB_MGMT_METHOD_SET && 689 method != IB_MGMT_METHOD_SET &&
694 method != IB_SA_METHOD_DELETE) 690 method != IB_SA_METHOD_DELETE)
@@ -697,37 +693,45 @@ int ib_sa_service_rec_query(struct ib_device *device, u8 port_num, u8 method,
697 query = kmalloc(sizeof *query, gfp_mask); 693 query = kmalloc(sizeof *query, gfp_mask);
698 if (!query) 694 if (!query)
699 return -ENOMEM; 695 return -ENOMEM;
700 query->sa_query.mad = kmalloc(sizeof *query->sa_query.mad, gfp_mask); 696
701 if (!query->sa_query.mad) { 697 query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0,
702 kfree(query); 698 0, IB_MGMT_SA_HDR,
703 return -ENOMEM; 699 IB_MGMT_SA_DATA, gfp_mask);
700 if (!query->sa_query.mad_buf) {
701 ret = -ENOMEM;
702 goto err1;
704 } 703 }
705 704
706 query->callback = callback; 705 query->callback = callback;
707 query->context = context; 706 query->context = context;
708 707
709 init_mad(query->sa_query.mad, agent); 708 mad = query->sa_query.mad_buf->mad;
709 init_mad(mad, agent);
710 710
711 query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL; 711 query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL;
712 query->sa_query.release = ib_sa_service_rec_release; 712 query->sa_query.release = ib_sa_service_rec_release;
713 query->sa_query.port = port; 713 query->sa_query.port = port;
714 query->sa_query.mad->mad_hdr.method = method; 714 mad->mad_hdr.method = method;
715 query->sa_query.mad->mad_hdr.attr_id = 715 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_SERVICE_REC);
716 cpu_to_be16(IB_SA_ATTR_SERVICE_REC); 716 mad->sa_hdr.comp_mask = comp_mask;
717 query->sa_query.mad->sa_hdr.comp_mask = comp_mask;
718 717
719 ib_pack(service_rec_table, ARRAY_SIZE(service_rec_table), 718 ib_pack(service_rec_table, ARRAY_SIZE(service_rec_table),
720 rec, query->sa_query.mad->data); 719 rec, mad->data);
721 720
722 *sa_query = &query->sa_query; 721 *sa_query = &query->sa_query;
723 722
724 ret = send_mad(&query->sa_query, timeout_ms); 723 ret = send_mad(&query->sa_query, timeout_ms);
725 if (ret < 0) { 724 if (ret < 0)
726 *sa_query = NULL; 725 goto err2;
727 kfree(query->sa_query.mad); 726
728 kfree(query); 727 return ret;
729 }
730 728
729err2:
730 *sa_query = NULL;
731 ib_free_send_mad(query->sa_query.mad_buf);
732
733err1:
734 kfree(query);
731 return ret; 735 return ret;
732} 736}
733EXPORT_SYMBOL(ib_sa_service_rec_query); 737EXPORT_SYMBOL(ib_sa_service_rec_query);
@@ -751,7 +755,6 @@ static void ib_sa_mcmember_rec_callback(struct ib_sa_query *sa_query,
751 755
752static void ib_sa_mcmember_rec_release(struct ib_sa_query *sa_query) 756static void ib_sa_mcmember_rec_release(struct ib_sa_query *sa_query)
753{ 757{
754 kfree(sa_query->mad);
755 kfree(container_of(sa_query, struct ib_sa_mcmember_query, sa_query)); 758 kfree(container_of(sa_query, struct ib_sa_mcmember_query, sa_query));
756} 759}
757 760
@@ -768,60 +771,69 @@ int ib_sa_mcmember_rec_query(struct ib_device *device, u8 port_num,
768{ 771{
769 struct ib_sa_mcmember_query *query; 772 struct ib_sa_mcmember_query *query;
770 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client); 773 struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
771 struct ib_sa_port *port = &sa_dev->port[port_num - sa_dev->start_port]; 774 struct ib_sa_port *port;
772 struct ib_mad_agent *agent = port->agent; 775 struct ib_mad_agent *agent;
776 struct ib_sa_mad *mad;
773 int ret; 777 int ret;
774 778
779 if (!sa_dev)
780 return -ENODEV;
781
782 port = &sa_dev->port[port_num - sa_dev->start_port];
783 agent = port->agent;
784
775 query = kmalloc(sizeof *query, gfp_mask); 785 query = kmalloc(sizeof *query, gfp_mask);
776 if (!query) 786 if (!query)
777 return -ENOMEM; 787 return -ENOMEM;
778 query->sa_query.mad = kmalloc(sizeof *query->sa_query.mad, gfp_mask); 788
779 if (!query->sa_query.mad) { 789 query->sa_query.mad_buf = ib_create_send_mad(agent, 1, 0,
780 kfree(query); 790 0, IB_MGMT_SA_HDR,
781 return -ENOMEM; 791 IB_MGMT_SA_DATA, gfp_mask);
792 if (!query->sa_query.mad_buf) {
793 ret = -ENOMEM;
794 goto err1;
782 } 795 }
783 796
784 query->callback = callback; 797 query->callback = callback;
785 query->context = context; 798 query->context = context;
786 799
787 init_mad(query->sa_query.mad, agent); 800 mad = query->sa_query.mad_buf->mad;
801 init_mad(mad, agent);
788 802
789 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL; 803 query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
790 query->sa_query.release = ib_sa_mcmember_rec_release; 804 query->sa_query.release = ib_sa_mcmember_rec_release;
791 query->sa_query.port = port; 805 query->sa_query.port = port;
792 query->sa_query.mad->mad_hdr.method = method; 806 mad->mad_hdr.method = method;
793 query->sa_query.mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC); 807 mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC);
794 query->sa_query.mad->sa_hdr.comp_mask = comp_mask; 808 mad->sa_hdr.comp_mask = comp_mask;
795 809
796 ib_pack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table), 810 ib_pack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table),
797 rec, query->sa_query.mad->data); 811 rec, mad->data);
798 812
799 *sa_query = &query->sa_query; 813 *sa_query = &query->sa_query;
800 814
801 ret = send_mad(&query->sa_query, timeout_ms); 815 ret = send_mad(&query->sa_query, timeout_ms);
802 if (ret < 0) { 816 if (ret < 0)
803 *sa_query = NULL; 817 goto err2;
804 kfree(query->sa_query.mad);
805 kfree(query);
806 }
807 818
808 return ret; 819 return ret;
820
821err2:
822 *sa_query = NULL;
823 ib_free_send_mad(query->sa_query.mad_buf);
824
825err1:
826 kfree(query);
827 return ret;
809} 828}
810EXPORT_SYMBOL(ib_sa_mcmember_rec_query); 829EXPORT_SYMBOL(ib_sa_mcmember_rec_query);
811 830
812static void send_handler(struct ib_mad_agent *agent, 831static void send_handler(struct ib_mad_agent *agent,
813 struct ib_mad_send_wc *mad_send_wc) 832 struct ib_mad_send_wc *mad_send_wc)
814{ 833{
815 struct ib_sa_query *query; 834 struct ib_sa_query *query = mad_send_wc->send_buf->context[0];
816 unsigned long flags; 835 unsigned long flags;
817 836
818 spin_lock_irqsave(&idr_lock, flags);
819 query = idr_find(&query_idr, mad_send_wc->wr_id);
820 spin_unlock_irqrestore(&idr_lock, flags);
821
822 if (!query)
823 return;
824
825 if (query->callback) 837 if (query->callback)
826 switch (mad_send_wc->status) { 838 switch (mad_send_wc->status) {
827 case IB_WC_SUCCESS: 839 case IB_WC_SUCCESS:
@@ -838,30 +850,25 @@ static void send_handler(struct ib_mad_agent *agent,
838 break; 850 break;
839 } 851 }
840 852
841 dma_unmap_single(agent->device->dma_device,
842 pci_unmap_addr(query, mapping),
843 sizeof (struct ib_sa_mad),
844 DMA_TO_DEVICE);
845 kref_put(&query->sm_ah->ref, free_sm_ah);
846
847 query->release(query);
848
849 spin_lock_irqsave(&idr_lock, flags); 853 spin_lock_irqsave(&idr_lock, flags);
850 idr_remove(&query_idr, mad_send_wc->wr_id); 854 idr_remove(&query_idr, query->id);
851 spin_unlock_irqrestore(&idr_lock, flags); 855 spin_unlock_irqrestore(&idr_lock, flags);
856
857 ib_free_send_mad(mad_send_wc->send_buf);
858 kref_put(&query->sm_ah->ref, free_sm_ah);
859 query->release(query);
852} 860}
853 861
854static void recv_handler(struct ib_mad_agent *mad_agent, 862static void recv_handler(struct ib_mad_agent *mad_agent,
855 struct ib_mad_recv_wc *mad_recv_wc) 863 struct ib_mad_recv_wc *mad_recv_wc)
856{ 864{
857 struct ib_sa_query *query; 865 struct ib_sa_query *query;
858 unsigned long flags; 866 struct ib_mad_send_buf *mad_buf;
859 867
860 spin_lock_irqsave(&idr_lock, flags); 868 mad_buf = (void *) (unsigned long) mad_recv_wc->wc->wr_id;
861 query = idr_find(&query_idr, mad_recv_wc->wc->wr_id); 869 query = mad_buf->context[0];
862 spin_unlock_irqrestore(&idr_lock, flags);
863 870
864 if (query && query->callback) { 871 if (query->callback) {
865 if (mad_recv_wc->wc->status == IB_WC_SUCCESS) 872 if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
866 query->callback(query, 873 query->callback(query,
867 mad_recv_wc->recv_buf.mad->mad_hdr.status ? 874 mad_recv_wc->recv_buf.mad->mad_hdr.status ?
@@ -975,6 +982,7 @@ static int __init ib_sa_init(void)
975static void __exit ib_sa_cleanup(void) 982static void __exit ib_sa_cleanup(void)
976{ 983{
977 ib_unregister_client(&sa_client); 984 ib_unregister_client(&sa_client);
985 idr_destroy(&query_idr);
978} 986}
979 987
980module_init(ib_sa_init); 988module_init(ib_sa_init);
diff --git a/drivers/infiniband/core/smi.h b/drivers/infiniband/core/smi.h
index db25503a0736..2b3c40198f81 100644
--- a/drivers/infiniband/core/smi.h
+++ b/drivers/infiniband/core/smi.h
@@ -39,6 +39,8 @@
39#ifndef __SMI_H_ 39#ifndef __SMI_H_
40#define __SMI_H_ 40#define __SMI_H_
41 41
42#include <rdma/ib_smi.h>
43
42int smi_handle_dr_smp_recv(struct ib_smp *smp, 44int smi_handle_dr_smp_recv(struct ib_smp *smp,
43 u8 node_type, 45 u8 node_type,
44 int port_num, 46 int port_num,
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 211ba3223f65..7ce7a6c782fa 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -65,6 +65,11 @@ struct port_table_attribute {
65 int index; 65 int index;
66}; 66};
67 67
68static inline int ibdev_is_alive(const struct ib_device *dev)
69{
70 return dev->reg_state == IB_DEV_REGISTERED;
71}
72
68static ssize_t port_attr_show(struct kobject *kobj, 73static ssize_t port_attr_show(struct kobject *kobj,
69 struct attribute *attr, char *buf) 74 struct attribute *attr, char *buf)
70{ 75{
@@ -74,6 +79,8 @@ static ssize_t port_attr_show(struct kobject *kobj,
74 79
75 if (!port_attr->show) 80 if (!port_attr->show)
76 return -EIO; 81 return -EIO;
82 if (!ibdev_is_alive(p->ibdev))
83 return -ENODEV;
77 84
78 return port_attr->show(p, port_attr, buf); 85 return port_attr->show(p, port_attr, buf);
79} 86}
@@ -581,6 +588,9 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
581{ 588{
582 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 589 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
583 590
591 if (!ibdev_is_alive(dev))
592 return -ENODEV;
593
584 switch (dev->node_type) { 594 switch (dev->node_type) {
585 case IB_NODE_CA: return sprintf(buf, "%d: CA\n", dev->node_type); 595 case IB_NODE_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
586 case IB_NODE_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type); 596 case IB_NODE_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
@@ -595,6 +605,9 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
595 struct ib_device_attr attr; 605 struct ib_device_attr attr;
596 ssize_t ret; 606 ssize_t ret;
597 607
608 if (!ibdev_is_alive(dev))
609 return -ENODEV;
610
598 ret = ib_query_device(dev, &attr); 611 ret = ib_query_device(dev, &attr);
599 if (ret) 612 if (ret)
600 return ret; 613 return ret;
@@ -612,6 +625,9 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
612 struct ib_device_attr attr; 625 struct ib_device_attr attr;
613 ssize_t ret; 626 ssize_t ret;
614 627
628 if (!ibdev_is_alive(dev))
629 return -ENODEV;
630
615 ret = ib_query_device(dev, &attr); 631 ret = ib_query_device(dev, &attr);
616 if (ret) 632 if (ret)
617 return ret; 633 return ret;
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index d0f0b0a2edd3..28477565ecba 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -41,37 +41,81 @@
41#include <linux/file.h> 41#include <linux/file.h>
42#include <linux/mount.h> 42#include <linux/mount.h>
43#include <linux/cdev.h> 43#include <linux/cdev.h>
44#include <linux/idr.h>
44 45
45#include <asm/uaccess.h> 46#include <asm/uaccess.h>
46 47
47#include "ucm.h" 48#include <rdma/ib_cm.h>
49#include <rdma/ib_user_cm.h>
48 50
49MODULE_AUTHOR("Libor Michalek"); 51MODULE_AUTHOR("Libor Michalek");
50MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access"); 52MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access");
51MODULE_LICENSE("Dual BSD/GPL"); 53MODULE_LICENSE("Dual BSD/GPL");
52 54
53static int ucm_debug_level; 55struct ib_ucm_device {
56 int devnum;
57 struct cdev dev;
58 struct class_device class_dev;
59 struct ib_device *ib_dev;
60};
61
62struct ib_ucm_file {
63 struct semaphore mutex;
64 struct file *filp;
65 struct ib_ucm_device *device;
66
67 struct list_head ctxs;
68 struct list_head events;
69 wait_queue_head_t poll_wait;
70};
71
72struct ib_ucm_context {
73 int id;
74 wait_queue_head_t wait;
75 atomic_t ref;
76 int events_reported;
77
78 struct ib_ucm_file *file;
79 struct ib_cm_id *cm_id;
80 __u64 uid;
81
82 struct list_head events; /* list of pending events. */
83 struct list_head file_list; /* member in file ctx list */
84};
85
86struct ib_ucm_event {
87 struct ib_ucm_context *ctx;
88 struct list_head file_list; /* member in file event list */
89 struct list_head ctx_list; /* member in ctx event list */
54 90
55module_param_named(debug_level, ucm_debug_level, int, 0644); 91 struct ib_cm_id *cm_id;
56MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0"); 92 struct ib_ucm_event_resp resp;
93 void *data;
94 void *info;
95 int data_len;
96 int info_len;
97};
57 98
58enum { 99enum {
59 IB_UCM_MAJOR = 231, 100 IB_UCM_MAJOR = 231,
60 IB_UCM_MINOR = 255 101 IB_UCM_BASE_MINOR = 224,
102 IB_UCM_MAX_DEVICES = 32
61}; 103};
62 104
63#define IB_UCM_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_MINOR) 105#define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR)
64 106
65#define PFX "UCM: " 107static void ib_ucm_add_one(struct ib_device *device);
108static void ib_ucm_remove_one(struct ib_device *device);
66 109
67#define ucm_dbg(format, arg...) \ 110static struct ib_client ucm_client = {
68 do { \ 111 .name = "ucm",
69 if (ucm_debug_level > 0) \ 112 .add = ib_ucm_add_one,
70 printk(KERN_DEBUG PFX format, ## arg); \ 113 .remove = ib_ucm_remove_one
71 } while (0) 114};
72 115
73static struct semaphore ctx_id_mutex; 116static DECLARE_MUTEX(ctx_id_mutex);
74static struct idr ctx_id_table; 117static DEFINE_IDR(ctx_id_table);
118static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
75 119
76static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) 120static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
77{ 121{
@@ -152,17 +196,13 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
152 goto error; 196 goto error;
153 197
154 list_add_tail(&ctx->file_list, &file->ctxs); 198 list_add_tail(&ctx->file_list, &file->ctxs);
155 ucm_dbg("Allocated CM ID <%d>\n", ctx->id);
156 return ctx; 199 return ctx;
157 200
158error: 201error:
159 kfree(ctx); 202 kfree(ctx);
160 return NULL; 203 return NULL;
161} 204}
162/* 205
163 * Event portion of the API, handle CM events
164 * and allow event polling.
165 */
166static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath, 206static void ib_ucm_event_path_get(struct ib_ucm_path_rec *upath,
167 struct ib_sa_path_rec *kpath) 207 struct ib_sa_path_rec *kpath)
168{ 208{
@@ -209,6 +249,7 @@ static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
209 ureq->retry_count = kreq->retry_count; 249 ureq->retry_count = kreq->retry_count;
210 ureq->rnr_retry_count = kreq->rnr_retry_count; 250 ureq->rnr_retry_count = kreq->rnr_retry_count;
211 ureq->srq = kreq->srq; 251 ureq->srq = kreq->srq;
252 ureq->port = kreq->port;
212 253
213 ib_ucm_event_path_get(&ureq->primary_path, kreq->primary_path); 254 ib_ucm_event_path_get(&ureq->primary_path, kreq->primary_path);
214 ib_ucm_event_path_get(&ureq->alternate_path, kreq->alternate_path); 255 ib_ucm_event_path_get(&ureq->alternate_path, kreq->alternate_path);
@@ -295,6 +336,8 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
295 case IB_CM_SIDR_REQ_RECEIVED: 336 case IB_CM_SIDR_REQ_RECEIVED:
296 uvt->resp.u.sidr_req_resp.pkey = 337 uvt->resp.u.sidr_req_resp.pkey =
297 evt->param.sidr_req_rcvd.pkey; 338 evt->param.sidr_req_rcvd.pkey;
339 uvt->resp.u.sidr_req_resp.port =
340 evt->param.sidr_req_rcvd.port;
298 uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; 341 uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE;
299 break; 342 break;
300 case IB_CM_SIDR_REP_RECEIVED: 343 case IB_CM_SIDR_REP_RECEIVED:
@@ -387,9 +430,7 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
387 430
388 if (copy_from_user(&cmd, inbuf, sizeof(cmd))) 431 if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
389 return -EFAULT; 432 return -EFAULT;
390 /* 433
391 * wait
392 */
393 down(&file->mutex); 434 down(&file->mutex);
394 while (list_empty(&file->events)) { 435 while (list_empty(&file->events)) {
395 436
@@ -471,7 +512,6 @@ done:
471 return result; 512 return result;
472} 513}
473 514
474
475static ssize_t ib_ucm_create_id(struct ib_ucm_file *file, 515static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
476 const char __user *inbuf, 516 const char __user *inbuf,
477 int in_len, int out_len) 517 int in_len, int out_len)
@@ -494,29 +534,27 @@ static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
494 return -ENOMEM; 534 return -ENOMEM;
495 535
496 ctx->uid = cmd.uid; 536 ctx->uid = cmd.uid;
497 ctx->cm_id = ib_create_cm_id(ib_ucm_event_handler, ctx); 537 ctx->cm_id = ib_create_cm_id(file->device->ib_dev,
538 ib_ucm_event_handler, ctx);
498 if (IS_ERR(ctx->cm_id)) { 539 if (IS_ERR(ctx->cm_id)) {
499 result = PTR_ERR(ctx->cm_id); 540 result = PTR_ERR(ctx->cm_id);
500 goto err; 541 goto err1;
501 } 542 }
502 543
503 resp.id = ctx->id; 544 resp.id = ctx->id;
504 if (copy_to_user((void __user *)(unsigned long)cmd.response, 545 if (copy_to_user((void __user *)(unsigned long)cmd.response,
505 &resp, sizeof(resp))) { 546 &resp, sizeof(resp))) {
506 result = -EFAULT; 547 result = -EFAULT;
507 goto err; 548 goto err2;
508 } 549 }
509
510 return 0; 550 return 0;
511 551
512err: 552err2:
553 ib_destroy_cm_id(ctx->cm_id);
554err1:
513 down(&ctx_id_mutex); 555 down(&ctx_id_mutex);
514 idr_remove(&ctx_id_table, ctx->id); 556 idr_remove(&ctx_id_table, ctx->id);
515 up(&ctx_id_mutex); 557 up(&ctx_id_mutex);
516
517 if (!IS_ERR(ctx->cm_id))
518 ib_destroy_cm_id(ctx->cm_id);
519
520 kfree(ctx); 558 kfree(ctx);
521 return result; 559 return result;
522} 560}
@@ -1184,9 +1222,6 @@ static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,
1184 if (copy_from_user(&hdr, buf, sizeof(hdr))) 1222 if (copy_from_user(&hdr, buf, sizeof(hdr)))
1185 return -EFAULT; 1223 return -EFAULT;
1186 1224
1187 ucm_dbg("Write. cmd <%d> in <%d> out <%d> len <%Zu>\n",
1188 hdr.cmd, hdr.in, hdr.out, len);
1189
1190 if (hdr.cmd < 0 || hdr.cmd >= ARRAY_SIZE(ucm_cmd_table)) 1225 if (hdr.cmd < 0 || hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))
1191 return -EINVAL; 1226 return -EINVAL;
1192 1227
@@ -1231,8 +1266,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
1231 1266
1232 filp->private_data = file; 1267 filp->private_data = file;
1233 file->filp = filp; 1268 file->filp = filp;
1234 1269 file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev);
1235 ucm_dbg("Created struct\n");
1236 1270
1237 return 0; 1271 return 0;
1238} 1272}
@@ -1263,7 +1297,17 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
1263 return 0; 1297 return 0;
1264} 1298}
1265 1299
1266static struct file_operations ib_ucm_fops = { 1300static void ib_ucm_release_class_dev(struct class_device *class_dev)
1301{
1302 struct ib_ucm_device *dev;
1303
1304 dev = container_of(class_dev, struct ib_ucm_device, class_dev);
1305 cdev_del(&dev->dev);
1306 clear_bit(dev->devnum, dev_map);
1307 kfree(dev);
1308}
1309
1310static struct file_operations ucm_fops = {
1267 .owner = THIS_MODULE, 1311 .owner = THIS_MODULE,
1268 .open = ib_ucm_open, 1312 .open = ib_ucm_open,
1269 .release = ib_ucm_close, 1313 .release = ib_ucm_close,
@@ -1271,55 +1315,142 @@ static struct file_operations ib_ucm_fops = {
1271 .poll = ib_ucm_poll, 1315 .poll = ib_ucm_poll,
1272}; 1316};
1273 1317
1318static struct class ucm_class = {
1319 .name = "infiniband_cm",
1320 .release = ib_ucm_release_class_dev
1321};
1274 1322
1275static struct class *ib_ucm_class; 1323static ssize_t show_dev(struct class_device *class_dev, char *buf)
1276static struct cdev ib_ucm_cdev; 1324{
1325 struct ib_ucm_device *dev;
1326
1327 dev = container_of(class_dev, struct ib_ucm_device, class_dev);
1328 return print_dev_t(buf, dev->dev.dev);
1329}
1330static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
1277 1331
1278static int __init ib_ucm_init(void) 1332static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
1279{ 1333{
1280 int result; 1334 struct ib_ucm_device *dev;
1335
1336 dev = container_of(class_dev, struct ib_ucm_device, class_dev);
1337 return sprintf(buf, "%s\n", dev->ib_dev->name);
1338}
1339static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1281 1340
1282 result = register_chrdev_region(IB_UCM_DEV, 1, "infiniband_cm"); 1341static void ib_ucm_add_one(struct ib_device *device)
1283 if (result) { 1342{
1284 ucm_dbg("Error <%d> registering dev\n", result); 1343 struct ib_ucm_device *ucm_dev;
1285 goto err_chr; 1344
1286 } 1345 if (!device->alloc_ucontext)
1346 return;
1347
1348 ucm_dev = kmalloc(sizeof *ucm_dev, GFP_KERNEL);
1349 if (!ucm_dev)
1350 return;
1287 1351
1288 cdev_init(&ib_ucm_cdev, &ib_ucm_fops); 1352 memset(ucm_dev, 0, sizeof *ucm_dev);
1353 ucm_dev->ib_dev = device;
1354
1355 ucm_dev->devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES);
1356 if (ucm_dev->devnum >= IB_UCM_MAX_DEVICES)
1357 goto err;
1358
1359 set_bit(ucm_dev->devnum, dev_map);
1360
1361 cdev_init(&ucm_dev->dev, &ucm_fops);
1362 ucm_dev->dev.owner = THIS_MODULE;
1363 kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum);
1364 if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
1365 goto err;
1289 1366
1290 result = cdev_add(&ib_ucm_cdev, IB_UCM_DEV, 1); 1367 ucm_dev->class_dev.class = &ucm_class;
1291 if (result) { 1368 ucm_dev->class_dev.dev = device->dma_device;
1292 ucm_dbg("Error <%d> adding cdev\n", result); 1369 snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d",
1370 ucm_dev->devnum);
1371 if (class_device_register(&ucm_dev->class_dev))
1293 goto err_cdev; 1372 goto err_cdev;
1294 }
1295 1373
1296 ib_ucm_class = class_create(THIS_MODULE, "infiniband_cm"); 1374 if (class_device_create_file(&ucm_dev->class_dev,
1297 if (IS_ERR(ib_ucm_class)) { 1375 &class_device_attr_dev))
1298 result = PTR_ERR(ib_ucm_class); 1376 goto err_class;
1299 ucm_dbg("Error <%d> creating class\n", result); 1377 if (class_device_create_file(&ucm_dev->class_dev,
1378 &class_device_attr_ibdev))
1300 goto err_class; 1379 goto err_class;
1380
1381 ib_set_client_data(device, &ucm_client, ucm_dev);
1382 return;
1383
1384err_class:
1385 class_device_unregister(&ucm_dev->class_dev);
1386err_cdev:
1387 cdev_del(&ucm_dev->dev);
1388 clear_bit(ucm_dev->devnum, dev_map);
1389err:
1390 kfree(ucm_dev);
1391 return;
1392}
1393
1394static void ib_ucm_remove_one(struct ib_device *device)
1395{
1396 struct ib_ucm_device *ucm_dev = ib_get_client_data(device, &ucm_client);
1397
1398 if (!ucm_dev)
1399 return;
1400
1401 class_device_unregister(&ucm_dev->class_dev);
1402}
1403
1404static ssize_t show_abi_version(struct class *class, char *buf)
1405{
1406 return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
1407}
1408static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
1409
1410static int __init ib_ucm_init(void)
1411{
1412 int ret;
1413
1414 ret = register_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES,
1415 "infiniband_cm");
1416 if (ret) {
1417 printk(KERN_ERR "ucm: couldn't register device number\n");
1418 goto err;
1301 } 1419 }
1302 1420
1303 class_device_create(ib_ucm_class, IB_UCM_DEV, NULL, "ucm"); 1421 ret = class_register(&ucm_class);
1422 if (ret) {
1423 printk(KERN_ERR "ucm: couldn't create class infiniband_cm\n");
1424 goto err_chrdev;
1425 }
1304 1426
1305 idr_init(&ctx_id_table); 1427 ret = class_create_file(&ucm_class, &class_attr_abi_version);
1306 init_MUTEX(&ctx_id_mutex); 1428 if (ret) {
1429 printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
1430 goto err_class;
1431 }
1307 1432
1433 ret = ib_register_client(&ucm_client);
1434 if (ret) {
1435 printk(KERN_ERR "ucm: couldn't register client\n");
1436 goto err_class;
1437 }
1308 return 0; 1438 return 0;
1439
1309err_class: 1440err_class:
1310 cdev_del(&ib_ucm_cdev); 1441 class_unregister(&ucm_class);
1311err_cdev: 1442err_chrdev:
1312 unregister_chrdev_region(IB_UCM_DEV, 1); 1443 unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
1313err_chr: 1444err:
1314 return result; 1445 return ret;
1315} 1446}
1316 1447
1317static void __exit ib_ucm_cleanup(void) 1448static void __exit ib_ucm_cleanup(void)
1318{ 1449{
1319 class_device_destroy(ib_ucm_class, IB_UCM_DEV); 1450 ib_unregister_client(&ucm_client);
1320 class_destroy(ib_ucm_class); 1451 class_unregister(&ucm_class);
1321 cdev_del(&ib_ucm_cdev); 1452 unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
1322 unregister_chrdev_region(IB_UCM_DEV, 1); 1453 idr_destroy(&ctx_id_table);
1323} 1454}
1324 1455
1325module_init(ib_ucm_init); 1456module_init(ib_ucm_init);
diff --git a/drivers/infiniband/core/ucm.h b/drivers/infiniband/core/ucm.h
deleted file mode 100644
index f46f37bc1201..000000000000
--- a/drivers/infiniband/core/ucm.h
+++ /dev/null
@@ -1,83 +0,0 @@
1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 *
33 * $Id: ucm.h 2208 2005-04-22 23:24:31Z libor $
34 */
35
36#ifndef UCM_H
37#define UCM_H
38
39#include <linux/fs.h>
40#include <linux/device.h>
41#include <linux/cdev.h>
42#include <linux/idr.h>
43
44#include <rdma/ib_cm.h>
45#include <rdma/ib_user_cm.h>
46
47struct ib_ucm_file {
48 struct semaphore mutex;
49 struct file *filp;
50
51 struct list_head ctxs; /* list of active connections */
52 struct list_head events; /* list of pending events */
53 wait_queue_head_t poll_wait;
54};
55
56struct ib_ucm_context {
57 int id;
58 wait_queue_head_t wait;
59 atomic_t ref;
60 int events_reported;
61
62 struct ib_ucm_file *file;
63 struct ib_cm_id *cm_id;
64 __u64 uid;
65
66 struct list_head events; /* list of pending events. */
67 struct list_head file_list; /* member in file ctx list */
68};
69
70struct ib_ucm_event {
71 struct ib_ucm_context *ctx;
72 struct list_head file_list; /* member in file event list */
73 struct list_head ctx_list; /* member in ctx event list */
74
75 struct ib_cm_id *cm_id;
76 struct ib_ucm_event_resp resp;
77 void *data;
78 void *info;
79 int data_len;
80 int info_len;
81};
82
83#endif /* UCM_H */
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index a64d6b4dcc16..97128e25f78b 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -64,18 +64,39 @@ enum {
64 IB_UMAD_MINOR_BASE = 0 64 IB_UMAD_MINOR_BASE = 0
65}; 65};
66 66
67/*
68 * Our lifetime rules for these structs are the following: each time a
69 * device special file is opened, we look up the corresponding struct
70 * ib_umad_port by minor in the umad_port[] table while holding the
71 * port_lock. If this lookup succeeds, we take a reference on the
72 * ib_umad_port's struct ib_umad_device while still holding the
73 * port_lock; if the lookup fails, we fail the open(). We drop these
74 * references in the corresponding close().
75 *
76 * In addition to references coming from open character devices, there
77 * is one more reference to each ib_umad_device representing the
78 * module's reference taken when allocating the ib_umad_device in
79 * ib_umad_add_one().
80 *
81 * When destroying an ib_umad_device, we clear all of its
82 * ib_umad_ports from umad_port[] while holding port_lock before
83 * dropping the module's reference to the ib_umad_device. This is
84 * always safe because any open() calls will either succeed and obtain
85 * a reference before we clear the umad_port[] entries, or fail after
86 * we clear the umad_port[] entries.
87 */
88
67struct ib_umad_port { 89struct ib_umad_port {
68 int devnum; 90 struct cdev *dev;
69 struct cdev dev; 91 struct class_device *class_dev;
70 struct class_device class_dev;
71 92
72 int sm_devnum; 93 struct cdev *sm_dev;
73 struct cdev sm_dev; 94 struct class_device *sm_class_dev;
74 struct class_device sm_class_dev;
75 struct semaphore sm_sem; 95 struct semaphore sm_sem;
76 96
77 struct ib_device *ib_dev; 97 struct ib_device *ib_dev;
78 struct ib_umad_device *umad_dev; 98 struct ib_umad_device *umad_dev;
99 int dev_num;
79 u8 port_num; 100 u8 port_num;
80}; 101};
81 102
@@ -96,21 +117,31 @@ struct ib_umad_file {
96}; 117};
97 118
98struct ib_umad_packet { 119struct ib_umad_packet {
99 struct ib_ah *ah;
100 struct ib_mad_send_buf *msg; 120 struct ib_mad_send_buf *msg;
101 struct list_head list; 121 struct list_head list;
102 int length; 122 int length;
103 DECLARE_PCI_UNMAP_ADDR(mapping)
104 struct ib_user_mad mad; 123 struct ib_user_mad mad;
105}; 124};
106 125
126static struct class *umad_class;
127
107static const dev_t base_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE); 128static const dev_t base_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE);
108static spinlock_t map_lock; 129
130static DEFINE_SPINLOCK(port_lock);
131static struct ib_umad_port *umad_port[IB_UMAD_MAX_PORTS];
109static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS * 2); 132static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS * 2);
110 133
111static void ib_umad_add_one(struct ib_device *device); 134static void ib_umad_add_one(struct ib_device *device);
112static void ib_umad_remove_one(struct ib_device *device); 135static void ib_umad_remove_one(struct ib_device *device);
113 136
137static void ib_umad_release_dev(struct kref *ref)
138{
139 struct ib_umad_device *dev =
140 container_of(ref, struct ib_umad_device, ref);
141
142 kfree(dev);
143}
144
114static int queue_packet(struct ib_umad_file *file, 145static int queue_packet(struct ib_umad_file *file,
115 struct ib_mad_agent *agent, 146 struct ib_mad_agent *agent,
116 struct ib_umad_packet *packet) 147 struct ib_umad_packet *packet)
@@ -139,22 +170,19 @@ static void send_handler(struct ib_mad_agent *agent,
139 struct ib_mad_send_wc *send_wc) 170 struct ib_mad_send_wc *send_wc)
140{ 171{
141 struct ib_umad_file *file = agent->context; 172 struct ib_umad_file *file = agent->context;
142 struct ib_umad_packet *timeout, *packet = 173 struct ib_umad_packet *timeout;
143 (void *) (unsigned long) send_wc->wr_id; 174 struct ib_umad_packet *packet = send_wc->send_buf->context[0];
144 175
145 ib_destroy_ah(packet->msg->send_wr.wr.ud.ah); 176 ib_destroy_ah(packet->msg->ah);
146 ib_free_send_mad(packet->msg); 177 ib_free_send_mad(packet->msg);
147 178
148 if (send_wc->status == IB_WC_RESP_TIMEOUT_ERR) { 179 if (send_wc->status == IB_WC_RESP_TIMEOUT_ERR) {
149 timeout = kmalloc(sizeof *timeout + sizeof (struct ib_mad_hdr), 180 timeout = kzalloc(sizeof *timeout + IB_MGMT_MAD_HDR, GFP_KERNEL);
150 GFP_KERNEL);
151 if (!timeout) 181 if (!timeout)
152 goto out; 182 goto out;
153 183
154 memset(timeout, 0, sizeof *timeout + sizeof (struct ib_mad_hdr)); 184 timeout->length = IB_MGMT_MAD_HDR;
155 185 timeout->mad.hdr.id = packet->mad.hdr.id;
156 timeout->length = sizeof (struct ib_mad_hdr);
157 timeout->mad.hdr.id = packet->mad.hdr.id;
158 timeout->mad.hdr.status = ETIMEDOUT; 186 timeout->mad.hdr.status = ETIMEDOUT;
159 memcpy(timeout->mad.data, packet->mad.data, 187 memcpy(timeout->mad.data, packet->mad.data,
160 sizeof (struct ib_mad_hdr)); 188 sizeof (struct ib_mad_hdr));
@@ -177,11 +205,10 @@ static void recv_handler(struct ib_mad_agent *agent,
177 goto out; 205 goto out;
178 206
179 length = mad_recv_wc->mad_len; 207 length = mad_recv_wc->mad_len;
180 packet = kmalloc(sizeof *packet + length, GFP_KERNEL); 208 packet = kzalloc(sizeof *packet + length, GFP_KERNEL);
181 if (!packet) 209 if (!packet)
182 goto out; 210 goto out;
183 211
184 memset(packet, 0, sizeof *packet + length);
185 packet->length = length; 212 packet->length = length;
186 213
187 ib_coalesce_recv_mad(mad_recv_wc, packet->mad.data); 214 ib_coalesce_recv_mad(mad_recv_wc, packet->mad.data);
@@ -247,7 +274,7 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf,
247 else 274 else
248 ret = -ENOSPC; 275 ret = -ENOSPC;
249 } else if (copy_to_user(buf, &packet->mad, 276 } else if (copy_to_user(buf, &packet->mad,
250 packet->length + sizeof (struct ib_user_mad))) 277 packet->length + sizeof (struct ib_user_mad)))
251 ret = -EFAULT; 278 ret = -EFAULT;
252 else 279 else
253 ret = packet->length + sizeof (struct ib_user_mad); 280 ret = packet->length + sizeof (struct ib_user_mad);
@@ -268,26 +295,23 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
268 struct ib_umad_packet *packet; 295 struct ib_umad_packet *packet;
269 struct ib_mad_agent *agent; 296 struct ib_mad_agent *agent;
270 struct ib_ah_attr ah_attr; 297 struct ib_ah_attr ah_attr;
271 struct ib_send_wr *bad_wr; 298 struct ib_ah *ah;
272 struct ib_rmpp_mad *rmpp_mad; 299 struct ib_rmpp_mad *rmpp_mad;
273 u8 method; 300 u8 method;
274 __be64 *tid; 301 __be64 *tid;
275 int ret, length, hdr_len, data_len, rmpp_hdr_size; 302 int ret, length, hdr_len, copy_offset;
276 int rmpp_active = 0; 303 int rmpp_active = 0;
277 304
278 if (count < sizeof (struct ib_user_mad)) 305 if (count < sizeof (struct ib_user_mad))
279 return -EINVAL; 306 return -EINVAL;
280 307
281 length = count - sizeof (struct ib_user_mad); 308 length = count - sizeof (struct ib_user_mad);
282 packet = kmalloc(sizeof *packet + sizeof(struct ib_mad_hdr) + 309 packet = kmalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL);
283 sizeof(struct ib_rmpp_hdr), GFP_KERNEL);
284 if (!packet) 310 if (!packet)
285 return -ENOMEM; 311 return -ENOMEM;
286 312
287 if (copy_from_user(&packet->mad, buf, 313 if (copy_from_user(&packet->mad, buf,
288 sizeof (struct ib_user_mad) + 314 sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR)) {
289 sizeof(struct ib_mad_hdr) +
290 sizeof(struct ib_rmpp_hdr))) {
291 ret = -EFAULT; 315 ret = -EFAULT;
292 goto err; 316 goto err;
293 } 317 }
@@ -298,8 +322,6 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
298 goto err; 322 goto err;
299 } 323 }
300 324
301 packet->length = length;
302
303 down_read(&file->agent_mutex); 325 down_read(&file->agent_mutex);
304 326
305 agent = file->agent[packet->mad.hdr.id]; 327 agent = file->agent[packet->mad.hdr.id];
@@ -321,9 +343,9 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
321 ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class; 343 ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class;
322 } 344 }
323 345
324 packet->ah = ib_create_ah(agent->qp->pd, &ah_attr); 346 ah = ib_create_ah(agent->qp->pd, &ah_attr);
325 if (IS_ERR(packet->ah)) { 347 if (IS_ERR(ah)) {
326 ret = PTR_ERR(packet->ah); 348 ret = PTR_ERR(ah);
327 goto err_up; 349 goto err_up;
328 } 350 }
329 351
@@ -337,64 +359,44 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
337 359
338 /* Validate that the management class can support RMPP */ 360 /* Validate that the management class can support RMPP */
339 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) { 361 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
340 hdr_len = offsetof(struct ib_sa_mad, data); 362 hdr_len = IB_MGMT_SA_HDR;
341 data_len = length - hdr_len;
342 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) && 363 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
343 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) { 364 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) {
344 hdr_len = offsetof(struct ib_vendor_mad, data); 365 hdr_len = IB_MGMT_VENDOR_HDR;
345 data_len = length - hdr_len;
346 } else { 366 } else {
347 ret = -EINVAL; 367 ret = -EINVAL;
348 goto err_ah; 368 goto err_ah;
349 } 369 }
350 rmpp_active = 1; 370 rmpp_active = 1;
371 copy_offset = IB_MGMT_RMPP_HDR;
351 } else { 372 } else {
352 if (length > sizeof(struct ib_mad)) { 373 hdr_len = IB_MGMT_MAD_HDR;
353 ret = -EINVAL; 374 copy_offset = IB_MGMT_MAD_HDR;
354 goto err_ah;
355 }
356 hdr_len = offsetof(struct ib_mad, data);
357 data_len = length - hdr_len;
358 } 375 }
359 376
360 packet->msg = ib_create_send_mad(agent, 377 packet->msg = ib_create_send_mad(agent,
361 be32_to_cpu(packet->mad.hdr.qpn), 378 be32_to_cpu(packet->mad.hdr.qpn),
362 0, packet->ah, rmpp_active, 379 0, rmpp_active,
363 hdr_len, data_len, 380 hdr_len, length - hdr_len,
364 GFP_KERNEL); 381 GFP_KERNEL);
365 if (IS_ERR(packet->msg)) { 382 if (IS_ERR(packet->msg)) {
366 ret = PTR_ERR(packet->msg); 383 ret = PTR_ERR(packet->msg);
367 goto err_ah; 384 goto err_ah;
368 } 385 }
369 386
370 packet->msg->send_wr.wr.ud.timeout_ms = packet->mad.hdr.timeout_ms; 387 packet->msg->ah = ah;
371 packet->msg->send_wr.wr.ud.retries = packet->mad.hdr.retries; 388 packet->msg->timeout_ms = packet->mad.hdr.timeout_ms;
372 389 packet->msg->retries = packet->mad.hdr.retries;
373 /* Override send WR WRID initialized in ib_create_send_mad */ 390 packet->msg->context[0] = packet;
374 packet->msg->send_wr.wr_id = (unsigned long) packet;
375
376 if (!rmpp_active) {
377 /* Copy message from user into send buffer */
378 if (copy_from_user(packet->msg->mad,
379 buf + sizeof(struct ib_user_mad), length)) {
380 ret = -EFAULT;
381 goto err_msg;
382 }
383 } else {
384 rmpp_hdr_size = sizeof(struct ib_mad_hdr) +
385 sizeof(struct ib_rmpp_hdr);
386 391
387 /* Only copy MAD headers (RMPP header in place) */ 392 /* Copy MAD headers (RMPP header in place) */
388 memcpy(packet->msg->mad, packet->mad.data, 393 memcpy(packet->msg->mad, packet->mad.data, IB_MGMT_MAD_HDR);
389 sizeof(struct ib_mad_hdr)); 394 /* Now, copy rest of message from user into send buffer */
390 395 if (copy_from_user(packet->msg->mad + copy_offset,
391 /* Now, copy rest of message from user into send buffer */ 396 buf + sizeof (struct ib_user_mad) + copy_offset,
392 if (copy_from_user(((struct ib_rmpp_mad *) packet->msg->mad)->data, 397 length - copy_offset)) {
393 buf + sizeof (struct ib_user_mad) + rmpp_hdr_size, 398 ret = -EFAULT;
394 length - rmpp_hdr_size)) { 399 goto err_msg;
395 ret = -EFAULT;
396 goto err_msg;
397 }
398 } 400 }
399 401
400 /* 402 /*
@@ -403,29 +405,29 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
403 * transaction ID matches the agent being used to send the 405 * transaction ID matches the agent being used to send the
404 * MAD. 406 * MAD.
405 */ 407 */
406 method = packet->msg->mad->mad_hdr.method; 408 method = ((struct ib_mad_hdr *) packet->msg->mad)->method;
407 409
408 if (!(method & IB_MGMT_METHOD_RESP) && 410 if (!(method & IB_MGMT_METHOD_RESP) &&
409 method != IB_MGMT_METHOD_TRAP_REPRESS && 411 method != IB_MGMT_METHOD_TRAP_REPRESS &&
410 method != IB_MGMT_METHOD_SEND) { 412 method != IB_MGMT_METHOD_SEND) {
411 tid = &packet->msg->mad->mad_hdr.tid; 413 tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
412 *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 | 414 *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
413 (be64_to_cpup(tid) & 0xffffffff)); 415 (be64_to_cpup(tid) & 0xffffffff));
414 } 416 }
415 417
416 ret = ib_post_send_mad(agent, &packet->msg->send_wr, &bad_wr); 418 ret = ib_post_send_mad(packet->msg, NULL);
417 if (ret) 419 if (ret)
418 goto err_msg; 420 goto err_msg;
419 421
420 up_read(&file->agent_mutex); 422 up_read(&file->agent_mutex);
421 423
422 return sizeof (struct ib_user_mad_hdr) + packet->length; 424 return count;
423 425
424err_msg: 426err_msg:
425 ib_free_send_mad(packet->msg); 427 ib_free_send_mad(packet->msg);
426 428
427err_ah: 429err_ah:
428 ib_destroy_ah(packet->ah); 430 ib_destroy_ah(ah);
429 431
430err_up: 432err_up:
431 up_read(&file->agent_mutex); 433 up_read(&file->agent_mutex);
@@ -565,15 +567,23 @@ static long ib_umad_ioctl(struct file *filp, unsigned int cmd,
565 567
566static int ib_umad_open(struct inode *inode, struct file *filp) 568static int ib_umad_open(struct inode *inode, struct file *filp)
567{ 569{
568 struct ib_umad_port *port = 570 struct ib_umad_port *port;
569 container_of(inode->i_cdev, struct ib_umad_port, dev);
570 struct ib_umad_file *file; 571 struct ib_umad_file *file;
571 572
572 file = kmalloc(sizeof *file, GFP_KERNEL); 573 spin_lock(&port_lock);
573 if (!file) 574 port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE];
574 return -ENOMEM; 575 if (port)
576 kref_get(&port->umad_dev->ref);
577 spin_unlock(&port_lock);
575 578
576 memset(file, 0, sizeof *file); 579 if (!port)
580 return -ENXIO;
581
582 file = kzalloc(sizeof *file, GFP_KERNEL);
583 if (!file) {
584 kref_put(&port->umad_dev->ref, ib_umad_release_dev);
585 return -ENOMEM;
586 }
577 587
578 spin_lock_init(&file->recv_lock); 588 spin_lock_init(&file->recv_lock);
579 init_rwsem(&file->agent_mutex); 589 init_rwsem(&file->agent_mutex);
@@ -589,6 +599,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
589static int ib_umad_close(struct inode *inode, struct file *filp) 599static int ib_umad_close(struct inode *inode, struct file *filp)
590{ 600{
591 struct ib_umad_file *file = filp->private_data; 601 struct ib_umad_file *file = filp->private_data;
602 struct ib_umad_device *dev = file->port->umad_dev;
592 struct ib_umad_packet *packet, *tmp; 603 struct ib_umad_packet *packet, *tmp;
593 int i; 604 int i;
594 605
@@ -603,6 +614,8 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
603 614
604 kfree(file); 615 kfree(file);
605 616
617 kref_put(&dev->ref, ib_umad_release_dev);
618
606 return 0; 619 return 0;
607} 620}
608 621
@@ -619,30 +632,46 @@ static struct file_operations umad_fops = {
619 632
620static int ib_umad_sm_open(struct inode *inode, struct file *filp) 633static int ib_umad_sm_open(struct inode *inode, struct file *filp)
621{ 634{
622 struct ib_umad_port *port = 635 struct ib_umad_port *port;
623 container_of(inode->i_cdev, struct ib_umad_port, sm_dev);
624 struct ib_port_modify props = { 636 struct ib_port_modify props = {
625 .set_port_cap_mask = IB_PORT_SM 637 .set_port_cap_mask = IB_PORT_SM
626 }; 638 };
627 int ret; 639 int ret;
628 640
641 spin_lock(&port_lock);
642 port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE - IB_UMAD_MAX_PORTS];
643 if (port)
644 kref_get(&port->umad_dev->ref);
645 spin_unlock(&port_lock);
646
647 if (!port)
648 return -ENXIO;
649
629 if (filp->f_flags & O_NONBLOCK) { 650 if (filp->f_flags & O_NONBLOCK) {
630 if (down_trylock(&port->sm_sem)) 651 if (down_trylock(&port->sm_sem)) {
631 return -EAGAIN; 652 ret = -EAGAIN;
653 goto fail;
654 }
632 } else { 655 } else {
633 if (down_interruptible(&port->sm_sem)) 656 if (down_interruptible(&port->sm_sem)) {
634 return -ERESTARTSYS; 657 ret = -ERESTARTSYS;
658 goto fail;
659 }
635 } 660 }
636 661
637 ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props); 662 ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
638 if (ret) { 663 if (ret) {
639 up(&port->sm_sem); 664 up(&port->sm_sem);
640 return ret; 665 goto fail;
641 } 666 }
642 667
643 filp->private_data = port; 668 filp->private_data = port;
644 669
645 return 0; 670 return 0;
671
672fail:
673 kref_put(&port->umad_dev->ref, ib_umad_release_dev);
674 return ret;
646} 675}
647 676
648static int ib_umad_sm_close(struct inode *inode, struct file *filp) 677static int ib_umad_sm_close(struct inode *inode, struct file *filp)
@@ -656,6 +685,8 @@ static int ib_umad_sm_close(struct inode *inode, struct file *filp)
656 ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props); 685 ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
657 up(&port->sm_sem); 686 up(&port->sm_sem);
658 687
688 kref_put(&port->umad_dev->ref, ib_umad_release_dev);
689
659 return ret; 690 return ret;
660} 691}
661 692
@@ -671,21 +702,13 @@ static struct ib_client umad_client = {
671 .remove = ib_umad_remove_one 702 .remove = ib_umad_remove_one
672}; 703};
673 704
674static ssize_t show_dev(struct class_device *class_dev, char *buf)
675{
676 struct ib_umad_port *port = class_get_devdata(class_dev);
677
678 if (class_dev == &port->class_dev)
679 return print_dev_t(buf, port->dev.dev);
680 else
681 return print_dev_t(buf, port->sm_dev.dev);
682}
683static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
684
685static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 705static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
686{ 706{
687 struct ib_umad_port *port = class_get_devdata(class_dev); 707 struct ib_umad_port *port = class_get_devdata(class_dev);
688 708
709 if (!port)
710 return -ENODEV;
711
689 return sprintf(buf, "%s\n", port->ib_dev->name); 712 return sprintf(buf, "%s\n", port->ib_dev->name);
690} 713}
691static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 714static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
@@ -694,38 +717,13 @@ static ssize_t show_port(struct class_device *class_dev, char *buf)
694{ 717{
695 struct ib_umad_port *port = class_get_devdata(class_dev); 718 struct ib_umad_port *port = class_get_devdata(class_dev);
696 719
720 if (!port)
721 return -ENODEV;
722
697 return sprintf(buf, "%d\n", port->port_num); 723 return sprintf(buf, "%d\n", port->port_num);
698} 724}
699static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 725static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
700 726
701static void ib_umad_release_dev(struct kref *ref)
702{
703 struct ib_umad_device *dev =
704 container_of(ref, struct ib_umad_device, ref);
705
706 kfree(dev);
707}
708
709static void ib_umad_release_port(struct class_device *class_dev)
710{
711 struct ib_umad_port *port = class_get_devdata(class_dev);
712
713 if (class_dev == &port->class_dev) {
714 cdev_del(&port->dev);
715 clear_bit(port->devnum, dev_map);
716 } else {
717 cdev_del(&port->sm_dev);
718 clear_bit(port->sm_devnum, dev_map);
719 }
720
721 kref_put(&port->umad_dev->ref, ib_umad_release_dev);
722}
723
724static struct class umad_class = {
725 .name = "infiniband_mad",
726 .release = ib_umad_release_port
727};
728
729static ssize_t show_abi_version(struct class *class, char *buf) 727static ssize_t show_abi_version(struct class *class, char *buf)
730{ 728{
731 return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION); 729 return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
@@ -735,91 +733,102 @@ static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
735static int ib_umad_init_port(struct ib_device *device, int port_num, 733static int ib_umad_init_port(struct ib_device *device, int port_num,
736 struct ib_umad_port *port) 734 struct ib_umad_port *port)
737{ 735{
738 spin_lock(&map_lock); 736 spin_lock(&port_lock);
739 port->devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS); 737 port->dev_num = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS);
740 if (port->devnum >= IB_UMAD_MAX_PORTS) { 738 if (port->dev_num >= IB_UMAD_MAX_PORTS) {
741 spin_unlock(&map_lock); 739 spin_unlock(&port_lock);
742 return -1; 740 return -1;
743 } 741 }
744 port->sm_devnum = find_next_zero_bit(dev_map, IB_UMAD_MAX_PORTS * 2, IB_UMAD_MAX_PORTS); 742 set_bit(port->dev_num, dev_map);
745 if (port->sm_devnum >= IB_UMAD_MAX_PORTS * 2) { 743 spin_unlock(&port_lock);
746 spin_unlock(&map_lock);
747 return -1;
748 }
749 set_bit(port->devnum, dev_map);
750 set_bit(port->sm_devnum, dev_map);
751 spin_unlock(&map_lock);
752 744
753 port->ib_dev = device; 745 port->ib_dev = device;
754 port->port_num = port_num; 746 port->port_num = port_num;
755 init_MUTEX(&port->sm_sem); 747 init_MUTEX(&port->sm_sem);
756 748
757 cdev_init(&port->dev, &umad_fops); 749 port->dev = cdev_alloc();
758 port->dev.owner = THIS_MODULE; 750 if (!port->dev)
759 kobject_set_name(&port->dev.kobj, "umad%d", port->devnum);
760 if (cdev_add(&port->dev, base_dev + port->devnum, 1))
761 return -1; 751 return -1;
762 752 port->dev->owner = THIS_MODULE;
763 port->class_dev.class = &umad_class; 753 port->dev->ops = &umad_fops;
764 port->class_dev.dev = device->dma_device; 754 kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num);
765 755 if (cdev_add(port->dev, base_dev + port->dev_num, 1))
766 snprintf(port->class_dev.class_id, BUS_ID_SIZE, "umad%d", port->devnum);
767
768 if (class_device_register(&port->class_dev))
769 goto err_cdev; 756 goto err_cdev;
770 757
771 class_set_devdata(&port->class_dev, port); 758 port->class_dev = class_device_create(umad_class, NULL, port->dev->dev,
772 kref_get(&port->umad_dev->ref); 759 device->dma_device,
760 "umad%d", port->dev_num);
761 if (IS_ERR(port->class_dev))
762 goto err_cdev;
773 763
774 if (class_device_create_file(&port->class_dev, &class_device_attr_dev)) 764 if (class_device_create_file(port->class_dev, &class_device_attr_ibdev))
775 goto err_class;
776 if (class_device_create_file(&port->class_dev, &class_device_attr_ibdev))
777 goto err_class; 765 goto err_class;
778 if (class_device_create_file(&port->class_dev, &class_device_attr_port)) 766 if (class_device_create_file(port->class_dev, &class_device_attr_port))
779 goto err_class; 767 goto err_class;
780 768
781 cdev_init(&port->sm_dev, &umad_sm_fops); 769 port->sm_dev = cdev_alloc();
782 port->sm_dev.owner = THIS_MODULE; 770 if (!port->sm_dev)
783 kobject_set_name(&port->dev.kobj, "issm%d", port->sm_devnum - IB_UMAD_MAX_PORTS); 771 goto err_class;
784 if (cdev_add(&port->sm_dev, base_dev + port->sm_devnum, 1)) 772 port->sm_dev->owner = THIS_MODULE;
785 return -1; 773 port->sm_dev->ops = &umad_sm_fops;
786 774 kobject_set_name(&port->dev->kobj, "issm%d", port->dev_num);
787 port->sm_class_dev.class = &umad_class; 775 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
788 port->sm_class_dev.dev = device->dma_device; 776 goto err_sm_cdev;
789
790 snprintf(port->sm_class_dev.class_id, BUS_ID_SIZE, "issm%d", port->sm_devnum - IB_UMAD_MAX_PORTS);
791 777
792 if (class_device_register(&port->sm_class_dev)) 778 port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev,
779 device->dma_device,
780 "issm%d", port->dev_num);
781 if (IS_ERR(port->sm_class_dev))
793 goto err_sm_cdev; 782 goto err_sm_cdev;
794 783
795 class_set_devdata(&port->sm_class_dev, port); 784 class_set_devdata(port->class_dev, port);
796 kref_get(&port->umad_dev->ref); 785 class_set_devdata(port->sm_class_dev, port);
797 786
798 if (class_device_create_file(&port->sm_class_dev, &class_device_attr_dev)) 787 if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev))
799 goto err_sm_class;
800 if (class_device_create_file(&port->sm_class_dev, &class_device_attr_ibdev))
801 goto err_sm_class; 788 goto err_sm_class;
802 if (class_device_create_file(&port->sm_class_dev, &class_device_attr_port)) 789 if (class_device_create_file(port->sm_class_dev, &class_device_attr_port))
803 goto err_sm_class; 790 goto err_sm_class;
804 791
792 spin_lock(&port_lock);
793 umad_port[port->dev_num] = port;
794 spin_unlock(&port_lock);
795
805 return 0; 796 return 0;
806 797
807err_sm_class: 798err_sm_class:
808 class_device_unregister(&port->sm_class_dev); 799 class_device_destroy(umad_class, port->sm_dev->dev);
809 800
810err_sm_cdev: 801err_sm_cdev:
811 cdev_del(&port->sm_dev); 802 cdev_del(port->sm_dev);
812 803
813err_class: 804err_class:
814 class_device_unregister(&port->class_dev); 805 class_device_destroy(umad_class, port->dev->dev);
815 806
816err_cdev: 807err_cdev:
817 cdev_del(&port->dev); 808 cdev_del(port->dev);
818 clear_bit(port->devnum, dev_map); 809 clear_bit(port->dev_num, dev_map);
819 810
820 return -1; 811 return -1;
821} 812}
822 813
814static void ib_umad_kill_port(struct ib_umad_port *port)
815{
816 class_set_devdata(port->class_dev, NULL);
817 class_set_devdata(port->sm_class_dev, NULL);
818
819 class_device_destroy(umad_class, port->dev->dev);
820 class_device_destroy(umad_class, port->sm_dev->dev);
821
822 cdev_del(port->dev);
823 cdev_del(port->sm_dev);
824
825 spin_lock(&port_lock);
826 umad_port[port->dev_num] = NULL;
827 spin_unlock(&port_lock);
828
829 clear_bit(port->dev_num, dev_map);
830}
831
823static void ib_umad_add_one(struct ib_device *device) 832static void ib_umad_add_one(struct ib_device *device)
824{ 833{
825 struct ib_umad_device *umad_dev; 834 struct ib_umad_device *umad_dev;
@@ -832,15 +841,12 @@ static void ib_umad_add_one(struct ib_device *device)
832 e = device->phys_port_cnt; 841 e = device->phys_port_cnt;
833 } 842 }
834 843
835 umad_dev = kmalloc(sizeof *umad_dev + 844 umad_dev = kzalloc(sizeof *umad_dev +
836 (e - s + 1) * sizeof (struct ib_umad_port), 845 (e - s + 1) * sizeof (struct ib_umad_port),
837 GFP_KERNEL); 846 GFP_KERNEL);
838 if (!umad_dev) 847 if (!umad_dev)
839 return; 848 return;
840 849
841 memset(umad_dev, 0, sizeof *umad_dev +
842 (e - s + 1) * sizeof (struct ib_umad_port));
843
844 kref_init(&umad_dev->ref); 850 kref_init(&umad_dev->ref);
845 851
846 umad_dev->start_port = s; 852 umad_dev->start_port = s;
@@ -858,10 +864,8 @@ static void ib_umad_add_one(struct ib_device *device)
858 return; 864 return;
859 865
860err: 866err:
861 while (--i >= s) { 867 while (--i >= s)
862 class_device_unregister(&umad_dev->port[i - s].class_dev); 868 ib_umad_kill_port(&umad_dev->port[i]);
863 class_device_unregister(&umad_dev->port[i - s].sm_class_dev);
864 }
865 869
866 kref_put(&umad_dev->ref, ib_umad_release_dev); 870 kref_put(&umad_dev->ref, ib_umad_release_dev);
867} 871}
@@ -874,10 +878,8 @@ static void ib_umad_remove_one(struct ib_device *device)
874 if (!umad_dev) 878 if (!umad_dev)
875 return; 879 return;
876 880
877 for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) { 881 for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
878 class_device_unregister(&umad_dev->port[i].class_dev); 882 ib_umad_kill_port(&umad_dev->port[i]);
879 class_device_unregister(&umad_dev->port[i].sm_class_dev);
880 }
881 883
882 kref_put(&umad_dev->ref, ib_umad_release_dev); 884 kref_put(&umad_dev->ref, ib_umad_release_dev);
883} 885}
@@ -886,8 +888,6 @@ static int __init ib_umad_init(void)
886{ 888{
887 int ret; 889 int ret;
888 890
889 spin_lock_init(&map_lock);
890
891 ret = register_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2, 891 ret = register_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2,
892 "infiniband_mad"); 892 "infiniband_mad");
893 if (ret) { 893 if (ret) {
@@ -895,13 +895,14 @@ static int __init ib_umad_init(void)
895 goto out; 895 goto out;
896 } 896 }
897 897
898 ret = class_register(&umad_class); 898 umad_class = class_create(THIS_MODULE, "infiniband_mad");
899 if (ret) { 899 if (IS_ERR(umad_class)) {
900 ret = PTR_ERR(umad_class);
900 printk(KERN_ERR "user_mad: couldn't create class infiniband_mad\n"); 901 printk(KERN_ERR "user_mad: couldn't create class infiniband_mad\n");
901 goto out_chrdev; 902 goto out_chrdev;
902 } 903 }
903 904
904 ret = class_create_file(&umad_class, &class_attr_abi_version); 905 ret = class_create_file(umad_class, &class_attr_abi_version);
905 if (ret) { 906 if (ret) {
906 printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n"); 907 printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n");
907 goto out_class; 908 goto out_class;
@@ -916,7 +917,7 @@ static int __init ib_umad_init(void)
916 return 0; 917 return 0;
917 918
918out_class: 919out_class:
919 class_unregister(&umad_class); 920 class_destroy(umad_class);
920 921
921out_chrdev: 922out_chrdev:
922 unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2); 923 unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
@@ -928,7 +929,7 @@ out:
928static void __exit ib_umad_cleanup(void) 929static void __exit ib_umad_cleanup(void)
929{ 930{
930 ib_unregister_client(&umad_client); 931 ib_unregister_client(&umad_client);
931 class_unregister(&umad_class); 932 class_destroy(umad_class);
932 unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2); 933 unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
933} 934}
934 935
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index cc124344dd2c..031cdf3c066d 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -3,6 +3,7 @@
3 * Copyright (c) 2005 Cisco Systems. All rights reserved. 3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 5 * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
6 * Copyright (c) 2005 PathScale, Inc. All rights reserved.
6 * 7 *
7 * This software is available to you under a choice of one of two 8 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU 9 * licenses. You may choose to be licensed under the terms of the GNU
@@ -38,29 +39,47 @@
38#ifndef UVERBS_H 39#ifndef UVERBS_H
39#define UVERBS_H 40#define UVERBS_H
40 41
41/* Include device.h and fs.h until cdev.h is self-sufficient */
42#include <linux/fs.h>
43#include <linux/device.h>
44#include <linux/cdev.h>
45#include <linux/kref.h> 42#include <linux/kref.h>
46#include <linux/idr.h> 43#include <linux/idr.h>
47 44
48#include <rdma/ib_verbs.h> 45#include <rdma/ib_verbs.h>
49#include <rdma/ib_user_verbs.h> 46#include <rdma/ib_user_verbs.h>
50 47
48/*
49 * Our lifetime rules for these structs are the following:
50 *
51 * struct ib_uverbs_device: One reference is held by the module and
52 * released in ib_uverbs_remove_one(). Another reference is taken by
53 * ib_uverbs_open() each time the character special file is opened,
54 * and released in ib_uverbs_release_file() when the file is released.
55 *
56 * struct ib_uverbs_file: One reference is held by the VFS and
57 * released when the file is closed. Another reference is taken when
58 * an asynchronous event queue file is created and released when the
59 * event file is closed.
60 *
61 * struct ib_uverbs_event_file: One reference is held by the VFS and
62 * released when the file is closed. For asynchronous event files,
63 * another reference is held by the corresponding main context file
64 * and released when that file is closed. For completion event files,
65 * a reference is taken when a CQ is created that uses the file, and
66 * released when the CQ is destroyed.
67 */
68
51struct ib_uverbs_device { 69struct ib_uverbs_device {
70 struct kref ref;
52 int devnum; 71 int devnum;
53 struct cdev dev; 72 struct cdev *dev;
54 struct class_device class_dev; 73 struct class_device *class_dev;
55 struct ib_device *ib_dev; 74 struct ib_device *ib_dev;
56 int num_comp; 75 int num_comp_vectors;
57}; 76};
58 77
59struct ib_uverbs_event_file { 78struct ib_uverbs_event_file {
60 struct kref ref; 79 struct kref ref;
80 struct file *file;
61 struct ib_uverbs_file *uverbs_file; 81 struct ib_uverbs_file *uverbs_file;
62 spinlock_t lock; 82 spinlock_t lock;
63 int fd;
64 int is_async; 83 int is_async;
65 wait_queue_head_t poll_wait; 84 wait_queue_head_t poll_wait;
66 struct fasync_struct *async_queue; 85 struct fasync_struct *async_queue;
@@ -73,8 +92,7 @@ struct ib_uverbs_file {
73 struct ib_uverbs_device *device; 92 struct ib_uverbs_device *device;
74 struct ib_ucontext *ucontext; 93 struct ib_ucontext *ucontext;
75 struct ib_event_handler event_handler; 94 struct ib_event_handler event_handler;
76 struct ib_uverbs_event_file async_file; 95 struct ib_uverbs_event_file *async_file;
77 struct ib_uverbs_event_file comp_file[1];
78}; 96};
79 97
80struct ib_uverbs_event { 98struct ib_uverbs_event {
@@ -110,10 +128,23 @@ extern struct idr ib_uverbs_cq_idr;
110extern struct idr ib_uverbs_qp_idr; 128extern struct idr ib_uverbs_qp_idr;
111extern struct idr ib_uverbs_srq_idr; 129extern struct idr ib_uverbs_srq_idr;
112 130
131struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
132 int is_async, int *fd);
133void ib_uverbs_release_event_file(struct kref *ref);
134struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
135
136void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
137 struct ib_uverbs_event_file *ev_file,
138 struct ib_ucq_object *uobj);
139void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
140 struct ib_uevent_object *uobj);
141
113void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context); 142void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
114void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr); 143void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
115void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr); 144void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
116void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr); 145void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
146void ib_uverbs_event_handler(struct ib_event_handler *handler,
147 struct ib_event *event);
117 148
118int ib_umem_get(struct ib_device *dev, struct ib_umem *mem, 149int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
119 void *addr, size_t size, int write); 150 void *addr, size_t size, int write);
@@ -125,21 +156,26 @@ void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem);
125 const char __user *buf, int in_len, \ 156 const char __user *buf, int in_len, \
126 int out_len) 157 int out_len)
127 158
128IB_UVERBS_DECLARE_CMD(query_params);
129IB_UVERBS_DECLARE_CMD(get_context); 159IB_UVERBS_DECLARE_CMD(get_context);
130IB_UVERBS_DECLARE_CMD(query_device); 160IB_UVERBS_DECLARE_CMD(query_device);
131IB_UVERBS_DECLARE_CMD(query_port); 161IB_UVERBS_DECLARE_CMD(query_port);
132IB_UVERBS_DECLARE_CMD(query_gid);
133IB_UVERBS_DECLARE_CMD(query_pkey);
134IB_UVERBS_DECLARE_CMD(alloc_pd); 162IB_UVERBS_DECLARE_CMD(alloc_pd);
135IB_UVERBS_DECLARE_CMD(dealloc_pd); 163IB_UVERBS_DECLARE_CMD(dealloc_pd);
136IB_UVERBS_DECLARE_CMD(reg_mr); 164IB_UVERBS_DECLARE_CMD(reg_mr);
137IB_UVERBS_DECLARE_CMD(dereg_mr); 165IB_UVERBS_DECLARE_CMD(dereg_mr);
166IB_UVERBS_DECLARE_CMD(create_comp_channel);
138IB_UVERBS_DECLARE_CMD(create_cq); 167IB_UVERBS_DECLARE_CMD(create_cq);
168IB_UVERBS_DECLARE_CMD(poll_cq);
169IB_UVERBS_DECLARE_CMD(req_notify_cq);
139IB_UVERBS_DECLARE_CMD(destroy_cq); 170IB_UVERBS_DECLARE_CMD(destroy_cq);
140IB_UVERBS_DECLARE_CMD(create_qp); 171IB_UVERBS_DECLARE_CMD(create_qp);
141IB_UVERBS_DECLARE_CMD(modify_qp); 172IB_UVERBS_DECLARE_CMD(modify_qp);
142IB_UVERBS_DECLARE_CMD(destroy_qp); 173IB_UVERBS_DECLARE_CMD(destroy_qp);
174IB_UVERBS_DECLARE_CMD(post_send);
175IB_UVERBS_DECLARE_CMD(post_recv);
176IB_UVERBS_DECLARE_CMD(post_srq_recv);
177IB_UVERBS_DECLARE_CMD(create_ah);
178IB_UVERBS_DECLARE_CMD(destroy_ah);
143IB_UVERBS_DECLARE_CMD(attach_mcast); 179IB_UVERBS_DECLARE_CMD(attach_mcast);
144IB_UVERBS_DECLARE_CMD(detach_mcast); 180IB_UVERBS_DECLARE_CMD(detach_mcast);
145IB_UVERBS_DECLARE_CMD(create_srq); 181IB_UVERBS_DECLARE_CMD(create_srq);
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 562445165d2b..8c89abc8c764 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved. 3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * Copyright (c) 2005 PathScale, Inc. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -33,6 +34,9 @@
33 * $Id: uverbs_cmd.c 2708 2005-06-24 17:27:21Z roland $ 34 * $Id: uverbs_cmd.c 2708 2005-06-24 17:27:21Z roland $
34 */ 35 */
35 36
37#include <linux/file.h>
38#include <linux/fs.h>
39
36#include <asm/uaccess.h> 40#include <asm/uaccess.h>
37 41
38#include "uverbs.h" 42#include "uverbs.h"
@@ -45,29 +49,6 @@
45 (udata)->outlen = (olen); \ 49 (udata)->outlen = (olen); \
46 } while (0) 50 } while (0)
47 51
48ssize_t ib_uverbs_query_params(struct ib_uverbs_file *file,
49 const char __user *buf,
50 int in_len, int out_len)
51{
52 struct ib_uverbs_query_params cmd;
53 struct ib_uverbs_query_params_resp resp;
54
55 if (out_len < sizeof resp)
56 return -ENOSPC;
57
58 if (copy_from_user(&cmd, buf, sizeof cmd))
59 return -EFAULT;
60
61 memset(&resp, 0, sizeof resp);
62
63 resp.num_cq_events = file->device->num_comp;
64
65 if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp))
66 return -EFAULT;
67
68 return in_len;
69}
70
71ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, 52ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
72 const char __user *buf, 53 const char __user *buf,
73 int in_len, int out_len) 54 int in_len, int out_len)
@@ -77,7 +58,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
77 struct ib_udata udata; 58 struct ib_udata udata;
78 struct ib_device *ibdev = file->device->ib_dev; 59 struct ib_device *ibdev = file->device->ib_dev;
79 struct ib_ucontext *ucontext; 60 struct ib_ucontext *ucontext;
80 int i; 61 struct file *filp;
81 int ret; 62 int ret;
82 63
83 if (out_len < sizeof resp) 64 if (out_len < sizeof resp)
@@ -110,26 +91,42 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
110 INIT_LIST_HEAD(&ucontext->srq_list); 91 INIT_LIST_HEAD(&ucontext->srq_list);
111 INIT_LIST_HEAD(&ucontext->ah_list); 92 INIT_LIST_HEAD(&ucontext->ah_list);
112 93
113 resp.async_fd = file->async_file.fd; 94 resp.num_comp_vectors = file->device->num_comp_vectors;
114 for (i = 0; i < file->device->num_comp; ++i) 95
115 if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab + 96 filp = ib_uverbs_alloc_event_file(file, 1, &resp.async_fd);
116 i * sizeof (__u32), 97 if (IS_ERR(filp)) {
117 &file->comp_file[i].fd, sizeof (__u32))) { 98 ret = PTR_ERR(filp);
118 ret = -EFAULT; 99 goto err_free;
119 goto err_free; 100 }
120 }
121 101
122 if (copy_to_user((void __user *) (unsigned long) cmd.response, 102 if (copy_to_user((void __user *) (unsigned long) cmd.response,
123 &resp, sizeof resp)) { 103 &resp, sizeof resp)) {
124 ret = -EFAULT; 104 ret = -EFAULT;
125 goto err_free; 105 goto err_file;
126 } 106 }
127 107
108 file->async_file = filp->private_data;
109
110 INIT_IB_EVENT_HANDLER(&file->event_handler, file->device->ib_dev,
111 ib_uverbs_event_handler);
112 ret = ib_register_event_handler(&file->event_handler);
113 if (ret)
114 goto err_file;
115
116 kref_get(&file->async_file->ref);
117 kref_get(&file->ref);
128 file->ucontext = ucontext; 118 file->ucontext = ucontext;
119
120 fd_install(resp.async_fd, filp);
121
129 up(&file->mutex); 122 up(&file->mutex);
130 123
131 return in_len; 124 return in_len;
132 125
126err_file:
127 put_unused_fd(resp.async_fd);
128 fput(filp);
129
133err_free: 130err_free:
134 ibdev->dealloc_ucontext(ucontext); 131 ibdev->dealloc_ucontext(ucontext);
135 132
@@ -255,62 +252,6 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
255 return in_len; 252 return in_len;
256} 253}
257 254
258ssize_t ib_uverbs_query_gid(struct ib_uverbs_file *file,
259 const char __user *buf,
260 int in_len, int out_len)
261{
262 struct ib_uverbs_query_gid cmd;
263 struct ib_uverbs_query_gid_resp resp;
264 int ret;
265
266 if (out_len < sizeof resp)
267 return -ENOSPC;
268
269 if (copy_from_user(&cmd, buf, sizeof cmd))
270 return -EFAULT;
271
272 memset(&resp, 0, sizeof resp);
273
274 ret = ib_query_gid(file->device->ib_dev, cmd.port_num, cmd.index,
275 (union ib_gid *) resp.gid);
276 if (ret)
277 return ret;
278
279 if (copy_to_user((void __user *) (unsigned long) cmd.response,
280 &resp, sizeof resp))
281 return -EFAULT;
282
283 return in_len;
284}
285
286ssize_t ib_uverbs_query_pkey(struct ib_uverbs_file *file,
287 const char __user *buf,
288 int in_len, int out_len)
289{
290 struct ib_uverbs_query_pkey cmd;
291 struct ib_uverbs_query_pkey_resp resp;
292 int ret;
293
294 if (out_len < sizeof resp)
295 return -ENOSPC;
296
297 if (copy_from_user(&cmd, buf, sizeof cmd))
298 return -EFAULT;
299
300 memset(&resp, 0, sizeof resp);
301
302 ret = ib_query_pkey(file->device->ib_dev, cmd.port_num, cmd.index,
303 &resp.pkey);
304 if (ret)
305 return ret;
306
307 if (copy_to_user((void __user *) (unsigned long) cmd.response,
308 &resp, sizeof resp))
309 return -EFAULT;
310
311 return in_len;
312}
313
314ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file, 255ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
315 const char __user *buf, 256 const char __user *buf,
316 int in_len, int out_len) 257 int in_len, int out_len)
@@ -349,24 +290,20 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
349 pd->uobject = uobj; 290 pd->uobject = uobj;
350 atomic_set(&pd->usecnt, 0); 291 atomic_set(&pd->usecnt, 0);
351 292
293 down(&ib_uverbs_idr_mutex);
294
352retry: 295retry:
353 if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) { 296 if (!idr_pre_get(&ib_uverbs_pd_idr, GFP_KERNEL)) {
354 ret = -ENOMEM; 297 ret = -ENOMEM;
355 goto err_pd; 298 goto err_up;
356 } 299 }
357 300
358 down(&ib_uverbs_idr_mutex);
359 ret = idr_get_new(&ib_uverbs_pd_idr, pd, &uobj->id); 301 ret = idr_get_new(&ib_uverbs_pd_idr, pd, &uobj->id);
360 up(&ib_uverbs_idr_mutex);
361 302
362 if (ret == -EAGAIN) 303 if (ret == -EAGAIN)
363 goto retry; 304 goto retry;
364 if (ret) 305 if (ret)
365 goto err_pd; 306 goto err_up;
366
367 down(&file->mutex);
368 list_add_tail(&uobj->list, &file->ucontext->pd_list);
369 up(&file->mutex);
370 307
371 memset(&resp, 0, sizeof resp); 308 memset(&resp, 0, sizeof resp);
372 resp.pd_handle = uobj->id; 309 resp.pd_handle = uobj->id;
@@ -374,21 +311,22 @@ retry:
374 if (copy_to_user((void __user *) (unsigned long) cmd.response, 311 if (copy_to_user((void __user *) (unsigned long) cmd.response,
375 &resp, sizeof resp)) { 312 &resp, sizeof resp)) {
376 ret = -EFAULT; 313 ret = -EFAULT;
377 goto err_list; 314 goto err_idr;
378 } 315 }
379 316
380 return in_len; 317 down(&file->mutex);
381 318 list_add_tail(&uobj->list, &file->ucontext->pd_list);
382err_list:
383 down(&file->mutex);
384 list_del(&uobj->list);
385 up(&file->mutex); 319 up(&file->mutex);
386 320
387 down(&ib_uverbs_idr_mutex);
388 idr_remove(&ib_uverbs_pd_idr, uobj->id);
389 up(&ib_uverbs_idr_mutex); 321 up(&ib_uverbs_idr_mutex);
390 322
391err_pd: 323 return in_len;
324
325err_idr:
326 idr_remove(&ib_uverbs_pd_idr, uobj->id);
327
328err_up:
329 up(&ib_uverbs_idr_mutex);
392 ib_dealloc_pd(pd); 330 ib_dealloc_pd(pd);
393 331
394err: 332err:
@@ -459,6 +397,14 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
459 if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) 397 if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
460 return -EINVAL; 398 return -EINVAL;
461 399
400 /*
401 * Local write permission is required if remote write or
402 * remote atomic permission is also requested.
403 */
404 if (cmd.access_flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) &&
405 !(cmd.access_flags & IB_ACCESS_LOCAL_WRITE))
406 return -EINVAL;
407
462 obj = kmalloc(sizeof *obj, GFP_KERNEL); 408 obj = kmalloc(sizeof *obj, GFP_KERNEL);
463 if (!obj) 409 if (!obj)
464 return -ENOMEM; 410 return -ENOMEM;
@@ -524,24 +470,22 @@ retry:
524 470
525 resp.mr_handle = obj->uobject.id; 471 resp.mr_handle = obj->uobject.id;
526 472
527 down(&file->mutex);
528 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
529 up(&file->mutex);
530
531 if (copy_to_user((void __user *) (unsigned long) cmd.response, 473 if (copy_to_user((void __user *) (unsigned long) cmd.response,
532 &resp, sizeof resp)) { 474 &resp, sizeof resp)) {
533 ret = -EFAULT; 475 ret = -EFAULT;
534 goto err_list; 476 goto err_idr;
535 } 477 }
536 478
479 down(&file->mutex);
480 list_add_tail(&obj->uobject.list, &file->ucontext->mr_list);
481 up(&file->mutex);
482
537 up(&ib_uverbs_idr_mutex); 483 up(&ib_uverbs_idr_mutex);
538 484
539 return in_len; 485 return in_len;
540 486
541err_list: 487err_idr:
542 down(&file->mutex); 488 idr_remove(&ib_uverbs_mr_idr, obj->uobject.id);
543 list_del(&obj->uobject.list);
544 up(&file->mutex);
545 489
546err_unreg: 490err_unreg:
547 ib_dereg_mr(mr); 491 ib_dereg_mr(mr);
@@ -595,6 +539,35 @@ out:
595 return ret ? ret : in_len; 539 return ret ? ret : in_len;
596} 540}
597 541
542ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
543 const char __user *buf, int in_len,
544 int out_len)
545{
546 struct ib_uverbs_create_comp_channel cmd;
547 struct ib_uverbs_create_comp_channel_resp resp;
548 struct file *filp;
549
550 if (out_len < sizeof resp)
551 return -ENOSPC;
552
553 if (copy_from_user(&cmd, buf, sizeof cmd))
554 return -EFAULT;
555
556 filp = ib_uverbs_alloc_event_file(file, 0, &resp.fd);
557 if (IS_ERR(filp))
558 return PTR_ERR(filp);
559
560 if (copy_to_user((void __user *) (unsigned long) cmd.response,
561 &resp, sizeof resp)) {
562 put_unused_fd(resp.fd);
563 fput(filp);
564 return -EFAULT;
565 }
566
567 fd_install(resp.fd, filp);
568 return in_len;
569}
570
598ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file, 571ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
599 const char __user *buf, int in_len, 572 const char __user *buf, int in_len,
600 int out_len) 573 int out_len)
@@ -603,6 +576,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
603 struct ib_uverbs_create_cq_resp resp; 576 struct ib_uverbs_create_cq_resp resp;
604 struct ib_udata udata; 577 struct ib_udata udata;
605 struct ib_ucq_object *uobj; 578 struct ib_ucq_object *uobj;
579 struct ib_uverbs_event_file *ev_file = NULL;
606 struct ib_cq *cq; 580 struct ib_cq *cq;
607 int ret; 581 int ret;
608 582
@@ -616,9 +590,12 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
616 (unsigned long) cmd.response + sizeof resp, 590 (unsigned long) cmd.response + sizeof resp,
617 in_len - sizeof cmd, out_len - sizeof resp); 591 in_len - sizeof cmd, out_len - sizeof resp);
618 592
619 if (cmd.event_handler >= file->device->num_comp) 593 if (cmd.comp_vector >= file->device->num_comp_vectors)
620 return -EINVAL; 594 return -EINVAL;
621 595
596 if (cmd.comp_channel >= 0)
597 ev_file = ib_uverbs_lookup_comp_file(cmd.comp_channel);
598
622 uobj = kmalloc(sizeof *uobj, GFP_KERNEL); 599 uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
623 if (!uobj) 600 if (!uobj)
624 return -ENOMEM; 601 return -ENOMEM;
@@ -641,27 +618,23 @@ ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
641 cq->uobject = &uobj->uobject; 618 cq->uobject = &uobj->uobject;
642 cq->comp_handler = ib_uverbs_comp_handler; 619 cq->comp_handler = ib_uverbs_comp_handler;
643 cq->event_handler = ib_uverbs_cq_event_handler; 620 cq->event_handler = ib_uverbs_cq_event_handler;
644 cq->cq_context = file; 621 cq->cq_context = ev_file;
645 atomic_set(&cq->usecnt, 0); 622 atomic_set(&cq->usecnt, 0);
646 623
624 down(&ib_uverbs_idr_mutex);
625
647retry: 626retry:
648 if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) { 627 if (!idr_pre_get(&ib_uverbs_cq_idr, GFP_KERNEL)) {
649 ret = -ENOMEM; 628 ret = -ENOMEM;
650 goto err_cq; 629 goto err_up;
651 } 630 }
652 631
653 down(&ib_uverbs_idr_mutex);
654 ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->uobject.id); 632 ret = idr_get_new(&ib_uverbs_cq_idr, cq, &uobj->uobject.id);
655 up(&ib_uverbs_idr_mutex);
656 633
657 if (ret == -EAGAIN) 634 if (ret == -EAGAIN)
658 goto retry; 635 goto retry;
659 if (ret) 636 if (ret)
660 goto err_cq; 637 goto err_up;
661
662 down(&file->mutex);
663 list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list);
664 up(&file->mutex);
665 638
666 memset(&resp, 0, sizeof resp); 639 memset(&resp, 0, sizeof resp);
667 resp.cq_handle = uobj->uobject.id; 640 resp.cq_handle = uobj->uobject.id;
@@ -670,21 +643,22 @@ retry:
670 if (copy_to_user((void __user *) (unsigned long) cmd.response, 643 if (copy_to_user((void __user *) (unsigned long) cmd.response,
671 &resp, sizeof resp)) { 644 &resp, sizeof resp)) {
672 ret = -EFAULT; 645 ret = -EFAULT;
673 goto err_list; 646 goto err_idr;
674 } 647 }
675 648
676 return in_len; 649 down(&file->mutex);
677 650 list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list);
678err_list:
679 down(&file->mutex);
680 list_del(&uobj->uobject.list);
681 up(&file->mutex); 651 up(&file->mutex);
682 652
683 down(&ib_uverbs_idr_mutex);
684 idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id);
685 up(&ib_uverbs_idr_mutex); 653 up(&ib_uverbs_idr_mutex);
686 654
687err_cq: 655 return in_len;
656
657err_idr:
658 idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id);
659
660err_up:
661 up(&ib_uverbs_idr_mutex);
688 ib_destroy_cq(cq); 662 ib_destroy_cq(cq);
689 663
690err: 664err:
@@ -692,6 +666,93 @@ err:
692 return ret; 666 return ret;
693} 667}
694 668
669ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
670 const char __user *buf, int in_len,
671 int out_len)
672{
673 struct ib_uverbs_poll_cq cmd;
674 struct ib_uverbs_poll_cq_resp *resp;
675 struct ib_cq *cq;
676 struct ib_wc *wc;
677 int ret = 0;
678 int i;
679 int rsize;
680
681 if (copy_from_user(&cmd, buf, sizeof cmd))
682 return -EFAULT;
683
684 wc = kmalloc(cmd.ne * sizeof *wc, GFP_KERNEL);
685 if (!wc)
686 return -ENOMEM;
687
688 rsize = sizeof *resp + cmd.ne * sizeof(struct ib_uverbs_wc);
689 resp = kmalloc(rsize, GFP_KERNEL);
690 if (!resp) {
691 ret = -ENOMEM;
692 goto out_wc;
693 }
694
695 down(&ib_uverbs_idr_mutex);
696 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
697 if (!cq || cq->uobject->context != file->ucontext) {
698 ret = -EINVAL;
699 goto out;
700 }
701
702 resp->count = ib_poll_cq(cq, cmd.ne, wc);
703
704 for (i = 0; i < resp->count; i++) {
705 resp->wc[i].wr_id = wc[i].wr_id;
706 resp->wc[i].status = wc[i].status;
707 resp->wc[i].opcode = wc[i].opcode;
708 resp->wc[i].vendor_err = wc[i].vendor_err;
709 resp->wc[i].byte_len = wc[i].byte_len;
710 resp->wc[i].imm_data = wc[i].imm_data;
711 resp->wc[i].qp_num = wc[i].qp_num;
712 resp->wc[i].src_qp = wc[i].src_qp;
713 resp->wc[i].wc_flags = wc[i].wc_flags;
714 resp->wc[i].pkey_index = wc[i].pkey_index;
715 resp->wc[i].slid = wc[i].slid;
716 resp->wc[i].sl = wc[i].sl;
717 resp->wc[i].dlid_path_bits = wc[i].dlid_path_bits;
718 resp->wc[i].port_num = wc[i].port_num;
719 }
720
721 if (copy_to_user((void __user *) (unsigned long) cmd.response, resp, rsize))
722 ret = -EFAULT;
723
724out:
725 up(&ib_uverbs_idr_mutex);
726 kfree(resp);
727
728out_wc:
729 kfree(wc);
730 return ret ? ret : in_len;
731}
732
733ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
734 const char __user *buf, int in_len,
735 int out_len)
736{
737 struct ib_uverbs_req_notify_cq cmd;
738 struct ib_cq *cq;
739 int ret = -EINVAL;
740
741 if (copy_from_user(&cmd, buf, sizeof cmd))
742 return -EFAULT;
743
744 down(&ib_uverbs_idr_mutex);
745 cq = idr_find(&ib_uverbs_cq_idr, cmd.cq_handle);
746 if (cq && cq->uobject->context == file->ucontext) {
747 ib_req_notify_cq(cq, cmd.solicited_only ?
748 IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
749 ret = in_len;
750 }
751 up(&ib_uverbs_idr_mutex);
752
753 return ret;
754}
755
695ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, 756ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
696 const char __user *buf, int in_len, 757 const char __user *buf, int in_len,
697 int out_len) 758 int out_len)
@@ -700,7 +761,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
700 struct ib_uverbs_destroy_cq_resp resp; 761 struct ib_uverbs_destroy_cq_resp resp;
701 struct ib_cq *cq; 762 struct ib_cq *cq;
702 struct ib_ucq_object *uobj; 763 struct ib_ucq_object *uobj;
703 struct ib_uverbs_event *evt, *tmp; 764 struct ib_uverbs_event_file *ev_file;
704 u64 user_handle; 765 u64 user_handle;
705 int ret = -EINVAL; 766 int ret = -EINVAL;
706 767
@@ -716,7 +777,8 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
716 goto out; 777 goto out;
717 778
718 user_handle = cq->uobject->user_handle; 779 user_handle = cq->uobject->user_handle;
719 uobj = container_of(cq->uobject, struct ib_ucq_object, uobject); 780 uobj = container_of(cq->uobject, struct ib_ucq_object, uobject);
781 ev_file = cq->cq_context;
720 782
721 ret = ib_destroy_cq(cq); 783 ret = ib_destroy_cq(cq);
722 if (ret) 784 if (ret)
@@ -728,19 +790,7 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
728 list_del(&uobj->uobject.list); 790 list_del(&uobj->uobject.list);
729 up(&file->mutex); 791 up(&file->mutex);
730 792
731 spin_lock_irq(&file->comp_file[0].lock); 793 ib_uverbs_release_ucq(file, ev_file, uobj);
732 list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
733 list_del(&evt->list);
734 kfree(evt);
735 }
736 spin_unlock_irq(&file->comp_file[0].lock);
737
738 spin_lock_irq(&file->async_file.lock);
739 list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
740 list_del(&evt->list);
741 kfree(evt);
742 }
743 spin_unlock_irq(&file->async_file.lock);
744 794
745 resp.comp_events_reported = uobj->comp_events_reported; 795 resp.comp_events_reported = uobj->comp_events_reported;
746 resp.async_events_reported = uobj->async_events_reported; 796 resp.async_events_reported = uobj->async_events_reported;
@@ -859,24 +909,22 @@ retry:
859 909
860 resp.qp_handle = uobj->uobject.id; 910 resp.qp_handle = uobj->uobject.id;
861 911
862 down(&file->mutex);
863 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list);
864 up(&file->mutex);
865
866 if (copy_to_user((void __user *) (unsigned long) cmd.response, 912 if (copy_to_user((void __user *) (unsigned long) cmd.response,
867 &resp, sizeof resp)) { 913 &resp, sizeof resp)) {
868 ret = -EFAULT; 914 ret = -EFAULT;
869 goto err_list; 915 goto err_idr;
870 } 916 }
871 917
918 down(&file->mutex);
919 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list);
920 up(&file->mutex);
921
872 up(&ib_uverbs_idr_mutex); 922 up(&ib_uverbs_idr_mutex);
873 923
874 return in_len; 924 return in_len;
875 925
876err_list: 926err_idr:
877 down(&file->mutex); 927 idr_remove(&ib_uverbs_qp_idr, uobj->uobject.id);
878 list_del(&uobj->uobject.list);
879 up(&file->mutex);
880 928
881err_destroy: 929err_destroy:
882 ib_destroy_qp(qp); 930 ib_destroy_qp(qp);
@@ -979,7 +1027,6 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
979 struct ib_uverbs_destroy_qp_resp resp; 1027 struct ib_uverbs_destroy_qp_resp resp;
980 struct ib_qp *qp; 1028 struct ib_qp *qp;
981 struct ib_uevent_object *uobj; 1029 struct ib_uevent_object *uobj;
982 struct ib_uverbs_event *evt, *tmp;
983 int ret = -EINVAL; 1030 int ret = -EINVAL;
984 1031
985 if (copy_from_user(&cmd, buf, sizeof cmd)) 1032 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1005,12 +1052,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1005 list_del(&uobj->uobject.list); 1052 list_del(&uobj->uobject.list);
1006 up(&file->mutex); 1053 up(&file->mutex);
1007 1054
1008 spin_lock_irq(&file->async_file.lock); 1055 ib_uverbs_release_uevent(file, uobj);
1009 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
1010 list_del(&evt->list);
1011 kfree(evt);
1012 }
1013 spin_unlock_irq(&file->async_file.lock);
1014 1056
1015 resp.events_reported = uobj->events_reported; 1057 resp.events_reported = uobj->events_reported;
1016 1058
@@ -1026,6 +1068,468 @@ out:
1026 return ret ? ret : in_len; 1068 return ret ? ret : in_len;
1027} 1069}
1028 1070
1071ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1072 const char __user *buf, int in_len,
1073 int out_len)
1074{
1075 struct ib_uverbs_post_send cmd;
1076 struct ib_uverbs_post_send_resp resp;
1077 struct ib_uverbs_send_wr *user_wr;
1078 struct ib_send_wr *wr = NULL, *last, *next, *bad_wr;
1079 struct ib_qp *qp;
1080 int i, sg_ind;
1081 ssize_t ret = -EINVAL;
1082
1083 if (copy_from_user(&cmd, buf, sizeof cmd))
1084 return -EFAULT;
1085
1086 if (in_len < sizeof cmd + cmd.wqe_size * cmd.wr_count +
1087 cmd.sge_count * sizeof (struct ib_uverbs_sge))
1088 return -EINVAL;
1089
1090 if (cmd.wqe_size < sizeof (struct ib_uverbs_send_wr))
1091 return -EINVAL;
1092
1093 user_wr = kmalloc(cmd.wqe_size, GFP_KERNEL);
1094 if (!user_wr)
1095 return -ENOMEM;
1096
1097 down(&ib_uverbs_idr_mutex);
1098
1099 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1100 if (!qp || qp->uobject->context != file->ucontext)
1101 goto out;
1102
1103 sg_ind = 0;
1104 last = NULL;
1105 for (i = 0; i < cmd.wr_count; ++i) {
1106 if (copy_from_user(user_wr,
1107 buf + sizeof cmd + i * cmd.wqe_size,
1108 cmd.wqe_size)) {
1109 ret = -EFAULT;
1110 goto out;
1111 }
1112
1113 if (user_wr->num_sge + sg_ind > cmd.sge_count) {
1114 ret = -EINVAL;
1115 goto out;
1116 }
1117
1118 next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
1119 user_wr->num_sge * sizeof (struct ib_sge),
1120 GFP_KERNEL);
1121 if (!next) {
1122 ret = -ENOMEM;
1123 goto out;
1124 }
1125
1126 if (!last)
1127 wr = next;
1128 else
1129 last->next = next;
1130 last = next;
1131
1132 next->next = NULL;
1133 next->wr_id = user_wr->wr_id;
1134 next->num_sge = user_wr->num_sge;
1135 next->opcode = user_wr->opcode;
1136 next->send_flags = user_wr->send_flags;
1137 next->imm_data = user_wr->imm_data;
1138
1139 if (qp->qp_type == IB_QPT_UD) {
1140 next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr,
1141 user_wr->wr.ud.ah);
1142 if (!next->wr.ud.ah) {
1143 ret = -EINVAL;
1144 goto out;
1145 }
1146 next->wr.ud.remote_qpn = user_wr->wr.ud.remote_qpn;
1147 next->wr.ud.remote_qkey = user_wr->wr.ud.remote_qkey;
1148 } else {
1149 switch (next->opcode) {
1150 case IB_WR_RDMA_WRITE:
1151 case IB_WR_RDMA_WRITE_WITH_IMM:
1152 case IB_WR_RDMA_READ:
1153 next->wr.rdma.remote_addr =
1154 user_wr->wr.rdma.remote_addr;
1155 next->wr.rdma.rkey =
1156 user_wr->wr.rdma.rkey;
1157 break;
1158 case IB_WR_ATOMIC_CMP_AND_SWP:
1159 case IB_WR_ATOMIC_FETCH_AND_ADD:
1160 next->wr.atomic.remote_addr =
1161 user_wr->wr.atomic.remote_addr;
1162 next->wr.atomic.compare_add =
1163 user_wr->wr.atomic.compare_add;
1164 next->wr.atomic.swap = user_wr->wr.atomic.swap;
1165 next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
1166 break;
1167 default:
1168 break;
1169 }
1170 }
1171
1172 if (next->num_sge) {
1173 next->sg_list = (void *) next +
1174 ALIGN(sizeof *next, sizeof (struct ib_sge));
1175 if (copy_from_user(next->sg_list,
1176 buf + sizeof cmd +
1177 cmd.wr_count * cmd.wqe_size +
1178 sg_ind * sizeof (struct ib_sge),
1179 next->num_sge * sizeof (struct ib_sge))) {
1180 ret = -EFAULT;
1181 goto out;
1182 }
1183 sg_ind += next->num_sge;
1184 } else
1185 next->sg_list = NULL;
1186 }
1187
1188 resp.bad_wr = 0;
1189 ret = qp->device->post_send(qp, wr, &bad_wr);
1190 if (ret)
1191 for (next = wr; next; next = next->next) {
1192 ++resp.bad_wr;
1193 if (next == bad_wr)
1194 break;
1195 }
1196
1197 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1198 &resp, sizeof resp))
1199 ret = -EFAULT;
1200
1201out:
1202 up(&ib_uverbs_idr_mutex);
1203
1204 while (wr) {
1205 next = wr->next;
1206 kfree(wr);
1207 wr = next;
1208 }
1209
1210 kfree(user_wr);
1211
1212 return ret ? ret : in_len;
1213}
1214
1215static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
1216 int in_len,
1217 u32 wr_count,
1218 u32 sge_count,
1219 u32 wqe_size)
1220{
1221 struct ib_uverbs_recv_wr *user_wr;
1222 struct ib_recv_wr *wr = NULL, *last, *next;
1223 int sg_ind;
1224 int i;
1225 int ret;
1226
1227 if (in_len < wqe_size * wr_count +
1228 sge_count * sizeof (struct ib_uverbs_sge))
1229 return ERR_PTR(-EINVAL);
1230
1231 if (wqe_size < sizeof (struct ib_uverbs_recv_wr))
1232 return ERR_PTR(-EINVAL);
1233
1234 user_wr = kmalloc(wqe_size, GFP_KERNEL);
1235 if (!user_wr)
1236 return ERR_PTR(-ENOMEM);
1237
1238 sg_ind = 0;
1239 last = NULL;
1240 for (i = 0; i < wr_count; ++i) {
1241 if (copy_from_user(user_wr, buf + i * wqe_size,
1242 wqe_size)) {
1243 ret = -EFAULT;
1244 goto err;
1245 }
1246
1247 if (user_wr->num_sge + sg_ind > sge_count) {
1248 ret = -EINVAL;
1249 goto err;
1250 }
1251
1252 next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
1253 user_wr->num_sge * sizeof (struct ib_sge),
1254 GFP_KERNEL);
1255 if (!next) {
1256 ret = -ENOMEM;
1257 goto err;
1258 }
1259
1260 if (!last)
1261 wr = next;
1262 else
1263 last->next = next;
1264 last = next;
1265
1266 next->next = NULL;
1267 next->wr_id = user_wr->wr_id;
1268 next->num_sge = user_wr->num_sge;
1269
1270 if (next->num_sge) {
1271 next->sg_list = (void *) next +
1272 ALIGN(sizeof *next, sizeof (struct ib_sge));
1273 if (copy_from_user(next->sg_list,
1274 buf + wr_count * wqe_size +
1275 sg_ind * sizeof (struct ib_sge),
1276 next->num_sge * sizeof (struct ib_sge))) {
1277 ret = -EFAULT;
1278 goto err;
1279 }
1280 sg_ind += next->num_sge;
1281 } else
1282 next->sg_list = NULL;
1283 }
1284
1285 kfree(user_wr);
1286 return wr;
1287
1288err:
1289 kfree(user_wr);
1290
1291 while (wr) {
1292 next = wr->next;
1293 kfree(wr);
1294 wr = next;
1295 }
1296
1297 return ERR_PTR(ret);
1298}
1299
1300ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
1301 const char __user *buf, int in_len,
1302 int out_len)
1303{
1304 struct ib_uverbs_post_recv cmd;
1305 struct ib_uverbs_post_recv_resp resp;
1306 struct ib_recv_wr *wr, *next, *bad_wr;
1307 struct ib_qp *qp;
1308 ssize_t ret = -EINVAL;
1309
1310 if (copy_from_user(&cmd, buf, sizeof cmd))
1311 return -EFAULT;
1312
1313 wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
1314 in_len - sizeof cmd, cmd.wr_count,
1315 cmd.sge_count, cmd.wqe_size);
1316 if (IS_ERR(wr))
1317 return PTR_ERR(wr);
1318
1319 down(&ib_uverbs_idr_mutex);
1320
1321 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1322 if (!qp || qp->uobject->context != file->ucontext)
1323 goto out;
1324
1325 resp.bad_wr = 0;
1326 ret = qp->device->post_recv(qp, wr, &bad_wr);
1327 if (ret)
1328 for (next = wr; next; next = next->next) {
1329 ++resp.bad_wr;
1330 if (next == bad_wr)
1331 break;
1332 }
1333
1334
1335 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1336 &resp, sizeof resp))
1337 ret = -EFAULT;
1338
1339out:
1340 up(&ib_uverbs_idr_mutex);
1341
1342 while (wr) {
1343 next = wr->next;
1344 kfree(wr);
1345 wr = next;
1346 }
1347
1348 return ret ? ret : in_len;
1349}
1350
1351ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
1352 const char __user *buf, int in_len,
1353 int out_len)
1354{
1355 struct ib_uverbs_post_srq_recv cmd;
1356 struct ib_uverbs_post_srq_recv_resp resp;
1357 struct ib_recv_wr *wr, *next, *bad_wr;
1358 struct ib_srq *srq;
1359 ssize_t ret = -EINVAL;
1360
1361 if (copy_from_user(&cmd, buf, sizeof cmd))
1362 return -EFAULT;
1363
1364 wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
1365 in_len - sizeof cmd, cmd.wr_count,
1366 cmd.sge_count, cmd.wqe_size);
1367 if (IS_ERR(wr))
1368 return PTR_ERR(wr);
1369
1370 down(&ib_uverbs_idr_mutex);
1371
1372 srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
1373 if (!srq || srq->uobject->context != file->ucontext)
1374 goto out;
1375
1376 resp.bad_wr = 0;
1377 ret = srq->device->post_srq_recv(srq, wr, &bad_wr);
1378 if (ret)
1379 for (next = wr; next; next = next->next) {
1380 ++resp.bad_wr;
1381 if (next == bad_wr)
1382 break;
1383 }
1384
1385
1386 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1387 &resp, sizeof resp))
1388 ret = -EFAULT;
1389
1390out:
1391 up(&ib_uverbs_idr_mutex);
1392
1393 while (wr) {
1394 next = wr->next;
1395 kfree(wr);
1396 wr = next;
1397 }
1398
1399 return ret ? ret : in_len;
1400}
1401
1402ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
1403 const char __user *buf, int in_len,
1404 int out_len)
1405{
1406 struct ib_uverbs_create_ah cmd;
1407 struct ib_uverbs_create_ah_resp resp;
1408 struct ib_uobject *uobj;
1409 struct ib_pd *pd;
1410 struct ib_ah *ah;
1411 struct ib_ah_attr attr;
1412 int ret;
1413
1414 if (out_len < sizeof resp)
1415 return -ENOSPC;
1416
1417 if (copy_from_user(&cmd, buf, sizeof cmd))
1418 return -EFAULT;
1419
1420 uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
1421 if (!uobj)
1422 return -ENOMEM;
1423
1424 down(&ib_uverbs_idr_mutex);
1425
1426 pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
1427 if (!pd || pd->uobject->context != file->ucontext) {
1428 ret = -EINVAL;
1429 goto err_up;
1430 }
1431
1432 uobj->user_handle = cmd.user_handle;
1433 uobj->context = file->ucontext;
1434
1435 attr.dlid = cmd.attr.dlid;
1436 attr.sl = cmd.attr.sl;
1437 attr.src_path_bits = cmd.attr.src_path_bits;
1438 attr.static_rate = cmd.attr.static_rate;
1439 attr.port_num = cmd.attr.port_num;
1440 attr.grh.flow_label = cmd.attr.grh.flow_label;
1441 attr.grh.sgid_index = cmd.attr.grh.sgid_index;
1442 attr.grh.hop_limit = cmd.attr.grh.hop_limit;
1443 attr.grh.traffic_class = cmd.attr.grh.traffic_class;
1444 memcpy(attr.grh.dgid.raw, cmd.attr.grh.dgid, 16);
1445
1446 ah = ib_create_ah(pd, &attr);
1447 if (IS_ERR(ah)) {
1448 ret = PTR_ERR(ah);
1449 goto err_up;
1450 }
1451
1452 ah->uobject = uobj;
1453
1454retry:
1455 if (!idr_pre_get(&ib_uverbs_ah_idr, GFP_KERNEL)) {
1456 ret = -ENOMEM;
1457 goto err_destroy;
1458 }
1459
1460 ret = idr_get_new(&ib_uverbs_ah_idr, ah, &uobj->id);
1461
1462 if (ret == -EAGAIN)
1463 goto retry;
1464 if (ret)
1465 goto err_destroy;
1466
1467 resp.ah_handle = uobj->id;
1468
1469 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1470 &resp, sizeof resp)) {
1471 ret = -EFAULT;
1472 goto err_idr;
1473 }
1474
1475 down(&file->mutex);
1476 list_add_tail(&uobj->list, &file->ucontext->ah_list);
1477 up(&file->mutex);
1478
1479 up(&ib_uverbs_idr_mutex);
1480
1481 return in_len;
1482
1483err_idr:
1484 idr_remove(&ib_uverbs_ah_idr, uobj->id);
1485
1486err_destroy:
1487 ib_destroy_ah(ah);
1488
1489err_up:
1490 up(&ib_uverbs_idr_mutex);
1491
1492 kfree(uobj);
1493 return ret;
1494}
1495
1496ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
1497 const char __user *buf, int in_len, int out_len)
1498{
1499 struct ib_uverbs_destroy_ah cmd;
1500 struct ib_ah *ah;
1501 struct ib_uobject *uobj;
1502 int ret = -EINVAL;
1503
1504 if (copy_from_user(&cmd, buf, sizeof cmd))
1505 return -EFAULT;
1506
1507 down(&ib_uverbs_idr_mutex);
1508
1509 ah = idr_find(&ib_uverbs_ah_idr, cmd.ah_handle);
1510 if (!ah || ah->uobject->context != file->ucontext)
1511 goto out;
1512
1513 uobj = ah->uobject;
1514
1515 ret = ib_destroy_ah(ah);
1516 if (ret)
1517 goto out;
1518
1519 idr_remove(&ib_uverbs_ah_idr, cmd.ah_handle);
1520
1521 down(&file->mutex);
1522 list_del(&uobj->list);
1523 up(&file->mutex);
1524
1525 kfree(uobj);
1526
1527out:
1528 up(&ib_uverbs_idr_mutex);
1529
1530 return ret ? ret : in_len;
1531}
1532
1029ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file, 1533ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1030 const char __user *buf, int in_len, 1534 const char __user *buf, int in_len,
1031 int out_len) 1535 int out_len)
@@ -1148,24 +1652,22 @@ retry:
1148 1652
1149 resp.srq_handle = uobj->uobject.id; 1653 resp.srq_handle = uobj->uobject.id;
1150 1654
1151 down(&file->mutex);
1152 list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list);
1153 up(&file->mutex);
1154
1155 if (copy_to_user((void __user *) (unsigned long) cmd.response, 1655 if (copy_to_user((void __user *) (unsigned long) cmd.response,
1156 &resp, sizeof resp)) { 1656 &resp, sizeof resp)) {
1157 ret = -EFAULT; 1657 ret = -EFAULT;
1158 goto err_list; 1658 goto err_idr;
1159 } 1659 }
1160 1660
1661 down(&file->mutex);
1662 list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list);
1663 up(&file->mutex);
1664
1161 up(&ib_uverbs_idr_mutex); 1665 up(&ib_uverbs_idr_mutex);
1162 1666
1163 return in_len; 1667 return in_len;
1164 1668
1165err_list: 1669err_idr:
1166 down(&file->mutex); 1670 idr_remove(&ib_uverbs_srq_idr, uobj->uobject.id);
1167 list_del(&uobj->uobject.list);
1168 up(&file->mutex);
1169 1671
1170err_destroy: 1672err_destroy:
1171 ib_destroy_srq(srq); 1673 ib_destroy_srq(srq);
@@ -1217,7 +1719,6 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
1217 struct ib_uverbs_destroy_srq_resp resp; 1719 struct ib_uverbs_destroy_srq_resp resp;
1218 struct ib_srq *srq; 1720 struct ib_srq *srq;
1219 struct ib_uevent_object *uobj; 1721 struct ib_uevent_object *uobj;
1220 struct ib_uverbs_event *evt, *tmp;
1221 int ret = -EINVAL; 1722 int ret = -EINVAL;
1222 1723
1223 if (copy_from_user(&cmd, buf, sizeof cmd)) 1724 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1243,12 +1744,7 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
1243 list_del(&uobj->uobject.list); 1744 list_del(&uobj->uobject.list);
1244 up(&file->mutex); 1745 up(&file->mutex);
1245 1746
1246 spin_lock_irq(&file->async_file.lock); 1747 ib_uverbs_release_uevent(file, uobj);
1247 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
1248 list_del(&evt->list);
1249 kfree(evt);
1250 }
1251 spin_unlock_irq(&file->async_file.lock);
1252 1748
1253 resp.events_reported = uobj->events_reported; 1749 resp.events_reported = uobj->events_reported;
1254 1750
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 12511808de21..0eb38f479b39 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -3,6 +3,7 @@
3 * Copyright (c) 2005 Cisco Systems. All rights reserved. 3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 4 * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
5 * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 5 * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
6 * Copyright (c) 2005 PathScale, Inc. All rights reserved.
6 * 7 *
7 * This software is available to you under a choice of one of two 8 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU 9 * licenses. You may choose to be licensed under the terms of the GNU
@@ -43,6 +44,7 @@
43#include <linux/poll.h> 44#include <linux/poll.h>
44#include <linux/file.h> 45#include <linux/file.h>
45#include <linux/mount.h> 46#include <linux/mount.h>
47#include <linux/cdev.h>
46 48
47#include <asm/uaccess.h> 49#include <asm/uaccess.h>
48 50
@@ -62,6 +64,8 @@ enum {
62 64
63#define IB_UVERBS_BASE_DEV MKDEV(IB_UVERBS_MAJOR, IB_UVERBS_BASE_MINOR) 65#define IB_UVERBS_BASE_DEV MKDEV(IB_UVERBS_MAJOR, IB_UVERBS_BASE_MINOR)
64 66
67static struct class *uverbs_class;
68
65DECLARE_MUTEX(ib_uverbs_idr_mutex); 69DECLARE_MUTEX(ib_uverbs_idr_mutex);
66DEFINE_IDR(ib_uverbs_pd_idr); 70DEFINE_IDR(ib_uverbs_pd_idr);
67DEFINE_IDR(ib_uverbs_mr_idr); 71DEFINE_IDR(ib_uverbs_mr_idr);
@@ -72,31 +76,37 @@ DEFINE_IDR(ib_uverbs_qp_idr);
72DEFINE_IDR(ib_uverbs_srq_idr); 76DEFINE_IDR(ib_uverbs_srq_idr);
73 77
74static spinlock_t map_lock; 78static spinlock_t map_lock;
79static struct ib_uverbs_device *dev_table[IB_UVERBS_MAX_DEVICES];
75static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES); 80static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
76 81
77static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, 82static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
78 const char __user *buf, int in_len, 83 const char __user *buf, int in_len,
79 int out_len) = { 84 int out_len) = {
80 [IB_USER_VERBS_CMD_QUERY_PARAMS] = ib_uverbs_query_params, 85 [IB_USER_VERBS_CMD_GET_CONTEXT] = ib_uverbs_get_context,
81 [IB_USER_VERBS_CMD_GET_CONTEXT] = ib_uverbs_get_context, 86 [IB_USER_VERBS_CMD_QUERY_DEVICE] = ib_uverbs_query_device,
82 [IB_USER_VERBS_CMD_QUERY_DEVICE] = ib_uverbs_query_device, 87 [IB_USER_VERBS_CMD_QUERY_PORT] = ib_uverbs_query_port,
83 [IB_USER_VERBS_CMD_QUERY_PORT] = ib_uverbs_query_port, 88 [IB_USER_VERBS_CMD_ALLOC_PD] = ib_uverbs_alloc_pd,
84 [IB_USER_VERBS_CMD_QUERY_GID] = ib_uverbs_query_gid, 89 [IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd,
85 [IB_USER_VERBS_CMD_QUERY_PKEY] = ib_uverbs_query_pkey, 90 [IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr,
86 [IB_USER_VERBS_CMD_ALLOC_PD] = ib_uverbs_alloc_pd, 91 [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr,
87 [IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd, 92 [IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel,
88 [IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr, 93 [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq,
89 [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr, 94 [IB_USER_VERBS_CMD_POLL_CQ] = ib_uverbs_poll_cq,
90 [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq, 95 [IB_USER_VERBS_CMD_REQ_NOTIFY_CQ] = ib_uverbs_req_notify_cq,
91 [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq, 96 [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq,
92 [IB_USER_VERBS_CMD_CREATE_QP] = ib_uverbs_create_qp, 97 [IB_USER_VERBS_CMD_CREATE_QP] = ib_uverbs_create_qp,
93 [IB_USER_VERBS_CMD_MODIFY_QP] = ib_uverbs_modify_qp, 98 [IB_USER_VERBS_CMD_MODIFY_QP] = ib_uverbs_modify_qp,
94 [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp, 99 [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp,
95 [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast, 100 [IB_USER_VERBS_CMD_POST_SEND] = ib_uverbs_post_send,
96 [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast, 101 [IB_USER_VERBS_CMD_POST_RECV] = ib_uverbs_post_recv,
97 [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq, 102 [IB_USER_VERBS_CMD_POST_SRQ_RECV] = ib_uverbs_post_srq_recv,
98 [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq, 103 [IB_USER_VERBS_CMD_CREATE_AH] = ib_uverbs_create_ah,
99 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq, 104 [IB_USER_VERBS_CMD_DESTROY_AH] = ib_uverbs_destroy_ah,
105 [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast,
106 [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
107 [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq,
108 [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq,
109 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
100}; 110};
101 111
102static struct vfsmount *uverbs_event_mnt; 112static struct vfsmount *uverbs_event_mnt;
@@ -104,7 +114,54 @@ static struct vfsmount *uverbs_event_mnt;
104static void ib_uverbs_add_one(struct ib_device *device); 114static void ib_uverbs_add_one(struct ib_device *device);
105static void ib_uverbs_remove_one(struct ib_device *device); 115static void ib_uverbs_remove_one(struct ib_device *device);
106 116
107static int ib_dealloc_ucontext(struct ib_ucontext *context) 117static void ib_uverbs_release_dev(struct kref *ref)
118{
119 struct ib_uverbs_device *dev =
120 container_of(ref, struct ib_uverbs_device, ref);
121
122 kfree(dev);
123}
124
125void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
126 struct ib_uverbs_event_file *ev_file,
127 struct ib_ucq_object *uobj)
128{
129 struct ib_uverbs_event *evt, *tmp;
130
131 if (ev_file) {
132 spin_lock_irq(&ev_file->lock);
133 list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
134 list_del(&evt->list);
135 kfree(evt);
136 }
137 spin_unlock_irq(&ev_file->lock);
138
139 kref_put(&ev_file->ref, ib_uverbs_release_event_file);
140 }
141
142 spin_lock_irq(&file->async_file->lock);
143 list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
144 list_del(&evt->list);
145 kfree(evt);
146 }
147 spin_unlock_irq(&file->async_file->lock);
148}
149
150void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
151 struct ib_uevent_object *uobj)
152{
153 struct ib_uverbs_event *evt, *tmp;
154
155 spin_lock_irq(&file->async_file->lock);
156 list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
157 list_del(&evt->list);
158 kfree(evt);
159 }
160 spin_unlock_irq(&file->async_file->lock);
161}
162
163static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
164 struct ib_ucontext *context)
108{ 165{
109 struct ib_uobject *uobj, *tmp; 166 struct ib_uobject *uobj, *tmp;
110 167
@@ -113,30 +170,46 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context)
113 170
114 down(&ib_uverbs_idr_mutex); 171 down(&ib_uverbs_idr_mutex);
115 172
116 /* XXX Free AHs */ 173 list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) {
174 struct ib_ah *ah = idr_find(&ib_uverbs_ah_idr, uobj->id);
175 idr_remove(&ib_uverbs_ah_idr, uobj->id);
176 ib_destroy_ah(ah);
177 list_del(&uobj->list);
178 kfree(uobj);
179 }
117 180
118 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) { 181 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
119 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id); 182 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id);
183 struct ib_uevent_object *uevent =
184 container_of(uobj, struct ib_uevent_object, uobject);
120 idr_remove(&ib_uverbs_qp_idr, uobj->id); 185 idr_remove(&ib_uverbs_qp_idr, uobj->id);
121 ib_destroy_qp(qp); 186 ib_destroy_qp(qp);
122 list_del(&uobj->list); 187 list_del(&uobj->list);
123 kfree(container_of(uobj, struct ib_uevent_object, uobject)); 188 ib_uverbs_release_uevent(file, uevent);
189 kfree(uevent);
124 } 190 }
125 191
126 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) { 192 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
127 struct ib_cq *cq = idr_find(&ib_uverbs_cq_idr, uobj->id); 193 struct ib_cq *cq = idr_find(&ib_uverbs_cq_idr, uobj->id);
194 struct ib_uverbs_event_file *ev_file = cq->cq_context;
195 struct ib_ucq_object *ucq =
196 container_of(uobj, struct ib_ucq_object, uobject);
128 idr_remove(&ib_uverbs_cq_idr, uobj->id); 197 idr_remove(&ib_uverbs_cq_idr, uobj->id);
129 ib_destroy_cq(cq); 198 ib_destroy_cq(cq);
130 list_del(&uobj->list); 199 list_del(&uobj->list);
131 kfree(container_of(uobj, struct ib_ucq_object, uobject)); 200 ib_uverbs_release_ucq(file, ev_file, ucq);
201 kfree(ucq);
132 } 202 }
133 203
134 list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) { 204 list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) {
135 struct ib_srq *srq = idr_find(&ib_uverbs_srq_idr, uobj->id); 205 struct ib_srq *srq = idr_find(&ib_uverbs_srq_idr, uobj->id);
206 struct ib_uevent_object *uevent =
207 container_of(uobj, struct ib_uevent_object, uobject);
136 idr_remove(&ib_uverbs_srq_idr, uobj->id); 208 idr_remove(&ib_uverbs_srq_idr, uobj->id);
137 ib_destroy_srq(srq); 209 ib_destroy_srq(srq);
138 list_del(&uobj->list); 210 list_del(&uobj->list);
139 kfree(container_of(uobj, struct ib_uevent_object, uobject)); 211 ib_uverbs_release_uevent(file, uevent);
212 kfree(uevent);
140 } 213 }
141 214
142 /* XXX Free MWs */ 215 /* XXX Free MWs */
@@ -175,6 +248,8 @@ static void ib_uverbs_release_file(struct kref *ref)
175 container_of(ref, struct ib_uverbs_file, ref); 248 container_of(ref, struct ib_uverbs_file, ref);
176 249
177 module_put(file->device->ib_dev->owner); 250 module_put(file->device->ib_dev->owner);
251 kref_put(&file->device->ref, ib_uverbs_release_dev);
252
178 kfree(file); 253 kfree(file);
179} 254}
180 255
@@ -188,25 +263,19 @@ static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf,
188 263
189 spin_lock_irq(&file->lock); 264 spin_lock_irq(&file->lock);
190 265
191 while (list_empty(&file->event_list) && file->fd >= 0) { 266 while (list_empty(&file->event_list)) {
192 spin_unlock_irq(&file->lock); 267 spin_unlock_irq(&file->lock);
193 268
194 if (filp->f_flags & O_NONBLOCK) 269 if (filp->f_flags & O_NONBLOCK)
195 return -EAGAIN; 270 return -EAGAIN;
196 271
197 if (wait_event_interruptible(file->poll_wait, 272 if (wait_event_interruptible(file->poll_wait,
198 !list_empty(&file->event_list) || 273 !list_empty(&file->event_list)))
199 file->fd < 0))
200 return -ERESTARTSYS; 274 return -ERESTARTSYS;
201 275
202 spin_lock_irq(&file->lock); 276 spin_lock_irq(&file->lock);
203 } 277 }
204 278
205 if (file->fd < 0) {
206 spin_unlock_irq(&file->lock);
207 return -ENODEV;
208 }
209
210 event = list_entry(file->event_list.next, struct ib_uverbs_event, list); 279 event = list_entry(file->event_list.next, struct ib_uverbs_event, list);
211 280
212 if (file->is_async) 281 if (file->is_async)
@@ -248,26 +317,19 @@ static unsigned int ib_uverbs_event_poll(struct file *filp,
248 poll_wait(filp, &file->poll_wait, wait); 317 poll_wait(filp, &file->poll_wait, wait);
249 318
250 spin_lock_irq(&file->lock); 319 spin_lock_irq(&file->lock);
251 if (file->fd < 0) 320 if (!list_empty(&file->event_list))
252 pollflags = POLLERR;
253 else if (!list_empty(&file->event_list))
254 pollflags = POLLIN | POLLRDNORM; 321 pollflags = POLLIN | POLLRDNORM;
255 spin_unlock_irq(&file->lock); 322 spin_unlock_irq(&file->lock);
256 323
257 return pollflags; 324 return pollflags;
258} 325}
259 326
260static void ib_uverbs_event_release(struct ib_uverbs_event_file *file) 327void ib_uverbs_release_event_file(struct kref *ref)
261{ 328{
262 struct ib_uverbs_event *entry, *tmp; 329 struct ib_uverbs_event_file *file =
330 container_of(ref, struct ib_uverbs_event_file, ref);
263 331
264 spin_lock_irq(&file->lock); 332 kfree(file);
265 if (file->fd != -1) {
266 file->fd = -1;
267 list_for_each_entry_safe(entry, tmp, &file->event_list, list)
268 kfree(entry);
269 }
270 spin_unlock_irq(&file->lock);
271} 333}
272 334
273static int ib_uverbs_event_fasync(int fd, struct file *filp, int on) 335static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
@@ -280,21 +342,30 @@ static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
280static int ib_uverbs_event_close(struct inode *inode, struct file *filp) 342static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
281{ 343{
282 struct ib_uverbs_event_file *file = filp->private_data; 344 struct ib_uverbs_event_file *file = filp->private_data;
345 struct ib_uverbs_event *entry, *tmp;
346
347 spin_lock_irq(&file->lock);
348 file->file = NULL;
349 list_for_each_entry_safe(entry, tmp, &file->event_list, list) {
350 if (entry->counter)
351 list_del(&entry->obj_list);
352 kfree(entry);
353 }
354 spin_unlock_irq(&file->lock);
283 355
284 ib_uverbs_event_release(file);
285 ib_uverbs_event_fasync(-1, filp, 0); 356 ib_uverbs_event_fasync(-1, filp, 0);
286 kref_put(&file->uverbs_file->ref, ib_uverbs_release_file); 357
358 if (file->is_async) {
359 ib_unregister_event_handler(&file->uverbs_file->event_handler);
360 kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
361 }
362 kref_put(&file->ref, ib_uverbs_release_event_file);
287 363
288 return 0; 364 return 0;
289} 365}
290 366
291static struct file_operations uverbs_event_fops = { 367static struct file_operations uverbs_event_fops = {
292 /* 368 .owner = THIS_MODULE,
293 * No .owner field since we artificially create event files,
294 * so there is no increment to the module reference count in
295 * the open path. All event files come from a uverbs command
296 * file, which already takes a module reference, so this is OK.
297 */
298 .read = ib_uverbs_event_read, 369 .read = ib_uverbs_event_read,
299 .poll = ib_uverbs_event_poll, 370 .poll = ib_uverbs_event_poll,
300 .release = ib_uverbs_event_close, 371 .release = ib_uverbs_event_close,
@@ -303,27 +374,37 @@ static struct file_operations uverbs_event_fops = {
303 374
304void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context) 375void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
305{ 376{
306 struct ib_uverbs_file *file = cq_context; 377 struct ib_uverbs_event_file *file = cq_context;
307 struct ib_ucq_object *uobj; 378 struct ib_ucq_object *uobj;
308 struct ib_uverbs_event *entry; 379 struct ib_uverbs_event *entry;
309 unsigned long flags; 380 unsigned long flags;
381
382 if (!file)
383 return;
384
385 spin_lock_irqsave(&file->lock, flags);
386 if (!file->file) {
387 spin_unlock_irqrestore(&file->lock, flags);
388 return;
389 }
310 390
311 entry = kmalloc(sizeof *entry, GFP_ATOMIC); 391 entry = kmalloc(sizeof *entry, GFP_ATOMIC);
312 if (!entry) 392 if (!entry) {
393 spin_unlock_irqrestore(&file->lock, flags);
313 return; 394 return;
395 }
314 396
315 uobj = container_of(cq->uobject, struct ib_ucq_object, uobject); 397 uobj = container_of(cq->uobject, struct ib_ucq_object, uobject);
316 398
317 entry->desc.comp.cq_handle = cq->uobject->user_handle; 399 entry->desc.comp.cq_handle = cq->uobject->user_handle;
318 entry->counter = &uobj->comp_events_reported; 400 entry->counter = &uobj->comp_events_reported;
319 401
320 spin_lock_irqsave(&file->comp_file[0].lock, flags); 402 list_add_tail(&entry->list, &file->event_list);
321 list_add_tail(&entry->list, &file->comp_file[0].event_list);
322 list_add_tail(&entry->obj_list, &uobj->comp_list); 403 list_add_tail(&entry->obj_list, &uobj->comp_list);
323 spin_unlock_irqrestore(&file->comp_file[0].lock, flags); 404 spin_unlock_irqrestore(&file->lock, flags);
324 405
325 wake_up_interruptible(&file->comp_file[0].poll_wait); 406 wake_up_interruptible(&file->poll_wait);
326 kill_fasync(&file->comp_file[0].async_queue, SIGIO, POLL_IN); 407 kill_fasync(&file->async_queue, SIGIO, POLL_IN);
327} 408}
328 409
329static void ib_uverbs_async_handler(struct ib_uverbs_file *file, 410static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
@@ -334,32 +415,40 @@ static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
334 struct ib_uverbs_event *entry; 415 struct ib_uverbs_event *entry;
335 unsigned long flags; 416 unsigned long flags;
336 417
418 spin_lock_irqsave(&file->async_file->lock, flags);
419 if (!file->async_file->file) {
420 spin_unlock_irqrestore(&file->async_file->lock, flags);
421 return;
422 }
423
337 entry = kmalloc(sizeof *entry, GFP_ATOMIC); 424 entry = kmalloc(sizeof *entry, GFP_ATOMIC);
338 if (!entry) 425 if (!entry) {
426 spin_unlock_irqrestore(&file->async_file->lock, flags);
339 return; 427 return;
428 }
340 429
341 entry->desc.async.element = element; 430 entry->desc.async.element = element;
342 entry->desc.async.event_type = event; 431 entry->desc.async.event_type = event;
343 entry->counter = counter; 432 entry->counter = counter;
344 433
345 spin_lock_irqsave(&file->async_file.lock, flags); 434 list_add_tail(&entry->list, &file->async_file->event_list);
346 list_add_tail(&entry->list, &file->async_file.event_list);
347 if (obj_list) 435 if (obj_list)
348 list_add_tail(&entry->obj_list, obj_list); 436 list_add_tail(&entry->obj_list, obj_list);
349 spin_unlock_irqrestore(&file->async_file.lock, flags); 437 spin_unlock_irqrestore(&file->async_file->lock, flags);
350 438
351 wake_up_interruptible(&file->async_file.poll_wait); 439 wake_up_interruptible(&file->async_file->poll_wait);
352 kill_fasync(&file->async_file.async_queue, SIGIO, POLL_IN); 440 kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN);
353} 441}
354 442
355void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr) 443void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
356{ 444{
445 struct ib_uverbs_event_file *ev_file = context_ptr;
357 struct ib_ucq_object *uobj; 446 struct ib_ucq_object *uobj;
358 447
359 uobj = container_of(event->element.cq->uobject, 448 uobj = container_of(event->element.cq->uobject,
360 struct ib_ucq_object, uobject); 449 struct ib_ucq_object, uobject);
361 450
362 ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle, 451 ib_uverbs_async_handler(ev_file->uverbs_file, uobj->uobject.user_handle,
363 event->event, &uobj->async_list, 452 event->event, &uobj->async_list,
364 &uobj->async_events_reported); 453 &uobj->async_events_reported);
365 454
@@ -389,8 +478,8 @@ void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr)
389 &uobj->events_reported); 478 &uobj->events_reported);
390} 479}
391 480
392static void ib_uverbs_event_handler(struct ib_event_handler *handler, 481void ib_uverbs_event_handler(struct ib_event_handler *handler,
393 struct ib_event *event) 482 struct ib_event *event)
394{ 483{
395 struct ib_uverbs_file *file = 484 struct ib_uverbs_file *file =
396 container_of(handler, struct ib_uverbs_file, event_handler); 485 container_of(handler, struct ib_uverbs_file, event_handler);
@@ -399,38 +488,90 @@ static void ib_uverbs_event_handler(struct ib_event_handler *handler,
399 NULL, NULL); 488 NULL, NULL);
400} 489}
401 490
402static int ib_uverbs_event_init(struct ib_uverbs_event_file *file, 491struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
403 struct ib_uverbs_file *uverbs_file) 492 int is_async, int *fd)
404{ 493{
494 struct ib_uverbs_event_file *ev_file;
405 struct file *filp; 495 struct file *filp;
496 int ret;
406 497
407 spin_lock_init(&file->lock); 498 ev_file = kmalloc(sizeof *ev_file, GFP_KERNEL);
408 INIT_LIST_HEAD(&file->event_list); 499 if (!ev_file)
409 init_waitqueue_head(&file->poll_wait); 500 return ERR_PTR(-ENOMEM);
410 file->uverbs_file = uverbs_file; 501
411 file->async_queue = NULL; 502 kref_init(&ev_file->ref);
412 503 spin_lock_init(&ev_file->lock);
413 file->fd = get_unused_fd(); 504 INIT_LIST_HEAD(&ev_file->event_list);
414 if (file->fd < 0) 505 init_waitqueue_head(&ev_file->poll_wait);
415 return file->fd; 506 ev_file->uverbs_file = uverbs_file;
507 ev_file->async_queue = NULL;
508 ev_file->is_async = is_async;
509
510 *fd = get_unused_fd();
511 if (*fd < 0) {
512 ret = *fd;
513 goto err;
514 }
416 515
417 filp = get_empty_filp(); 516 filp = get_empty_filp();
418 if (!filp) { 517 if (!filp) {
419 put_unused_fd(file->fd); 518 ret = -ENFILE;
420 return -ENFILE; 519 goto err_fd;
421 } 520 }
422 521
423 filp->f_op = &uverbs_event_fops; 522 ev_file->file = filp;
523
524 /*
525 * fops_get() can't fail here, because we're coming from a
526 * system call on a uverbs file, which will already have a
527 * module reference.
528 */
529 filp->f_op = fops_get(&uverbs_event_fops);
424 filp->f_vfsmnt = mntget(uverbs_event_mnt); 530 filp->f_vfsmnt = mntget(uverbs_event_mnt);
425 filp->f_dentry = dget(uverbs_event_mnt->mnt_root); 531 filp->f_dentry = dget(uverbs_event_mnt->mnt_root);
426 filp->f_mapping = filp->f_dentry->d_inode->i_mapping; 532 filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
427 filp->f_flags = O_RDONLY; 533 filp->f_flags = O_RDONLY;
428 filp->f_mode = FMODE_READ; 534 filp->f_mode = FMODE_READ;
429 filp->private_data = file; 535 filp->private_data = ev_file;
430 536
431 fd_install(file->fd, filp); 537 return filp;
432 538
433 return 0; 539err_fd:
540 put_unused_fd(*fd);
541
542err:
543 kfree(ev_file);
544 return ERR_PTR(ret);
545}
546
547/*
548 * Look up a completion event file by FD. If lookup is successful,
549 * takes a ref to the event file struct that it returns; if
550 * unsuccessful, returns NULL.
551 */
552struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
553{
554 struct ib_uverbs_event_file *ev_file = NULL;
555 struct file *filp;
556
557 filp = fget(fd);
558 if (!filp)
559 return NULL;
560
561 if (filp->f_op != &uverbs_event_fops)
562 goto out;
563
564 ev_file = filp->private_data;
565 if (ev_file->is_async) {
566 ev_file = NULL;
567 goto out;
568 }
569
570 kref_get(&ev_file->ref);
571
572out:
573 fput(filp);
574 return ev_file;
434} 575}
435 576
436static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, 577static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
@@ -450,11 +591,11 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
450 591
451 if (hdr.command < 0 || 592 if (hdr.command < 0 ||
452 hdr.command >= ARRAY_SIZE(uverbs_cmd_table) || 593 hdr.command >= ARRAY_SIZE(uverbs_cmd_table) ||
453 !uverbs_cmd_table[hdr.command]) 594 !uverbs_cmd_table[hdr.command] ||
595 !(file->device->ib_dev->uverbs_cmd_mask & (1ull << hdr.command)))
454 return -EINVAL; 596 return -EINVAL;
455 597
456 if (!file->ucontext && 598 if (!file->ucontext &&
457 hdr.command != IB_USER_VERBS_CMD_QUERY_PARAMS &&
458 hdr.command != IB_USER_VERBS_CMD_GET_CONTEXT) 599 hdr.command != IB_USER_VERBS_CMD_GET_CONTEXT)
459 return -EINVAL; 600 return -EINVAL;
460 601
@@ -474,84 +615,57 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
474 615
475static int ib_uverbs_open(struct inode *inode, struct file *filp) 616static int ib_uverbs_open(struct inode *inode, struct file *filp)
476{ 617{
477 struct ib_uverbs_device *dev = 618 struct ib_uverbs_device *dev;
478 container_of(inode->i_cdev, struct ib_uverbs_device, dev);
479 struct ib_uverbs_file *file; 619 struct ib_uverbs_file *file;
480 int i = 0;
481 int ret; 620 int ret;
482 621
483 if (!try_module_get(dev->ib_dev->owner)) 622 spin_lock(&map_lock);
484 return -ENODEV; 623 dev = dev_table[iminor(inode) - IB_UVERBS_BASE_MINOR];
624 if (dev)
625 kref_get(&dev->ref);
626 spin_unlock(&map_lock);
627
628 if (!dev)
629 return -ENXIO;
630
631 if (!try_module_get(dev->ib_dev->owner)) {
632 ret = -ENODEV;
633 goto err;
634 }
485 635
486 file = kmalloc(sizeof *file + 636 file = kmalloc(sizeof *file, GFP_KERNEL);
487 (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file),
488 GFP_KERNEL);
489 if (!file) { 637 if (!file) {
490 ret = -ENOMEM; 638 ret = -ENOMEM;
491 goto err; 639 goto err_module;
492 } 640 }
493 641
494 file->device = dev; 642 file->device = dev;
643 file->ucontext = NULL;
644 file->async_file = NULL;
495 kref_init(&file->ref); 645 kref_init(&file->ref);
496 init_MUTEX(&file->mutex); 646 init_MUTEX(&file->mutex);
497 647
498 file->ucontext = NULL;
499
500 kref_get(&file->ref);
501 ret = ib_uverbs_event_init(&file->async_file, file);
502 if (ret)
503 goto err_kref;
504
505 file->async_file.is_async = 1;
506
507 for (i = 0; i < dev->num_comp; ++i) {
508 kref_get(&file->ref);
509 ret = ib_uverbs_event_init(&file->comp_file[i], file);
510 if (ret)
511 goto err_async;
512 file->comp_file[i].is_async = 0;
513 }
514
515
516 filp->private_data = file; 648 filp->private_data = file;
517 649
518 INIT_IB_EVENT_HANDLER(&file->event_handler, dev->ib_dev,
519 ib_uverbs_event_handler);
520 if (ib_register_event_handler(&file->event_handler))
521 goto err_async;
522
523 return 0; 650 return 0;
524 651
525err_async: 652err_module:
526 while (i--) 653 module_put(dev->ib_dev->owner);
527 ib_uverbs_event_release(&file->comp_file[i]);
528
529 ib_uverbs_event_release(&file->async_file);
530
531err_kref:
532 /*
533 * One extra kref_put() because we took a reference before the
534 * event file creation that failed and got us here.
535 */
536 kref_put(&file->ref, ib_uverbs_release_file);
537 kref_put(&file->ref, ib_uverbs_release_file);
538 654
539err: 655err:
540 module_put(dev->ib_dev->owner); 656 kref_put(&dev->ref, ib_uverbs_release_dev);
657
541 return ret; 658 return ret;
542} 659}
543 660
544static int ib_uverbs_close(struct inode *inode, struct file *filp) 661static int ib_uverbs_close(struct inode *inode, struct file *filp)
545{ 662{
546 struct ib_uverbs_file *file = filp->private_data; 663 struct ib_uverbs_file *file = filp->private_data;
547 int i;
548 664
549 ib_unregister_event_handler(&file->event_handler); 665 ib_uverbs_cleanup_ucontext(file, file->ucontext);
550 ib_uverbs_event_release(&file->async_file);
551 ib_dealloc_ucontext(file->ucontext);
552 666
553 for (i = 0; i < file->device->num_comp; ++i) 667 if (file->async_file)
554 ib_uverbs_event_release(&file->comp_file[i]); 668 kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
555 669
556 kref_put(&file->ref, ib_uverbs_release_file); 670 kref_put(&file->ref, ib_uverbs_release_file);
557 671
@@ -581,27 +695,25 @@ static struct ib_client uverbs_client = {
581 695
582static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 696static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
583{ 697{
584 struct ib_uverbs_device *dev = 698 struct ib_uverbs_device *dev = class_get_devdata(class_dev);
585 container_of(class_dev, struct ib_uverbs_device, class_dev); 699
700 if (!dev)
701 return -ENODEV;
586 702
587 return sprintf(buf, "%s\n", dev->ib_dev->name); 703 return sprintf(buf, "%s\n", dev->ib_dev->name);
588} 704}
589static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 705static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
590 706
591static void ib_uverbs_release_class_dev(struct class_device *class_dev) 707static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf)
592{ 708{
593 struct ib_uverbs_device *dev = 709 struct ib_uverbs_device *dev = class_get_devdata(class_dev);
594 container_of(class_dev, struct ib_uverbs_device, class_dev);
595 710
596 cdev_del(&dev->dev); 711 if (!dev)
597 clear_bit(dev->devnum, dev_map); 712 return -ENODEV;
598 kfree(dev);
599}
600 713
601static struct class uverbs_class = { 714 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver);
602 .name = "infiniband_verbs", 715}
603 .release = ib_uverbs_release_class_dev 716static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
604};
605 717
606static ssize_t show_abi_version(struct class *class, char *buf) 718static ssize_t show_abi_version(struct class *class, char *buf)
607{ 719{
@@ -622,6 +734,8 @@ static void ib_uverbs_add_one(struct ib_device *device)
622 734
623 memset(uverbs_dev, 0, sizeof *uverbs_dev); 735 memset(uverbs_dev, 0, sizeof *uverbs_dev);
624 736
737 kref_init(&uverbs_dev->ref);
738
625 spin_lock(&map_lock); 739 spin_lock(&map_lock);
626 uverbs_dev->devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); 740 uverbs_dev->devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
627 if (uverbs_dev->devnum >= IB_UVERBS_MAX_DEVICES) { 741 if (uverbs_dev->devnum >= IB_UVERBS_MAX_DEVICES) {
@@ -631,41 +745,49 @@ static void ib_uverbs_add_one(struct ib_device *device)
631 set_bit(uverbs_dev->devnum, dev_map); 745 set_bit(uverbs_dev->devnum, dev_map);
632 spin_unlock(&map_lock); 746 spin_unlock(&map_lock);
633 747
634 uverbs_dev->ib_dev = device; 748 uverbs_dev->ib_dev = device;
635 uverbs_dev->num_comp = 1; 749 uverbs_dev->num_comp_vectors = 1;
636 750
637 if (device->mmap) 751 uverbs_dev->dev = cdev_alloc();
638 cdev_init(&uverbs_dev->dev, &uverbs_mmap_fops); 752 if (!uverbs_dev->dev)
639 else
640 cdev_init(&uverbs_dev->dev, &uverbs_fops);
641 uverbs_dev->dev.owner = THIS_MODULE;
642 kobject_set_name(&uverbs_dev->dev.kobj, "uverbs%d", uverbs_dev->devnum);
643 if (cdev_add(&uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
644 goto err; 753 goto err;
754 uverbs_dev->dev->owner = THIS_MODULE;
755 uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
756 kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum);
757 if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
758 goto err_cdev;
645 759
646 uverbs_dev->class_dev.class = &uverbs_class; 760 uverbs_dev->class_dev = class_device_create(uverbs_class, NULL,
647 uverbs_dev->class_dev.dev = device->dma_device; 761 uverbs_dev->dev->dev,
648 uverbs_dev->class_dev.devt = uverbs_dev->dev.dev; 762 device->dma_device,
649 snprintf(uverbs_dev->class_dev.class_id, BUS_ID_SIZE, "uverbs%d", uverbs_dev->devnum); 763 "uverbs%d", uverbs_dev->devnum);
650 if (class_device_register(&uverbs_dev->class_dev)) 764 if (IS_ERR(uverbs_dev->class_dev))
651 goto err_cdev; 765 goto err_cdev;
652 766
653 if (class_device_create_file(&uverbs_dev->class_dev, &class_device_attr_ibdev)) 767 class_set_devdata(uverbs_dev->class_dev, uverbs_dev);
768
769 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev))
654 goto err_class; 770 goto err_class;
771 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version))
772 goto err_class;
773
774 spin_lock(&map_lock);
775 dev_table[uverbs_dev->devnum] = uverbs_dev;
776 spin_unlock(&map_lock);
655 777
656 ib_set_client_data(device, &uverbs_client, uverbs_dev); 778 ib_set_client_data(device, &uverbs_client, uverbs_dev);
657 779
658 return; 780 return;
659 781
660err_class: 782err_class:
661 class_device_unregister(&uverbs_dev->class_dev); 783 class_device_destroy(uverbs_class, uverbs_dev->dev->dev);
662 784
663err_cdev: 785err_cdev:
664 cdev_del(&uverbs_dev->dev); 786 cdev_del(uverbs_dev->dev);
665 clear_bit(uverbs_dev->devnum, dev_map); 787 clear_bit(uverbs_dev->devnum, dev_map);
666 788
667err: 789err:
668 kfree(uverbs_dev); 790 kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
669 return; 791 return;
670} 792}
671 793
@@ -676,7 +798,16 @@ static void ib_uverbs_remove_one(struct ib_device *device)
676 if (!uverbs_dev) 798 if (!uverbs_dev)
677 return; 799 return;
678 800
679 class_device_unregister(&uverbs_dev->class_dev); 801 class_set_devdata(uverbs_dev->class_dev, NULL);
802 class_device_destroy(uverbs_class, uverbs_dev->dev->dev);
803 cdev_del(uverbs_dev->dev);
804
805 spin_lock(&map_lock);
806 dev_table[uverbs_dev->devnum] = NULL;
807 spin_unlock(&map_lock);
808
809 clear_bit(uverbs_dev->devnum, dev_map);
810 kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
680} 811}
681 812
682static struct super_block *uverbs_event_get_sb(struct file_system_type *fs_type, int flags, 813static struct super_block *uverbs_event_get_sb(struct file_system_type *fs_type, int flags,
@@ -706,13 +837,14 @@ static int __init ib_uverbs_init(void)
706 goto out; 837 goto out;
707 } 838 }
708 839
709 ret = class_register(&uverbs_class); 840 uverbs_class = class_create(THIS_MODULE, "infiniband_verbs");
710 if (ret) { 841 if (IS_ERR(uverbs_class)) {
842 ret = PTR_ERR(uverbs_class);
711 printk(KERN_ERR "user_verbs: couldn't create class infiniband_verbs\n"); 843 printk(KERN_ERR "user_verbs: couldn't create class infiniband_verbs\n");
712 goto out_chrdev; 844 goto out_chrdev;
713 } 845 }
714 846
715 ret = class_create_file(&uverbs_class, &class_attr_abi_version); 847 ret = class_create_file(uverbs_class, &class_attr_abi_version);
716 if (ret) { 848 if (ret) {
717 printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n"); 849 printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n");
718 goto out_class; 850 goto out_class;
@@ -746,7 +878,7 @@ out_fs:
746 unregister_filesystem(&uverbs_event_fs); 878 unregister_filesystem(&uverbs_event_fs);
747 879
748out_class: 880out_class:
749 class_unregister(&uverbs_class); 881 class_destroy(uverbs_class);
750 882
751out_chrdev: 883out_chrdev:
752 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES); 884 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
@@ -760,8 +892,15 @@ static void __exit ib_uverbs_cleanup(void)
760 ib_unregister_client(&uverbs_client); 892 ib_unregister_client(&uverbs_client);
761 mntput(uverbs_event_mnt); 893 mntput(uverbs_event_mnt);
762 unregister_filesystem(&uverbs_event_fs); 894 unregister_filesystem(&uverbs_event_fs);
763 class_unregister(&uverbs_class); 895 class_destroy(uverbs_class);
764 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES); 896 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
897 idr_destroy(&ib_uverbs_pd_idr);
898 idr_destroy(&ib_uverbs_mr_idr);
899 idr_destroy(&ib_uverbs_mw_idr);
900 idr_destroy(&ib_uverbs_ah_idr);
901 idr_destroy(&ib_uverbs_cq_idr);
902 idr_destroy(&ib_uverbs_qp_idr);
903 idr_destroy(&ib_uverbs_srq_idr);
765} 904}
766 905
767module_init(ib_uverbs_init); 906module_init(ib_uverbs_init);
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 5081d903e561..72d3ef786db5 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -523,16 +523,22 @@ EXPORT_SYMBOL(ib_dealloc_fmr);
523 523
524int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid) 524int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
525{ 525{
526 return qp->device->attach_mcast ? 526 if (!qp->device->attach_mcast)
527 qp->device->attach_mcast(qp, gid, lid) : 527 return -ENOSYS;
528 -ENOSYS; 528 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
529 return -EINVAL;
530
531 return qp->device->attach_mcast(qp, gid, lid);
529} 532}
530EXPORT_SYMBOL(ib_attach_mcast); 533EXPORT_SYMBOL(ib_attach_mcast);
531 534
532int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid) 535int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
533{ 536{
534 return qp->device->detach_mcast ? 537 if (!qp->device->detach_mcast)
535 qp->device->detach_mcast(qp, gid, lid) : 538 return -ENOSYS;
536 -ENOSYS; 539 if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
540 return -EINVAL;
541
542 return qp->device->detach_mcast(qp, gid, lid);
537} 543}
538EXPORT_SYMBOL(ib_detach_mcast); 544EXPORT_SYMBOL(ib_detach_mcast);
diff --git a/drivers/infiniband/hw/mthca/Makefile b/drivers/infiniband/hw/mthca/Makefile
index c44f7bae5424..47ec5a7cba0b 100644
--- a/drivers/infiniband/hw/mthca/Makefile
+++ b/drivers/infiniband/hw/mthca/Makefile
@@ -7,4 +7,5 @@ obj-$(CONFIG_INFINIBAND_MTHCA) += ib_mthca.o
7ib_mthca-y := mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \ 7ib_mthca-y := mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \
8 mthca_allocator.o mthca_eq.o mthca_pd.o mthca_cq.o \ 8 mthca_allocator.o mthca_eq.o mthca_pd.o mthca_cq.o \
9 mthca_mr.o mthca_qp.o mthca_av.o mthca_mcg.o mthca_mad.o \ 9 mthca_mr.o mthca_qp.o mthca_av.o mthca_mcg.o mthca_mad.o \
10 mthca_provider.o mthca_memfree.o mthca_uar.o mthca_srq.o 10 mthca_provider.o mthca_memfree.o mthca_uar.o mthca_srq.o \
11 mthca_catas.o
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
new file mode 100644
index 000000000000..7ac52af43b99
--- /dev/null
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -0,0 +1,153 @@
1/*
2 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 *
32 * $Id$
33 */
34
35#include "mthca_dev.h"
36
37enum {
38 MTHCA_CATAS_POLL_INTERVAL = 5 * HZ,
39
40 MTHCA_CATAS_TYPE_INTERNAL = 0,
41 MTHCA_CATAS_TYPE_UPLINK = 3,
42 MTHCA_CATAS_TYPE_DDR = 4,
43 MTHCA_CATAS_TYPE_PARITY = 5,
44};
45
46static DEFINE_SPINLOCK(catas_lock);
47
48static void handle_catas(struct mthca_dev *dev)
49{
50 struct ib_event event;
51 const char *type;
52 int i;
53
54 event.device = &dev->ib_dev;
55 event.event = IB_EVENT_DEVICE_FATAL;
56 event.element.port_num = 0;
57
58 ib_dispatch_event(&event);
59
60 switch (swab32(readl(dev->catas_err.map)) >> 24) {
61 case MTHCA_CATAS_TYPE_INTERNAL:
62 type = "internal error";
63 break;
64 case MTHCA_CATAS_TYPE_UPLINK:
65 type = "uplink bus error";
66 break;
67 case MTHCA_CATAS_TYPE_DDR:
68 type = "DDR data error";
69 break;
70 case MTHCA_CATAS_TYPE_PARITY:
71 type = "internal parity error";
72 break;
73 default:
74 type = "unknown error";
75 break;
76 }
77
78 mthca_err(dev, "Catastrophic error detected: %s\n", type);
79 for (i = 0; i < dev->catas_err.size; ++i)
80 mthca_err(dev, " buf[%02x]: %08x\n",
81 i, swab32(readl(dev->catas_err.map + i)));
82}
83
84static void poll_catas(unsigned long dev_ptr)
85{
86 struct mthca_dev *dev = (struct mthca_dev *) dev_ptr;
87 unsigned long flags;
88 int i;
89
90 for (i = 0; i < dev->catas_err.size; ++i)
91 if (readl(dev->catas_err.map + i)) {
92 handle_catas(dev);
93 return;
94 }
95
96 spin_lock_irqsave(&catas_lock, flags);
97 if (dev->catas_err.stop)
98 mod_timer(&dev->catas_err.timer,
99 jiffies + MTHCA_CATAS_POLL_INTERVAL);
100 spin_unlock_irqrestore(&catas_lock, flags);
101
102 return;
103}
104
105void mthca_start_catas_poll(struct mthca_dev *dev)
106{
107 unsigned long addr;
108
109 init_timer(&dev->catas_err.timer);
110 dev->catas_err.stop = 0;
111 dev->catas_err.map = NULL;
112
113 addr = pci_resource_start(dev->pdev, 0) +
114 ((pci_resource_len(dev->pdev, 0) - 1) &
115 dev->catas_err.addr);
116
117 if (!request_mem_region(addr, dev->catas_err.size * 4,
118 DRV_NAME)) {
119 mthca_warn(dev, "couldn't request catastrophic error region "
120 "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4);
121 return;
122 }
123
124 dev->catas_err.map = ioremap(addr, dev->catas_err.size * 4);
125 if (!dev->catas_err.map) {
126 mthca_warn(dev, "couldn't map catastrophic error region "
127 "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4);
128 release_mem_region(addr, dev->catas_err.size * 4);
129 return;
130 }
131
132 dev->catas_err.timer.data = (unsigned long) dev;
133 dev->catas_err.timer.function = poll_catas;
134 dev->catas_err.timer.expires = jiffies + MTHCA_CATAS_POLL_INTERVAL;
135 add_timer(&dev->catas_err.timer);
136}
137
138void mthca_stop_catas_poll(struct mthca_dev *dev)
139{
140 spin_lock_irq(&catas_lock);
141 dev->catas_err.stop = 1;
142 spin_unlock_irq(&catas_lock);
143
144 del_timer_sync(&dev->catas_err.timer);
145
146 if (dev->catas_err.map) {
147 iounmap(dev->catas_err.map);
148 release_mem_region(pci_resource_start(dev->pdev, 0) +
149 ((pci_resource_len(dev->pdev, 0) - 1) &
150 dev->catas_err.addr),
151 dev->catas_err.size * 4);
152 }
153}
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index f6a8ac026557..49f211d55df7 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -524,7 +525,7 @@ void mthca_cmd_use_polling(struct mthca_dev *dev)
524} 525}
525 526
526struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev, 527struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
527 unsigned int gfp_mask) 528 gfp_t gfp_mask)
528{ 529{
529 struct mthca_mailbox *mailbox; 530 struct mthca_mailbox *mailbox;
530 531
@@ -706,9 +707,13 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status)
706 707
707 MTHCA_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET); 708 MTHCA_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET);
708 dev->cmd.max_cmds = 1 << lg; 709 dev->cmd.max_cmds = 1 << lg;
710 MTHCA_GET(dev->catas_err.addr, outbox, QUERY_FW_ERR_START_OFFSET);
711 MTHCA_GET(dev->catas_err.size, outbox, QUERY_FW_ERR_SIZE_OFFSET);
709 712
710 mthca_dbg(dev, "FW version %012llx, max commands %d\n", 713 mthca_dbg(dev, "FW version %012llx, max commands %d\n",
711 (unsigned long long) dev->fw_ver, dev->cmd.max_cmds); 714 (unsigned long long) dev->fw_ver, dev->cmd.max_cmds);
715 mthca_dbg(dev, "Catastrophic error buffer at 0x%llx, size 0x%x\n",
716 (unsigned long long) dev->catas_err.addr, dev->catas_err.size);
712 717
713 if (mthca_is_memfree(dev)) { 718 if (mthca_is_memfree(dev)) {
714 MTHCA_GET(dev->fw.arbel.fw_pages, outbox, QUERY_FW_SIZE_OFFSET); 719 MTHCA_GET(dev->fw.arbel.fw_pages, outbox, QUERY_FW_SIZE_OFFSET);
@@ -933,9 +938,9 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
933 goto out; 938 goto out;
934 939
935 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET); 940 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET);
936 dev_lim->max_srq_sz = 1 << field; 941 dev_lim->max_srq_sz = (1 << field) - 1;
937 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET); 942 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET);
938 dev_lim->max_qp_sz = 1 << field; 943 dev_lim->max_qp_sz = (1 << field) - 1;
939 MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_QP_OFFSET); 944 MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_QP_OFFSET);
940 dev_lim->reserved_qps = 1 << (field & 0xf); 945 dev_lim->reserved_qps = 1 << (field & 0xf);
941 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_OFFSET); 946 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_OFFSET);
@@ -1045,6 +1050,8 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
1045 dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars); 1050 dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars);
1046 mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n", 1051 mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n",
1047 dev_lim->max_pds, dev_lim->reserved_mgms); 1052 dev_lim->max_pds, dev_lim->reserved_mgms);
1053 mthca_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n",
1054 dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz);
1048 1055
1049 mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags); 1056 mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags);
1050 1057
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h
index 65f976a13e02..18175bec84c2 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.h
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.h
@@ -248,7 +248,7 @@ void mthca_cmd_event(struct mthca_dev *dev, u16 token,
248 u8 status, u64 out_param); 248 u8 status, u64 out_param);
249 249
250struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev, 250struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
251 unsigned int gfp_mask); 251 gfp_t gfp_mask);
252void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox); 252void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox);
253 253
254int mthca_SYS_EN(struct mthca_dev *dev, u8 *status); 254int mthca_SYS_EN(struct mthca_dev *dev, u8 *status);
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 7bff5a8425f4..7e68bd4a3780 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -83,6 +83,8 @@ enum {
83 /* Arbel FW gives us these, but we need them for Tavor */ 83 /* Arbel FW gives us these, but we need them for Tavor */
84 MTHCA_MPT_ENTRY_SIZE = 0x40, 84 MTHCA_MPT_ENTRY_SIZE = 0x40,
85 MTHCA_MTT_SEG_SIZE = 0x40, 85 MTHCA_MTT_SEG_SIZE = 0x40,
86
87 MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2)
86}; 88};
87 89
88enum { 90enum {
@@ -128,12 +130,16 @@ struct mthca_limits {
128 int num_uars; 130 int num_uars;
129 int max_sg; 131 int max_sg;
130 int num_qps; 132 int num_qps;
133 int max_wqes;
134 int max_qp_init_rdma;
131 int reserved_qps; 135 int reserved_qps;
132 int num_srqs; 136 int num_srqs;
137 int max_srq_wqes;
133 int reserved_srqs; 138 int reserved_srqs;
134 int num_eecs; 139 int num_eecs;
135 int reserved_eecs; 140 int reserved_eecs;
136 int num_cqs; 141 int num_cqs;
142 int max_cqes;
137 int reserved_cqs; 143 int reserved_cqs;
138 int num_eqs; 144 int num_eqs;
139 int reserved_eqs; 145 int reserved_eqs;
@@ -148,6 +154,7 @@ struct mthca_limits {
148 int reserved_mcgs; 154 int reserved_mcgs;
149 int num_pds; 155 int num_pds;
150 int reserved_pds; 156 int reserved_pds;
157 u32 flags;
151 u8 port_width_cap; 158 u8 port_width_cap;
152}; 159};
153 160
@@ -251,6 +258,14 @@ struct mthca_mcg_table {
251 struct mthca_icm_table *table; 258 struct mthca_icm_table *table;
252}; 259};
253 260
261struct mthca_catas_err {
262 u64 addr;
263 u32 __iomem *map;
264 unsigned long stop;
265 u32 size;
266 struct timer_list timer;
267};
268
254struct mthca_dev { 269struct mthca_dev {
255 struct ib_device ib_dev; 270 struct ib_device ib_dev;
256 struct pci_dev *pdev; 271 struct pci_dev *pdev;
@@ -311,6 +326,8 @@ struct mthca_dev {
311 struct mthca_av_table av_table; 326 struct mthca_av_table av_table;
312 struct mthca_mcg_table mcg_table; 327 struct mthca_mcg_table mcg_table;
313 328
329 struct mthca_catas_err catas_err;
330
314 struct mthca_uar driver_uar; 331 struct mthca_uar driver_uar;
315 struct mthca_db_table *db_tab; 332 struct mthca_db_table *db_tab;
316 struct mthca_pd driver_pd; 333 struct mthca_pd driver_pd;
@@ -398,6 +415,9 @@ void mthca_cleanup_mcg_table(struct mthca_dev *dev);
398int mthca_register_device(struct mthca_dev *dev); 415int mthca_register_device(struct mthca_dev *dev);
399void mthca_unregister_device(struct mthca_dev *dev); 416void mthca_unregister_device(struct mthca_dev *dev);
400 417
418void mthca_start_catas_poll(struct mthca_dev *dev);
419void mthca_stop_catas_poll(struct mthca_dev *dev);
420
401int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); 421int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
402void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); 422void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
403 423
@@ -447,6 +467,8 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn,
447int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, 467int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
448 struct ib_srq_attr *attr, struct mthca_srq *srq); 468 struct ib_srq_attr *attr, struct mthca_srq *srq);
449void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq); 469void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
470int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
471 enum ib_srq_attr_mask attr_mask);
450void mthca_srq_event(struct mthca_dev *dev, u32 srqn, 472void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
451 enum ib_event_type event_type); 473 enum ib_event_type event_type);
452void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr); 474void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 8dfafda5ed24..e5a047a6dbeb 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -83,7 +83,8 @@ enum {
83 MTHCA_EVENT_TYPE_PATH_MIG = 0x01, 83 MTHCA_EVENT_TYPE_PATH_MIG = 0x01,
84 MTHCA_EVENT_TYPE_COMM_EST = 0x02, 84 MTHCA_EVENT_TYPE_COMM_EST = 0x02,
85 MTHCA_EVENT_TYPE_SQ_DRAINED = 0x03, 85 MTHCA_EVENT_TYPE_SQ_DRAINED = 0x03,
86 MTHCA_EVENT_TYPE_SRQ_LAST_WQE = 0x13, 86 MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE = 0x13,
87 MTHCA_EVENT_TYPE_SRQ_LIMIT = 0x14,
87 MTHCA_EVENT_TYPE_CQ_ERROR = 0x04, 88 MTHCA_EVENT_TYPE_CQ_ERROR = 0x04,
88 MTHCA_EVENT_TYPE_WQ_CATAS_ERROR = 0x05, 89 MTHCA_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
89 MTHCA_EVENT_TYPE_EEC_CATAS_ERROR = 0x06, 90 MTHCA_EVENT_TYPE_EEC_CATAS_ERROR = 0x06,
@@ -110,8 +111,9 @@ enum {
110 (1ULL << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \ 111 (1ULL << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \
111 (1ULL << MTHCA_EVENT_TYPE_PORT_CHANGE) | \ 112 (1ULL << MTHCA_EVENT_TYPE_PORT_CHANGE) | \
112 (1ULL << MTHCA_EVENT_TYPE_ECC_DETECT)) 113 (1ULL << MTHCA_EVENT_TYPE_ECC_DETECT))
113#define MTHCA_SRQ_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \ 114#define MTHCA_SRQ_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \
114 (1ULL << MTHCA_EVENT_TYPE_SRQ_LAST_WQE) 115 (1ULL << MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE) | \
116 (1ULL << MTHCA_EVENT_TYPE_SRQ_LIMIT))
115#define MTHCA_CMD_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_CMD) 117#define MTHCA_CMD_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_CMD)
116 118
117#define MTHCA_EQ_DB_INC_CI (1 << 24) 119#define MTHCA_EQ_DB_INC_CI (1 << 24)
@@ -142,6 +144,9 @@ struct mthca_eqe {
142 __be32 qpn; 144 __be32 qpn;
143 } __attribute__((packed)) qp; 145 } __attribute__((packed)) qp;
144 struct { 146 struct {
147 __be32 srqn;
148 } __attribute__((packed)) srq;
149 struct {
145 __be32 cqn; 150 __be32 cqn;
146 u32 reserved1; 151 u32 reserved1;
147 u8 reserved2[3]; 152 u8 reserved2[3];
@@ -305,6 +310,16 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq)
305 IB_EVENT_SQ_DRAINED); 310 IB_EVENT_SQ_DRAINED);
306 break; 311 break;
307 312
313 case MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE:
314 mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
315 IB_EVENT_QP_LAST_WQE_REACHED);
316 break;
317
318 case MTHCA_EVENT_TYPE_SRQ_LIMIT:
319 mthca_srq_event(dev, be32_to_cpu(eqe->event.srq.srqn) & 0xffffff,
320 IB_EVENT_SRQ_LIMIT_REACHED);
321 break;
322
308 case MTHCA_EVENT_TYPE_WQ_CATAS_ERROR: 323 case MTHCA_EVENT_TYPE_WQ_CATAS_ERROR:
309 mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff, 324 mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
310 IB_EVENT_QP_FATAL); 325 IB_EVENT_QP_FATAL);
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 9804174f7f3c..8561b297a19b 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -46,11 +46,6 @@ enum {
46 MTHCA_VENDOR_CLASS2 = 0xa 46 MTHCA_VENDOR_CLASS2 = 0xa
47}; 47};
48 48
49struct mthca_trap_mad {
50 struct ib_mad *mad;
51 DECLARE_PCI_UNMAP_ADDR(mapping)
52};
53
54static void update_sm_ah(struct mthca_dev *dev, 49static void update_sm_ah(struct mthca_dev *dev,
55 u8 port_num, u16 lid, u8 sl) 50 u8 port_num, u16 lid, u8 sl)
56{ 51{
@@ -116,49 +111,14 @@ static void forward_trap(struct mthca_dev *dev,
116 struct ib_mad *mad) 111 struct ib_mad *mad)
117{ 112{
118 int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED; 113 int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED;
119 struct mthca_trap_mad *tmad; 114 struct ib_mad_send_buf *send_buf;
120 struct ib_sge gather_list;
121 struct ib_send_wr *bad_wr, wr = {
122 .opcode = IB_WR_SEND,
123 .sg_list = &gather_list,
124 .num_sge = 1,
125 .send_flags = IB_SEND_SIGNALED,
126 .wr = {
127 .ud = {
128 .remote_qpn = qpn,
129 .remote_qkey = qpn ? IB_QP1_QKEY : 0,
130 .timeout_ms = 0
131 }
132 }
133 };
134 struct ib_mad_agent *agent = dev->send_agent[port_num - 1][qpn]; 115 struct ib_mad_agent *agent = dev->send_agent[port_num - 1][qpn];
135 int ret; 116 int ret;
136 unsigned long flags; 117 unsigned long flags;
137 118
138 if (agent) { 119 if (agent) {
139 tmad = kmalloc(sizeof *tmad, GFP_KERNEL); 120 send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
140 if (!tmad) 121 IB_MGMT_MAD_DATA, GFP_ATOMIC);
141 return;
142
143 tmad->mad = kmalloc(sizeof *tmad->mad, GFP_KERNEL);
144 if (!tmad->mad) {
145 kfree(tmad);
146 return;
147 }
148
149 memcpy(tmad->mad, mad, sizeof *mad);
150
151 wr.wr.ud.mad_hdr = &tmad->mad->mad_hdr;
152 wr.wr_id = (unsigned long) tmad;
153
154 gather_list.addr = dma_map_single(agent->device->dma_device,
155 tmad->mad,
156 sizeof *tmad->mad,
157 DMA_TO_DEVICE);
158 gather_list.length = sizeof *tmad->mad;
159 gather_list.lkey = to_mpd(agent->qp->pd)->ntmr.ibmr.lkey;
160 pci_unmap_addr_set(tmad, mapping, gather_list.addr);
161
162 /* 122 /*
163 * We rely here on the fact that MLX QPs don't use the 123 * We rely here on the fact that MLX QPs don't use the
164 * address handle after the send is posted (this is 124 * address handle after the send is posted (this is
@@ -166,21 +126,15 @@ static void forward_trap(struct mthca_dev *dev,
166 * it's OK for our devices). 126 * it's OK for our devices).
167 */ 127 */
168 spin_lock_irqsave(&dev->sm_lock, flags); 128 spin_lock_irqsave(&dev->sm_lock, flags);
169 wr.wr.ud.ah = dev->sm_ah[port_num - 1]; 129 memcpy(send_buf->mad, mad, sizeof *mad);
170 if (wr.wr.ud.ah) 130 if ((send_buf->ah = dev->sm_ah[port_num - 1]))
171 ret = ib_post_send_mad(agent, &wr, &bad_wr); 131 ret = ib_post_send_mad(send_buf, NULL);
172 else 132 else
173 ret = -EINVAL; 133 ret = -EINVAL;
174 spin_unlock_irqrestore(&dev->sm_lock, flags); 134 spin_unlock_irqrestore(&dev->sm_lock, flags);
175 135
176 if (ret) { 136 if (ret)
177 dma_unmap_single(agent->device->dma_device, 137 ib_free_send_mad(send_buf);
178 pci_unmap_addr(tmad, mapping),
179 sizeof *tmad->mad,
180 DMA_TO_DEVICE);
181 kfree(tmad->mad);
182 kfree(tmad);
183 }
184 } 138 }
185} 139}
186 140
@@ -267,15 +221,7 @@ int mthca_process_mad(struct ib_device *ibdev,
267static void send_handler(struct ib_mad_agent *agent, 221static void send_handler(struct ib_mad_agent *agent,
268 struct ib_mad_send_wc *mad_send_wc) 222 struct ib_mad_send_wc *mad_send_wc)
269{ 223{
270 struct mthca_trap_mad *tmad = 224 ib_free_send_mad(mad_send_wc->send_buf);
271 (void *) (unsigned long) mad_send_wc->wr_id;
272
273 dma_unmap_single(agent->device->dma_device,
274 pci_unmap_addr(tmad, mapping),
275 sizeof *tmad->mad,
276 DMA_TO_DEVICE);
277 kfree(tmad->mad);
278 kfree(tmad);
279} 225}
280 226
281int mthca_create_agents(struct mthca_dev *dev) 227int mthca_create_agents(struct mthca_dev *dev)
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 23a3f56c7899..883d1e5a79bc 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -162,9 +162,18 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
162 mdev->limits.pkey_table_len = dev_lim->max_pkeys; 162 mdev->limits.pkey_table_len = dev_lim->max_pkeys;
163 mdev->limits.local_ca_ack_delay = dev_lim->local_ca_ack_delay; 163 mdev->limits.local_ca_ack_delay = dev_lim->local_ca_ack_delay;
164 mdev->limits.max_sg = dev_lim->max_sg; 164 mdev->limits.max_sg = dev_lim->max_sg;
165 mdev->limits.max_wqes = dev_lim->max_qp_sz;
166 mdev->limits.max_qp_init_rdma = dev_lim->max_requester_per_qp;
165 mdev->limits.reserved_qps = dev_lim->reserved_qps; 167 mdev->limits.reserved_qps = dev_lim->reserved_qps;
168 mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
166 mdev->limits.reserved_srqs = dev_lim->reserved_srqs; 169 mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
167 mdev->limits.reserved_eecs = dev_lim->reserved_eecs; 170 mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
171 /*
172 * Subtract 1 from the limit because we need to allocate a
173 * spare CQE so the HCA HW can tell the difference between an
174 * empty CQ and a full CQ.
175 */
176 mdev->limits.max_cqes = dev_lim->max_cq_sz - 1;
168 mdev->limits.reserved_cqs = dev_lim->reserved_cqs; 177 mdev->limits.reserved_cqs = dev_lim->reserved_cqs;
169 mdev->limits.reserved_eqs = dev_lim->reserved_eqs; 178 mdev->limits.reserved_eqs = dev_lim->reserved_eqs;
170 mdev->limits.reserved_mtts = dev_lim->reserved_mtts; 179 mdev->limits.reserved_mtts = dev_lim->reserved_mtts;
@@ -172,6 +181,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
172 mdev->limits.reserved_uars = dev_lim->reserved_uars; 181 mdev->limits.reserved_uars = dev_lim->reserved_uars;
173 mdev->limits.reserved_pds = dev_lim->reserved_pds; 182 mdev->limits.reserved_pds = dev_lim->reserved_pds;
174 mdev->limits.port_width_cap = dev_lim->max_port_width; 183 mdev->limits.port_width_cap = dev_lim->max_port_width;
184 mdev->limits.flags = dev_lim->flags;
175 185
176 /* IB_DEVICE_RESIZE_MAX_WR not supported by driver. 186 /* IB_DEVICE_RESIZE_MAX_WR not supported by driver.
177 May be doable since hardware supports it for SRQ. 187 May be doable since hardware supports it for SRQ.
@@ -1186,6 +1196,7 @@ MODULE_DEVICE_TABLE(pci, mthca_pci_table);
1186 1196
1187static struct pci_driver mthca_driver = { 1197static struct pci_driver mthca_driver = {
1188 .name = DRV_NAME, 1198 .name = DRV_NAME,
1199 .owner = THIS_MODULE,
1189 .id_table = mthca_pci_table, 1200 .id_table = mthca_pci_table,
1190 .probe = mthca_init_one, 1201 .probe = mthca_init_one,
1191 .remove = __devexit_p(mthca_remove_one) 1202 .remove = __devexit_p(mthca_remove_one)
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index a2707605f4c8..b47ea7daf088 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -37,10 +37,6 @@
37#include "mthca_dev.h" 37#include "mthca_dev.h"
38#include "mthca_cmd.h" 38#include "mthca_cmd.h"
39 39
40enum {
41 MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2)
42};
43
44struct mthca_mgm { 40struct mthca_mgm {
45 __be32 next_gid_index; 41 __be32 next_gid_index;
46 u32 reserved[3]; 42 u32 reserved[3];
@@ -189,7 +185,12 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
189 } 185 }
190 186
191 for (i = 0; i < MTHCA_QP_PER_MGM; ++i) 187 for (i = 0; i < MTHCA_QP_PER_MGM; ++i)
192 if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) { 188 if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) {
189 mthca_dbg(dev, "QP %06x already a member of MGM\n",
190 ibqp->qp_num);
191 err = 0;
192 goto out;
193 } else if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) {
193 mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31)); 194 mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31));
194 break; 195 break;
195 } 196 }
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 7bd7a4bec7b4..d72fe95cba08 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -82,7 +82,7 @@ void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm)
82} 82}
83 83
84struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, 84struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
85 unsigned int gfp_mask) 85 gfp_t gfp_mask)
86{ 86{
87 struct mthca_icm *icm; 87 struct mthca_icm *icm;
88 struct mthca_icm_chunk *chunk = NULL; 88 struct mthca_icm_chunk *chunk = NULL;
@@ -487,7 +487,8 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
487 } 487 }
488} 488}
489 489
490int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) 490int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
491 u32 qn, __be32 **db)
491{ 492{
492 int group; 493 int group;
493 int start, end, dir; 494 int start, end, dir;
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index bafa51544aa3..4fdca26eea85 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -77,7 +77,7 @@ struct mthca_icm_iter {
77struct mthca_dev; 77struct mthca_dev;
78 78
79struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, 79struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
80 unsigned int gfp_mask); 80 gfp_t gfp_mask);
81void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm); 81void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm);
82 82
83struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, 83struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
@@ -173,7 +173,8 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
173 173
174int mthca_init_db_tab(struct mthca_dev *dev); 174int mthca_init_db_tab(struct mthca_dev *dev);
175void mthca_cleanup_db_tab(struct mthca_dev *dev); 175void mthca_cleanup_db_tab(struct mthca_dev *dev);
176int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db); 176int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
177 u32 qn, __be32 **db);
177void mthca_free_db(struct mthca_dev *dev, int type, int db_index); 178void mthca_free_db(struct mthca_dev *dev, int type, int db_index);
178 179
179#endif /* MTHCA_MEMFREE_H */ 180#endif /* MTHCA_MEMFREE_H */
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 3f5319a46577..1b9477edbd7b 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -37,6 +37,7 @@
37 */ 37 */
38 38
39#include <rdma/ib_smi.h> 39#include <rdma/ib_smi.h>
40#include <rdma/ib_user_verbs.h>
40#include <linux/mm.h> 41#include <linux/mm.h>
41 42
42#include "mthca_dev.h" 43#include "mthca_dev.h"
@@ -90,15 +91,26 @@ static int mthca_query_device(struct ib_device *ibdev,
90 91
91 props->max_mr_size = ~0ull; 92 props->max_mr_size = ~0ull;
92 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps; 93 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps;
93 props->max_qp_wr = 0xffff; 94 props->max_qp_wr = mdev->limits.max_wqes;
94 props->max_sge = mdev->limits.max_sg; 95 props->max_sge = mdev->limits.max_sg;
95 props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs; 96 props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs;
96 props->max_cqe = 0xffff; 97 props->max_cqe = mdev->limits.max_cqes;
97 props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws; 98 props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws;
98 props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds; 99 props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds;
99 props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift; 100 props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift;
100 props->max_qp_init_rd_atom = 1 << mdev->qp_table.rdb_shift; 101 props->max_qp_init_rd_atom = mdev->limits.max_qp_init_rdma;
102 props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
103 props->max_srq = mdev->limits.num_srqs - mdev->limits.reserved_srqs;
104 props->max_srq_wr = mdev->limits.max_srq_wqes;
105 props->max_srq_sge = mdev->limits.max_sg;
101 props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay; 106 props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay;
107 props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
108 IB_ATOMIC_HCA : IB_ATOMIC_NONE;
109 props->max_pkeys = mdev->limits.pkey_table_len;
110 props->max_mcast_grp = mdev->limits.num_mgms + mdev->limits.num_amgms;
111 props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
112 props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
113 props->max_mcast_grp;
102 114
103 err = 0; 115 err = 0;
104 out: 116 out:
@@ -150,9 +162,13 @@ static int mthca_query_port(struct ib_device *ibdev,
150 props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len; 162 props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len;
151 props->max_msg_sz = 0x80000000; 163 props->max_msg_sz = 0x80000000;
152 props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len; 164 props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len;
165 props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46));
153 props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48)); 166 props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
154 props->active_width = out_mad->data[31] & 0xf; 167 props->active_width = out_mad->data[31] & 0xf;
155 props->active_speed = out_mad->data[35] >> 4; 168 props->active_speed = out_mad->data[35] >> 4;
169 props->max_mtu = out_mad->data[41] & 0xf;
170 props->active_mtu = out_mad->data[36] >> 4;
171 props->subnet_timeout = out_mad->data[51] & 0x1f;
156 172
157 out: 173 out:
158 kfree(in_mad); 174 kfree(in_mad);
@@ -634,6 +650,9 @@ static struct ib_cq *mthca_create_cq(struct ib_device *ibdev, int entries,
634 int nent; 650 int nent;
635 int err; 651 int err;
636 652
653 if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
654 return ERR_PTR(-EINVAL);
655
637 if (context) { 656 if (context) {
638 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 657 if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
639 return ERR_PTR(-EFAULT); 658 return ERR_PTR(-EFAULT);
@@ -1058,6 +1077,26 @@ int mthca_register_device(struct mthca_dev *dev)
1058 strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX); 1077 strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
1059 dev->ib_dev.owner = THIS_MODULE; 1078 dev->ib_dev.owner = THIS_MODULE;
1060 1079
1080 dev->ib_dev.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION;
1081 dev->ib_dev.uverbs_cmd_mask =
1082 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
1083 (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
1084 (1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
1085 (1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
1086 (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
1087 (1ull << IB_USER_VERBS_CMD_REG_MR) |
1088 (1ull << IB_USER_VERBS_CMD_DEREG_MR) |
1089 (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
1090 (1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
1091 (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
1092 (1ull << IB_USER_VERBS_CMD_CREATE_QP) |
1093 (1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
1094 (1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
1095 (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
1096 (1ull << IB_USER_VERBS_CMD_DETACH_MCAST) |
1097 (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
1098 (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
1099 (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
1061 dev->ib_dev.node_type = IB_NODE_CA; 1100 dev->ib_dev.node_type = IB_NODE_CA;
1062 dev->ib_dev.phys_port_cnt = dev->limits.num_ports; 1101 dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
1063 dev->ib_dev.dma_device = &dev->pdev->dev; 1102 dev->ib_dev.dma_device = &dev->pdev->dev;
@@ -1077,6 +1116,7 @@ int mthca_register_device(struct mthca_dev *dev)
1077 1116
1078 if (dev->mthca_flags & MTHCA_FLAG_SRQ) { 1117 if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
1079 dev->ib_dev.create_srq = mthca_create_srq; 1118 dev->ib_dev.create_srq = mthca_create_srq;
1119 dev->ib_dev.modify_srq = mthca_modify_srq;
1080 dev->ib_dev.destroy_srq = mthca_destroy_srq; 1120 dev->ib_dev.destroy_srq = mthca_destroy_srq;
1081 1121
1082 if (mthca_is_memfree(dev)) 1122 if (mthca_is_memfree(dev))
@@ -1135,10 +1175,13 @@ int mthca_register_device(struct mthca_dev *dev)
1135 } 1175 }
1136 } 1176 }
1137 1177
1178 mthca_start_catas_poll(dev);
1179
1138 return 0; 1180 return 0;
1139} 1181}
1140 1182
1141void mthca_unregister_device(struct mthca_dev *dev) 1183void mthca_unregister_device(struct mthca_dev *dev)
1142{ 1184{
1185 mthca_stop_catas_poll(dev);
1143 ib_unregister_device(&dev->ib_dev); 1186 ib_unregister_device(&dev->ib_dev);
1144} 1187}
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 5fa00669f9b8..62ff091505da 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -338,8 +338,7 @@ static const struct {
338 [UC] = (IB_QP_AV | 338 [UC] = (IB_QP_AV |
339 IB_QP_PATH_MTU | 339 IB_QP_PATH_MTU |
340 IB_QP_DEST_QPN | 340 IB_QP_DEST_QPN |
341 IB_QP_RQ_PSN | 341 IB_QP_RQ_PSN),
342 IB_QP_MAX_DEST_RD_ATOMIC),
343 [RC] = (IB_QP_AV | 342 [RC] = (IB_QP_AV |
344 IB_QP_PATH_MTU | 343 IB_QP_PATH_MTU |
345 IB_QP_DEST_QPN | 344 IB_QP_DEST_QPN |
@@ -368,8 +367,7 @@ static const struct {
368 .trans = MTHCA_TRANS_RTR2RTS, 367 .trans = MTHCA_TRANS_RTR2RTS,
369 .req_param = { 368 .req_param = {
370 [UD] = IB_QP_SQ_PSN, 369 [UD] = IB_QP_SQ_PSN,
371 [UC] = (IB_QP_SQ_PSN | 370 [UC] = IB_QP_SQ_PSN,
372 IB_QP_MAX_QP_RD_ATOMIC),
373 [RC] = (IB_QP_TIMEOUT | 371 [RC] = (IB_QP_TIMEOUT |
374 IB_QP_RETRY_CNT | 372 IB_QP_RETRY_CNT |
375 IB_QP_RNR_RETRY | 373 IB_QP_RNR_RETRY |
@@ -446,8 +444,6 @@ static const struct {
446 [UD] = (IB_QP_PKEY_INDEX | 444 [UD] = (IB_QP_PKEY_INDEX |
447 IB_QP_QKEY), 445 IB_QP_QKEY),
448 [UC] = (IB_QP_AV | 446 [UC] = (IB_QP_AV |
449 IB_QP_MAX_QP_RD_ATOMIC |
450 IB_QP_MAX_DEST_RD_ATOMIC |
451 IB_QP_CUR_STATE | 447 IB_QP_CUR_STATE |
452 IB_QP_ALT_PATH | 448 IB_QP_ALT_PATH |
453 IB_QP_ACCESS_FLAGS | 449 IB_QP_ACCESS_FLAGS |
@@ -478,7 +474,7 @@ static const struct {
478 .opt_param = { 474 .opt_param = {
479 [UD] = (IB_QP_CUR_STATE | 475 [UD] = (IB_QP_CUR_STATE |
480 IB_QP_QKEY), 476 IB_QP_QKEY),
481 [UC] = (IB_QP_CUR_STATE), 477 [UC] = IB_QP_CUR_STATE,
482 [RC] = (IB_QP_CUR_STATE | 478 [RC] = (IB_QP_CUR_STATE |
483 IB_QP_MIN_RNR_TIMER), 479 IB_QP_MIN_RNR_TIMER),
484 [MLX] = (IB_QP_CUR_STATE | 480 [MLX] = (IB_QP_CUR_STATE |
@@ -1112,8 +1108,10 @@ static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
1112 struct mthca_qp *qp) 1108 struct mthca_qp *qp)
1113{ 1109{
1114 /* Sanity check QP size before proceeding */ 1110 /* Sanity check QP size before proceeding */
1115 if (cap->max_send_wr > 65536 || cap->max_recv_wr > 65536 || 1111 if (cap->max_send_wr > dev->limits.max_wqes ||
1116 cap->max_send_sge > 64 || cap->max_recv_sge > 64) 1112 cap->max_recv_wr > dev->limits.max_wqes ||
1113 cap->max_send_sge > dev->limits.max_sg ||
1114 cap->max_recv_sge > dev->limits.max_sg)
1117 return -EINVAL; 1115 return -EINVAL;
1118 1116
1119 if (mthca_is_memfree(dev)) { 1117 if (mthca_is_memfree(dev)) {
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 18998d48c53e..64f70aa1b3c0 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -186,7 +186,8 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
186 int err; 186 int err;
187 187
188 /* Sanity check SRQ size before proceeding */ 188 /* Sanity check SRQ size before proceeding */
189 if (attr->max_wr > 16 << 20 || attr->max_sge > 64) 189 if (attr->max_wr > dev->limits.max_srq_wqes ||
190 attr->max_sge > dev->limits.max_sg)
190 return -EINVAL; 191 return -EINVAL;
191 192
192 srq->max = attr->max_wr; 193 srq->max = attr->max_wr;
@@ -332,6 +333,29 @@ void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq)
332 mthca_free_mailbox(dev, mailbox); 333 mthca_free_mailbox(dev, mailbox);
333} 334}
334 335
336int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
337 enum ib_srq_attr_mask attr_mask)
338{
339 struct mthca_dev *dev = to_mdev(ibsrq->device);
340 struct mthca_srq *srq = to_msrq(ibsrq);
341 int ret;
342 u8 status;
343
344 /* We don't support resizing SRQs (yet?) */
345 if (attr_mask & IB_SRQ_MAX_WR)
346 return -EINVAL;
347
348 if (attr_mask & IB_SRQ_LIMIT) {
349 ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
350 if (ret)
351 return ret;
352 if (status)
353 return -EINVAL;
354 }
355
356 return 0;
357}
358
335void mthca_srq_event(struct mthca_dev *dev, u32 srqn, 359void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
336 enum ib_event_type event_type) 360 enum ib_event_type event_type)
337{ 361{
@@ -354,7 +378,7 @@ void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
354 378
355 event.device = &dev->ib_dev; 379 event.device = &dev->ib_dev;
356 event.event = event_type; 380 event.event = event_type;
357 event.element.srq = &srq->ibsrq; 381 event.element.srq = &srq->ibsrq;
358 srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context); 382 srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context);
359 383
360out: 384out:
@@ -415,6 +439,14 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
415 439
416 wqe = get_wqe(srq, ind); 440 wqe = get_wqe(srq, ind);
417 next_ind = *wqe_to_link(wqe); 441 next_ind = *wqe_to_link(wqe);
442
443 if (next_ind < 0) {
444 mthca_err(dev, "SRQ %06x full\n", srq->srqn);
445 err = -ENOMEM;
446 *bad_wr = wr;
447 break;
448 }
449
418 prev_wqe = srq->last; 450 prev_wqe = srq->last;
419 srq->last = wqe; 451 srq->last = wqe;
420 452
@@ -506,6 +538,13 @@ int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
506 wqe = get_wqe(srq, ind); 538 wqe = get_wqe(srq, ind);
507 next_ind = *wqe_to_link(wqe); 539 next_ind = *wqe_to_link(wqe);
508 540
541 if (next_ind < 0) {
542 mthca_err(dev, "SRQ %06x full\n", srq->srqn);
543 err = -ENOMEM;
544 *bad_wr = wr;
545 break;
546 }
547
509 ((struct mthca_next_seg *) wqe)->nda_op = 548 ((struct mthca_next_seg *) wqe)->nda_op =
510 cpu_to_be32((next_ind << srq->wqe_shift) | 1); 549 cpu_to_be32((next_ind << srq->wqe_shift) | 1);
511 ((struct mthca_next_seg *) wqe)->ee_nds = 0; 550 ((struct mthca_next_seg *) wqe)->ee_nds = 0;
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
index 41613ec8a04e..bb015c6494c4 100644
--- a/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -38,6 +38,12 @@
38#include <linux/types.h> 38#include <linux/types.h>
39 39
40/* 40/*
41 * Increment this value if any changes that break userspace ABI
42 * compatibility are made.
43 */
44#define MTHCA_UVERBS_ABI_VERSION 1
45
46/*
41 * Make sure that all structs defined in this file remain laid out so 47 * Make sure that all structs defined in this file remain laid out so
42 * that they pack the same way on 32-bit and 64-bit architectures (to 48 * that they pack the same way on 32-bit and 64-bit architectures (to
43 * avoid incompatibility between 32-bit userspace and 64-bit kernels). 49 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 4ea1c1ca85bc..c994a916a58a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -100,7 +100,12 @@ struct ipoib_pseudoheader {
100 100
101struct ipoib_mcast; 101struct ipoib_mcast;
102 102
103struct ipoib_buf { 103struct ipoib_rx_buf {
104 struct sk_buff *skb;
105 dma_addr_t mapping;
106};
107
108struct ipoib_tx_buf {
104 struct sk_buff *skb; 109 struct sk_buff *skb;
105 DECLARE_PCI_UNMAP_ADDR(mapping) 110 DECLARE_PCI_UNMAP_ADDR(mapping)
106}; 111};
@@ -150,14 +155,14 @@ struct ipoib_dev_priv {
150 unsigned int admin_mtu; 155 unsigned int admin_mtu;
151 unsigned int mcast_mtu; 156 unsigned int mcast_mtu;
152 157
153 struct ipoib_buf *rx_ring; 158 struct ipoib_rx_buf *rx_ring;
154 159
155 spinlock_t tx_lock; 160 spinlock_t tx_lock;
156 struct ipoib_buf *tx_ring; 161 struct ipoib_tx_buf *tx_ring;
157 unsigned tx_head; 162 unsigned tx_head;
158 unsigned tx_tail; 163 unsigned tx_tail;
159 struct ib_sge tx_sge; 164 struct ib_sge tx_sge;
160 struct ib_send_wr tx_wr; 165 struct ib_send_wr tx_wr;
161 166
162 struct ib_wc ibwc[IPOIB_NUM_WC]; 167 struct ib_wc ibwc[IPOIB_NUM_WC];
163 168
@@ -277,7 +282,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
277int ipoib_mcast_detach(struct net_device *dev, u16 mlid, 282int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
278 union ib_gid *mgid); 283 union ib_gid *mgid);
279 284
280int ipoib_qp_create(struct net_device *dev); 285int ipoib_init_qp(struct net_device *dev);
281int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca); 286int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
282void ipoib_transport_dev_cleanup(struct net_device *dev); 287void ipoib_transport_dev_cleanup(struct net_device *dev);
283 288
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index f7440096b5ed..192fef884e21 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -95,57 +95,65 @@ void ipoib_free_ah(struct kref *kref)
95 } 95 }
96} 96}
97 97
98static inline int ipoib_ib_receive(struct ipoib_dev_priv *priv, 98static int ipoib_ib_post_receive(struct net_device *dev, int id)
99 unsigned int wr_id,
100 dma_addr_t addr)
101{ 99{
102 struct ib_sge list = { 100 struct ipoib_dev_priv *priv = netdev_priv(dev);
103 .addr = addr, 101 struct ib_sge list;
104 .length = IPOIB_BUF_SIZE, 102 struct ib_recv_wr param;
105 .lkey = priv->mr->lkey,
106 };
107 struct ib_recv_wr param = {
108 .wr_id = wr_id | IPOIB_OP_RECV,
109 .sg_list = &list,
110 .num_sge = 1,
111 };
112 struct ib_recv_wr *bad_wr; 103 struct ib_recv_wr *bad_wr;
104 int ret;
105
106 list.addr = priv->rx_ring[id].mapping;
107 list.length = IPOIB_BUF_SIZE;
108 list.lkey = priv->mr->lkey;
109
110 param.next = NULL;
111 param.wr_id = id | IPOIB_OP_RECV;
112 param.sg_list = &list;
113 param.num_sge = 1;
114
115 ret = ib_post_recv(priv->qp, &param, &bad_wr);
116 if (unlikely(ret)) {
117 ipoib_warn(priv, "receive failed for buf %d (%d)\n", id, ret);
118 dma_unmap_single(priv->ca->dma_device,
119 priv->rx_ring[id].mapping,
120 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
121 dev_kfree_skb_any(priv->rx_ring[id].skb);
122 priv->rx_ring[id].skb = NULL;
123 }
113 124
114 return ib_post_recv(priv->qp, &param, &bad_wr); 125 return ret;
115} 126}
116 127
117static int ipoib_ib_post_receive(struct net_device *dev, int id) 128static int ipoib_alloc_rx_skb(struct net_device *dev, int id)
118{ 129{
119 struct ipoib_dev_priv *priv = netdev_priv(dev); 130 struct ipoib_dev_priv *priv = netdev_priv(dev);
120 struct sk_buff *skb; 131 struct sk_buff *skb;
121 dma_addr_t addr; 132 dma_addr_t addr;
122 int ret;
123 133
124 skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4); 134 skb = dev_alloc_skb(IPOIB_BUF_SIZE + 4);
125 if (!skb) { 135 if (!skb)
126 ipoib_warn(priv, "failed to allocate receive buffer\n");
127
128 priv->rx_ring[id].skb = NULL;
129 return -ENOMEM; 136 return -ENOMEM;
130 } 137
131 skb_reserve(skb, 4); /* 16 byte align IP header */ 138 /*
132 priv->rx_ring[id].skb = skb; 139 * IB will leave a 40 byte gap for a GRH and IPoIB adds a 4 byte
140 * header. So we need 4 more bytes to get to 48 and align the
141 * IP header to a multiple of 16.
142 */
143 skb_reserve(skb, 4);
144
133 addr = dma_map_single(priv->ca->dma_device, 145 addr = dma_map_single(priv->ca->dma_device,
134 skb->data, IPOIB_BUF_SIZE, 146 skb->data, IPOIB_BUF_SIZE,
135 DMA_FROM_DEVICE); 147 DMA_FROM_DEVICE);
136 pci_unmap_addr_set(&priv->rx_ring[id], mapping, addr); 148 if (unlikely(dma_mapping_error(addr))) {
137
138 ret = ipoib_ib_receive(priv, id, addr);
139 if (ret) {
140 ipoib_warn(priv, "ipoib_ib_receive failed for buf %d (%d)\n",
141 id, ret);
142 dma_unmap_single(priv->ca->dma_device, addr,
143 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
144 dev_kfree_skb_any(skb); 149 dev_kfree_skb_any(skb);
145 priv->rx_ring[id].skb = NULL; 150 return -EIO;
146 } 151 }
147 152
148 return ret; 153 priv->rx_ring[id].skb = skb;
154 priv->rx_ring[id].mapping = addr;
155
156 return 0;
149} 157}
150 158
151static int ipoib_ib_post_receives(struct net_device *dev) 159static int ipoib_ib_post_receives(struct net_device *dev)
@@ -154,6 +162,10 @@ static int ipoib_ib_post_receives(struct net_device *dev)
154 int i; 162 int i;
155 163
156 for (i = 0; i < IPOIB_RX_RING_SIZE; ++i) { 164 for (i = 0; i < IPOIB_RX_RING_SIZE; ++i) {
165 if (ipoib_alloc_rx_skb(dev, i)) {
166 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
167 return -ENOMEM;
168 }
157 if (ipoib_ib_post_receive(dev, i)) { 169 if (ipoib_ib_post_receive(dev, i)) {
158 ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i); 170 ipoib_warn(priv, "ipoib_ib_post_receive failed for buf %d\n", i);
159 return -EIO; 171 return -EIO;
@@ -176,28 +188,36 @@ static void ipoib_ib_handle_wc(struct net_device *dev,
176 wr_id &= ~IPOIB_OP_RECV; 188 wr_id &= ~IPOIB_OP_RECV;
177 189
178 if (wr_id < IPOIB_RX_RING_SIZE) { 190 if (wr_id < IPOIB_RX_RING_SIZE) {
179 struct sk_buff *skb = priv->rx_ring[wr_id].skb; 191 struct sk_buff *skb = priv->rx_ring[wr_id].skb;
180 192 dma_addr_t addr = priv->rx_ring[wr_id].mapping;
181 priv->rx_ring[wr_id].skb = NULL;
182 193
183 dma_unmap_single(priv->ca->dma_device, 194 if (unlikely(wc->status != IB_WC_SUCCESS)) {
184 pci_unmap_addr(&priv->rx_ring[wr_id],
185 mapping),
186 IPOIB_BUF_SIZE,
187 DMA_FROM_DEVICE);
188
189 if (wc->status != IB_WC_SUCCESS) {
190 if (wc->status != IB_WC_WR_FLUSH_ERR) 195 if (wc->status != IB_WC_WR_FLUSH_ERR)
191 ipoib_warn(priv, "failed recv event " 196 ipoib_warn(priv, "failed recv event "
192 "(status=%d, wrid=%d vend_err %x)\n", 197 "(status=%d, wrid=%d vend_err %x)\n",
193 wc->status, wr_id, wc->vendor_err); 198 wc->status, wr_id, wc->vendor_err);
199 dma_unmap_single(priv->ca->dma_device, addr,
200 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
194 dev_kfree_skb_any(skb); 201 dev_kfree_skb_any(skb);
202 priv->rx_ring[wr_id].skb = NULL;
195 return; 203 return;
196 } 204 }
197 205
206 /*
207 * If we can't allocate a new RX buffer, dump
208 * this packet and reuse the old buffer.
209 */
210 if (unlikely(ipoib_alloc_rx_skb(dev, wr_id))) {
211 ++priv->stats.rx_dropped;
212 goto repost;
213 }
214
198 ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n", 215 ipoib_dbg_data(priv, "received %d bytes, SLID 0x%04x\n",
199 wc->byte_len, wc->slid); 216 wc->byte_len, wc->slid);
200 217
218 dma_unmap_single(priv->ca->dma_device, addr,
219 IPOIB_BUF_SIZE, DMA_FROM_DEVICE);
220
201 skb_put(skb, wc->byte_len); 221 skb_put(skb, wc->byte_len);
202 skb_pull(skb, IB_GRH_BYTES); 222 skb_pull(skb, IB_GRH_BYTES);
203 223
@@ -220,8 +240,8 @@ static void ipoib_ib_handle_wc(struct net_device *dev,
220 dev_kfree_skb_any(skb); 240 dev_kfree_skb_any(skb);
221 } 241 }
222 242
223 /* repost receive */ 243 repost:
224 if (ipoib_ib_post_receive(dev, wr_id)) 244 if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
225 ipoib_warn(priv, "ipoib_ib_post_receive failed " 245 ipoib_warn(priv, "ipoib_ib_post_receive failed "
226 "for buf %d\n", wr_id); 246 "for buf %d\n", wr_id);
227 } else 247 } else
@@ -229,7 +249,7 @@ static void ipoib_ib_handle_wc(struct net_device *dev,
229 wr_id); 249 wr_id);
230 250
231 } else { 251 } else {
232 struct ipoib_buf *tx_req; 252 struct ipoib_tx_buf *tx_req;
233 unsigned long flags; 253 unsigned long flags;
234 254
235 if (wr_id >= IPOIB_TX_RING_SIZE) { 255 if (wr_id >= IPOIB_TX_RING_SIZE) {
@@ -302,7 +322,7 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
302 struct ipoib_ah *address, u32 qpn) 322 struct ipoib_ah *address, u32 qpn)
303{ 323{
304 struct ipoib_dev_priv *priv = netdev_priv(dev); 324 struct ipoib_dev_priv *priv = netdev_priv(dev);
305 struct ipoib_buf *tx_req; 325 struct ipoib_tx_buf *tx_req;
306 dma_addr_t addr; 326 dma_addr_t addr;
307 327
308 if (skb->len > dev->mtu + INFINIBAND_ALEN) { 328 if (skb->len > dev->mtu + INFINIBAND_ALEN) {
@@ -387,9 +407,9 @@ int ipoib_ib_dev_open(struct net_device *dev)
387 struct ipoib_dev_priv *priv = netdev_priv(dev); 407 struct ipoib_dev_priv *priv = netdev_priv(dev);
388 int ret; 408 int ret;
389 409
390 ret = ipoib_qp_create(dev); 410 ret = ipoib_init_qp(dev);
391 if (ret) { 411 if (ret) {
392 ipoib_warn(priv, "ipoib_qp_create returned %d\n", ret); 412 ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret);
393 return -1; 413 return -1;
394 } 414 }
395 415
@@ -468,7 +488,7 @@ int ipoib_ib_dev_stop(struct net_device *dev)
468 struct ib_qp_attr qp_attr; 488 struct ib_qp_attr qp_attr;
469 int attr_mask; 489 int attr_mask;
470 unsigned long begin; 490 unsigned long begin;
471 struct ipoib_buf *tx_req; 491 struct ipoib_tx_buf *tx_req;
472 int i; 492 int i;
473 493
474 /* Kill the existing QP and allocate a new one */ 494 /* Kill the existing QP and allocate a new one */
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 6c5bf07489f4..cd4f42328dbe 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -637,8 +637,11 @@ static void ipoib_timeout(struct net_device *dev)
637{ 637{
638 struct ipoib_dev_priv *priv = netdev_priv(dev); 638 struct ipoib_dev_priv *priv = netdev_priv(dev);
639 639
640 ipoib_warn(priv, "transmit timeout: latency %ld\n", 640 ipoib_warn(priv, "transmit timeout: latency %d msecs\n",
641 jiffies - dev->trans_start); 641 jiffies_to_msecs(jiffies - dev->trans_start));
642 ipoib_warn(priv, "queue stopped %d, tx_head %u, tx_tail %u\n",
643 netif_queue_stopped(dev),
644 priv->tx_head, priv->tx_tail);
642 /* XXX reset QP, etc. */ 645 /* XXX reset QP, etc. */
643} 646}
644 647
@@ -729,7 +732,7 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
729 732
730 /* Allocate RX/TX "rings" to hold queued skbs */ 733 /* Allocate RX/TX "rings" to hold queued skbs */
731 734
732 priv->rx_ring = kmalloc(IPOIB_RX_RING_SIZE * sizeof (struct ipoib_buf), 735 priv->rx_ring = kmalloc(IPOIB_RX_RING_SIZE * sizeof (struct ipoib_rx_buf),
733 GFP_KERNEL); 736 GFP_KERNEL);
734 if (!priv->rx_ring) { 737 if (!priv->rx_ring) {
735 printk(KERN_WARNING "%s: failed to allocate RX ring (%d entries)\n", 738 printk(KERN_WARNING "%s: failed to allocate RX ring (%d entries)\n",
@@ -737,9 +740,9 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
737 goto out; 740 goto out;
738 } 741 }
739 memset(priv->rx_ring, 0, 742 memset(priv->rx_ring, 0,
740 IPOIB_RX_RING_SIZE * sizeof (struct ipoib_buf)); 743 IPOIB_RX_RING_SIZE * sizeof (struct ipoib_rx_buf));
741 744
742 priv->tx_ring = kmalloc(IPOIB_TX_RING_SIZE * sizeof (struct ipoib_buf), 745 priv->tx_ring = kmalloc(IPOIB_TX_RING_SIZE * sizeof (struct ipoib_tx_buf),
743 GFP_KERNEL); 746 GFP_KERNEL);
744 if (!priv->tx_ring) { 747 if (!priv->tx_ring) {
745 printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n", 748 printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n",
@@ -747,7 +750,7 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
747 goto out_rx_ring_cleanup; 750 goto out_rx_ring_cleanup;
748 } 751 }
749 memset(priv->tx_ring, 0, 752 memset(priv->tx_ring, 0,
750 IPOIB_TX_RING_SIZE * sizeof (struct ipoib_buf)); 753 IPOIB_TX_RING_SIZE * sizeof (struct ipoib_tx_buf));
751 754
752 /* priv->tx_head & tx_tail are already 0 */ 755 /* priv->tx_head & tx_tail are already 0 */
753 756
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 79f59d0563ed..b5902a7ec240 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -92,7 +92,7 @@ int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
92 return ret; 92 return ret;
93} 93}
94 94
95int ipoib_qp_create(struct net_device *dev) 95int ipoib_init_qp(struct net_device *dev)
96{ 96{
97 struct ipoib_dev_priv *priv = netdev_priv(dev); 97 struct ipoib_dev_priv *priv = netdev_priv(dev);
98 int ret; 98 int ret;
@@ -149,10 +149,11 @@ int ipoib_qp_create(struct net_device *dev)
149 return 0; 149 return 0;
150 150
151out_fail: 151out_fail:
152 ib_destroy_qp(priv->qp); 152 qp_attr.qp_state = IB_QPS_RESET;
153 priv->qp = NULL; 153 if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
154 ipoib_warn(priv, "Failed to modify QP to RESET state\n");
154 155
155 return -EINVAL; 156 return ret;
156} 157}
157 158
158int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) 159int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 3738d173f9a6..a4696cd0978c 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -20,7 +20,6 @@
20#include <linux/major.h> 20#include <linux/major.h>
21#include <linux/smp_lock.h> 21#include <linux/smp_lock.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/devfs_fs_kernel.h>
24#include <linux/compat.h> 23#include <linux/compat.h>
25 24
26struct evdev { 25struct evdev {
@@ -662,6 +661,7 @@ static struct file_operations evdev_fops = {
662static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) 661static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
663{ 662{
664 struct evdev *evdev; 663 struct evdev *evdev;
664 struct class_device *cdev;
665 int minor; 665 int minor;
666 666
667 for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++); 667 for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
@@ -687,11 +687,13 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
687 687
688 evdev_table[minor] = evdev; 688 evdev_table[minor] = evdev;
689 689
690 devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 690 cdev = class_device_create(&input_class, &dev->cdev,
691 S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
692 class_device_create(input_class,
693 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 691 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
694 dev->dev, "event%d", minor); 692 dev->cdev.dev, evdev->name);
693
694 /* temporary symlink to keep userspace happy */
695 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
696 evdev->name);
695 697
696 return &evdev->handle; 698 return &evdev->handle;
697} 699}
@@ -701,9 +703,9 @@ static void evdev_disconnect(struct input_handle *handle)
701 struct evdev *evdev = handle->private; 703 struct evdev *evdev = handle->private;
702 struct evdev_list *list; 704 struct evdev_list *list;
703 705
704 class_device_destroy(input_class, 706 sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name);
707 class_device_destroy(&input_class,
705 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); 708 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
706 devfs_remove("input/event%d", evdev->minor);
707 evdev->exist = 0; 709 evdev->exist = 0;
708 710
709 if (evdev->open) { 711 if (evdev->open) {
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 14ae5583e198..3b1685ff9d10 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -22,12 +22,12 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/poll.h> 23#include <linux/poll.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/devfs_fs_kernel.h>
26 25
27MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 26MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
28MODULE_DESCRIPTION("Input core"); 27MODULE_DESCRIPTION("Input core");
29MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
30 29
30EXPORT_SYMBOL(input_allocate_device);
31EXPORT_SYMBOL(input_register_device); 31EXPORT_SYMBOL(input_register_device);
32EXPORT_SYMBOL(input_unregister_device); 32EXPORT_SYMBOL(input_unregister_device);
33EXPORT_SYMBOL(input_register_handler); 33EXPORT_SYMBOL(input_register_handler);
@@ -39,7 +39,7 @@ EXPORT_SYMBOL(input_close_device);
39EXPORT_SYMBOL(input_accept_process); 39EXPORT_SYMBOL(input_accept_process);
40EXPORT_SYMBOL(input_flush_device); 40EXPORT_SYMBOL(input_flush_device);
41EXPORT_SYMBOL(input_event); 41EXPORT_SYMBOL(input_event);
42EXPORT_SYMBOL(input_class); 42EXPORT_SYMBOL_GPL(input_class);
43 43
44#define INPUT_DEVICES 256 44#define INPUT_DEVICES 256
45 45
@@ -316,124 +316,21 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st
316 return NULL; 316 return NULL;
317} 317}
318 318
319 319static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, int max)
320/*
321 * Input hotplugging interface - loading event handlers based on
322 * device bitfields.
323 */
324
325#ifdef CONFIG_HOTPLUG
326
327/*
328 * Input hotplugging invokes what /proc/sys/kernel/hotplug says
329 * (normally /sbin/hotplug) when input devices get added or removed.
330 *
331 * This invokes a user mode policy agent, typically helping to load driver
332 * or other modules, configure the device, and more. Drivers can provide
333 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
334 *
335 */
336
337#define SPRINTF_BIT_A(bit, name, max) \
338 do { \
339 envp[i++] = scratch; \
340 scratch += sprintf(scratch, name); \
341 for (j = NBITS(max) - 1; j >= 0; j--) \
342 if (dev->bit[j]) break; \
343 for (; j >= 0; j--) \
344 scratch += sprintf(scratch, "%lx ", dev->bit[j]); \
345 scratch++; \
346 } while (0)
347
348#define SPRINTF_BIT_A2(bit, name, max, ev) \
349 do { \
350 if (test_bit(ev, dev->evbit)) \
351 SPRINTF_BIT_A(bit, name, max); \
352 } while (0)
353
354static void input_call_hotplug(char *verb, struct input_dev *dev)
355{ 320{
356 char *argv[3], **envp, *buf, *scratch; 321 int i;
357 int i = 0, j, value; 322 int len = 0;
358
359 if (!hotplug_path[0]) {
360 printk(KERN_ERR "input.c: calling hotplug without a hotplug agent defined\n");
361 return;
362 }
363 if (in_interrupt()) {
364 printk(KERN_ERR "input.c: calling hotplug from interrupt\n");
365 return;
366 }
367 if (!current->fs->root) {
368 printk(KERN_WARNING "input.c: calling hotplug without valid filesystem\n");
369 return;
370 }
371 if (!(envp = (char **) kmalloc(20 * sizeof(char *), GFP_KERNEL))) {
372 printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n");
373 return;
374 }
375 if (!(buf = kmalloc(1024, GFP_KERNEL))) {
376 kfree (envp);
377 printk(KERN_ERR "input.c: not enough memory allocating hotplug environment\n");
378 return;
379 }
380
381 argv[0] = hotplug_path;
382 argv[1] = "input";
383 argv[2] = NULL;
384
385 envp[i++] = "HOME=/";
386 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
387
388 scratch = buf;
389
390 envp[i++] = scratch;
391 scratch += sprintf(scratch, "ACTION=%s", verb) + 1;
392
393 envp[i++] = scratch;
394 scratch += sprintf(scratch, "PRODUCT=%x/%x/%x/%x",
395 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version) + 1;
396
397 if (dev->name) {
398 envp[i++] = scratch;
399 scratch += sprintf(scratch, "NAME=%s", dev->name) + 1;
400 }
401
402 if (dev->phys) {
403 envp[i++] = scratch;
404 scratch += sprintf(scratch, "PHYS=%s", dev->phys) + 1;
405 }
406
407 SPRINTF_BIT_A(evbit, "EV=", EV_MAX);
408 SPRINTF_BIT_A2(keybit, "KEY=", KEY_MAX, EV_KEY);
409 SPRINTF_BIT_A2(relbit, "REL=", REL_MAX, EV_REL);
410 SPRINTF_BIT_A2(absbit, "ABS=", ABS_MAX, EV_ABS);
411 SPRINTF_BIT_A2(mscbit, "MSC=", MSC_MAX, EV_MSC);
412 SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED);
413 SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND);
414 SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF);
415 SPRINTF_BIT_A2(swbit, "SW=", SW_MAX, EV_SW);
416
417 envp[i++] = NULL;
418
419#ifdef INPUT_DEBUG
420 printk(KERN_DEBUG "input.c: calling %s %s [%s %s %s %s %s]\n",
421 argv[0], argv[1], envp[0], envp[1], envp[2], envp[3], envp[4]);
422#endif
423
424 value = call_usermodehelper(argv [0], argv, envp, 0);
425 323
426 kfree(buf); 324 for (i = NBITS(max) - 1; i > 0; i--)
427 kfree(envp); 325 if (bitmap[i])
326 break;
428 327
429#ifdef INPUT_DEBUG 328 for (; i >= 0; i--)
430 if (value != 0) 329 len += snprintf(buf + len, max(buf_size - len, 0),
431 printk(KERN_DEBUG "input.c: hotplug returned %d\n", value); 330 "%lx%s", bitmap[i], i > 0 ? " " : "");
432#endif 331 return len;
433} 332}
434 333
435#endif
436
437#ifdef CONFIG_PROC_FS 334#ifdef CONFIG_PROC_FS
438 335
439static struct proc_dir_entry *proc_bus_input_dir; 336static struct proc_dir_entry *proc_bus_input_dir;
@@ -455,37 +352,39 @@ static unsigned int input_devices_poll(struct file *file, poll_table *wait)
455 return 0; 352 return 0;
456} 353}
457 354
458#define SPRINTF_BIT_B(bit, name, max) \ 355#define SPRINTF_BIT(ev, bm) \
459 do { \ 356 do { \
460 len += sprintf(buf + len, "B: %s", name); \ 357 len += sprintf(buf + len, "B: %s=", #ev); \
461 for (i = NBITS(max) - 1; i >= 0; i--) \ 358 len += input_print_bitmap(buf + len, INT_MAX, \
462 if (dev->bit[i]) break; \ 359 dev->bm##bit, ev##_MAX); \
463 for (; i >= 0; i--) \ 360 len += sprintf(buf + len, "\n"); \
464 len += sprintf(buf + len, "%lx ", dev->bit[i]); \
465 len += sprintf(buf + len, "\n"); \
466 } while (0) 361 } while (0)
467 362
468#define SPRINTF_BIT_B2(bit, name, max, ev) \ 363#define TEST_AND_SPRINTF_BIT(ev, bm) \
469 do { \ 364 do { \
470 if (test_bit(ev, dev->evbit)) \ 365 if (test_bit(EV_##ev, dev->evbit)) \
471 SPRINTF_BIT_B(bit, name, max); \ 366 SPRINTF_BIT(ev, bm); \
472 } while (0) 367 } while (0)
473 368
474static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) 369static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data)
475{ 370{
476 struct input_dev *dev; 371 struct input_dev *dev;
477 struct input_handle *handle; 372 struct input_handle *handle;
373 const char *path;
478 374
479 off_t at = 0; 375 off_t at = 0;
480 int i, len, cnt = 0; 376 int len, cnt = 0;
481 377
482 list_for_each_entry(dev, &input_dev_list, node) { 378 list_for_each_entry(dev, &input_dev_list, node) {
483 379
380 path = dev->dynalloc ? kobject_get_path(&dev->cdev.kobj, GFP_KERNEL) : NULL;
381
484 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", 382 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
485 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); 383 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
486 384
487 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); 385 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
488 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : ""); 386 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : "");
387 len += sprintf(buf + len, "S: Sysfs=%s\n", path ? path : "");
489 len += sprintf(buf + len, "H: Handlers="); 388 len += sprintf(buf + len, "H: Handlers=");
490 389
491 list_for_each_entry(handle, &dev->h_list, d_node) 390 list_for_each_entry(handle, &dev->h_list, d_node)
@@ -493,15 +392,15 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
493 392
494 len += sprintf(buf + len, "\n"); 393 len += sprintf(buf + len, "\n");
495 394
496 SPRINTF_BIT_B(evbit, "EV=", EV_MAX); 395 SPRINTF_BIT(EV, ev);
497 SPRINTF_BIT_B2(keybit, "KEY=", KEY_MAX, EV_KEY); 396 TEST_AND_SPRINTF_BIT(KEY, key);
498 SPRINTF_BIT_B2(relbit, "REL=", REL_MAX, EV_REL); 397 TEST_AND_SPRINTF_BIT(REL, rel);
499 SPRINTF_BIT_B2(absbit, "ABS=", ABS_MAX, EV_ABS); 398 TEST_AND_SPRINTF_BIT(ABS, abs);
500 SPRINTF_BIT_B2(mscbit, "MSC=", MSC_MAX, EV_MSC); 399 TEST_AND_SPRINTF_BIT(MSC, msc);
501 SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); 400 TEST_AND_SPRINTF_BIT(LED, led);
502 SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); 401 TEST_AND_SPRINTF_BIT(SND, snd);
503 SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); 402 TEST_AND_SPRINTF_BIT(FF, ff);
504 SPRINTF_BIT_B2(swbit, "SW=", SW_MAX, EV_SW); 403 TEST_AND_SPRINTF_BIT(SW, sw);
505 404
506 len += sprintf(buf + len, "\n"); 405 len += sprintf(buf + len, "\n");
507 406
@@ -516,6 +415,8 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int
516 if (cnt >= count) 415 if (cnt >= count)
517 break; 416 break;
518 } 417 }
418
419 kfree(path);
519 } 420 }
520 421
521 if (&dev->node == &input_dev_list) 422 if (&dev->node == &input_dev_list)
@@ -606,6 +507,240 @@ static inline int input_proc_init(void) { return 0; }
606static inline void input_proc_exit(void) { } 507static inline void input_proc_exit(void) { }
607#endif 508#endif
608 509
510#define INPUT_DEV_STRING_ATTR_SHOW(name) \
511static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \
512{ \
513 struct input_dev *input_dev = to_input_dev(dev); \
514 int retval; \
515 \
516 retval = down_interruptible(&input_dev->sem); \
517 if (retval) \
518 return retval; \
519 \
520 retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \
521 \
522 up(&input_dev->sem); \
523 \
524 return retval; \
525} \
526static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_##name, NULL);
527
528INPUT_DEV_STRING_ATTR_SHOW(name);
529INPUT_DEV_STRING_ATTR_SHOW(phys);
530INPUT_DEV_STRING_ATTR_SHOW(uniq);
531
532static struct attribute *input_dev_attrs[] = {
533 &class_device_attr_name.attr,
534 &class_device_attr_phys.attr,
535 &class_device_attr_uniq.attr,
536 NULL
537};
538
539static struct attribute_group input_dev_group = {
540 .attrs = input_dev_attrs,
541};
542
543#define INPUT_DEV_ID_ATTR(name) \
544static ssize_t input_dev_show_id_##name(struct class_device *dev, char *buf) \
545{ \
546 struct input_dev *input_dev = to_input_dev(dev); \
547 return sprintf(buf, "%04x\n", input_dev->id.name); \
548} \
549static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_id_##name, NULL);
550
551INPUT_DEV_ID_ATTR(bustype);
552INPUT_DEV_ID_ATTR(vendor);
553INPUT_DEV_ID_ATTR(product);
554INPUT_DEV_ID_ATTR(version);
555
556static struct attribute *input_dev_id_attrs[] = {
557 &class_device_attr_bustype.attr,
558 &class_device_attr_vendor.attr,
559 &class_device_attr_product.attr,
560 &class_device_attr_version.attr,
561 NULL
562};
563
564static struct attribute_group input_dev_id_attr_group = {
565 .name = "id",
566 .attrs = input_dev_id_attrs,
567};
568
569#define INPUT_DEV_CAP_ATTR(ev, bm) \
570static ssize_t input_dev_show_cap_##bm(struct class_device *dev, char *buf) \
571{ \
572 struct input_dev *input_dev = to_input_dev(dev); \
573 return input_print_bitmap(buf, PAGE_SIZE, input_dev->bm##bit, ev##_MAX);\
574} \
575static CLASS_DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL);
576
577INPUT_DEV_CAP_ATTR(EV, ev);
578INPUT_DEV_CAP_ATTR(KEY, key);
579INPUT_DEV_CAP_ATTR(REL, rel);
580INPUT_DEV_CAP_ATTR(ABS, abs);
581INPUT_DEV_CAP_ATTR(MSC, msc);
582INPUT_DEV_CAP_ATTR(LED, led);
583INPUT_DEV_CAP_ATTR(SND, snd);
584INPUT_DEV_CAP_ATTR(FF, ff);
585INPUT_DEV_CAP_ATTR(SW, sw);
586
587static struct attribute *input_dev_caps_attrs[] = {
588 &class_device_attr_ev.attr,
589 &class_device_attr_key.attr,
590 &class_device_attr_rel.attr,
591 &class_device_attr_abs.attr,
592 &class_device_attr_msc.attr,
593 &class_device_attr_led.attr,
594 &class_device_attr_snd.attr,
595 &class_device_attr_ff.attr,
596 &class_device_attr_sw.attr,
597 NULL
598};
599
600static struct attribute_group input_dev_caps_attr_group = {
601 .name = "capabilities",
602 .attrs = input_dev_caps_attrs,
603};
604
605static void input_dev_release(struct class_device *class_dev)
606{
607 struct input_dev *dev = to_input_dev(class_dev);
608
609 kfree(dev);
610 module_put(THIS_MODULE);
611}
612
613/*
614 * Input hotplugging interface - loading event handlers based on
615 * device bitfields.
616 */
617static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
618 char *buffer, int buffer_size, int *cur_len,
619 const char *name, unsigned long *bitmap, int max)
620{
621 if (*cur_index >= num_envp - 1)
622 return -ENOMEM;
623
624 envp[*cur_index] = buffer + *cur_len;
625
626 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name);
627 if (*cur_len > buffer_size)
628 return -ENOMEM;
629
630 *cur_len += input_print_bitmap(buffer + *cur_len,
631 max(buffer_size - *cur_len, 0),
632 bitmap, max) + 1;
633 if (*cur_len > buffer_size)
634 return -ENOMEM;
635
636 (*cur_index)++;
637 return 0;
638}
639
640#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
641 do { \
642 int err = add_hotplug_env_var(envp, num_envp, &i, \
643 buffer, buffer_size, &len, \
644 fmt, val); \
645 if (err) \
646 return err; \
647 } while (0)
648
649#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \
650 do { \
651 int err = input_add_hotplug_bm_var(envp, num_envp, &i, \
652 buffer, buffer_size, &len, \
653 name, bm, max); \
654 if (err) \
655 return err; \
656 } while (0)
657
658static int input_dev_hotplug(struct class_device *cdev, char **envp,
659 int num_envp, char *buffer, int buffer_size)
660{
661 struct input_dev *dev = to_input_dev(cdev);
662 int i = 0;
663 int len = 0;
664
665 INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x",
666 dev->id.bustype, dev->id.vendor,
667 dev->id.product, dev->id.version);
668 if (dev->name)
669 INPUT_ADD_HOTPLUG_VAR("NAME=\"%s\"", dev->name);
670 if (dev->phys)
671 INPUT_ADD_HOTPLUG_VAR("PHYS=\"%s\"", dev->phys);
672 if (dev->phys)
673 INPUT_ADD_HOTPLUG_VAR("UNIQ=\"%s\"", dev->uniq);
674
675 INPUT_ADD_HOTPLUG_BM_VAR("EV=", dev->evbit, EV_MAX);
676 if (test_bit(EV_KEY, dev->evbit))
677 INPUT_ADD_HOTPLUG_BM_VAR("KEY=", dev->keybit, KEY_MAX);
678 if (test_bit(EV_REL, dev->evbit))
679 INPUT_ADD_HOTPLUG_BM_VAR("REL=", dev->relbit, REL_MAX);
680 if (test_bit(EV_ABS, dev->evbit))
681 INPUT_ADD_HOTPLUG_BM_VAR("ABS=", dev->absbit, ABS_MAX);
682 if (test_bit(EV_MSC, dev->evbit))
683 INPUT_ADD_HOTPLUG_BM_VAR("MSC=", dev->mscbit, MSC_MAX);
684 if (test_bit(EV_LED, dev->evbit))
685 INPUT_ADD_HOTPLUG_BM_VAR("LED=", dev->ledbit, LED_MAX);
686 if (test_bit(EV_SND, dev->evbit))
687 INPUT_ADD_HOTPLUG_BM_VAR("SND=", dev->sndbit, SND_MAX);
688 if (test_bit(EV_FF, dev->evbit))
689 INPUT_ADD_HOTPLUG_BM_VAR("FF=", dev->ffbit, FF_MAX);
690 if (test_bit(EV_SW, dev->evbit))
691 INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
692
693 envp[i] = NULL;
694
695 return 0;
696}
697
698struct class input_class = {
699 .name = "input",
700 .release = input_dev_release,
701 .hotplug = input_dev_hotplug,
702};
703
704struct input_dev *input_allocate_device(void)
705{
706 struct input_dev *dev;
707
708 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
709 if (dev) {
710 dev->dynalloc = 1;
711 dev->cdev.class = &input_class;
712 class_device_initialize(&dev->cdev);
713 INIT_LIST_HEAD(&dev->h_list);
714 INIT_LIST_HEAD(&dev->node);
715 }
716
717 return dev;
718}
719
720static void input_register_classdevice(struct input_dev *dev)
721{
722 static atomic_t input_no = ATOMIC_INIT(0);
723 const char *path;
724
725 __module_get(THIS_MODULE);
726
727 dev->dev = dev->cdev.dev;
728
729 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
730 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
731
732 path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL);
733 printk(KERN_INFO "input: %s/%s as %s\n",
734 dev->name ? dev->name : "Unspecified device",
735 path ? path : "", dev->cdev.class_id);
736 kfree(path);
737
738 class_device_add(&dev->cdev);
739 sysfs_create_group(&dev->cdev.kobj, &input_dev_group);
740 sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
741 sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
742}
743
609void input_register_device(struct input_dev *dev) 744void input_register_device(struct input_dev *dev)
610{ 745{
611 struct input_handle *handle; 746 struct input_handle *handle;
@@ -632,15 +767,15 @@ void input_register_device(struct input_dev *dev)
632 INIT_LIST_HEAD(&dev->h_list); 767 INIT_LIST_HEAD(&dev->h_list);
633 list_add_tail(&dev->node, &input_dev_list); 768 list_add_tail(&dev->node, &input_dev_list);
634 769
770 if (dev->dynalloc)
771 input_register_classdevice(dev);
772
635 list_for_each_entry(handler, &input_handler_list, node) 773 list_for_each_entry(handler, &input_handler_list, node)
636 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 774 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
637 if ((id = input_match_device(handler->id_table, dev))) 775 if ((id = input_match_device(handler->id_table, dev)))
638 if ((handle = handler->connect(handler, dev, id))) 776 if ((handle = handler->connect(handler, dev, id)))
639 input_link_handle(handle); 777 input_link_handle(handle);
640 778
641#ifdef CONFIG_HOTPLUG
642 input_call_hotplug("add", dev);
643#endif
644 779
645 input_wakeup_procfs_readers(); 780 input_wakeup_procfs_readers();
646} 781}
@@ -660,12 +795,14 @@ void input_unregister_device(struct input_dev *dev)
660 handle->handler->disconnect(handle); 795 handle->handler->disconnect(handle);
661 } 796 }
662 797
663#ifdef CONFIG_HOTPLUG
664 input_call_hotplug("remove", dev);
665#endif
666
667 list_del_init(&dev->node); 798 list_del_init(&dev->node);
668 799
800 if (dev->dynalloc) {
801 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
802 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
803 class_device_unregister(&dev->cdev);
804 }
805
669 input_wakeup_procfs_readers(); 806 input_wakeup_procfs_readers();
670} 807}
671 808
@@ -748,16 +885,14 @@ static struct file_operations input_fops = {
748 .open = input_open_file, 885 .open = input_open_file,
749}; 886};
750 887
751struct class *input_class;
752
753static int __init input_init(void) 888static int __init input_init(void)
754{ 889{
755 int err; 890 int err;
756 891
757 input_class = class_create(THIS_MODULE, "input"); 892 err = class_register(&input_class);
758 if (IS_ERR(input_class)) { 893 if (err) {
759 printk(KERN_ERR "input: unable to register input class\n"); 894 printk(KERN_ERR "input: unable to register input_dev class\n");
760 return PTR_ERR(input_class); 895 return err;
761 } 896 }
762 897
763 err = input_proc_init(); 898 err = input_proc_init();
@@ -770,24 +905,18 @@ static int __init input_init(void)
770 goto fail2; 905 goto fail2;
771 } 906 }
772 907
773 err = devfs_mk_dir("input");
774 if (err)
775 goto fail3;
776
777 return 0; 908 return 0;
778 909
779 fail3: unregister_chrdev(INPUT_MAJOR, "input");
780 fail2: input_proc_exit(); 910 fail2: input_proc_exit();
781 fail1: class_destroy(input_class); 911 fail1: class_unregister(&input_class);
782 return err; 912 return err;
783} 913}
784 914
785static void __exit input_exit(void) 915static void __exit input_exit(void)
786{ 916{
787 input_proc_exit(); 917 input_proc_exit();
788 devfs_remove("input");
789 unregister_chrdev(INPUT_MAJOR, "input"); 918 unregister_chrdev(INPUT_MAJOR, "input");
790 class_destroy(input_class); 919 class_unregister(&input_class);
791} 920}
792 921
793subsys_initcall(input_init); 922subsys_initcall(input_init);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index e0938d1d3ad7..20e2972b9204 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/smp_lock.h> 27#include <linux/smp_lock.h>
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/devfs_fs_kernel.h>
30 29
31MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 30MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
32MODULE_DESCRIPTION("Joystick device interfaces"); 31MODULE_DESCRIPTION("Joystick device interfaces");
@@ -449,6 +448,7 @@ static struct file_operations joydev_fops = {
449static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) 448static struct input_handle *joydev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
450{ 449{
451 struct joydev *joydev; 450 struct joydev *joydev;
451 struct class_device *cdev;
452 int i, j, t, minor; 452 int i, j, t, minor;
453 453
454 for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++); 454 for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
@@ -514,11 +514,13 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
514 514
515 joydev_table[minor] = joydev; 515 joydev_table[minor] = joydev;
516 516
517 devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 517 cdev = class_device_create(&input_class, &dev->cdev,
518 S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor);
519 class_device_create(input_class,
520 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 518 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
521 dev->dev, "js%d", minor); 519 dev->cdev.dev, joydev->name);
520
521 /* temporary symlink to keep userspace happy */
522 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
523 joydev->name);
522 524
523 return &joydev->handle; 525 return &joydev->handle;
524} 526}
@@ -528,8 +530,8 @@ static void joydev_disconnect(struct input_handle *handle)
528 struct joydev *joydev = handle->private; 530 struct joydev *joydev = handle->private;
529 struct joydev_list *list; 531 struct joydev_list *list;
530 532
531 class_device_destroy(input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); 533 sysfs_remove_link(&input_class.subsys.kset.kobj, joydev->name);
532 devfs_remove("input/js%d", joydev->minor); 534 class_device_destroy(&input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
533 joydev->exist = 0; 535 joydev->exist = 0;
534 536
535 if (joydev->open) { 537 if (joydev->open) {
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index cf35ae638a0d..9d95459f4bcb 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54#define ADI_MIN_LENGTH 8 54#define ADI_MIN_LENGTH 8
55#define ADI_MIN_LEN_LENGTH 10 55#define ADI_MIN_LEN_LENGTH 10
56#define ADI_MIN_ID_LENGTH 66 56#define ADI_MIN_ID_LENGTH 66
57#define ADI_MAX_NAME_LENGTH 48 57#define ADI_MAX_NAME_LENGTH 64
58#define ADI_MAX_CNAME_LENGTH 16 58#define ADI_MAX_CNAME_LENGTH 16
59#define ADI_MAX_PHYS_LENGTH 64 59#define ADI_MAX_PHYS_LENGTH 64
60 60
@@ -106,7 +106,7 @@ static struct {
106 */ 106 */
107 107
108struct adi { 108struct adi {
109 struct input_dev dev; 109 struct input_dev *dev;
110 int length; 110 int length;
111 int ret; 111 int ret;
112 int idx; 112 int idx;
@@ -215,7 +215,7 @@ static inline int adi_get_bits(struct adi *adi, int count)
215 215
216static int adi_decode(struct adi *adi) 216static int adi_decode(struct adi *adi)
217{ 217{
218 struct input_dev *dev = &adi->dev; 218 struct input_dev *dev = adi->dev;
219 char *abs = adi->abs; 219 char *abs = adi->abs;
220 short *key = adi->key; 220 short *key = adi->key;
221 int i, t; 221 int i, t;
@@ -318,7 +318,8 @@ static void adi_init_digital(struct gameport *gameport)
318 318
319 for (i = 0; seq[i]; i++) { 319 for (i = 0; seq[i]; i++) {
320 gameport_trigger(gameport); 320 gameport_trigger(gameport);
321 if (seq[i] > 0) msleep(seq[i]); 321 if (seq[i] > 0)
322 msleep(seq[i]);
322 if (seq[i] < 0) { 323 if (seq[i] < 0) {
323 mdelay(-seq[i]); 324 mdelay(-seq[i]);
324 udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */ 325 udelay(-seq[i]*14); /* It looks like mdelay() is off by approx 1.4% */
@@ -397,42 +398,46 @@ static void adi_id_decode(struct adi *adi, struct adi_port *port)
397 } 398 }
398} 399}
399 400
400static void adi_init_input(struct adi *adi, struct adi_port *port, int half) 401static int adi_init_input(struct adi *adi, struct adi_port *port, int half)
401{ 402{
402 int i, t; 403 struct input_dev *input_dev;
403 char buf[ADI_MAX_NAME_LENGTH]; 404 char buf[ADI_MAX_NAME_LENGTH];
405 int i, t;
404 406
405 if (!adi->length) return; 407 adi->dev = input_dev = input_allocate_device();
406 408 if (!input_dev)
407 init_input_dev(&adi->dev); 409 return -ENOMEM;
408 410
409 t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX; 411 t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
410 412
411 snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id); 413 snprintf(buf, ADI_MAX_PHYS_LENGTH, adi_names[t], adi->id);
412 snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s", buf); 414 snprintf(adi->name, ADI_MAX_NAME_LENGTH, "Logitech %s [%s]", buf, adi->cname);
413 snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half); 415 snprintf(adi->phys, ADI_MAX_PHYS_LENGTH, "%s/input%d", port->gameport->phys, half);
414 416
415 adi->abs = adi_abs[t]; 417 adi->abs = adi_abs[t];
416 adi->key = adi_key[t]; 418 adi->key = adi_key[t];
417 419
418 adi->dev.open = adi_open; 420 input_dev->name = adi->name;
419 adi->dev.close = adi_close; 421 input_dev->phys = adi->phys;
422 input_dev->id.bustype = BUS_GAMEPORT;
423 input_dev->id.vendor = GAMEPORT_ID_VENDOR_LOGITECH;
424 input_dev->id.product = adi->id;
425 input_dev->id.version = 0x0100;
426 input_dev->cdev.dev = &port->gameport->dev;
427 input_dev->private = port;
420 428
421 adi->dev.name = adi->name; 429 input_dev->open = adi_open;
422 adi->dev.phys = adi->phys; 430 input_dev->close = adi_close;
423 adi->dev.id.bustype = BUS_GAMEPORT;
424 adi->dev.id.vendor = GAMEPORT_ID_VENDOR_LOGITECH;
425 adi->dev.id.product = adi->id;
426 adi->dev.id.version = 0x0100;
427 431
428 adi->dev.private = port; 432 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
429 adi->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
430 433
431 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) 434 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++)
432 set_bit(adi->abs[i], adi->dev.absbit); 435 set_bit(adi->abs[i], input_dev->absbit);
433 436
434 for (i = 0; i < adi->buttons; i++) 437 for (i = 0; i < adi->buttons; i++)
435 set_bit(adi->key[i], adi->dev.keybit); 438 set_bit(adi->key[i], input_dev->keybit);
439
440 return 0;
436} 441}
437 442
438static void adi_init_center(struct adi *adi) 443static void adi_init_center(struct adi *adi)
@@ -445,17 +450,17 @@ static void adi_init_center(struct adi *adi)
445 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { 450 for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) {
446 451
447 t = adi->abs[i]; 452 t = adi->abs[i];
448 x = adi->dev.abs[t]; 453 x = adi->dev->abs[t];
449 454
450 if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) 455 if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE)
451 x = i < adi->axes10 ? 512 : 128; 456 x = i < adi->axes10 ? 512 : 128;
452 457
453 if (i < adi->axes10) 458 if (i < adi->axes10)
454 input_set_abs_params(&adi->dev, t, 64, x * 2 - 64, 2, 16); 459 input_set_abs_params(adi->dev, t, 64, x * 2 - 64, 2, 16);
455 else if (i < adi->axes10 + adi->axes8) 460 else if (i < adi->axes10 + adi->axes8)
456 input_set_abs_params(&adi->dev, t, 48, x * 2 - 48, 1, 16); 461 input_set_abs_params(adi->dev, t, 48, x * 2 - 48, 1, 16);
457 else 462 else
458 input_set_abs_params(&adi->dev, t, -1, 1, 0, 0); 463 input_set_abs_params(adi->dev, t, -1, 1, 0, 0);
459 } 464 }
460} 465}
461 466
@@ -469,7 +474,8 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
469 int i; 474 int i;
470 int err; 475 int err;
471 476
472 if (!(port = kzalloc(sizeof(struct adi_port), GFP_KERNEL))) 477 port = kzalloc(sizeof(struct adi_port), GFP_KERNEL);
478 if (!port)
473 return -ENOMEM; 479 return -ENOMEM;
474 480
475 port->gameport = gameport; 481 port->gameport = gameport;
@@ -477,10 +483,8 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
477 gameport_set_drvdata(gameport, port); 483 gameport_set_drvdata(gameport, port);
478 484
479 err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW); 485 err = gameport_open(gameport, drv, GAMEPORT_MODE_RAW);
480 if (err) { 486 if (err)
481 kfree(port); 487 goto fail1;
482 return err;
483 }
484 488
485 adi_init_digital(gameport); 489 adi_init_digital(gameport);
486 adi_read_packet(port); 490 adi_read_packet(port);
@@ -490,13 +494,18 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
490 494
491 for (i = 0; i < 2; i++) { 495 for (i = 0; i < 2; i++) {
492 adi_id_decode(port->adi + i, port); 496 adi_id_decode(port->adi + i, port);
493 adi_init_input(port->adi + i, port, i); 497
498 if (!port->adi[i].length)
499 continue;
500
501 err = adi_init_input(port->adi + i, port, i);
502 if (err)
503 goto fail2;
494 } 504 }
495 505
496 if (!port->adi[0].length && !port->adi[1].length) { 506 if (!port->adi[0].length && !port->adi[1].length) {
497 gameport_close(gameport); 507 err = -ENODEV;
498 kfree(port); 508 goto fail2;
499 return -ENODEV;
500 } 509 }
501 510
502 gameport_set_poll_handler(gameport, adi_poll); 511 gameport_set_poll_handler(gameport, adi_poll);
@@ -511,12 +520,18 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
511 for (i = 0; i < 2; i++) 520 for (i = 0; i < 2; i++)
512 if (port->adi[i].length > 0) { 521 if (port->adi[i].length > 0) {
513 adi_init_center(port->adi + i); 522 adi_init_center(port->adi + i);
514 input_register_device(&port->adi[i].dev); 523 input_register_device(port->adi[i].dev);
515 printk(KERN_INFO "input: %s [%s] on %s\n",
516 port->adi[i].name, port->adi[i].cname, gameport->phys);
517 } 524 }
518 525
519 return 0; 526 return 0;
527
528 fail2: for (i = 0; i < 2; i++)
529 if (port->adi[i].dev)
530 input_free_device(port->adi[i].dev);
531 gameport_close(gameport);
532 fail1: gameport_set_drvdata(gameport, NULL);
533 kfree(port);
534 return err;
520} 535}
521 536
522static void adi_disconnect(struct gameport *gameport) 537static void adi_disconnect(struct gameport *gameport)
@@ -526,7 +541,7 @@ static void adi_disconnect(struct gameport *gameport)
526 541
527 for (i = 0; i < 2; i++) 542 for (i = 0; i < 2; i++)
528 if (port->adi[i].length > 0) 543 if (port->adi[i].length > 0)
529 input_unregister_device(&port->adi[i].dev); 544 input_unregister_device(port->adi[i].dev);
530 gameport_close(gameport); 545 gameport_close(gameport);
531 gameport_set_drvdata(gameport, NULL); 546 gameport_set_drvdata(gameport, NULL);
532 kfree(port); 547 kfree(port);
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index e996183c5b06..8558a99f6635 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -53,11 +53,9 @@ __obsolete_setup("amijoy=");
53 53
54static int amijoy_used; 54static int amijoy_used;
55static DECLARE_MUTEX(amijoy_sem); 55static DECLARE_MUTEX(amijoy_sem);
56static struct input_dev amijoy_dev[2]; 56static struct input_dev *amijoy_dev[2];
57static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; 57static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" };
58 58
59static char *amijoy_name = "Amiga joystick";
60
61static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp) 59static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp)
62{ 60{
63 int i, data = 0, button = 0; 61 int i, data = 0, button = 0;
@@ -70,15 +68,15 @@ static irqreturn_t amijoy_interrupt(int irq, void *dummy, struct pt_regs *fp)
70 case 1: data = ~custom.joy1dat; button = (~ciaa.pra >> 7) & 1; break; 68 case 1: data = ~custom.joy1dat; button = (~ciaa.pra >> 7) & 1; break;
71 } 69 }
72 70
73 input_regs(amijoy_dev + i, fp); 71 input_regs(amijoy_dev[i], fp);
74 72
75 input_report_key(amijoy_dev + i, BTN_TRIGGER, button); 73 input_report_key(amijoy_dev[i], BTN_TRIGGER, button);
76 74
77 input_report_abs(amijoy_dev + i, ABS_X, ((data >> 1) & 1) - ((data >> 9) & 1)); 75 input_report_abs(amijoy_dev[i], ABS_X, ((data >> 1) & 1) - ((data >> 9) & 1));
78 data = ~(data ^ (data << 1)); 76 data = ~(data ^ (data << 1));
79 input_report_abs(amijoy_dev + i, ABS_Y, ((data >> 1) & 1) - ((data >> 9) & 1)); 77 input_report_abs(amijoy_dev[i], ABS_Y, ((data >> 1) & 1) - ((data >> 9) & 1));
80 78
81 input_sync(amijoy_dev + i); 79 input_sync(amijoy_dev[i]);
82 } 80 }
83 return IRQ_HANDLED; 81 return IRQ_HANDLED;
84} 82}
@@ -114,39 +112,52 @@ static void amijoy_close(struct input_dev *dev)
114static int __init amijoy_init(void) 112static int __init amijoy_init(void)
115{ 113{
116 int i, j; 114 int i, j;
115 int err;
117 116
118 for (i = 0; i < 2; i++) 117 for (i = 0; i < 2; i++) {
119 if (amijoy[i]) { 118 if (!amijoy[i])
120 if (!request_mem_region(CUSTOM_PHYSADDR+10+i*2, 2, 119 continue;
121 "amijoy [Denise]")) {
122 if (i == 1 && amijoy[0]) {
123 input_unregister_device(amijoy_dev);
124 release_mem_region(CUSTOM_PHYSADDR+10, 2);
125 }
126 return -EBUSY;
127 }
128 120
129 amijoy_dev[i].open = amijoy_open; 121 amijoy_dev[i] = input_allocate_device();
130 amijoy_dev[i].close = amijoy_close; 122 if (!amijoy_dev[i]) {
131 amijoy_dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 123 err = -ENOMEM;
132 amijoy_dev[i].absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 124 goto fail;
133 amijoy_dev[i].keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 125 }
134 for (j = 0; j < 2; j++) {
135 amijoy_dev[i].absmin[ABS_X + j] = -1;
136 amijoy_dev[i].absmax[ABS_X + j] = 1;
137 }
138 126
139 amijoy_dev[i].name = amijoy_name; 127 if (!request_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2, "amijoy [Denise]")) {
140 amijoy_dev[i].phys = amijoy_phys[i]; 128 input_free_device(amijoy_dev[i]);
141 amijoy_dev[i].id.bustype = BUS_AMIGA; 129 err = -EBUSY;
142 amijoy_dev[i].id.vendor = 0x0001; 130 goto fail;
143 amijoy_dev[i].id.product = 0x0003; 131 }
144 amijoy_dev[i].id.version = 0x0100;
145 132
146 input_register_device(amijoy_dev + i); 133 amijoy_dev[i]->name = "Amiga joystick";
147 printk(KERN_INFO "input: %s at joy%ddat\n", amijoy_name, i); 134 amijoy_dev[i]->phys = amijoy_phys[i];
135 amijoy_dev[i]->id.bustype = BUS_AMIGA;
136 amijoy_dev[i]->id.vendor = 0x0001;
137 amijoy_dev[i]->id.product = 0x0003;
138 amijoy_dev[i]->id.version = 0x0100;
139
140 amijoy_dev[i]->open = amijoy_open;
141 amijoy_dev[i]->close = amijoy_close;
142
143 amijoy_dev[i]->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
144 amijoy_dev[i]->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
145 amijoy_dev[i]->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
146 for (j = 0; j < 2; j++) {
147 amijoy_dev[i]->absmin[ABS_X + j] = -1;
148 amijoy_dev[i]->absmax[ABS_X + j] = 1;
148 } 149 }
150
151 input_register_device(amijoy_dev[i]);
152 }
149 return 0; 153 return 0;
154
155 fail: while (--i >= 0)
156 if (amijoy[i]) {
157 input_unregister_device(amijoy_dev[i]);
158 release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2);
159 }
160 return err;
150} 161}
151 162
152static void __exit amijoy_exit(void) 163static void __exit amijoy_exit(void)
@@ -155,8 +166,8 @@ static void __exit amijoy_exit(void)
155 166
156 for (i = 0; i < 2; i++) 167 for (i = 0; i < 2; i++)
157 if (amijoy[i]) { 168 if (amijoy[i]) {
158 input_unregister_device(amijoy_dev + i); 169 input_unregister_device(amijoy_dev[i]);
159 release_mem_region(CUSTOM_PHYSADDR+10+i*2, 2); 170 release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2);
160 } 171 }
161} 172}
162 173
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index 64b1313a3c66..c75ac6eb1ffb 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -111,7 +111,7 @@ static short analog_joy_btn[] = { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN
111static unsigned char analog_chf[] = { 0xf, 0x0, 0x1, 0x9, 0x2, 0x4, 0xc, 0x8, 0x3, 0x5, 0xb, 0x7, 0xd, 0xe, 0xa, 0x6 }; 111static unsigned char analog_chf[] = { 0xf, 0x0, 0x1, 0x9, 0x2, 0x4, 0xc, 0x8, 0x3, 0x5, 0xb, 0x7, 0xd, 0xe, 0xa, 0x6 };
112 112
113struct analog { 113struct analog {
114 struct input_dev dev; 114 struct input_dev *dev;
115 int mask; 115 int mask;
116 short *buttons; 116 short *buttons;
117 char name[ANALOG_MAX_NAME_LENGTH]; 117 char name[ANALOG_MAX_NAME_LENGTH];
@@ -182,7 +182,7 @@ static unsigned long analog_faketime = 0;
182 182
183static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons) 183static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons)
184{ 184{
185 struct input_dev *dev = &analog->dev; 185 struct input_dev *dev = analog->dev;
186 int i, j; 186 int i, j;
187 187
188 if (analog->mask & ANALOG_HAT_FCS) 188 if (analog->mask & ANALOG_HAT_FCS)
@@ -428,27 +428,30 @@ static void analog_name(struct analog *analog)
428 * analog_init_device() 428 * analog_init_device()
429 */ 429 */
430 430
431static void analog_init_device(struct analog_port *port, struct analog *analog, int index) 431static int analog_init_device(struct analog_port *port, struct analog *analog, int index)
432{ 432{
433 struct input_dev *input_dev;
433 int i, j, t, v, w, x, y, z; 434 int i, j, t, v, w, x, y, z;
434 435
435 analog_name(analog); 436 analog_name(analog);
436 sprintf(analog->phys, "%s/input%d", port->gameport->phys, index); 437 sprintf(analog->phys, "%s/input%d", port->gameport->phys, index);
437 analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; 438 analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn;
438 439
439 init_input_dev(&analog->dev); 440 analog->dev = input_dev = input_allocate_device();
441 if (!input_dev)
442 return -ENOMEM;
440 443
441 analog->dev.name = analog->name; 444 input_dev->name = analog->name;
442 analog->dev.phys = analog->phys; 445 input_dev->phys = analog->phys;
443 analog->dev.id.bustype = BUS_GAMEPORT; 446 input_dev->id.bustype = BUS_GAMEPORT;
444 analog->dev.id.vendor = GAMEPORT_ID_VENDOR_ANALOG; 447 input_dev->id.vendor = GAMEPORT_ID_VENDOR_ANALOG;
445 analog->dev.id.product = analog->mask >> 4; 448 input_dev->id.product = analog->mask >> 4;
446 analog->dev.id.version = 0x0100; 449 input_dev->id.version = 0x0100;
447 450
448 analog->dev.open = analog_open; 451 input_dev->open = analog_open;
449 analog->dev.close = analog_close; 452 input_dev->close = analog_close;
450 analog->dev.private = port; 453 input_dev->private = port;
451 analog->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 454 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
452 455
453 for (i = j = 0; i < 4; i++) 456 for (i = j = 0; i < 4; i++)
454 if (analog->mask & (1 << i)) { 457 if (analog->mask & (1 << i)) {
@@ -461,8 +464,6 @@ static void analog_init_device(struct analog_port *port, struct analog *analog,
461 v = (x >> 3); 464 v = (x >> 3);
462 w = (x >> 3); 465 w = (x >> 3);
463 466
464 set_bit(t, analog->dev.absbit);
465
466 if ((i == 2 || i == 3) && (j == 2 || j == 3) && (z > (y >> 3))) 467 if ((i == 2 || i == 3) && (j == 2 || j == 3) && (z > (y >> 3)))
467 x = y; 468 x = y;
468 469
@@ -472,11 +473,7 @@ static void analog_init_device(struct analog_port *port, struct analog *analog,
472 w = (x >> 4); 473 w = (x >> 4);
473 } 474 }
474 475
475 analog->dev.absmax[t] = (x << 1) - v; 476 input_set_abs_params(input_dev, t, v, (x << 1) - v, port->fuzz, w);
476 analog->dev.absmin[t] = v;
477 analog->dev.absfuzz[t] = port->fuzz;
478 analog->dev.absflat[t] = w;
479
480 j++; 477 j++;
481 } 478 }
482 479
@@ -484,41 +481,30 @@ static void analog_init_device(struct analog_port *port, struct analog *analog,
484 if (analog->mask & analog_exts[i]) 481 if (analog->mask & analog_exts[i])
485 for (x = 0; x < 2; x++) { 482 for (x = 0; x < 2; x++) {
486 t = analog_hats[j++]; 483 t = analog_hats[j++];
487 set_bit(t, analog->dev.absbit); 484 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
488 analog->dev.absmax[t] = 1;
489 analog->dev.absmin[t] = -1;
490 } 485 }
491 486
492 for (i = j = 0; i < 4; i++) 487 for (i = j = 0; i < 4; i++)
493 if (analog->mask & (0x10 << i)) 488 if (analog->mask & (0x10 << i))
494 set_bit(analog->buttons[j++], analog->dev.keybit); 489 set_bit(analog->buttons[j++], input_dev->keybit);
495 490
496 if (analog->mask & ANALOG_BTNS_CHF) 491 if (analog->mask & ANALOG_BTNS_CHF)
497 for (i = 0; i < 2; i++) 492 for (i = 0; i < 2; i++)
498 set_bit(analog->buttons[j++], analog->dev.keybit); 493 set_bit(analog->buttons[j++], input_dev->keybit);
499 494
500 if (analog->mask & ANALOG_HBTN_CHF) 495 if (analog->mask & ANALOG_HBTN_CHF)
501 for (i = 0; i < 4; i++) 496 for (i = 0; i < 4; i++)
502 set_bit(analog->buttons[j++], analog->dev.keybit); 497 set_bit(analog->buttons[j++], input_dev->keybit);
503 498
504 for (i = 0; i < 4; i++) 499 for (i = 0; i < 4; i++)
505 if (analog->mask & (ANALOG_BTN_TL << i)) 500 if (analog->mask & (ANALOG_BTN_TL << i))
506 set_bit(analog_pads[i], analog->dev.keybit); 501 set_bit(analog_pads[i], input_dev->keybit);
507 502
508 analog_decode(analog, port->axes, port->initial, port->buttons); 503 analog_decode(analog, port->axes, port->initial, port->buttons);
509 504
510 input_register_device(&analog->dev); 505 input_register_device(analog->dev);
511 506
512 printk(KERN_INFO "input: %s at %s", analog->name, port->gameport->phys); 507 return 0;
513
514 if (port->cooked)
515 printk(" [ADC port]\n");
516 else
517 printk(" [%s timer, %d %sHz clock, %d ns res]\n", TIME_NAME,
518 port->speed > 10000 ? (port->speed + 800) / 1000 : port->speed,
519 port->speed > 10000 ? "M" : "k",
520 port->speed > 10000 ? (port->loop * 1000) / (port->speed / 1000)
521 : (port->loop * 1000000) / port->speed);
522} 508}
523 509
524/* 510/*
@@ -659,37 +645,41 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
659 return - ENOMEM; 645 return - ENOMEM;
660 646
661 err = analog_init_port(gameport, drv, port); 647 err = analog_init_port(gameport, drv, port);
662 if (err) { 648 if (err)
663 kfree(port); 649 goto fail1;
664 return err;
665 }
666 650
667 err = analog_init_masks(port); 651 err = analog_init_masks(port);
668 if (err) { 652 if (err)
669 gameport_close(gameport); 653 goto fail2;
670 gameport_set_drvdata(gameport, NULL);
671 kfree(port);
672 return err;
673 }
674 654
675 gameport_set_poll_handler(gameport, analog_poll); 655 gameport_set_poll_handler(gameport, analog_poll);
676 gameport_set_poll_interval(gameport, 10); 656 gameport_set_poll_interval(gameport, 10);
677 657
678 for (i = 0; i < 2; i++) 658 for (i = 0; i < 2; i++)
679 if (port->analog[i].mask) 659 if (port->analog[i].mask) {
680 analog_init_device(port, port->analog + i, i); 660 err = analog_init_device(port, port->analog + i, i);
661 if (err)
662 goto fail3;
663 }
681 664
682 return 0; 665 return 0;
666
667 fail3: while (--i >= 0)
668 input_unregister_device(port->analog[i].dev);
669 fail2: gameport_close(gameport);
670 fail1: gameport_set_drvdata(gameport, NULL);
671 kfree(port);
672 return err;
683} 673}
684 674
685static void analog_disconnect(struct gameport *gameport) 675static void analog_disconnect(struct gameport *gameport)
686{ 676{
687 int i;
688 struct analog_port *port = gameport_get_drvdata(gameport); 677 struct analog_port *port = gameport_get_drvdata(gameport);
678 int i;
689 679
690 for (i = 0; i < 2; i++) 680 for (i = 0; i < 2; i++)
691 if (port->analog[i].mask) 681 if (port->analog[i].mask)
692 input_unregister_device(&port->analog[i].dev); 682 input_unregister_device(port->analog[i].dev);
693 gameport_close(gameport); 683 gameport_close(gameport);
694 gameport_set_drvdata(gameport, NULL); 684 gameport_set_drvdata(gameport, NULL);
695 printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n", 685 printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n",
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 0b2e9fa26579..9a3dfc724a41 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -44,13 +44,11 @@ MODULE_LICENSE("GPL");
44#define COBRA_MAX_STROBE 45 /* 45 us max wait for first strobe */ 44#define COBRA_MAX_STROBE 45 /* 45 us max wait for first strobe */
45#define COBRA_LENGTH 36 45#define COBRA_LENGTH 36
46 46
47static char* cobra_name = "Creative Labs Blaster GamePad Cobra";
48
49static int cobra_btn[] = { BTN_START, BTN_SELECT, BTN_TL, BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL2, BTN_TR2, 0 }; 47static int cobra_btn[] = { BTN_START, BTN_SELECT, BTN_TL, BTN_TR, BTN_X, BTN_Y, BTN_Z, BTN_A, BTN_B, BTN_C, BTN_TL2, BTN_TR2, 0 };
50 48
51struct cobra { 49struct cobra {
52 struct gameport *gameport; 50 struct gameport *gameport;
53 struct input_dev dev[2]; 51 struct input_dev *dev[2];
54 int reads; 52 int reads;
55 int bads; 53 int bads;
56 unsigned char exists; 54 unsigned char exists;
@@ -128,7 +126,7 @@ static void cobra_poll(struct gameport *gameport)
128 for (i = 0; i < 2; i++) 126 for (i = 0; i < 2; i++)
129 if (cobra->exists & r & (1 << i)) { 127 if (cobra->exists & r & (1 << i)) {
130 128
131 dev = cobra->dev + i; 129 dev = cobra->dev[i];
132 130
133 input_report_abs(dev, ABS_X, ((data[i] >> 4) & 1) - ((data[i] >> 3) & 1)); 131 input_report_abs(dev, ABS_X, ((data[i] >> 4) & 1) - ((data[i] >> 3) & 1));
134 input_report_abs(dev, ABS_Y, ((data[i] >> 2) & 1) - ((data[i] >> 1) & 1)); 132 input_report_abs(dev, ABS_Y, ((data[i] >> 2) & 1) - ((data[i] >> 1) & 1));
@@ -159,11 +157,13 @@ static void cobra_close(struct input_dev *dev)
159static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv) 157static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
160{ 158{
161 struct cobra *cobra; 159 struct cobra *cobra;
160 struct input_dev *input_dev;
162 unsigned int data[2]; 161 unsigned int data[2];
163 int i, j; 162 int i, j;
164 int err; 163 int err;
165 164
166 if (!(cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL))) 165 cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL);
166 if (!cobra)
167 return -ENOMEM; 167 return -ENOMEM;
168 168
169 cobra->gameport = gameport; 169 cobra->gameport = gameport;
@@ -191,38 +191,46 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
191 gameport_set_poll_handler(gameport, cobra_poll); 191 gameport_set_poll_handler(gameport, cobra_poll);
192 gameport_set_poll_interval(gameport, 20); 192 gameport_set_poll_interval(gameport, 20);
193 193
194 for (i = 0; i < 2; i++) 194 for (i = 0; i < 2; i++) {
195 if ((cobra->exists >> i) & 1) { 195 if (~(cobra->exists >> i) & 1)
196 196 continue;
197 sprintf(cobra->phys[i], "%s/input%d", gameport->phys, i);
198 197
199 cobra->dev[i].private = cobra; 198 cobra->dev[i] = input_dev = input_allocate_device();
200 cobra->dev[i].open = cobra_open; 199 if (!input_dev) {
201 cobra->dev[i].close = cobra_close; 200 err = -ENOMEM;
201 goto fail3;
202 }
202 203
203 cobra->dev[i].name = cobra_name; 204 sprintf(cobra->phys[i], "%s/input%d", gameport->phys, i);
204 cobra->dev[i].phys = cobra->phys[i];
205 cobra->dev[i].id.bustype = BUS_GAMEPORT;
206 cobra->dev[i].id.vendor = GAMEPORT_ID_VENDOR_CREATIVE;
207 cobra->dev[i].id.product = 0x0008;
208 cobra->dev[i].id.version = 0x0100;
209 205
210 cobra->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 206 input_dev->name = "Creative Labs Blaster GamePad Cobra";
207 input_dev->phys = cobra->phys[i];
208 input_dev->id.bustype = BUS_GAMEPORT;
209 input_dev->id.vendor = GAMEPORT_ID_VENDOR_CREATIVE;
210 input_dev->id.product = 0x0008;
211 input_dev->id.version = 0x0100;
212 input_dev->cdev.dev = &gameport->dev;
213 input_dev->private = cobra;
211 214
212 input_set_abs_params(&cobra->dev[i], ABS_X, -1, 1, 0, 0); 215 input_dev->open = cobra_open;
213 input_set_abs_params(&cobra->dev[i], ABS_Y, -1, 1, 0, 0); 216 input_dev->close = cobra_close;
214 217
215 for (j = 0; cobra_btn[j]; j++) 218 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
216 set_bit(cobra_btn[j], cobra->dev[i].keybit); 219 input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0);
220 input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0);
221 for (j = 0; cobra_btn[j]; j++)
222 set_bit(cobra_btn[j], input_dev->keybit);
217 223
218 input_register_device(&cobra->dev[i]); 224 input_register_device(cobra->dev[i]);
219 printk(KERN_INFO "input: %s on %s\n", cobra_name, gameport->phys); 225 }
220 }
221 226
222 return 0; 227 return 0;
223 228
224fail2: gameport_close(gameport); 229 fail3: for (i = 0; i < 2; i++)
225fail1: gameport_set_drvdata(gameport, NULL); 230 if (cobra->dev[i])
231 input_unregister_device(cobra->dev[i]);
232 fail2: gameport_close(gameport);
233 fail1: gameport_set_drvdata(gameport, NULL);
226 kfree(cobra); 234 kfree(cobra);
227 return err; 235 return err;
228} 236}
@@ -234,7 +242,7 @@ static void cobra_disconnect(struct gameport *gameport)
234 242
235 for (i = 0; i < 2; i++) 243 for (i = 0; i < 2; i++)
236 if ((cobra->exists >> i) & 1) 244 if ((cobra->exists >> i) & 1)
237 input_unregister_device(cobra->dev + i); 245 input_unregister_device(cobra->dev[i]);
238 gameport_close(gameport); 246 gameport_close(gameport);
239 gameport_set_drvdata(gameport, NULL); 247 gameport_set_drvdata(gameport, NULL);
240 kfree(cobra); 248 kfree(cobra);
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 2a3e4bb2da50..499344c72756 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -43,25 +43,28 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
43MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); 43MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver");
44MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
45 45
46static int db9[] __initdata = { -1, 0 }; 46struct db9_config {
47static int db9_nargs __initdata = 0; 47 int args[2];
48module_param_array_named(dev, db9, int, &db9_nargs, 0); 48 int nargs;
49MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)"); 49};
50 50
51static int db9_2[] __initdata = { -1, 0 }; 51#define DB9_MAX_PORTS 3
52static int db9_nargs_2 __initdata = 0; 52static struct db9_config db9[DB9_MAX_PORTS] __initdata;
53module_param_array_named(dev2, db9_2, int, &db9_nargs_2, 0);
54MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)");
55 53
56static int db9_3[] __initdata = { -1, 0 }; 54module_param_array_named(dev, db9[0].args, int, &db9[0].nargs, 0);
57static int db9_nargs_3 __initdata = 0; 55MODULE_PARM_DESC(dev, "Describes first attached device (<parport#>,<type>)");
58module_param_array_named(dev3, db9_3, int, &db9_nargs_3, 0); 56module_param_array_named(dev2, db9[1].args, int, &db9[0].nargs, 0);
57MODULE_PARM_DESC(dev2, "Describes second attached device (<parport#>,<type>)");
58module_param_array_named(dev3, db9[2].args, int, &db9[2].nargs, 0);
59MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)"); 59MODULE_PARM_DESC(dev3, "Describes third attached device (<parport#>,<type>)");
60 60
61__obsolete_setup("db9="); 61__obsolete_setup("db9=");
62__obsolete_setup("db9_2="); 62__obsolete_setup("db9_2=");
63__obsolete_setup("db9_3="); 63__obsolete_setup("db9_3=");
64 64
65#define DB9_ARG_PARPORT 0
66#define DB9_ARG_MODE 1
67
65#define DB9_MULTI_STICK 0x01 68#define DB9_MULTI_STICK 0x01
66#define DB9_MULTI2_STICK 0x02 69#define DB9_MULTI2_STICK 0x02
67#define DB9_GENESIS_PAD 0x03 70#define DB9_GENESIS_PAD 0x03
@@ -87,40 +90,53 @@ __obsolete_setup("db9_3=");
87#define DB9_NORMAL 0x0a 90#define DB9_NORMAL 0x0a
88#define DB9_NOSELECT 0x08 91#define DB9_NOSELECT 0x08
89 92
90#define DB9_MAX_DEVICES 2
91
92#define DB9_GENESIS6_DELAY 14 93#define DB9_GENESIS6_DELAY 14
93#define DB9_REFRESH_TIME HZ/100 94#define DB9_REFRESH_TIME HZ/100
94 95
96#define DB9_MAX_DEVICES 2
97
98struct db9_mode_data {
99 const char *name;
100 const short *buttons;
101 int n_buttons;
102 int n_pads;
103 int n_axis;
104 int bidirectional;
105 int reverse;
106};
107
95struct db9 { 108struct db9 {
96 struct input_dev dev[DB9_MAX_DEVICES]; 109 struct input_dev *dev[DB9_MAX_DEVICES];
97 struct timer_list timer; 110 struct timer_list timer;
98 struct pardevice *pd; 111 struct pardevice *pd;
99 int mode; 112 int mode;
100 int used; 113 int used;
101 struct semaphore sem; 114 struct semaphore sem;
102 char phys[2][32]; 115 char phys[DB9_MAX_DEVICES][32];
103}; 116};
104 117
105static struct db9 *db9_base[3]; 118static struct db9 *db9_base[3];
106 119
107static short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB }; 120static const short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB };
108static short db9_genesis_btn[] = { BTN_START, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_MODE }; 121static const short db9_genesis_btn[] = { BTN_START, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_MODE };
109static short db9_cd32_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START }; 122static const short db9_cd32_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START };
110
111static char db9_buttons[DB9_MAX_PAD] = { 0, 1, 2, 4, 0, 6, 8, 9, 1, 1, 7, 9, 9 };
112static short *db9_btn[DB9_MAX_PAD] = { NULL, db9_multi_btn, db9_multi_btn, db9_genesis_btn, NULL, db9_genesis_btn,
113 db9_genesis_btn, db9_cd32_btn, db9_multi_btn, db9_multi_btn, db9_cd32_btn,
114 db9_cd32_btn, db9_cd32_btn };
115static char *db9_name[DB9_MAX_PAD] = { NULL, "Multisystem joystick", "Multisystem joystick (2 fire)", "Genesis pad",
116 NULL, "Genesis 5 pad", "Genesis 6 pad", "Saturn pad", "Multisystem (0.8.0.2) joystick",
117 "Multisystem (0.8.0.2-dual) joystick", "Amiga CD-32 pad", "Saturn dpp", "Saturn dpp dual" };
118
119static const int db9_max_pads[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 6, 1, 2, 1, 6, 12 };
120static const int db9_num_axis[DB9_MAX_PAD] = { 0, 2, 2, 2, 0, 2, 2, 7, 2, 2, 2 ,7, 7 };
121static const short db9_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_RZ, ABS_Z, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; 123static const short db9_abs[] = { ABS_X, ABS_Y, ABS_RX, ABS_RY, ABS_RZ, ABS_Z, ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y };
122static const int db9_bidirectional[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0 }; 124
123static const int db9_reverse[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0 }; 125static const struct db9_mode_data db9_modes[] = {
126 { NULL, NULL, 0, 0, 0, 0, 0 },
127 { "Multisystem joystick", db9_multi_btn, 1, 1, 2, 1, 1 },
128 { "Multisystem joystick (2 fire)", db9_multi_btn, 2, 1, 2, 1, 1 },
129 { "Genesis pad", db9_genesis_btn, 4, 1, 2, 1, 1 },
130 { NULL, NULL, 0, 0, 0, 0, 0 },
131 { "Genesis 5 pad", db9_genesis_btn, 6, 1, 2, 1, 1 },
132 { "Genesis 6 pad", db9_genesis_btn, 8, 1, 2, 1, 1 },
133 { "Saturn pad", db9_cd32_btn, 9, 6, 7, 0, 1 },
134 { "Multisystem (0.8.0.2) joystick", db9_multi_btn, 1, 1, 2, 1, 1 },
135 { "Multisystem (0.8.0.2-dual) joystick", db9_multi_btn, 1, 2, 2, 1, 1 },
136 { "Amiga CD-32 pad", db9_cd32_btn, 7, 1, 2, 1, 1 },
137 { "Saturn dpp", db9_cd32_btn, 9, 6, 7, 0, 0 },
138 { "Saturn dpp dual", db9_cd32_btn, 9, 12, 7, 0, 0 },
139};
124 140
125/* 141/*
126 * Saturn controllers 142 * Saturn controllers
@@ -342,7 +358,7 @@ static int db9_saturn(int mode, struct parport *port, struct input_dev *dev)
342 default: 358 default:
343 return -1; 359 return -1;
344 } 360 }
345 max_pads = min(db9_max_pads[mode], DB9_MAX_DEVICES); 361 max_pads = min(db9_modes[mode].n_pads, DB9_MAX_DEVICES);
346 for (tmp = 0, i = 0; i < n; i++) { 362 for (tmp = 0, i = 0; i < n; i++) {
347 id = db9_saturn_read_packet(port, data, type + i, 1); 363 id = db9_saturn_read_packet(port, data, type + i, 1);
348 tmp = db9_saturn_report(id, data, dev, tmp, max_pads); 364 tmp = db9_saturn_report(id, data, dev, tmp, max_pads);
@@ -354,17 +370,18 @@ static void db9_timer(unsigned long private)
354{ 370{
355 struct db9 *db9 = (void *) private; 371 struct db9 *db9 = (void *) private;
356 struct parport *port = db9->pd->port; 372 struct parport *port = db9->pd->port;
357 struct input_dev *dev = db9->dev; 373 struct input_dev *dev = db9->dev[0];
374 struct input_dev *dev2 = db9->dev[1];
358 int data, i; 375 int data, i;
359 376
360 switch(db9->mode) { 377 switch (db9->mode) {
361 case DB9_MULTI_0802_2: 378 case DB9_MULTI_0802_2:
362 379
363 data = parport_read_data(port) >> 3; 380 data = parport_read_data(port) >> 3;
364 381
365 input_report_abs(dev + 1, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); 382 input_report_abs(dev2, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1));
366 input_report_abs(dev + 1, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); 383 input_report_abs(dev2, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1));
367 input_report_key(dev + 1, BTN_TRIGGER, ~data & DB9_FIRE1); 384 input_report_key(dev2, BTN_TRIGGER, ~data & DB9_FIRE1);
368 385
369 case DB9_MULTI_0802: 386 case DB9_MULTI_0802:
370 387
@@ -405,7 +422,7 @@ static void db9_timer(unsigned long private)
405 input_report_key(dev, BTN_C, ~data & DB9_FIRE2); 422 input_report_key(dev, BTN_C, ~data & DB9_FIRE2);
406 423
407 parport_write_control(port, DB9_NORMAL); 424 parport_write_control(port, DB9_NORMAL);
408 data=parport_read_data(port); 425 data = parport_read_data(port);
409 426
410 input_report_key(dev, BTN_A, ~data & DB9_FIRE1); 427 input_report_key(dev, BTN_A, ~data & DB9_FIRE1);
411 input_report_key(dev, BTN_START, ~data & DB9_FIRE2); 428 input_report_key(dev, BTN_START, ~data & DB9_FIRE2);
@@ -414,7 +431,7 @@ static void db9_timer(unsigned long private)
414 case DB9_GENESIS5_PAD: 431 case DB9_GENESIS5_PAD:
415 432
416 parport_write_control(port, DB9_NOSELECT); 433 parport_write_control(port, DB9_NOSELECT);
417 data=parport_read_data(port); 434 data = parport_read_data(port);
418 435
419 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); 436 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1));
420 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); 437 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1));
@@ -422,7 +439,7 @@ static void db9_timer(unsigned long private)
422 input_report_key(dev, BTN_C, ~data & DB9_FIRE2); 439 input_report_key(dev, BTN_C, ~data & DB9_FIRE2);
423 440
424 parport_write_control(port, DB9_NORMAL); 441 parport_write_control(port, DB9_NORMAL);
425 data=parport_read_data(port); 442 data = parport_read_data(port);
426 443
427 input_report_key(dev, BTN_A, ~data & DB9_FIRE1); 444 input_report_key(dev, BTN_A, ~data & DB9_FIRE1);
428 input_report_key(dev, BTN_X, ~data & DB9_FIRE2); 445 input_report_key(dev, BTN_X, ~data & DB9_FIRE2);
@@ -434,7 +451,7 @@ static void db9_timer(unsigned long private)
434 451
435 parport_write_control(port, DB9_NOSELECT); /* 1 */ 452 parport_write_control(port, DB9_NOSELECT); /* 1 */
436 udelay(DB9_GENESIS6_DELAY); 453 udelay(DB9_GENESIS6_DELAY);
437 data=parport_read_data(port); 454 data = parport_read_data(port);
438 455
439 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); 456 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1));
440 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); 457 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1));
@@ -443,7 +460,7 @@ static void db9_timer(unsigned long private)
443 460
444 parport_write_control(port, DB9_NORMAL); 461 parport_write_control(port, DB9_NORMAL);
445 udelay(DB9_GENESIS6_DELAY); 462 udelay(DB9_GENESIS6_DELAY);
446 data=parport_read_data(port); 463 data = parport_read_data(port);
447 464
448 input_report_key(dev, BTN_A, ~data & DB9_FIRE1); 465 input_report_key(dev, BTN_A, ~data & DB9_FIRE1);
449 input_report_key(dev, BTN_START, ~data & DB9_FIRE2); 466 input_report_key(dev, BTN_START, ~data & DB9_FIRE2);
@@ -477,7 +494,7 @@ static void db9_timer(unsigned long private)
477 494
478 case DB9_CD32_PAD: 495 case DB9_CD32_PAD:
479 496
480 data=parport_read_data(port); 497 data = parport_read_data(port);
481 498
482 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1)); 499 input_report_abs(dev, ABS_X, (data & DB9_RIGHT ? 0 : 1) - (data & DB9_LEFT ? 0 : 1));
483 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1)); 500 input_report_abs(dev, ABS_Y, (data & DB9_DOWN ? 0 : 1) - (data & DB9_UP ? 0 : 1));
@@ -489,7 +506,7 @@ static void db9_timer(unsigned long private)
489 parport_write_control(port, 0x02); 506 parport_write_control(port, 0x02);
490 parport_write_control(port, 0x0a); 507 parport_write_control(port, 0x0a);
491 input_report_key(dev, db9_cd32_btn[i], ~data & DB9_FIRE2); 508 input_report_key(dev, db9_cd32_btn[i], ~data & DB9_FIRE2);
492 } 509 }
493 510
494 parport_write_control(port, 0x00); 511 parport_write_control(port, 0x00);
495 break; 512 break;
@@ -513,7 +530,7 @@ static int db9_open(struct input_dev *dev)
513 if (!db9->used++) { 530 if (!db9->used++) {
514 parport_claim(db9->pd); 531 parport_claim(db9->pd);
515 parport_write_data(port, 0xff); 532 parport_write_data(port, 0xff);
516 if (db9_reverse[db9->mode]) { 533 if (db9_modes[db9->mode].reverse) {
517 parport_data_reverse(port); 534 parport_data_reverse(port);
518 parport_write_control(port, DB9_NORMAL); 535 parport_write_control(port, DB9_NORMAL);
519 } 536 }
@@ -539,117 +556,160 @@ static void db9_close(struct input_dev *dev)
539 up(&db9->sem); 556 up(&db9->sem);
540} 557}
541 558
542static struct db9 __init *db9_probe(int *config, int nargs) 559static struct db9 __init *db9_probe(int parport, int mode)
543{ 560{
544 struct db9 *db9; 561 struct db9 *db9;
562 const struct db9_mode_data *db9_mode;
545 struct parport *pp; 563 struct parport *pp;
564 struct pardevice *pd;
565 struct input_dev *input_dev;
546 int i, j; 566 int i, j;
567 int err;
547 568
548 if (config[0] < 0) 569 if (mode < 1 || mode >= DB9_MAX_PAD || !db9_modes[mode].n_buttons) {
549 return NULL; 570 printk(KERN_ERR "db9.c: Bad device type %d\n", mode);
550 571 err = -EINVAL;
551 if (nargs < 2) { 572 goto err_out;
552 printk(KERN_ERR "db9.c: Device type must be specified.\n");
553 return NULL;
554 } 573 }
555 574
556 if (config[1] < 1 || config[1] >= DB9_MAX_PAD || !db9_buttons[config[1]]) { 575 db9_mode = &db9_modes[mode];
557 printk(KERN_ERR "db9.c: bad config\n");
558 return NULL;
559 }
560 576
561 pp = parport_find_number(config[0]); 577 pp = parport_find_number(parport);
562 if (!pp) { 578 if (!pp) {
563 printk(KERN_ERR "db9.c: no such parport\n"); 579 printk(KERN_ERR "db9.c: no such parport\n");
564 return NULL; 580 err = -ENODEV;
581 goto err_out;
565 } 582 }
566 583
567 if (db9_bidirectional[config[1]]) { 584 if (db9_mode[mode].bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) {
568 if (!(pp->modes & PARPORT_MODE_TRISTATE)) { 585 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n");
569 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); 586 err = -EINVAL;
570 parport_put_port(pp); 587 goto err_put_pp;
571 return NULL; 588 }
572 } 589
590 pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
591 if (!pd) {
592 printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n");
593 err = -EBUSY;
594 goto err_put_pp;
573 } 595 }
574 596
575 if (!(db9 = kzalloc(sizeof(struct db9), GFP_KERNEL))) { 597 db9 = kzalloc(sizeof(struct db9), GFP_KERNEL);
576 parport_put_port(pp); 598 if (!db9) {
577 return NULL; 599 printk(KERN_ERR "db9.c: Not enough memory\n");
600 err = -ENOMEM;
601 goto err_unreg_pardev;
578 } 602 }
579 603
580 init_MUTEX(&db9->sem); 604 init_MUTEX(&db9->sem);
581 db9->mode = config[1]; 605 db9->pd = pd;
606 db9->mode = mode;
582 init_timer(&db9->timer); 607 init_timer(&db9->timer);
583 db9->timer.data = (long) db9; 608 db9->timer.data = (long) db9;
584 db9->timer.function = db9_timer; 609 db9->timer.function = db9_timer;
585 610
586 db9->pd = parport_register_device(pp, "db9", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 611 for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) {
587 parport_put_port(pp);
588
589 if (!db9->pd) {
590 printk(KERN_ERR "db9.c: parport busy already - lp.o loaded?\n");
591 kfree(db9);
592 return NULL;
593 }
594 612
595 for (i = 0; i < (min(db9_max_pads[db9->mode], DB9_MAX_DEVICES)); i++) { 613 db9->dev[i] = input_dev = input_allocate_device();
614 if (!input_dev) {
615 printk(KERN_ERR "db9.c: Not enough memory for input device\n");
616 err = -ENOMEM;
617 goto err_free_devs;
618 }
596 619
597 sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i); 620 sprintf(db9->phys[i], "%s/input%d", db9->pd->port->name, i);
598 621
599 db9->dev[i].private = db9; 622 input_dev->name = db9_mode->name;
600 db9->dev[i].open = db9_open; 623 input_dev->phys = db9->phys[i];
601 db9->dev[i].close = db9_close; 624 input_dev->id.bustype = BUS_PARPORT;
602 625 input_dev->id.vendor = 0x0002;
603 db9->dev[i].name = db9_name[db9->mode]; 626 input_dev->id.product = mode;
604 db9->dev[i].phys = db9->phys[i]; 627 input_dev->id.version = 0x0100;
605 db9->dev[i].id.bustype = BUS_PARPORT; 628 input_dev->private = db9;
606 db9->dev[i].id.vendor = 0x0002; 629
607 db9->dev[i].id.product = config[1]; 630 input_dev->open = db9_open;
608 db9->dev[i].id.version = 0x0100; 631 input_dev->close = db9_close;
609 632
610 db9->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 633 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
611 for (j = 0; j < db9_buttons[db9->mode]; j++) 634 for (j = 0; j < db9_mode->n_buttons; j++)
612 set_bit(db9_btn[db9->mode][j], db9->dev[i].keybit); 635 set_bit(db9_mode->buttons[j], input_dev->keybit);
613 for (j = 0; j < db9_num_axis[db9->mode]; j++) { 636 for (j = 0; j < db9_mode->n_axis; j++) {
614 set_bit(db9_abs[j], db9->dev[i].absbit); 637 if (j < 2)
615 if (j < 2) { 638 input_set_abs_params(input_dev, db9_abs[j], -1, 1, 0, 0);
616 db9->dev[i].absmin[db9_abs[j]] = -1; 639 else
617 db9->dev[i].absmax[db9_abs[j]] = 1; 640 input_set_abs_params(input_dev, db9_abs[j], 1, 255, 0, 0);
618 } else {
619 db9->dev[i].absmin[db9_abs[j]] = 1;
620 db9->dev[i].absmax[db9_abs[j]] = 255;
621 db9->dev[i].absflat[db9_abs[j]] = 0;
622 }
623 } 641 }
624 input_register_device(db9->dev + i); 642
625 printk(KERN_INFO "input: %s on %s\n", db9->dev[i].name, db9->pd->port->name); 643 input_register_device(input_dev);
626 } 644 }
627 645
646 parport_put_port(pp);
628 return db9; 647 return db9;
648
649 err_free_devs:
650 while (--i >= 0)
651 input_unregister_device(db9->dev[i]);
652 kfree(db9);
653 err_unreg_pardev:
654 parport_unregister_device(pd);
655 err_put_pp:
656 parport_put_port(pp);
657 err_out:
658 return ERR_PTR(err);
659}
660
661static void __exit db9_remove(struct db9 *db9)
662{
663 int i;
664
665 for (i = 0; i < min(db9_modes[db9->mode].n_pads, DB9_MAX_DEVICES); i++)
666 input_unregister_device(db9->dev[i]);
667 parport_unregister_device(db9->pd);
668 kfree(db9);
629} 669}
630 670
631static int __init db9_init(void) 671static int __init db9_init(void)
632{ 672{
633 db9_base[0] = db9_probe(db9, db9_nargs); 673 int i;
634 db9_base[1] = db9_probe(db9_2, db9_nargs_2); 674 int have_dev = 0;
635 db9_base[2] = db9_probe(db9_3, db9_nargs_3); 675 int err = 0;
676
677 for (i = 0; i < DB9_MAX_PORTS; i++) {
678 if (db9[i].nargs == 0 || db9[i].args[DB9_ARG_PARPORT] < 0)
679 continue;
680
681 if (db9[i].nargs < 2) {
682 printk(KERN_ERR "db9.c: Device type must be specified.\n");
683 err = -EINVAL;
684 break;
685 }
686
687 db9_base[i] = db9_probe(db9[i].args[DB9_ARG_PARPORT],
688 db9[i].args[DB9_ARG_MODE]);
689 if (IS_ERR(db9_base[i])) {
690 err = PTR_ERR(db9_base[i]);
691 break;
692 }
693
694 have_dev = 1;
695 }
636 696
637 if (db9_base[0] || db9_base[1] || db9_base[2]) 697 if (err) {
638 return 0; 698 while (--i >= 0)
699 db9_remove(db9_base[i]);
700 return err;
701 }
639 702
640 return -ENODEV; 703 return have_dev ? 0 : -ENODEV;
641} 704}
642 705
643static void __exit db9_exit(void) 706static void __exit db9_exit(void)
644{ 707{
645 int i, j; 708 int i;
646 709
647 for (i = 0; i < 3; i++) 710 for (i = 0; i < DB9_MAX_PORTS; i++)
648 if (db9_base[i]) { 711 if (db9_base[i])
649 for (j = 0; j < min(db9_max_pads[db9_base[i]->mode], DB9_MAX_DEVICES); j++) 712 db9_remove(db9_base[i]);
650 input_unregister_device(db9_base[i]->dev + j);
651 parport_unregister_device(db9_base[i]->pd);
652 }
653} 713}
654 714
655module_init(db9_init); 715module_init(db9_init);
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 5427bf9fc862..7df2d82f2c83 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -41,20 +41,22 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
41MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); 41MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
42MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
43 43
44static int gc[] __initdata = { -1, 0, 0, 0, 0, 0 }; 44#define GC_MAX_PORTS 3
45static int gc_nargs __initdata = 0; 45#define GC_MAX_DEVICES 5
46module_param_array_named(map, gc, int, &gc_nargs, 0);
47MODULE_PARM_DESC(map, "Describers first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
48 46
49static int gc_2[] __initdata = { -1, 0, 0, 0, 0, 0 }; 47struct gc_config {
50static int gc_nargs_2 __initdata = 0; 48 int args[GC_MAX_DEVICES + 1];
51module_param_array_named(map2, gc_2, int, &gc_nargs_2, 0); 49 int nargs;
52MODULE_PARM_DESC(map2, "Describers second set of devices"); 50};
51
52static struct gc_config gc[GC_MAX_PORTS] __initdata;
53 53
54static int gc_3[] __initdata = { -1, 0, 0, 0, 0, 0 }; 54module_param_array_named(map, gc[0].args, int, &gc[0].nargs, 0);
55static int gc_nargs_3 __initdata = 0; 55MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
56module_param_array_named(map3, gc_3, int, &gc_nargs_3, 0); 56module_param_array_named(map2, gc[1].args, int, &gc[1].nargs, 0);
57MODULE_PARM_DESC(map3, "Describers third set of devices"); 57MODULE_PARM_DESC(map2, "Describes second set of devices");
58module_param_array_named(map3, gc[2].args, int, &gc[2].nargs, 0);
59MODULE_PARM_DESC(map3, "Describes third set of devices");
58 60
59__obsolete_setup("gc="); 61__obsolete_setup("gc=");
60__obsolete_setup("gc_2="); 62__obsolete_setup("gc_2=");
@@ -77,12 +79,12 @@ __obsolete_setup("gc_3=");
77 79
78struct gc { 80struct gc {
79 struct pardevice *pd; 81 struct pardevice *pd;
80 struct input_dev dev[5]; 82 struct input_dev *dev[GC_MAX_DEVICES];
81 struct timer_list timer; 83 struct timer_list timer;
82 unsigned char pads[GC_MAX + 1]; 84 unsigned char pads[GC_MAX + 1];
83 int used; 85 int used;
84 struct semaphore sem; 86 struct semaphore sem;
85 char phys[5][32]; 87 char phys[GC_MAX_DEVICES][32];
86}; 88};
87 89
88static struct gc *gc_base[3]; 90static struct gc *gc_base[3];
@@ -330,7 +332,6 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[5][GC_PSX_BYTES
330static void gc_timer(unsigned long private) 332static void gc_timer(unsigned long private)
331{ 333{
332 struct gc *gc = (void *) private; 334 struct gc *gc = (void *) private;
333 struct input_dev *dev = gc->dev;
334 unsigned char data[GC_MAX_LENGTH]; 335 unsigned char data[GC_MAX_LENGTH];
335 unsigned char data_psx[5][GC_PSX_BYTES]; 336 unsigned char data_psx[5][GC_PSX_BYTES];
336 int i, j, s; 337 int i, j, s;
@@ -357,16 +358,16 @@ static void gc_timer(unsigned long private)
357 if (data[31 - j] & s) axes[1] |= 1 << j; 358 if (data[31 - j] & s) axes[1] |= 1 << j;
358 } 359 }
359 360
360 input_report_abs(dev + i, ABS_X, axes[0]); 361 input_report_abs(gc->dev[i], ABS_X, axes[0]);
361 input_report_abs(dev + i, ABS_Y, -axes[1]); 362 input_report_abs(gc->dev[i], ABS_Y, -axes[1]);
362 363
363 input_report_abs(dev + i, ABS_HAT0X, !(s & data[6]) - !(s & data[7])); 364 input_report_abs(gc->dev[i], ABS_HAT0X, !(s & data[6]) - !(s & data[7]));
364 input_report_abs(dev + i, ABS_HAT0Y, !(s & data[4]) - !(s & data[5])); 365 input_report_abs(gc->dev[i], ABS_HAT0Y, !(s & data[4]) - !(s & data[5]));
365 366
366 for (j = 0; j < 10; j++) 367 for (j = 0; j < 10; j++)
367 input_report_key(dev + i, gc_n64_btn[j], s & data[gc_n64_bytes[j]]); 368 input_report_key(gc->dev[i], gc_n64_btn[j], s & data[gc_n64_bytes[j]]);
368 369
369 input_sync(dev + i); 370 input_sync(gc->dev[i]);
370 } 371 }
371 } 372 }
372 } 373 }
@@ -384,19 +385,19 @@ static void gc_timer(unsigned long private)
384 s = gc_status_bit[i]; 385 s = gc_status_bit[i];
385 386
386 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 387 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) {
387 input_report_abs(dev + i, ABS_X, !(s & data[6]) - !(s & data[7])); 388 input_report_abs(gc->dev[i], ABS_X, !(s & data[6]) - !(s & data[7]));
388 input_report_abs(dev + i, ABS_Y, !(s & data[4]) - !(s & data[5])); 389 input_report_abs(gc->dev[i], ABS_Y, !(s & data[4]) - !(s & data[5]));
389 } 390 }
390 391
391 if (s & gc->pads[GC_NES]) 392 if (s & gc->pads[GC_NES])
392 for (j = 0; j < 4; j++) 393 for (j = 0; j < 4; j++)
393 input_report_key(dev + i, gc_snes_btn[j], s & data[gc_nes_bytes[j]]); 394 input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_nes_bytes[j]]);
394 395
395 if (s & gc->pads[GC_SNES]) 396 if (s & gc->pads[GC_SNES])
396 for (j = 0; j < 8; j++) 397 for (j = 0; j < 8; j++)
397 input_report_key(dev + i, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 398 input_report_key(gc->dev[i], gc_snes_btn[j], s & data[gc_snes_bytes[j]]);
398 399
399 input_sync(dev + i); 400 input_sync(gc->dev[i]);
400 } 401 }
401 } 402 }
402 403
@@ -413,15 +414,15 @@ static void gc_timer(unsigned long private)
413 s = gc_status_bit[i]; 414 s = gc_status_bit[i];
414 415
415 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { 416 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) {
416 input_report_abs(dev + i, ABS_X, !(s & data[2]) - !(s & data[3])); 417 input_report_abs(gc->dev[i], ABS_X, !(s & data[2]) - !(s & data[3]));
417 input_report_abs(dev + i, ABS_Y, !(s & data[0]) - !(s & data[1])); 418 input_report_abs(gc->dev[i], ABS_Y, !(s & data[0]) - !(s & data[1]));
418 input_report_key(dev + i, BTN_TRIGGER, s & data[4]); 419 input_report_key(gc->dev[i], BTN_TRIGGER, s & data[4]);
419 } 420 }
420 421
421 if (s & gc->pads[GC_MULTI2]) 422 if (s & gc->pads[GC_MULTI2])
422 input_report_key(dev + i, BTN_THUMB, s & data[5]); 423 input_report_key(gc->dev[i], BTN_THUMB, s & data[5]);
423 424
424 input_sync(dev + i); 425 input_sync(gc->dev[i]);
425 } 426 }
426 } 427 }
427 428
@@ -438,44 +439,44 @@ static void gc_timer(unsigned long private)
438 439
439 case GC_PSX_RUMBLE: 440 case GC_PSX_RUMBLE:
440 441
441 input_report_key(dev + i, BTN_THUMBL, ~data_psx[i][0] & 0x04); 442 input_report_key(gc->dev[i], BTN_THUMBL, ~data_psx[i][0] & 0x04);
442 input_report_key(dev + i, BTN_THUMBR, ~data_psx[i][0] & 0x02); 443 input_report_key(gc->dev[i], BTN_THUMBR, ~data_psx[i][0] & 0x02);
443 444
444 case GC_PSX_NEGCON: 445 case GC_PSX_NEGCON:
445 case GC_PSX_ANALOG: 446 case GC_PSX_ANALOG:
446 447
447 if(gc->pads[GC_DDR] & gc_status_bit[i]) { 448 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
448 for(j = 0; j < 4; j++) 449 for(j = 0; j < 4; j++)
449 input_report_key(dev + i, gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); 450 input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j));
450 } else { 451 } else {
451 for (j = 0; j < 4; j++) 452 for (j = 0; j < 4; j++)
452 input_report_abs(dev + i, gc_psx_abs[j+2], data_psx[i][j + 2]); 453 input_report_abs(gc->dev[i], gc_psx_abs[j+2], data_psx[i][j + 2]);
453 454
454 input_report_abs(dev + i, ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); 455 input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128);
455 input_report_abs(dev + i, ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); 456 input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128);
456 } 457 }
457 458
458 for (j = 0; j < 8; j++) 459 for (j = 0; j < 8; j++)
459 input_report_key(dev + i, gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); 460 input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j));
460 461
461 input_report_key(dev + i, BTN_START, ~data_psx[i][0] & 0x08); 462 input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08);
462 input_report_key(dev + i, BTN_SELECT, ~data_psx[i][0] & 0x01); 463 input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01);
463 464
464 input_sync(dev + i); 465 input_sync(gc->dev[i]);
465 466
466 break; 467 break;
467 468
468 case GC_PSX_NORMAL: 469 case GC_PSX_NORMAL:
469 if(gc->pads[GC_DDR] & gc_status_bit[i]) { 470 if (gc->pads[GC_DDR] & gc_status_bit[i]) {
470 for(j = 0; j < 4; j++) 471 for(j = 0; j < 4; j++)
471 input_report_key(dev + i, gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j)); 472 input_report_key(gc->dev[i], gc_psx_ddr_btn[j], ~data_psx[i][0] & (0x10 << j));
472 } else { 473 } else {
473 input_report_abs(dev + i, ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128); 474 input_report_abs(gc->dev[i], ABS_X, 128 + !(data_psx[i][0] & 0x20) * 127 - !(data_psx[i][0] & 0x80) * 128);
474 input_report_abs(dev + i, ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128); 475 input_report_abs(gc->dev[i], ABS_Y, 128 + !(data_psx[i][0] & 0x40) * 127 - !(data_psx[i][0] & 0x10) * 128);
475 476
476 /* for some reason if the extra axes are left unset they drift */ 477 /* for some reason if the extra axes are left unset they drift */
477 /* for (j = 0; j < 4; j++) 478 /* for (j = 0; j < 4; j++)
478 input_report_abs(dev + i, gc_psx_abs[j+2], 128); 479 input_report_abs(gc->dev[i], gc_psx_abs[j+2], 128);
479 * This needs to be debugged properly, 480 * This needs to be debugged properly,
480 * maybe fuzz processing needs to be done in input_sync() 481 * maybe fuzz processing needs to be done in input_sync()
481 * --vojtech 482 * --vojtech
@@ -483,12 +484,12 @@ static void gc_timer(unsigned long private)
483 } 484 }
484 485
485 for (j = 0; j < 8; j++) 486 for (j = 0; j < 8; j++)
486 input_report_key(dev + i, gc_psx_btn[j], ~data_psx[i][1] & (1 << j)); 487 input_report_key(gc->dev[i], gc_psx_btn[j], ~data_psx[i][1] & (1 << j));
487 488
488 input_report_key(dev + i, BTN_START, ~data_psx[i][0] & 0x08); 489 input_report_key(gc->dev[i], BTN_START, ~data_psx[i][0] & 0x08);
489 input_report_key(dev + i, BTN_SELECT, ~data_psx[i][0] & 0x01); 490 input_report_key(gc->dev[i], BTN_SELECT, ~data_psx[i][0] & 0x01);
490 491
491 input_sync(dev + i); 492 input_sync(gc->dev[i]);
492 493
493 break; 494 break;
494 495
@@ -533,177 +534,212 @@ static void gc_close(struct input_dev *dev)
533 up(&gc->sem); 534 up(&gc->sem);
534} 535}
535 536
536static struct gc __init *gc_probe(int *config, int nargs) 537static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
537{ 538{
538 struct gc *gc; 539 struct input_dev *input_dev;
539 struct parport *pp; 540 int i;
540 int i, j;
541 541
542 if (config[0] < 0) 542 if (!pad_type)
543 return NULL; 543 return 0;
544 544
545 if (nargs < 2) { 545 if (pad_type < 1 || pad_type > GC_MAX) {
546 printk(KERN_ERR "gamecon.c: at least one device must be specified\n"); 546 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type);
547 return NULL; 547 return -EINVAL;
548 } 548 }
549 549
550 pp = parport_find_number(config[0]); 550 gc->dev[idx] = input_dev = input_allocate_device();
551 551 if (!input_dev) {
552 if (!pp) { 552 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n");
553 printk(KERN_ERR "gamecon.c: no such parport\n"); 553 return -ENOMEM;
554 return NULL;
555 } 554 }
556 555
557 if (!(gc = kzalloc(sizeof(struct gc), GFP_KERNEL))) { 556 input_dev->name = gc_names[pad_type];
558 parport_put_port(pp); 557 input_dev->phys = gc->phys[idx];
559 return NULL; 558 input_dev->id.bustype = BUS_PARPORT;
559 input_dev->id.vendor = 0x0001;
560 input_dev->id.product = pad_type;
561 input_dev->id.version = 0x0100;
562 input_dev->private = gc;
563
564 input_dev->open = gc_open;
565 input_dev->close = gc_close;
566
567 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
568
569 for (i = 0; i < 2; i++)
570 input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0);
571
572 gc->pads[0] |= gc_status_bit[idx];
573 gc->pads[pad_type] |= gc_status_bit[idx];
574
575 switch (pad_type) {
576
577 case GC_N64:
578 for (i = 0; i < 10; i++)
579 set_bit(gc_n64_btn[i], input_dev->keybit);
580
581 for (i = 0; i < 2; i++) {
582 input_set_abs_params(input_dev, ABS_X + i, -127, 126, 0, 2);
583 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0);
584 }
585
586 break;
587
588 case GC_SNES:
589 for (i = 4; i < 8; i++)
590 set_bit(gc_snes_btn[i], input_dev->keybit);
591 case GC_NES:
592 for (i = 0; i < 4; i++)
593 set_bit(gc_snes_btn[i], input_dev->keybit);
594 break;
595
596 case GC_MULTI2:
597 set_bit(BTN_THUMB, input_dev->keybit);
598 case GC_MULTI:
599 set_bit(BTN_TRIGGER, input_dev->keybit);
600 break;
601
602 case GC_PSX:
603 for (i = 0; i < 6; i++)
604 input_set_abs_params(input_dev, gc_psx_abs[i], 4, 252, 0, 2);
605 for (i = 0; i < 12; i++)
606 set_bit(gc_psx_btn[i], input_dev->keybit);
607
608 break;
609
610 case GC_DDR:
611 for (i = 0; i < 4; i++)
612 set_bit(gc_psx_ddr_btn[i], input_dev->keybit);
613 for (i = 0; i < 12; i++)
614 set_bit(gc_psx_btn[i], input_dev->keybit);
615
616 break;
560 } 617 }
561 618
562 init_MUTEX(&gc->sem); 619 return 0;
620}
563 621
564 gc->pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 622static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
623{
624 struct gc *gc;
625 struct parport *pp;
626 struct pardevice *pd;
627 int i;
628 int err;
565 629
566 parport_put_port(pp); 630 pp = parport_find_number(parport);
631 if (!pp) {
632 printk(KERN_ERR "gamecon.c: no such parport\n");
633 err = -EINVAL;
634 goto err_out;
635 }
567 636
568 if (!gc->pd) { 637 pd = parport_register_device(pp, "gamecon", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
638 if (!pd) {
569 printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n"); 639 printk(KERN_ERR "gamecon.c: parport busy already - lp.o loaded?\n");
570 kfree(gc); 640 err = -EBUSY;
571 return NULL; 641 goto err_put_pp;
572 } 642 }
573 643
574 parport_claim(gc->pd); 644 gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
645 if (!gc) {
646 printk(KERN_ERR "gamecon.c: Not enough memory\n");
647 err = -ENOMEM;
648 goto err_unreg_pardev;
649 }
575 650
651 init_MUTEX(&gc->sem);
652 gc->pd = pd;
576 init_timer(&gc->timer); 653 init_timer(&gc->timer);
577 gc->timer.data = (long) gc; 654 gc->timer.data = (long) gc;
578 gc->timer.function = gc_timer; 655 gc->timer.function = gc_timer;
579 656
580 for (i = 0; i < nargs - 1; i++) { 657 for (i = 0; i < n_pads; i++) {
581 658 if (!pads[i])
582 if (!config[i + 1])
583 continue; 659 continue;
584 660
585 if (config[i + 1] < 1 || config[i + 1] > GC_MAX) { 661 sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i);
586 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", config[i + 1]); 662 err = gc_setup_pad(gc, i, pads[i]);
587 continue; 663 if (err)
588 } 664 goto err_free_devs;
589
590 gc->dev[i].private = gc;
591 gc->dev[i].open = gc_open;
592 gc->dev[i].close = gc_close;
593 665
594 gc->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 666 input_register_device(gc->dev[i]);
667 }
595 668
596 for (j = 0; j < 2; j++) { 669 if (!gc->pads[0]) {
597 set_bit(ABS_X + j, gc->dev[i].absbit); 670 printk(KERN_ERR "gamecon.c: No valid devices specified\n");
598 gc->dev[i].absmin[ABS_X + j] = -1; 671 err = -EINVAL;
599 gc->dev[i].absmax[ABS_X + j] = 1; 672 goto err_free_gc;
600 } 673 }
601 674
602 gc->pads[0] |= gc_status_bit[i]; 675 parport_put_port(pp);
603 gc->pads[config[i + 1]] |= gc_status_bit[i]; 676 return gc;
604 677
605 switch(config[i + 1]) { 678 err_free_devs:
679 while (--i >= 0)
680 input_unregister_device(gc->dev[i]);
681 err_free_gc:
682 kfree(gc);
683 err_unreg_pardev:
684 parport_unregister_device(pd);
685 err_put_pp:
686 parport_put_port(pp);
687 err_out:
688 return ERR_PTR(err);
689}
606 690
607 case GC_N64: 691static void __exit gc_remove(struct gc *gc)
608 for (j = 0; j < 10; j++) 692{
609 set_bit(gc_n64_btn[j], gc->dev[i].keybit); 693 int i;
610
611 for (j = 0; j < 2; j++) {
612 set_bit(ABS_X + j, gc->dev[i].absbit);
613 gc->dev[i].absmin[ABS_X + j] = -127;
614 gc->dev[i].absmax[ABS_X + j] = 126;
615 gc->dev[i].absflat[ABS_X + j] = 2;
616 set_bit(ABS_HAT0X + j, gc->dev[i].absbit);
617 gc->dev[i].absmin[ABS_HAT0X + j] = -1;
618 gc->dev[i].absmax[ABS_HAT0X + j] = 1;
619 }
620 694
621 break; 695 for (i = 0; i < GC_MAX_DEVICES; i++)
696 if (gc->dev[i])
697 input_unregister_device(gc->dev[i]);
698 parport_unregister_device(gc->pd);
699 kfree(gc);
700}
622 701
623 case GC_SNES: 702static int __init gc_init(void)
624 for (j = 4; j < 8; j++) 703{
625 set_bit(gc_snes_btn[j], gc->dev[i].keybit); 704 int i;
626 case GC_NES: 705 int have_dev = 0;
627 for (j = 0; j < 4; j++) 706 int err = 0;
628 set_bit(gc_snes_btn[j], gc->dev[i].keybit);
629 break;
630
631 case GC_MULTI2:
632 set_bit(BTN_THUMB, gc->dev[i].keybit);
633 case GC_MULTI:
634 set_bit(BTN_TRIGGER, gc->dev[i].keybit);
635 break;
636
637 case GC_PSX:
638 case GC_DDR:
639 if(config[i + 1] == GC_DDR) {
640 for (j = 0; j < 4; j++)
641 set_bit(gc_psx_ddr_btn[j], gc->dev[i].keybit);
642 } else {
643 for (j = 0; j < 6; j++) {
644 set_bit(gc_psx_abs[j], gc->dev[i].absbit);
645 gc->dev[i].absmin[gc_psx_abs[j]] = 4;
646 gc->dev[i].absmax[gc_psx_abs[j]] = 252;
647 gc->dev[i].absflat[gc_psx_abs[j]] = 2;
648 }
649 }
650 707
651 for (j = 0; j < 12; j++) 708 for (i = 0; i < GC_MAX_PORTS; i++) {
652 set_bit(gc_psx_btn[j], gc->dev[i].keybit); 709 if (gc[i].nargs == 0 || gc[i].args[0] < 0)
710 continue;
653 711
654 break; 712 if (gc[i].nargs < 2) {
713 printk(KERN_ERR "gamecon.c: at least one device must be specified\n");
714 err = -EINVAL;
715 break;
655 } 716 }
656 717
657 sprintf(gc->phys[i], "%s/input%d", gc->pd->port->name, i); 718 gc_base[i] = gc_probe(gc[i].args[0], gc[i].args + 1, gc[i].nargs - 1);
719 if (IS_ERR(gc_base[i])) {
720 err = PTR_ERR(gc_base[i]);
721 break;
722 }
658 723
659 gc->dev[i].name = gc_names[config[i + 1]]; 724 have_dev = 1;
660 gc->dev[i].phys = gc->phys[i];
661 gc->dev[i].id.bustype = BUS_PARPORT;
662 gc->dev[i].id.vendor = 0x0001;
663 gc->dev[i].id.product = config[i + 1];
664 gc->dev[i].id.version = 0x0100;
665 } 725 }
666 726
667 parport_release(gc->pd); 727 if (err) {
668 728 while (--i >= 0)
669 if (!gc->pads[0]) { 729 gc_remove(gc_base[i]);
670 parport_unregister_device(gc->pd); 730 return err;
671 kfree(gc);
672 return NULL;
673 } 731 }
674 732
675 for (i = 0; i < 5; i++) 733 return have_dev ? 0 : -ENODEV;
676 if (gc->pads[0] & gc_status_bit[i]) {
677 input_register_device(gc->dev + i);
678 printk(KERN_INFO "input: %s on %s\n", gc->dev[i].name, gc->pd->port->name);
679 }
680
681 return gc;
682}
683
684static int __init gc_init(void)
685{
686 gc_base[0] = gc_probe(gc, gc_nargs);
687 gc_base[1] = gc_probe(gc_2, gc_nargs_2);
688 gc_base[2] = gc_probe(gc_3, gc_nargs_3);
689
690 if (gc_base[0] || gc_base[1] || gc_base[2])
691 return 0;
692
693 return -ENODEV;
694} 734}
695 735
696static void __exit gc_exit(void) 736static void __exit gc_exit(void)
697{ 737{
698 int i, j; 738 int i;
699 739
700 for (i = 0; i < 3; i++) 740 for (i = 0; i < GC_MAX_PORTS; i++)
701 if (gc_base[i]) { 741 if (gc_base[i])
702 for (j = 0; j < 5; j++) 742 gc_remove(gc_base[i]);
703 if (gc_base[i]->pads[0] & gc_status_bit[j])
704 input_unregister_device(gc_base[i]->dev + j);
705 parport_unregister_device(gc_base[i]->pd);
706 }
707} 743}
708 744
709module_init(gc_init); 745module_init(gc_init);
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index 8e4f92b115e6..e151f8c5bcb9 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -81,7 +81,7 @@ static short gf2k_seq_digital[] = { 590, 320, 860, 0 };
81 81
82struct gf2k { 82struct gf2k {
83 struct gameport *gameport; 83 struct gameport *gameport;
84 struct input_dev dev; 84 struct input_dev *dev;
85 int reads; 85 int reads;
86 int bads; 86 int bads;
87 unsigned char id; 87 unsigned char id;
@@ -175,7 +175,7 @@ static int gf2k_get_bits(unsigned char *buf, int pos, int num, int shift)
175 175
176static void gf2k_read(struct gf2k *gf2k, unsigned char *data) 176static void gf2k_read(struct gf2k *gf2k, unsigned char *data)
177{ 177{
178 struct input_dev *dev = &gf2k->dev; 178 struct input_dev *dev = gf2k->dev;
179 int i, t; 179 int i, t;
180 180
181 for (i = 0; i < 4 && i < gf2k_axes[gf2k->id]; i++) 181 for (i = 0; i < 4 && i < gf2k_axes[gf2k->id]; i++)
@@ -239,13 +239,19 @@ static void gf2k_close(struct input_dev *dev)
239static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) 239static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
240{ 240{
241 struct gf2k *gf2k; 241 struct gf2k *gf2k;
242 struct input_dev *input_dev;
242 unsigned char data[GF2K_LENGTH]; 243 unsigned char data[GF2K_LENGTH];
243 int i, err; 244 int i, err;
244 245
245 if (!(gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL))) 246 gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL);
246 return -ENOMEM; 247 input_dev = input_allocate_device();
248 if (!gf2k || !input_dev) {
249 err = -ENOMEM;
250 goto fail1;
251 }
247 252
248 gf2k->gameport = gameport; 253 gf2k->gameport = gameport;
254 gf2k->dev = input_dev;
249 255
250 gameport_set_drvdata(gameport, gf2k); 256 gameport_set_drvdata(gameport, gf2k);
251 257
@@ -295,53 +301,52 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
295 301
296 gf2k->length = gf2k_lens[gf2k->id]; 302 gf2k->length = gf2k_lens[gf2k->id];
297 303
298 init_input_dev(&gf2k->dev); 304 input_dev->name = gf2k_names[gf2k->id];
299 305 input_dev->phys = gf2k->phys;
300 gf2k->dev.private = gf2k; 306 input_dev->id.bustype = BUS_GAMEPORT;
301 gf2k->dev.open = gf2k_open; 307 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
302 gf2k->dev.close = gf2k_close; 308 input_dev->id.product = gf2k->id;
303 gf2k->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 309 input_dev->id.version = 0x0100;
310 input_dev->cdev.dev = &gameport->dev;
311 input_dev->private = gf2k;
304 312
305 gf2k->dev.name = gf2k_names[gf2k->id]; 313 input_dev->open = gf2k_open;
306 gf2k->dev.phys = gf2k->phys; 314 input_dev->close = gf2k_close;
307 gf2k->dev.id.bustype = BUS_GAMEPORT; 315 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
308 gf2k->dev.id.vendor = GAMEPORT_ID_VENDOR_GENIUS;
309 gf2k->dev.id.product = gf2k->id;
310 gf2k->dev.id.version = 0x0100;
311 316
312 for (i = 0; i < gf2k_axes[gf2k->id]; i++) 317 for (i = 0; i < gf2k_axes[gf2k->id]; i++)
313 set_bit(gf2k_abs[i], gf2k->dev.absbit); 318 set_bit(gf2k_abs[i], input_dev->absbit);
314 319
315 for (i = 0; i < gf2k_hats[gf2k->id]; i++) { 320 for (i = 0; i < gf2k_hats[gf2k->id]; i++) {
316 set_bit(ABS_HAT0X + i, gf2k->dev.absbit); 321 set_bit(ABS_HAT0X + i, input_dev->absbit);
317 gf2k->dev.absmin[ABS_HAT0X + i] = -1; 322 input_dev->absmin[ABS_HAT0X + i] = -1;
318 gf2k->dev.absmax[ABS_HAT0X + i] = 1; 323 input_dev->absmax[ABS_HAT0X + i] = 1;
319 } 324 }
320 325
321 for (i = 0; i < gf2k_joys[gf2k->id]; i++) 326 for (i = 0; i < gf2k_joys[gf2k->id]; i++)
322 set_bit(gf2k_btn_joy[i], gf2k->dev.keybit); 327 set_bit(gf2k_btn_joy[i], input_dev->keybit);
323 328
324 for (i = 0; i < gf2k_pads[gf2k->id]; i++) 329 for (i = 0; i < gf2k_pads[gf2k->id]; i++)
325 set_bit(gf2k_btn_pad[i], gf2k->dev.keybit); 330 set_bit(gf2k_btn_pad[i], input_dev->keybit);
326 331
327 gf2k_read_packet(gameport, gf2k->length, data); 332 gf2k_read_packet(gameport, gf2k->length, data);
328 gf2k_read(gf2k, data); 333 gf2k_read(gf2k, data);
329 334
330 for (i = 0; i < gf2k_axes[gf2k->id]; i++) { 335 for (i = 0; i < gf2k_axes[gf2k->id]; i++) {
331 gf2k->dev.absmax[gf2k_abs[i]] = (i < 2) ? gf2k->dev.abs[gf2k_abs[i]] * 2 - 32 : 336 input_dev->absmax[gf2k_abs[i]] = (i < 2) ? input_dev->abs[gf2k_abs[i]] * 2 - 32 :
332 gf2k->dev.abs[gf2k_abs[0]] + gf2k->dev.abs[gf2k_abs[1]] - 32; 337 input_dev->abs[gf2k_abs[0]] + input_dev->abs[gf2k_abs[1]] - 32;
333 gf2k->dev.absmin[gf2k_abs[i]] = 32; 338 input_dev->absmin[gf2k_abs[i]] = 32;
334 gf2k->dev.absfuzz[gf2k_abs[i]] = 8; 339 input_dev->absfuzz[gf2k_abs[i]] = 8;
335 gf2k->dev.absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; 340 input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0;
336 } 341 }
337 342
338 input_register_device(&gf2k->dev); 343 input_register_device(gf2k->dev);
339 printk(KERN_INFO "input: %s on %s\n", gf2k_names[gf2k->id], gameport->phys);
340 344
341 return 0; 345 return 0;
342 346
343fail2: gameport_close(gameport); 347 fail2: gameport_close(gameport);
344fail1: gameport_set_drvdata(gameport, NULL); 348 fail1: gameport_set_drvdata(gameport, NULL);
349 input_free_device(input_dev);
345 kfree(gf2k); 350 kfree(gf2k);
346 return err; 351 return err;
347} 352}
@@ -350,7 +355,7 @@ static void gf2k_disconnect(struct gameport *gameport)
350{ 355{
351 struct gf2k *gf2k = gameport_get_drvdata(gameport); 356 struct gf2k *gf2k = gameport_get_drvdata(gameport);
352 357
353 input_unregister_device(&gf2k->dev); 358 input_unregister_device(gf2k->dev);
354 gameport_close(gameport); 359 gameport_close(gameport);
355 gameport_set_drvdata(gameport, NULL); 360 gameport_set_drvdata(gameport, NULL);
356 kfree(gf2k); 361 kfree(gf2k);
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index 9d3f910dd568..e206bb56e53c 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -55,7 +55,7 @@ MODULE_LICENSE("GPL");
55 55
56struct grip { 56struct grip {
57 struct gameport *gameport; 57 struct gameport *gameport;
58 struct input_dev dev[2]; 58 struct input_dev *dev[2];
59 unsigned char mode[2]; 59 unsigned char mode[2];
60 int reads; 60 int reads;
61 int bads; 61 int bads;
@@ -190,7 +190,7 @@ static void grip_poll(struct gameport *gameport)
190 190
191 for (i = 0; i < 2; i++) { 191 for (i = 0; i < 2; i++) {
192 192
193 dev = grip->dev + i; 193 dev = grip->dev[i];
194 grip->reads++; 194 grip->reads++;
195 195
196 switch (grip->mode[i]) { 196 switch (grip->mode[i]) {
@@ -297,6 +297,7 @@ static void grip_close(struct input_dev *dev)
297static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) 297static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
298{ 298{
299 struct grip *grip; 299 struct grip *grip;
300 struct input_dev *input_dev;
300 unsigned int data[GRIP_LENGTH_XT]; 301 unsigned int data[GRIP_LENGTH_XT];
301 int i, j, t; 302 int i, j, t;
302 int err; 303 int err;
@@ -339,48 +340,56 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
339 gameport_set_poll_handler(gameport, grip_poll); 340 gameport_set_poll_handler(gameport, grip_poll);
340 gameport_set_poll_interval(gameport, 20); 341 gameport_set_poll_interval(gameport, 20);
341 342
342 for (i = 0; i < 2; i++) 343 for (i = 0; i < 2; i++) {
343 if (grip->mode[i]) { 344 if (!grip->mode[i])
345 continue;
344 346
345 sprintf(grip->phys[i], "%s/input%d", gameport->phys, i); 347 grip->dev[i] = input_dev = input_allocate_device();
348 if (!input_dev) {
349 err = -ENOMEM;
350 goto fail3;
351 }
346 352
347 grip->dev[i].private = grip; 353 sprintf(grip->phys[i], "%s/input%d", gameport->phys, i);
348 354
349 grip->dev[i].open = grip_open; 355 input_dev->name = grip_name[grip->mode[i]];
350 grip->dev[i].close = grip_close; 356 input_dev->phys = grip->phys[i];
357 input_dev->id.bustype = BUS_GAMEPORT;
358 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
359 input_dev->id.product = grip->mode[i];
360 input_dev->id.version = 0x0100;
361 input_dev->cdev.dev = &gameport->dev;
362 input_dev->private = grip;
351 363
352 grip->dev[i].name = grip_name[grip->mode[i]]; 364 input_dev->open = grip_open;
353 grip->dev[i].phys = grip->phys[i]; 365 input_dev->close = grip_close;
354 grip->dev[i].id.bustype = BUS_GAMEPORT;
355 grip->dev[i].id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
356 grip->dev[i].id.product = grip->mode[i];
357 grip->dev[i].id.version = 0x0100;
358 366
359 grip->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 367 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
360 368
361 for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) { 369 for (j = 0; (t = grip_abs[grip->mode[i]][j]) >= 0; j++) {
362 370
363 if (j < grip_cen[grip->mode[i]]) 371 if (j < grip_cen[grip->mode[i]])
364 input_set_abs_params(&grip->dev[i], t, 14, 52, 1, 2); 372 input_set_abs_params(input_dev, t, 14, 52, 1, 2);
365 else if (j < grip_anx[grip->mode[i]]) 373 else if (j < grip_anx[grip->mode[i]])
366 input_set_abs_params(&grip->dev[i], t, 3, 57, 1, 0); 374 input_set_abs_params(input_dev, t, 3, 57, 1, 0);
367 else 375 else
368 input_set_abs_params(&grip->dev[i], t, -1, 1, 0, 0); 376 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
369 } 377 }
370 378
371 for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++) 379 for (j = 0; (t = grip_btn[grip->mode[i]][j]) >= 0; j++)
372 if (t > 0) 380 if (t > 0)
373 set_bit(t, grip->dev[i].keybit); 381 set_bit(t, input_dev->keybit);
374 382
375 printk(KERN_INFO "input: %s on %s\n", 383 input_register_device(grip->dev[i]);
376 grip_name[grip->mode[i]], gameport->phys); 384 }
377 input_register_device(grip->dev + i);
378 }
379 385
380 return 0; 386 return 0;
381 387
382fail2: gameport_close(gameport); 388 fail3: for (i = 0; i < 2; i++)
383fail1: gameport_set_drvdata(gameport, NULL); 389 if (grip->dev[i])
390 input_unregister_device(grip->dev[i]);
391 fail2: gameport_close(gameport);
392 fail1: gameport_set_drvdata(gameport, NULL);
384 kfree(grip); 393 kfree(grip);
385 return err; 394 return err;
386} 395}
@@ -391,8 +400,8 @@ static void grip_disconnect(struct gameport *gameport)
391 int i; 400 int i;
392 401
393 for (i = 0; i < 2; i++) 402 for (i = 0; i < 2; i++)
394 if (grip->mode[i]) 403 if (grip->dev[i])
395 input_unregister_device(grip->dev + i); 404 input_unregister_device(grip->dev[i]);
396 gameport_close(gameport); 405 gameport_close(gameport);
397 gameport_set_drvdata(gameport, NULL); 406 gameport_set_drvdata(gameport, NULL);
398 kfree(grip); 407 kfree(grip);
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index da17eee6f574..a0ba93ccac72 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -32,23 +32,37 @@ MODULE_LICENSE("GPL");
32#define dbg(format, arg...) do {} while (0) 32#define dbg(format, arg...) do {} while (0)
33#endif 33#endif
34 34
35#define GRIP_MAX_PORTS 4
35/* 36/*
36 * Grip multiport state 37 * Grip multiport state
37 */ 38 */
38 39
40struct grip_port {
41 struct input_dev *dev;
42 int mode;
43 int registered;
44
45 /* individual gamepad states */
46 int buttons;
47 int xaxes;
48 int yaxes;
49 int dirty; /* has the state been updated? */
50};
51
39struct grip_mp { 52struct grip_mp {
40 struct gameport *gameport; 53 struct gameport *gameport;
41 struct input_dev dev[4]; 54 struct grip_port *port[GRIP_MAX_PORTS];
42 int mode[4]; 55// struct input_dev *dev[4];
43 int registered[4]; 56// int mode[4];
57// int registered[4];
44 int reads; 58 int reads;
45 int bads; 59 int bads;
46 60
47 /* individual gamepad states */ 61 /* individual gamepad states */
48 int buttons[4]; 62// int buttons[4];
49 int xaxes[4]; 63// int xaxes[4];
50 int yaxes[4]; 64// int yaxes[4];
51 int dirty[4]; /* has the state been updated? */ 65// int dirty[4]; /* has the state been updated? */
52}; 66};
53 67
54/* 68/*
@@ -85,16 +99,16 @@ struct grip_mp {
85#define GRIP_MODE_GP 2 99#define GRIP_MODE_GP 2
86#define GRIP_MODE_C64 3 100#define GRIP_MODE_C64 3
87 101
88static int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 }; 102static const int grip_btn_gp[] = { BTN_TR, BTN_TL, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, -1 };
89static int grip_btn_c64[] = { BTN_JOYSTICK, -1 }; 103static const int grip_btn_c64[] = { BTN_JOYSTICK, -1 };
90 104
91static int grip_abs_gp[] = { ABS_X, ABS_Y, -1 }; 105static const int grip_abs_gp[] = { ABS_X, ABS_Y, -1 };
92static int grip_abs_c64[] = { ABS_X, ABS_Y, -1 }; 106static const int grip_abs_c64[] = { ABS_X, ABS_Y, -1 };
93 107
94static int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 }; 108static const int *grip_abs[] = { NULL, NULL, grip_abs_gp, grip_abs_c64 };
95static int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 }; 109static const int *grip_btn[] = { NULL, NULL, grip_btn_gp, grip_btn_c64 };
96 110
97static char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" }; 111static const char *grip_name[] = { NULL, NULL, "Gravis Grip Pad", "Commodore 64 Joystick" };
98 112
99static const int init_seq[] = { 113static const int init_seq[] = {
100 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 114 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
@@ -104,9 +118,9 @@ static const int init_seq[] = {
104 118
105/* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */ 119/* Maps multiport directional values to X,Y axis values (each axis encoded in 3 bits) */
106 120
107static int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 }; 121static const int axis_map[] = { 5, 9, 1, 5, 6, 10, 2, 6, 4, 8, 0, 4, 5, 9, 1, 5 };
108 122
109static void register_slot(int i, struct grip_mp *grip); 123static int register_slot(int i, struct grip_mp *grip);
110 124
111/* 125/*
112 * Returns whether an odd or even number of bits are on in pkt. 126 * Returns whether an odd or even number of bits are on in pkt.
@@ -353,9 +367,10 @@ static int dig_mode_start(struct gameport *gameport, u32 *packet)
353 367
354static int get_and_decode_packet(struct grip_mp *grip, int flags) 368static int get_and_decode_packet(struct grip_mp *grip, int flags)
355{ 369{
370 struct grip_port *port;
356 u32 packet; 371 u32 packet;
357 int joytype = 0; 372 int joytype = 0;
358 int slot = 0; 373 int slot;
359 374
360 /* Get a packet and check for validity */ 375 /* Get a packet and check for validity */
361 376
@@ -377,6 +392,8 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
377 if ((slot < 0) || (slot > 3)) 392 if ((slot < 0) || (slot > 3))
378 return flags; 393 return flags;
379 394
395 port = grip->port[slot];
396
380 /* 397 /*
381 * Handle "reset" packets, which occur at startup, and when gamepads 398 * Handle "reset" packets, which occur at startup, and when gamepads
382 * are removed or plugged in. May contain configuration of a new gamepad. 399 * are removed or plugged in. May contain configuration of a new gamepad.
@@ -385,14 +402,14 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
385 joytype = (packet >> 16) & 0x1f; 402 joytype = (packet >> 16) & 0x1f;
386 if (!joytype) { 403 if (!joytype) {
387 404
388 if (grip->registered[slot]) { 405 if (port->registered) {
389 printk(KERN_INFO "grip_mp: removing %s, slot %d\n", 406 printk(KERN_INFO "grip_mp: removing %s, slot %d\n",
390 grip_name[grip->mode[slot]], slot); 407 grip_name[port->mode], slot);
391 input_unregister_device(grip->dev + slot); 408 input_unregister_device(port->dev);
392 grip->registered[slot] = 0; 409 port->registered = 0;
393 } 410 }
394 dbg("Reset: grip multiport slot %d\n", slot); 411 dbg("Reset: grip multiport slot %d\n", slot);
395 grip->mode[slot] = GRIP_MODE_RESET; 412 port->mode = GRIP_MODE_RESET;
396 flags |= IO_SLOT_CHANGE; 413 flags |= IO_SLOT_CHANGE;
397 return flags; 414 return flags;
398 } 415 }
@@ -402,17 +419,17 @@ static int get_and_decode_packet(struct grip_mp *grip, int flags)
402 if (joytype == 0x1f) { 419 if (joytype == 0x1f) {
403 420
404 int dir = (packet >> 8) & 0xf; /* eight way directional value */ 421 int dir = (packet >> 8) & 0xf; /* eight way directional value */
405 grip->buttons[slot] = (~packet) & 0xff; 422 port->buttons = (~packet) & 0xff;
406 grip->yaxes[slot] = ((axis_map[dir] >> 2) & 3) - 1; 423 port->yaxes = ((axis_map[dir] >> 2) & 3) - 1;
407 grip->xaxes[slot] = (axis_map[dir] & 3) - 1; 424 port->xaxes = (axis_map[dir] & 3) - 1;
408 grip->dirty[slot] = 1; 425 port->dirty = 1;
409 426
410 if (grip->mode[slot] == GRIP_MODE_RESET) 427 if (port->mode == GRIP_MODE_RESET)
411 flags |= IO_SLOT_CHANGE; 428 flags |= IO_SLOT_CHANGE;
412 429
413 grip->mode[slot] = GRIP_MODE_GP; 430 port->mode = GRIP_MODE_GP;
414 431
415 if (!grip->registered[slot]) { 432 if (!port->registered) {
416 dbg("New Grip pad in multiport slot %d.\n", slot); 433 dbg("New Grip pad in multiport slot %d.\n", slot);
417 register_slot(slot, grip); 434 register_slot(slot, grip);
418 } 435 }
@@ -445,9 +462,9 @@ static int slots_valid(struct grip_mp *grip)
445 return 0; 462 return 0;
446 463
447 for (slot = 0; slot < 4; slot++) { 464 for (slot = 0; slot < 4; slot++) {
448 if (grip->mode[slot] == GRIP_MODE_RESET) 465 if (grip->port[slot]->mode == GRIP_MODE_RESET)
449 invalid = 1; 466 invalid = 1;
450 if (grip->mode[slot] != GRIP_MODE_NONE) 467 if (grip->port[slot]->mode != GRIP_MODE_NONE)
451 active = 1; 468 active = 1;
452 } 469 }
453 470
@@ -484,7 +501,7 @@ static int multiport_init(struct grip_mp *grip)
484 501
485 /* Get packets, store multiport state, and check state's validity */ 502 /* Get packets, store multiport state, and check state's validity */
486 for (tries = 0; tries < 4096; tries++) { 503 for (tries = 0; tries < 4096; tries++) {
487 if ( slots_valid(grip) ) { 504 if (slots_valid(grip)) {
488 initialized = 1; 505 initialized = 1;
489 break; 506 break;
490 } 507 }
@@ -499,24 +516,24 @@ static int multiport_init(struct grip_mp *grip)
499 516
500static void report_slot(struct grip_mp *grip, int slot) 517static void report_slot(struct grip_mp *grip, int slot)
501{ 518{
502 struct input_dev *dev = &(grip->dev[slot]); 519 struct grip_port *port = grip->port[slot];
503 int i, buttons = grip->buttons[slot]; 520 int i;
504 521
505 /* Store button states with linux input driver */ 522 /* Store button states with linux input driver */
506 523
507 for (i = 0; i < 8; i++) 524 for (i = 0; i < 8; i++)
508 input_report_key(dev, grip_btn_gp[i], (buttons >> i) & 1); 525 input_report_key(port->dev, grip_btn_gp[i], (port->buttons >> i) & 1);
509 526
510 /* Store axis states with linux driver */ 527 /* Store axis states with linux driver */
511 528
512 input_report_abs(dev, ABS_X, grip->xaxes[slot]); 529 input_report_abs(port->dev, ABS_X, port->xaxes);
513 input_report_abs(dev, ABS_Y, grip->yaxes[slot]); 530 input_report_abs(port->dev, ABS_Y, port->yaxes);
514 531
515 /* Tell the receiver of the events to process them */ 532 /* Tell the receiver of the events to process them */
516 533
517 input_sync(dev); 534 input_sync(port->dev);
518 535
519 grip->dirty[slot] = 0; 536 port->dirty = 0;
520} 537}
521 538
522/* 539/*
@@ -540,7 +557,7 @@ static void grip_poll(struct gameport *gameport)
540 } 557 }
541 558
542 for (i = 0; i < 4; i++) 559 for (i = 0; i < 4; i++)
543 if (grip->dirty[i]) 560 if (grip->port[i]->dirty)
544 report_slot(grip, i); 561 report_slot(grip, i);
545} 562}
546 563
@@ -571,35 +588,43 @@ static void grip_close(struct input_dev *dev)
571 * Tell the linux input layer about a newly plugged-in gamepad. 588 * Tell the linux input layer about a newly plugged-in gamepad.
572 */ 589 */
573 590
574static void register_slot(int slot, struct grip_mp *grip) 591static int register_slot(int slot, struct grip_mp *grip)
575{ 592{
593 struct grip_port *port = grip->port[slot];
594 struct input_dev *input_dev;
576 int j, t; 595 int j, t;
577 596
578 grip->dev[slot].private = grip; 597 port->dev = input_dev = input_allocate_device();
579 grip->dev[slot].open = grip_open; 598 if (!input_dev)
580 grip->dev[slot].close = grip_close; 599 return -ENOMEM;
581 grip->dev[slot].name = grip_name[grip->mode[slot]]; 600
582 grip->dev[slot].id.bustype = BUS_GAMEPORT; 601 input_dev->name = grip_name[port->mode];
583 grip->dev[slot].id.vendor = GAMEPORT_ID_VENDOR_GRAVIS; 602 input_dev->id.bustype = BUS_GAMEPORT;
584 grip->dev[slot].id.product = 0x0100 + grip->mode[slot]; 603 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GRAVIS;
585 grip->dev[slot].id.version = 0x0100; 604 input_dev->id.product = 0x0100 + port->mode;
586 grip->dev[slot].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 605 input_dev->id.version = 0x0100;
606 input_dev->cdev.dev = &grip->gameport->dev;
607 input_dev->private = grip;
608
609 input_dev->open = grip_open;
610 input_dev->close = grip_close;
587 611
588 for (j = 0; (t = grip_abs[grip->mode[slot]][j]) >= 0; j++) 612 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
589 input_set_abs_params(&grip->dev[slot], t, -1, 1, 0, 0);
590 613
591 for (j = 0; (t = grip_btn[grip->mode[slot]][j]) >= 0; j++) 614 for (j = 0; (t = grip_abs[port->mode][j]) >= 0; j++)
615 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
616
617 for (j = 0; (t = grip_btn[port->mode][j]) >= 0; j++)
592 if (t > 0) 618 if (t > 0)
593 set_bit(t, grip->dev[slot].keybit); 619 set_bit(t, input_dev->keybit);
594 620
595 input_register_device(grip->dev + slot); 621 input_register_device(port->dev);
596 grip->registered[slot] = 1; 622 port->registered = 1;
597 623
598 if (grip->dirty[slot]) /* report initial state, if any */ 624 if (port->dirty) /* report initial state, if any */
599 report_slot(grip, slot); 625 report_slot(grip, slot);
600 626
601 printk(KERN_INFO "grip_mp: added %s, slot %d\n", 627 return 0;
602 grip_name[grip->mode[slot]], slot);
603} 628}
604 629
605static int grip_connect(struct gameport *gameport, struct gameport_driver *drv) 630static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
@@ -626,7 +651,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
626 goto fail2; 651 goto fail2;
627 } 652 }
628 653
629 if (!grip->mode[0] && !grip->mode[1] && !grip->mode[2] && !grip->mode[3]) { 654 if (!grip->port[0]->mode && !grip->port[1]->mode && !grip->port[2]->mode && !grip->port[3]->mode) {
630 /* nothing plugged in */ 655 /* nothing plugged in */
631 err = -ENODEV; 656 err = -ENODEV;
632 goto fail2; 657 goto fail2;
@@ -646,8 +671,8 @@ static void grip_disconnect(struct gameport *gameport)
646 int i; 671 int i;
647 672
648 for (i = 0; i < 4; i++) 673 for (i = 0; i < 4; i++)
649 if (grip->registered[i]) 674 if (grip->port[i]->registered)
650 input_unregister_device(grip->dev + i); 675 input_unregister_device(grip->port[i]->dev);
651 gameport_close(gameport); 676 gameport_close(gameport);
652 gameport_set_drvdata(gameport, NULL); 677 gameport_set_drvdata(gameport, NULL);
653 kfree(grip); 678 kfree(grip);
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 6a70ec429f06..c528473c09d8 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -67,7 +67,7 @@ struct guillemot_type {
67 67
68struct guillemot { 68struct guillemot {
69 struct gameport *gameport; 69 struct gameport *gameport;
70 struct input_dev dev; 70 struct input_dev *dev;
71 int bads; 71 int bads;
72 int reads; 72 int reads;
73 struct guillemot_type *type; 73 struct guillemot_type *type;
@@ -123,7 +123,7 @@ static int guillemot_read_packet(struct gameport *gameport, u8 *data)
123static void guillemot_poll(struct gameport *gameport) 123static void guillemot_poll(struct gameport *gameport)
124{ 124{
125 struct guillemot *guillemot = gameport_get_drvdata(gameport); 125 struct guillemot *guillemot = gameport_get_drvdata(gameport);
126 struct input_dev *dev = &guillemot->dev; 126 struct input_dev *dev = guillemot->dev;
127 u8 data[GUILLEMOT_MAX_LENGTH]; 127 u8 data[GUILLEMOT_MAX_LENGTH];
128 int i; 128 int i;
129 129
@@ -179,14 +179,20 @@ static void guillemot_close(struct input_dev *dev)
179static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv) 179static int guillemot_connect(struct gameport *gameport, struct gameport_driver *drv)
180{ 180{
181 struct guillemot *guillemot; 181 struct guillemot *guillemot;
182 struct input_dev *input_dev;
182 u8 data[GUILLEMOT_MAX_LENGTH]; 183 u8 data[GUILLEMOT_MAX_LENGTH];
183 int i, t; 184 int i, t;
184 int err; 185 int err;
185 186
186 if (!(guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL))) 187 guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL);
187 return -ENOMEM; 188 input_dev = input_allocate_device();
189 if (!guillemot || !input_dev) {
190 err = -ENOMEM;
191 goto fail1;
192 }
188 193
189 guillemot->gameport = gameport; 194 guillemot->gameport = gameport;
195 guillemot->dev = input_dev;
190 196
191 gameport_set_drvdata(gameport, guillemot); 197 gameport_set_drvdata(gameport, guillemot);
192 198
@@ -216,41 +222,40 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
216 gameport_set_poll_interval(gameport, 20); 222 gameport_set_poll_interval(gameport, 20);
217 223
218 sprintf(guillemot->phys, "%s/input0", gameport->phys); 224 sprintf(guillemot->phys, "%s/input0", gameport->phys);
219
220 guillemot->type = guillemot_type + i; 225 guillemot->type = guillemot_type + i;
221 226
222 guillemot->dev.private = guillemot; 227 input_dev->name = guillemot_type[i].name;
223 guillemot->dev.open = guillemot_open; 228 input_dev->phys = guillemot->phys;
224 guillemot->dev.close = guillemot_close; 229 input_dev->id.bustype = BUS_GAMEPORT;
230 input_dev->id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
231 input_dev->id.product = guillemot_type[i].id;
232 input_dev->id.version = (int)data[14] << 8 | data[15];
233 input_dev->cdev.dev = &gameport->dev;
234 input_dev->private = guillemot;
225 235
226 guillemot->dev.name = guillemot_type[i].name; 236 input_dev->open = guillemot_open;
227 guillemot->dev.phys = guillemot->phys; 237 input_dev->close = guillemot_close;
228 guillemot->dev.id.bustype = BUS_GAMEPORT;
229 guillemot->dev.id.vendor = GAMEPORT_ID_VENDOR_GUILLEMOT;
230 guillemot->dev.id.product = guillemot_type[i].id;
231 guillemot->dev.id.version = (int)data[14] << 8 | data[15];
232 238
233 guillemot->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 239 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
234 240
235 for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++) 241 for (i = 0; (t = guillemot->type->abs[i]) >= 0; i++)
236 input_set_abs_params(&guillemot->dev, t, 0, 255, 0, 0); 242 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
237 243
238 if (guillemot->type->hat) { 244 if (guillemot->type->hat) {
239 input_set_abs_params(&guillemot->dev, ABS_HAT0X, -1, 1, 0, 0); 245 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
240 input_set_abs_params(&guillemot->dev, ABS_HAT0Y, -1, 1, 0, 0); 246 input_set_abs_params(input_dev, ABS_HAT0Y, -1, 1, 0, 0);
241 } 247 }
242 248
243 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++) 249 for (i = 0; (t = guillemot->type->btn[i]) >= 0; i++)
244 set_bit(t, guillemot->dev.keybit); 250 set_bit(t, input_dev->keybit);
245 251
246 input_register_device(&guillemot->dev); 252 input_register_device(guillemot->dev);
247 printk(KERN_INFO "input: %s ver %d.%02d on %s\n",
248 guillemot->type->name, data[14], data[15], gameport->phys);
249 253
250 return 0; 254 return 0;
251 255
252fail2: gameport_close(gameport); 256fail2: gameport_close(gameport);
253fail1: gameport_set_drvdata(gameport, NULL); 257fail1: gameport_set_drvdata(gameport, NULL);
258 input_free_device(input_dev);
254 kfree(guillemot); 259 kfree(guillemot);
255 return err; 260 return err;
256} 261}
@@ -260,7 +265,7 @@ static void guillemot_disconnect(struct gameport *gameport)
260 struct guillemot *guillemot = gameport_get_drvdata(gameport); 265 struct guillemot *guillemot = gameport_get_drvdata(gameport);
261 266
262 printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys); 267 printk(KERN_INFO "guillemot.c: Failed %d reads out of %d on %s\n", guillemot->reads, guillemot->bads, guillemot->phys);
263 input_unregister_device(&guillemot->dev); 268 input_unregister_device(guillemot->dev);
264 gameport_close(gameport); 269 gameport_close(gameport);
265 kfree(guillemot); 270 kfree(guillemot);
266} 271}
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index e31b7b93fde2..64b9c31c47fc 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -144,7 +144,7 @@ static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect)
144 int is_update; 144 int is_update;
145 145
146/* Check this effect type is supported by this device */ 146/* Check this effect type is supported by this device */
147 if (!test_bit(effect->type, iforce->dev.ffbit)) 147 if (!test_bit(effect->type, iforce->dev->ffbit))
148 return -EINVAL; 148 return -EINVAL;
149 149
150/* 150/*
@@ -152,30 +152,31 @@ static int iforce_upload_effect(struct input_dev *dev, struct ff_effect *effect)
152 */ 152 */
153 if (effect->id == -1) { 153 if (effect->id == -1) {
154 154
155 for (id=0; id < FF_EFFECTS_MAX; ++id) 155 for (id = 0; id < FF_EFFECTS_MAX; ++id)
156 if (!test_and_set_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags)) break; 156 if (!test_and_set_bit(FF_CORE_IS_USED, iforce->core_effects[id].flags))
157 break;
157 158
158 if ( id == FF_EFFECTS_MAX || id >= iforce->dev.ff_effects_max) 159 if (id == FF_EFFECTS_MAX || id >= iforce->dev->ff_effects_max)
159 return -ENOMEM; 160 return -ENOMEM;
160 161
161 effect->id = id; 162 effect->id = id;
162 iforce->core_effects[id].owner = current->pid; 163 iforce->core_effects[id].owner = current->pid;
163 iforce->core_effects[id].flags[0] = (1<<FF_CORE_IS_USED); /* Only IS_USED bit must be set */ 164 iforce->core_effects[id].flags[0] = (1 << FF_CORE_IS_USED); /* Only IS_USED bit must be set */
164 165
165 is_update = FALSE; 166 is_update = FALSE;
166 } 167 }
167 else { 168 else {
168 /* We want to update an effect */ 169 /* We want to update an effect */
169 if (!CHECK_OWNERSHIP(effect->id, iforce)) return -EACCES; 170 if (!CHECK_OWNERSHIP(effect->id, iforce))
171 return -EACCES;
170 172
171 /* Parameter type cannot be updated */ 173 /* Parameter type cannot be updated */
172 if (effect->type != iforce->core_effects[effect->id].effect.type) 174 if (effect->type != iforce->core_effects[effect->id].effect.type)
173 return -EINVAL; 175 return -EINVAL;
174 176
175 /* Check the effect is not already being updated */ 177 /* Check the effect is not already being updated */
176 if (test_bit(FF_CORE_UPDATE, iforce->core_effects[effect->id].flags)) { 178 if (test_bit(FF_CORE_UPDATE, iforce->core_effects[effect->id].flags))
177 return -EAGAIN; 179 return -EAGAIN;
178 }
179 180
180 is_update = TRUE; 181 is_update = TRUE;
181 } 182 }
@@ -339,15 +340,19 @@ void iforce_delete_device(struct iforce *iforce)
339 340
340int iforce_init_device(struct iforce *iforce) 341int iforce_init_device(struct iforce *iforce)
341{ 342{
343 struct input_dev *input_dev;
342 unsigned char c[] = "CEOV"; 344 unsigned char c[] = "CEOV";
343 int i; 345 int i;
344 346
347 input_dev = input_allocate_device();
348 if (input_dev)
349 return -ENOMEM;
350
345 init_waitqueue_head(&iforce->wait); 351 init_waitqueue_head(&iforce->wait);
346 spin_lock_init(&iforce->xmit_lock); 352 spin_lock_init(&iforce->xmit_lock);
347 init_MUTEX(&iforce->mem_mutex); 353 init_MUTEX(&iforce->mem_mutex);
348 iforce->xmit.buf = iforce->xmit_data; 354 iforce->xmit.buf = iforce->xmit_data;
349 355 iforce->dev = input_dev;
350 iforce->dev.ff_effects_max = 10;
351 356
352/* 357/*
353 * Input device fields. 358 * Input device fields.
@@ -356,26 +361,27 @@ int iforce_init_device(struct iforce *iforce)
356 switch (iforce->bus) { 361 switch (iforce->bus) {
357#ifdef CONFIG_JOYSTICK_IFORCE_USB 362#ifdef CONFIG_JOYSTICK_IFORCE_USB
358 case IFORCE_USB: 363 case IFORCE_USB:
359 iforce->dev.id.bustype = BUS_USB; 364 input_dev->id.bustype = BUS_USB;
360 iforce->dev.dev = &iforce->usbdev->dev; 365 input_dev->cdev.dev = &iforce->usbdev->dev;
361 break; 366 break;
362#endif 367#endif
363#ifdef CONFIG_JOYSTICK_IFORCE_232 368#ifdef CONFIG_JOYSTICK_IFORCE_232
364 case IFORCE_232: 369 case IFORCE_232:
365 iforce->dev.id.bustype = BUS_RS232; 370 input_dev->id.bustype = BUS_RS232;
366 iforce->dev.dev = &iforce->serio->dev; 371 input_dev->cdev.dev = &iforce->serio->dev;
367 break; 372 break;
368#endif 373#endif
369 } 374 }
370 375
371 iforce->dev.private = iforce; 376 input_dev->private = iforce;
372 iforce->dev.name = "Unknown I-Force device"; 377 input_dev->name = "Unknown I-Force device";
373 iforce->dev.open = iforce_open; 378 input_dev->open = iforce_open;
374 iforce->dev.close = iforce_release; 379 input_dev->close = iforce_release;
375 iforce->dev.flush = iforce_flush; 380 input_dev->flush = iforce_flush;
376 iforce->dev.event = iforce_input_event; 381 input_dev->event = iforce_input_event;
377 iforce->dev.upload_effect = iforce_upload_effect; 382 input_dev->upload_effect = iforce_upload_effect;
378 iforce->dev.erase_effect = iforce_erase_effect; 383 input_dev->erase_effect = iforce_erase_effect;
384 input_dev->ff_effects_max = 10;
379 385
380/* 386/*
381 * On-device memory allocation. 387 * On-device memory allocation.
@@ -399,7 +405,8 @@ int iforce_init_device(struct iforce *iforce)
399 405
400 if (i == 20) { /* 5 seconds */ 406 if (i == 20) { /* 5 seconds */
401 printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n"); 407 printk(KERN_ERR "iforce-main.c: Timeout waiting for response from device.\n");
402 return -1; 408 input_free_device(input_dev);
409 return -ENODEV;
403 } 410 }
404 411
405/* 412/*
@@ -407,12 +414,12 @@ int iforce_init_device(struct iforce *iforce)
407 */ 414 */
408 415
409 if (!iforce_get_id_packet(iforce, "M")) 416 if (!iforce_get_id_packet(iforce, "M"))
410 iforce->dev.id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; 417 input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1];
411 else 418 else
412 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n"); 419 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet M\n");
413 420
414 if (!iforce_get_id_packet(iforce, "P")) 421 if (!iforce_get_id_packet(iforce, "P"))
415 iforce->dev.id.product = (iforce->edata[2] << 8) | iforce->edata[1]; 422 input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1];
416 else 423 else
417 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n"); 424 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet P\n");
418 425
@@ -422,15 +429,15 @@ int iforce_init_device(struct iforce *iforce)
422 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n"); 429 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet B\n");
423 430
424 if (!iforce_get_id_packet(iforce, "N")) 431 if (!iforce_get_id_packet(iforce, "N"))
425 iforce->dev.ff_effects_max = iforce->edata[1]; 432 iforce->dev->ff_effects_max = iforce->edata[1];
426 else 433 else
427 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n"); 434 printk(KERN_WARNING "iforce-main.c: Device does not respond to id packet N\n");
428 435
429 /* Check if the device can store more effects than the driver can really handle */ 436 /* Check if the device can store more effects than the driver can really handle */
430 if (iforce->dev.ff_effects_max > FF_EFFECTS_MAX) { 437 if (iforce->dev->ff_effects_max > FF_EFFECTS_MAX) {
431 printk(KERN_WARNING "input??: Device can handle %d effects, but N_EFFECTS_MAX is set to %d in iforce.h\n", 438 printk(KERN_WARNING "input??: Device can handle %d effects, but N_EFFECTS_MAX is set to %d in iforce.h\n",
432 iforce->dev.ff_effects_max, FF_EFFECTS_MAX); 439 iforce->dev->ff_effects_max, FF_EFFECTS_MAX);
433 iforce->dev.ff_effects_max = FF_EFFECTS_MAX; 440 iforce->dev->ff_effects_max = FF_EFFECTS_MAX;
434 } 441 }
435 442
436/* 443/*
@@ -453,29 +460,28 @@ int iforce_init_device(struct iforce *iforce)
453 */ 460 */
454 461
455 for (i = 0; iforce_device[i].idvendor; i++) 462 for (i = 0; iforce_device[i].idvendor; i++)
456 if (iforce_device[i].idvendor == iforce->dev.id.vendor && 463 if (iforce_device[i].idvendor == input_dev->id.vendor &&
457 iforce_device[i].idproduct == iforce->dev.id.product) 464 iforce_device[i].idproduct == input_dev->id.product)
458 break; 465 break;
459 466
460 iforce->type = iforce_device + i; 467 iforce->type = iforce_device + i;
461 iforce->dev.name = iforce->type->name; 468 input_dev->name = iforce->type->name;
462 469
463/* 470/*
464 * Set input device bitfields and ranges. 471 * Set input device bitfields and ranges.
465 */ 472 */
466 473
467 iforce->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF) | BIT(EV_FF_STATUS); 474 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_FF) | BIT(EV_FF_STATUS);
468 475
469 for (i = 0; iforce->type->btn[i] >= 0; i++) { 476 for (i = 0; iforce->type->btn[i] >= 0; i++) {
470 signed short t = iforce->type->btn[i]; 477 signed short t = iforce->type->btn[i];
471 set_bit(t, iforce->dev.keybit); 478 set_bit(t, input_dev->keybit);
472 } 479 }
473 set_bit(BTN_DEAD, iforce->dev.keybit); 480 set_bit(BTN_DEAD, input_dev->keybit);
474 481
475 for (i = 0; iforce->type->abs[i] >= 0; i++) { 482 for (i = 0; iforce->type->abs[i] >= 0; i++) {
476 483
477 signed short t = iforce->type->abs[i]; 484 signed short t = iforce->type->abs[i];
478 set_bit(t, iforce->dev.absbit);
479 485
480 switch (t) { 486 switch (t) {
481 487
@@ -483,52 +489,42 @@ int iforce_init_device(struct iforce *iforce)
483 case ABS_Y: 489 case ABS_Y:
484 case ABS_WHEEL: 490 case ABS_WHEEL:
485 491
486 iforce->dev.absmax[t] = 1920; 492 input_set_abs_params(input_dev, t, -1920, 1920, 16, 128);
487 iforce->dev.absmin[t] = -1920; 493 set_bit(t, input_dev->ffbit);
488 iforce->dev.absflat[t] = 128;
489 iforce->dev.absfuzz[t] = 16;
490
491 set_bit(t, iforce->dev.ffbit);
492 break; 494 break;
493 495
494 case ABS_THROTTLE: 496 case ABS_THROTTLE:
495 case ABS_GAS: 497 case ABS_GAS:
496 case ABS_BRAKE: 498 case ABS_BRAKE:
497 499
498 iforce->dev.absmax[t] = 255; 500 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
499 iforce->dev.absmin[t] = 0;
500 break; 501 break;
501 502
502 case ABS_RUDDER: 503 case ABS_RUDDER:
503 504
504 iforce->dev.absmax[t] = 127; 505 input_set_abs_params(input_dev, t, -128, 127, 0, 0);
505 iforce->dev.absmin[t] = -128;
506 break; 506 break;
507 507
508 case ABS_HAT0X: 508 case ABS_HAT0X:
509 case ABS_HAT0Y: 509 case ABS_HAT0Y:
510 case ABS_HAT1X: 510 case ABS_HAT1X:
511 case ABS_HAT1Y: 511 case ABS_HAT1Y:
512 iforce->dev.absmax[t] = 1; 512
513 iforce->dev.absmin[t] = -1; 513 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
514 break; 514 break;
515 } 515 }
516 } 516 }
517 517
518 for (i = 0; iforce->type->ff[i] >= 0; i++) 518 for (i = 0; iforce->type->ff[i] >= 0; i++)
519 set_bit(iforce->type->ff[i], iforce->dev.ffbit); 519 set_bit(iforce->type->ff[i], input_dev->ffbit);
520 520
521/* 521/*
522 * Register input device. 522 * Register input device.
523 */ 523 */
524 524
525 input_register_device(&iforce->dev); 525 input_register_device(iforce->dev);
526
527 printk(KERN_DEBUG "iforce->dev.open = %p\n", iforce->dev.open);
528 526
529 printk(KERN_INFO "input: %s [%d effects, %ld bytes memory]\n", 527 printk(KERN_DEBUG "iforce->dev->open = %p\n", iforce->dev->open);
530 iforce->dev.name, iforce->dev.ff_effects_max,
531 iforce->device_memory.end);
532 528
533 return 0; 529 return 0;
534} 530}
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c
index e5a31e55d3e2..4a2629243e19 100644
--- a/drivers/input/joystick/iforce/iforce-packets.c
+++ b/drivers/input/joystick/iforce/iforce-packets.c
@@ -139,7 +139,8 @@ printk(KERN_DEBUG "iforce-packets.c: control_playback %d %d\n", id, value);
139static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) 139static int mark_core_as_ready(struct iforce *iforce, unsigned short addr)
140{ 140{
141 int i; 141 int i;
142 for (i=0; i<iforce->dev.ff_effects_max; ++i) { 142
143 for (i = 0; i < iforce->dev->ff_effects_max; ++i) {
143 if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags) && 144 if (test_bit(FF_CORE_IS_USED, iforce->core_effects[i].flags) &&
144 (iforce->core_effects[i].mod1_chunk.start == addr || 145 (iforce->core_effects[i].mod1_chunk.start == addr ||
145 iforce->core_effects[i].mod2_chunk.start == addr)) { 146 iforce->core_effects[i].mod2_chunk.start == addr)) {
@@ -153,7 +154,7 @@ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr)
153 154
154void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, struct pt_regs *regs) 155void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data, struct pt_regs *regs)
155{ 156{
156 struct input_dev *dev = &iforce->dev; 157 struct input_dev *dev = iforce->dev;
157 int i; 158 int i;
158 static int being_used = 0; 159 static int being_used = 0;
159 160
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index 11f51905cba7..64a78c515484 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -131,11 +131,10 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
131 struct iforce *iforce; 131 struct iforce *iforce;
132 int err; 132 int err;
133 133
134 if (!(iforce = kmalloc(sizeof(struct iforce), GFP_KERNEL))) 134 iforce = kzalloc(sizeof(struct iforce), GFP_KERNEL);
135 if (!iforce)
135 return -ENOMEM; 136 return -ENOMEM;
136 137
137 memset(iforce, 0, sizeof(struct iforce));
138
139 iforce->bus = IFORCE_232; 138 iforce->bus = IFORCE_232;
140 iforce->serio = serio; 139 iforce->serio = serio;
141 140
@@ -148,7 +147,8 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
148 return err; 147 return err;
149 } 148 }
150 149
151 if (iforce_init_device(iforce)) { 150 err = iforce_init_device(iforce);
151 if (err) {
152 serio_close(serio); 152 serio_close(serio);
153 serio_set_drvdata(serio, NULL); 153 serio_set_drvdata(serio, NULL);
154 kfree(iforce); 154 kfree(iforce);
@@ -162,7 +162,7 @@ static void iforce_serio_disconnect(struct serio *serio)
162{ 162{
163 struct iforce *iforce = serio_get_drvdata(serio); 163 struct iforce *iforce = serio_get_drvdata(serio);
164 164
165 input_unregister_device(&iforce->dev); 165 input_unregister_device(iforce->dev);
166 serio_close(serio); 166 serio_close(serio);
167 serio_set_drvdata(serio, NULL); 167 serio_set_drvdata(serio, NULL);
168 kfree(iforce); 168 kfree(iforce);
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 58600f91eff5..64b4a3080985 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -135,28 +135,24 @@ static int iforce_usb_probe(struct usb_interface *intf,
135 struct usb_host_interface *interface; 135 struct usb_host_interface *interface;
136 struct usb_endpoint_descriptor *epirq, *epout; 136 struct usb_endpoint_descriptor *epirq, *epout;
137 struct iforce *iforce; 137 struct iforce *iforce;
138 int err = -ENOMEM;
138 139
139 interface = intf->cur_altsetting; 140 interface = intf->cur_altsetting;
140 141
141 epirq = &interface->endpoint[0].desc; 142 epirq = &interface->endpoint[0].desc;
142 epout = &interface->endpoint[1].desc; 143 epout = &interface->endpoint[1].desc;
143 144
144 if (!(iforce = kmalloc(sizeof(struct iforce) + 32, GFP_KERNEL))) 145 if (!(iforce = kzalloc(sizeof(struct iforce) + 32, GFP_KERNEL)))
145 goto fail; 146 goto fail;
146 147
147 memset(iforce, 0, sizeof(struct iforce)); 148 if (!(iforce->irq = usb_alloc_urb(0, GFP_KERNEL)))
148
149 if (!(iforce->irq = usb_alloc_urb(0, GFP_KERNEL))) {
150 goto fail; 149 goto fail;
151 }
152 150
153 if (!(iforce->out = usb_alloc_urb(0, GFP_KERNEL))) { 151 if (!(iforce->out = usb_alloc_urb(0, GFP_KERNEL)))
154 goto fail; 152 goto fail;
155 }
156 153
157 if (!(iforce->ctrl = usb_alloc_urb(0, GFP_KERNEL))) { 154 if (!(iforce->ctrl = usb_alloc_urb(0, GFP_KERNEL)))
158 goto fail; 155 goto fail;
159 }
160 156
161 iforce->bus = IFORCE_USB; 157 iforce->bus = IFORCE_USB;
162 iforce->usbdev = dev; 158 iforce->usbdev = dev;
@@ -174,7 +170,9 @@ static int iforce_usb_probe(struct usb_interface *intf,
174 usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0), 170 usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0),
175 (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce); 171 (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce);
176 172
177 if (iforce_init_device(iforce)) goto fail; 173 err = iforce_init_device(iforce);
174 if (err)
175 goto fail;
178 176
179 usb_set_intfdata(intf, iforce); 177 usb_set_intfdata(intf, iforce);
180 return 0; 178 return 0;
@@ -187,7 +185,7 @@ fail:
187 kfree(iforce); 185 kfree(iforce);
188 } 186 }
189 187
190 return -ENODEV; 188 return err;
191} 189}
192 190
193/* Called by iforce_delete() */ 191/* Called by iforce_delete() */
@@ -211,7 +209,7 @@ static void iforce_usb_disconnect(struct usb_interface *intf)
211 usb_set_intfdata(intf, NULL); 209 usb_set_intfdata(intf, NULL);
212 if (iforce) { 210 if (iforce) {
213 iforce->usbdev = NULL; 211 iforce->usbdev = NULL;
214 input_unregister_device(&iforce->dev); 212 input_unregister_device(iforce->dev);
215 213
216 if (!open) { 214 if (!open) {
217 iforce_delete_device(iforce); 215 iforce_delete_device(iforce);
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index bce247bc300b..146f406b8f8a 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -117,7 +117,7 @@ struct iforce_device {
117}; 117};
118 118
119struct iforce { 119struct iforce {
120 struct input_dev dev; /* Input device interface */ 120 struct input_dev *dev; /* Input device interface */
121 struct iforce_device *type; 121 struct iforce_device *type;
122 int bus; 122 int bus;
123 123
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index d7b3472bd686..8511ee7bb263 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -54,7 +54,7 @@ MODULE_LICENSE("GPL");
54 54
55struct interact { 55struct interact {
56 struct gameport *gameport; 56 struct gameport *gameport;
57 struct input_dev dev; 57 struct input_dev *dev;
58 int bads; 58 int bads;
59 int reads; 59 int reads;
60 unsigned char type; 60 unsigned char type;
@@ -130,7 +130,7 @@ static int interact_read_packet(struct gameport *gameport, int length, u32 *data
130static void interact_poll(struct gameport *gameport) 130static void interact_poll(struct gameport *gameport)
131{ 131{
132 struct interact *interact = gameport_get_drvdata(gameport); 132 struct interact *interact = gameport_get_drvdata(gameport);
133 struct input_dev *dev = &interact->dev; 133 struct input_dev *dev = interact->dev;
134 u32 data[3]; 134 u32 data[3];
135 int i; 135 int i;
136 136
@@ -208,14 +208,20 @@ static void interact_close(struct input_dev *dev)
208static int interact_connect(struct gameport *gameport, struct gameport_driver *drv) 208static int interact_connect(struct gameport *gameport, struct gameport_driver *drv)
209{ 209{
210 struct interact *interact; 210 struct interact *interact;
211 struct input_dev *input_dev;
211 __u32 data[3]; 212 __u32 data[3];
212 int i, t; 213 int i, t;
213 int err; 214 int err;
214 215
215 if (!(interact = kzalloc(sizeof(struct interact), GFP_KERNEL))) 216 interact = kzalloc(sizeof(struct interact), GFP_KERNEL);
216 return -ENOMEM; 217 input_dev = input_allocate_device();
218 if (!interact || !input_dev) {
219 err = -ENOMEM;
220 goto fail1;
221 }
217 222
218 interact->gameport = gameport; 223 interact->gameport = gameport;
224 interact->dev = input_dev;
219 225
220 gameport_set_drvdata(gameport, interact); 226 gameport_set_drvdata(gameport, interact);
221 227
@@ -249,41 +255,40 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
249 interact->type = i; 255 interact->type = i;
250 interact->length = interact_type[i].length; 256 interact->length = interact_type[i].length;
251 257
252 interact->dev.private = interact; 258 input_dev->name = interact_type[i].name;
253 interact->dev.open = interact_open; 259 input_dev->phys = interact->phys;
254 interact->dev.close = interact_close; 260 input_dev->id.bustype = BUS_GAMEPORT;
261 input_dev->id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
262 input_dev->id.product = interact_type[i].id;
263 input_dev->id.version = 0x0100;
264 input_dev->private = interact;
255 265
256 interact->dev.name = interact_type[i].name; 266 input_dev->open = interact_open;
257 interact->dev.phys = interact->phys; 267 input_dev->close = interact_close;
258 interact->dev.id.bustype = BUS_GAMEPORT;
259 interact->dev.id.vendor = GAMEPORT_ID_VENDOR_INTERACT;
260 interact->dev.id.product = interact_type[i].id;
261 interact->dev.id.version = 0x0100;
262 268
263 interact->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 269 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
264 270
265 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { 271 for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) {
266 set_bit(t, interact->dev.absbit); 272 set_bit(t, input_dev->absbit);
267 if (i < interact_type[interact->type].b8) { 273 if (i < interact_type[interact->type].b8) {
268 interact->dev.absmin[t] = 0; 274 input_dev->absmin[t] = 0;
269 interact->dev.absmax[t] = 255; 275 input_dev->absmax[t] = 255;
270 } else { 276 } else {
271 interact->dev.absmin[t] = -1; 277 input_dev->absmin[t] = -1;
272 interact->dev.absmax[t] = 1; 278 input_dev->absmax[t] = 1;
273 } 279 }
274 } 280 }
275 281
276 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) 282 for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++)
277 set_bit(t, interact->dev.keybit); 283 set_bit(t, input_dev->keybit);
278 284
279 input_register_device(&interact->dev); 285 input_register_device(interact->dev);
280 printk(KERN_INFO "input: %s on %s\n",
281 interact_type[interact->type].name, gameport->phys);
282 286
283 return 0; 287 return 0;
284 288
285fail2: gameport_close(gameport); 289fail2: gameport_close(gameport);
286fail1: gameport_set_drvdata(gameport, NULL); 290fail1: gameport_set_drvdata(gameport, NULL);
291 input_free_device(input_dev);
287 kfree(interact); 292 kfree(interact);
288 return err; 293 return err;
289} 294}
@@ -292,7 +297,7 @@ static void interact_disconnect(struct gameport *gameport)
292{ 297{
293 struct interact *interact = gameport_get_drvdata(gameport); 298 struct interact *interact = gameport_get_drvdata(gameport);
294 299
295 input_unregister_device(&interact->dev); 300 input_unregister_device(interact->dev);
296 gameport_close(gameport); 301 gameport_close(gameport);
297 gameport_set_drvdata(gameport, NULL); 302 gameport_set_drvdata(gameport, NULL);
298 kfree(interact); 303 kfree(interact);
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 1ba503627242..ca3cc2319d6a 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -49,14 +49,13 @@ MODULE_LICENSE("GPL");
49 49
50static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 }; 50static int magellan_buttons[] = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_7, BTN_8 };
51static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; 51static int magellan_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
52static char *magellan_name = "LogiCad3D Magellan / SpaceMouse";
53 52
54/* 53/*
55 * Per-Magellan data. 54 * Per-Magellan data.
56 */ 55 */
57 56
58struct magellan { 57struct magellan {
59 struct input_dev dev; 58 struct input_dev *dev;
60 int idx; 59 int idx;
61 unsigned char data[MAGELLAN_MAX_LENGTH]; 60 unsigned char data[MAGELLAN_MAX_LENGTH];
62 char phys[32]; 61 char phys[32];
@@ -85,7 +84,7 @@ static int magellan_crunch_nibbles(unsigned char *data, int count)
85 84
86static void magellan_process_packet(struct magellan* magellan, struct pt_regs *regs) 85static void magellan_process_packet(struct magellan* magellan, struct pt_regs *regs)
87{ 86{
88 struct input_dev *dev = &magellan->dev; 87 struct input_dev *dev = magellan->dev;
89 unsigned char *data = magellan->data; 88 unsigned char *data = magellan->data;
90 int i, t; 89 int i, t;
91 90
@@ -138,9 +137,9 @@ static void magellan_disconnect(struct serio *serio)
138{ 137{
139 struct magellan* magellan = serio_get_drvdata(serio); 138 struct magellan* magellan = serio_get_drvdata(serio);
140 139
141 input_unregister_device(&magellan->dev);
142 serio_close(serio); 140 serio_close(serio);
143 serio_set_drvdata(serio, NULL); 141 serio_set_drvdata(serio, NULL);
142 input_unregister_device(magellan->dev);
144 kfree(magellan); 143 kfree(magellan);
145} 144}
146 145
@@ -153,52 +152,48 @@ static void magellan_disconnect(struct serio *serio)
153static int magellan_connect(struct serio *serio, struct serio_driver *drv) 152static int magellan_connect(struct serio *serio, struct serio_driver *drv)
154{ 153{
155 struct magellan *magellan; 154 struct magellan *magellan;
156 int i, t; 155 struct input_dev *input_dev;
157 int err; 156 int err = -ENOMEM;
158 157 int i;
159 if (!(magellan = kmalloc(sizeof(struct magellan), GFP_KERNEL)))
160 return -ENOMEM;
161 158
162 memset(magellan, 0, sizeof(struct magellan)); 159 magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL);
160 input_dev = input_allocate_device();
161 if (!magellan || !input_dev)
162 goto fail;
163 163
164 magellan->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 164 magellan->dev = input_dev;
165 sprintf(magellan->phys, "%s/input0", serio->phys);
165 166
166 for (i = 0; i < 9; i++) 167 input_dev->name = "LogiCad3D Magellan / SpaceMouse";
167 set_bit(magellan_buttons[i], magellan->dev.keybit); 168 input_dev->phys = magellan->phys;
169 input_dev->id.bustype = BUS_RS232;
170 input_dev->id.vendor = SERIO_MAGELLAN;
171 input_dev->id.product = 0x0001;
172 input_dev->id.version = 0x0100;
173 input_dev->cdev.dev = &serio->dev;
174 input_dev->private = magellan;
168 175
169 for (i = 0; i < 6; i++) { 176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
170 t = magellan_axes[i];
171 set_bit(t, magellan->dev.absbit);
172 magellan->dev.absmin[t] = -360;
173 magellan->dev.absmax[t] = 360;
174 }
175 177
176 sprintf(magellan->phys, "%s/input0", serio->phys); 178 for (i = 0; i < 9; i++)
179 set_bit(magellan_buttons[i], input_dev->keybit);
177 180
178 init_input_dev(&magellan->dev); 181 for (i = 0; i < 6; i++)
179 magellan->dev.private = magellan; 182 input_set_abs_params(input_dev, magellan_axes[i], -360, 360, 0, 0);
180 magellan->dev.name = magellan_name;
181 magellan->dev.phys = magellan->phys;
182 magellan->dev.id.bustype = BUS_RS232;
183 magellan->dev.id.vendor = SERIO_MAGELLAN;
184 magellan->dev.id.product = 0x0001;
185 magellan->dev.id.version = 0x0100;
186 magellan->dev.dev = &serio->dev;
187 183
188 serio_set_drvdata(serio, magellan); 184 serio_set_drvdata(serio, magellan);
189 185
190 err = serio_open(serio, drv); 186 err = serio_open(serio, drv);
191 if (err) { 187 if (err)
192 serio_set_drvdata(serio, NULL); 188 goto fail;
193 kfree(magellan);
194 return err;
195 }
196
197 input_register_device(&magellan->dev);
198
199 printk(KERN_INFO "input: %s on %s\n", magellan_name, serio->phys);
200 189
190 input_register_device(magellan->dev);
201 return 0; 191 return 0;
192
193 fail: serio_set_drvdata(serio, NULL);
194 input_free_device(input_dev);
195 kfree(magellan);
196 return err;
202} 197}
203 198
204/* 199/*
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 9e0353721a35..eaaad45cc750 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -113,7 +113,7 @@ static struct {
113 113
114struct sw { 114struct sw {
115 struct gameport *gameport; 115 struct gameport *gameport;
116 struct input_dev dev[4]; 116 struct input_dev *dev[4];
117 char name[64]; 117 char name[64];
118 char phys[4][32]; 118 char phys[4][32];
119 int length; 119 int length;
@@ -301,7 +301,7 @@ static int sw_check(__u64 t)
301static int sw_parse(unsigned char *buf, struct sw *sw) 301static int sw_parse(unsigned char *buf, struct sw *sw)
302{ 302{
303 int hat, i, j; 303 int hat, i, j;
304 struct input_dev *dev = sw->dev; 304 struct input_dev *dev;
305 305
306 switch (sw->type) { 306 switch (sw->type) {
307 307
@@ -310,6 +310,8 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
310 if (sw_check(GB(0,64)) || (hat = (GB(6,1) << 3) | GB(60,3)) > 8) 310 if (sw_check(GB(0,64)) || (hat = (GB(6,1) << 3) | GB(60,3)) > 8)
311 return -1; 311 return -1;
312 312
313 dev = sw->dev[0];
314
313 input_report_abs(dev, ABS_X, (GB( 3,3) << 7) | GB(16,7)); 315 input_report_abs(dev, ABS_X, (GB( 3,3) << 7) | GB(16,7));
314 input_report_abs(dev, ABS_Y, (GB( 0,3) << 7) | GB(24,7)); 316 input_report_abs(dev, ABS_Y, (GB( 0,3) << 7) | GB(24,7));
315 input_report_abs(dev, ABS_RZ, (GB(35,2) << 7) | GB(40,7)); 317 input_report_abs(dev, ABS_RZ, (GB(35,2) << 7) | GB(40,7));
@@ -335,13 +337,13 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
335 if (sw_parity(GB(i*15,15))) 337 if (sw_parity(GB(i*15,15)))
336 return -1; 338 return -1;
337 339
338 input_report_abs(dev + i, ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); 340 input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1));
339 input_report_abs(dev + i, ABS_Y, GB(i*15+0,1) - GB(i*15+1,1)); 341 input_report_abs(sw->dev[i], ABS_Y, GB(i*15+0,1) - GB(i*15+1,1));
340 342
341 for (j = 0; j < 10; j++) 343 for (j = 0; j < 10; j++)
342 input_report_key(dev + i, sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1)); 344 input_report_key(sw->dev[i], sw_btn[SW_ID_GP][j], !GB(i*15+j+4,1));
343 345
344 input_sync(dev + i); 346 input_sync(sw->dev[i]);
345 } 347 }
346 348
347 return 0; 349 return 0;
@@ -352,6 +354,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
352 if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8) 354 if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8)
353 return -1; 355 return -1;
354 356
357 dev = sw->dev[0];
355 input_report_abs(dev, ABS_X, GB( 9,10)); 358 input_report_abs(dev, ABS_X, GB( 9,10));
356 input_report_abs(dev, ABS_Y, GB(19,10)); 359 input_report_abs(dev, ABS_Y, GB(19,10));
357 input_report_abs(dev, ABS_RZ, GB(36, 6)); 360 input_report_abs(dev, ABS_RZ, GB(36, 6));
@@ -372,6 +375,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
372 if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8) 375 if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8)
373 return -1; 376 return -1;
374 377
378 dev = sw->dev[0];
375 input_report_abs(dev, ABS_X, GB( 0,10)); 379 input_report_abs(dev, ABS_X, GB( 0,10));
376 input_report_abs(dev, ABS_Y, GB(16,10)); 380 input_report_abs(dev, ABS_Y, GB(16,10));
377 input_report_abs(dev, ABS_THROTTLE, GB(32, 6)); 381 input_report_abs(dev, ABS_THROTTLE, GB(32, 6));
@@ -396,6 +400,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw)
396 if (!sw_parity(GB(0,33))) 400 if (!sw_parity(GB(0,33)))
397 return -1; 401 return -1;
398 402
403 dev = sw->dev[0];
399 input_report_abs(dev, ABS_RX, GB( 0,10)); 404 input_report_abs(dev, ABS_RX, GB( 0,10));
400 input_report_abs(dev, ABS_RUDDER, GB(10, 6)); 405 input_report_abs(dev, ABS_RUDDER, GB(10, 6));
401 input_report_abs(dev, ABS_THROTTLE, GB(16, 6)); 406 input_report_abs(dev, ABS_THROTTLE, GB(16, 6));
@@ -581,6 +586,7 @@ static int sw_guess_mode(unsigned char *buf, int len)
581static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) 586static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
582{ 587{
583 struct sw *sw; 588 struct sw *sw;
589 struct input_dev *input_dev;
584 int i, j, k, l; 590 int i, j, k, l;
585 int err; 591 int err;
586 unsigned char *buf = NULL; /* [SW_LENGTH] */ 592 unsigned char *buf = NULL; /* [SW_LENGTH] */
@@ -729,42 +735,50 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
729 sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]); 735 sprintf(sw->name, "Microsoft SideWinder %s", sw_name[sw->type]);
730 sprintf(sw->phys[i], "%s/input%d", gameport->phys, i); 736 sprintf(sw->phys[i], "%s/input%d", gameport->phys, i);
731 737
732 sw->dev[i].private = sw; 738 input_dev = input_allocate_device();
739 if (!input_dev) {
740 err = -ENOMEM;
741 goto fail3;
742 }
733 743
734 sw->dev[i].open = sw_open; 744 input_dev->name = sw->name;
735 sw->dev[i].close = sw_close; 745 input_dev->phys = sw->phys[i];
746 input_dev->id.bustype = BUS_GAMEPORT;
747 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT;
748 input_dev->id.product = sw->type;
749 input_dev->id.version = 0x0100;
750 input_dev->cdev.dev = &gameport->dev;
751 input_dev->private = sw;
736 752
737 sw->dev[i].name = sw->name; 753 input_dev->open = sw_open;
738 sw->dev[i].phys = sw->phys[i]; 754 input_dev->close = sw_close;
739 sw->dev[i].id.bustype = BUS_GAMEPORT;
740 sw->dev[i].id.vendor = GAMEPORT_ID_VENDOR_MICROSOFT;
741 sw->dev[i].id.product = sw->type;
742 sw->dev[i].id.version = 0x0100;
743 755
744 sw->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 756 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
745 757
746 for (j = 0; (bits = sw_bit[sw->type][j]); j++) { 758 for (j = 0; (bits = sw_bit[sw->type][j]); j++) {
747 code = sw_abs[sw->type][j]; 759 code = sw_abs[sw->type][j];
748 set_bit(code, sw->dev[i].absbit); 760 set_bit(code, input_dev->absbit);
749 sw->dev[i].absmax[code] = (1 << bits) - 1; 761 input_dev->absmax[code] = (1 << bits) - 1;
750 sw->dev[i].absmin[code] = (bits == 1) ? -1 : 0; 762 input_dev->absmin[code] = (bits == 1) ? -1 : 0;
751 sw->dev[i].absfuzz[code] = ((bits >> 1) >= 2) ? (1 << ((bits >> 1) - 2)) : 0; 763 input_dev->absfuzz[code] = ((bits >> 1) >= 2) ? (1 << ((bits >> 1) - 2)) : 0;
752 if (code != ABS_THROTTLE) 764 if (code != ABS_THROTTLE)
753 sw->dev[i].absflat[code] = (bits >= 5) ? (1 << (bits - 5)) : 0; 765 input_dev->absflat[code] = (bits >= 5) ? (1 << (bits - 5)) : 0;
754 } 766 }
755 767
756 for (j = 0; (code = sw_btn[sw->type][j]); j++) 768 for (j = 0; (code = sw_btn[sw->type][j]); j++)
757 set_bit(code, sw->dev[i].keybit); 769 set_bit(code, input_dev->keybit);
770
771 dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k);
758 772
759 input_register_device(sw->dev + i); 773 input_register_device(sw->dev[i]);
760 printk(KERN_INFO "input: %s%s on %s [%d-bit id %d data %d]\n",
761 sw->name, comment, gameport->phys, m, l, k);
762 } 774 }
763 775
764 return 0; 776 return 0;
765 777
766fail2: gameport_close(gameport); 778 fail3: while (--i >= 0)
767fail1: gameport_set_drvdata(gameport, NULL); 779 input_unregister_device(sw->dev[i]);
780 fail2: gameport_close(gameport);
781 fail1: gameport_set_drvdata(gameport, NULL);
768 kfree(sw); 782 kfree(sw);
769 kfree(buf); 783 kfree(buf);
770 kfree(idbuf); 784 kfree(idbuf);
@@ -777,7 +791,7 @@ static void sw_disconnect(struct gameport *gameport)
777 int i; 791 int i;
778 792
779 for (i = 0; i < sw->number; i++) 793 for (i = 0; i < sw->number; i++)
780 input_unregister_device(sw->dev + i); 794 input_unregister_device(sw->dev[i]);
781 gameport_close(gameport); 795 gameport_close(gameport);
782 gameport_set_drvdata(gameport, NULL); 796 gameport_set_drvdata(gameport, NULL);
783 kfree(sw); 797 kfree(sw);
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index a436f2220856..d6f8db8ec3fd 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -70,8 +70,7 @@ static char *spaceball_names[] = {
70 */ 70 */
71 71
72struct spaceball { 72struct spaceball {
73 struct input_dev dev; 73 struct input_dev *dev;
74 struct serio *serio;
75 int idx; 74 int idx;
76 int escape; 75 int escape;
77 unsigned char data[SPACEBALL_MAX_LENGTH]; 76 unsigned char data[SPACEBALL_MAX_LENGTH];
@@ -85,7 +84,7 @@ struct spaceball {
85 84
86static void spaceball_process_packet(struct spaceball* spaceball, struct pt_regs *regs) 85static void spaceball_process_packet(struct spaceball* spaceball, struct pt_regs *regs)
87{ 86{
88 struct input_dev *dev = &spaceball->dev; 87 struct input_dev *dev = spaceball->dev;
89 unsigned char *data = spaceball->data; 88 unsigned char *data = spaceball->data;
90 int i; 89 int i;
91 90
@@ -193,9 +192,9 @@ static void spaceball_disconnect(struct serio *serio)
193{ 192{
194 struct spaceball* spaceball = serio_get_drvdata(serio); 193 struct spaceball* spaceball = serio_get_drvdata(serio);
195 194
196 input_unregister_device(&spaceball->dev);
197 serio_close(serio); 195 serio_close(serio);
198 serio_set_drvdata(serio, NULL); 196 serio_set_drvdata(serio, NULL);
197 input_unregister_device(spaceball->dev);
199 kfree(spaceball); 198 kfree(spaceball);
200} 199}
201 200
@@ -208,69 +207,62 @@ static void spaceball_disconnect(struct serio *serio)
208static int spaceball_connect(struct serio *serio, struct serio_driver *drv) 207static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
209{ 208{
210 struct spaceball *spaceball; 209 struct spaceball *spaceball;
211 int i, t, id; 210 struct input_dev *input_dev;
212 int err; 211 int err = -ENOMEM;
212 int i, id;
213 213
214 if ((id = serio->id.id) > SPACEBALL_MAX_ID) 214 if ((id = serio->id.id) > SPACEBALL_MAX_ID)
215 return -ENODEV; 215 return -ENODEV;
216 216
217 if (!(spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL))) 217 spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL);
218 return - ENOMEM; 218 input_dev = input_allocate_device();
219 if (!spaceball || !input_dev)
220 goto fail;
219 221
220 memset(spaceball, 0, sizeof(struct spaceball)); 222 spaceball->dev = input_dev;
223 sprintf(spaceball->phys, "%s/input0", serio->phys);
224
225 input_dev->name = spaceball_names[id];
226 input_dev->phys = spaceball->phys;
227 input_dev->id.bustype = BUS_RS232;
228 input_dev->id.vendor = SERIO_SPACEBALL;
229 input_dev->id.product = id;
230 input_dev->id.version = 0x0100;
231 input_dev->cdev.dev = &serio->dev;
232 input_dev->private = spaceball;
221 233
222 spaceball->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 234 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
223 235
224 switch (id) { 236 switch (id) {
225 case SPACEBALL_4000FLX: 237 case SPACEBALL_4000FLX:
226 case SPACEBALL_4000FLX_L: 238 case SPACEBALL_4000FLX_L:
227 spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_9); 239 input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_9);
228 spaceball->dev.keybit[LONG(BTN_A)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_MODE); 240 input_dev->keybit[LONG(BTN_A)] |= BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_MODE);
229 default: 241 default:
230 spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) 242 input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4)
231 | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7) | BIT(BTN_8); 243 | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7) | BIT(BTN_8);
232 case SPACEBALL_3003C: 244 case SPACEBALL_3003C:
233 spaceball->dev.keybit[LONG(BTN_0)] |= BIT(BTN_1) | BIT(BTN_8); 245 input_dev->keybit[LONG(BTN_0)] |= BIT(BTN_1) | BIT(BTN_8);
234 } 246 }
235 247
236 for (i = 0; i < 6; i++) { 248 for (i = 0; i < 3; i++) {
237 t = spaceball_axes[i]; 249 input_set_abs_params(input_dev, ABS_X + i, -8000, 8000, 8, 40);
238 set_bit(t, spaceball->dev.absbit); 250 input_set_abs_params(input_dev, ABS_RX + i, -1600, 1600, 2, 8);
239 spaceball->dev.absmin[t] = i < 3 ? -8000 : -1600;
240 spaceball->dev.absmax[t] = i < 3 ? 8000 : 1600;
241 spaceball->dev.absflat[t] = i < 3 ? 40 : 8;
242 spaceball->dev.absfuzz[t] = i < 3 ? 8 : 2;
243 } 251 }
244 252
245 spaceball->serio = serio;
246 spaceball->dev.private = spaceball;
247
248 sprintf(spaceball->phys, "%s/input0", serio->phys);
249
250 init_input_dev(&spaceball->dev);
251 spaceball->dev.name = spaceball_names[id];
252 spaceball->dev.phys = spaceball->phys;
253 spaceball->dev.id.bustype = BUS_RS232;
254 spaceball->dev.id.vendor = SERIO_SPACEBALL;
255 spaceball->dev.id.product = id;
256 spaceball->dev.id.version = 0x0100;
257 spaceball->dev.dev = &serio->dev;
258
259 serio_set_drvdata(serio, spaceball); 253 serio_set_drvdata(serio, spaceball);
260 254
261 err = serio_open(serio, drv); 255 err = serio_open(serio, drv);
262 if (err) { 256 if (err)
263 serio_set_drvdata(serio, NULL); 257 goto fail;
264 kfree(spaceball);
265 return err;
266 }
267
268 input_register_device(&spaceball->dev);
269
270 printk(KERN_INFO "input: %s on serio%s\n",
271 spaceball_names[id], serio->phys);
272 258
259 input_register_device(spaceball->dev);
273 return 0; 260 return 0;
261
262 fail: serio_set_drvdata(serio, NULL);
263 input_free_device(input_dev);
264 kfree(spaceball);
265 return err;
274} 266}
275 267
276/* 268/*
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index 01fd2e4791ae..7c123a01c58e 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -52,15 +52,13 @@ MODULE_LICENSE("GPL");
52 52
53static int spaceorb_buttons[] = { BTN_TL, BTN_TR, BTN_Y, BTN_X, BTN_B, BTN_A }; 53static int spaceorb_buttons[] = { BTN_TL, BTN_TR, BTN_Y, BTN_X, BTN_B, BTN_A };
54static int spaceorb_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; 54static int spaceorb_axes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ };
55static char *spaceorb_name = "SpaceTec SpaceOrb 360 / Avenger";
56 55
57/* 56/*
58 * Per-Orb data. 57 * Per-Orb data.
59 */ 58 */
60 59
61struct spaceorb { 60struct spaceorb {
62 struct input_dev dev; 61 struct input_dev *dev;
63 struct serio *serio;
64 int idx; 62 int idx;
65 unsigned char data[SPACEORB_MAX_LENGTH]; 63 unsigned char data[SPACEORB_MAX_LENGTH];
66 char phys[32]; 64 char phys[32];
@@ -78,7 +76,7 @@ static unsigned char *spaceorb_errors[] = { "EEPROM storing 0 failed", "Receive
78 76
79static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *regs) 77static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *regs)
80{ 78{
81 struct input_dev *dev = &spaceorb->dev; 79 struct input_dev *dev = spaceorb->dev;
82 unsigned char *data = spaceorb->data; 80 unsigned char *data = spaceorb->data;
83 unsigned char c = 0; 81 unsigned char c = 0;
84 int axes[6]; 82 int axes[6];
@@ -95,8 +93,8 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r
95 case 'R': /* Reset packet */ 93 case 'R': /* Reset packet */
96 spaceorb->data[spaceorb->idx - 1] = 0; 94 spaceorb->data[spaceorb->idx - 1] = 0;
97 for (i = 1; i < spaceorb->idx && spaceorb->data[i] == ' '; i++); 95 for (i = 1; i < spaceorb->idx && spaceorb->data[i] == ' '; i++);
98 printk(KERN_INFO "input: %s [%s] on %s\n", 96 printk(KERN_INFO "input: %s [%s] is %s\n",
99 spaceorb_name, spaceorb->data + i, spaceorb->serio->phys); 97 dev->name, spaceorb->data + i, spaceorb->phys);
100 break; 98 break;
101 99
102 case 'D': /* Ball + button data */ 100 case 'D': /* Ball + button data */
@@ -123,7 +121,7 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r
123 121
124 case 'E': /* Error packet */ 122 case 'E': /* Error packet */
125 if (spaceorb->idx != 4) return; 123 if (spaceorb->idx != 4) return;
126 printk(KERN_ERR "joy-spaceorb: Device error. [ "); 124 printk(KERN_ERR "spaceorb: Device error. [ ");
127 for (i = 0; i < 7; i++) if (data[1] & (1 << i)) printk("%s ", spaceorb_errors[i]); 125 for (i = 0; i < 7; i++) if (data[1] & (1 << i)) printk("%s ", spaceorb_errors[i]);
128 printk("]\n"); 126 printk("]\n");
129 break; 127 break;
@@ -154,9 +152,9 @@ static void spaceorb_disconnect(struct serio *serio)
154{ 152{
155 struct spaceorb* spaceorb = serio_get_drvdata(serio); 153 struct spaceorb* spaceorb = serio_get_drvdata(serio);
156 154
157 input_unregister_device(&spaceorb->dev);
158 serio_close(serio); 155 serio_close(serio);
159 serio_set_drvdata(serio, NULL); 156 serio_set_drvdata(serio, NULL);
157 input_unregister_device(spaceorb->dev);
160 kfree(spaceorb); 158 kfree(spaceorb);
161} 159}
162 160
@@ -169,52 +167,48 @@ static void spaceorb_disconnect(struct serio *serio)
169static int spaceorb_connect(struct serio *serio, struct serio_driver *drv) 167static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
170{ 168{
171 struct spaceorb *spaceorb; 169 struct spaceorb *spaceorb;
172 int i, t; 170 struct input_dev *input_dev;
173 int err; 171 int err = -ENOMEM;
174 172 int i;
175 if (!(spaceorb = kmalloc(sizeof(struct spaceorb), GFP_KERNEL)))
176 return -ENOMEM;
177
178 memset(spaceorb, 0, sizeof(struct spaceorb));
179 173
180 spaceorb->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 174 spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL);
175 input_dev = input_allocate_device();
176 if (!spaceorb || !input_dev)
177 goto fail;
181 178
182 for (i = 0; i < 6; i++) 179 spaceorb->dev = input_dev;
183 set_bit(spaceorb_buttons[i], spaceorb->dev.keybit); 180 sprintf(spaceorb->phys, "%s/input0", serio->phys);
184 181
185 for (i = 0; i < 6; i++) { 182 input_dev->name = "SpaceTec SpaceOrb 360 / Avenger";
186 t = spaceorb_axes[i]; 183 input_dev->phys = spaceorb->phys;
187 set_bit(t, spaceorb->dev.absbit); 184 input_dev->id.bustype = BUS_RS232;
188 spaceorb->dev.absmin[t] = -508; 185 input_dev->id.vendor = SERIO_SPACEORB;
189 spaceorb->dev.absmax[t] = 508; 186 input_dev->id.product = 0x0001;
190 } 187 input_dev->id.version = 0x0100;
188 input_dev->cdev.dev = &serio->dev;
189 input_dev->private = spaceorb;
191 190
192 spaceorb->serio = serio; 191 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
193 spaceorb->dev.private = spaceorb;
194 192
195 sprintf(spaceorb->phys, "%s/input0", serio->phys); 193 for (i = 0; i < 6; i++)
194 set_bit(spaceorb_buttons[i], input_dev->keybit);
196 195
197 init_input_dev(&spaceorb->dev); 196 for (i = 0; i < 6; i++)
198 spaceorb->dev.name = spaceorb_name; 197 input_set_abs_params(input_dev, spaceorb_axes[i], -508, 508, 0, 0);
199 spaceorb->dev.phys = spaceorb->phys;
200 spaceorb->dev.id.bustype = BUS_RS232;
201 spaceorb->dev.id.vendor = SERIO_SPACEORB;
202 spaceorb->dev.id.product = 0x0001;
203 spaceorb->dev.id.version = 0x0100;
204 spaceorb->dev.dev = &serio->dev;
205 198
206 serio_set_drvdata(serio, spaceorb); 199 serio_set_drvdata(serio, spaceorb);
207 200
208 err = serio_open(serio, drv); 201 err = serio_open(serio, drv);
209 if (err) { 202 if (err)
210 serio_set_drvdata(serio, NULL); 203 goto fail;
211 kfree(spaceorb);
212 return err;
213 }
214
215 input_register_device(&spaceorb->dev);
216 204
205 input_register_device(spaceorb->dev);
217 return 0; 206 return 0;
207
208 fail: serio_set_drvdata(serio, NULL);
209 input_free_device(input_dev);
210 kfree(spaceorb);
211 return err;
218} 212}
219 213
220/* 214/*
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 6f6e6753d590..0a9ed1d30636 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL");
48 48
49#define STINGER_MAX_LENGTH 8 49#define STINGER_MAX_LENGTH 8
50 50
51static char *stinger_name = "Gravis Stinger";
52
53/* 51/*
54 * Per-Stinger data. 52 * Per-Stinger data.
55 */ 53 */
56 54
57struct stinger { 55struct stinger {
58 struct input_dev dev; 56 struct input_dev *dev;
59 int idx; 57 int idx;
60 unsigned char data[STINGER_MAX_LENGTH]; 58 unsigned char data[STINGER_MAX_LENGTH];
61 char phys[32]; 59 char phys[32];
@@ -68,7 +66,7 @@ struct stinger {
68 66
69static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs) 67static void stinger_process_packet(struct stinger *stinger, struct pt_regs *regs)
70{ 68{
71 struct input_dev *dev = &stinger->dev; 69 struct input_dev *dev = stinger->dev;
72 unsigned char *data = stinger->data; 70 unsigned char *data = stinger->data;
73 71
74 if (!stinger->idx) return; 72 if (!stinger->idx) return;
@@ -126,9 +124,9 @@ static void stinger_disconnect(struct serio *serio)
126{ 124{
127 struct stinger *stinger = serio_get_drvdata(serio); 125 struct stinger *stinger = serio_get_drvdata(serio);
128 126
129 input_unregister_device(&stinger->dev);
130 serio_close(serio); 127 serio_close(serio);
131 serio_set_drvdata(serio, NULL); 128 serio_set_drvdata(serio, NULL);
129 input_unregister_device(stinger->dev);
132 kfree(stinger); 130 kfree(stinger);
133} 131}
134 132
@@ -141,53 +139,46 @@ static void stinger_disconnect(struct serio *serio)
141static int stinger_connect(struct serio *serio, struct serio_driver *drv) 139static int stinger_connect(struct serio *serio, struct serio_driver *drv)
142{ 140{
143 struct stinger *stinger; 141 struct stinger *stinger;
144 int i; 142 struct input_dev *input_dev;
145 int err; 143 int err = -ENOMEM;
146
147 if (!(stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL)))
148 return -ENOMEM;
149
150 memset(stinger, 0, sizeof(struct stinger));
151 144
152 stinger->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 145 stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL);
153 stinger->dev.keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) | \ 146 input_dev = input_allocate_device();
154 BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) | \ 147 if (!stinger || !input_dev)
155 BIT(BTN_START) | BIT(BTN_SELECT); 148 goto fail;
156 stinger->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
157 149
150 stinger->dev = input_dev;
158 sprintf(stinger->phys, "%s/serio0", serio->phys); 151 sprintf(stinger->phys, "%s/serio0", serio->phys);
159 152
160 init_input_dev(&stinger->dev); 153 input_dev->name = "Gravis Stinger";
161 stinger->dev.name = stinger_name; 154 input_dev->phys = stinger->phys;
162 stinger->dev.phys = stinger->phys; 155 input_dev->id.bustype = BUS_RS232;
163 stinger->dev.id.bustype = BUS_RS232; 156 input_dev->id.vendor = SERIO_STINGER;
164 stinger->dev.id.vendor = SERIO_STINGER; 157 input_dev->id.product = 0x0001;
165 stinger->dev.id.product = 0x0001; 158 input_dev->id.version = 0x0100;
166 stinger->dev.id.version = 0x0100; 159 input_dev->cdev.dev = &serio->dev;
167 stinger->dev.dev = &serio->dev; 160 input_dev->private = stinger;
168 161
169 for (i = 0; i < 2; i++) { 162 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
170 stinger->dev.absmax[ABS_X+i] = 64; 163 input_dev->keybit[LONG(BTN_A)] = BIT(BTN_A) | BIT(BTN_B) | BIT(BTN_C) | BIT(BTN_X) |
171 stinger->dev.absmin[ABS_X+i] = -64; 164 BIT(BTN_Y) | BIT(BTN_Z) | BIT(BTN_TL) | BIT(BTN_TR) |
172 stinger->dev.absflat[ABS_X+i] = 4; 165 BIT(BTN_START) | BIT(BTN_SELECT);
173 } 166 input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 4);
174 167 input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 4);
175 stinger->dev.private = stinger;
176 168
177 serio_set_drvdata(serio, stinger); 169 serio_set_drvdata(serio, stinger);
178 170
179 err = serio_open(serio, drv); 171 err = serio_open(serio, drv);
180 if (err) { 172 if (err)
181 serio_set_drvdata(serio, NULL); 173 goto fail;
182 kfree(stinger);
183 return err;
184 }
185
186 input_register_device(&stinger->dev);
187
188 printk(KERN_INFO "input: %s on %s\n", stinger_name, serio->phys);
189 174
175 input_register_device(stinger->dev);
190 return 0; 176 return 0;
177
178 fail: serio_set_drvdata(serio, NULL);
179 input_free_device(input_dev);
180 kfree(stinger);
181 return err;
191} 182}
192 183
193/* 184/*
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 7431efc4330e..3a7d1bb46472 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -63,37 +63,70 @@ MODULE_LICENSE("GPL");
63#define TMDC_ABS_HAT 4 63#define TMDC_ABS_HAT 4
64#define TMDC_BTN 16 64#define TMDC_BTN 16
65 65
66static unsigned char tmdc_byte_a[16] = { 0, 1, 3, 4, 6, 7 }; 66static const unsigned char tmdc_byte_a[16] = { 0, 1, 3, 4, 6, 7 };
67static unsigned char tmdc_byte_d[16] = { 2, 5, 8, 9 }; 67static const unsigned char tmdc_byte_d[16] = { 2, 5, 8, 9 };
68 68
69static signed char tmdc_abs[TMDC_ABS] = 69static const signed char tmdc_abs[TMDC_ABS] =
70 { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE, ABS_RX, ABS_RY, ABS_RZ }; 70 { ABS_X, ABS_Y, ABS_RUDDER, ABS_THROTTLE, ABS_RX, ABS_RY, ABS_RZ };
71static signed char tmdc_abs_hat[TMDC_ABS_HAT] = 71static const signed char tmdc_abs_hat[TMDC_ABS_HAT] =
72 { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y }; 72 { ABS_HAT0X, ABS_HAT0Y, ABS_HAT1X, ABS_HAT1Y };
73static signed char tmdc_abs_at[TMDC_ABS] = 73static const signed char tmdc_abs_at[TMDC_ABS] =
74 { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE }; 74 { ABS_X, ABS_Y, ABS_RUDDER, -1, ABS_THROTTLE };
75static signed char tmdc_abs_fm[TMDC_ABS] = 75static const signed char tmdc_abs_fm[TMDC_ABS] =
76 { ABS_RX, ABS_RY, ABS_X, ABS_Y }; 76 { ABS_RX, ABS_RY, ABS_X, ABS_Y };
77 77
78static short tmdc_btn_pad[TMDC_BTN] = 78static const short tmdc_btn_pad[TMDC_BTN] =
79 { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR }; 79 { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_START, BTN_SELECT, BTN_TL, BTN_TR };
80static short tmdc_btn_joy[TMDC_BTN] = 80static const short tmdc_btn_joy[TMDC_BTN] =
81 { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE, 81 { BTN_TRIGGER, BTN_THUMB, BTN_TOP, BTN_TOP2, BTN_BASE, BTN_BASE2, BTN_THUMB2, BTN_PINKIE,
82 BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z }; 82 BTN_BASE3, BTN_BASE4, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z };
83static short tmdc_btn_fm[TMDC_BTN] = 83static const short tmdc_btn_fm[TMDC_BTN] =
84 { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 }; 84 { BTN_TRIGGER, BTN_C, BTN_B, BTN_A, BTN_THUMB, BTN_X, BTN_Y, BTN_Z, BTN_TOP, BTN_TOP2 };
85static short tmdc_btn_at[TMDC_BTN] = 85static const short tmdc_btn_at[TMDC_BTN] =
86 { BTN_TRIGGER, BTN_THUMB2, BTN_PINKIE, BTN_THUMB, BTN_BASE6, BTN_BASE5, BTN_BASE4, 86 { BTN_TRIGGER, BTN_THUMB2, BTN_PINKIE, BTN_THUMB, BTN_BASE6, BTN_BASE5, BTN_BASE4,
87 BTN_BASE3, BTN_BASE2, BTN_BASE }; 87 BTN_BASE3, BTN_BASE2, BTN_BASE };
88 88
89static struct { 89static const struct {
90 int x; 90 int x;
91 int y; 91 int y;
92} tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}}; 92} tmdc_hat_to_axis[] = {{ 0, 0}, { 1, 0}, { 0,-1}, {-1, 0}, { 0, 1}};
93 93
94static const struct tmdc_model {
95 unsigned char id;
96 const char *name;
97 char abs;
98 char hats;
99 char btnc[4];
100 char btno[4];
101 const signed char *axes;
102 const short *buttons;
103} tmdc_models[] = {
104 { 1, "ThrustMaster Millenium 3D Inceptor", 6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy },
105 { 3, "ThrustMaster Rage 3D Gamepad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
106 { 4, "ThrustMaster Attack Throttle", 5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at },
107 { 8, "ThrustMaster FragMaster", 4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm },
108 { 163, "Thrustmaster Fusion GamePad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
109 { 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy }
110};
111
112
113struct tmdc_port {
114 struct input_dev *dev;
115 char name[64];
116 char phys[32];
117 int mode;
118 const signed char *abs;
119 const short *btn;
120 unsigned char absc;
121 unsigned char btnc[4];
122 unsigned char btno[4];
123};
124
94struct tmdc { 125struct tmdc {
95 struct gameport *gameport; 126 struct gameport *gameport;
96 struct input_dev dev[2]; 127 struct tmdc_port *port[2];
128#if 0
129 struct input_dev *dev[2];
97 char name[2][64]; 130 char name[2][64];
98 char phys[2][32]; 131 char phys[2][32];
99 int mode[2]; 132 int mode[2];
@@ -102,6 +135,7 @@ struct tmdc {
102 unsigned char absc[2]; 135 unsigned char absc[2];
103 unsigned char btnc[2][4]; 136 unsigned char btnc[2][4];
104 unsigned char btno[2][4]; 137 unsigned char btno[2][4];
138#endif
105 int reads; 139 int reads;
106 int bads; 140 int bads;
107 unsigned char exists; 141 unsigned char exists;
@@ -156,6 +190,50 @@ static int tmdc_read_packet(struct gameport *gameport, unsigned char data[2][TMD
156 return (i[0] == TMDC_MAX_LENGTH) | ((i[1] == TMDC_MAX_LENGTH) << 1); 190 return (i[0] == TMDC_MAX_LENGTH) | ((i[1] == TMDC_MAX_LENGTH) << 1);
157} 191}
158 192
193static int tmdc_parse_packet(struct tmdc_port *port, unsigned char *data)
194{
195 int i, k, l;
196
197 if (data[TMDC_BYTE_ID] != port->mode)
198 return -1;
199
200 for (i = 0; i < port->absc; i++) {
201 if (port->abs[i] < 0)
202 return 0;
203
204 input_report_abs(port->dev, port->abs[i], data[tmdc_byte_a[i]]);
205 }
206
207 switch (port->mode) {
208
209 case TMDC_MODE_M3DI:
210
211 i = tmdc_byte_d[0];
212 input_report_abs(port->dev, ABS_HAT0X, ((data[i] >> 3) & 1) - ((data[i] >> 1) & 1));
213 input_report_abs(port->dev, ABS_HAT0Y, ((data[i] >> 2) & 1) - ( data[i] & 1));
214 break;
215
216 case TMDC_MODE_AT:
217
218 i = tmdc_byte_a[3];
219 input_report_abs(port->dev, ABS_HAT0X, tmdc_hat_to_axis[(data[i] - 141) / 25].x);
220 input_report_abs(port->dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[i] - 141) / 25].y);
221 break;
222
223 }
224
225 for (k = l = 0; k < 4; k++) {
226 for (i = 0; i < port->btnc[k]; i++)
227 input_report_key(port->dev, port->btn[i + l],
228 ((data[tmdc_byte_d[k]] >> (i + port->btno[k])) & 1));
229 l += port->btnc[k];
230 }
231
232 input_sync(port->dev);
233
234 return 0;
235}
236
159/* 237/*
160 * tmdc_poll() reads and analyzes ThrustMaster joystick data. 238 * tmdc_poll() reads and analyzes ThrustMaster joystick data.
161 */ 239 */
@@ -164,57 +242,21 @@ static void tmdc_poll(struct gameport *gameport)
164{ 242{
165 unsigned char data[2][TMDC_MAX_LENGTH]; 243 unsigned char data[2][TMDC_MAX_LENGTH];
166 struct tmdc *tmdc = gameport_get_drvdata(gameport); 244 struct tmdc *tmdc = gameport_get_drvdata(gameport);
167 struct input_dev *dev;
168 unsigned char r, bad = 0; 245 unsigned char r, bad = 0;
169 int i, j, k, l; 246 int i;
170 247
171 tmdc->reads++; 248 tmdc->reads++;
172 249
173 if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists) 250 if ((r = tmdc_read_packet(tmdc->gameport, data)) != tmdc->exists)
174 bad = 1; 251 bad = 1;
175 else 252 else {
176 253 for (i = 0; i < 2; i++) {
177 for (j = 0; j < 2; j++) 254 if (r & (1 << i) & tmdc->exists) {
178 if (r & (1 << j) & tmdc->exists) {
179
180 if (data[j][TMDC_BYTE_ID] != tmdc->mode[j]) {
181 bad = 1;
182 continue;
183 }
184
185 dev = tmdc->dev + j;
186
187 for (i = 0; i < tmdc->absc[j]; i++) {
188 if (tmdc->abs[j][i] < 0) continue;
189 input_report_abs(dev, tmdc->abs[j][i], data[j][tmdc_byte_a[i]]);
190 }
191
192 switch (tmdc->mode[j]) {
193 255
194 case TMDC_MODE_M3DI: 256 if (tmdc_parse_packet(tmdc->port[i], data[i]))
195 257 bad = 1;
196 i = tmdc_byte_d[0];
197 input_report_abs(dev, ABS_HAT0X, ((data[j][i] >> 3) & 1) - ((data[j][i] >> 1) & 1));
198 input_report_abs(dev, ABS_HAT0Y, ((data[j][i] >> 2) & 1) - ( data[j][i] & 1));
199 break;
200
201 case TMDC_MODE_AT:
202
203 i = tmdc_byte_a[3];
204 input_report_abs(dev, ABS_HAT0X, tmdc_hat_to_axis[(data[j][i] - 141) / 25].x);
205 input_report_abs(dev, ABS_HAT0Y, tmdc_hat_to_axis[(data[j][i] - 141) / 25].y);
206 break;
207
208 }
209
210 for (k = l = 0; k < 4; k++) {
211 for (i = 0; i < tmdc->btnc[j][k]; i++)
212 input_report_key(dev, tmdc->btn[j][i + l],
213 ((data[j][tmdc_byte_d[k]] >> (i + tmdc->btno[j][k])) & 1));
214 l += tmdc->btnc[j][k];
215 } 258 }
216 259 }
217 input_sync(dev);
218 } 260 }
219 261
220 tmdc->bads += bad; 262 tmdc->bads += bad;
@@ -235,31 +277,89 @@ static void tmdc_close(struct input_dev *dev)
235 gameport_stop_polling(tmdc->gameport); 277 gameport_stop_polling(tmdc->gameport);
236} 278}
237 279
280static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
281{
282 const struct tmdc_model *model;
283 struct tmdc_port *port;
284 struct input_dev *input_dev;
285 int i, j, b = 0;
286
287 tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
288 input_dev = input_allocate_device();
289 if (!port || !input_dev) {
290 kfree(port);
291 input_free_device(input_dev);
292 return -ENOMEM;
293 }
294
295 port->mode = data[TMDC_BYTE_ID];
296
297 for (model = tmdc_models; model->id && model->id != port->mode; model++)
298 /* empty */;
299
300 port->abs = model->axes;
301 port->btn = model->buttons;
302
303 if (!model->id) {
304 port->absc = data[TMDC_BYTE_DEF] >> 4;
305 for (i = 0; i < 4; i++)
306 port->btnc[i] = i < (data[TMDC_BYTE_DEF] & 0xf) ? 8 : 0;
307 } else {
308 port->absc = model->abs;
309 for (i = 0; i < 4; i++)
310 port->btnc[i] = model->btnc[i];
311 }
312
313 for (i = 0; i < 4; i++)
314 port->btno[i] = model->btno[i];
315
316 snprintf(port->name, sizeof(port->name), model->name,
317 port->absc, (data[TMDC_BYTE_DEF] & 0xf) << 3, port->mode);
318 snprintf(port->phys, sizeof(port->phys), "%s/input%d", tmdc->gameport->phys, i);
319
320 port->dev = input_dev;
321
322 input_dev->name = port->name;
323 input_dev->phys = port->phys;
324 input_dev->id.bustype = BUS_GAMEPORT;
325 input_dev->id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER;
326 input_dev->id.product = model->id;
327 input_dev->id.version = 0x0100;
328 input_dev->cdev.dev = &tmdc->gameport->dev;
329 input_dev->private = tmdc;
330
331 input_dev->open = tmdc_open;
332 input_dev->close = tmdc_close;
333
334 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
335
336 for (i = 0; i < port->absc && i < TMDC_ABS; i++)
337 if (port->abs[i] >= 0)
338 input_set_abs_params(input_dev, port->abs[i], 8, 248, 2, 4);
339
340 for (i = 0; i < model->hats && i < TMDC_ABS_HAT; i++)
341 input_set_abs_params(input_dev, tmdc_abs_hat[i], -1, 1, 0, 0);
342
343 for (i = 0; i < 4; i++) {
344 for (j = 0; j < port->btnc[i] && j < TMDC_BTN; j++)
345 set_bit(port->btn[j + b], input_dev->keybit);
346 b += port->btnc[i];
347 }
348
349 input_register_device(port->dev);
350
351 return 0;
352}
353
238/* 354/*
239 * tmdc_probe() probes for ThrustMaster type joysticks. 355 * tmdc_probe() probes for ThrustMaster type joysticks.
240 */ 356 */
241 357
242static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv) 358static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
243{ 359{
244 static struct models {
245 unsigned char id;
246 char *name;
247 char abs;
248 char hats;
249 char btnc[4];
250 char btno[4];
251 signed char *axes;
252 short *buttons;
253 } models[] = { { 1, "ThrustMaster Millenium 3D Inceptor", 6, 2, { 4, 2 }, { 4, 6 }, tmdc_abs, tmdc_btn_joy },
254 { 3, "ThrustMaster Rage 3D Gamepad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
255 { 4, "ThrustMaster Attack Throttle", 5, 2, { 4, 6 }, { 4, 2 }, tmdc_abs_at, tmdc_btn_at },
256 { 8, "ThrustMaster FragMaster", 4, 0, { 8, 2 }, { 0, 0 }, tmdc_abs_fm, tmdc_btn_fm },
257 { 163, "Thrustmaster Fusion GamePad", 2, 0, { 8, 2 }, { 0, 0 }, tmdc_abs, tmdc_btn_pad },
258 { 0, "Unknown %d-axis, %d-button TM device %d", 0, 0, { 0, 0 }, { 0, 0 }, tmdc_abs, tmdc_btn_joy }};
259
260 unsigned char data[2][TMDC_MAX_LENGTH]; 360 unsigned char data[2][TMDC_MAX_LENGTH];
261 struct tmdc *tmdc; 361 struct tmdc *tmdc;
262 int i, j, k, l, m; 362 int i;
263 int err; 363 int err;
264 364
265 if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) 365 if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL)))
@@ -281,68 +381,25 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
281 gameport_set_poll_handler(gameport, tmdc_poll); 381 gameport_set_poll_handler(gameport, tmdc_poll);
282 gameport_set_poll_interval(gameport, 20); 382 gameport_set_poll_interval(gameport, 20);
283 383
284 for (j = 0; j < 2; j++) 384 for (i = 0; i < 2; i++) {
285 if (tmdc->exists & (1 << j)) { 385 if (tmdc->exists & (1 << i)) {
286 386
287 tmdc->mode[j] = data[j][TMDC_BYTE_ID]; 387 err = tmdc_setup_port(tmdc, i, data[i]);
288 388 if (err)
289 for (m = 0; models[m].id && models[m].id != tmdc->mode[j]; m++); 389 goto fail3;
290
291 tmdc->abs[j] = models[m].axes;
292 tmdc->btn[j] = models[m].buttons;
293
294 if (!models[m].id) {
295 models[m].abs = data[j][TMDC_BYTE_DEF] >> 4;
296 for (k = 0; k < 4; k++)
297 models[m].btnc[k] = k < (data[j][TMDC_BYTE_DEF] & 0xf) ? 8 : 0;
298 }
299
300 tmdc->absc[j] = models[m].abs;
301 for (k = 0; k < 4; k++) {
302 tmdc->btnc[j][k] = models[m].btnc[k];
303 tmdc->btno[j][k] = models[m].btno[k];
304 }
305
306 sprintf(tmdc->name[j], models[m].name, models[m].abs,
307 (data[j][TMDC_BYTE_DEF] & 0xf) << 3, tmdc->mode[j]);
308
309 sprintf(tmdc->phys[j], "%s/input%d", gameport->phys, j);
310
311 tmdc->dev[j].private = tmdc;
312 tmdc->dev[j].open = tmdc_open;
313 tmdc->dev[j].close = tmdc_close;
314
315 tmdc->dev[j].name = tmdc->name[j];
316 tmdc->dev[j].phys = tmdc->phys[j];
317 tmdc->dev[j].id.bustype = BUS_GAMEPORT;
318 tmdc->dev[j].id.vendor = GAMEPORT_ID_VENDOR_THRUSTMASTER;
319 tmdc->dev[j].id.product = models[m].id;
320 tmdc->dev[j].id.version = 0x0100;
321
322 tmdc->dev[j].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
323
324 for (i = 0; i < models[m].abs && i < TMDC_ABS; i++)
325 if (tmdc->abs[j][i] >= 0)
326 input_set_abs_params(&tmdc->dev[j], tmdc->abs[j][i], 8, 248, 2, 4);
327
328 for (i = 0; i < models[m].hats && i < TMDC_ABS_HAT; i++)
329 input_set_abs_params(&tmdc->dev[j], tmdc_abs_hat[i], -1, 1, 0, 0);
330
331
332 for (k = l = 0; k < 4; k++) {
333 for (i = 0; i < models[m].btnc[k] && i < TMDC_BTN; i++)
334 set_bit(tmdc->btn[j][i + l], tmdc->dev[j].keybit);
335 l += models[m].btnc[k];
336 }
337
338 input_register_device(tmdc->dev + j);
339 printk(KERN_INFO "input: %s on %s\n", tmdc->name[j], gameport->phys);
340 } 390 }
391 }
341 392
342 return 0; 393 return 0;
343 394
344fail2: gameport_close(gameport); 395 fail3: while (--i >= 0) {
345fail1: gameport_set_drvdata(gameport, NULL); 396 if (tmdc->port[i]) {
397 input_unregister_device(tmdc->port[i]->dev);
398 kfree(tmdc->port[i]);
399 }
400 }
401 fail2: gameport_close(gameport);
402 fail1: gameport_set_drvdata(gameport, NULL);
346 kfree(tmdc); 403 kfree(tmdc);
347 return err; 404 return err;
348} 405}
@@ -352,9 +409,12 @@ static void tmdc_disconnect(struct gameport *gameport)
352 struct tmdc *tmdc = gameport_get_drvdata(gameport); 409 struct tmdc *tmdc = gameport_get_drvdata(gameport);
353 int i; 410 int i;
354 411
355 for (i = 0; i < 2; i++) 412 for (i = 0; i < 2; i++) {
356 if (tmdc->exists & (1 << i)) 413 if (tmdc->port[i]) {
357 input_unregister_device(tmdc->dev + i); 414 input_unregister_device(tmdc->port[i]->dev);
415 kfree(tmdc->port[i]);
416 }
417 }
358 gameport_close(gameport); 418 gameport_close(gameport);
359 gameport_set_drvdata(gameport, NULL); 419 gameport_set_drvdata(gameport, NULL);
360 kfree(tmdc); 420 kfree(tmdc);
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 0c5b9c8297cd..7e9764937d06 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -42,19 +42,21 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
42MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); 42MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
44 44
45static int tgfx[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; 45#define TGFX_MAX_PORTS 3
46static int tgfx_nargs __initdata = 0; 46#define TGFX_MAX_DEVICES 7
47module_param_array_named(map, tgfx, int, &tgfx_nargs, 0);
48MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>");
49 47
50static int tgfx_2[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; 48struct tgfx_config {
51static int tgfx_nargs_2 __initdata = 0; 49 int args[TGFX_MAX_DEVICES + 1];
52module_param_array_named(map2, tgfx_2, int, &tgfx_nargs_2, 0); 50 int nargs;
53MODULE_PARM_DESC(map2, "Describes second set of devices"); 51};
52
53static struct tgfx_config tgfx[TGFX_MAX_PORTS] __initdata;
54 54
55static int tgfx_3[] __initdata = { -1, 0, 0, 0, 0, 0, 0, 0 }; 55module_param_array_named(map, tgfx[0].args, int, &tgfx[0].nargs, 0);
56static int tgfx_nargs_3 __initdata = 0; 56MODULE_PARM_DESC(map, "Describes first set of devices (<parport#>,<js1>,<js2>,..<js7>");
57module_param_array_named(map3, tgfx_3, int, &tgfx_nargs_3, 0); 57module_param_array_named(map2, tgfx[1].args, int, &tgfx[1].nargs, 0);
58MODULE_PARM_DESC(map2, "Describes second set of devices");
59module_param_array_named(map3, tgfx[2].args, int, &tgfx[2].nargs, 0);
58MODULE_PARM_DESC(map3, "Describes third set of devices"); 60MODULE_PARM_DESC(map3, "Describes third set of devices");
59 61
60__obsolete_setup("tgfx="); 62__obsolete_setup("tgfx=");
@@ -75,17 +77,17 @@ __obsolete_setup("tgfx_3=");
75#define TGFX_TOP2 0x08 77#define TGFX_TOP2 0x08
76 78
77static int tgfx_buttons[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2 }; 79static int tgfx_buttons[] = { BTN_TRIGGER, BTN_THUMB, BTN_THUMB2, BTN_TOP, BTN_TOP2 };
78static char *tgfx_name = "TurboGraFX Multisystem joystick";
79 80
80static struct tgfx { 81static struct tgfx {
81 struct pardevice *pd; 82 struct pardevice *pd;
82 struct timer_list timer; 83 struct timer_list timer;
83 struct input_dev dev[7]; 84 struct input_dev *dev[TGFX_MAX_DEVICES];
84 char phys[7][32]; 85 char name[TGFX_MAX_DEVICES][64];
86 char phys[TGFX_MAX_DEVICES][32];
85 int sticks; 87 int sticks;
86 int used; 88 int used;
87 struct semaphore sem; 89 struct semaphore sem;
88} *tgfx_base[3]; 90} *tgfx_base[TGFX_MAX_PORTS];
89 91
90/* 92/*
91 * tgfx_timer() reads and analyzes TurboGraFX joystick data. 93 * tgfx_timer() reads and analyzes TurboGraFX joystick data.
@@ -100,7 +102,7 @@ static void tgfx_timer(unsigned long private)
100 for (i = 0; i < 7; i++) 102 for (i = 0; i < 7; i++)
101 if (tgfx->sticks & (1 << i)) { 103 if (tgfx->sticks & (1 << i)) {
102 104
103 dev = tgfx->dev + i; 105 dev = tgfx->dev[i];
104 106
105 parport_write_data(tgfx->pd->port, ~(1 << i)); 107 parport_write_data(tgfx->pd->port, ~(1 << i));
106 data1 = parport_read_status(tgfx->pd->port) ^ 0x7f; 108 data1 = parport_read_status(tgfx->pd->port) ^ 0x7f;
@@ -153,118 +155,165 @@ static void tgfx_close(struct input_dev *dev)
153 up(&tgfx->sem); 155 up(&tgfx->sem);
154} 156}
155 157
158
159
156/* 160/*
157 * tgfx_probe() probes for tg gamepads. 161 * tgfx_probe() probes for tg gamepads.
158 */ 162 */
159 163
160static struct tgfx __init *tgfx_probe(int *config, int nargs) 164static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
161{ 165{
162 struct tgfx *tgfx; 166 struct tgfx *tgfx;
167 struct input_dev *input_dev;
163 struct parport *pp; 168 struct parport *pp;
169 struct pardevice *pd;
164 int i, j; 170 int i, j;
171 int err;
165 172
166 if (config[0] < 0) 173 pp = parport_find_number(parport);
167 return NULL;
168
169 if (nargs < 2) {
170 printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n");
171 return NULL;
172 }
173
174 pp = parport_find_number(config[0]);
175
176 if (!pp) { 174 if (!pp) {
177 printk(KERN_ERR "turbografx.c: no such parport\n"); 175 printk(KERN_ERR "turbografx.c: no such parport\n");
178 return NULL; 176 err = -EINVAL;
177 goto err_out;
179 } 178 }
180 179
181 if (!(tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL))) { 180 pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
182 parport_put_port(pp); 181 if (!pd) {
183 return NULL; 182 printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n");
183 err = -EBUSY;
184 goto err_put_pp;
184 } 185 }
185 186
186 init_MUTEX(&tgfx->sem); 187 tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL);
187 188 if (!tgfx) {
188 tgfx->pd = parport_register_device(pp, "turbografx", NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); 189 printk(KERN_ERR "turbografx.c: Not enough memory\n");
189 190 err = -ENOMEM;
190 parport_put_port(pp); 191 goto err_unreg_pardev;
191
192 if (!tgfx->pd) {
193 printk(KERN_ERR "turbografx.c: parport busy already - lp.o loaded?\n");
194 kfree(tgfx);
195 return NULL;
196 } 192 }
197 193
194 init_MUTEX(&tgfx->sem);
195 tgfx->pd = pd;
198 init_timer(&tgfx->timer); 196 init_timer(&tgfx->timer);
199 tgfx->timer.data = (long) tgfx; 197 tgfx->timer.data = (long) tgfx;
200 tgfx->timer.function = tgfx_timer; 198 tgfx->timer.function = tgfx_timer;
201 199
202 tgfx->sticks = 0; 200 for (i = 0; i < n_devs; i++) {
201 if (n_buttons[i] < 1)
202 continue;
203 203
204 for (i = 0; i < nargs - 1; i++) 204 if (n_buttons[i] > 6) {
205 if (config[i+1] > 0 && config[i+1] < 6) { 205 printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]);
206 206 err = -EINVAL;
207 tgfx->sticks |= (1 << i); 207 goto err_free_devs;
208 }
208 209
209 tgfx->dev[i].private = tgfx; 210 tgfx->dev[i] = input_dev = input_allocate_device();
210 tgfx->dev[i].open = tgfx_open; 211 if (!input_dev) {
211 tgfx->dev[i].close = tgfx_close; 212 printk(KERN_ERR "turbografx.c: Not enough memory for input device\n");
213 err = -ENOMEM;
214 goto err_free_devs;
215 }
212 216
213 sprintf(tgfx->phys[i], "%s/input0", tgfx->pd->port->name); 217 tgfx->sticks |= (1 << i);
218 snprintf(tgfx->name[i], sizeof(tgfx->name[i]),
219 "TurboGraFX %d-button Multisystem joystick", n_buttons[i]);
220 snprintf(tgfx->phys[i], sizeof(tgfx->phys[i]),
221 "%s/input%d", tgfx->pd->port->name, i);
214 222
215 tgfx->dev[i].name = tgfx_name; 223 input_dev->name = tgfx->name[i];
216 tgfx->dev[i].phys = tgfx->phys[i]; 224 input_dev->phys = tgfx->phys[i];
217 tgfx->dev[i].id.bustype = BUS_PARPORT; 225 input_dev->id.bustype = BUS_PARPORT;
218 tgfx->dev[i].id.vendor = 0x0003; 226 input_dev->id.vendor = 0x0003;
219 tgfx->dev[i].id.product = config[i+1]; 227 input_dev->id.product = n_buttons[i];
220 tgfx->dev[i].id.version = 0x0100; 228 input_dev->id.version = 0x0100;
221 229
222 tgfx->dev[i].evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 230 input_dev->private = tgfx;
223 tgfx->dev[i].absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 231 input_dev->open = tgfx_open;
232 input_dev->close = tgfx_close;
224 233
225 for (j = 0; j < config[i+1]; j++) 234 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
226 set_bit(tgfx_buttons[j], tgfx->dev[i].keybit); 235 input_set_abs_params(input_dev, ABS_X, -1, 1, 0, 0);
236 input_set_abs_params(input_dev, ABS_Y, -1, 1, 0, 0);
227 237
228 tgfx->dev[i].absmin[ABS_X] = -1; tgfx->dev[i].absmax[ABS_X] = 1; 238 for (j = 0; j < n_buttons[i]; j++)
229 tgfx->dev[i].absmin[ABS_Y] = -1; tgfx->dev[i].absmax[ABS_Y] = 1; 239 set_bit(tgfx_buttons[j], input_dev->keybit);
230 240
231 input_register_device(tgfx->dev + i); 241 input_register_device(tgfx->dev[i]);
232 printk(KERN_INFO "input: %d-button Multisystem joystick on %s\n", 242 }
233 config[i+1], tgfx->pd->port->name);
234 }
235 243
236 if (!tgfx->sticks) { 244 if (!tgfx->sticks) {
237 parport_unregister_device(tgfx->pd); 245 printk(KERN_ERR "turbografx.c: No valid devices specified\n");
238 kfree(tgfx); 246 err = -EINVAL;
239 return NULL; 247 goto err_free_tgfx;
240 } 248 }
241 249
242 return tgfx; 250 return tgfx;
251
252 err_free_devs:
253 while (--i >= 0)
254 input_unregister_device(tgfx->dev[i]);
255 err_free_tgfx:
256 kfree(tgfx);
257 err_unreg_pardev:
258 parport_unregister_device(pd);
259 err_put_pp:
260 parport_put_port(pp);
261 err_out:
262 return ERR_PTR(err);
263}
264
265static void __exit tgfx_remove(struct tgfx *tgfx)
266{
267 int i;
268
269 for (i = 0; i < TGFX_MAX_DEVICES; i++)
270 if (tgfx->dev[i])
271 input_unregister_device(tgfx->dev[i]);
272 parport_unregister_device(tgfx->pd);
273 kfree(tgfx);
243} 274}
244 275
245static int __init tgfx_init(void) 276static int __init tgfx_init(void)
246{ 277{
247 tgfx_base[0] = tgfx_probe(tgfx, tgfx_nargs); 278 int i;
248 tgfx_base[1] = tgfx_probe(tgfx_2, tgfx_nargs_2); 279 int have_dev = 0;
249 tgfx_base[2] = tgfx_probe(tgfx_3, tgfx_nargs_3); 280 int err = 0;
281
282 for (i = 0; i < TGFX_MAX_PORTS; i++) {
283 if (tgfx[i].nargs == 0 || tgfx[i].args[0] < 0)
284 continue;
285
286 if (tgfx[i].nargs < 2) {
287 printk(KERN_ERR "turbografx.c: at least one joystick must be specified\n");
288 err = -EINVAL;
289 break;
290 }
291
292 tgfx_base[i] = tgfx_probe(tgfx[i].args[0], tgfx[i].args + 1, tgfx[i].nargs - 1);
293 if (IS_ERR(tgfx_base[i])) {
294 err = PTR_ERR(tgfx_base[i]);
295 break;
296 }
297
298 have_dev = 1;
299 }
250 300
251 if (tgfx_base[0] || tgfx_base[1] || tgfx_base[2]) 301 if (err) {
252 return 0; 302 while (--i >= 0)
303 tgfx_remove(tgfx_base[i]);
304 return err;
305 }
253 306
254 return -ENODEV; 307 return have_dev ? 0 : -ENODEV;
255} 308}
256 309
257static void __exit tgfx_exit(void) 310static void __exit tgfx_exit(void)
258{ 311{
259 int i, j; 312 int i;
260 313
261 for (i = 0; i < 3; i++) 314 for (i = 0; i < TGFX_MAX_PORTS; i++)
262 if (tgfx_base[i]) { 315 if (tgfx_base[i])
263 for (j = 0; j < 7; j++) 316 tgfx_remove(tgfx_base[i]);
264 if (tgfx_base[i]->sticks & (1 << j))
265 input_unregister_device(tgfx_base[i]->dev + j);
266 parport_unregister_device(tgfx_base[i]->pd);
267 }
268} 317}
269 318
270module_init(tgfx_init); 319module_init(tgfx_init);
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 0379bc166525..cd3a1e742a30 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -69,8 +69,6 @@ MODULE_LICENSE("GPL");
69 69
70#define TWIDJOY_MAX_LENGTH 5 70#define TWIDJOY_MAX_LENGTH 5
71 71
72static char *twidjoy_name = "Handykey Twiddler";
73
74static struct twidjoy_button_spec { 72static struct twidjoy_button_spec {
75 int bitshift; 73 int bitshift;
76 int bitmask; 74 int bitmask;
@@ -95,7 +93,7 @@ twidjoy_buttons[] = {
95 */ 93 */
96 94
97struct twidjoy { 95struct twidjoy {
98 struct input_dev dev; 96 struct input_dev *dev;
99 int idx; 97 int idx;
100 unsigned char data[TWIDJOY_MAX_LENGTH]; 98 unsigned char data[TWIDJOY_MAX_LENGTH];
101 char phys[32]; 99 char phys[32];
@@ -108,37 +106,33 @@ struct twidjoy {
108 106
109static void twidjoy_process_packet(struct twidjoy *twidjoy, struct pt_regs *regs) 107static void twidjoy_process_packet(struct twidjoy *twidjoy, struct pt_regs *regs)
110{ 108{
111 if (twidjoy->idx == TWIDJOY_MAX_LENGTH) { 109 struct input_dev *dev = twidjoy->dev;
112 struct input_dev *dev = &twidjoy->dev; 110 unsigned char *data = twidjoy->data;
113 unsigned char *data = twidjoy->data; 111 struct twidjoy_button_spec *bp;
114 struct twidjoy_button_spec *bp; 112 int button_bits, abs_x, abs_y;
115 int button_bits, abs_x, abs_y;
116
117 button_bits = ((data[1] & 0x7f) << 7) | (data[0] & 0x7f);
118 113
119 input_regs(dev, regs); 114 button_bits = ((data[1] & 0x7f) << 7) | (data[0] & 0x7f);
120 115
121 for (bp = twidjoy_buttons; bp->bitmask; bp++) { 116 input_regs(dev, regs);
122 int value = (button_bits & (bp->bitmask << bp->bitshift)) >> bp->bitshift;
123 int i;
124 117
125 for (i = 0; i < bp->bitmask; i++) 118 for (bp = twidjoy_buttons; bp->bitmask; bp++) {
126 input_report_key(dev, bp->buttons[i], i+1 == value); 119 int value = (button_bits & (bp->bitmask << bp->bitshift)) >> bp->bitshift;
127 } 120 int i;
128 121
129 abs_x = ((data[4] & 0x07) << 5) | ((data[3] & 0x7C) >> 2); 122 for (i = 0; i < bp->bitmask; i++)
130 if (data[4] & 0x08) abs_x -= 256; 123 input_report_key(dev, bp->buttons[i], i+1 == value);
124 }
131 125
132 abs_y = ((data[3] & 0x01) << 7) | ((data[2] & 0x7F) >> 0); 126 abs_x = ((data[4] & 0x07) << 5) | ((data[3] & 0x7C) >> 2);
133 if (data[3] & 0x02) abs_y -= 256; 127 if (data[4] & 0x08) abs_x -= 256;
134 128
135 input_report_abs(dev, ABS_X, -abs_x); 129 abs_y = ((data[3] & 0x01) << 7) | ((data[2] & 0x7F) >> 0);
136 input_report_abs(dev, ABS_Y, +abs_y); 130 if (data[3] & 0x02) abs_y -= 256;
137 131
138 input_sync(dev); 132 input_report_abs(dev, ABS_X, -abs_x);
139 } 133 input_report_abs(dev, ABS_Y, +abs_y);
140 134
141 return; 135 input_sync(dev);
142} 136}
143 137
144/* 138/*
@@ -179,9 +173,9 @@ static void twidjoy_disconnect(struct serio *serio)
179{ 173{
180 struct twidjoy *twidjoy = serio_get_drvdata(serio); 174 struct twidjoy *twidjoy = serio_get_drvdata(serio);
181 175
182 input_unregister_device(&twidjoy->dev);
183 serio_close(serio); 176 serio_close(serio);
184 serio_set_drvdata(serio, NULL); 177 serio_set_drvdata(serio, NULL);
178 input_unregister_device(twidjoy->dev);
185 kfree(twidjoy); 179 kfree(twidjoy);
186} 180}
187 181
@@ -195,59 +189,49 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
195{ 189{
196 struct twidjoy_button_spec *bp; 190 struct twidjoy_button_spec *bp;
197 struct twidjoy *twidjoy; 191 struct twidjoy *twidjoy;
192 struct input_dev *input_dev;
193 int err = -ENOMEM;
198 int i; 194 int i;
199 int err;
200
201 if (!(twidjoy = kmalloc(sizeof(struct twidjoy), GFP_KERNEL)))
202 return -ENOMEM;
203 195
204 memset(twidjoy, 0, sizeof(struct twidjoy)); 196 twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
197 input_dev = input_allocate_device();
198 if (!twidjoy || !input_dev)
199 goto fail;
205 200
201 twidjoy->dev = input_dev;
206 sprintf(twidjoy->phys, "%s/input0", serio->phys); 202 sprintf(twidjoy->phys, "%s/input0", serio->phys);
207 203
208 init_input_dev(&twidjoy->dev); 204 input_dev->name = "Handykey Twiddler";
209 twidjoy->dev.name = twidjoy_name; 205 input_dev->phys = twidjoy->phys;
210 twidjoy->dev.phys = twidjoy->phys; 206 input_dev->id.bustype = BUS_RS232;
211 twidjoy->dev.id.bustype = BUS_RS232; 207 input_dev->id.vendor = SERIO_TWIDJOY;
212 twidjoy->dev.id.vendor = SERIO_TWIDJOY; 208 input_dev->id.product = 0x0001;
213 twidjoy->dev.id.product = 0x0001; 209 input_dev->id.version = 0x0100;
214 twidjoy->dev.id.version = 0x0100; 210 input_dev->cdev.dev = &serio->dev;
215 twidjoy->dev.dev = &serio->dev; 211 input_dev->private = twidjoy;
216 212
217 twidjoy->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 213 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
218 214 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
219 for (bp = twidjoy_buttons; bp->bitmask; bp++) { 215 input_set_abs_params(input_dev, ABS_X, -50, 50, 4, 4);
216 input_set_abs_params(input_dev, ABS_Y, -50, 50, 4, 4);
217
218 for (bp = twidjoy_buttons; bp->bitmask; bp++)
220 for (i = 0; i < bp->bitmask; i++) 219 for (i = 0; i < bp->bitmask; i++)
221 set_bit(bp->buttons[i], twidjoy->dev.keybit); 220 set_bit(bp->buttons[i], input_dev->keybit);
222 }
223
224 twidjoy->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
225
226 for (i = 0; i < 2; i++) {
227 twidjoy->dev.absmax[ABS_X+i] = 50;
228 twidjoy->dev.absmin[ABS_X+i] = -50;
229
230 /* TODO: arndt 20010708: Are these values appropriate? */
231 twidjoy->dev.absfuzz[ABS_X+i] = 4;
232 twidjoy->dev.absflat[ABS_X+i] = 4;
233 }
234
235 twidjoy->dev.private = twidjoy;
236 221
237 serio_set_drvdata(serio, twidjoy); 222 serio_set_drvdata(serio, twidjoy);
238 223
239 err = serio_open(serio, drv); 224 err = serio_open(serio, drv);
240 if (err) { 225 if (err)
241 serio_set_drvdata(serio, NULL); 226 goto fail;
242 kfree(twidjoy);
243 return err;
244 }
245
246 input_register_device(&twidjoy->dev);
247
248 printk(KERN_INFO "input: %s on %s\n", twidjoy_name, serio->phys);
249 227
228 input_register_device(twidjoy->dev);
250 return 0; 229 return 0;
230
231 fail: serio_set_drvdata(serio, NULL);
232 input_free_device(input_dev);
233 kfree(twidjoy);
234 return err;
251} 235}
252 236
253/* 237/*
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index 6976a219504c..99a642d2a1fe 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -47,14 +47,13 @@ MODULE_LICENSE("GPL");
47 47
48#define WARRIOR_MAX_LENGTH 16 48#define WARRIOR_MAX_LENGTH 16
49static char warrior_lengths[] = { 0, 4, 12, 3, 4, 4, 0, 0 }; 49static char warrior_lengths[] = { 0, 4, 12, 3, 4, 4, 0, 0 };
50static char *warrior_name = "Logitech WingMan Warrior";
51 50
52/* 51/*
53 * Per-Warrior data. 52 * Per-Warrior data.
54 */ 53 */
55 54
56struct warrior { 55struct warrior {
57 struct input_dev dev; 56 struct input_dev *dev;
58 int idx, len; 57 int idx, len;
59 unsigned char data[WARRIOR_MAX_LENGTH]; 58 unsigned char data[WARRIOR_MAX_LENGTH];
60 char phys[32]; 59 char phys[32];
@@ -67,7 +66,7 @@ struct warrior {
67 66
68static void warrior_process_packet(struct warrior *warrior, struct pt_regs *regs) 67static void warrior_process_packet(struct warrior *warrior, struct pt_regs *regs)
69{ 68{
70 struct input_dev *dev = &warrior->dev; 69 struct input_dev *dev = warrior->dev;
71 unsigned char *data = warrior->data; 70 unsigned char *data = warrior->data;
72 71
73 if (!warrior->idx) return; 72 if (!warrior->idx) return;
@@ -131,9 +130,9 @@ static void warrior_disconnect(struct serio *serio)
131{ 130{
132 struct warrior *warrior = serio_get_drvdata(serio); 131 struct warrior *warrior = serio_get_drvdata(serio);
133 132
134 input_unregister_device(&warrior->dev);
135 serio_close(serio); 133 serio_close(serio);
136 serio_set_drvdata(serio, NULL); 134 serio_set_drvdata(serio, NULL);
135 input_unregister_device(warrior->dev);
137 kfree(warrior); 136 kfree(warrior);
138} 137}
139 138
@@ -146,60 +145,48 @@ static void warrior_disconnect(struct serio *serio)
146static int warrior_connect(struct serio *serio, struct serio_driver *drv) 145static int warrior_connect(struct serio *serio, struct serio_driver *drv)
147{ 146{
148 struct warrior *warrior; 147 struct warrior *warrior;
149 int i; 148 struct input_dev *input_dev;
150 int err; 149 int err = -ENOMEM;
151 150
152 if (!(warrior = kmalloc(sizeof(struct warrior), GFP_KERNEL))) 151 warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL);
153 return -ENOMEM; 152 input_dev = input_allocate_device();
154 153 if (!warrior || !input_dev)
155 memset(warrior, 0, sizeof(struct warrior)); 154 goto fail;
156
157 warrior->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
158 warrior->dev.keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2);
159 warrior->dev.relbit[0] = BIT(REL_DIAL);
160 warrior->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_HAT0X) | BIT(ABS_HAT0Y);
161 155
156 warrior->dev = input_dev;
162 sprintf(warrior->phys, "%s/input0", serio->phys); 157 sprintf(warrior->phys, "%s/input0", serio->phys);
163 158
164 init_input_dev(&warrior->dev); 159 input_dev->name = "Logitech WingMan Warrior";
165 warrior->dev.name = warrior_name; 160 input_dev->phys = warrior->phys;
166 warrior->dev.phys = warrior->phys; 161 input_dev->id.bustype = BUS_RS232;
167 warrior->dev.id.bustype = BUS_RS232; 162 input_dev->id.vendor = SERIO_WARRIOR;
168 warrior->dev.id.vendor = SERIO_WARRIOR; 163 input_dev->id.product = 0x0001;
169 warrior->dev.id.product = 0x0001; 164 input_dev->id.version = 0x0100;
170 warrior->dev.id.version = 0x0100; 165 input_dev->cdev.dev = &serio->dev;
171 warrior->dev.dev = &serio->dev; 166 input_dev->private = warrior;
172 167
173 for (i = 0; i < 2; i++) { 168 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_ABS);
174 warrior->dev.absmax[ABS_X+i] = -64; 169 input_dev->keybit[LONG(BTN_TRIGGER)] = BIT(BTN_TRIGGER) | BIT(BTN_THUMB) | BIT(BTN_TOP) | BIT(BTN_TOP2);
175 warrior->dev.absmin[ABS_X+i] = 64; 170 input_dev->relbit[0] = BIT(REL_DIAL);
176 warrior->dev.absflat[ABS_X+i] = 8; 171 input_set_abs_params(input_dev, ABS_X, -64, 64, 0, 8);
177 } 172 input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8);
178 173 input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0);
179 warrior->dev.absmax[ABS_THROTTLE] = -112; 174 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
180 warrior->dev.absmin[ABS_THROTTLE] = 112; 175 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
181
182 for (i = 0; i < 2; i++) {
183 warrior->dev.absmax[ABS_HAT0X+i] = -1;
184 warrior->dev.absmin[ABS_HAT0X+i] = 1;
185 }
186
187 warrior->dev.private = warrior;
188 176
189 serio_set_drvdata(serio, warrior); 177 serio_set_drvdata(serio, warrior);
190 178
191 err = serio_open(serio, drv); 179 err = serio_open(serio, drv);
192 if (err) { 180 if (err)
193 serio_set_drvdata(serio, NULL); 181 goto fail;
194 kfree(warrior);
195 return err;
196 }
197
198 input_register_device(&warrior->dev);
199
200 printk(KERN_INFO "input: Logitech WingMan Warrior on %s\n", serio->phys);
201 182
183 input_register_device(warrior->dev);
202 return 0; 184 return 0;
185
186 fail: serio_set_drvdata(serio, NULL);
187 input_free_device(input_dev);
188 kfree(warrior);
189 return err;
203} 190}
204 191
205/* 192/*
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index 4e8e8ea214ab..3d63bc1ad322 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -155,10 +155,7 @@ static const char *amikbd_messages[8] = {
155 [7] = KERN_WARNING "amikbd: keyboard interrupt\n" 155 [7] = KERN_WARNING "amikbd: keyboard interrupt\n"
156}; 156};
157 157
158static struct input_dev amikbd_dev; 158static struct input_dev *amikbd_dev;
159
160static char *amikbd_name = "Amiga keyboard";
161static char *amikbd_phys = "amikbd/input0";
162 159
163static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) 160static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp)
164{ 161{
@@ -176,16 +173,16 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp)
176 173
177 scancode = amikbd_keycode[scancode]; 174 scancode = amikbd_keycode[scancode];
178 175
179 input_regs(&amikbd_dev, fp); 176 input_regs(amikbd_dev, fp);
180 177
181 if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ 178 if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */
182 input_report_key(&amikbd_dev, scancode, 1); 179 input_report_key(amikbd_dev, scancode, 1);
183 input_report_key(&amikbd_dev, scancode, 0); 180 input_report_key(amikbd_dev, scancode, 0);
184 input_sync(&amikbd_dev);
185 } else { 181 } else {
186 input_report_key(&amikbd_dev, scancode, down); 182 input_report_key(amikbd_dev, scancode, down);
187 input_sync(&amikbd_dev);
188 } 183 }
184
185 input_sync(amikbd_dev);
189 } else /* scancodes >= 0x78 are error codes */ 186 } else /* scancodes >= 0x78 are error codes */
190 printk(amikbd_messages[scancode - 0x78]); 187 printk(amikbd_messages[scancode - 0x78]);
191 188
@@ -202,39 +199,41 @@ static int __init amikbd_init(void)
202 if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) 199 if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb"))
203 return -EBUSY; 200 return -EBUSY;
204 201
205 init_input_dev(&amikbd_dev); 202 amikbd_dev = input_dev_allocate();
206 203 if (!amikbd_dev) {
207 amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 204 printk(KERN_ERR "amikbd: not enough memory for input device\n");
208 amikbd_dev.keycode = amikbd_keycode; 205 release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
209 amikbd_dev.keycodesize = sizeof(unsigned char); 206 return -ENOMEM;
210 amikbd_dev.keycodemax = ARRAY_SIZE(amikbd_keycode); 207 }
208
209 amikbd_dev->name = "Amiga Keyboard";
210 amikbd_dev->phys = "amikbd/input0";
211 amikbd_dev->id.bustype = BUS_AMIGA;
212 amikbd_dev->id.vendor = 0x0001;
213 amikbd_dev->id.product = 0x0001;
214 amikbd_dev->id.version = 0x0100;
215
216 amikbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
217 amikbd_dev->keycode = amikbd_keycode;
218 amikbd_dev->keycodesize = sizeof(unsigned char);
219 amikbd_dev->keycodemax = ARRAY_SIZE(amikbd_keycode);
211 220
212 for (i = 0; i < 0x78; i++) 221 for (i = 0; i < 0x78; i++)
213 if (amikbd_keycode[i]) 222 if (amikbd_keycode[i])
214 set_bit(amikbd_keycode[i], amikbd_dev.keybit); 223 set_bit(amikbd_keycode[i], amikbd_dev->keybit);
215 224
216 ciaa.cra &= ~0x41; /* serial data in, turn off TA */ 225 ciaa.cra &= ~0x41; /* serial data in, turn off TA */
217 request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); 226 request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt);
218 227
219 amikbd_dev.name = amikbd_name; 228 input_register_device(amikbd_dev);
220 amikbd_dev.phys = amikbd_phys;
221 amikbd_dev.id.bustype = BUS_AMIGA;
222 amikbd_dev.id.vendor = 0x0001;
223 amikbd_dev.id.product = 0x0001;
224 amikbd_dev.id.version = 0x0100;
225
226 input_register_device(&amikbd_dev);
227
228 printk(KERN_INFO "input: %s\n", amikbd_name);
229
230 return 0; 229 return 0;
231} 230}
232 231
233static void __exit amikbd_exit(void) 232static void __exit amikbd_exit(void)
234{ 233{
235 input_unregister_device(&amikbd_dev);
236 free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); 234 free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt);
237 release_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100); 235 input_unregister_device(amikbd_dev);
236 release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100);
238} 237}
239 238
240module_init(amikbd_init); 239module_init(amikbd_init);
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 1ad8c2ee7dbf..820c7fd9a604 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -185,12 +185,12 @@ static struct {
185 185
186struct atkbd { 186struct atkbd {
187 187
188 struct ps2dev ps2dev; 188 struct ps2dev ps2dev;
189 struct input_dev *dev;
189 190
190 /* Written only during init */ 191 /* Written only during init */
191 char name[64]; 192 char name[64];
192 char phys[32]; 193 char phys[32];
193 struct input_dev dev;
194 194
195 unsigned short id; 195 unsigned short id;
196 unsigned char keycode[512]; 196 unsigned char keycode[512];
@@ -290,7 +290,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
290 if (!atkbd->enabled) 290 if (!atkbd->enabled)
291 goto out; 291 goto out;
292 292
293 input_event(&atkbd->dev, EV_MSC, MSC_RAW, code); 293 input_event(atkbd->dev, EV_MSC, MSC_RAW, code);
294 294
295 if (atkbd->translated) { 295 if (atkbd->translated) {
296 296
@@ -326,10 +326,10 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
326 atkbd->release = 1; 326 atkbd->release = 1;
327 goto out; 327 goto out;
328 case ATKBD_RET_HANGUEL: 328 case ATKBD_RET_HANGUEL:
329 atkbd_report_key(&atkbd->dev, regs, KEY_HANGUEL, 3); 329 atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3);
330 goto out; 330 goto out;
331 case ATKBD_RET_HANJA: 331 case ATKBD_RET_HANJA:
332 atkbd_report_key(&atkbd->dev, regs, KEY_HANJA, 3); 332 atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3);
333 goto out; 333 goto out;
334 case ATKBD_RET_ERR: 334 case ATKBD_RET_ERR:
335 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 335 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys);
@@ -345,7 +345,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
345 } 345 }
346 346
347 if (atkbd->keycode[code] != ATKBD_KEY_NULL) 347 if (atkbd->keycode[code] != ATKBD_KEY_NULL)
348 input_event(&atkbd->dev, EV_MSC, MSC_SCAN, code); 348 input_event(atkbd->dev, EV_MSC, MSC_SCAN, code);
349 349
350 switch (atkbd->keycode[code]) { 350 switch (atkbd->keycode[code]) {
351 case ATKBD_KEY_NULL: 351 case ATKBD_KEY_NULL:
@@ -365,7 +365,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
365 "to make it known.\n", 365 "to make it known.\n",
366 code & 0x80 ? "e0" : "", code & 0x7f); 366 code & 0x80 ? "e0" : "", code & 0x7f);
367 } 367 }
368 input_sync(&atkbd->dev); 368 input_sync(atkbd->dev);
369 break; 369 break;
370 case ATKBD_SCR_1: 370 case ATKBD_SCR_1:
371 scroll = 1 - atkbd->release * 2; 371 scroll = 1 - atkbd->release * 2;
@@ -390,7 +390,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
390 break; 390 break;
391 default: 391 default:
392 value = atkbd->release ? 0 : 392 value = atkbd->release ? 0 :
393 (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); 393 (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key)));
394 394
395 switch (value) { /* Workaround Toshiba laptop multiple keypress */ 395 switch (value) { /* Workaround Toshiba laptop multiple keypress */
396 case 0: 396 case 0:
@@ -398,7 +398,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
398 break; 398 break;
399 case 1: 399 case 1:
400 atkbd->last = code; 400 atkbd->last = code;
401 atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev.rep[REP_DELAY]) / 2; 401 atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev->rep[REP_DELAY]) / 2;
402 break; 402 break;
403 case 2: 403 case 2:
404 if (!time_after(jiffies, atkbd->time) && atkbd->last == code) 404 if (!time_after(jiffies, atkbd->time) && atkbd->last == code)
@@ -406,16 +406,16 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
406 break; 406 break;
407 } 407 }
408 408
409 atkbd_report_key(&atkbd->dev, regs, atkbd->keycode[code], value); 409 atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value);
410 } 410 }
411 411
412 if (atkbd->scroll) { 412 if (atkbd->scroll) {
413 input_regs(&atkbd->dev, regs); 413 input_regs(atkbd->dev, regs);
414 if (click != -1) 414 if (click != -1)
415 input_report_key(&atkbd->dev, BTN_MIDDLE, click); 415 input_report_key(atkbd->dev, BTN_MIDDLE, click);
416 input_report_rel(&atkbd->dev, REL_WHEEL, scroll); 416 input_report_rel(atkbd->dev, REL_WHEEL, scroll);
417 input_report_rel(&atkbd->dev, REL_HWHEEL, hscroll); 417 input_report_rel(atkbd->dev, REL_HWHEEL, hscroll);
418 input_sync(&atkbd->dev); 418 input_sync(atkbd->dev);
419 } 419 }
420 420
421 atkbd->release = 0; 421 atkbd->release = 0;
@@ -463,7 +463,6 @@ static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int co
463 463
464 return 0; 464 return 0;
465 465
466
467 case EV_REP: 466 case EV_REP:
468 467
469 if (atkbd->softrepeat) return 0; 468 if (atkbd->softrepeat) return 0;
@@ -693,7 +692,7 @@ static void atkbd_disconnect(struct serio *serio)
693 device_remove_file(&serio->dev, &atkbd_attr_softrepeat); 692 device_remove_file(&serio->dev, &atkbd_attr_softrepeat);
694 device_remove_file(&serio->dev, &atkbd_attr_softraw); 693 device_remove_file(&serio->dev, &atkbd_attr_softraw);
695 694
696 input_unregister_device(&atkbd->dev); 695 input_unregister_device(atkbd->dev);
697 serio_close(serio); 696 serio_close(serio);
698 serio_set_drvdata(serio, NULL); 697 serio_set_drvdata(serio, NULL);
699 kfree(atkbd); 698 kfree(atkbd);
@@ -701,7 +700,7 @@ static void atkbd_disconnect(struct serio *serio)
701 700
702 701
703/* 702/*
704 * atkbd_set_device_attrs() initializes keyboard's keycode table 703 * atkbd_set_keycode_table() initializes keyboard's keycode table
705 * according to the selected scancode set 704 * according to the selected scancode set
706 */ 705 */
707 706
@@ -737,53 +736,58 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd)
737 736
738static void atkbd_set_device_attrs(struct atkbd *atkbd) 737static void atkbd_set_device_attrs(struct atkbd *atkbd)
739{ 738{
739 struct input_dev *input_dev = atkbd->dev;
740 int i; 740 int i;
741 741
742 memset(&atkbd->dev, 0, sizeof(struct input_dev)); 742 if (atkbd->extra)
743 sprintf(atkbd->name, "AT Set 2 Extra keyboard");
744 else
745 sprintf(atkbd->name, "AT %s Set %d keyboard",
746 atkbd->translated ? "Translated" : "Raw", atkbd->set);
743 747
744 init_input_dev(&atkbd->dev); 748 sprintf(atkbd->phys, "%s/input0", atkbd->ps2dev.serio->phys);
745 749
746 atkbd->dev.name = atkbd->name; 750 input_dev->name = atkbd->name;
747 atkbd->dev.phys = atkbd->phys; 751 input_dev->phys = atkbd->phys;
748 atkbd->dev.id.bustype = BUS_I8042; 752 input_dev->id.bustype = BUS_I8042;
749 atkbd->dev.id.vendor = 0x0001; 753 input_dev->id.vendor = 0x0001;
750 atkbd->dev.id.product = atkbd->translated ? 1 : atkbd->set; 754 input_dev->id.product = atkbd->translated ? 1 : atkbd->set;
751 atkbd->dev.id.version = atkbd->id; 755 input_dev->id.version = atkbd->id;
752 atkbd->dev.event = atkbd_event; 756 input_dev->event = atkbd_event;
753 atkbd->dev.private = atkbd; 757 input_dev->private = atkbd;
754 atkbd->dev.dev = &atkbd->ps2dev.serio->dev; 758 input_dev->cdev.dev = &atkbd->ps2dev.serio->dev;
755 759
756 atkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); 760 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC);
757 761
758 if (atkbd->write) { 762 if (atkbd->write) {
759 atkbd->dev.evbit[0] |= BIT(EV_LED); 763 input_dev->evbit[0] |= BIT(EV_LED);
760 atkbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); 764 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
761 } 765 }
762 766
763 if (atkbd->extra) 767 if (atkbd->extra)
764 atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | 768 input_dev->ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) |
765 BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); 769 BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC);
766 770
767 if (!atkbd->softrepeat) { 771 if (!atkbd->softrepeat) {
768 atkbd->dev.rep[REP_DELAY] = 250; 772 input_dev->rep[REP_DELAY] = 250;
769 atkbd->dev.rep[REP_PERIOD] = 33; 773 input_dev->rep[REP_PERIOD] = 33;
770 } 774 }
771 775
772 atkbd->dev.mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); 776 input_dev->mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN);
773 777
774 if (atkbd->scroll) { 778 if (atkbd->scroll) {
775 atkbd->dev.evbit[0] |= BIT(EV_REL); 779 input_dev->evbit[0] |= BIT(EV_REL);
776 atkbd->dev.relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); 780 input_dev->relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL);
777 set_bit(BTN_MIDDLE, atkbd->dev.keybit); 781 set_bit(BTN_MIDDLE, input_dev->keybit);
778 } 782 }
779 783
780 atkbd->dev.keycode = atkbd->keycode; 784 input_dev->keycode = atkbd->keycode;
781 atkbd->dev.keycodesize = sizeof(unsigned char); 785 input_dev->keycodesize = sizeof(unsigned char);
782 atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode); 786 input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
783 787
784 for (i = 0; i < 512; i++) 788 for (i = 0; i < 512; i++)
785 if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) 789 if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL)
786 set_bit(atkbd->keycode[i], atkbd->dev.keybit); 790 set_bit(atkbd->keycode[i], input_dev->keybit);
787} 791}
788 792
789/* 793/*
@@ -796,13 +800,15 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
796static int atkbd_connect(struct serio *serio, struct serio_driver *drv) 800static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
797{ 801{
798 struct atkbd *atkbd; 802 struct atkbd *atkbd;
799 int err; 803 struct input_dev *dev;
800 804 int err = -ENOMEM;
801 if (!(atkbd = kmalloc(sizeof(struct atkbd), GFP_KERNEL)))
802 return - ENOMEM;
803 805
804 memset(atkbd, 0, sizeof(struct atkbd)); 806 atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL);
807 dev = input_allocate_device();
808 if (!atkbd || !dev)
809 goto fail;
805 810
811 atkbd->dev = dev;
806 ps2_init(&atkbd->ps2dev, serio); 812 ps2_init(&atkbd->ps2dev, serio);
807 813
808 switch (serio->id.type) { 814 switch (serio->id.type) {
@@ -828,19 +834,15 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
828 serio_set_drvdata(serio, atkbd); 834 serio_set_drvdata(serio, atkbd);
829 835
830 err = serio_open(serio, drv); 836 err = serio_open(serio, drv);
831 if (err) { 837 if (err)
832 serio_set_drvdata(serio, NULL); 838 goto fail;
833 kfree(atkbd);
834 return err;
835 }
836 839
837 if (atkbd->write) { 840 if (atkbd->write) {
838 841
839 if (atkbd_probe(atkbd)) { 842 if (atkbd_probe(atkbd)) {
840 serio_close(serio); 843 serio_close(serio);
841 serio_set_drvdata(serio, NULL); 844 err = -ENODEV;
842 kfree(atkbd); 845 goto fail;
843 return -ENODEV;
844 } 846 }
845 847
846 atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); 848 atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra);
@@ -851,19 +853,9 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
851 atkbd->id = 0xab00; 853 atkbd->id = 0xab00;
852 } 854 }
853 855
854 if (atkbd->extra)
855 sprintf(atkbd->name, "AT Set 2 Extra keyboard");
856 else
857 sprintf(atkbd->name, "AT %s Set %d keyboard",
858 atkbd->translated ? "Translated" : "Raw", atkbd->set);
859
860 sprintf(atkbd->phys, "%s/input0", serio->phys);
861
862 atkbd_set_keycode_table(atkbd); 856 atkbd_set_keycode_table(atkbd);
863 atkbd_set_device_attrs(atkbd); 857 atkbd_set_device_attrs(atkbd);
864 858
865 input_register_device(&atkbd->dev);
866
867 device_create_file(&serio->dev, &atkbd_attr_extra); 859 device_create_file(&serio->dev, &atkbd_attr_extra);
868 device_create_file(&serio->dev, &atkbd_attr_scroll); 860 device_create_file(&serio->dev, &atkbd_attr_scroll);
869 device_create_file(&serio->dev, &atkbd_attr_set); 861 device_create_file(&serio->dev, &atkbd_attr_set);
@@ -872,9 +864,14 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
872 864
873 atkbd_enable(atkbd); 865 atkbd_enable(atkbd);
874 866
875 printk(KERN_INFO "input: %s on %s\n", atkbd->name, serio->phys); 867 input_register_device(atkbd->dev);
876 868
877 return 0; 869 return 0;
870
871 fail: serio_set_drvdata(serio, NULL);
872 input_free_device(dev);
873 kfree(atkbd);
874 return err;
878} 875}
879 876
880/* 877/*
@@ -896,9 +893,9 @@ static int atkbd_reconnect(struct serio *serio)
896 atkbd_disable(atkbd); 893 atkbd_disable(atkbd);
897 894
898 if (atkbd->write) { 895 if (atkbd->write) {
899 param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) 896 param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0)
900 | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) 897 | (test_bit(LED_NUML, atkbd->dev->led) ? 2 : 0)
901 | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); 898 | (test_bit(LED_CAPSL, atkbd->dev->led) ? 4 : 0);
902 899
903 if (atkbd_probe(atkbd)) 900 if (atkbd_probe(atkbd))
904 return -1; 901 return -1;
@@ -1008,6 +1005,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
1008 1005
1009static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) 1006static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
1010{ 1007{
1008 struct input_dev *new_dev;
1011 unsigned long value; 1009 unsigned long value;
1012 char *rest; 1010 char *rest;
1013 1011
@@ -1019,12 +1017,19 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
1019 return -EINVAL; 1017 return -EINVAL;
1020 1018
1021 if (atkbd->extra != value) { 1019 if (atkbd->extra != value) {
1022 /* unregister device as it's properties will change */ 1020 /*
1023 input_unregister_device(&atkbd->dev); 1021 * Since device's properties will change we need to
1022 * unregister old device. But allocate new one first
1023 * to make sure we have it.
1024 */
1025 if (!(new_dev = input_allocate_device()))
1026 return -ENOMEM;
1027 input_unregister_device(atkbd->dev);
1028 atkbd->dev = new_dev;
1024 atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); 1029 atkbd->set = atkbd_select_set(atkbd, atkbd->set, value);
1025 atkbd_activate(atkbd); 1030 atkbd_activate(atkbd);
1026 atkbd_set_device_attrs(atkbd); 1031 atkbd_set_device_attrs(atkbd);
1027 input_register_device(&atkbd->dev); 1032 input_register_device(atkbd->dev);
1028 } 1033 }
1029 return count; 1034 return count;
1030} 1035}
@@ -1036,6 +1041,7 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
1036 1041
1037static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) 1042static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
1038{ 1043{
1044 struct input_dev *new_dev;
1039 unsigned long value; 1045 unsigned long value;
1040 char *rest; 1046 char *rest;
1041 1047
@@ -1044,12 +1050,14 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou
1044 return -EINVAL; 1050 return -EINVAL;
1045 1051
1046 if (atkbd->scroll != value) { 1052 if (atkbd->scroll != value) {
1047 /* unregister device as it's properties will change */ 1053 if (!(new_dev = input_allocate_device()))
1048 input_unregister_device(&atkbd->dev); 1054 return -ENOMEM;
1055 input_unregister_device(atkbd->dev);
1056 atkbd->dev = new_dev;
1049 atkbd->scroll = value; 1057 atkbd->scroll = value;
1050 atkbd_set_keycode_table(atkbd); 1058 atkbd_set_keycode_table(atkbd);
1051 atkbd_set_device_attrs(atkbd); 1059 atkbd_set_device_attrs(atkbd);
1052 input_register_device(&atkbd->dev); 1060 input_register_device(atkbd->dev);
1053 } 1061 }
1054 return count; 1062 return count;
1055} 1063}
@@ -1061,6 +1069,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
1061 1069
1062static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) 1070static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1063{ 1071{
1072 struct input_dev *new_dev;
1064 unsigned long value; 1073 unsigned long value;
1065 char *rest; 1074 char *rest;
1066 1075
@@ -1072,13 +1081,15 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
1072 return -EINVAL; 1081 return -EINVAL;
1073 1082
1074 if (atkbd->set != value) { 1083 if (atkbd->set != value) {
1075 /* unregister device as it's properties will change */ 1084 if (!(new_dev = input_allocate_device()))
1076 input_unregister_device(&atkbd->dev); 1085 return -ENOMEM;
1086 input_unregister_device(atkbd->dev);
1087 atkbd->dev = new_dev;
1077 atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); 1088 atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra);
1078 atkbd_activate(atkbd); 1089 atkbd_activate(atkbd);
1079 atkbd_set_keycode_table(atkbd); 1090 atkbd_set_keycode_table(atkbd);
1080 atkbd_set_device_attrs(atkbd); 1091 atkbd_set_device_attrs(atkbd);
1081 input_register_device(&atkbd->dev); 1092 input_register_device(atkbd->dev);
1082 } 1093 }
1083 return count; 1094 return count;
1084} 1095}
@@ -1090,6 +1101,7 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
1090 1101
1091static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) 1102static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
1092{ 1103{
1104 struct input_dev *new_dev;
1093 unsigned long value; 1105 unsigned long value;
1094 char *rest; 1106 char *rest;
1095 1107
@@ -1101,15 +1113,16 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t
1101 return -EINVAL; 1113 return -EINVAL;
1102 1114
1103 if (atkbd->softrepeat != value) { 1115 if (atkbd->softrepeat != value) {
1104 /* unregister device as it's properties will change */ 1116 if (!(new_dev = input_allocate_device()))
1105 input_unregister_device(&atkbd->dev); 1117 return -ENOMEM;
1118 input_unregister_device(atkbd->dev);
1119 atkbd->dev = new_dev;
1106 atkbd->softrepeat = value; 1120 atkbd->softrepeat = value;
1107 if (atkbd->softrepeat) 1121 if (atkbd->softrepeat)
1108 atkbd->softraw = 1; 1122 atkbd->softraw = 1;
1109 atkbd_set_device_attrs(atkbd); 1123 atkbd_set_device_attrs(atkbd);
1110 input_register_device(&atkbd->dev); 1124 input_register_device(atkbd->dev);
1111 } 1125 }
1112
1113 return count; 1126 return count;
1114} 1127}
1115 1128
@@ -1121,6 +1134,7 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
1121 1134
1122static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) 1135static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
1123{ 1136{
1137 struct input_dev *new_dev;
1124 unsigned long value; 1138 unsigned long value;
1125 char *rest; 1139 char *rest;
1126 1140
@@ -1129,11 +1143,13 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1129 return -EINVAL; 1143 return -EINVAL;
1130 1144
1131 if (atkbd->softraw != value) { 1145 if (atkbd->softraw != value) {
1132 /* unregister device as it's properties will change */ 1146 if (!(new_dev = input_allocate_device()))
1133 input_unregister_device(&atkbd->dev); 1147 return -ENOMEM;
1148 input_unregister_device(atkbd->dev);
1149 atkbd->dev = new_dev;
1134 atkbd->softraw = value; 1150 atkbd->softraw = value;
1135 atkbd_set_device_attrs(atkbd); 1151 atkbd_set_device_attrs(atkbd);
1136 input_register_device(&atkbd->dev); 1152 input_register_device(atkbd->dev);
1137 } 1153 }
1138 return count; 1154 return count;
1139} 1155}
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index cd4b6e795013..3210d298b3bc 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -70,8 +70,7 @@ static unsigned char corgikbd_keycode[NR_SCANCODES] = {
70 70
71struct corgikbd { 71struct corgikbd {
72 unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; 72 unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)];
73 struct input_dev input; 73 struct input_dev *input;
74 char phys[32];
75 74
76 spinlock_t lock; 75 spinlock_t lock;
77 struct timer_list timer; 76 struct timer_list timer;
@@ -147,7 +146,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs
147 spin_lock_irqsave(&corgikbd_data->lock, flags); 146 spin_lock_irqsave(&corgikbd_data->lock, flags);
148 147
149 if (regs) 148 if (regs)
150 input_regs(&corgikbd_data->input, regs); 149 input_regs(corgikbd_data->input, regs);
151 150
152 num_pressed = 0; 151 num_pressed = 0;
153 for (col = 0; col < KB_COLS; col++) { 152 for (col = 0; col < KB_COLS; col++) {
@@ -169,14 +168,14 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs
169 scancode = SCANCODE(row, col); 168 scancode = SCANCODE(row, col);
170 pressed = rowd & KB_ROWMASK(row); 169 pressed = rowd & KB_ROWMASK(row);
171 170
172 input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); 171 input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);
173 172
174 if (pressed) 173 if (pressed)
175 num_pressed++; 174 num_pressed++;
176 175
177 if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) 176 if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
178 && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { 177 && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
179 input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); 178 input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
180 corgikbd_data->suspend_jiffies=jiffies; 179 corgikbd_data->suspend_jiffies=jiffies;
181 } 180 }
182 } 181 }
@@ -185,7 +184,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs
185 184
186 corgikbd_activate_all(); 185 corgikbd_activate_all();
187 186
188 input_sync(&corgikbd_data->input); 187 input_sync(corgikbd_data->input);
189 188
190 /* if any keys are pressed, enable the timer */ 189 /* if any keys are pressed, enable the timer */
191 if (num_pressed) 190 if (num_pressed)
@@ -249,9 +248,9 @@ static void corgikbd_hinge_timer(unsigned long data)
249 if (hinge_count >= HINGE_STABLE_COUNT) { 248 if (hinge_count >= HINGE_STABLE_COUNT) {
250 spin_lock_irqsave(&corgikbd_data->lock, flags); 249 spin_lock_irqsave(&corgikbd_data->lock, flags);
251 250
252 input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); 251 input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
253 input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); 252 input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
254 input_sync(&corgikbd_data->input); 253 input_sync(corgikbd_data->input);
255 254
256 spin_unlock_irqrestore(&corgikbd_data->lock, flags); 255 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
257 } 256 }
@@ -260,24 +259,22 @@ static void corgikbd_hinge_timer(unsigned long data)
260} 259}
261 260
262#ifdef CONFIG_PM 261#ifdef CONFIG_PM
263static int corgikbd_suspend(struct device *dev, pm_message_t state, uint32_t level) 262static int corgikbd_suspend(struct device *dev, pm_message_t state)
264{ 263{
265 if (level == SUSPEND_POWER_DOWN) { 264 struct corgikbd *corgikbd = dev_get_drvdata(dev);
266 struct corgikbd *corgikbd = dev_get_drvdata(dev); 265 corgikbd->suspended = 1;
267 corgikbd->suspended = 1; 266
268 }
269 return 0; 267 return 0;
270} 268}
271 269
272static int corgikbd_resume(struct device *dev, uint32_t level) 270static int corgikbd_resume(struct device *dev)
273{ 271{
274 if (level == RESUME_POWER_ON) { 272 struct corgikbd *corgikbd = dev_get_drvdata(dev);
275 struct corgikbd *corgikbd = dev_get_drvdata(dev); 273
274 /* Upon resume, ignore the suspend key for a short while */
275 corgikbd->suspend_jiffies=jiffies;
276 corgikbd->suspended = 0;
276 277
277 /* Upon resume, ignore the suspend key for a short while */
278 corgikbd->suspend_jiffies=jiffies;
279 corgikbd->suspended = 0;
280 }
281 return 0; 278 return 0;
282} 279}
283#else 280#else
@@ -287,16 +284,21 @@ static int corgikbd_resume(struct device *dev, uint32_t level)
287 284
288static int __init corgikbd_probe(struct device *dev) 285static int __init corgikbd_probe(struct device *dev)
289{ 286{
290 int i;
291 struct corgikbd *corgikbd; 287 struct corgikbd *corgikbd;
288 struct input_dev *input_dev;
289 int i;
292 290
293 corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); 291 corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL);
294 if (!corgikbd) 292 input_dev = input_allocate_device();
293 if (!corgikbd || !input_dev) {
294 kfree(corgikbd);
295 input_free_device(input_dev);
295 return -ENOMEM; 296 return -ENOMEM;
297 }
296 298
297 dev_set_drvdata(dev,corgikbd); 299 dev_set_drvdata(dev, corgikbd);
298 strcpy(corgikbd->phys, "corgikbd/input0");
299 300
301 corgikbd->input = input_dev;
300 spin_lock_init(&corgikbd->lock); 302 spin_lock_init(&corgikbd->lock);
301 303
302 /* Init Keyboard rescan timer */ 304 /* Init Keyboard rescan timer */
@@ -311,28 +313,30 @@ static int __init corgikbd_probe(struct device *dev)
311 313
312 corgikbd->suspend_jiffies=jiffies; 314 corgikbd->suspend_jiffies=jiffies;
313 315
314 init_input_dev(&corgikbd->input);
315 corgikbd->input.private = corgikbd;
316 corgikbd->input.name = "Corgi Keyboard";
317 corgikbd->input.dev = dev;
318 corgikbd->input.phys = corgikbd->phys;
319 corgikbd->input.id.bustype = BUS_HOST;
320 corgikbd->input.id.vendor = 0x0001;
321 corgikbd->input.id.product = 0x0001;
322 corgikbd->input.id.version = 0x0100;
323 corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
324 corgikbd->input.keycode = corgikbd->keycode;
325 corgikbd->input.keycodesize = sizeof(unsigned char);
326 corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode);
327
328 memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); 316 memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode));
317
318 input_dev->name = "Corgi Keyboard";
319 input_dev->phys = "corgikbd/input0";
320 input_dev->id.bustype = BUS_HOST;
321 input_dev->id.vendor = 0x0001;
322 input_dev->id.product = 0x0001;
323 input_dev->id.version = 0x0100;
324 input_dev->cdev.dev = dev;
325 input_dev->private = corgikbd;
326
327 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
328 input_dev->keycode = corgikbd->keycode;
329 input_dev->keycodesize = sizeof(unsigned char);
330 input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode);
331
329 for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) 332 for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
330 set_bit(corgikbd->keycode[i], corgikbd->input.keybit); 333 set_bit(corgikbd->keycode[i], input_dev->keybit);
331 clear_bit(0, corgikbd->input.keybit); 334 clear_bit(0, input_dev->keybit);
332 set_bit(SW_0, corgikbd->input.swbit); 335 set_bit(SW_0, input_dev->swbit);
333 set_bit(SW_1, corgikbd->input.swbit); 336 set_bit(SW_1, input_dev->swbit);
337
338 input_register_device(corgikbd->input);
334 339
335 input_register_device(&corgikbd->input);
336 mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); 340 mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL);
337 341
338 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ 342 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
@@ -349,8 +353,6 @@ static int __init corgikbd_probe(struct device *dev)
349 for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) 353 for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
350 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); 354 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
351 355
352 printk(KERN_INFO "input: Corgi Keyboard Registered\n");
353
354 return 0; 356 return 0;
355} 357}
356 358
@@ -365,7 +367,7 @@ static int corgikbd_remove(struct device *dev)
365 del_timer_sync(&corgikbd->htimer); 367 del_timer_sync(&corgikbd->htimer);
366 del_timer_sync(&corgikbd->timer); 368 del_timer_sync(&corgikbd->timer);
367 369
368 input_unregister_device(&corgikbd->input); 370 input_unregister_device(corgikbd->input);
369 371
370 kfree(corgikbd); 372 kfree(corgikbd);
371 373
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index ef78bffed5e7..0a90962c38e7 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -204,7 +204,7 @@ static irqreturn_t hil_kbd_interrupt(struct serio *serio,
204 hil_packet packet; 204 hil_packet packet;
205 int idx; 205 int idx;
206 206
207 kbd = (struct hil_kbd *)serio->private; 207 kbd = serio_get_drvdata(serio);
208 if (kbd == NULL) { 208 if (kbd == NULL) {
209 BUG(); 209 BUG();
210 return IRQ_HANDLED; 210 return IRQ_HANDLED;
@@ -234,7 +234,7 @@ static void hil_kbd_disconnect(struct serio *serio)
234{ 234{
235 struct hil_kbd *kbd; 235 struct hil_kbd *kbd;
236 236
237 kbd = (struct hil_kbd *)serio->private; 237 kbd = serio_get_drvdata(serio);
238 if (kbd == NULL) { 238 if (kbd == NULL) {
239 BUG(); 239 BUG();
240 return; 240 return;
@@ -245,20 +245,20 @@ static void hil_kbd_disconnect(struct serio *serio)
245 kfree(kbd); 245 kfree(kbd);
246} 246}
247 247
248static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv) 248static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
249{ 249{
250 struct hil_kbd *kbd; 250 struct hil_kbd *kbd;
251 uint8_t did, *idd; 251 uint8_t did, *idd;
252 int i; 252 int i;
253 253
254 if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return; 254 kbd = kmalloc(sizeof(*kbd), GFP_KERNEL);
255 255 if (!kbd)
256 if (!(kbd = kmalloc(sizeof(struct hil_kbd), GFP_KERNEL))) return; 256 return -ENOMEM;
257 memset(kbd, 0, sizeof(struct hil_kbd)); 257 memset(kbd, 0, sizeof(struct hil_kbd));
258 258
259 if (serio_open(serio, drv)) goto bail0; 259 if (serio_open(serio, drv)) goto bail0;
260 260
261 serio->private = kbd; 261 serio_set_drvdata(serio, kbd);
262 kbd->serio = serio; 262 kbd->serio = serio;
263 kbd->dev.private = kbd; 263 kbd->dev.private = kbd;
264 264
@@ -342,19 +342,31 @@ static void hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
342 down(&(kbd->sem)); 342 down(&(kbd->sem));
343 up(&(kbd->sem)); 343 up(&(kbd->sem));
344 344
345 return; 345 return 0;
346 bail1: 346 bail1:
347 serio_close(serio); 347 serio_close(serio);
348 bail0: 348 bail0:
349 kfree(kbd); 349 kfree(kbd);
350 serio_set_drvdata(serio, NULL);
351 return -EIO;
350} 352}
351 353
354static struct serio_device_id hil_kbd_ids[] = {
355 {
356 .type = SERIO_HIL_MLC,
357 .proto = SERIO_HIL,
358 .id = SERIO_ANY,
359 .extra = SERIO_ANY,
360 },
361 { 0 }
362};
352 363
353struct serio_driver hil_kbd_serio_drv = { 364struct serio_driver hil_kbd_serio_drv = {
354 .driver = { 365 .driver = {
355 .name = "hil_kbd", 366 .name = "hil_kbd",
356 }, 367 },
357 .description = "HP HIL keyboard driver", 368 .description = "HP HIL keyboard driver",
369 .id_table = hil_kbd_ids,
358 .connect = hil_kbd_connect, 370 .connect = hil_kbd_connect,
359 .disconnect = hil_kbd_disconnect, 371 .disconnect = hil_kbd_disconnect,
360 .interrupt = hil_kbd_interrupt 372 .interrupt = hil_kbd_interrupt
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index eecb77db0847..e95bc052e32a 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -22,7 +22,7 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/irq.h> 25#include <linux/interrupt.h>
26#include <linux/hil.h> 26#include <linux/hil.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28 28
@@ -278,11 +278,11 @@ static int __init
278hil_init_chip(struct parisc_device *dev) 278hil_init_chip(struct parisc_device *dev)
279{ 279{
280 if (!dev->irq) { 280 if (!dev->irq) {
281 printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa); 281 printk(KERN_WARNING "HIL: IRQ not found for HIL bus at 0x%08lx\n", dev->hpa.start);
282 return -ENODEV; 282 return -ENODEV;
283 } 283 }
284 284
285 hil_base = dev->hpa; 285 hil_base = dev->hpa.start;
286 hil_irq = dev->irq; 286 hil_irq = dev->irq;
287 hil_dev.dev_id = dev; 287 hil_dev.dev_id = dev;
288 288
@@ -299,7 +299,7 @@ static struct parisc_device_id hil_tbl[] = {
299MODULE_DEVICE_TABLE(parisc, hil_tbl); 299MODULE_DEVICE_TABLE(parisc, hil_tbl);
300 300
301static struct parisc_driver hil_driver = { 301static struct parisc_driver hil_driver = {
302 .name = "HIL", 302 .name = "hil",
303 .id_table = hil_tbl, 303 .id_table = hil_tbl,
304 .probe = hil_init_chip, 304 .probe = hil_init_chip,
305}; 305};
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 098963c7cdd6..7f06780a437f 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -102,7 +102,7 @@ static int ctrlclick_volume = 100; /* % */
102module_param (ctrlclick_volume, int, 0); 102module_param (ctrlclick_volume, int, 0);
103MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); 103MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%");
104 104
105static int lk201_compose_is_alt = 0; 105static int lk201_compose_is_alt;
106module_param (lk201_compose_is_alt, int, 0); 106module_param (lk201_compose_is_alt, int, 0);
107MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key " 107MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key "
108 "will act as an Alt key"); 108 "will act as an Alt key");
@@ -274,7 +274,7 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = {
274}; 274};
275 275
276#define CHECK_LED(LED, BITS) do { \ 276#define CHECK_LED(LED, BITS) do { \
277 if (test_bit (LED, lk->dev.led)) \ 277 if (test_bit (LED, lk->dev->led)) \
278 leds_on |= BITS; \ 278 leds_on |= BITS; \
279 else \ 279 else \
280 leds_off |= BITS; \ 280 leds_off |= BITS; \
@@ -287,7 +287,7 @@ struct lkkbd {
287 lk_keycode_t keycode[LK_NUM_KEYCODES]; 287 lk_keycode_t keycode[LK_NUM_KEYCODES];
288 int ignore_bytes; 288 int ignore_bytes;
289 unsigned char id[LK_NUM_IGNORE_BYTES]; 289 unsigned char id[LK_NUM_IGNORE_BYTES];
290 struct input_dev dev; 290 struct input_dev *dev;
291 struct serio *serio; 291 struct serio *serio;
292 struct work_struct tq; 292 struct work_struct tq;
293 char name[64]; 293 char name[64];
@@ -423,8 +423,7 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
423 DBG (KERN_INFO "Got byte 0x%02x\n", data); 423 DBG (KERN_INFO "Got byte 0x%02x\n", data);
424 424
425 if (lk->ignore_bytes > 0) { 425 if (lk->ignore_bytes > 0) {
426 DBG (KERN_INFO "Ignoring a byte on %s\n", 426 DBG (KERN_INFO "Ignoring a byte on %s\n", lk->name);
427 lk->name);
428 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; 427 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
429 428
430 if (lk->ignore_bytes == 0) 429 if (lk->ignore_bytes == 0)
@@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
435 434
436 switch (data) { 435 switch (data) {
437 case LK_ALL_KEYS_UP: 436 case LK_ALL_KEYS_UP:
438 input_regs (&lk->dev, regs); 437 input_regs (lk->dev, regs);
439 for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++) 438 for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
440 if (lk->keycode[i] != KEY_RESERVED) 439 if (lk->keycode[i] != KEY_RESERVED)
441 input_report_key (&lk->dev, lk->keycode[i], 0); 440 input_report_key (lk->dev, lk->keycode[i], 0);
442 input_sync (&lk->dev); 441 input_sync (lk->dev);
443 break; 442 break;
444 case LK_METRONOME: 443 case LK_METRONOME:
445 DBG (KERN_INFO "Got LK_METRONOME and don't " 444 DBG (KERN_INFO "Got %#d and don't "
446 "know how to handle...\n"); 445 "know how to handle...\n");
447 break; 446 break;
448 case LK_OUTPUT_ERROR: 447 case LK_OUTPUT_ERROR:
@@ -482,12 +481,12 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
482 481
483 default: 482 default:
484 if (lk->keycode[data] != KEY_RESERVED) { 483 if (lk->keycode[data] != KEY_RESERVED) {
485 input_regs (&lk->dev, regs); 484 input_regs (lk->dev, regs);
486 if (!test_bit (lk->keycode[data], lk->dev.key)) 485 if (!test_bit (lk->keycode[data], lk->dev->key))
487 input_report_key (&lk->dev, lk->keycode[data], 1); 486 input_report_key (lk->dev, lk->keycode[data], 1);
488 else 487 else
489 input_report_key (&lk->dev, lk->keycode[data], 0); 488 input_report_key (lk->dev, lk->keycode[data], 0);
490 input_sync (&lk->dev); 489 input_sync (lk->dev);
491 } else 490 } else
492 printk (KERN_WARNING "%s: Unknown key with " 491 printk (KERN_WARNING "%s: Unknown key with "
493 "scancode 0x%02x on %s.\n", 492 "scancode 0x%02x on %s.\n",
@@ -605,7 +604,7 @@ lkkbd_reinit (void *data)
605 lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume)); 604 lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume));
606 605
607 /* Enable/disable keyclick (and possibly set volume) */ 606 /* Enable/disable keyclick (and possibly set volume) */
608 if (test_bit (SND_CLICK, lk->dev.snd)) { 607 if (test_bit (SND_CLICK, lk->dev->snd)) {
609 lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK); 608 lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK);
610 lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume)); 609 lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume));
611 lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK); 610 lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK);
@@ -616,7 +615,7 @@ lkkbd_reinit (void *data)
616 } 615 }
617 616
618 /* Sound the bell if needed */ 617 /* Sound the bell if needed */
619 if (test_bit (SND_BELL, lk->dev.snd)) 618 if (test_bit (SND_BELL, lk->dev->snd))
620 lk->serio->write (lk->serio, LK_CMD_SOUND_BELL); 619 lk->serio->write (lk->serio, LK_CMD_SOUND_BELL);
621} 620}
622 621
@@ -627,71 +626,70 @@ static int
627lkkbd_connect (struct serio *serio, struct serio_driver *drv) 626lkkbd_connect (struct serio *serio, struct serio_driver *drv)
628{ 627{
629 struct lkkbd *lk; 628 struct lkkbd *lk;
629 struct input_dev *input_dev;
630 int i; 630 int i;
631 int err; 631 int err;
632 632
633 if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL))) 633 lk = kzalloc (sizeof (struct lkkbd), GFP_KERNEL);
634 return -ENOMEM; 634 input_dev = input_allocate_device ();
635 635 if (!lk || !input_dev) {
636 memset (lk, 0, sizeof (struct lkkbd)); 636 err = -ENOMEM;
637 637 goto fail;
638 init_input_dev (&lk->dev); 638 }
639 set_bit (EV_KEY, lk->dev.evbit);
640 set_bit (EV_LED, lk->dev.evbit);
641 set_bit (EV_SND, lk->dev.evbit);
642 set_bit (EV_REP, lk->dev.evbit);
643 set_bit (LED_CAPSL, lk->dev.ledbit);
644 set_bit (LED_SLEEP, lk->dev.ledbit);
645 set_bit (LED_COMPOSE, lk->dev.ledbit);
646 set_bit (LED_SCROLLL, lk->dev.ledbit);
647 set_bit (SND_BELL, lk->dev.sndbit);
648 set_bit (SND_CLICK, lk->dev.sndbit);
649 639
650 lk->serio = serio; 640 lk->serio = serio;
651 641 lk->dev = input_dev;
652 INIT_WORK (&lk->tq, lkkbd_reinit, lk); 642 INIT_WORK (&lk->tq, lkkbd_reinit, lk);
653
654 lk->bell_volume = bell_volume; 643 lk->bell_volume = bell_volume;
655 lk->keyclick_volume = keyclick_volume; 644 lk->keyclick_volume = keyclick_volume;
656 lk->ctrlclick_volume = ctrlclick_volume; 645 lk->ctrlclick_volume = ctrlclick_volume;
646 memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
657 647
658 lk->dev.keycode = lk->keycode; 648 strlcpy (lk->name, "DEC LK keyboard", sizeof(lk->name));
659 lk->dev.keycodesize = sizeof (lk_keycode_t); 649 snprintf (lk->phys, sizeof(lk->phys), "%s/input0", serio->phys);
660 lk->dev.keycodemax = LK_NUM_KEYCODES; 650
661 651 input_dev->name = lk->name;
662 lk->dev.event = lkkbd_event; 652 input_dev->phys = lk->phys;
663 lk->dev.private = lk; 653 input_dev->id.bustype = BUS_RS232;
654 input_dev->id.vendor = SERIO_LKKBD;
655 input_dev->id.product = 0;
656 input_dev->id.version = 0x0100;
657 input_dev->cdev.dev = &serio->dev;
658 input_dev->event = lkkbd_event;
659 input_dev->private = lk;
660
661 set_bit (EV_KEY, input_dev->evbit);
662 set_bit (EV_LED, input_dev->evbit);
663 set_bit (EV_SND, input_dev->evbit);
664 set_bit (EV_REP, input_dev->evbit);
665 set_bit (LED_CAPSL, input_dev->ledbit);
666 set_bit (LED_SLEEP, input_dev->ledbit);
667 set_bit (LED_COMPOSE, input_dev->ledbit);
668 set_bit (LED_SCROLLL, input_dev->ledbit);
669 set_bit (SND_BELL, input_dev->sndbit);
670 set_bit (SND_CLICK, input_dev->sndbit);
671
672 input_dev->keycode = lk->keycode;
673 input_dev->keycodesize = sizeof (lk_keycode_t);
674 input_dev->keycodemax = LK_NUM_KEYCODES;
675 for (i = 0; i < LK_NUM_KEYCODES; i++)
676 set_bit (lk->keycode[i], input_dev->keybit);
664 677
665 serio_set_drvdata (serio, lk); 678 serio_set_drvdata (serio, lk);
666 679
667 err = serio_open (serio, drv); 680 err = serio_open (serio, drv);
668 if (err) { 681 if (err)
669 serio_set_drvdata (serio, NULL); 682 goto fail;
670 kfree (lk);
671 return err;
672 }
673 683
674 sprintf (lk->name, "DEC LK keyboard"); 684 input_register_device (lk->dev);
675 sprintf (lk->phys, "%s/input0", serio->phys);
676
677 memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
678 for (i = 0; i < LK_NUM_KEYCODES; i++)
679 set_bit (lk->keycode[i], lk->dev.keybit);
680
681 lk->dev.name = lk->name;
682 lk->dev.phys = lk->phys;
683 lk->dev.id.bustype = BUS_RS232;
684 lk->dev.id.vendor = SERIO_LKKBD;
685 lk->dev.id.product = 0;
686 lk->dev.id.version = 0x0100;
687 lk->dev.dev = &serio->dev;
688
689 input_register_device (&lk->dev);
690
691 printk (KERN_INFO "input: %s on %s, initiating reset\n", lk->name, serio->phys);
692 lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); 685 lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET);
693 686
694 return 0; 687 return 0;
688
689 fail: serio_set_drvdata (serio, NULL);
690 input_free_device (input_dev);
691 kfree (lk);
692 return err;
695} 693}
696 694
697/* 695/*
@@ -702,9 +700,11 @@ lkkbd_disconnect (struct serio *serio)
702{ 700{
703 struct lkkbd *lk = serio_get_drvdata (serio); 701 struct lkkbd *lk = serio_get_drvdata (serio);
704 702
705 input_unregister_device (&lk->dev); 703 input_get_device (lk->dev);
704 input_unregister_device (lk->dev);
706 serio_close (serio); 705 serio_close (serio);
707 serio_set_drvdata (serio, NULL); 706 serio_set_drvdata (serio, NULL);
707 input_put_device (lk->dev);
708 kfree (lk); 708 kfree (lk);
709} 709}
710 710
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c
index eecbde294f1f..cc6aaf9e85be 100644
--- a/drivers/input/keyboard/maple_keyb.c
+++ b/drivers/input/keyboard/maple_keyb.c
@@ -37,7 +37,7 @@ static unsigned char dc_kbd_keycode[256] = {
37 37
38 38
39struct dc_kbd { 39struct dc_kbd {
40 struct input_dev dev; 40 struct input_dev *dev;
41 unsigned char new[8]; 41 unsigned char new[8];
42 unsigned char old[8]; 42 unsigned char old[8];
43}; 43};
@@ -46,30 +46,24 @@ struct dc_kbd {
46static void dc_scan_kbd(struct dc_kbd *kbd) 46static void dc_scan_kbd(struct dc_kbd *kbd)
47{ 47{
48 int i; 48 int i;
49 struct input_dev *dev = &kbd->dev; 49 struct input_dev *dev = kbd->dev;
50 50
51 for(i=0; i<8; i++) 51 for (i = 0; i < 8; i++)
52 input_report_key(dev, 52 input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
53 dc_kbd_keycode[i+224],
54 (kbd->new[0]>>i)&1);
55 53
56 for(i=2; i<8; i++) { 54 for (i = 2; i < 8; i++) {
57 55
58 if(kbd->old[i]>3&&memscan(kbd->new+2, kbd->old[i], 6)==NULL) { 56 if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) {
59 if(dc_kbd_keycode[kbd->old[i]]) 57 if (dc_kbd_keycode[kbd->old[i]])
60 input_report_key(dev, 58 input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0);
61 dc_kbd_keycode[kbd->old[i]],
62 0);
63 else 59 else
64 printk("Unknown key (scancode %#x) released.", 60 printk("Unknown key (scancode %#x) released.",
65 kbd->old[i]); 61 kbd->old[i]);
66 } 62 }
67 63
68 if(kbd->new[i]>3&&memscan(kbd->old+2, kbd->new[i], 6)!=NULL) { 64 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) {
69 if(dc_kbd_keycode[kbd->new[i]]) 65 if(dc_kbd_keycode[kbd->new[i]])
70 input_report_key(dev, 66 input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1);
71 dc_kbd_keycode[kbd->new[i]],
72 1);
73 else 67 else
74 printk("Unknown key (scancode %#x) pressed.", 68 printk("Unknown key (scancode %#x) pressed.",
75 kbd->new[i]); 69 kbd->new[i]);
@@ -89,43 +83,39 @@ static void dc_kbd_callback(struct mapleq *mq)
89 unsigned long *buf = mq->recvbuf; 83 unsigned long *buf = mq->recvbuf;
90 84
91 if (buf[1] == mapledev->function) { 85 if (buf[1] == mapledev->function) {
92 memcpy(kbd->new, buf+2, 8); 86 memcpy(kbd->new, buf + 2, 8);
93 dc_scan_kbd(kbd); 87 dc_scan_kbd(kbd);
94 } 88 }
95} 89}
96 90
97static int dc_kbd_connect(struct maple_device *dev) 91static int dc_kbd_connect(struct maple_device *dev)
98{ 92{
99 int i;
100 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
101 struct dc_kbd *kbd; 93 struct dc_kbd *kbd;
94 struct input_dev *input_dev;
95 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
96 int i;
102 97
103 if (!(kbd = kmalloc(sizeof(struct dc_kbd), GFP_KERNEL))) 98 dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL);
104 return -1; 99 input_dev = input_allocate_device();
105 memset(kbd, 0, sizeof(struct dc_kbd)); 100 if (!kbd || !input_dev) {
106 101 kfree(kbd);
107 dev->private_data = kbd; 102 input_free_device(input_dev);
108 103 return -ENOMEM;
109 kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 104 }
110
111 init_input_dev(&kbd->dev);
112
113 for (i=0; i<255; i++)
114 set_bit(dc_kbd_keycode[i], kbd->dev.keybit);
115
116 clear_bit(0, kbd->dev.keybit);
117 105
118 kbd->dev.private = kbd; 106 kbd->dev = input_dev;
119 107
120 kbd->dev.name = dev->product_name; 108 input_dev->name = dev->product_name;
121 kbd->dev.id.bustype = BUS_MAPLE; 109 input_dev->id.bustype = BUS_MAPLE;
110 input_dev->private = kbd;
111 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
112 for (i = 0; i < 255; i++)
113 set_bit(dc_kbd_keycode[i], input_dev->keybit);
114 clear_bit(0, input_dev->keybit);
122 115
123 input_register_device(&kbd->dev); 116 input_register_device(kbd->dev);
124 117
125 maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); 118 maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD);
126
127 printk(KERN_INFO "input: keyboard(0x%lx): %s\n", data, kbd->dev.name);
128
129 return 0; 119 return 0;
130} 120}
131 121
@@ -134,7 +124,7 @@ static void dc_kbd_disconnect(struct maple_device *dev)
134{ 124{
135 struct dc_kbd *kbd = dev->private_data; 125 struct dc_kbd *kbd = dev->private_data;
136 126
137 input_unregister_device(&kbd->dev); 127 input_unregister_device(kbd->dev);
138 kfree(kbd); 128 kfree(kbd);
139} 129}
140 130
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c
index 2e8ce1613eec..d10983c521e6 100644
--- a/drivers/input/keyboard/newtonkbd.c
+++ b/drivers/input/keyboard/newtonkbd.c
@@ -57,11 +57,9 @@ static unsigned char nkbd_keycode[128] = {
57 KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0 57 KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0
58}; 58};
59 59
60static char *nkbd_name = "Newton Keyboard";
61
62struct nkbd { 60struct nkbd {
63 unsigned char keycode[128]; 61 unsigned char keycode[128];
64 struct input_dev dev; 62 struct input_dev *dev;
65 struct serio *serio; 63 struct serio *serio;
66 char phys[32]; 64 char phys[32];
67}; 65};
@@ -73,13 +71,13 @@ static irqreturn_t nkbd_interrupt(struct serio *serio,
73 71
74 /* invalid scan codes are probably the init sequence, so we ignore them */ 72 /* invalid scan codes are probably the init sequence, so we ignore them */
75 if (nkbd->keycode[data & NKBD_KEY]) { 73 if (nkbd->keycode[data & NKBD_KEY]) {
76 input_regs(&nkbd->dev, regs); 74 input_regs(nkbd->dev, regs);
77 input_report_key(&nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); 75 input_report_key(nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS);
78 input_sync(&nkbd->dev); 76 input_sync(nkbd->dev);
79 } 77 }
80 78
81 else if (data == 0xe7) /* end of init sequence */ 79 else if (data == 0xe7) /* end of init sequence */
82 printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys); 80 printk(KERN_INFO "input: %s on %s\n", nkbd->dev->name, serio->phys);
83 return IRQ_HANDLED; 81 return IRQ_HANDLED;
84 82
85} 83}
@@ -87,62 +85,59 @@ static irqreturn_t nkbd_interrupt(struct serio *serio,
87static int nkbd_connect(struct serio *serio, struct serio_driver *drv) 85static int nkbd_connect(struct serio *serio, struct serio_driver *drv)
88{ 86{
89 struct nkbd *nkbd; 87 struct nkbd *nkbd;
88 struct input_dev *input_dev;
89 int err = -ENOMEM;
90 int i; 90 int i;
91 int err;
92
93 if (!(nkbd = kmalloc(sizeof(struct nkbd), GFP_KERNEL)))
94 return -ENOMEM;
95
96 memset(nkbd, 0, sizeof(struct nkbd));
97 91
98 nkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 92 nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL);
93 input_dev = input_allocate_device();
94 if (!nkbd || !input_dev)
95 goto fail;
99 96
100 nkbd->serio = serio; 97 nkbd->serio = serio;
98 nkbd->dev = input_dev;
99 sprintf(nkbd->phys, "%s/input0", serio->phys);
100 memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode));
101 101
102 init_input_dev(&nkbd->dev); 102 input_dev->name = "Newton Keyboard";
103 nkbd->dev.keycode = nkbd->keycode; 103 input_dev->phys = nkbd->phys;
104 nkbd->dev.keycodesize = sizeof(unsigned char); 104 input_dev->id.bustype = BUS_RS232;
105 nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode); 105 input_dev->id.vendor = SERIO_NEWTON;
106 nkbd->dev.private = nkbd; 106 input_dev->id.product = 0x0001;
107 input_dev->id.version = 0x0100;
108 input_dev->cdev.dev = &serio->dev;
109 input_dev->private = nkbd;
110
111 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
112 input_dev->keycode = nkbd->keycode;
113 input_dev->keycodesize = sizeof(unsigned char);
114 input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode);
115 for (i = 0; i < 128; i++)
116 set_bit(nkbd->keycode[i], input_dev->keybit);
117 clear_bit(0, input_dev->keybit);
107 118
108 serio_set_drvdata(serio, nkbd); 119 serio_set_drvdata(serio, nkbd);
109 120
110 err = serio_open(serio, drv); 121 err = serio_open(serio, drv);
111 if (err) { 122 if (err)
112 serio_set_drvdata(serio, NULL); 123 goto fail;
113 kfree(nkbd);
114 return err;
115 }
116
117 memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode));
118 for (i = 0; i < 128; i++)
119 set_bit(nkbd->keycode[i], nkbd->dev.keybit);
120 clear_bit(0, nkbd->dev.keybit);
121
122 sprintf(nkbd->phys, "%s/input0", serio->phys);
123
124 nkbd->dev.name = nkbd_name;
125 nkbd->dev.phys = nkbd->phys;
126 nkbd->dev.id.bustype = BUS_RS232;
127 nkbd->dev.id.vendor = SERIO_NEWTON;
128 nkbd->dev.id.product = 0x0001;
129 nkbd->dev.id.version = 0x0100;
130 nkbd->dev.dev = &serio->dev;
131
132 input_register_device(&nkbd->dev);
133
134 printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys);
135 124
125 input_register_device(nkbd->dev);
136 return 0; 126 return 0;
127
128 fail: serio_set_drvdata(serio, NULL);
129 input_free_device(input_dev);
130 kfree(nkbd);
131 return err;
137} 132}
138 133
139static void nkbd_disconnect(struct serio *serio) 134static void nkbd_disconnect(struct serio *serio)
140{ 135{
141 struct nkbd *nkbd = serio_get_drvdata(serio); 136 struct nkbd *nkbd = serio_get_drvdata(serio);
142 137
143 input_unregister_device(&nkbd->dev);
144 serio_close(serio); 138 serio_close(serio);
145 serio_set_drvdata(serio, NULL); 139 serio_set_drvdata(serio, NULL);
140 input_unregister_device(nkbd->dev);
146 kfree(nkbd); 141 kfree(nkbd);
147} 142}
148 143
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 344f46005401..cee9c734a048 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -85,7 +85,7 @@ static int spitz_senses[] = {
85 85
86struct spitzkbd { 86struct spitzkbd {
87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; 87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
88 struct input_dev input; 88 struct input_dev *input;
89 char phys[32]; 89 char phys[32];
90 90
91 spinlock_t lock; 91 spinlock_t lock;
@@ -187,8 +187,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
187 187
188 spin_lock_irqsave(&spitzkbd_data->lock, flags); 188 spin_lock_irqsave(&spitzkbd_data->lock, flags);
189 189
190 if (regs) 190 input_regs(spitzkbd_data->input, regs);
191 input_regs(&spitzkbd_data->input, regs);
192 191
193 num_pressed = 0; 192 num_pressed = 0;
194 for (col = 0; col < KB_COLS; col++) { 193 for (col = 0; col < KB_COLS; col++) {
@@ -210,7 +209,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
210 scancode = SCANCODE(row, col); 209 scancode = SCANCODE(row, col);
211 pressed = rowd & KB_ROWMASK(row); 210 pressed = rowd & KB_ROWMASK(row);
212 211
213 input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); 212 input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
214 213
215 if (pressed) 214 if (pressed)
216 num_pressed++; 215 num_pressed++;
@@ -220,15 +219,15 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
220 219
221 spitzkbd_activate_all(); 220 spitzkbd_activate_all();
222 221
223 input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); 222 input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
224 input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey); 223 input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey);
225 224
226 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { 225 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
227 input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); 226 input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
228 spitzkbd_data->suspend_jiffies = jiffies; 227 spitzkbd_data->suspend_jiffies = jiffies;
229 } 228 }
230 229
231 input_sync(&spitzkbd_data->input); 230 input_sync(spitzkbd_data->input);
232 231
233 /* if any keys are pressed, enable the timer */ 232 /* if any keys are pressed, enable the timer */
234 if (num_pressed) 233 if (num_pressed)
@@ -259,6 +258,7 @@ static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *reg
259static void spitzkbd_timer_callback(unsigned long data) 258static void spitzkbd_timer_callback(unsigned long data)
260{ 259{
261 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; 260 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
261
262 spitzkbd_scankeyboard(spitzkbd_data, NULL); 262 spitzkbd_scankeyboard(spitzkbd_data, NULL);
263} 263}
264 264
@@ -298,9 +298,9 @@ static void spitzkbd_hinge_timer(unsigned long data)
298 if (hinge_count >= HINGE_STABLE_COUNT) { 298 if (hinge_count >= HINGE_STABLE_COUNT) {
299 spin_lock_irqsave(&spitzkbd_data->lock, flags); 299 spin_lock_irqsave(&spitzkbd_data->lock, flags);
300 300
301 input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); 301 input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
302 input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); 302 input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
303 input_sync(&spitzkbd_data->input); 303 input_sync(spitzkbd_data->input);
304 304
305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags); 305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
306 } else { 306 } else {
@@ -309,34 +309,32 @@ static void spitzkbd_hinge_timer(unsigned long data)
309} 309}
310 310
311#ifdef CONFIG_PM 311#ifdef CONFIG_PM
312static int spitzkbd_suspend(struct device *dev, pm_message_t state, uint32_t level) 312static int spitzkbd_suspend(struct device *dev, pm_message_t state)
313{ 313{
314 if (level == SUSPEND_POWER_DOWN) { 314 int i;
315 int i; 315 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
316 struct spitzkbd *spitzkbd = dev_get_drvdata(dev); 316 spitzkbd->suspended = 1;
317 spitzkbd->suspended = 1; 317
318 318 /* Set Strobe lines as inputs - *except* strobe line 0 leave this
319 /* Set Strobe lines as inputs - *except* strobe line 0 leave this 319 enabled so we can detect a power button press for resume */
320 enabled so we can detect a power button press for resume */ 320 for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++)
321 for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++) 321 pxa_gpio_mode(spitz_strobes[i] | GPIO_IN);
322 pxa_gpio_mode(spitz_strobes[i] | GPIO_IN); 322
323 }
324 return 0; 323 return 0;
325} 324}
326 325
327static int spitzkbd_resume(struct device *dev, uint32_t level) 326static int spitzkbd_resume(struct device *dev)
328{ 327{
329 if (level == RESUME_POWER_ON) { 328 int i;
330 int i; 329 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
331 struct spitzkbd *spitzkbd = dev_get_drvdata(dev);
332 330
333 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) 331 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
334 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); 332 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
333
334 /* Upon resume, ignore the suspend key for a short while */
335 spitzkbd->suspend_jiffies = jiffies;
336 spitzkbd->suspended = 0;
335 337
336 /* Upon resume, ignore the suspend key for a short while */
337 spitzkbd->suspend_jiffies = jiffies;
338 spitzkbd->suspended = 0;
339 }
340 return 0; 338 return 0;
341} 339}
342#else 340#else
@@ -346,14 +344,21 @@ static int spitzkbd_resume(struct device *dev, uint32_t level)
346 344
347static int __init spitzkbd_probe(struct device *dev) 345static int __init spitzkbd_probe(struct device *dev)
348{ 346{
349 int i;
350 struct spitzkbd *spitzkbd; 347 struct spitzkbd *spitzkbd;
348 struct input_dev *input_dev;
349 int i;
351 350
352 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); 351 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
353 if (!spitzkbd) 352 if (!spitzkbd)
354 return -ENOMEM; 353 return -ENOMEM;
355 354
356 dev_set_drvdata(dev,spitzkbd); 355 input_dev = input_allocate_device();
356 if (!input_dev) {
357 kfree(spitzkbd);
358 return -ENOMEM;
359 }
360
361 dev_set_drvdata(dev, spitzkbd);
357 strcpy(spitzkbd->phys, "spitzkbd/input0"); 362 strcpy(spitzkbd->phys, "spitzkbd/input0");
358 363
359 spin_lock_init(&spitzkbd->lock); 364 spin_lock_init(&spitzkbd->lock);
@@ -368,30 +373,34 @@ static int __init spitzkbd_probe(struct device *dev)
368 spitzkbd->htimer.function = spitzkbd_hinge_timer; 373 spitzkbd->htimer.function = spitzkbd_hinge_timer;
369 spitzkbd->htimer.data = (unsigned long) spitzkbd; 374 spitzkbd->htimer.data = (unsigned long) spitzkbd;
370 375
371 spitzkbd->suspend_jiffies=jiffies; 376 spitzkbd->suspend_jiffies = jiffies;
372 377
373 init_input_dev(&spitzkbd->input); 378 spitzkbd->input = input_dev;
374 spitzkbd->input.private = spitzkbd; 379
375 spitzkbd->input.name = "Spitz Keyboard"; 380 input_dev->private = spitzkbd;
376 spitzkbd->input.dev = dev; 381 input_dev->name = "Spitz Keyboard";
377 spitzkbd->input.phys = spitzkbd->phys; 382 input_dev->phys = spitzkbd->phys;
378 spitzkbd->input.id.bustype = BUS_HOST; 383 input_dev->cdev.dev = dev;
379 spitzkbd->input.id.vendor = 0x0001; 384
380 spitzkbd->input.id.product = 0x0001; 385 input_dev->id.bustype = BUS_HOST;
381 spitzkbd->input.id.version = 0x0100; 386 input_dev->id.vendor = 0x0001;
382 spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); 387 input_dev->id.product = 0x0001;
383 spitzkbd->input.keycode = spitzkbd->keycode; 388 input_dev->id.version = 0x0100;
384 spitzkbd->input.keycodesize = sizeof(unsigned char); 389
385 spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode); 390 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
391 input_dev->keycode = spitzkbd->keycode;
392 input_dev->keycodesize = sizeof(unsigned char);
393 input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode);
386 394
387 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); 395 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
388 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) 396 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
389 set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit); 397 set_bit(spitzkbd->keycode[i], input_dev->keybit);
390 clear_bit(0, spitzkbd->input.keybit); 398 clear_bit(0, input_dev->keybit);
391 set_bit(SW_0, spitzkbd->input.swbit); 399 set_bit(SW_0, input_dev->swbit);
392 set_bit(SW_1, spitzkbd->input.swbit); 400 set_bit(SW_1, input_dev->swbit);
401
402 input_register_device(input_dev);
393 403
394 input_register_device(&spitzkbd->input);
395 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); 404 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
396 405
397 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ 406 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
@@ -444,7 +453,7 @@ static int spitzkbd_remove(struct device *dev)
444 del_timer_sync(&spitzkbd->htimer); 453 del_timer_sync(&spitzkbd->htimer);
445 del_timer_sync(&spitzkbd->timer); 454 del_timer_sync(&spitzkbd->timer);
446 455
447 input_unregister_device(&spitzkbd->input); 456 input_unregister_device(spitzkbd->input);
448 457
449 kfree(spitzkbd); 458 kfree(spitzkbd);
450 459
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index 4bae5d89348d..b15b6d8d4f83 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -76,13 +76,14 @@ static unsigned char sunkbd_keycode[128] = {
76 76
77struct sunkbd { 77struct sunkbd {
78 unsigned char keycode[128]; 78 unsigned char keycode[128];
79 struct input_dev dev; 79 struct input_dev *dev;
80 struct serio *serio; 80 struct serio *serio;
81 struct work_struct tq; 81 struct work_struct tq;
82 wait_queue_head_t wait; 82 wait_queue_head_t wait;
83 char name[64]; 83 char name[64];
84 char phys[32]; 84 char phys[32];
85 char type; 85 char type;
86 unsigned char enabled;
86 volatile s8 reset; 87 volatile s8 reset;
87 volatile s8 layout; 88 volatile s8 layout;
88}; 89};
@@ -124,10 +125,13 @@ static irqreturn_t sunkbd_interrupt(struct serio *serio,
124 break; 125 break;
125 126
126 default: 127 default:
128 if (!sunkbd->enabled)
129 break;
130
127 if (sunkbd->keycode[data & SUNKBD_KEY]) { 131 if (sunkbd->keycode[data & SUNKBD_KEY]) {
128 input_regs(&sunkbd->dev, regs); 132 input_regs(sunkbd->dev, regs);
129 input_report_key(&sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); 133 input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE));
130 input_sync(&sunkbd->dev); 134 input_sync(sunkbd->dev);
131 } else { 135 } else {
132 printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", 136 printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n",
133 data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); 137 data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed");
@@ -184,7 +188,7 @@ static int sunkbd_initialize(struct sunkbd *sunkbd)
184 sunkbd->reset = -2; 188 sunkbd->reset = -2;
185 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET); 189 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET);
186 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); 190 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
187 if (sunkbd->reset <0) 191 if (sunkbd->reset < 0)
188 return -1; 192 return -1;
189 193
190 sunkbd->type = sunkbd->reset; 194 sunkbd->type = sunkbd->reset;
@@ -213,10 +217,17 @@ static void sunkbd_reinit(void *data)
213 217
214 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED); 218 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED);
215 sunkbd->serio->write(sunkbd->serio, 219 sunkbd->serio->write(sunkbd->serio,
216 (!!test_bit(LED_CAPSL, sunkbd->dev.led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev.led) << 2) | 220 (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) |
217 (!!test_bit(LED_COMPOSE, sunkbd->dev.led) << 1) | !!test_bit(LED_NUML, sunkbd->dev.led)); 221 (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | !!test_bit(LED_NUML, sunkbd->dev->led));
218 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev.snd)); 222 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd));
219 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev.snd)); 223 sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd));
224}
225
226static void sunkbd_enable(struct sunkbd *sunkbd, int enable)
227{
228 serio_pause_rx(sunkbd->serio);
229 sunkbd->enabled = 1;
230 serio_continue_rx(sunkbd->serio);
220} 231}
221 232
222/* 233/*
@@ -226,70 +237,64 @@ static void sunkbd_reinit(void *data)
226static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) 237static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
227{ 238{
228 struct sunkbd *sunkbd; 239 struct sunkbd *sunkbd;
240 struct input_dev *input_dev;
241 int err = -ENOMEM;
229 int i; 242 int i;
230 int err;
231
232 if (!(sunkbd = kmalloc(sizeof(struct sunkbd), GFP_KERNEL)))
233 return -ENOMEM;
234 243
235 memset(sunkbd, 0, sizeof(struct sunkbd)); 244 sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL);
236 245 input_dev = input_allocate_device();
237 init_input_dev(&sunkbd->dev); 246 if (!sunkbd || !input_dev)
238 init_waitqueue_head(&sunkbd->wait); 247 goto fail;
239
240 sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
241 sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
242 sunkbd->dev.sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL);
243 248
244 sunkbd->serio = serio; 249 sunkbd->serio = serio;
245 250 sunkbd->dev = input_dev;
251 init_waitqueue_head(&sunkbd->wait);
246 INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); 252 INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd);
247 253 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys);
248 sunkbd->dev.keycode = sunkbd->keycode;
249 sunkbd->dev.keycodesize = sizeof(unsigned char);
250 sunkbd->dev.keycodemax = ARRAY_SIZE(sunkbd_keycode);
251
252 sunkbd->dev.event = sunkbd_event;
253 sunkbd->dev.private = sunkbd;
254 254
255 serio_set_drvdata(serio, sunkbd); 255 serio_set_drvdata(serio, sunkbd);
256 256
257 err = serio_open(serio, drv); 257 err = serio_open(serio, drv);
258 if (err) { 258 if (err)
259 serio_set_drvdata(serio, NULL); 259 goto fail;
260 kfree(sunkbd);
261 return err;
262 }
263 260
264 if (sunkbd_initialize(sunkbd) < 0) { 261 if (sunkbd_initialize(sunkbd) < 0) {
265 serio_close(serio); 262 serio_close(serio);
266 serio_set_drvdata(serio, NULL); 263 goto fail;
267 kfree(sunkbd);
268 return -ENODEV;
269 } 264 }
270 265
271 sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); 266 sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type);
272
273 memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); 267 memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode));
274 for (i = 0; i < 128; i++)
275 set_bit(sunkbd->keycode[i], sunkbd->dev.keybit);
276 clear_bit(0, sunkbd->dev.keybit);
277
278 sprintf(sunkbd->phys, "%s/input0", serio->phys);
279
280 sunkbd->dev.name = sunkbd->name;
281 sunkbd->dev.phys = sunkbd->phys;
282 sunkbd->dev.id.bustype = BUS_RS232;
283 sunkbd->dev.id.vendor = SERIO_SUNKBD;
284 sunkbd->dev.id.product = sunkbd->type;
285 sunkbd->dev.id.version = 0x0100;
286 sunkbd->dev.dev = &serio->dev;
287 268
288 input_register_device(&sunkbd->dev); 269 input_dev->name = sunkbd->name;
289 270 input_dev->phys = sunkbd->phys;
290 printk(KERN_INFO "input: %s on %s\n", sunkbd->name, serio->phys); 271 input_dev->id.bustype = BUS_RS232;
272 input_dev->id.vendor = SERIO_SUNKBD;
273 input_dev->id.product = sunkbd->type;
274 input_dev->id.version = 0x0100;
275 input_dev->cdev.dev = &serio->dev;
276 input_dev->private = sunkbd;
277 input_dev->event = sunkbd_event;
278
279 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
280 input_dev->ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
281 input_dev->sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL);
282
283 input_dev->keycode = sunkbd->keycode;
284 input_dev->keycodesize = sizeof(unsigned char);
285 input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode);
286 for (i = 0; i < 128; i++)
287 set_bit(sunkbd->keycode[i], input_dev->keybit);
288 clear_bit(0, input_dev->keybit);
291 289
290 sunkbd_enable(sunkbd, 1);
291 input_register_device(sunkbd->dev);
292 return 0; 292 return 0;
293
294 fail: serio_set_drvdata(serio, NULL);
295 input_free_device(input_dev);
296 kfree(sunkbd);
297 return err;
293} 298}
294 299
295/* 300/*
@@ -299,7 +304,9 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
299static void sunkbd_disconnect(struct serio *serio) 304static void sunkbd_disconnect(struct serio *serio)
300{ 305{
301 struct sunkbd *sunkbd = serio_get_drvdata(serio); 306 struct sunkbd *sunkbd = serio_get_drvdata(serio);
302 input_unregister_device(&sunkbd->dev); 307
308 sunkbd_enable(sunkbd, 0);
309 input_unregister_device(sunkbd->dev);
303 serio_close(serio); 310 serio_close(serio);
304 serio_set_drvdata(serio, NULL); 311 serio_set_drvdata(serio, NULL);
305 kfree(sunkbd); 312 kfree(sunkbd);
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c
index 19eaec7789d1..4135e3e16c51 100644
--- a/drivers/input/keyboard/xtkbd.c
+++ b/drivers/input/keyboard/xtkbd.c
@@ -56,11 +56,9 @@ static unsigned char xtkbd_keycode[256] = {
56 106 56 106
57}; 57};
58 58
59static char *xtkbd_name = "XT Keyboard";
60
61struct xtkbd { 59struct xtkbd {
62 unsigned char keycode[256]; 60 unsigned char keycode[256];
63 struct input_dev dev; 61 struct input_dev *dev;
64 struct serio *serio; 62 struct serio *serio;
65 char phys[32]; 63 char phys[32];
66}; 64};
@@ -77,9 +75,9 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio,
77 default: 75 default:
78 76
79 if (xtkbd->keycode[data & XTKBD_KEY]) { 77 if (xtkbd->keycode[data & XTKBD_KEY]) {
80 input_regs(&xtkbd->dev, regs); 78 input_regs(xtkbd->dev, regs);
81 input_report_key(&xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); 79 input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE));
82 input_sync(&xtkbd->dev); 80 input_sync(xtkbd->dev);
83 } else { 81 } else {
84 printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", 82 printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n",
85 data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); 83 data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed");
@@ -91,62 +89,60 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio,
91static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) 89static int xtkbd_connect(struct serio *serio, struct serio_driver *drv)
92{ 90{
93 struct xtkbd *xtkbd; 91 struct xtkbd *xtkbd;
92 struct input_dev *input_dev;
93 int err = -ENOMEM;
94 int i; 94 int i;
95 int err;
96
97 if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL)))
98 return -ENOMEM;
99
100 memset(xtkbd, 0, sizeof(struct xtkbd));
101 95
102 xtkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 96 xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL);
97 input_dev = input_allocate_device();
98 if (!xtkbd || !input_dev)
99 goto fail;
103 100
104 xtkbd->serio = serio; 101 xtkbd->serio = serio;
102 xtkbd->dev = input_dev;
103 sprintf(xtkbd->phys, "%s/input0", serio->phys);
104 memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode));
105 105
106 init_input_dev(&xtkbd->dev); 106 input_dev->name = "XT Keyboard";
107 xtkbd->dev.keycode = xtkbd->keycode; 107 input_dev->phys = xtkbd->phys;
108 xtkbd->dev.keycodesize = sizeof(unsigned char); 108 input_dev->id.bustype = BUS_XTKBD;
109 xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode); 109 input_dev->id.vendor = 0x0001;
110 xtkbd->dev.private = xtkbd; 110 input_dev->id.product = 0x0001;
111 111 input_dev->id.version = 0x0100;
112 serio_set_drvdata(serio, xtkbd); 112 input_dev->cdev.dev = &serio->dev;
113 input_dev->private = xtkbd;
113 114
114 err = serio_open(serio, drv); 115 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
115 if (err) { 116 input_dev->keycode = xtkbd->keycode;
116 serio_set_drvdata(serio, NULL); 117 input_dev->keycodesize = sizeof(unsigned char);
117 kfree(xtkbd); 118 input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode);
118 return err;
119 }
120 119
121 memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode));
122 for (i = 0; i < 255; i++) 120 for (i = 0; i < 255; i++)
123 set_bit(xtkbd->keycode[i], xtkbd->dev.keybit); 121 set_bit(xtkbd->keycode[i], input_dev->keybit);
124 clear_bit(0, xtkbd->dev.keybit); 122 clear_bit(0, input_dev->keybit);
125
126 sprintf(xtkbd->phys, "%s/input0", serio->phys);
127
128 xtkbd->dev.name = xtkbd_name;
129 xtkbd->dev.phys = xtkbd->phys;
130 xtkbd->dev.id.bustype = BUS_XTKBD;
131 xtkbd->dev.id.vendor = 0x0001;
132 xtkbd->dev.id.product = 0x0001;
133 xtkbd->dev.id.version = 0x0100;
134 xtkbd->dev.dev = &serio->dev;
135 123
136 input_register_device(&xtkbd->dev); 124 serio_set_drvdata(serio, xtkbd);
137 125
138 printk(KERN_INFO "input: %s on %s\n", xtkbd_name, serio->phys); 126 err = serio_open(serio, drv);
127 if (err)
128 goto fail;
139 129
130 input_register_device(xtkbd->dev);
140 return 0; 131 return 0;
132
133 fail: serio_set_drvdata(serio, NULL);
134 input_free_device(input_dev);
135 kfree(xtkbd);
136 return err;
141} 137}
142 138
143static void xtkbd_disconnect(struct serio *serio) 139static void xtkbd_disconnect(struct serio *serio)
144{ 140{
145 struct xtkbd *xtkbd = serio_get_drvdata(serio); 141 struct xtkbd *xtkbd = serio_get_drvdata(serio);
146 142
147 input_unregister_device(&xtkbd->dev);
148 serio_close(serio); 143 serio_close(serio);
149 serio_set_drvdata(serio, NULL); 144 serio_set_drvdata(serio, NULL);
145 input_unregister_device(xtkbd->dev);
150 kfree(xtkbd); 146 kfree(xtkbd);
151} 147}
152 148
diff --git a/drivers/input/misc/m68kspkr.c b/drivers/input/misc/m68kspkr.c
index 64abdd98d482..04489ad7702a 100644
--- a/drivers/input/misc/m68kspkr.c
+++ b/drivers/input/misc/m68kspkr.c
@@ -24,9 +24,7 @@ MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>");
24MODULE_DESCRIPTION("m68k beeper driver"); 24MODULE_DESCRIPTION("m68k beeper driver");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27static char m68kspkr_name[] = "m68k beeper"; 27static struct input_dev *m68kspkr_dev;
28static char m68kspkr_phys[] = "m68k/generic";
29static struct input_dev m68kspkr_dev;
30 28
31static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 29static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
32{ 30{
@@ -51,32 +49,34 @@ static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int
51 49
52static int __init m68kspkr_init(void) 50static int __init m68kspkr_init(void)
53{ 51{
54 if (!mach_beep){ 52 if (!mach_beep) {
55 printk("%s: no lowlevel beep support\n", m68kspkr_name); 53 printk(KERN_INFO "m68kspkr: no lowlevel beep support\n");
56 return -1; 54 return -ENODEV;
57 } 55 }
58 56
59 m68kspkr_dev.evbit[0] = BIT(EV_SND); 57 m68kspkr_dev = input_allocate_device();
60 m68kspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 58 if (!m68kspkr_dev)
61 m68kspkr_dev.event = m68kspkr_event; 59 return -ENOMEM;
62 60
63 m68kspkr_dev.name = m68kspkr_name; 61 m68kspkr_dev->name = "m68k beeper";
64 m68kspkr_dev.phys = m68kspkr_phys; 62 m68kspkr_dev->phys = "m68k/generic";
65 m68kspkr_dev.id.bustype = BUS_HOST; 63 m68kspkr_dev->id.bustype = BUS_HOST;
66 m68kspkr_dev.id.vendor = 0x001f; 64 m68kspkr_dev->id.vendor = 0x001f;
67 m68kspkr_dev.id.product = 0x0001; 65 m68kspkr_dev->id.product = 0x0001;
68 m68kspkr_dev.id.version = 0x0100; 66 m68kspkr_dev->id.version = 0x0100;
69 67
70 input_register_device(&m68kspkr_dev); 68 m68kspkr_dev->evbit[0] = BIT(EV_SND);
69 m68kspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
70 m68kspkr_dev->event = m68kspkr_event;
71 71
72 printk(KERN_INFO "input: %s\n", m68kspkr_name); 72 input_register_device(m68kspkr_dev);
73 73
74 return 0; 74 return 0;
75} 75}
76 76
77static void __exit m68kspkr_exit(void) 77static void __exit m68kspkr_exit(void)
78{ 78{
79 input_unregister_device(&m68kspkr_dev); 79 input_unregister_device(m68kspkr_dev);
80} 80}
81 81
82module_init(m68kspkr_init); 82module_init(m68kspkr_init);
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 3013194f462b..e34633c37fdd 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -23,9 +23,7 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
23MODULE_DESCRIPTION("PC Speaker beeper driver"); 23MODULE_DESCRIPTION("PC Speaker beeper driver");
24MODULE_LICENSE("GPL"); 24MODULE_LICENSE("GPL");
25 25
26static char pcspkr_name[] = "PC Speaker"; 26static struct input_dev *pcspkr_dev;
27static char pcspkr_phys[] = "isa0061/input0";
28static struct input_dev pcspkr_dev;
29 27
30static DEFINE_SPINLOCK(i8253_beep_lock); 28static DEFINE_SPINLOCK(i8253_beep_lock);
31 29
@@ -68,27 +66,29 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
68 66
69static int __init pcspkr_init(void) 67static int __init pcspkr_init(void)
70{ 68{
71 pcspkr_dev.evbit[0] = BIT(EV_SND); 69 pcspkr_dev = input_allocate_device();
72 pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 70 if (!pcspkr_dev)
73 pcspkr_dev.event = pcspkr_event; 71 return -ENOMEM;
74 72
75 pcspkr_dev.name = pcspkr_name; 73 pcspkr_dev->name = "PC Speaker";
76 pcspkr_dev.phys = pcspkr_phys; 74 pcspkr_dev->name = "isa0061/input0";
77 pcspkr_dev.id.bustype = BUS_ISA; 75 pcspkr_dev->id.bustype = BUS_ISA;
78 pcspkr_dev.id.vendor = 0x001f; 76 pcspkr_dev->id.vendor = 0x001f;
79 pcspkr_dev.id.product = 0x0001; 77 pcspkr_dev->id.product = 0x0001;
80 pcspkr_dev.id.version = 0x0100; 78 pcspkr_dev->id.version = 0x0100;
81 79
82 input_register_device(&pcspkr_dev); 80 pcspkr_dev->evbit[0] = BIT(EV_SND);
81 pcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
82 pcspkr_dev->event = pcspkr_event;
83 83
84 printk(KERN_INFO "input: %s\n", pcspkr_name); 84 input_register_device(pcspkr_dev);
85 85
86 return 0; 86 return 0;
87} 87}
88 88
89static void __exit pcspkr_exit(void) 89static void __exit pcspkr_exit(void)
90{ 90{
91 input_unregister_device(&pcspkr_dev); 91 input_unregister_device(pcspkr_dev);
92 /* turn off the speaker */ 92 /* turn off the speaker */
93 pcspkr_event(NULL, EV_SND, SND_BELL, 0); 93 pcspkr_event(NULL, EV_SND, SND_BELL, 0);
94} 94}
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index cdc3fb3d5f46..5778220a18d2 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -17,28 +17,24 @@
17#endif 17#endif
18 18
19MODULE_AUTHOR("David S. Miller <davem@redhat.com>"); 19MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
20MODULE_DESCRIPTION("PC Speaker beeper driver"); 20MODULE_DESCRIPTION("Sparc Speaker beeper driver");
21MODULE_LICENSE("GPL"); 21MODULE_LICENSE("GPL");
22 22
23static unsigned long beep_iobase; 23static unsigned long beep_iobase;
24 24static struct input_dev *sparcspkr_dev;
25static char *sparcspkr_isa_name = "Sparc ISA Speaker";
26static char *sparcspkr_ebus_name = "Sparc EBUS Speaker";
27static char *sparcspkr_phys = "sparc/input0";
28static struct input_dev sparcspkr_dev;
29 25
30DEFINE_SPINLOCK(beep_lock); 26DEFINE_SPINLOCK(beep_lock);
31 27
32static void __init init_sparcspkr_struct(void) 28static void __init init_sparcspkr_struct(void)
33{ 29{
34 sparcspkr_dev.evbit[0] = BIT(EV_SND); 30 sparcspkr_dev->evbit[0] = BIT(EV_SND);
35 sparcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE); 31 sparcspkr_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
36 32
37 sparcspkr_dev.phys = sparcspkr_phys; 33 sparcspkr_dev->phys = "sparc/input0";
38 sparcspkr_dev.id.bustype = BUS_ISA; 34 sparcspkr_dev->id.bustype = BUS_ISA;
39 sparcspkr_dev.id.vendor = 0x001f; 35 sparcspkr_dev->id.vendor = 0x001f;
40 sparcspkr_dev.id.product = 0x0001; 36 sparcspkr_dev->id.product = 0x0001;
41 sparcspkr_dev.id.version = 0x0100; 37 sparcspkr_dev->id.version = 0x0100;
42} 38}
43 39
44static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 40static int ebus_spkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
@@ -84,14 +80,15 @@ static int __init init_ebus_beep(struct linux_ebus_device *edev)
84{ 80{
85 beep_iobase = edev->resource[0].start; 81 beep_iobase = edev->resource[0].start;
86 82
87 init_sparcspkr_struct(); 83 sparcspkr_dev = input_allocate_device();
84 if (!sparcspkr_dev)
85 return -ENOMEM;
88 86
89 sparcspkr_dev.name = sparcspkr_ebus_name; 87 sparcspkr_dev->name = "Sparc EBUS Speaker";
90 sparcspkr_dev.event = ebus_spkr_event; 88 sparcspkr_dev->event = ebus_spkr_event;
91 89
92 input_register_device(&sparcspkr_dev); 90 input_register_device(sparcspkr_dev);
93 91
94 printk(KERN_INFO "input: %s\n", sparcspkr_ebus_name);
95 return 0; 92 return 0;
96} 93}
97 94
@@ -137,15 +134,17 @@ static int __init init_isa_beep(struct sparc_isa_device *isa_dev)
137{ 134{
138 beep_iobase = isa_dev->resource.start; 135 beep_iobase = isa_dev->resource.start;
139 136
137 sparcspkr_dev = input_allocate_device();
138 if (!sparcspkr_dev)
139 return -ENOMEM;
140
140 init_sparcspkr_struct(); 141 init_sparcspkr_struct();
141 142
142 sparcspkr_dev.name = sparcspkr_isa_name; 143 sparcspkr_dev->name = "Sparc ISA Speaker";
143 sparcspkr_dev.event = isa_spkr_event; 144 sparcspkr_dev->event = isa_spkr_event;
144 sparcspkr_dev.id.bustype = BUS_ISA;
145 145
146 input_register_device(&sparcspkr_dev); 146 input_register_device(&sparcspkr_dev);
147 147
148 printk(KERN_INFO "input: %s\n", sparcspkr_isa_name);
149 return 0; 148 return 0;
150} 149}
151#endif 150#endif
@@ -182,7 +181,7 @@ static int __init sparcspkr_init(void)
182 181
183static void __exit sparcspkr_exit(void) 182static void __exit sparcspkr_exit(void)
184{ 183{
185 input_unregister_device(&sparcspkr_dev); 184 input_unregister_device(sparcspkr_dev);
186} 185}
187 186
188module_init(sparcspkr_init); 187module_init(sparcspkr_init);
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index b20783f9748a..4acc7fd4cd0f 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -79,8 +79,8 @@ static void alps_process_packet(struct psmouse *psmouse, struct pt_regs *regs)
79{ 79{
80 struct alps_data *priv = psmouse->private; 80 struct alps_data *priv = psmouse->private;
81 unsigned char *packet = psmouse->packet; 81 unsigned char *packet = psmouse->packet;
82 struct input_dev *dev = &psmouse->dev; 82 struct input_dev *dev = psmouse->dev;
83 struct input_dev *dev2 = &priv->dev2; 83 struct input_dev *dev2 = priv->dev2;
84 int x, y, z, ges, fin, left, right, middle; 84 int x, y, z, ges, fin, left, right, middle;
85 int back = 0, forward = 0; 85 int back = 0, forward = 0;
86 86
@@ -379,20 +379,24 @@ static int alps_reconnect(struct psmouse *psmouse)
379static void alps_disconnect(struct psmouse *psmouse) 379static void alps_disconnect(struct psmouse *psmouse)
380{ 380{
381 struct alps_data *priv = psmouse->private; 381 struct alps_data *priv = psmouse->private;
382
382 psmouse_reset(psmouse); 383 psmouse_reset(psmouse);
383 input_unregister_device(&priv->dev2); 384 input_unregister_device(priv->dev2);
384 kfree(priv); 385 kfree(priv);
385} 386}
386 387
387int alps_init(struct psmouse *psmouse) 388int alps_init(struct psmouse *psmouse)
388{ 389{
389 struct alps_data *priv; 390 struct alps_data *priv;
391 struct input_dev *dev1 = psmouse->dev, *dev2;
390 int version; 392 int version;
391 393
392 psmouse->private = priv = kmalloc(sizeof(struct alps_data), GFP_KERNEL); 394 psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL);
393 if (!priv) 395 dev2 = input_allocate_device();
396 if (!priv || !dev2)
394 goto init_fail; 397 goto init_fail;
395 memset(priv, 0, sizeof(struct alps_data)); 398
399 priv->dev2 = dev2;
396 400
397 if (!(priv->i = alps_get_model(psmouse, &version))) 401 if (!(priv->i = alps_get_model(psmouse, &version)))
398 goto init_fail; 402 goto init_fail;
@@ -411,41 +415,39 @@ int alps_init(struct psmouse *psmouse)
411 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0)) 415 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 0))
412 goto init_fail; 416 goto init_fail;
413 417
414 psmouse->dev.evbit[LONG(EV_KEY)] |= BIT(EV_KEY); 418 dev1->evbit[LONG(EV_KEY)] |= BIT(EV_KEY);
415 psmouse->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH); 419 dev1->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
416 psmouse->dev.keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER); 420 dev1->keybit[LONG(BTN_TOOL_FINGER)] |= BIT(BTN_TOOL_FINGER);
417 psmouse->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 421 dev1->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
418 422
419 psmouse->dev.evbit[LONG(EV_ABS)] |= BIT(EV_ABS); 423 dev1->evbit[LONG(EV_ABS)] |= BIT(EV_ABS);
420 input_set_abs_params(&psmouse->dev, ABS_X, 0, 1023, 0, 0); 424 input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0);
421 input_set_abs_params(&psmouse->dev, ABS_Y, 0, 767, 0, 0); 425 input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0);
422 input_set_abs_params(&psmouse->dev, ABS_PRESSURE, 0, 127, 0, 0); 426 input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0);
423 427
424 if (priv->i->flags & ALPS_WHEEL) { 428 if (priv->i->flags & ALPS_WHEEL) {
425 psmouse->dev.evbit[LONG(EV_REL)] |= BIT(EV_REL); 429 dev1->evbit[LONG(EV_REL)] |= BIT(EV_REL);
426 psmouse->dev.relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL); 430 dev1->relbit[LONG(REL_WHEEL)] |= BIT(REL_WHEEL);
427 } 431 }
428 432
429 if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) { 433 if (priv->i->flags & (ALPS_FW_BK_1 | ALPS_FW_BK_2)) {
430 psmouse->dev.keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD); 434 dev1->keybit[LONG(BTN_FORWARD)] |= BIT(BTN_FORWARD);
431 psmouse->dev.keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK); 435 dev1->keybit[LONG(BTN_BACK)] |= BIT(BTN_BACK);
432 } 436 }
433 437
434 sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys); 438 sprintf(priv->phys, "%s/input1", psmouse->ps2dev.serio->phys);
435 priv->dev2.phys = priv->phys; 439 dev2->phys = priv->phys;
436 priv->dev2.name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse"; 440 dev2->name = (priv->i->flags & ALPS_DUALPOINT) ? "DualPoint Stick" : "PS/2 Mouse";
437 priv->dev2.id.bustype = BUS_I8042; 441 dev2->id.bustype = BUS_I8042;
438 priv->dev2.id.vendor = 0x0002; 442 dev2->id.vendor = 0x0002;
439 priv->dev2.id.product = PSMOUSE_ALPS; 443 dev2->id.product = PSMOUSE_ALPS;
440 priv->dev2.id.version = 0x0000; 444 dev2->id.version = 0x0000;
441
442 priv->dev2.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
443 priv->dev2.relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
444 priv->dev2.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
445 445
446 input_register_device(&priv->dev2); 446 dev2->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
447 dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y);
448 dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
447 449
448 printk(KERN_INFO "input: %s on %s\n", priv->dev2.name, psmouse->ps2dev.serio->phys); 450 input_register_device(priv->dev2);
449 451
450 psmouse->protocol_handler = alps_process_byte; 452 psmouse->protocol_handler = alps_process_byte;
451 psmouse->disconnect = alps_disconnect; 453 psmouse->disconnect = alps_disconnect;
@@ -455,6 +457,7 @@ int alps_init(struct psmouse *psmouse)
455 return 0; 457 return 0;
456 458
457init_fail: 459init_fail:
460 input_free_device(dev2);
458 kfree(priv); 461 kfree(priv);
459 return -1; 462 return -1;
460} 463}
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index aba103dd65b7..e428f8d5d12e 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -22,7 +22,7 @@ struct alps_model_info {
22}; 22};
23 23
24struct alps_data { 24struct alps_data {
25 struct input_dev dev2; /* Relative device */ 25 struct input_dev *dev2; /* Relative device */
26 char name[32]; /* Name */ 26 char name[32]; /* Name */
27 char phys[32]; /* Phys */ 27 char phys[32]; /* Phys */
28 struct alps_model_info *i; /* Info */ 28 struct alps_model_info *i; /* Info */
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index e994849efb8f..d13d4c8fe3c5 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -34,10 +34,7 @@ MODULE_DESCRIPTION("Amiga mouse driver");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36static int amimouse_lastx, amimouse_lasty; 36static int amimouse_lastx, amimouse_lasty;
37static struct input_dev amimouse_dev; 37static struct input_dev *amimouse_dev;
38
39static char *amimouse_name = "Amiga mouse";
40static char *amimouse_phys = "amimouse/input0";
41 38
42static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp) 39static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp)
43{ 40{
@@ -62,16 +59,16 @@ static irqreturn_t amimouse_interrupt(int irq, void *dummy, struct pt_regs *fp)
62 59
63 potgor = custom.potgor; 60 potgor = custom.potgor;
64 61
65 input_regs(&amimouse_dev, fp); 62 input_regs(amimouse_dev, fp);
66 63
67 input_report_rel(&amimouse_dev, REL_X, dx); 64 input_report_rel(amimouse_dev, REL_X, dx);
68 input_report_rel(&amimouse_dev, REL_Y, dy); 65 input_report_rel(amimouse_dev, REL_Y, dy);
69 66
70 input_report_key(&amimouse_dev, BTN_LEFT, ciaa.pra & 0x40); 67 input_report_key(amimouse_dev, BTN_LEFT, ciaa.pra & 0x40);
71 input_report_key(&amimouse_dev, BTN_MIDDLE, potgor & 0x0100); 68 input_report_key(amimouse_dev, BTN_MIDDLE, potgor & 0x0100);
72 input_report_key(&amimouse_dev, BTN_RIGHT, potgor & 0x0400); 69 input_report_key(amimouse_dev, BTN_RIGHT, potgor & 0x0400);
73 70
74 input_sync(&amimouse_dev); 71 input_sync(amimouse_dev);
75 72
76 return IRQ_HANDLED; 73 return IRQ_HANDLED;
77} 74}
@@ -103,28 +100,30 @@ static int __init amimouse_init(void)
103 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE)) 100 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_MOUSE))
104 return -ENODEV; 101 return -ENODEV;
105 102
106 amimouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 103 if (!(amimouse_dev = input_allocate_device()))
107 amimouse_dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 104 return -ENOMEM;
108 amimouse_dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 105
109 amimouse_dev.open = amimouse_open; 106 amimouse_dev->name = "Amiga mouse";
110 amimouse_dev.close = amimouse_close; 107 amimouse_dev->phys = "amimouse/input0";
108 amimouse_dev->id.bustype = BUS_AMIGA;
109 amimouse_dev->id.vendor = 0x0001;
110 amimouse_dev->id.product = 0x0002;
111 amimouse_dev->id.version = 0x0100;
111 112
112 amimouse_dev.name = amimouse_name; 113 amimouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
113 amimouse_dev.phys = amimouse_phys; 114 amimouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
114 amimouse_dev.id.bustype = BUS_AMIGA; 115 amimouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
115 amimouse_dev.id.vendor = 0x0001; 116 amimouse_dev->open = amimouse_open;
116 amimouse_dev.id.product = 0x0002; 117 amimouse_dev->close = amimouse_close;
117 amimouse_dev.id.version = 0x0100;
118 118
119 input_register_device(&amimouse_dev); 119 input_register_device(amimouse_dev);
120 120
121 printk(KERN_INFO "input: %s at joy0dat\n", amimouse_name);
122 return 0; 121 return 0;
123} 122}
124 123
125static void __exit amimouse_exit(void) 124static void __exit amimouse_exit(void)
126{ 125{
127 input_unregister_device(&amimouse_dev); 126 input_unregister_device(amimouse_dev);
128} 127}
129 128
130module_init(amimouse_init); 129module_init(amimouse_init);
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c
index bc22849c6c79..c2bf2ed07dc6 100644
--- a/drivers/input/mouse/hil_ptr.c
+++ b/drivers/input/mouse/hil_ptr.c
@@ -196,7 +196,7 @@ static irqreturn_t hil_ptr_interrupt(struct serio *serio,
196 hil_packet packet; 196 hil_packet packet;
197 int idx; 197 int idx;
198 198
199 ptr = (struct hil_ptr *)serio->private; 199 ptr = serio_get_drvdata(serio);
200 if (ptr == NULL) { 200 if (ptr == NULL) {
201 BUG(); 201 BUG();
202 return IRQ_HANDLED; 202 return IRQ_HANDLED;
@@ -227,7 +227,7 @@ static void hil_ptr_disconnect(struct serio *serio)
227{ 227{
228 struct hil_ptr *ptr; 228 struct hil_ptr *ptr;
229 229
230 ptr = (struct hil_ptr *)serio->private; 230 ptr = serio_get_drvdata(serio);
231 if (ptr == NULL) { 231 if (ptr == NULL) {
232 BUG(); 232 BUG();
233 return; 233 return;
@@ -238,21 +238,19 @@ static void hil_ptr_disconnect(struct serio *serio)
238 kfree(ptr); 238 kfree(ptr);
239} 239}
240 240
241static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver) 241static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
242{ 242{
243 struct hil_ptr *ptr; 243 struct hil_ptr *ptr;
244 char *txt; 244 char *txt;
245 unsigned int i, naxsets, btntype; 245 unsigned int i, naxsets, btntype;
246 uint8_t did, *idd; 246 uint8_t did, *idd;
247 247
248 if (serio->type != (SERIO_HIL_MLC | SERIO_HIL)) return; 248 if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return -ENOMEM;
249
250 if (!(ptr = kmalloc(sizeof(struct hil_ptr), GFP_KERNEL))) return;
251 memset(ptr, 0, sizeof(struct hil_ptr)); 249 memset(ptr, 0, sizeof(struct hil_ptr));
252 250
253 if (serio_open(serio, driver)) goto bail0; 251 if (serio_open(serio, driver)) goto bail0;
254 252
255 serio->private = ptr; 253 serio_set_drvdata(serio, ptr);
256 ptr->serio = serio; 254 ptr->serio = serio;
257 ptr->dev.private = ptr; 255 ptr->dev.private = ptr;
258 256
@@ -380,23 +378,34 @@ static void hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
380 (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", 378 (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad",
381 did); 379 did);
382 380
383 return; 381 return 0;
384 bail1: 382 bail1:
385 serio_close(serio); 383 serio_close(serio);
386 bail0: 384 bail0:
387 kfree(ptr); 385 kfree(ptr);
388 return; 386 serio_set_drvdata(serio, NULL);
387 return -ENODEV;
389} 388}
390 389
390static struct serio_device_id hil_ptr_ids[] = {
391 {
392 .type = SERIO_HIL_MLC,
393 .proto = SERIO_HIL,
394 .id = SERIO_ANY,
395 .extra = SERIO_ANY,
396 },
397 { 0 }
398};
391 399
392static struct serio_driver hil_ptr_serio_driver = { 400static struct serio_driver hil_ptr_serio_driver = {
393 .driver = { 401 .driver = {
394 .name = "hil_ptr", 402 .name = "hil_ptr",
395 }, 403 },
396 .description = "HP HIL mouse/tablet driver", 404 .description = "HP HIL mouse/tablet driver",
397 .connect = hil_ptr_connect, 405 .id_table = hil_ptr_ids,
398 .disconnect = hil_ptr_disconnect, 406 .connect = hil_ptr_connect,
399 .interrupt = hil_ptr_interrupt 407 .disconnect = hil_ptr_disconnect,
408 .interrupt = hil_ptr_interrupt
400}; 409};
401 410
402static int __init hil_ptr_init(void) 411static int __init hil_ptr_init(void)
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
index 1f62c0134010..afc66f56df43 100644
--- a/drivers/input/mouse/inport.c
+++ b/drivers/input/mouse/inport.c
@@ -87,40 +87,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
87 87
88__obsolete_setup("inport_irq="); 88__obsolete_setup("inport_irq=");
89 89
90static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); 90static struct input_dev *inport_dev;
91
92static int inport_open(struct input_dev *dev)
93{
94 if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
95 return -EBUSY;
96 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
97 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
98
99 return 0;
100}
101
102static void inport_close(struct input_dev *dev)
103{
104 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
105 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
106 free_irq(inport_irq, NULL);
107}
108
109static struct input_dev inport_dev = {
110 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
111 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
112 .relbit = { BIT(REL_X) | BIT(REL_Y) },
113 .open = inport_open,
114 .close = inport_close,
115 .name = INPORT_NAME,
116 .phys = "isa023c/input0",
117 .id = {
118 .bustype = BUS_ISA,
119 .vendor = INPORT_VENDOR,
120 .product = 0x0001,
121 .version = 0x0100,
122 },
123};
124 91
125static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs) 92static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
126{ 93{
@@ -129,31 +96,48 @@ static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
129 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 96 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
130 outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 97 outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
131 98
132 input_regs(&inport_dev, regs); 99 input_regs(inport_dev, regs);
133 100
134 outb(INPORT_REG_X, INPORT_CONTROL_PORT); 101 outb(INPORT_REG_X, INPORT_CONTROL_PORT);
135 input_report_rel(&inport_dev, REL_X, inb(INPORT_DATA_PORT)); 102 input_report_rel(inport_dev, REL_X, inb(INPORT_DATA_PORT));
136 103
137 outb(INPORT_REG_Y, INPORT_CONTROL_PORT); 104 outb(INPORT_REG_Y, INPORT_CONTROL_PORT);
138 input_report_rel(&inport_dev, REL_Y, inb(INPORT_DATA_PORT)); 105 input_report_rel(inport_dev, REL_Y, inb(INPORT_DATA_PORT));
139 106
140 outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT); 107 outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT);
141 buttons = inb(INPORT_DATA_PORT); 108 buttons = inb(INPORT_DATA_PORT);
142 109
143 input_report_key(&inport_dev, BTN_MIDDLE, buttons & 1); 110 input_report_key(inport_dev, BTN_MIDDLE, buttons & 1);
144 input_report_key(&inport_dev, BTN_LEFT, buttons & 2); 111 input_report_key(inport_dev, BTN_LEFT, buttons & 2);
145 input_report_key(&inport_dev, BTN_RIGHT, buttons & 4); 112 input_report_key(inport_dev, BTN_RIGHT, buttons & 4);
146 113
147 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 114 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
148 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT); 115 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
149 116
150 input_sync(&inport_dev); 117 input_sync(inport_dev);
151 return IRQ_HANDLED; 118 return IRQ_HANDLED;
152} 119}
153 120
121static int inport_open(struct input_dev *dev)
122{
123 if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
124 return -EBUSY;
125 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
126 outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
127
128 return 0;
129}
130
131static void inport_close(struct input_dev *dev)
132{
133 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
134 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
135 free_irq(inport_irq, NULL);
136}
137
154static int __init inport_init(void) 138static int __init inport_init(void)
155{ 139{
156 unsigned char a,b,c; 140 unsigned char a, b, c;
157 141
158 if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { 142 if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
159 printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); 143 printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -163,26 +147,44 @@ static int __init inport_init(void)
163 a = inb(INPORT_SIGNATURE_PORT); 147 a = inb(INPORT_SIGNATURE_PORT);
164 b = inb(INPORT_SIGNATURE_PORT); 148 b = inb(INPORT_SIGNATURE_PORT);
165 c = inb(INPORT_SIGNATURE_PORT); 149 c = inb(INPORT_SIGNATURE_PORT);
166 if (( a == b ) || ( a != c )) { 150 if (a == b || a != c) {
167 release_region(INPORT_BASE, INPORT_EXTENT); 151 release_region(INPORT_BASE, INPORT_EXTENT);
168 printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); 152 printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
169 return -ENODEV; 153 return -ENODEV;
170 } 154 }
171 155
156 if (!(inport_dev = input_allocate_device())) {
157 printk(KERN_ERR "inport.c: Not enough memory for input device\n");
158 release_region(INPORT_BASE, INPORT_EXTENT);
159 return -ENOMEM;
160 }
161
162 inport_dev->name = INPORT_NAME;
163 inport_dev->phys = "isa023c/input0";
164 inport_dev->id.bustype = BUS_ISA;
165 inport_dev->id.vendor = INPORT_VENDOR;
166 inport_dev->id.product = 0x0001;
167 inport_dev->id.version = 0x0100;
168
169 inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
170 inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
171 inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
172
173 inport_dev->open = inport_open;
174 inport_dev->close = inport_close;
175
172 outb(INPORT_RESET, INPORT_CONTROL_PORT); 176 outb(INPORT_RESET, INPORT_CONTROL_PORT);
173 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); 177 outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
174 outb(INPORT_MODE_BASE, INPORT_DATA_PORT); 178 outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
175 179
176 input_register_device(&inport_dev); 180 input_register_device(inport_dev);
177
178 printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq);
179 181
180 return 0; 182 return 0;
181} 183}
182 184
183static void __exit inport_exit(void) 185static void __exit inport_exit(void)
184{ 186{
185 input_unregister_device(&inport_dev); 187 input_unregister_device(inport_dev);
186 release_region(INPORT_BASE, INPORT_EXTENT); 188 release_region(INPORT_BASE, INPORT_EXTENT);
187} 189}
188 190
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index bd9df9b28325..55991424ac91 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -34,7 +34,7 @@ static struct dmi_system_id lifebook_dmi_table[] = {
34static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 34static psmouse_ret_t lifebook_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
35{ 35{
36 unsigned char *packet = psmouse->packet; 36 unsigned char *packet = psmouse->packet;
37 struct input_dev *dev = &psmouse->dev; 37 struct input_dev *dev = psmouse->dev;
38 38
39 if (psmouse->pktcnt != 3) 39 if (psmouse->pktcnt != 3)
40 return PSMOUSE_GOOD_DATA; 40 return PSMOUSE_GOOD_DATA;
@@ -113,15 +113,17 @@ int lifebook_detect(struct psmouse *psmouse, int set_properties)
113 113
114int lifebook_init(struct psmouse *psmouse) 114int lifebook_init(struct psmouse *psmouse)
115{ 115{
116 struct input_dev *input_dev = psmouse->dev;
117
116 if (lifebook_absolute_mode(psmouse)) 118 if (lifebook_absolute_mode(psmouse))
117 return -1; 119 return -1;
118 120
119 psmouse->dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL); 121 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
120 psmouse->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 122 input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
121 psmouse->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 123 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
122 psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 124 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
123 input_set_abs_params(&psmouse->dev, ABS_X, 0, 1024, 0, 0); 125 input_set_abs_params(input_dev, ABS_X, 0, 1024, 0, 0);
124 input_set_abs_params(&psmouse->dev, ABS_Y, 0, 1024, 0, 0); 126 input_set_abs_params(input_dev, ABS_Y, 0, 1024, 0, 0);
125 127
126 psmouse->protocol_handler = lifebook_process_byte; 128 psmouse->protocol_handler = lifebook_process_byte;
127 psmouse->set_resolution = lifebook_set_resolution; 129 psmouse->set_resolution = lifebook_set_resolution;
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
index 8b5243167227..9c7ce38806d7 100644
--- a/drivers/input/mouse/logibm.c
+++ b/drivers/input/mouse/logibm.c
@@ -77,39 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
77 77
78__obsolete_setup("logibm_irq="); 78__obsolete_setup("logibm_irq=");
79 79
80static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); 80static struct input_dev *logibm_dev;
81
82static int logibm_open(struct input_dev *dev)
83{
84 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
85 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
86 return -EBUSY;
87 }
88 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
89 return 0;
90}
91
92static void logibm_close(struct input_dev *dev)
93{
94 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
95 free_irq(logibm_irq, NULL);
96}
97
98static struct input_dev logibm_dev = {
99 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
100 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
101 .relbit = { BIT(REL_X) | BIT(REL_Y) },
102 .open = logibm_open,
103 .close = logibm_close,
104 .name = "Logitech bus mouse",
105 .phys = "isa023c/input0",
106 .id = {
107 .bustype = BUS_ISA,
108 .vendor = 0x0003,
109 .product = 0x0001,
110 .version = 0x0100,
111 },
112};
113 81
114static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs) 82static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
115{ 83{
@@ -127,18 +95,34 @@ static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
127 dy |= (buttons & 0xf) << 4; 95 dy |= (buttons & 0xf) << 4;
128 buttons = ~buttons >> 5; 96 buttons = ~buttons >> 5;
129 97
130 input_regs(&logibm_dev, regs); 98 input_regs(logibm_dev, regs);
131 input_report_rel(&logibm_dev, REL_X, dx); 99 input_report_rel(logibm_dev, REL_X, dx);
132 input_report_rel(&logibm_dev, REL_Y, dy); 100 input_report_rel(logibm_dev, REL_Y, dy);
133 input_report_key(&logibm_dev, BTN_RIGHT, buttons & 1); 101 input_report_key(logibm_dev, BTN_RIGHT, buttons & 1);
134 input_report_key(&logibm_dev, BTN_MIDDLE, buttons & 2); 102 input_report_key(logibm_dev, BTN_MIDDLE, buttons & 2);
135 input_report_key(&logibm_dev, BTN_LEFT, buttons & 4); 103 input_report_key(logibm_dev, BTN_LEFT, buttons & 4);
136 input_sync(&logibm_dev); 104 input_sync(logibm_dev);
137 105
138 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT); 106 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
139 return IRQ_HANDLED; 107 return IRQ_HANDLED;
140} 108}
141 109
110static int logibm_open(struct input_dev *dev)
111{
112 if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
113 printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
114 return -EBUSY;
115 }
116 outb(LOGIBM_ENABLE_IRQ, LOGIBM_CONTROL_PORT);
117 return 0;
118}
119
120static void logibm_close(struct input_dev *dev)
121{
122 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
123 free_irq(logibm_irq, NULL);
124}
125
142static int __init logibm_init(void) 126static int __init logibm_init(void)
143{ 127{
144 if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { 128 if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
@@ -159,16 +143,34 @@ static int __init logibm_init(void)
159 outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); 143 outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT);
160 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); 144 outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
161 145
162 input_register_device(&logibm_dev); 146 if (!(logibm_dev = input_allocate_device())) {
147 printk(KERN_ERR "logibm.c: Not enough memory for input device\n");
148 release_region(LOGIBM_BASE, LOGIBM_EXTENT);
149 return -ENOMEM;
150 }
151
152 logibm_dev->name = "Logitech bus mouse";
153 logibm_dev->phys = "isa023c/input0";
154 logibm_dev->id.bustype = BUS_ISA;
155 logibm_dev->id.vendor = 0x0003;
156 logibm_dev->id.product = 0x0001;
157 logibm_dev->id.version = 0x0100;
158
159 logibm_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
160 logibm_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
161 logibm_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
162
163 logibm_dev->open = logibm_open;
164 logibm_dev->close = logibm_close;
163 165
164 printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq); 166 input_register_device(logibm_dev);
165 167
166 return 0; 168 return 0;
167} 169}
168 170
169static void __exit logibm_exit(void) 171static void __exit logibm_exit(void)
170{ 172{
171 input_unregister_device(&logibm_dev); 173 input_unregister_device(logibm_dev);
172 release_region(LOGIBM_BASE, LOGIBM_EXTENT); 174 release_region(LOGIBM_BASE, LOGIBM_EXTENT);
173} 175}
174 176
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c
index 7df96525222e..0f69ff46c1ae 100644
--- a/drivers/input/mouse/logips2pp.c
+++ b/drivers/input/mouse/logips2pp.c
@@ -40,7 +40,7 @@ struct ps2pp_info {
40 40
41static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 41static psmouse_ret_t ps2pp_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
42{ 42{
43 struct input_dev *dev = &psmouse->dev; 43 struct input_dev *dev = psmouse->dev;
44 unsigned char *packet = psmouse->packet; 44 unsigned char *packet = psmouse->packet;
45 45
46 if (psmouse->pktcnt < 3) 46 if (psmouse->pktcnt < 3)
@@ -257,25 +257,27 @@ static struct ps2pp_info *get_model_info(unsigned char model)
257static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info, 257static void ps2pp_set_model_properties(struct psmouse *psmouse, struct ps2pp_info *model_info,
258 int using_ps2pp) 258 int using_ps2pp)
259{ 259{
260 struct input_dev *input_dev = psmouse->dev;
261
260 if (model_info->features & PS2PP_SIDE_BTN) 262 if (model_info->features & PS2PP_SIDE_BTN)
261 set_bit(BTN_SIDE, psmouse->dev.keybit); 263 set_bit(BTN_SIDE, input_dev->keybit);
262 264
263 if (model_info->features & PS2PP_EXTRA_BTN) 265 if (model_info->features & PS2PP_EXTRA_BTN)
264 set_bit(BTN_EXTRA, psmouse->dev.keybit); 266 set_bit(BTN_EXTRA, input_dev->keybit);
265 267
266 if (model_info->features & PS2PP_TASK_BTN) 268 if (model_info->features & PS2PP_TASK_BTN)
267 set_bit(BTN_TASK, psmouse->dev.keybit); 269 set_bit(BTN_TASK, input_dev->keybit);
268 270
269 if (model_info->features & PS2PP_NAV_BTN) { 271 if (model_info->features & PS2PP_NAV_BTN) {
270 set_bit(BTN_FORWARD, psmouse->dev.keybit); 272 set_bit(BTN_FORWARD, input_dev->keybit);
271 set_bit(BTN_BACK, psmouse->dev.keybit); 273 set_bit(BTN_BACK, input_dev->keybit);
272 } 274 }
273 275
274 if (model_info->features & PS2PP_WHEEL) 276 if (model_info->features & PS2PP_WHEEL)
275 set_bit(REL_WHEEL, psmouse->dev.relbit); 277 set_bit(REL_WHEEL, input_dev->relbit);
276 278
277 if (model_info->features & PS2PP_HWHEEL) 279 if (model_info->features & PS2PP_HWHEEL)
278 set_bit(REL_HWHEEL, psmouse->dev.relbit); 280 set_bit(REL_HWHEEL, input_dev->relbit);
279 281
280 switch (model_info->kind) { 282 switch (model_info->kind) {
281 case PS2PP_KIND_WHEEL: 283 case PS2PP_KIND_WHEEL:
@@ -387,7 +389,7 @@ int ps2pp_init(struct psmouse *psmouse, int set_properties)
387 } 389 }
388 390
389 if (buttons < 3) 391 if (buttons < 3)
390 clear_bit(BTN_MIDDLE, psmouse->dev.keybit); 392 clear_bit(BTN_MIDDLE, psmouse->dev->keybit);
391 393
392 if (model_info) 394 if (model_info)
393 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp); 395 ps2pp_set_model_properties(psmouse, model_info, use_ps2pp);
diff --git a/drivers/input/mouse/maplemouse.c b/drivers/input/mouse/maplemouse.c
index e90c60cbbf05..b5b34fe4fee8 100644
--- a/drivers/input/mouse/maplemouse.c
+++ b/drivers/input/mouse/maplemouse.c
@@ -41,13 +41,12 @@ static int dc_mouse_connect(struct maple_device *dev)
41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); 41 unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
42 struct input_dev *input_dev; 42 struct input_dev *input_dev;
43 43
44 if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL))) 44 dev->private_data = input_dev = input_allocate_device();
45 return -1; 45 if (!input_dev)
46 return -ENOMEM;
46 47
47 dev->private_data = input_dev; 48 dev->private_data = input_dev;
48 49
49 memset(input_dev, 0, sizeof(struct dc_mouse));
50 init_input_dev(input_dev);
51 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 50 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
52 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 51 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
53 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL); 52 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
@@ -59,8 +58,6 @@ static int dc_mouse_connect(struct maple_device *dev)
59 58
60 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); 59 maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);
61 60
62 printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
63
64 return 0; 61 return 0;
65} 62}
66 63
@@ -70,7 +67,6 @@ static void dc_mouse_disconnect(struct maple_device *dev)
70 struct input_dev *input_dev = dev->private_data; 67 struct input_dev *input_dev = dev->private_data;
71 68
72 input_unregister_device(input_dev); 69 input_unregister_device(input_dev);
73 kfree(input_dev);
74} 70}
75 71
76 72
diff --git a/drivers/input/mouse/pc110pad.c b/drivers/input/mouse/pc110pad.c
index 93393d5c0078..d284ea712151 100644
--- a/drivers/input/mouse/pc110pad.c
+++ b/drivers/input/mouse/pc110pad.c
@@ -53,13 +53,10 @@ MODULE_LICENSE("GPL");
53static int pc110pad_irq = 10; 53static int pc110pad_irq = 10;
54static int pc110pad_io = 0x15e0; 54static int pc110pad_io = 0x15e0;
55 55
56static struct input_dev pc110pad_dev; 56static struct input_dev *pc110pad_dev;
57static int pc110pad_data[3]; 57static int pc110pad_data[3];
58static int pc110pad_count; 58static int pc110pad_count;
59 59
60static char *pc110pad_name = "IBM PC110 TouchPad";
61static char *pc110pad_phys = "isa15e0/input0";
62
63static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) 60static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
64{ 61{
65 int value = inb_p(pc110pad_io); 62 int value = inb_p(pc110pad_io);
@@ -74,14 +71,14 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
74 if (pc110pad_count < 3) 71 if (pc110pad_count < 3)
75 return IRQ_HANDLED; 72 return IRQ_HANDLED;
76 73
77 input_regs(&pc110pad_dev, regs); 74 input_regs(pc110pad_dev, regs);
78 input_report_key(&pc110pad_dev, BTN_TOUCH, 75 input_report_key(pc110pad_dev, BTN_TOUCH,
79 pc110pad_data[0] & 0x01); 76 pc110pad_data[0] & 0x01);
80 input_report_abs(&pc110pad_dev, ABS_X, 77 input_report_abs(pc110pad_dev, ABS_X,
81 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100)); 78 pc110pad_data[1] | ((pc110pad_data[0] << 3) & 0x80) | ((pc110pad_data[0] << 1) & 0x100));
82 input_report_abs(&pc110pad_dev, ABS_Y, 79 input_report_abs(pc110pad_dev, ABS_Y,
83 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80)); 80 pc110pad_data[2] | ((pc110pad_data[0] << 4) & 0x80));
84 input_sync(&pc110pad_dev); 81 input_sync(pc110pad_dev);
85 82
86 pc110pad_count = 0; 83 pc110pad_count = 0;
87 return IRQ_HANDLED; 84 return IRQ_HANDLED;
@@ -94,9 +91,9 @@ static void pc110pad_close(struct input_dev *dev)
94 91
95static int pc110pad_open(struct input_dev *dev) 92static int pc110pad_open(struct input_dev *dev)
96{ 93{
97 pc110pad_interrupt(0,NULL,NULL); 94 pc110pad_interrupt(0, NULL, NULL);
98 pc110pad_interrupt(0,NULL,NULL); 95 pc110pad_interrupt(0, NULL, NULL);
99 pc110pad_interrupt(0,NULL,NULL); 96 pc110pad_interrupt(0, NULL, NULL);
100 outb(PC110PAD_ON, pc110pad_io + 2); 97 outb(PC110PAD_ON, pc110pad_io + 2);
101 pc110pad_count = 0; 98 pc110pad_count = 0;
102 99
@@ -127,45 +124,46 @@ static int __init pc110pad_init(void)
127 124
128 outb(PC110PAD_OFF, pc110pad_io + 2); 125 outb(PC110PAD_OFF, pc110pad_io + 2);
129 126
130 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) 127 if (request_irq(pc110pad_irq, pc110pad_interrupt, 0, "pc110pad", NULL)) {
131 {
132 release_region(pc110pad_io, 4); 128 release_region(pc110pad_io, 4);
133 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq); 129 printk(KERN_ERR "pc110pad: Unable to get irq %d.\n", pc110pad_irq);
134 return -EBUSY; 130 return -EBUSY;
135 } 131 }
136 132
137 pc110pad_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 133 if (!(pc110pad_dev = input_allocate_device())) {
138 pc110pad_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 134 free_irq(pc110pad_irq, NULL);
139 pc110pad_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 135 release_region(pc110pad_io, 4);
136 printk(KERN_ERR "pc110pad: Not enough memory.\n");
137 return -ENOMEM;
138 }
140 139
141 pc110pad_dev.absmax[ABS_X] = 0x1ff; 140 pc110pad_dev->name = "IBM PC110 TouchPad";
142 pc110pad_dev.absmax[ABS_Y] = 0x0ff; 141 pc110pad_dev->phys = "isa15e0/input0";
142 pc110pad_dev->id.bustype = BUS_ISA;
143 pc110pad_dev->id.vendor = 0x0003;
144 pc110pad_dev->id.product = 0x0001;
145 pc110pad_dev->id.version = 0x0100;
143 146
144 pc110pad_dev.open = pc110pad_open; 147 pc110pad_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
145 pc110pad_dev.close = pc110pad_close; 148 pc110pad_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
149 pc110pad_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
146 150
147 pc110pad_dev.name = pc110pad_name; 151 pc110pad_dev->absmax[ABS_X] = 0x1ff;
148 pc110pad_dev.phys = pc110pad_phys; 152 pc110pad_dev->absmax[ABS_Y] = 0x0ff;
149 pc110pad_dev.id.bustype = BUS_ISA;
150 pc110pad_dev.id.vendor = 0x0003;
151 pc110pad_dev.id.product = 0x0001;
152 pc110pad_dev.id.version = 0x0100;
153 153
154 input_register_device(&pc110pad_dev); 154 pc110pad_dev->open = pc110pad_open;
155 pc110pad_dev->close = pc110pad_close;
155 156
156 printk(KERN_INFO "input: %s at %#x irq %d\n", 157 input_register_device(pc110pad_dev);
157 pc110pad_name, pc110pad_io, pc110pad_irq);
158 158
159 return 0; 159 return 0;
160} 160}
161 161
162static void __exit pc110pad_exit(void) 162static void __exit pc110pad_exit(void)
163{ 163{
164 input_unregister_device(&pc110pad_dev);
165
166 outb(PC110PAD_OFF, pc110pad_io + 2); 164 outb(PC110PAD_OFF, pc110pad_io + 2);
167
168 free_irq(pc110pad_irq, NULL); 165 free_irq(pc110pad_irq, NULL);
166 input_unregister_device(pc110pad_dev);
169 release_region(pc110pad_io, 4); 167 release_region(pc110pad_io, 4);
170} 168}
171 169
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index af24313ff5bb..6ee9999a2eaa 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -114,7 +114,7 @@ struct psmouse_protocol {
114 114
115static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 115static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
116{ 116{
117 struct input_dev *dev = &psmouse->dev; 117 struct input_dev *dev = psmouse->dev;
118 unsigned char *packet = psmouse->packet; 118 unsigned char *packet = psmouse->packet;
119 119
120 if (psmouse->pktcnt < psmouse->pktsize) 120 if (psmouse->pktcnt < psmouse->pktsize)
@@ -333,12 +333,11 @@ static int genius_detect(struct psmouse *psmouse, int set_properties)
333 return -1; 333 return -1;
334 334
335 if (set_properties) { 335 if (set_properties) {
336 set_bit(BTN_EXTRA, psmouse->dev.keybit); 336 set_bit(BTN_EXTRA, psmouse->dev->keybit);
337 set_bit(BTN_SIDE, psmouse->dev.keybit); 337 set_bit(BTN_SIDE, psmouse->dev->keybit);
338 set_bit(REL_WHEEL, psmouse->dev.relbit); 338 set_bit(REL_WHEEL, psmouse->dev->relbit);
339 339
340 psmouse->vendor = "Genius"; 340 psmouse->vendor = "Genius";
341 psmouse->name = "Wheel Mouse";
342 psmouse->pktsize = 4; 341 psmouse->pktsize = 4;
343 } 342 }
344 343
@@ -365,8 +364,8 @@ static int intellimouse_detect(struct psmouse *psmouse, int set_properties)
365 return -1; 364 return -1;
366 365
367 if (set_properties) { 366 if (set_properties) {
368 set_bit(BTN_MIDDLE, psmouse->dev.keybit); 367 set_bit(BTN_MIDDLE, psmouse->dev->keybit);
369 set_bit(REL_WHEEL, psmouse->dev.relbit); 368 set_bit(REL_WHEEL, psmouse->dev->relbit);
370 369
371 if (!psmouse->vendor) psmouse->vendor = "Generic"; 370 if (!psmouse->vendor) psmouse->vendor = "Generic";
372 if (!psmouse->name) psmouse->name = "Wheel Mouse"; 371 if (!psmouse->name) psmouse->name = "Wheel Mouse";
@@ -398,10 +397,10 @@ static int im_explorer_detect(struct psmouse *psmouse, int set_properties)
398 return -1; 397 return -1;
399 398
400 if (set_properties) { 399 if (set_properties) {
401 set_bit(BTN_MIDDLE, psmouse->dev.keybit); 400 set_bit(BTN_MIDDLE, psmouse->dev->keybit);
402 set_bit(REL_WHEEL, psmouse->dev.relbit); 401 set_bit(REL_WHEEL, psmouse->dev->relbit);
403 set_bit(BTN_SIDE, psmouse->dev.keybit); 402 set_bit(BTN_SIDE, psmouse->dev->keybit);
404 set_bit(BTN_EXTRA, psmouse->dev.keybit); 403 set_bit(BTN_EXTRA, psmouse->dev->keybit);
405 404
406 if (!psmouse->vendor) psmouse->vendor = "Generic"; 405 if (!psmouse->vendor) psmouse->vendor = "Generic";
407 if (!psmouse->name) psmouse->name = "Explorer Mouse"; 406 if (!psmouse->name) psmouse->name = "Explorer Mouse";
@@ -433,7 +432,7 @@ static int thinking_detect(struct psmouse *psmouse, int set_properties)
433 return -1; 432 return -1;
434 433
435 if (set_properties) { 434 if (set_properties) {
436 set_bit(BTN_EXTRA, psmouse->dev.keybit); 435 set_bit(BTN_EXTRA, psmouse->dev->keybit);
437 436
438 psmouse->vendor = "Kensington"; 437 psmouse->vendor = "Kensington";
439 psmouse->name = "ThinkingMouse"; 438 psmouse->name = "ThinkingMouse";
@@ -839,9 +838,9 @@ static void psmouse_disconnect(struct serio *serio)
839 838
840 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 839 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
841 840
842 input_unregister_device(&psmouse->dev);
843 serio_close(serio); 841 serio_close(serio);
844 serio_set_drvdata(serio, NULL); 842 serio_set_drvdata(serio, NULL);
843 input_unregister_device(psmouse->dev);
845 kfree(psmouse); 844 kfree(psmouse);
846 845
847 if (parent) 846 if (parent)
@@ -852,16 +851,14 @@ static void psmouse_disconnect(struct serio *serio)
852 851
853static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 852static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto)
854{ 853{
855 memset(&psmouse->dev, 0, sizeof(struct input_dev)); 854 struct input_dev *input_dev = psmouse->dev;
856 855
857 init_input_dev(&psmouse->dev); 856 input_dev->private = psmouse;
857 input_dev->cdev.dev = &psmouse->ps2dev.serio->dev;
858 858
859 psmouse->dev.private = psmouse; 859 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
860 psmouse->dev.dev = &psmouse->ps2dev.serio->dev; 860 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
861 861 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
862 psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
863 psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
864 psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
865 862
866 psmouse->set_rate = psmouse_set_rate; 863 psmouse->set_rate = psmouse_set_rate;
867 psmouse->set_resolution = psmouse_set_resolution; 864 psmouse->set_resolution = psmouse_set_resolution;
@@ -883,12 +880,12 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto
883 sprintf(psmouse->devname, "%s %s %s", 880 sprintf(psmouse->devname, "%s %s %s",
884 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); 881 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name);
885 882
886 psmouse->dev.name = psmouse->devname; 883 input_dev->name = psmouse->devname;
887 psmouse->dev.phys = psmouse->phys; 884 input_dev->phys = psmouse->phys;
888 psmouse->dev.id.bustype = BUS_I8042; 885 input_dev->id.bustype = BUS_I8042;
889 psmouse->dev.id.vendor = 0x0002; 886 input_dev->id.vendor = 0x0002;
890 psmouse->dev.id.product = psmouse->type; 887 input_dev->id.product = psmouse->type;
891 psmouse->dev.id.version = psmouse->model; 888 input_dev->id.version = psmouse->model;
892 889
893 return 0; 890 return 0;
894} 891}
@@ -900,7 +897,8 @@ static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_proto
900static int psmouse_connect(struct serio *serio, struct serio_driver *drv) 897static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
901{ 898{
902 struct psmouse *psmouse, *parent = NULL; 899 struct psmouse *psmouse, *parent = NULL;
903 int retval; 900 struct input_dev *input_dev;
901 int retval = -ENOMEM;
904 902
905 down(&psmouse_sem); 903 down(&psmouse_sem);
906 904
@@ -913,12 +911,13 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
913 psmouse_deactivate(parent); 911 psmouse_deactivate(parent);
914 } 912 }
915 913
916 if (!(psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL))) { 914 psmouse = kzalloc(sizeof(struct psmouse), GFP_KERNEL);
917 retval = -ENOMEM; 915 input_dev = input_allocate_device();
916 if (!psmouse || !input_dev)
918 goto out; 917 goto out;
919 }
920 918
921 ps2_init(&psmouse->ps2dev, serio); 919 ps2_init(&psmouse->ps2dev, serio);
920 psmouse->dev = input_dev;
922 sprintf(psmouse->phys, "%s/input0", serio->phys); 921 sprintf(psmouse->phys, "%s/input0", serio->phys);
923 922
924 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 923 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
@@ -926,16 +925,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
926 serio_set_drvdata(serio, psmouse); 925 serio_set_drvdata(serio, psmouse);
927 926
928 retval = serio_open(serio, drv); 927 retval = serio_open(serio, drv);
929 if (retval) { 928 if (retval)
930 serio_set_drvdata(serio, NULL);
931 kfree(psmouse);
932 goto out; 929 goto out;
933 }
934 930
935 if (psmouse_probe(psmouse) < 0) { 931 if (psmouse_probe(psmouse) < 0) {
936 serio_close(serio); 932 serio_close(serio);
937 serio_set_drvdata(serio, NULL);
938 kfree(psmouse);
939 retval = -ENODEV; 933 retval = -ENODEV;
940 goto out; 934 goto out;
941 } 935 }
@@ -947,13 +941,11 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
947 941
948 psmouse_switch_protocol(psmouse, NULL); 942 psmouse_switch_protocol(psmouse, NULL);
949 943
950 input_register_device(&psmouse->dev);
951 printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
952
953 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 944 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
954
955 psmouse_initialize(psmouse); 945 psmouse_initialize(psmouse);
956 946
947 input_register_device(psmouse->dev);
948
957 if (parent && parent->pt_activate) 949 if (parent && parent->pt_activate)
958 parent->pt_activate(parent); 950 parent->pt_activate(parent);
959 951
@@ -964,6 +956,12 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
964 retval = 0; 956 retval = 0;
965 957
966out: 958out:
959 if (retval) {
960 serio_set_drvdata(serio, NULL);
961 input_free_device(input_dev);
962 kfree(psmouse);
963 }
964
967 /* If this is a pass-through port the parent needs to be re-activated */ 965 /* If this is a pass-through port the parent needs to be re-activated */
968 if (parent) 966 if (parent)
969 psmouse_activate(parent); 967 psmouse_activate(parent);
@@ -1161,6 +1159,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1161{ 1159{
1162 struct serio *serio = psmouse->ps2dev.serio; 1160 struct serio *serio = psmouse->ps2dev.serio;
1163 struct psmouse *parent = NULL; 1161 struct psmouse *parent = NULL;
1162 struct input_dev *new_dev;
1164 struct psmouse_protocol *proto; 1163 struct psmouse_protocol *proto;
1165 int retry = 0; 1164 int retry = 0;
1166 1165
@@ -1170,9 +1169,13 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1170 if (psmouse->type == proto->type) 1169 if (psmouse->type == proto->type)
1171 return count; 1170 return count;
1172 1171
1172 if (!(new_dev = input_allocate_device()))
1173 return -ENOMEM;
1174
1173 while (serio->child) { 1175 while (serio->child) {
1174 if (++retry > 3) { 1176 if (++retry > 3) {
1175 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n"); 1177 printk(KERN_WARNING "psmouse: failed to destroy child port, protocol change aborted.\n");
1178 input_free_device(new_dev);
1176 return -EIO; 1179 return -EIO;
1177 } 1180 }
1178 1181
@@ -1182,11 +1185,15 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1182 serio_pin_driver_uninterruptible(serio); 1185 serio_pin_driver_uninterruptible(serio);
1183 down(&psmouse_sem); 1186 down(&psmouse_sem);
1184 1187
1185 if (serio->drv != &psmouse_drv) 1188 if (serio->drv != &psmouse_drv) {
1189 input_free_device(new_dev);
1186 return -ENODEV; 1190 return -ENODEV;
1191 }
1187 1192
1188 if (psmouse->type == proto->type) 1193 if (psmouse->type == proto->type) {
1194 input_free_device(new_dev);
1189 return count; /* switched by other thread */ 1195 return count; /* switched by other thread */
1196 }
1190 } 1197 }
1191 1198
1192 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1199 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
@@ -1199,8 +1206,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1199 psmouse->disconnect(psmouse); 1206 psmouse->disconnect(psmouse);
1200 1207
1201 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 1208 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1202 input_unregister_device(&psmouse->dev); 1209 input_unregister_device(psmouse->dev);
1203 1210
1211 psmouse->dev = new_dev;
1204 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 1212 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1205 1213
1206 if (psmouse_switch_protocol(psmouse, proto) < 0) { 1214 if (psmouse_switch_protocol(psmouse, proto) < 0) {
@@ -1212,8 +1220,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1212 psmouse_initialize(psmouse); 1220 psmouse_initialize(psmouse);
1213 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1221 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1214 1222
1215 input_register_device(&psmouse->dev); 1223 input_register_device(psmouse->dev);
1216 printk(KERN_INFO "input: %s on %s\n", psmouse->devname, serio->phys);
1217 1224
1218 if (parent && parent->pt_activate) 1225 if (parent && parent->pt_activate)
1219 parent->pt_activate(parent); 1226 parent->pt_activate(parent);
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 45d2bd774f00..7c4192bd1279 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -36,7 +36,7 @@ typedef enum {
36 36
37struct psmouse { 37struct psmouse {
38 void *private; 38 void *private;
39 struct input_dev dev; 39 struct input_dev *dev;
40 struct ps2dev ps2dev; 40 struct ps2dev ps2dev;
41 char *vendor; 41 char *vendor;
42 char *name; 42 char *name;
diff --git a/drivers/input/mouse/rpcmouse.c b/drivers/input/mouse/rpcmouse.c
index 8fe1212b8fd7..09b6ffdb7582 100644
--- a/drivers/input/mouse/rpcmouse.c
+++ b/drivers/input/mouse/rpcmouse.c
@@ -34,20 +34,7 @@ MODULE_DESCRIPTION("Acorn RiscPC mouse driver");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36static short rpcmouse_lastx, rpcmouse_lasty; 36static short rpcmouse_lastx, rpcmouse_lasty;
37 37static struct input_dev *rpcmouse_dev;
38static struct input_dev rpcmouse_dev = {
39 .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
40 .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
41 .relbit = { BIT(REL_X) | BIT(REL_Y) },
42 .name = "Acorn RiscPC Mouse",
43 .phys = "rpcmouse/input0",
44 .id = {
45 .bustype = BUS_HOST,
46 .vendor = 0x0005,
47 .product = 0x0001,
48 .version = 0x0100,
49 },
50};
51 38
52static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs) 39static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
53{ 40{
@@ -78,29 +65,41 @@ static irqreturn_t rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
78 return IRQ_HANDLED; 65 return IRQ_HANDLED;
79} 66}
80 67
68
81static int __init rpcmouse_init(void) 69static int __init rpcmouse_init(void)
82{ 70{
83 init_input_dev(&rpcmouse_dev); 71 if (!(rpcmouse_dev = input_allocate_device()))
72 return -ENOMEM;
73
74 rpcmouse_dev->name = "Acorn RiscPC Mouse";
75 rpcmouse_dev->phys = "rpcmouse/input0";
76 rpcmouse_dev->id.bustype = BUS_HOST;
77 rpcmouse_dev->id.vendor = 0x0005;
78 rpcmouse_dev->id.product = 0x0001;
79 rpcmouse_dev->id.version = 0x0100;
80
81 rpcmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
82 rpcmouse_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
83 rpcmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
84 84
85 rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX); 85 rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX);
86 rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY); 86 rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY);
87 87
88 if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", &rpcmouse_dev)) { 88 if (request_irq(IRQ_VSYNCPULSE, rpcmouse_irq, SA_SHIRQ, "rpcmouse", rpcmouse_dev)) {
89 printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n"); 89 printk(KERN_ERR "rpcmouse: unable to allocate VSYNC interrupt\n");
90 return -1; 90 input_free_device(rpcmouse_dev);
91 return -EBUSY;
91 } 92 }
92 93
93 input_register_device(&rpcmouse_dev); 94 input_register_device(rpcmouse_dev);
94
95 printk(KERN_INFO "input: Acorn RiscPC mouse\n");
96 95
97 return 0; 96 return 0;
98} 97}
99 98
100static void __exit rpcmouse_exit(void) 99static void __exit rpcmouse_exit(void)
101{ 100{
102 input_unregister_device(&rpcmouse_dev); 101 free_irq(IRQ_VSYNCPULSE, rpcmouse_dev);
103 free_irq(IRQ_VSYNCPULSE, &rpcmouse_dev); 102 input_unregister_device(rpcmouse_dev);
104} 103}
105 104
106module_init(rpcmouse_init); 105module_init(rpcmouse_init);
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index d12b93ae3900..4bf584364d28 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -48,7 +48,7 @@ static char *sermouse_protocols[] = { "None", "Mouse Systems Mouse", "Sun Mouse"
48 "Logitech MZ++ Mouse"}; 48 "Logitech MZ++ Mouse"};
49 49
50struct sermouse { 50struct sermouse {
51 struct input_dev dev; 51 struct input_dev *dev;
52 signed char buf[8]; 52 signed char buf[8];
53 unsigned char count; 53 unsigned char count;
54 unsigned char type; 54 unsigned char type;
@@ -64,7 +64,7 @@ struct sermouse {
64 64
65static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs) 65static void sermouse_process_msc(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
66{ 66{
67 struct input_dev *dev = &sermouse->dev; 67 struct input_dev *dev = sermouse->dev;
68 signed char *buf = sermouse->buf; 68 signed char *buf = sermouse->buf;
69 69
70 input_regs(dev, regs); 70 input_regs(dev, regs);
@@ -107,7 +107,7 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data, st
107 107
108static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs) 108static void sermouse_process_ms(struct sermouse *sermouse, signed char data, struct pt_regs *regs)
109{ 109{
110 struct input_dev *dev = &sermouse->dev; 110 struct input_dev *dev = sermouse->dev;
111 signed char *buf = sermouse->buf; 111 signed char *buf = sermouse->buf;
112 112
113 if (data & 0x40) sermouse->count = 0; 113 if (data & 0x40) sermouse->count = 0;
@@ -230,9 +230,9 @@ static void sermouse_disconnect(struct serio *serio)
230{ 230{
231 struct sermouse *sermouse = serio_get_drvdata(serio); 231 struct sermouse *sermouse = serio_get_drvdata(serio);
232 232
233 input_unregister_device(&sermouse->dev);
234 serio_close(serio); 233 serio_close(serio);
235 serio_set_drvdata(serio, NULL); 234 serio_set_drvdata(serio, NULL);
235 input_unregister_device(sermouse->dev);
236 kfree(sermouse); 236 kfree(sermouse);
237} 237}
238 238
@@ -244,56 +244,52 @@ static void sermouse_disconnect(struct serio *serio)
244static int sermouse_connect(struct serio *serio, struct serio_driver *drv) 244static int sermouse_connect(struct serio *serio, struct serio_driver *drv)
245{ 245{
246 struct sermouse *sermouse; 246 struct sermouse *sermouse;
247 unsigned char c; 247 struct input_dev *input_dev;
248 int err; 248 unsigned char c = serio->id.extra;
249 int err = -ENOMEM;
249 250
250 if (!serio->id.proto || serio->id.proto > SERIO_MZPP) 251 sermouse = kzalloc(sizeof(struct sermouse), GFP_KERNEL);
251 return -ENODEV; 252 input_dev = input_allocate_device();
252 253 if (!sermouse || !input_dev)
253 if (!(sermouse = kmalloc(sizeof(struct sermouse), GFP_KERNEL))) 254 goto fail;
254 return -ENOMEM;
255
256 memset(sermouse, 0, sizeof(struct sermouse));
257
258 init_input_dev(&sermouse->dev);
259 sermouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
260 sermouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
261 sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
262 sermouse->dev.private = sermouse;
263
264 sermouse->type = serio->id.proto;
265 c = serio->id.extra;
266
267 if (c & 0x01) set_bit(BTN_MIDDLE, sermouse->dev.keybit);
268 if (c & 0x02) set_bit(BTN_SIDE, sermouse->dev.keybit);
269 if (c & 0x04) set_bit(BTN_EXTRA, sermouse->dev.keybit);
270 if (c & 0x10) set_bit(REL_WHEEL, sermouse->dev.relbit);
271 if (c & 0x20) set_bit(REL_HWHEEL, sermouse->dev.relbit);
272 255
256 sermouse->dev = input_dev;
273 sprintf(sermouse->phys, "%s/input0", serio->phys); 257 sprintf(sermouse->phys, "%s/input0", serio->phys);
258 sermouse->type = serio->id.proto;
274 259
275 sermouse->dev.name = sermouse_protocols[sermouse->type]; 260 input_dev->name = sermouse_protocols[sermouse->type];
276 sermouse->dev.phys = sermouse->phys; 261 input_dev->phys = sermouse->phys;
277 sermouse->dev.id.bustype = BUS_RS232; 262 input_dev->id.bustype = BUS_RS232;
278 sermouse->dev.id.vendor = sermouse->type; 263 input_dev->id.vendor = sermouse->type;
279 sermouse->dev.id.product = c; 264 input_dev->id.product = c;
280 sermouse->dev.id.version = 0x0100; 265 input_dev->id.version = 0x0100;
281 sermouse->dev.dev = &serio->dev; 266 input_dev->cdev.dev = &serio->dev;
267
268 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
269 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
270 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
271 input_dev->private = sermouse;
272
273 if (c & 0x01) set_bit(BTN_MIDDLE, input_dev->keybit);
274 if (c & 0x02) set_bit(BTN_SIDE, input_dev->keybit);
275 if (c & 0x04) set_bit(BTN_EXTRA, input_dev->keybit);
276 if (c & 0x10) set_bit(REL_WHEEL, input_dev->relbit);
277 if (c & 0x20) set_bit(REL_HWHEEL, input_dev->relbit);
282 278
283 serio_set_drvdata(serio, sermouse); 279 serio_set_drvdata(serio, sermouse);
284 280
285 err = serio_open(serio, drv); 281 err = serio_open(serio, drv);
286 if (err) { 282 if (err)
287 serio_set_drvdata(serio, NULL); 283 goto fail;
288 kfree(sermouse);
289 return err;
290 }
291
292 input_register_device(&sermouse->dev);
293 284
294 printk(KERN_INFO "input: %s on %s\n", sermouse_protocols[sermouse->type], serio->phys); 285 input_register_device(sermouse->dev);
295 286
296 return 0; 287 return 0;
288
289 fail: serio_set_drvdata(serio, NULL);
290 input_free_device(input_dev);
291 kfree(sermouse);
292 return err;
297} 293}
298 294
299static struct serio_device_id sermouse_serio_ids[] = { 295static struct serio_device_id sermouse_serio_ids[] = {
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 029309422409..97cdfd6acaca 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -342,7 +342,7 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
342 */ 342 */
343static void synaptics_process_packet(struct psmouse *psmouse) 343static void synaptics_process_packet(struct psmouse *psmouse)
344{ 344{
345 struct input_dev *dev = &psmouse->dev; 345 struct input_dev *dev = psmouse->dev;
346 struct synaptics_data *priv = psmouse->private; 346 struct synaptics_data *priv = psmouse->private;
347 struct synaptics_hw_state hw; 347 struct synaptics_hw_state hw;
348 int num_fingers; 348 int num_fingers;
@@ -473,7 +473,7 @@ static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse)
473 473
474static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs) 474static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
475{ 475{
476 struct input_dev *dev = &psmouse->dev; 476 struct input_dev *dev = psmouse->dev;
477 struct synaptics_data *priv = psmouse->private; 477 struct synaptics_data *priv = psmouse->private;
478 478
479 input_regs(dev, regs); 479 input_regs(dev, regs);
@@ -645,7 +645,7 @@ int synaptics_init(struct psmouse *psmouse)
645 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), 645 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
646 priv->model_id, priv->capabilities, priv->ext_cap); 646 priv->model_id, priv->capabilities, priv->ext_cap);
647 647
648 set_input_params(&psmouse->dev, priv); 648 set_input_params(psmouse->dev, priv);
649 649
650 psmouse->protocol_handler = synaptics_process_byte; 650 psmouse->protocol_handler = synaptics_process_byte;
651 psmouse->set_rate = synaptics_set_rate; 651 psmouse->set_rate = synaptics_set_rate;
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index f024be9b44d2..36e9442a16b2 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -112,7 +112,7 @@ MODULE_LICENSE ("GPL");
112 112
113 113
114struct vsxxxaa { 114struct vsxxxaa {
115 struct input_dev dev; 115 struct input_dev *dev;
116 struct serio *serio; 116 struct serio *serio;
117#define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ 117#define BUFLEN 15 /* At least 5 is needed for a full tablet packet */
118 unsigned char buf[BUFLEN]; 118 unsigned char buf[BUFLEN];
@@ -211,7 +211,7 @@ vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t le
211static void 211static void
212vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 212vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
213{ 213{
214 struct input_dev *dev = &mouse->dev; 214 struct input_dev *dev = mouse->dev;
215 unsigned char *buf = mouse->buf; 215 unsigned char *buf = mouse->buf;
216 int left, middle, right; 216 int left, middle, right;
217 int dx, dy; 217 int dx, dy;
@@ -269,7 +269,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
269static void 269static void
270vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 270vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
271{ 271{
272 struct input_dev *dev = &mouse->dev; 272 struct input_dev *dev = mouse->dev;
273 unsigned char *buf = mouse->buf; 273 unsigned char *buf = mouse->buf;
274 int left, middle, right, touch; 274 int left, middle, right, touch;
275 int x, y; 275 int x, y;
@@ -323,7 +323,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
323static void 323static void
324vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) 324vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs)
325{ 325{
326 struct input_dev *dev = &mouse->dev; 326 struct input_dev *dev = mouse->dev;
327 unsigned char *buf = mouse->buf; 327 unsigned char *buf = mouse->buf;
328 int left, middle, right; 328 int left, middle, right;
329 unsigned char error; 329 unsigned char error;
@@ -483,9 +483,9 @@ vsxxxaa_disconnect (struct serio *serio)
483{ 483{
484 struct vsxxxaa *mouse = serio_get_drvdata (serio); 484 struct vsxxxaa *mouse = serio_get_drvdata (serio);
485 485
486 input_unregister_device (&mouse->dev);
487 serio_close (serio); 486 serio_close (serio);
488 serio_set_drvdata (serio, NULL); 487 serio_set_drvdata (serio, NULL);
488 input_unregister_device (mouse->dev);
489 kfree (mouse); 489 kfree (mouse);
490} 490}
491 491
@@ -493,61 +493,57 @@ static int
493vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) 493vsxxxaa_connect (struct serio *serio, struct serio_driver *drv)
494{ 494{
495 struct vsxxxaa *mouse; 495 struct vsxxxaa *mouse;
496 int err; 496 struct input_dev *input_dev;
497 int err = -ENOMEM;
497 498
498 if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL))) 499 mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL);
499 return -ENOMEM; 500 input_dev = input_allocate_device ();
500 501 if (!mouse || !input_dev)
501 memset (mouse, 0, sizeof (struct vsxxxaa)); 502 goto fail;
502
503 init_input_dev (&mouse->dev);
504 set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */
505 set_bit (EV_REL, mouse->dev.evbit);
506 set_bit (EV_ABS, mouse->dev.evbit);
507 set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */
508 set_bit (BTN_MIDDLE, mouse->dev.keybit);
509 set_bit (BTN_RIGHT, mouse->dev.keybit);
510 set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */
511 set_bit (REL_X, mouse->dev.relbit);
512 set_bit (REL_Y, mouse->dev.relbit);
513 set_bit (ABS_X, mouse->dev.absbit);
514 set_bit (ABS_Y, mouse->dev.absbit);
515
516 mouse->dev.absmin[ABS_X] = 0;
517 mouse->dev.absmax[ABS_X] = 1023;
518 mouse->dev.absmin[ABS_Y] = 0;
519 mouse->dev.absmax[ABS_Y] = 1023;
520
521 mouse->dev.private = mouse;
522 503
504 mouse->dev = input_dev;
505 mouse->serio = serio;
523 sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); 506 sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer");
524 sprintf (mouse->phys, "%s/input0", serio->phys); 507 sprintf (mouse->phys, "%s/input0", serio->phys);
525 mouse->dev.name = mouse->name; 508
526 mouse->dev.phys = mouse->phys; 509 input_dev->name = mouse->name;
527 mouse->dev.id.bustype = BUS_RS232; 510 input_dev->phys = mouse->phys;
528 mouse->dev.dev = &serio->dev; 511 input_dev->id.bustype = BUS_RS232;
529 mouse->serio = serio; 512 input_dev->cdev.dev = &serio->dev;
513 input_dev->private = mouse;
514
515 set_bit (EV_KEY, input_dev->evbit); /* We have buttons */
516 set_bit (EV_REL, input_dev->evbit);
517 set_bit (EV_ABS, input_dev->evbit);
518 set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */
519 set_bit (BTN_MIDDLE, input_dev->keybit);
520 set_bit (BTN_RIGHT, input_dev->keybit);
521 set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */
522 set_bit (REL_X, input_dev->relbit);
523 set_bit (REL_Y, input_dev->relbit);
524 input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0);
525 input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0);
530 526
531 serio_set_drvdata (serio, mouse); 527 serio_set_drvdata (serio, mouse);
532 528
533 err = serio_open (serio, drv); 529 err = serio_open (serio, drv);
534 if (err) { 530 if (err)
535 serio_set_drvdata (serio, NULL); 531 goto fail;
536 kfree (mouse);
537 return err;
538 }
539 532
540 /* 533 /*
541 * Request selftest. Standard packet format and differential 534 * Request selftest. Standard packet format and differential
542 * mode will be requested after the device ID'ed successfully. 535 * mode will be requested after the device ID'ed successfully.
543 */ 536 */
544 mouse->serio->write (mouse->serio, 'T'); /* Test */ 537 serio->write (serio, 'T'); /* Test */
545
546 input_register_device (&mouse->dev);
547 538
548 printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys); 539 input_register_device (input_dev);
549 540
550 return 0; 541 return 0;
542
543 fail: serio_set_drvdata (serio, NULL);
544 input_free_device (input_dev);
545 kfree (mouse);
546 return err;
551} 547}
552 548
553static struct serio_device_id vsxxaa_serio_ids[] = { 549static struct serio_device_id vsxxaa_serio_ids[] = {
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index c6194a9dd174..2d0af44ac4b9 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -9,7 +9,7 @@
9 * the Free Software Foundation. 9 * the Free Software Foundation.
10 */ 10 */
11 11
12#define MOUSEDEV_MINOR_BASE 32 12#define MOUSEDEV_MINOR_BASE 32
13#define MOUSEDEV_MINORS 32 13#define MOUSEDEV_MINORS 32
14#define MOUSEDEV_MIX 31 14#define MOUSEDEV_MIX 31
15 15
@@ -24,7 +24,6 @@
24#include <linux/random.h> 24#include <linux/random.h>
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/devfs_fs_kernel.h>
28#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 27#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
29#include <linux/miscdevice.h> 28#include <linux/miscdevice.h>
30#endif 29#endif
@@ -621,6 +620,7 @@ static struct file_operations mousedev_fops = {
621static struct input_handle *mousedev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) 620static struct input_handle *mousedev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
622{ 621{
623 struct mousedev *mousedev; 622 struct mousedev *mousedev;
623 struct class_device *cdev;
624 int minor = 0; 624 int minor = 0;
625 625
626 for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++); 626 for (minor = 0; minor < MOUSEDEV_MINORS && mousedev_table[minor]; minor++);
@@ -649,11 +649,13 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
649 649
650 mousedev_table[minor] = mousedev; 650 mousedev_table[minor] = mousedev;
651 651
652 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 652 cdev = class_device_create(&input_class, &dev->cdev,
653 S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
654 class_device_create(input_class,
655 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 653 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
656 dev->dev, "mouse%d", minor); 654 dev->cdev.dev, mousedev->name);
655
656 /* temporary symlink to keep userspace happy */
657 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
658 mousedev->name);
657 659
658 return &mousedev->handle; 660 return &mousedev->handle;
659} 661}
@@ -663,9 +665,9 @@ static void mousedev_disconnect(struct input_handle *handle)
663 struct mousedev *mousedev = handle->private; 665 struct mousedev *mousedev = handle->private;
664 struct mousedev_list *list; 666 struct mousedev_list *list;
665 667
666 class_device_destroy(input_class, 668 sysfs_remove_link(&input_class.subsys.kset.kobj, mousedev->name);
669 class_device_destroy(&input_class,
667 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); 670 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
668 devfs_remove("input/mouse%d", mousedev->minor);
669 mousedev->exist = 0; 671 mousedev->exist = 0;
670 672
671 if (mousedev->open) { 673 if (mousedev->open) {
@@ -738,9 +740,7 @@ static int __init mousedev_init(void)
738 mousedev_mix.exist = 1; 740 mousedev_mix.exist = 1;
739 mousedev_mix.minor = MOUSEDEV_MIX; 741 mousedev_mix.minor = MOUSEDEV_MIX;
740 742
741 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), 743 class_device_create(&input_class, NULL,
742 S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
743 class_device_create(input_class,
744 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice"); 744 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");
745 745
746#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 746#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
@@ -759,8 +759,7 @@ static void __exit mousedev_exit(void)
759 if (psaux_registered) 759 if (psaux_registered)
760 misc_deregister(&psaux_mouse); 760 misc_deregister(&psaux_mouse);
761#endif 761#endif
762 devfs_remove("input/mice"); 762 class_device_destroy(&input_class,
763 class_device_destroy(input_class,
764 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX)); 763 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
765 input_unregister_handler(&mousedev_handler); 764 input_unregister_handler(&mousedev_handler);
766} 765}
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
index 897e4c12b642..a7b0de0f92b2 100644
--- a/drivers/input/serio/gscps2.c
+++ b/drivers/input/serio/gscps2.c
@@ -211,9 +211,6 @@ static void gscps2_reset(struct gscps2port *ps2port)
211 writeb(0xff, addr+GSC_RESET); 211 writeb(0xff, addr+GSC_RESET);
212 gscps2_flush(ps2port); 212 gscps2_flush(ps2port);
213 spin_unlock_irqrestore(&ps2port->lock, flags); 213 spin_unlock_irqrestore(&ps2port->lock, flags);
214
215 /* enable it */
216 gscps2_enable(ps2port, ENABLE);
217} 214}
218 215
219static LIST_HEAD(ps2port_list); 216static LIST_HEAD(ps2port_list);
@@ -307,6 +304,9 @@ static int gscps2_open(struct serio *port)
307 304
308 gscps2_reset(ps2port); 305 gscps2_reset(ps2port);
309 306
307 /* enable it */
308 gscps2_enable(ps2port, ENABLE);
309
310 gscps2_interrupt(0, NULL, NULL); 310 gscps2_interrupt(0, NULL, NULL);
311 311
312 return 0; 312 return 0;
@@ -331,7 +331,7 @@ static int __init gscps2_probe(struct parisc_device *dev)
331{ 331{
332 struct gscps2port *ps2port; 332 struct gscps2port *ps2port;
333 struct serio *serio; 333 struct serio *serio;
334 unsigned long hpa = dev->hpa; 334 unsigned long hpa = dev->hpa.start;
335 int ret; 335 int ret;
336 336
337 if (!dev->irq) 337 if (!dev->irq)
@@ -370,8 +370,6 @@ static int __init gscps2_probe(struct parisc_device *dev)
370 serio->port_data = ps2port; 370 serio->port_data = ps2port;
371 serio->dev.parent = &dev->dev; 371 serio->dev.parent = &dev->dev;
372 372
373 list_add_tail(&ps2port->node, &ps2port_list);
374
375 ret = -EBUSY; 373 ret = -EBUSY;
376 if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port)) 374 if (request_irq(dev->irq, gscps2_interrupt, SA_SHIRQ, ps2port->port->name, ps2port))
377 goto fail_miserably; 375 goto fail_miserably;
@@ -396,15 +394,16 @@ static int __init gscps2_probe(struct parisc_device *dev)
396 394
397 serio_register_port(ps2port->port); 395 serio_register_port(ps2port->port);
398 396
397 list_add_tail(&ps2port->node, &ps2port_list);
398
399 return 0; 399 return 0;
400 400
401fail: 401fail:
402 free_irq(dev->irq, ps2port); 402 free_irq(dev->irq, ps2port);
403 403
404fail_miserably: 404fail_miserably:
405 list_del(&ps2port->node);
406 iounmap(ps2port->addr); 405 iounmap(ps2port->addr);
407 release_mem_region(dev->hpa, GSC_STATUS + 4); 406 release_mem_region(dev->hpa.start, GSC_STATUS + 4);
408 407
409fail_nomem: 408fail_nomem:
410 kfree(ps2port); 409 kfree(ps2port);
@@ -444,7 +443,7 @@ static struct parisc_device_id gscps2_device_tbl[] = {
444}; 443};
445 444
446static struct parisc_driver parisc_ps2_driver = { 445static struct parisc_driver parisc_ps2_driver = {
447 .name = "GSC PS2", 446 .name = "gsc_ps2",
448 .id_table = gscps2_device_tbl, 447 .id_table = gscps2_device_tbl,
449 .probe = gscps2_probe, 448 .probe = gscps2_probe,
450 .remove = gscps2_remove, 449 .remove = gscps2_remove,
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index c243cb6fdfc4..5704204964a3 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -801,7 +801,8 @@ static int hil_mlc_serio_open(struct serio *serio) {
801 struct hil_mlc_serio_map *map; 801 struct hil_mlc_serio_map *map;
802 struct hil_mlc *mlc; 802 struct hil_mlc *mlc;
803 803
804 if (serio->private != NULL) return -EBUSY; 804 if (serio_get_drvdata(serio) != NULL)
805 return -EBUSY;
805 806
806 map = serio->port_data; 807 map = serio->port_data;
807 if (map == NULL) { 808 if (map == NULL) {
@@ -832,11 +833,18 @@ static void hil_mlc_serio_close(struct serio *serio) {
832 return; 833 return;
833 } 834 }
834 835
835 serio->private = NULL; 836 serio_set_drvdata(serio, NULL);
836 serio->drv = NULL; 837 serio->drv = NULL;
837 /* TODO wake up interruptable */ 838 /* TODO wake up interruptable */
838} 839}
839 840
841static struct serio_device_id hil_mlc_serio_id = {
842 .type = SERIO_HIL_MLC,
843 .proto = SERIO_HIL,
844 .extra = SERIO_ANY,
845 .id = SERIO_ANY,
846};
847
840int hil_mlc_register(hil_mlc *mlc) { 848int hil_mlc_register(hil_mlc *mlc) {
841 int i; 849 int i;
842 unsigned long flags; 850 unsigned long flags;
@@ -867,7 +875,7 @@ int hil_mlc_register(hil_mlc *mlc) {
867 mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL); 875 mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL);
868 mlc->serio[i] = mlc_serio; 876 mlc->serio[i] = mlc_serio;
869 memset(mlc_serio, 0, sizeof(*mlc_serio)); 877 memset(mlc_serio, 0, sizeof(*mlc_serio));
870 mlc_serio->type = SERIO_HIL | SERIO_HIL_MLC; 878 mlc_serio->id = hil_mlc_serio_id;
871 mlc_serio->write = hil_mlc_serio_write; 879 mlc_serio->write = hil_mlc_serio_write;
872 mlc_serio->open = hil_mlc_serio_open; 880 mlc_serio->open = hil_mlc_serio_open;
873 mlc_serio->close = hil_mlc_serio_close; 881 mlc_serio->close = hil_mlc_serio_close;
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 7629452dd64b..a10348bb25e9 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -764,7 +764,7 @@ MODULE_DEVICE_TABLE(parisc, hp_sdc_tbl);
764static int __init hp_sdc_init_hppa(struct parisc_device *d); 764static int __init hp_sdc_init_hppa(struct parisc_device *d);
765 765
766static struct parisc_driver hp_sdc_driver = { 766static struct parisc_driver hp_sdc_driver = {
767 .name = "HP SDC", 767 .name = "hp_sdc",
768 .id_table = hp_sdc_tbl, 768 .id_table = hp_sdc_tbl,
769 .probe = hp_sdc_init_hppa, 769 .probe = hp_sdc_init_hppa,
770}; 770};
@@ -875,9 +875,9 @@ static int __init hp_sdc_init_hppa(struct parisc_device *d)
875 hp_sdc.dev = d; 875 hp_sdc.dev = d;
876 hp_sdc.irq = d->irq; 876 hp_sdc.irq = d->irq;
877 hp_sdc.nmi = d->aux_irq; 877 hp_sdc.nmi = d->aux_irq;
878 hp_sdc.base_io = d->hpa; 878 hp_sdc.base_io = d->hpa.start;
879 hp_sdc.data_io = d->hpa + 0x800; 879 hp_sdc.data_io = d->hpa.start + 0x800;
880 hp_sdc.status_io = d->hpa + 0x801; 880 hp_sdc.status_io = d->hpa.start + 0x801;
881 881
882 return hp_sdc_init(); 882 return hp_sdc_init();
883} 883}
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 40d451ce07ff..4bc40f159996 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -911,12 +911,10 @@ static long i8042_panic_blink(long count)
911 * Here we try to restore the original BIOS settings 911 * Here we try to restore the original BIOS settings
912 */ 912 */
913 913
914static int i8042_suspend(struct device *dev, pm_message_t state, u32 level) 914static int i8042_suspend(struct device *dev, pm_message_t state)
915{ 915{
916 if (level == SUSPEND_DISABLE) { 916 del_timer_sync(&i8042_timer);
917 del_timer_sync(&i8042_timer); 917 i8042_controller_reset();
918 i8042_controller_reset();
919 }
920 918
921 return 0; 919 return 0;
922} 920}
@@ -926,13 +924,10 @@ static int i8042_suspend(struct device *dev, pm_message_t state, u32 level)
926 * Here we try to reset everything back to a state in which suspended 924 * Here we try to reset everything back to a state in which suspended
927 */ 925 */
928 926
929static int i8042_resume(struct device *dev, u32 level) 927static int i8042_resume(struct device *dev)
930{ 928{
931 int i; 929 int i;
932 930
933 if (level != RESUME_ENABLE)
934 return 0;
935
936 if (i8042_ctl_test()) 931 if (i8042_ctl_test())
937 return -1; 932 return -1;
938 933
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 4c7fbe550365..0ba3e6562bff 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -41,8 +41,7 @@ struct ts_event {
41}; 41};
42 42
43struct corgi_ts { 43struct corgi_ts {
44 char phys[32]; 44 struct input_dev *input;
45 struct input_dev input;
46 struct timer_list timer; 45 struct timer_list timer;
47 struct ts_event tc; 46 struct ts_event tc;
48 int pendown; 47 int pendown;
@@ -182,14 +181,12 @@ static void new_data(struct corgi_ts *corgi_ts, struct pt_regs *regs)
182 if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0) 181 if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0)
183 return; 182 return;
184 183
185 if (regs) 184 input_regs(corgi_ts->input, regs);
186 input_regs(&corgi_ts->input, regs); 185 input_report_abs(corgi_ts->input, ABS_X, corgi_ts->tc.x);
187 186 input_report_abs(corgi_ts->input, ABS_Y, corgi_ts->tc.y);
188 input_report_abs(&corgi_ts->input, ABS_X, corgi_ts->tc.x); 187 input_report_abs(corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure);
189 input_report_abs(&corgi_ts->input, ABS_Y, corgi_ts->tc.y); 188 input_report_key(corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
190 input_report_abs(&corgi_ts->input, ABS_PRESSURE, corgi_ts->tc.pressure); 189 input_sync(corgi_ts->input);
191 input_report_key(&corgi_ts->input, BTN_TOUCH, (corgi_ts->pendown != 0));
192 input_sync(&corgi_ts->input);
193} 190}
194 191
195static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs) 192static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer, struct pt_regs *regs)
@@ -234,34 +231,32 @@ static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs)
234} 231}
235 232
236#ifdef CONFIG_PM 233#ifdef CONFIG_PM
237static int corgits_suspend(struct device *dev, pm_message_t state, uint32_t level) 234static int corgits_suspend(struct device *dev, pm_message_t state)
238{ 235{
239 if (level == SUSPEND_POWER_DOWN) { 236 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
240 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
241
242 if (corgi_ts->pendown) {
243 del_timer_sync(&corgi_ts->timer);
244 corgi_ts->tc.pressure = 0;
245 new_data(corgi_ts, NULL);
246 corgi_ts->pendown = 0;
247 }
248 corgi_ts->power_mode = PWR_MODE_SUSPEND;
249 237
250 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 238 if (corgi_ts->pendown) {
239 del_timer_sync(&corgi_ts->timer);
240 corgi_ts->tc.pressure = 0;
241 new_data(corgi_ts, NULL);
242 corgi_ts->pendown = 0;
251 } 243 }
244 corgi_ts->power_mode = PWR_MODE_SUSPEND;
245
246 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
247
252 return 0; 248 return 0;
253} 249}
254 250
255static int corgits_resume(struct device *dev, uint32_t level) 251static int corgits_resume(struct device *dev)
256{ 252{
257 if (level == RESUME_POWER_ON) { 253 struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
258 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 254
255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
256 /* Enable Falling Edge */
257 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
258 corgi_ts->power_mode = PWR_MODE_ACTIVE;
259 259
260 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
261 /* Enable Falling Edge */
262 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
263 corgi_ts->power_mode = PWR_MODE_ACTIVE;
264 }
265 return 0; 260 return 0;
266} 261}
267#else 262#else
@@ -273,39 +268,44 @@ static int __init corgits_probe(struct device *dev)
273{ 268{
274 struct corgi_ts *corgi_ts; 269 struct corgi_ts *corgi_ts;
275 struct platform_device *pdev = to_platform_device(dev); 270 struct platform_device *pdev = to_platform_device(dev);
271 struct input_dev *input_dev;
272 int err = -ENOMEM;
276 273
277 if (!(corgi_ts = kmalloc(sizeof(struct corgi_ts), GFP_KERNEL))) 274 corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL);
278 return -ENOMEM; 275 input_dev = input_allocate_device();
276 if (!corgi_ts || !input_dev)
277 goto fail;
279 278
280 dev_set_drvdata(dev, corgi_ts); 279 dev_set_drvdata(dev, corgi_ts);
281 280
282 memset(corgi_ts, 0, sizeof(struct corgi_ts));
283
284 corgi_ts->machinfo = dev->platform_data; 281 corgi_ts->machinfo = dev->platform_data;
285 corgi_ts->irq_gpio = platform_get_irq(pdev, 0); 282 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
286 283
287 if (corgi_ts->irq_gpio < 0) { 284 if (corgi_ts->irq_gpio < 0) {
288 kfree(corgi_ts); 285 err = -ENODEV;
289 return -ENODEV; 286 goto fail;
290 } 287 }
291 288
292 init_input_dev(&corgi_ts->input); 289 corgi_ts->input = input_dev;
293 corgi_ts->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
294 corgi_ts->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
295 input_set_abs_params(&corgi_ts->input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
296 input_set_abs_params(&corgi_ts->input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
297 input_set_abs_params(&corgi_ts->input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
298 290
299 strcpy(corgi_ts->phys, "corgits/input0"); 291 init_timer(&corgi_ts->timer);
292 corgi_ts->timer.data = (unsigned long) corgi_ts;
293 corgi_ts->timer.function = corgi_ts_timer;
300 294
301 corgi_ts->input.private = corgi_ts; 295 input_dev->name = "Corgi Touchscreen";
302 corgi_ts->input.name = "Corgi Touchscreen"; 296 input_dev->phys = "corgits/input0";
303 corgi_ts->input.dev = dev; 297 input_dev->id.bustype = BUS_HOST;
304 corgi_ts->input.phys = corgi_ts->phys; 298 input_dev->id.vendor = 0x0001;
305 corgi_ts->input.id.bustype = BUS_HOST; 299 input_dev->id.product = 0x0002;
306 corgi_ts->input.id.vendor = 0x0001; 300 input_dev->id.version = 0x0100;
307 corgi_ts->input.id.product = 0x0002; 301 input_dev->cdev.dev = dev;
308 corgi_ts->input.id.version = 0x0100; 302 input_dev->private = corgi_ts;
303
304 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
305 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
306 input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
307 input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
308 input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
309 309
310 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN); 310 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);
311 311
@@ -319,25 +319,24 @@ static int __init corgits_probe(struct device *dev)
319 corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 319 corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
320 mdelay(5); 320 mdelay(5);
321 321
322 init_timer(&corgi_ts->timer);
323 corgi_ts->timer.data = (unsigned long) corgi_ts;
324 corgi_ts->timer.function = corgi_ts_timer;
325
326 input_register_device(&corgi_ts->input);
327 corgi_ts->power_mode = PWR_MODE_ACTIVE;
328
329 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) { 322 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, SA_INTERRUPT, "ts", corgi_ts)) {
330 input_unregister_device(&corgi_ts->input); 323 err = -EBUSY;
331 kfree(corgi_ts); 324 goto fail;
332 return -EBUSY;
333 } 325 }
334 326
327 input_register_device(corgi_ts->input);
328
329 corgi_ts->power_mode = PWR_MODE_ACTIVE;
330
335 /* Enable Falling Edge */ 331 /* Enable Falling Edge */
336 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING); 332 set_irq_type(corgi_ts->irq_gpio, IRQT_FALLING);
337 333
338 printk(KERN_INFO "input: Corgi Touchscreen Registered\n");
339
340 return 0; 334 return 0;
335
336 fail: input_free_device(input_dev);
337 kfree(corgi_ts);
338 return err;
339
341} 340}
342 341
343static int corgits_remove(struct device *dev) 342static int corgits_remove(struct device *dev)
@@ -347,7 +346,7 @@ static int corgits_remove(struct device *dev)
347 free_irq(corgi_ts->irq_gpio, NULL); 346 free_irq(corgi_ts->irq_gpio, NULL);
348 del_timer_sync(&corgi_ts->timer); 347 del_timer_sync(&corgi_ts->timer);
349 corgi_ts->machinfo->put_hsync(); 348 corgi_ts->machinfo->put_hsync();
350 input_unregister_device(&corgi_ts->input); 349 input_unregister_device(corgi_ts->input);
351 kfree(corgi_ts); 350 kfree(corgi_ts);
352 return 0; 351 return 0;
353} 352}
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c
index 3cdc9cab688d..c86a2eb310fd 100644
--- a/drivers/input/touchscreen/elo.c
+++ b/drivers/input/touchscreen/elo.c
@@ -36,14 +36,12 @@ MODULE_LICENSE("GPL");
36 36
37#define ELO_MAX_LENGTH 10 37#define ELO_MAX_LENGTH 10
38 38
39static char *elo_name = "Elo Serial TouchScreen";
40
41/* 39/*
42 * Per-touchscreen data. 40 * Per-touchscreen data.
43 */ 41 */
44 42
45struct elo { 43struct elo {
46 struct input_dev dev; 44 struct input_dev *dev;
47 struct serio *serio; 45 struct serio *serio;
48 int id; 46 int id;
49 int idx; 47 int idx;
@@ -54,7 +52,7 @@ struct elo {
54 52
55static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) 53static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs)
56{ 54{
57 struct input_dev *dev = &elo->dev; 55 struct input_dev *dev = elo->dev;
58 56
59 elo->csum += elo->data[elo->idx] = data; 57 elo->csum += elo->data[elo->idx] = data;
60 58
@@ -80,7 +78,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r
80 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); 78 input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
81 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); 79 input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
82 input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); 80 input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]);
83 input_report_key(dev, BTN_TOUCH, elo->data[2] & 3); 81 input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]);
84 input_sync(dev); 82 input_sync(dev);
85 } 83 }
86 elo->idx = 0; 84 elo->idx = 0;
@@ -91,7 +89,7 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r
91 89
92static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) 90static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs)
93{ 91{
94 struct input_dev *dev = &elo->dev; 92 struct input_dev *dev = elo->dev;
95 93
96 elo->data[elo->idx] = data; 94 elo->data[elo->idx] = data;
97 95
@@ -129,7 +127,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re
129 case 5: 127 case 5:
130 if ((data & 0xf0) == 0) { 128 if ((data & 0xf0) == 0) {
131 input_report_abs(dev, ABS_PRESSURE, elo->data[5]); 129 input_report_abs(dev, ABS_PRESSURE, elo->data[5]);
132 input_report_key(dev, BTN_TOUCH, elo->data[5]); 130 input_report_key(dev, BTN_TOUCH, !!elo->data[5]);
133 } 131 }
134 input_sync(dev); 132 input_sync(dev);
135 elo->idx = 0; 133 elo->idx = 0;
@@ -139,7 +137,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re
139 137
140static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) 138static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs)
141{ 139{
142 struct input_dev *dev = &elo->dev; 140 struct input_dev *dev = elo->dev;
143 141
144 elo->data[elo->idx] = data; 142 elo->data[elo->idx] = data;
145 143
@@ -191,7 +189,7 @@ static void elo_disconnect(struct serio *serio)
191{ 189{
192 struct elo* elo = serio_get_drvdata(serio); 190 struct elo* elo = serio_get_drvdata(serio);
193 191
194 input_unregister_device(&elo->dev); 192 input_unregister_device(elo->dev);
195 serio_close(serio); 193 serio_close(serio);
196 serio_set_drvdata(serio, NULL); 194 serio_set_drvdata(serio, NULL);
197 kfree(elo); 195 kfree(elo);
@@ -206,67 +204,68 @@ static void elo_disconnect(struct serio *serio)
206static int elo_connect(struct serio *serio, struct serio_driver *drv) 204static int elo_connect(struct serio *serio, struct serio_driver *drv)
207{ 205{
208 struct elo *elo; 206 struct elo *elo;
207 struct input_dev *input_dev;
209 int err; 208 int err;
210 209
211 if (!(elo = kmalloc(sizeof(struct elo), GFP_KERNEL))) 210 elo = kzalloc(sizeof(struct elo), GFP_KERNEL);
212 return -ENOMEM; 211 input_dev = input_allocate_device();
212 if (!elo || !input_dev) {
213 err = -ENOMEM;
214 goto fail;
215 }
213 216
214 memset(elo, 0, sizeof(struct elo)); 217 elo->serio = serio;
218 elo->id = serio->id.id;
219 elo->dev = input_dev;
220 snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys);
215 221
216 init_input_dev(&elo->dev); 222 input_dev->private = elo;
217 elo->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 223 input_dev->name = "Elo Serial TouchScreen";
218 elo->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 224 input_dev->phys = elo->phys;
225 input_dev->id.bustype = BUS_RS232;
226 input_dev->id.vendor = SERIO_ELO;
227 input_dev->id.product = elo->id;
228 input_dev->id.version = 0x0100;
229 input_dev->cdev.dev = &serio->dev;
219 230
220 elo->id = serio->id.id; 231 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
232 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
221 233
222 switch (elo->id) { 234 switch (elo->id) {
223 235
224 case 0: /* 10-byte protocol */ 236 case 0: /* 10-byte protocol */
225 input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); 237 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
226 input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); 238 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
227 input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 255, 0, 0); 239 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
228 break; 240 break;
229 241
230 case 1: /* 6-byte protocol */ 242 case 1: /* 6-byte protocol */
231 input_set_abs_params(&elo->dev, ABS_PRESSURE, 0, 15, 0, 0); 243 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0);
232 244
233 case 2: /* 4-byte protocol */ 245 case 2: /* 4-byte protocol */
234 input_set_abs_params(&elo->dev, ABS_X, 96, 4000, 0, 0); 246 input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0);
235 input_set_abs_params(&elo->dev, ABS_Y, 96, 4000, 0, 0); 247 input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0);
236 break; 248 break;
237 249
238 case 3: /* 3-byte protocol */ 250 case 3: /* 3-byte protocol */
239 input_set_abs_params(&elo->dev, ABS_X, 0, 255, 0, 0); 251 input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0);
240 input_set_abs_params(&elo->dev, ABS_Y, 0, 255, 0, 0); 252 input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0);
241 break; 253 break;
242 } 254 }
243 255
244 elo->serio = serio;
245
246 sprintf(elo->phys, "%s/input0", serio->phys);
247
248 elo->dev.private = elo;
249 elo->dev.name = elo_name;
250 elo->dev.phys = elo->phys;
251 elo->dev.id.bustype = BUS_RS232;
252 elo->dev.id.vendor = SERIO_ELO;
253 elo->dev.id.product = elo->id;
254 elo->dev.id.version = 0x0100;
255
256 serio_set_drvdata(serio, elo); 256 serio_set_drvdata(serio, elo);
257 257
258 err = serio_open(serio, drv); 258 err = serio_open(serio, drv);
259 if (err) { 259 if (err)
260 serio_set_drvdata(serio, NULL); 260 goto fail;
261 kfree(elo);
262 return err;
263 }
264
265 input_register_device(&elo->dev);
266
267 printk(KERN_INFO "input: %s on %s\n", elo_name, serio->phys);
268 261
262 input_register_device(elo->dev);
269 return 0; 263 return 0;
264
265 fail: serio_set_drvdata(serio, NULL);
266 input_free_device(input_dev);
267 kfree(elo);
268 return err;
270} 269}
271 270
272/* 271/*
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
index 53a27e43dd23..466da190ceec 100644
--- a/drivers/input/touchscreen/gunze.c
+++ b/drivers/input/touchscreen/gunze.c
@@ -48,14 +48,12 @@ MODULE_LICENSE("GPL");
48 48
49#define GUNZE_MAX_LENGTH 10 49#define GUNZE_MAX_LENGTH 10
50 50
51static char *gunze_name = "Gunze AHL-51S TouchScreen";
52
53/* 51/*
54 * Per-touchscreen data. 52 * Per-touchscreen data.
55 */ 53 */
56 54
57struct gunze { 55struct gunze {
58 struct input_dev dev; 56 struct input_dev *dev;
59 struct serio *serio; 57 struct serio *serio;
60 int idx; 58 int idx;
61 unsigned char data[GUNZE_MAX_LENGTH]; 59 unsigned char data[GUNZE_MAX_LENGTH];
@@ -64,7 +62,7 @@ struct gunze {
64 62
65static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs) 63static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs)
66{ 64{
67 struct input_dev *dev = &gunze->dev; 65 struct input_dev *dev = gunze->dev;
68 66
69 if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' || 67 if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' ||
70 (gunze->data[0] != 'T' && gunze->data[0] != 'R')) { 68 (gunze->data[0] != 'T' && gunze->data[0] != 'R')) {
@@ -100,11 +98,13 @@ static irqreturn_t gunze_interrupt(struct serio *serio,
100 98
101static void gunze_disconnect(struct serio *serio) 99static void gunze_disconnect(struct serio *serio)
102{ 100{
103 struct gunze* gunze = serio_get_drvdata(serio); 101 struct gunze *gunze = serio_get_drvdata(serio);
104 102
105 input_unregister_device(&gunze->dev); 103 input_get_device(gunze->dev);
104 input_unregister_device(gunze->dev);
106 serio_close(serio); 105 serio_close(serio);
107 serio_set_drvdata(serio, NULL); 106 serio_set_drvdata(serio, NULL);
107 input_put_device(gunze->dev);
108 kfree(gunze); 108 kfree(gunze);
109} 109}
110 110
@@ -117,45 +117,45 @@ static void gunze_disconnect(struct serio *serio)
117static int gunze_connect(struct serio *serio, struct serio_driver *drv) 117static int gunze_connect(struct serio *serio, struct serio_driver *drv)
118{ 118{
119 struct gunze *gunze; 119 struct gunze *gunze;
120 struct input_dev *input_dev;
120 int err; 121 int err;
121 122
122 if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL))) 123 gunze = kzalloc(sizeof(struct gunze), GFP_KERNEL);
123 return -ENOMEM; 124 input_dev = input_allocate_device();
124 125 if (!gunze || !input_dev) {
125 memset(gunze, 0, sizeof(struct gunze)); 126 err = -ENOMEM;
126 127 goto fail;
127 init_input_dev(&gunze->dev); 128 }
128 gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
129 gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
130 input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0);
131 input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0);
132 129
133 gunze->serio = serio; 130 gunze->serio = serio;
134 131 gunze->dev = input_dev;
135 sprintf(gunze->phys, "%s/input0", serio->phys); 132 sprintf(gunze->phys, "%s/input0", serio->phys);
136 133
137 gunze->dev.private = gunze; 134 input_dev->private = gunze;
138 gunze->dev.name = gunze_name; 135 input_dev->name = "Gunze AHL-51S TouchScreen";
139 gunze->dev.phys = gunze->phys; 136 input_dev->phys = gunze->phys;
140 gunze->dev.id.bustype = BUS_RS232; 137 input_dev->id.bustype = BUS_RS232;
141 gunze->dev.id.vendor = SERIO_GUNZE; 138 input_dev->id.vendor = SERIO_GUNZE;
142 gunze->dev.id.product = 0x0051; 139 input_dev->id.product = 0x0051;
143 gunze->dev.id.version = 0x0100; 140 input_dev->id.version = 0x0100;
141 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
142 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
143 input_set_abs_params(input_dev, ABS_X, 24, 1000, 0, 0);
144 input_set_abs_params(input_dev, ABS_Y, 24, 1000, 0, 0);
144 145
145 serio_set_drvdata(serio, gunze); 146 serio_set_drvdata(serio, gunze);
146 147
147 err = serio_open(serio, drv); 148 err = serio_open(serio, drv);
148 if (err) { 149 if (err)
149 serio_set_drvdata(serio, NULL); 150 goto fail;
150 kfree(gunze);
151 return err;
152 }
153
154 input_register_device(&gunze->dev);
155
156 printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys);
157 151
152 input_register_device(gunze->dev);
158 return 0; 153 return 0;
154
155 fail: serio_set_drvdata(serio, NULL);
156 input_free_device(input_dev);
157 kfree(gunze);
158 return err;
159} 159}
160 160
161/* 161/*
diff --git a/drivers/input/touchscreen/h3600_ts_input.c b/drivers/input/touchscreen/h3600_ts_input.c
index bcfa1e36f957..a18d56bdafd9 100644
--- a/drivers/input/touchscreen/h3600_ts_input.c
+++ b/drivers/input/touchscreen/h3600_ts_input.c
@@ -39,7 +39,6 @@
39#include <linux/serio.h> 39#include <linux/serio.h>
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/pm.h>
43 42
44/* SA1100 serial defines */ 43/* SA1100 serial defines */
45#include <asm/arch/hardware.h> 44#include <asm/arch/hardware.h>
@@ -93,16 +92,12 @@ MODULE_LICENSE("GPL");
93#define H3600_SCANCODE_LEFT 8 /* 8 -> left */ 92#define H3600_SCANCODE_LEFT 8 /* 8 -> left */
94#define H3600_SCANCODE_DOWN 9 /* 9 -> down */ 93#define H3600_SCANCODE_DOWN 9 /* 9 -> down */
95 94
96static char *h3600_name = "H3600 TouchScreen";
97
98/* 95/*
99 * Per-touchscreen data. 96 * Per-touchscreen data.
100 */ 97 */
101struct h3600_dev { 98struct h3600_dev {
102 struct input_dev dev; 99 struct input_dev *dev;
103 struct pm_dev *pm_dev;
104 struct serio *serio; 100 struct serio *serio;
105 struct pm_dev *pm_dev;
106 unsigned char event; /* event ID from packet */ 101 unsigned char event; /* event ID from packet */
107 unsigned char chksum; 102 unsigned char chksum;
108 unsigned char len; 103 unsigned char len;
@@ -163,33 +158,6 @@ unsigned int h3600_flite_power(struct input_dev *dev, enum flite_pwr pwr)
163 return 0; 158 return 0;
164} 159}
165 160
166static int suspended = 0;
167static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req,
168 void *data)
169{
170 struct input_dev *dev = (struct input_dev *) data;
171
172 switch (req) {
173 case PM_SUSPEND: /* enter D1-D3 */
174 suspended = 1;
175 h3600_flite_power(dev, FLITE_PWR_OFF);
176 break;
177 case PM_BLANK:
178 if (!suspended)
179 h3600_flite_power(dev, FLITE_PWR_OFF);
180 break;
181 case PM_RESUME: /* enter D0 */
182 /* same as unblank */
183 case PM_UNBLANK:
184 if (suspended) {
185 //initSerial();
186 suspended = 0;
187 }
188 h3600_flite_power(dev, FLITE_PWR_ON);
189 break;
190 }
191 return 0;
192}
193#endif 161#endif
194 162
195/* 163/*
@@ -199,7 +167,7 @@ static int h3600ts_pm_callback(struct pm_dev *pm_dev, pm_request_t req,
199 */ 167 */
200static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs) 168static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs)
201{ 169{
202 struct input_dev *dev = &ts->dev; 170 struct input_dev *dev = ts->dev;
203 static int touched = 0; 171 static int touched = 0;
204 int key, down = 0; 172 int key, down = 0;
205 173
@@ -295,6 +263,7 @@ static void h3600ts_process_packet(struct h3600_dev *ts, struct pt_regs *regs)
295static int h3600ts_event(struct input_dev *dev, unsigned int type, 263static int h3600ts_event(struct input_dev *dev, unsigned int type,
296 unsigned int code, int value) 264 unsigned int code, int value)
297{ 265{
266#if 0
298 struct h3600_dev *ts = dev->private; 267 struct h3600_dev *ts = dev->private;
299 268
300 switch (type) { 269 switch (type) {
@@ -304,6 +273,8 @@ static int h3600ts_event(struct input_dev *dev, unsigned int type,
304 } 273 }
305 } 274 }
306 return -1; 275 return -1;
276#endif
277 return 0;
307} 278}
308 279
309/* 280/*
@@ -380,14 +351,48 @@ static irqreturn_t h3600ts_interrupt(struct serio *serio, unsigned char data,
380static int h3600ts_connect(struct serio *serio, struct serio_driver *drv) 351static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
381{ 352{
382 struct h3600_dev *ts; 353 struct h3600_dev *ts;
354 struct input_dev *input_dev;
383 int err; 355 int err;
384 356
385 if (!(ts = kmalloc(sizeof(struct h3600_dev), GFP_KERNEL))) 357 ts = kzalloc(sizeof(struct h3600_dev), GFP_KERNEL);
386 return -ENOMEM; 358 input_dev = input_allocate_device();
359 if (!ts || !input_dev) {
360 err = -ENOMEM;
361 goto fail1;
362 }
387 363
388 memset(ts, 0, sizeof(struct h3600_dev)); 364 ts->serio = serio;
365 ts->dev = input_dev;
366 sprintf(ts->phys, "%s/input0", serio->phys);
389 367
390 init_input_dev(&ts->dev); 368 input_dev->name = "H3600 TouchScreen";
369 input_dev->phys = ts->phys;
370 input_dev->id.bustype = BUS_RS232;
371 input_dev->id.vendor = SERIO_H3600;
372 input_dev->id.product = 0x0666; /* FIXME !!! We can ask the hardware */
373 input_dev->id.version = 0x0100;
374 input_dev->cdev.dev = &serio->dev;
375 input_dev->private = ts;
376
377 input_dev->event = h3600ts_event;
378
379 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR);
380 input_dev->ledbit[0] = BIT(LED_SLEEP);
381 input_set_abs_params(input_dev, ABS_X, 60, 985, 0, 0);
382 input_set_abs_params(input_dev, ABS_Y, 35, 1024, 0, 0);
383
384 set_bit(KEY_RECORD, input_dev->keybit);
385 set_bit(KEY_Q, input_dev->keybit);
386 set_bit(KEY_PROG1, input_dev->keybit);
387 set_bit(KEY_PROG2, input_dev->keybit);
388 set_bit(KEY_PROG3, input_dev->keybit);
389 set_bit(KEY_UP, input_dev->keybit);
390 set_bit(KEY_RIGHT, input_dev->keybit);
391 set_bit(KEY_LEFT, input_dev->keybit);
392 set_bit(KEY_DOWN, input_dev->keybit);
393 set_bit(KEY_ENTER, input_dev->keybit);
394 set_bit(KEY_SUSPEND, input_dev->keybit);
395 set_bit(BTN_TOUCH, input_dev->keybit);
391 396
392 /* Device specific stuff */ 397 /* Device specific stuff */
393 set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES); 398 set_GPIO_IRQ_edge(GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES);
@@ -397,73 +402,35 @@ static int h3600ts_connect(struct serio *serio, struct serio_driver *drv)
397 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, 402 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
398 "h3600_action", &ts->dev)) { 403 "h3600_action", &ts->dev)) {
399 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n"); 404 printk(KERN_ERR "h3600ts.c: Could not allocate Action Button IRQ!\n");
400 kfree(ts); 405 err = -EBUSY;
401 return -EBUSY; 406 goto fail2;
402 } 407 }
403 408
404 if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler, 409 if (request_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, npower_button_handler,
405 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM, 410 SA_SHIRQ | SA_INTERRUPT | SA_SAMPLE_RANDOM,
406 "h3600_suspend", &ts->dev)) { 411 "h3600_suspend", &ts->dev)) {
407 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
408 printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n"); 412 printk(KERN_ERR "h3600ts.c: Could not allocate Power Button IRQ!\n");
409 kfree(ts); 413 err = -EBUSY;
410 return -EBUSY; 414 goto fail3;
411 } 415 }
412 416
413 /* Now we have things going we setup our input device */
414 ts->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_LED) | BIT(EV_PWR);
415 ts->dev.ledbit[0] = BIT(LED_SLEEP);
416 input_set_abs_params(&ts->dev, ABS_X, 60, 985, 0, 0);
417 input_set_abs_params(&ts->dev, ABS_Y, 35, 1024, 0, 0);
418
419 set_bit(KEY_RECORD, ts->dev.keybit);
420 set_bit(KEY_Q, ts->dev.keybit);
421 set_bit(KEY_PROG1, ts->dev.keybit);
422 set_bit(KEY_PROG2, ts->dev.keybit);
423 set_bit(KEY_PROG3, ts->dev.keybit);
424 set_bit(KEY_UP, ts->dev.keybit);
425 set_bit(KEY_RIGHT, ts->dev.keybit);
426 set_bit(KEY_LEFT, ts->dev.keybit);
427 set_bit(KEY_DOWN, ts->dev.keybit);
428 set_bit(KEY_ENTER, ts->dev.keybit);
429 ts->dev.keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
430 ts->dev.keybit[LONG(KEY_SUSPEND)] |= BIT(KEY_SUSPEND);
431
432 ts->serio = serio;
433
434 sprintf(ts->phys, "%s/input0", serio->phys);
435
436 ts->dev.event = h3600ts_event;
437 ts->dev.private = ts;
438 ts->dev.name = h3600_name;
439 ts->dev.phys = ts->phys;
440 ts->dev.id.bustype = BUS_RS232;
441 ts->dev.id.vendor = SERIO_H3600;
442 ts->dev.id.product = 0x0666; /* FIXME !!! We can ask the hardware */
443 ts->dev.id.version = 0x0100;
444
445 serio_set_drvdata(serio, ts); 417 serio_set_drvdata(serio, ts);
446 418
447 err = serio_open(serio, drv); 419 err = serio_open(serio, drv);
448 if (err) { 420 if (err)
449 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts);
450 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts);
451 serio_set_drvdata(serio, NULL);
452 kfree(ts);
453 return err; 421 return err;
454 }
455 422
456 //h3600_flite_control(1, 25); /* default brightness */ 423 //h3600_flite_control(1, 25); /* default brightness */
457#ifdef CONFIG_PM 424 input_register_device(ts->dev);
458 ts->pm_dev = pm_register(PM_ILLUMINATION_DEV, PM_SYS_LIGHT,
459 h3600ts_pm_callback);
460 printk("registered pm callback\n");
461#endif
462 input_register_device(&ts->dev);
463
464 printk(KERN_INFO "input: %s on %s\n", h3600_name, serio->phys);
465 425
466 return 0; 426 return 0;
427
428fail3: free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, ts->dev);
429fail2: free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, ts->dev);
430fail1: serio_set_drvdata(serio, NULL);
431 input_free_device(input_dev);
432 kfree(ts);
433 return err;
467} 434}
468 435
469/* 436/*
@@ -476,9 +443,11 @@ static void h3600ts_disconnect(struct serio *serio)
476 443
477 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev); 444 free_irq(IRQ_GPIO_BITSY_ACTION_BUTTON, &ts->dev);
478 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev); 445 free_irq(IRQ_GPIO_BITSY_NPOWER_BUTTON, &ts->dev);
479 input_unregister_device(&ts->dev); 446 input_get_device(ts->dev);
447 input_unregister_device(ts->dev);
480 serio_close(serio); 448 serio_close(serio);
481 serio_set_drvdata(serio, NULL); 449 serio_set_drvdata(serio, NULL);
450 input_put_device(ts->dev);
482 kfree(ts); 451 kfree(ts);
483} 452}
484 453
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index 7e1404441eca..957dd5a1b15e 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -21,10 +21,8 @@
21 21
22static void do_softint(void *data); 22static void do_softint(void *data);
23 23
24static struct input_dev hp680_ts_dev; 24static struct input_dev *hp680_ts_dev;
25static DECLARE_WORK(work, do_softint, 0); 25static DECLARE_WORK(work, do_softint, 0);
26static char *hp680_ts_name = "HP Jornada touchscreen";
27static char *hp680_ts_phys = "input0";
28 26
29static void do_softint(void *data) 27static void do_softint(void *data)
30{ 28{
@@ -58,14 +56,14 @@ static void do_softint(void *data)
58 } 56 }
59 57
60 if (touched) { 58 if (touched) {
61 input_report_key(&hp680_ts_dev, BTN_TOUCH, 1); 59 input_report_key(hp680_ts_dev, BTN_TOUCH, 1);
62 input_report_abs(&hp680_ts_dev, ABS_X, absx); 60 input_report_abs(hp680_ts_dev, ABS_X, absx);
63 input_report_abs(&hp680_ts_dev, ABS_Y, absy); 61 input_report_abs(hp680_ts_dev, ABS_Y, absy);
64 } else { 62 } else {
65 input_report_key(&hp680_ts_dev, BTN_TOUCH, 0); 63 input_report_key(hp680_ts_dev, BTN_TOUCH, 0);
66 } 64 }
67 65
68 input_sync(&hp680_ts_dev); 66 input_sync(hp680_ts_dev);
69 enable_irq(HP680_TS_IRQ); 67 enable_irq(HP680_TS_IRQ);
70} 68}
71 69
@@ -92,27 +90,29 @@ static int __init hp680_ts_init(void)
92 scpcr |= SCPCR_TS_ENABLE; 90 scpcr |= SCPCR_TS_ENABLE;
93 ctrl_outw(scpcr, SCPCR); 91 ctrl_outw(scpcr, SCPCR);
94 92
95 memset(&hp680_ts_dev, 0, sizeof(hp680_ts_dev)); 93 hp680_ts_dev = input_allocate_device();
96 init_input_dev(&hp680_ts_dev); 94 if (!hp680_ts_dev)
95 return -ENOMEM;
97 96
98 hp680_ts_dev.evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); 97 hp680_ts_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
99 hp680_ts_dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y); 98 hp680_ts_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
100 hp680_ts_dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 99 hp680_ts_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
101 100
102 hp680_ts_dev.absmin[ABS_X] = HP680_TS_ABS_X_MIN; 101 hp680_ts_dev->absmin[ABS_X] = HP680_TS_ABS_X_MIN;
103 hp680_ts_dev.absmin[ABS_Y] = HP680_TS_ABS_Y_MIN; 102 hp680_ts_dev->absmin[ABS_Y] = HP680_TS_ABS_Y_MIN;
104 hp680_ts_dev.absmax[ABS_X] = HP680_TS_ABS_X_MAX; 103 hp680_ts_dev->absmax[ABS_X] = HP680_TS_ABS_X_MAX;
105 hp680_ts_dev.absmax[ABS_Y] = HP680_TS_ABS_Y_MAX; 104 hp680_ts_dev->absmax[ABS_Y] = HP680_TS_ABS_Y_MAX;
106 105
107 hp680_ts_dev.name = hp680_ts_name; 106 hp680_ts_dev->name = "HP Jornada touchscreen";
108 hp680_ts_dev.phys = hp680_ts_phys; 107 hp680_ts_dev->phys = "hp680_ts/input0";
109 input_register_device(&hp680_ts_dev);
110 108
111 if (request_irq 109 input_register_device(hp680_ts_dev);
112 (HP680_TS_IRQ, hp680_ts_interrupt, SA_INTERRUPT, MODNAME, 0) < 0) { 110
113 printk(KERN_ERR "hp680_touchscreen.c : Can't allocate irq %d\n", 111 if (request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
112 SA_INTERRUPT, MODNAME, 0) < 0) {
113 printk(KERN_ERR "hp680_touchscreen.c: Can't allocate irq %d\n",
114 HP680_TS_IRQ); 114 HP680_TS_IRQ);
115 input_unregister_device(&hp680_ts_dev); 115 input_unregister_device(hp680_ts_dev);
116 return -EBUSY; 116 return -EBUSY;
117 } 117 }
118 118
@@ -124,7 +124,7 @@ static void __exit hp680_ts_exit(void)
124 free_irq(HP680_TS_IRQ, 0); 124 free_irq(HP680_TS_IRQ, 0);
125 cancel_delayed_work(&work); 125 cancel_delayed_work(&work);
126 flush_scheduled_work(); 126 flush_scheduled_work();
127 input_unregister_device(&hp680_ts_dev); 127 input_unregister_device(hp680_ts_dev);
128} 128}
129 129
130module_init(hp680_ts_init); 130module_init(hp680_ts_init);
diff --git a/drivers/input/touchscreen/mk712.c b/drivers/input/touchscreen/mk712.c
index afaaebe5225b..4844d250a5eb 100644
--- a/drivers/input/touchscreen/mk712.c
+++ b/drivers/input/touchscreen/mk712.c
@@ -77,7 +77,7 @@ MODULE_PARM_DESC(irq, "IRQ of MK712 touchscreen controller");
77#define MK712_READ_ONE_POINT 0x20 77#define MK712_READ_ONE_POINT 0x20
78#define MK712_POWERUP 0x40 78#define MK712_POWERUP 0x40
79 79
80static struct input_dev mk712_dev; 80static struct input_dev *mk712_dev;
81static DEFINE_SPINLOCK(mk712_lock); 81static DEFINE_SPINLOCK(mk712_lock);
82 82
83static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs) 83static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -88,7 +88,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
88 static unsigned short last_y; 88 static unsigned short last_y;
89 89
90 spin_lock(&mk712_lock); 90 spin_lock(&mk712_lock);
91 input_regs(&mk712_dev, regs); 91 input_regs(mk712_dev, regs);
92 92
93 status = inb(mk712_io + MK712_STATUS); 93 status = inb(mk712_io + MK712_STATUS);
94 94
@@ -100,7 +100,7 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
100 if (~status & MK712_STATUS_TOUCH) 100 if (~status & MK712_STATUS_TOUCH)
101 { 101 {
102 debounce = 1; 102 debounce = 1;
103 input_report_key(&mk712_dev, BTN_TOUCH, 0); 103 input_report_key(mk712_dev, BTN_TOUCH, 0);
104 goto end; 104 goto end;
105 } 105 }
106 106
@@ -110,15 +110,15 @@ static irqreturn_t mk712_interrupt(int irq, void *dev_id, struct pt_regs *regs)
110 goto end; 110 goto end;
111 } 111 }
112 112
113 input_report_key(&mk712_dev, BTN_TOUCH, 1); 113 input_report_key(mk712_dev, BTN_TOUCH, 1);
114 input_report_abs(&mk712_dev, ABS_X, last_x); 114 input_report_abs(mk712_dev, ABS_X, last_x);
115 input_report_abs(&mk712_dev, ABS_Y, last_y); 115 input_report_abs(mk712_dev, ABS_Y, last_y);
116 116
117end: 117end:
118 118
119 last_x = inw(mk712_io + MK712_X) & 0x0fff; 119 last_x = inw(mk712_io + MK712_X) & 0x0fff;
120 last_y = inw(mk712_io + MK712_Y) & 0x0fff; 120 last_y = inw(mk712_io + MK712_Y) & 0x0fff;
121 input_sync(&mk712_dev); 121 input_sync(mk712_dev);
122 spin_unlock(&mk712_lock); 122 spin_unlock(&mk712_lock);
123 return IRQ_HANDLED; 123 return IRQ_HANDLED;
124} 124}
@@ -154,30 +154,11 @@ static void mk712_close(struct input_dev *dev)
154 spin_unlock_irqrestore(&mk712_lock, flags); 154 spin_unlock_irqrestore(&mk712_lock, flags);
155} 155}
156 156
157static struct input_dev mk712_dev = {
158 .evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
159 .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
160 .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
161 .open = mk712_open,
162 .close = mk712_close,
163 .name = "ICS MicroClock MK712 TouchScreen",
164 .phys = "isa0260/input0",
165 .absmin = { [ABS_X] = 0, [ABS_Y] = 0 },
166 .absmax = { [ABS_X] = 0xfff, [ABS_Y] = 0xfff },
167 .absfuzz = { [ABS_X] = 88, [ABS_Y] = 88 },
168 .id = {
169 .bustype = BUS_ISA,
170 .vendor = 0x0005,
171 .product = 0x0001,
172 .version = 0x0100,
173 },
174};
175
176int __init mk712_init(void) 157int __init mk712_init(void)
177{ 158{
159 int err;
178 160
179 if(!request_region(mk712_io, 8, "mk712")) 161 if (!request_region(mk712_io, 8, "mk712")) {
180 {
181 printk(KERN_WARNING "mk712: unable to get IO region\n"); 162 printk(KERN_WARNING "mk712: unable to get IO region\n");
182 return -ENODEV; 163 return -ENODEV;
183 } 164 }
@@ -188,28 +169,49 @@ int __init mk712_init(void)
188 (inw(mk712_io + MK712_Y) & 0xf000) || 169 (inw(mk712_io + MK712_Y) & 0xf000) ||
189 (inw(mk712_io + MK712_STATUS) & 0xf333)) { 170 (inw(mk712_io + MK712_STATUS) & 0xf333)) {
190 printk(KERN_WARNING "mk712: device not present\n"); 171 printk(KERN_WARNING "mk712: device not present\n");
191 release_region(mk712_io, 8); 172 err = -ENODEV;
192 return -ENODEV; 173 goto fail;
193 } 174 }
194 175
195 if(request_irq(mk712_irq, mk712_interrupt, 0, "mk712", &mk712_dev)) 176 if (!(mk712_dev = input_allocate_device())) {
196 { 177 printk(KERN_ERR "mk712: not enough memory\n");
197 printk(KERN_WARNING "mk712: unable to get IRQ\n"); 178 err = -ENOMEM;
198 release_region(mk712_io, 8); 179 goto fail;
199 return -EBUSY;
200 } 180 }
201 181
202 input_register_device(&mk712_dev); 182 mk712_dev->name = "ICS MicroClock MK712 TouchScreen";
183 mk712_dev->phys = "isa0260/input0";
184 mk712_dev->id.bustype = BUS_ISA;
185 mk712_dev->id.vendor = 0x0005;
186 mk712_dev->id.product = 0x0001;
187 mk712_dev->id.version = 0x0100;
188
189 mk712_dev->open = mk712_open;
190 mk712_dev->close = mk712_close;
203 191
204 printk(KERN_INFO "input: ICS MicroClock MK712 TouchScreen at %#x irq %d\n", mk712_io, mk712_irq); 192 mk712_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
193 mk712_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
194 input_set_abs_params(mk712_dev, ABS_X, 0, 0xfff, 88, 0);
195 input_set_abs_params(mk712_dev, ABS_Y, 0, 0xfff, 88, 0);
205 196
197 if (request_irq(mk712_irq, mk712_interrupt, 0, "mk712", mk712_dev)) {
198 printk(KERN_WARNING "mk712: unable to get IRQ\n");
199 err = -EBUSY;
200 goto fail;
201 }
202
203 input_register_device(mk712_dev);
206 return 0; 204 return 0;
205
206 fail: input_free_device(mk712_dev);
207 release_region(mk712_io, 8);
208 return err;
207} 209}
208 210
209static void __exit mk712_exit(void) 211static void __exit mk712_exit(void)
210{ 212{
211 input_unregister_device(&mk712_dev); 213 input_unregister_device(mk712_dev);
212 free_irq(mk712_irq, &mk712_dev); 214 free_irq(mk712_irq, mk712_dev);
213 release_region(mk712_io, 8); 215 release_region(mk712_io, 8);
214} 216}
215 217
diff --git a/drivers/input/touchscreen/mtouch.c b/drivers/input/touchscreen/mtouch.c
index aa8ee7842179..1d0d37eeef6e 100644
--- a/drivers/input/touchscreen/mtouch.c
+++ b/drivers/input/touchscreen/mtouch.c
@@ -51,14 +51,12 @@ MODULE_LICENSE("GPL");
51#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3]) 51#define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3])
52#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0]) 52#define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0])
53 53
54static char *mtouch_name = "MicroTouch Serial TouchScreen";
55
56/* 54/*
57 * Per-touchscreen data. 55 * Per-touchscreen data.
58 */ 56 */
59 57
60struct mtouch { 58struct mtouch {
61 struct input_dev dev; 59 struct input_dev *dev;
62 struct serio *serio; 60 struct serio *serio;
63 int idx; 61 int idx;
64 unsigned char data[MTOUCH_MAX_LENGTH]; 62 unsigned char data[MTOUCH_MAX_LENGTH];
@@ -67,7 +65,7 @@ struct mtouch {
67 65
68static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs) 66static void mtouch_process_format_tablet(struct mtouch *mtouch, struct pt_regs *regs)
69{ 67{
70 struct input_dev *dev = &mtouch->dev; 68 struct input_dev *dev = mtouch->dev;
71 69
72 if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) { 70 if (MTOUCH_FORMAT_TABLET_LENGTH == ++mtouch->idx) {
73 input_regs(dev, regs); 71 input_regs(dev, regs);
@@ -116,9 +114,11 @@ static void mtouch_disconnect(struct serio *serio)
116{ 114{
117 struct mtouch* mtouch = serio_get_drvdata(serio); 115 struct mtouch* mtouch = serio_get_drvdata(serio);
118 116
119 input_unregister_device(&mtouch->dev); 117 input_get_device(mtouch->dev);
118 input_unregister_device(mtouch->dev);
120 serio_close(serio); 119 serio_close(serio);
121 serio_set_drvdata(serio, NULL); 120 serio_set_drvdata(serio, NULL);
121 input_put_device(mtouch->dev);
122 kfree(mtouch); 122 kfree(mtouch);
123} 123}
124 124
@@ -131,46 +131,46 @@ static void mtouch_disconnect(struct serio *serio)
131static int mtouch_connect(struct serio *serio, struct serio_driver *drv) 131static int mtouch_connect(struct serio *serio, struct serio_driver *drv)
132{ 132{
133 struct mtouch *mtouch; 133 struct mtouch *mtouch;
134 struct input_dev *input_dev;
134 int err; 135 int err;
135 136
136 if (!(mtouch = kmalloc(sizeof(*mtouch), GFP_KERNEL))) 137 mtouch = kzalloc(sizeof(struct mtouch), GFP_KERNEL);
137 return -ENOMEM; 138 input_dev = input_allocate_device();
138 139 if (!mtouch || !input_dev) {
139 memset(mtouch, 0, sizeof(*mtouch)); 140 err = -ENOMEM;
140 141 goto fail;
141 init_input_dev(&mtouch->dev); 142 }
142 mtouch->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
143 mtouch->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
144
145 input_set_abs_params(&mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
146 input_set_abs_params(&mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
147 143
148 mtouch->serio = serio; 144 mtouch->serio = serio;
149 145 mtouch->dev = input_dev;
150 sprintf(mtouch->phys, "%s/input0", serio->phys); 146 sprintf(mtouch->phys, "%s/input0", serio->phys);
151 147
152 mtouch->dev.private = mtouch; 148 input_dev->private = mtouch;
153 mtouch->dev.name = mtouch_name; 149 input_dev->name = "MicroTouch Serial TouchScreen";
154 mtouch->dev.phys = mtouch->phys; 150 input_dev->phys = mtouch->phys;
155 mtouch->dev.id.bustype = BUS_RS232; 151 input_dev->id.bustype = BUS_RS232;
156 mtouch->dev.id.vendor = SERIO_MICROTOUCH; 152 input_dev->id.vendor = SERIO_MICROTOUCH;
157 mtouch->dev.id.product = 0; 153 input_dev->id.product = 0;
158 mtouch->dev.id.version = 0x0100; 154 input_dev->id.version = 0x0100;
155 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
156 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
157 input_set_abs_params(mtouch->dev, ABS_X, MTOUCH_MIN_XC, MTOUCH_MAX_XC, 0, 0);
158 input_set_abs_params(mtouch->dev, ABS_Y, MTOUCH_MIN_YC, MTOUCH_MAX_YC, 0, 0);
159 159
160 serio_set_drvdata(serio, mtouch); 160 serio_set_drvdata(serio, mtouch);
161 161
162 err = serio_open(serio, drv); 162 err = serio_open(serio, drv);
163 if (err) { 163 if (err)
164 serio_set_drvdata(serio, NULL); 164 goto fail;
165 kfree(mtouch);
166 return err;
167 }
168
169 input_register_device(&mtouch->dev);
170 165
171 printk(KERN_INFO "input: %s on %s\n", mtouch->dev.name, serio->phys); 166 input_register_device(mtouch->dev);
172 167
173 return 0; 168 return 0;
169
170 fail: serio_set_drvdata(serio, NULL);
171 input_free_device(input_dev);
172 kfree(mtouch);
173 return err;
174} 174}
175 175
176/* 176/*
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index 50c63a155156..ca1547929d62 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -53,7 +53,6 @@
53#include <linux/random.h> 53#include <linux/random.h>
54#include <linux/time.h> 54#include <linux/time.h>
55#include <linux/device.h> 55#include <linux/device.h>
56#include <linux/devfs_fs_kernel.h>
57 56
58#ifndef CONFIG_INPUT_TSDEV_SCREEN_X 57#ifndef CONFIG_INPUT_TSDEV_SCREEN_X
59#define CONFIG_INPUT_TSDEV_SCREEN_X 240 58#define CONFIG_INPUT_TSDEV_SCREEN_X 240
@@ -369,6 +368,7 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
369 struct input_device_id *id) 368 struct input_device_id *id)
370{ 369{
371 struct tsdev *tsdev; 370 struct tsdev *tsdev;
371 struct class_device *cdev;
372 int minor, delta; 372 int minor, delta;
373 373
374 for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; 374 for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor];
@@ -410,13 +410,13 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
410 410
411 tsdev_table[minor] = tsdev; 411 tsdev_table[minor] = tsdev;
412 412
413 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), 413 cdev = class_device_create(&input_class, &dev->cdev,
414 S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
415 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
416 S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
417 class_device_create(input_class,
418 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), 414 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
419 dev->dev, "ts%d", minor); 415 dev->cdev.dev, tsdev->name);
416
417 /* temporary symlink to keep userspace happy */
418 sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj,
419 tsdev->name);
420 420
421 return &tsdev->handle; 421 return &tsdev->handle;
422} 422}
@@ -426,10 +426,9 @@ static void tsdev_disconnect(struct input_handle *handle)
426 struct tsdev *tsdev = handle->private; 426 struct tsdev *tsdev = handle->private;
427 struct tsdev_list *list; 427 struct tsdev_list *list;
428 428
429 class_device_destroy(input_class, 429 sysfs_remove_link(&input_class.subsys.kset.kobj, tsdev->name);
430 class_device_destroy(&input_class,
430 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); 431 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
431 devfs_remove("input/ts%d", tsdev->minor);
432 devfs_remove("input/tsraw%d", tsdev->minor);
433 tsdev->exist = 0; 432 tsdev->exist = 0;
434 433
435 if (tsdev->open) { 434 if (tsdev->open) {
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 04fb606b5ddd..11ae0fddea04 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1505,7 +1505,7 @@ static int __init capi_init(void)
1505 return PTR_ERR(capi_class); 1505 return PTR_ERR(capi_class);
1506 } 1506 }
1507 1507
1508 class_device_create(capi_class, MKDEV(capi_major, 0), NULL, "capi"); 1508 class_device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi");
1509 devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR, 1509 devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
1510 "isdn/capi20"); 1510 "isdn/capi20");
1511 1511
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index c0dc1e3fa58b..d2ead1776c16 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -905,5 +905,5 @@ adbdev_init(void)
905 adb_dev_class = class_create(THIS_MODULE, "adb"); 905 adb_dev_class = class_create(THIS_MODULE, "adb");
906 if (IS_ERR(adb_dev_class)) 906 if (IS_ERR(adb_dev_class))
907 return; 907 return;
908 class_device_create(adb_dev_class, MKDEV(ADB_MAJOR, 0), NULL, "adb"); 908 class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
909} 909}
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index db654e8bd67e..cdb6d0283195 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -206,7 +206,7 @@ u8 adb_to_linux_keycodes[128] = {
206}; 206};
207 207
208struct adbhid { 208struct adbhid {
209 struct input_dev input; 209 struct input_dev *input;
210 int id; 210 int id;
211 int default_id; 211 int default_id;
212 int original_handler_id; 212 int original_handler_id;
@@ -291,10 +291,10 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
291 291
292 switch (keycode) { 292 switch (keycode) {
293 case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */ 293 case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock everytime. */
294 input_regs(&ahid->input, regs); 294 input_regs(ahid->input, regs);
295 input_report_key(&ahid->input, KEY_CAPSLOCK, 1); 295 input_report_key(ahid->input, KEY_CAPSLOCK, 1);
296 input_report_key(&ahid->input, KEY_CAPSLOCK, 0); 296 input_report_key(ahid->input, KEY_CAPSLOCK, 0);
297 input_sync(&ahid->input); 297 input_sync(ahid->input);
298 return; 298 return;
299#ifdef CONFIG_PPC_PMAC 299#ifdef CONFIG_PPC_PMAC
300 case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs remapping */ 300 case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs remapping */
@@ -347,10 +347,10 @@ adbhid_input_keycode(int id, int keycode, int repeat, struct pt_regs *regs)
347 } 347 }
348 348
349 if (adbhid[id]->keycode[keycode]) { 349 if (adbhid[id]->keycode[keycode]) {
350 input_regs(&adbhid[id]->input, regs); 350 input_regs(adbhid[id]->input, regs);
351 input_report_key(&adbhid[id]->input, 351 input_report_key(adbhid[id]->input,
352 adbhid[id]->keycode[keycode], !up_flag); 352 adbhid[id]->keycode[keycode], !up_flag);
353 input_sync(&adbhid[id]->input); 353 input_sync(adbhid[id]->input);
354 } else 354 } else
355 printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode, 355 printk(KERN_INFO "Unhandled ADB key (scancode %#02x) %s.\n", keycode,
356 up_flag ? "released" : "pressed"); 356 up_flag ? "released" : "pressed");
@@ -441,20 +441,20 @@ adbhid_mouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopo
441 break; 441 break;
442 } 442 }
443 443
444 input_regs(&adbhid[id]->input, regs); 444 input_regs(adbhid[id]->input, regs);
445 445
446 input_report_key(&adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); 446 input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1));
447 input_report_key(&adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); 447 input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1));
448 448
449 if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) 449 if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD)
450 input_report_key(&adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); 450 input_report_key(adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1));
451 451
452 input_report_rel(&adbhid[id]->input, REL_X, 452 input_report_rel(adbhid[id]->input, REL_X,
453 ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); 453 ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 ));
454 input_report_rel(&adbhid[id]->input, REL_Y, 454 input_report_rel(adbhid[id]->input, REL_Y,
455 ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); 455 ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 ));
456 456
457 input_sync(&adbhid[id]->input); 457 input_sync(adbhid[id]->input);
458} 458}
459 459
460static void 460static void
@@ -467,7 +467,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
467 return; 467 return;
468 } 468 }
469 469
470 input_regs(&adbhid[id]->input, regs); 470 input_regs(adbhid[id]->input, regs);
471 471
472 switch (adbhid[id]->original_handler_id) { 472 switch (adbhid[id]->original_handler_id) {
473 default: 473 default:
@@ -477,19 +477,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
477 477
478 switch (data[1] & 0x0f) { 478 switch (data[1] & 0x0f) {
479 case 0x0: /* microphone */ 479 case 0x0: /* microphone */
480 input_report_key(&adbhid[id]->input, KEY_SOUND, down); 480 input_report_key(adbhid[id]->input, KEY_SOUND, down);
481 break; 481 break;
482 482
483 case 0x1: /* mute */ 483 case 0x1: /* mute */
484 input_report_key(&adbhid[id]->input, KEY_MUTE, down); 484 input_report_key(adbhid[id]->input, KEY_MUTE, down);
485 break; 485 break;
486 486
487 case 0x2: /* volume decrease */ 487 case 0x2: /* volume decrease */
488 input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, down); 488 input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down);
489 break; 489 break;
490 490
491 case 0x3: /* volume increase */ 491 case 0x3: /* volume increase */
492 input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, down); 492 input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down);
493 break; 493 break;
494 494
495 default: 495 default:
@@ -513,19 +513,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
513 513
514 switch (data[1] & 0x0f) { 514 switch (data[1] & 0x0f) {
515 case 0x8: /* mute */ 515 case 0x8: /* mute */
516 input_report_key(&adbhid[id]->input, KEY_MUTE, down); 516 input_report_key(adbhid[id]->input, KEY_MUTE, down);
517 break; 517 break;
518 518
519 case 0x7: /* volume decrease */ 519 case 0x7: /* volume decrease */
520 input_report_key(&adbhid[id]->input, KEY_VOLUMEDOWN, down); 520 input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down);
521 break; 521 break;
522 522
523 case 0x6: /* volume increase */ 523 case 0x6: /* volume increase */
524 input_report_key(&adbhid[id]->input, KEY_VOLUMEUP, down); 524 input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down);
525 break; 525 break;
526 526
527 case 0xb: /* eject */ 527 case 0xb: /* eject */
528 input_report_key(&adbhid[id]->input, KEY_EJECTCD, down); 528 input_report_key(adbhid[id]->input, KEY_EJECTCD, down);
529 break; 529 break;
530 530
531 case 0xa: /* brightness decrease */ 531 case 0xa: /* brightness decrease */
@@ -539,7 +539,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
539 } 539 }
540 } 540 }
541#endif /* CONFIG_PMAC_BACKLIGHT */ 541#endif /* CONFIG_PMAC_BACKLIGHT */
542 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSDOWN, down); 542 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down);
543 break; 543 break;
544 544
545 case 0x9: /* brightness increase */ 545 case 0x9: /* brightness increase */
@@ -553,19 +553,19 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
553 } 553 }
554 } 554 }
555#endif /* CONFIG_PMAC_BACKLIGHT */ 555#endif /* CONFIG_PMAC_BACKLIGHT */
556 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down); 556 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down);
557 break; 557 break;
558 558
559 case 0xc: /* videomode switch */ 559 case 0xc: /* videomode switch */
560 input_report_key(&adbhid[id]->input, KEY_SWITCHVIDEOMODE, down); 560 input_report_key(adbhid[id]->input, KEY_SWITCHVIDEOMODE, down);
561 break; 561 break;
562 562
563 case 0xd: /* keyboard illumination toggle */ 563 case 0xd: /* keyboard illumination toggle */
564 input_report_key(&adbhid[id]->input, KEY_KBDILLUMTOGGLE, down); 564 input_report_key(adbhid[id]->input, KEY_KBDILLUMTOGGLE, down);
565 break; 565 break;
566 566
567 case 0xe: /* keyboard illumination decrease */ 567 case 0xe: /* keyboard illumination decrease */
568 input_report_key(&adbhid[id]->input, KEY_KBDILLUMDOWN, down); 568 input_report_key(adbhid[id]->input, KEY_KBDILLUMDOWN, down);
569 break; 569 break;
570 570
571 case 0xf: 571 case 0xf:
@@ -573,7 +573,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
573 case 0x8f: 573 case 0x8f:
574 case 0x0f: 574 case 0x0f:
575 /* keyboard illumination increase */ 575 /* keyboard illumination increase */
576 input_report_key(&adbhid[id]->input, KEY_KBDILLUMUP, down); 576 input_report_key(adbhid[id]->input, KEY_KBDILLUMUP, down);
577 break; 577 break;
578 578
579 case 0x7f: 579 case 0x7f:
@@ -596,7 +596,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
596 break; 596 break;
597 } 597 }
598 598
599 input_sync(&adbhid[id]->input); 599 input_sync(adbhid[id]->input);
600} 600}
601 601
602static struct adb_request led_request; 602static struct adb_request led_request;
@@ -683,7 +683,7 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x)
683 int i; 683 int i;
684 for (i = 1; i < 16; i++) { 684 for (i = 1; i < 16; i++) {
685 if (adbhid[i]) 685 if (adbhid[i])
686 del_timer_sync(&adbhid[i]->input.timer); 686 del_timer_sync(&adbhid[i]->input->timer);
687 } 687 }
688 } 688 }
689 689
@@ -699,153 +699,163 @@ adb_message_handler(struct notifier_block *this, unsigned long code, void *x)
699 return NOTIFY_DONE; 699 return NOTIFY_DONE;
700} 700}
701 701
702static void 702static int
703adbhid_input_register(int id, int default_id, int original_handler_id, 703adbhid_input_register(int id, int default_id, int original_handler_id,
704 int current_handler_id, int mouse_kind) 704 int current_handler_id, int mouse_kind)
705{ 705{
706 struct adbhid *hid;
707 struct input_dev *input_dev;
708 int err;
706 int i; 709 int i;
707 710
708 if (adbhid[id]) { 711 if (adbhid[id]) {
709 printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id); 712 printk(KERN_ERR "Trying to reregister ADB HID on ID %d\n", id);
710 return; 713 return -EEXIST;
711 } 714 }
712 715
713 if (!(adbhid[id] = kmalloc(sizeof(struct adbhid), GFP_KERNEL))) 716 adbhid[id] = hid = kzalloc(sizeof(struct adbhid), GFP_KERNEL);
714 return; 717 input_dev = input_allocate_device();
715 718 if (!hid || !input_dev) {
716 memset(adbhid[id], 0, sizeof(struct adbhid)); 719 err = -ENOMEM;
717 sprintf(adbhid[id]->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); 720 goto fail;
718 721
719 init_input_dev(&adbhid[id]->input); 722 }
720 723
721 adbhid[id]->id = default_id; 724 sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id);
722 adbhid[id]->original_handler_id = original_handler_id; 725
723 adbhid[id]->current_handler_id = current_handler_id; 726 hid->id = default_id;
724 adbhid[id]->mouse_kind = mouse_kind; 727 hid->original_handler_id = original_handler_id;
725 adbhid[id]->flags = 0; 728 hid->current_handler_id = current_handler_id;
726 adbhid[id]->input.private = adbhid[id]; 729 hid->mouse_kind = mouse_kind;
727 adbhid[id]->input.name = adbhid[id]->name; 730 hid->flags = 0;
728 adbhid[id]->input.phys = adbhid[id]->phys; 731 input_dev->private = hid;
729 adbhid[id]->input.id.bustype = BUS_ADB; 732 input_dev->name = hid->name;
730 adbhid[id]->input.id.vendor = 0x0001; 733 input_dev->phys = hid->phys;
731 adbhid[id]->input.id.product = (id << 12) | (default_id << 8) | original_handler_id; 734 input_dev->id.bustype = BUS_ADB;
732 adbhid[id]->input.id.version = 0x0100; 735 input_dev->id.vendor = 0x0001;
736 input_dev->id.product = (id << 12) | (default_id << 8) | original_handler_id;
737 input_dev->id.version = 0x0100;
733 738
734 switch (default_id) { 739 switch (default_id) {
735 case ADB_KEYBOARD: 740 case ADB_KEYBOARD:
736 if (!(adbhid[id]->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL))) { 741 hid->keycode = kmalloc(sizeof(adb_to_linux_keycodes), GFP_KERNEL);
737 kfree(adbhid[id]); 742 if (!hid->keycode) {
738 return; 743 err = -ENOMEM;
744 goto fail;
739 } 745 }
740 746
741 sprintf(adbhid[id]->name, "ADB keyboard"); 747 sprintf(hid->name, "ADB keyboard");
742 748
743 memcpy(adbhid[id]->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes)); 749 memcpy(hid->keycode, adb_to_linux_keycodes, sizeof(adb_to_linux_keycodes));
744 750
745 printk(KERN_INFO "Detected ADB keyboard, type "); 751 printk(KERN_INFO "Detected ADB keyboard, type ");
746 switch (original_handler_id) { 752 switch (original_handler_id) {
747 default: 753 default:
748 printk("<unknown>.\n"); 754 printk("<unknown>.\n");
749 adbhid[id]->input.id.version = ADB_KEYBOARD_UNKNOWN; 755 input_dev->id.version = ADB_KEYBOARD_UNKNOWN;
750 break; 756 break;
751 757
752 case 0x01: case 0x02: case 0x03: case 0x06: case 0x08: 758 case 0x01: case 0x02: case 0x03: case 0x06: case 0x08:
753 case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C: 759 case 0x0C: case 0x10: case 0x18: case 0x1B: case 0x1C:
754 case 0xC0: case 0xC3: case 0xC6: 760 case 0xC0: case 0xC3: case 0xC6:
755 printk("ANSI.\n"); 761 printk("ANSI.\n");
756 adbhid[id]->input.id.version = ADB_KEYBOARD_ANSI; 762 input_dev->id.version = ADB_KEYBOARD_ANSI;
757 break; 763 break;
758 764
759 case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D: 765 case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D:
760 case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1: 766 case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1:
761 case 0xC4: case 0xC7: 767 case 0xC4: case 0xC7:
762 printk("ISO, swapping keys.\n"); 768 printk("ISO, swapping keys.\n");
763 adbhid[id]->input.id.version = ADB_KEYBOARD_ISO; 769 input_dev->id.version = ADB_KEYBOARD_ISO;
764 i = adbhid[id]->keycode[10]; 770 i = hid->keycode[10];
765 adbhid[id]->keycode[10] = adbhid[id]->keycode[50]; 771 hid->keycode[10] = hid->keycode[50];
766 adbhid[id]->keycode[50] = i; 772 hid->keycode[50] = i;
767 break; 773 break;
768 774
769 case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A: 775 case 0x12: case 0x15: case 0x16: case 0x17: case 0x1A:
770 case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9: 776 case 0x1E: case 0xC2: case 0xC5: case 0xC8: case 0xC9:
771 printk("JIS.\n"); 777 printk("JIS.\n");
772 adbhid[id]->input.id.version = ADB_KEYBOARD_JIS; 778 input_dev->id.version = ADB_KEYBOARD_JIS;
773 break; 779 break;
774 } 780 }
775 781
776 for (i = 0; i < 128; i++) 782 for (i = 0; i < 128; i++)
777 if (adbhid[id]->keycode[i]) 783 if (hid->keycode[i])
778 set_bit(adbhid[id]->keycode[i], adbhid[id]->input.keybit); 784 set_bit(hid->keycode[i], input_dev->keybit);
779 785
780 adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); 786 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
781 adbhid[id]->input.ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML); 787 input_dev->ledbit[0] = BIT(LED_SCROLLL) | BIT(LED_CAPSL) | BIT(LED_NUML);
782 adbhid[id]->input.event = adbhid_kbd_event; 788 input_dev->event = adbhid_kbd_event;
783 adbhid[id]->input.keycodemax = 127; 789 input_dev->keycodemax = 127;
784 adbhid[id]->input.keycodesize = 1; 790 input_dev->keycodesize = 1;
785 break; 791 break;
786 792
787 case ADB_MOUSE: 793 case ADB_MOUSE:
788 sprintf(adbhid[id]->name, "ADB mouse"); 794 sprintf(hid->name, "ADB mouse");
789 795
790 adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 796 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
791 adbhid[id]->input.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 797 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
792 adbhid[id]->input.relbit[0] = BIT(REL_X) | BIT(REL_Y); 798 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
793 break; 799 break;
794 800
795 case ADB_MISC: 801 case ADB_MISC:
796 switch (original_handler_id) { 802 switch (original_handler_id) {
797 case 0x02: /* Adjustable keyboard button device */ 803 case 0x02: /* Adjustable keyboard button device */
798 sprintf(adbhid[id]->name, "ADB adjustable keyboard buttons"); 804 sprintf(hid->name, "ADB adjustable keyboard buttons");
799 adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 805 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
800 set_bit(KEY_SOUND, adbhid[id]->input.keybit); 806 set_bit(KEY_SOUND, input_dev->keybit);
801 set_bit(KEY_MUTE, adbhid[id]->input.keybit); 807 set_bit(KEY_MUTE, input_dev->keybit);
802 set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit); 808 set_bit(KEY_VOLUMEUP, input_dev->keybit);
803 set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit); 809 set_bit(KEY_VOLUMEDOWN, input_dev->keybit);
804 break; 810 break;
805 case 0x1f: /* Powerbook button device */ 811 case 0x1f: /* Powerbook button device */
806 sprintf(adbhid[id]->name, "ADB Powerbook buttons"); 812 sprintf(hid->name, "ADB Powerbook buttons");
807 adbhid[id]->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 813 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
808 set_bit(KEY_MUTE, adbhid[id]->input.keybit); 814 set_bit(KEY_MUTE, input_dev->keybit);
809 set_bit(KEY_VOLUMEUP, adbhid[id]->input.keybit); 815 set_bit(KEY_VOLUMEUP, input_dev->keybit);
810 set_bit(KEY_VOLUMEDOWN, adbhid[id]->input.keybit); 816 set_bit(KEY_VOLUMEDOWN, input_dev->keybit);
811 set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit); 817 set_bit(KEY_BRIGHTNESSUP, input_dev->keybit);
812 set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit); 818 set_bit(KEY_BRIGHTNESSDOWN, input_dev->keybit);
813 set_bit(KEY_EJECTCD, adbhid[id]->input.keybit); 819 set_bit(KEY_EJECTCD, input_dev->keybit);
814 set_bit(KEY_SWITCHVIDEOMODE, adbhid[id]->input.keybit); 820 set_bit(KEY_SWITCHVIDEOMODE, input_dev->keybit);
815 set_bit(KEY_KBDILLUMTOGGLE, adbhid[id]->input.keybit); 821 set_bit(KEY_KBDILLUMTOGGLE, input_dev->keybit);
816 set_bit(KEY_KBDILLUMDOWN, adbhid[id]->input.keybit); 822 set_bit(KEY_KBDILLUMDOWN, input_dev->keybit);
817 set_bit(KEY_KBDILLUMUP, adbhid[id]->input.keybit); 823 set_bit(KEY_KBDILLUMUP, input_dev->keybit);
818 break; 824 break;
819 } 825 }
820 if (adbhid[id]->name[0]) 826 if (hid->name[0])
821 break; 827 break;
822 /* else fall through */ 828 /* else fall through */
823 829
824 default: 830 default:
825 printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n"); 831 printk(KERN_INFO "Trying to register unknown ADB device to input layer.\n");
826 kfree(adbhid[id]); 832 err = -ENODEV;
827 return; 833 goto fail;
828 } 834 }
829 835
830 adbhid[id]->input.keycode = adbhid[id]->keycode; 836 input_dev->keycode = hid->keycode;
831
832 input_register_device(&adbhid[id]->input);
833 837
834 printk(KERN_INFO "input: %s on %s\n", 838 input_register_device(input_dev);
835 adbhid[id]->name, adbhid[id]->phys);
836 839
837 if (default_id == ADB_KEYBOARD) { 840 if (default_id == ADB_KEYBOARD) {
838 /* HACK WARNING!! This should go away as soon there is an utility 841 /* HACK WARNING!! This should go away as soon there is an utility
839 * to control that for event devices. 842 * to control that for event devices.
840 */ 843 */
841 adbhid[id]->input.rep[REP_DELAY] = 500; /* input layer default: 250 */ 844 input_dev->rep[REP_DELAY] = 500; /* input layer default: 250 */
842 adbhid[id]->input.rep[REP_PERIOD] = 66; /* input layer default: 33 */ 845 input_dev->rep[REP_PERIOD] = 66; /* input layer default: 33 */
843 } 846 }
847
848 return 0;
849
850 fail: input_free_device(input_dev);
851 kfree(hid);
852 adbhid[id] = NULL;
853 return err;
844} 854}
845 855
846static void adbhid_input_unregister(int id) 856static void adbhid_input_unregister(int id)
847{ 857{
848 input_unregister_device(&adbhid[id]->input); 858 input_unregister_device(adbhid[id]->input);
849 if (adbhid[id]->keycode) 859 if (adbhid[id]->keycode)
850 kfree(adbhid[id]->keycode); 860 kfree(adbhid[id]->keycode);
851 kfree(adbhid[id]); 861 kfree(adbhid[id]);
@@ -858,7 +868,7 @@ adbhid_input_reregister(int id, int default_id, int org_handler_id,
858 int cur_handler_id, int mk) 868 int cur_handler_id, int mk)
859{ 869{
860 if (adbhid[id]) { 870 if (adbhid[id]) {
861 if (adbhid[id]->input.id.product != 871 if (adbhid[id]->input->id.product !=
862 ((id << 12)|(default_id << 8)|org_handler_id)) { 872 ((id << 12)|(default_id << 8)|org_handler_id)) {
863 adbhid_input_unregister(id); 873 adbhid_input_unregister(id);
864 adbhid_input_register(id, default_id, org_handler_id, 874 adbhid_input_register(id, default_id, org_handler_id,
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index 5ad3a5a9eb7f..a66636116f0b 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -16,8 +16,8 @@
16#include <linux/module.h> 16#include <linux/module.h>
17 17
18 18
19static struct input_dev emumousebtn; 19static struct input_dev *emumousebtn;
20static void emumousebtn_input_register(void); 20static int emumousebtn_input_register(void);
21static int mouse_emulate_buttons = 0; 21static int mouse_emulate_buttons = 0;
22static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */ 22static int mouse_button2_keycode = KEY_RIGHTCTRL; /* right control key */
23static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */ 23static int mouse_button3_keycode = KEY_RIGHTALT; /* right option key */
@@ -90,10 +90,10 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
90 && (keycode == mouse_button2_keycode 90 && (keycode == mouse_button2_keycode
91 || keycode == mouse_button3_keycode)) { 91 || keycode == mouse_button3_keycode)) {
92 if (mouse_emulate_buttons == 1) { 92 if (mouse_emulate_buttons == 1) {
93 input_report_key(&emumousebtn, 93 input_report_key(emumousebtn,
94 keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT, 94 keycode == mouse_button2_keycode ? BTN_MIDDLE : BTN_RIGHT,
95 down); 95 down);
96 input_sync(&emumousebtn); 96 input_sync(emumousebtn);
97 return 1; 97 return 1;
98 } 98 }
99 mouse_last_keycode = down ? keycode : 0; 99 mouse_last_keycode = down ? keycode : 0;
@@ -105,30 +105,34 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
105 105
106EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons); 106EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons);
107 107
108static void emumousebtn_input_register(void) 108static int emumousebtn_input_register(void)
109{ 109{
110 emumousebtn.name = "Macintosh mouse button emulation"; 110 emumousebtn = input_allocate_device();
111 if (!emumousebtn)
112 return -ENOMEM;
111 113
112 init_input_dev(&emumousebtn); 114 emumousebtn->name = "Macintosh mouse button emulation";
115 emumousebtn->id.bustype = BUS_ADB;
116 emumousebtn->id.vendor = 0x0001;
117 emumousebtn->id.product = 0x0001;
118 emumousebtn->id.version = 0x0100;
113 119
114 emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 120 emumousebtn->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
115 emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 121 emumousebtn->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
116 emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y); 122 emumousebtn->relbit[0] = BIT(REL_X) | BIT(REL_Y);
117 123
118 emumousebtn.id.bustype = BUS_ADB; 124 input_register_device(emumousebtn);
119 emumousebtn.id.vendor = 0x0001;
120 emumousebtn.id.product = 0x0001;
121 emumousebtn.id.version = 0x0100;
122 125
123 input_register_device(&emumousebtn); 126 return 0;
124
125 printk(KERN_INFO "input: Macintosh mouse button emulation\n");
126} 127}
127 128
128int __init mac_hid_init(void) 129int __init mac_hid_init(void)
129{ 130{
131 int err;
130 132
131 emumousebtn_input_register(); 133 err = emumousebtn_input_register();
134 if (err)
135 return err;
132 136
133#if defined(CONFIG_SYSCTL) 137#if defined(CONFIG_SYSCTL)
134 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1); 138 mac_hid_sysctl_header = register_sysctl_table(mac_hid_root_dir, 1);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 2fba2bbe72d8..01654fcabc52 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -91,7 +91,7 @@ int bitmap_active(struct bitmap *bitmap)
91 91
92#define WRITE_POOL_SIZE 256 92#define WRITE_POOL_SIZE 256
93/* mempool for queueing pending writes on the bitmap file */ 93/* mempool for queueing pending writes on the bitmap file */
94static void *write_pool_alloc(unsigned int gfp_flags, void *data) 94static void *write_pool_alloc(gfp_t gfp_flags, void *data)
95{ 95{
96 return kmalloc(sizeof(struct page_list), gfp_flags); 96 return kmalloc(sizeof(struct page_list), gfp_flags);
97} 97}
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b6148f6f7836..28c1a628621f 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -331,7 +331,7 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
331{ 331{
332 struct bio *bio; 332 struct bio *bio;
333 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 333 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
334 int gfp_mask = GFP_NOIO | __GFP_HIGHMEM; 334 gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
335 unsigned int i; 335 unsigned int i;
336 336
337 /* 337 /*
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index a0e700d7a4a4..06f4d4686a6c 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -252,7 +252,6 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
252 if (ir_codes) 252 if (ir_codes)
253 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); 253 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
254 254
255 init_input_dev(dev);
256 dev->keycode = ir->ir_codes; 255 dev->keycode = ir->ir_codes;
257 dev->keycodesize = sizeof(IR_KEYTAB_TYPE); 256 dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
258 dev->keycodemax = IR_KEYTAB_SIZE; 257 dev->keycodemax = IR_KEYTAB_SIZE;
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 6db0929ef53d..a1607e7d6d6b 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -137,7 +137,8 @@ struct cinergyt2 {
137 struct urb *stream_urb [STREAM_URB_COUNT]; 137 struct urb *stream_urb [STREAM_URB_COUNT];
138 138
139#ifdef ENABLE_RC 139#ifdef ENABLE_RC
140 struct input_dev rc_input_dev; 140 struct input_dev *rc_input_dev;
141 char phys[64];
141 struct work_struct rc_query_work; 142 struct work_struct rc_query_work;
142 int rc_input_event; 143 int rc_input_event;
143 u32 rc_last_code; 144 u32 rc_last_code;
@@ -683,6 +684,7 @@ static struct dvb_device cinergyt2_fe_template = {
683}; 684};
684 685
685#ifdef ENABLE_RC 686#ifdef ENABLE_RC
687
686static void cinergyt2_query_rc (void *data) 688static void cinergyt2_query_rc (void *data)
687{ 689{
688 struct cinergyt2 *cinergyt2 = data; 690 struct cinergyt2 *cinergyt2 = data;
@@ -703,7 +705,7 @@ static void cinergyt2_query_rc (void *data)
703 /* stop key repeat */ 705 /* stop key repeat */
704 if (cinergyt2->rc_input_event != KEY_MAX) { 706 if (cinergyt2->rc_input_event != KEY_MAX) {
705 dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); 707 dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event);
706 input_report_key(&cinergyt2->rc_input_dev, 708 input_report_key(cinergyt2->rc_input_dev,
707 cinergyt2->rc_input_event, 0); 709 cinergyt2->rc_input_event, 0);
708 cinergyt2->rc_input_event = KEY_MAX; 710 cinergyt2->rc_input_event = KEY_MAX;
709 } 711 }
@@ -722,7 +724,7 @@ static void cinergyt2_query_rc (void *data)
722 /* keyrepeat bit -> just repeat last rc_input_event */ 724 /* keyrepeat bit -> just repeat last rc_input_event */
723 } else { 725 } else {
724 cinergyt2->rc_input_event = KEY_MAX; 726 cinergyt2->rc_input_event = KEY_MAX;
725 for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { 727 for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) {
726 if (rc_keys[i + 0] == rc_events[n].type && 728 if (rc_keys[i + 0] == rc_events[n].type &&
727 rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { 729 rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) {
728 cinergyt2->rc_input_event = rc_keys[i + 2]; 730 cinergyt2->rc_input_event = rc_keys[i + 2];
@@ -736,11 +738,11 @@ static void cinergyt2_query_rc (void *data)
736 cinergyt2->rc_last_code != ~0) { 738 cinergyt2->rc_last_code != ~0) {
737 /* emit a key-up so the double event is recognized */ 739 /* emit a key-up so the double event is recognized */
738 dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); 740 dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event);
739 input_report_key(&cinergyt2->rc_input_dev, 741 input_report_key(cinergyt2->rc_input_dev,
740 cinergyt2->rc_input_event, 0); 742 cinergyt2->rc_input_event, 0);
741 } 743 }
742 dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); 744 dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event);
743 input_report_key(&cinergyt2->rc_input_dev, 745 input_report_key(cinergyt2->rc_input_dev,
744 cinergyt2->rc_input_event, 1); 746 cinergyt2->rc_input_event, 1);
745 cinergyt2->rc_last_code = rc_events[n].value; 747 cinergyt2->rc_last_code = rc_events[n].value;
746 } 748 }
@@ -752,7 +754,59 @@ out:
752 754
753 up(&cinergyt2->sem); 755 up(&cinergyt2->sem);
754} 756}
755#endif 757
758static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
759{
760 struct input_dev *input_dev;
761 int i;
762
763 cinergyt2->rc_input_dev = input_dev = input_allocate_device();
764 if (!input_dev)
765 return -ENOMEM;
766
767 usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys));
768 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
769 cinergyt2->rc_input_event = KEY_MAX;
770 cinergyt2->rc_last_code = ~0;
771 INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2);
772
773 input_dev->name = DRIVER_NAME " remote control";
774 input_dev->phys = cinergyt2->phys;
775 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
776 for (i = 0; ARRAY_SIZE(rc_keys); i += 3)
777 set_bit(rc_keys[i + 2], input_dev->keybit);
778 input_dev->keycodesize = 0;
779 input_dev->keycodemax = 0;
780
781 input_register_device(cinergyt2->rc_input_dev);
782 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
783}
784
785static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2)
786{
787 cancel_delayed_work(&cinergyt2->rc_query_work);
788 flush_scheduled_work();
789 input_unregister_device(cinergyt2->rc_input_dev);
790}
791
792static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2)
793{
794 cancel_delayed_work(&cinergyt2->rc_query_work);
795}
796
797static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2)
798{
799 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
800}
801
802#else
803
804static inline int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) { return 0; }
805static inline void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) { }
806static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2) { }
807static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
808
809#endif /* ENABLE_RC */
756 810
757static void cinergyt2_query (void *data) 811static void cinergyt2_query (void *data)
758{ 812{
@@ -789,9 +843,6 @@ static int cinergyt2_probe (struct usb_interface *intf,
789{ 843{
790 struct cinergyt2 *cinergyt2; 844 struct cinergyt2 *cinergyt2;
791 int err; 845 int err;
792#ifdef ENABLE_RC
793 int i;
794#endif
795 846
796 if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { 847 if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
797 dprintk(1, "out of memory?!?\n"); 848 dprintk(1, "out of memory?!?\n");
@@ -846,30 +897,17 @@ static int cinergyt2_probe (struct usb_interface *intf,
846 &cinergyt2_fe_template, cinergyt2, 897 &cinergyt2_fe_template, cinergyt2,
847 DVB_DEVICE_FRONTEND); 898 DVB_DEVICE_FRONTEND);
848 899
849#ifdef ENABLE_RC 900 err = cinergyt2_register_rc(cinergyt2);
850 cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 901 if (err)
851 cinergyt2->rc_input_dev.keycodesize = 0; 902 goto bailout;
852 cinergyt2->rc_input_dev.keycodemax = 0;
853 cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control";
854
855 for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3)
856 set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit);
857
858 input_register_device(&cinergyt2->rc_input_dev);
859
860 cinergyt2->rc_input_event = KEY_MAX;
861 cinergyt2->rc_last_code = ~0;
862 903
863 INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2);
864 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
865#endif
866 return 0; 904 return 0;
867 905
868bailout: 906bailout:
869 dvb_dmxdev_release(&cinergyt2->dmxdev); 907 dvb_dmxdev_release(&cinergyt2->dmxdev);
870 dvb_dmx_release(&cinergyt2->demux); 908 dvb_dmx_release(&cinergyt2->demux);
871 dvb_unregister_adapter (&cinergyt2->adapter); 909 dvb_unregister_adapter(&cinergyt2->adapter);
872 cinergyt2_free_stream_urbs (cinergyt2); 910 cinergyt2_free_stream_urbs(cinergyt2);
873 kfree(cinergyt2); 911 kfree(cinergyt2);
874 return -ENOMEM; 912 return -ENOMEM;
875} 913}
@@ -881,11 +919,7 @@ static void cinergyt2_disconnect (struct usb_interface *intf)
881 if (down_interruptible(&cinergyt2->sem)) 919 if (down_interruptible(&cinergyt2->sem))
882 return; 920 return;
883 921
884#ifdef ENABLE_RC 922 cinergyt2_unregister_rc(cinergyt2);
885 cancel_delayed_work(&cinergyt2->rc_query_work);
886 flush_scheduled_work();
887 input_unregister_device(&cinergyt2->rc_input_dev);
888#endif
889 923
890 cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx); 924 cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);
891 dvb_net_release(&cinergyt2->dvbnet); 925 dvb_net_release(&cinergyt2->dvbnet);
@@ -908,9 +942,8 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
908 942
909 if (state.event > PM_EVENT_ON) { 943 if (state.event > PM_EVENT_ON) {
910 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 944 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
911#ifdef ENABLE_RC 945
912 cancel_delayed_work(&cinergyt2->rc_query_work); 946 cinergyt2_suspend_rc(cinergyt2);
913#endif
914 cancel_delayed_work(&cinergyt2->query_work); 947 cancel_delayed_work(&cinergyt2->query_work);
915 if (cinergyt2->streaming) 948 if (cinergyt2->streaming)
916 cinergyt2_stop_stream_xfer(cinergyt2); 949 cinergyt2_stop_stream_xfer(cinergyt2);
@@ -938,9 +971,8 @@ static int cinergyt2_resume (struct usb_interface *intf)
938 schedule_delayed_work(&cinergyt2->query_work, HZ/2); 971 schedule_delayed_work(&cinergyt2->query_work, HZ/2);
939 } 972 }
940 973
941#ifdef ENABLE_RC 974 cinergyt2_resume_rc(cinergyt2);
942 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); 975
943#endif
944 up(&cinergyt2->sem); 976 up(&cinergyt2->sem);
945 return 0; 977 return 0;
946} 978}
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 4b7adca3e286..477b4fa56430 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -235,7 +235,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
235 S_IFCHR | S_IRUSR | S_IWUSR, 235 S_IFCHR | S_IRUSR | S_IWUSR,
236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id); 236 "dvb/adapter%d/%s%d", adap->num, dnames[type], id);
237 237
238 class_device_create(dvb_class, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 238 class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
239 NULL, "dvb%d.%s%d", adap->num, dnames[type], id); 239 NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
240 240
241 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", 241 dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index fc7800f1743e..e5c6d9835e06 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -39,9 +39,9 @@ static void dvb_usb_read_remote_control(void *data)
39 d->last_event = event; 39 d->last_event = event;
40 case REMOTE_KEY_REPEAT: 40 case REMOTE_KEY_REPEAT:
41 deb_rc("key repeated\n"); 41 deb_rc("key repeated\n");
42 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 1); 42 input_event(d->rc_input_dev, EV_KEY, event, 1);
43 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0); 43 input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
44 input_sync(&d->rc_input_dev); 44 input_sync(d->rc_input_dev);
45 break; 45 break;
46 default: 46 default:
47 break; 47 break;
@@ -53,8 +53,8 @@ static void dvb_usb_read_remote_control(void *data)
53 deb_rc("NO KEY PRESSED\n"); 53 deb_rc("NO KEY PRESSED\n");
54 if (d->last_state != REMOTE_NO_KEY_PRESSED) { 54 if (d->last_state != REMOTE_NO_KEY_PRESSED) {
55 deb_rc("releasing event %d\n",d->last_event); 55 deb_rc("releasing event %d\n",d->last_event);
56 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 0); 56 input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
57 input_sync(&d->rc_input_dev); 57 input_sync(d->rc_input_dev);
58 } 58 }
59 d->last_state = REMOTE_NO_KEY_PRESSED; 59 d->last_state = REMOTE_NO_KEY_PRESSED;
60 d->last_event = 0; 60 d->last_event = 0;
@@ -63,8 +63,8 @@ static void dvb_usb_read_remote_control(void *data)
63 deb_rc("KEY PRESSED\n"); 63 deb_rc("KEY PRESSED\n");
64 deb_rc("pressing event %d\n",event); 64 deb_rc("pressing event %d\n",event);
65 65
66 input_event(&d->rc_input_dev, EV_KEY, event, 1); 66 input_event(d->rc_input_dev, EV_KEY, event, 1);
67 input_sync(&d->rc_input_dev); 67 input_sync(d->rc_input_dev);
68 68
69 d->last_event = event; 69 d->last_event = event;
70 d->last_state = REMOTE_KEY_PRESSED; 70 d->last_state = REMOTE_KEY_PRESSED;
@@ -73,8 +73,8 @@ static void dvb_usb_read_remote_control(void *data)
73 deb_rc("KEY_REPEAT\n"); 73 deb_rc("KEY_REPEAT\n");
74 if (d->last_state != REMOTE_NO_KEY_PRESSED) { 74 if (d->last_state != REMOTE_NO_KEY_PRESSED) {
75 deb_rc("repeating event %d\n",d->last_event); 75 deb_rc("repeating event %d\n",d->last_event);
76 input_event(&d->rc_input_dev, EV_KEY, d->last_event, 2); 76 input_event(d->rc_input_dev, EV_KEY, d->last_event, 2);
77 input_sync(&d->rc_input_dev); 77 input_sync(d->rc_input_dev);
78 d->last_state = REMOTE_KEY_REPEAT; 78 d->last_state = REMOTE_KEY_REPEAT;
79 } 79 }
80 default: 80 default:
@@ -89,24 +89,30 @@ schedule:
89int dvb_usb_remote_init(struct dvb_usb_device *d) 89int dvb_usb_remote_init(struct dvb_usb_device *d)
90{ 90{
91 int i; 91 int i;
92
92 if (d->props.rc_key_map == NULL || 93 if (d->props.rc_key_map == NULL ||
93 d->props.rc_query == NULL || 94 d->props.rc_query == NULL ||
94 dvb_usb_disable_rc_polling) 95 dvb_usb_disable_rc_polling)
95 return 0; 96 return 0;
96 97
97 /* Initialise the remote-control structures.*/ 98 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
98 init_input_dev(&d->rc_input_dev); 99 strlcpy(d->rc_phys, "/ir0", sizeof(d->rc_phys));
100
101 d->rc_input_dev = input_allocate_device();
102 if (!d->rc_input_dev)
103 return -ENOMEM;
99 104
100 d->rc_input_dev.evbit[0] = BIT(EV_KEY); 105 d->rc_input_dev->evbit[0] = BIT(EV_KEY);
101 d->rc_input_dev.keycodesize = sizeof(unsigned char); 106 d->rc_input_dev->keycodesize = sizeof(unsigned char);
102 d->rc_input_dev.keycodemax = KEY_MAX; 107 d->rc_input_dev->keycodemax = KEY_MAX;
103 d->rc_input_dev.name = "IR-receiver inside an USB DVB receiver"; 108 d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver";
109 d->rc_input_dev->phys = d->rc_phys;
104 110
105 /* set the bits for the keys */ 111 /* set the bits for the keys */
106 deb_rc("key map size: %d\n",d->props.rc_key_map_size); 112 deb_rc("key map size: %d\n", d->props.rc_key_map_size);
107 for (i = 0; i < d->props.rc_key_map_size; i++) { 113 for (i = 0; i < d->props.rc_key_map_size; i++) {
108 deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i); 114 deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i);
109 set_bit(d->props.rc_key_map[i].event, d->rc_input_dev.keybit); 115 set_bit(d->props.rc_key_map[i].event, d->rc_input_dev->keybit);
110 } 116 }
111 117
112 /* Start the remote-control polling. */ 118 /* Start the remote-control polling. */
@@ -114,14 +120,14 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
114 d->props.rc_interval = 100; /* default */ 120 d->props.rc_interval = 100; /* default */
115 121
116 /* setting these two values to non-zero, we have to manage key repeats */ 122 /* setting these two values to non-zero, we have to manage key repeats */
117 d->rc_input_dev.rep[REP_PERIOD] = d->props.rc_interval; 123 d->rc_input_dev->rep[REP_PERIOD] = d->props.rc_interval;
118 d->rc_input_dev.rep[REP_DELAY] = d->props.rc_interval + 150; 124 d->rc_input_dev->rep[REP_DELAY] = d->props.rc_interval + 150;
119 125
120 input_register_device(&d->rc_input_dev); 126 input_register_device(d->rc_input_dev);
121 127
122 INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); 128 INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d);
123 129
124 info("schedule remote query interval to %d msecs.",d->props.rc_interval); 130 info("schedule remote query interval to %d msecs.", d->props.rc_interval);
125 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); 131 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
126 132
127 d->state |= DVB_USB_STATE_REMOTE; 133 d->state |= DVB_USB_STATE_REMOTE;
@@ -134,7 +140,7 @@ int dvb_usb_remote_exit(struct dvb_usb_device *d)
134 if (d->state & DVB_USB_STATE_REMOTE) { 140 if (d->state & DVB_USB_STATE_REMOTE) {
135 cancel_delayed_work(&d->rc_query_work); 141 cancel_delayed_work(&d->rc_query_work);
136 flush_scheduled_work(); 142 flush_scheduled_work();
137 input_unregister_device(&d->rc_input_dev); 143 input_unregister_device(d->rc_input_dev);
138 } 144 }
139 d->state &= ~DVB_USB_STATE_REMOTE; 145 d->state &= ~DVB_USB_STATE_REMOTE;
140 return 0; 146 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 0e4f1035b0dd..b4a1a98006c7 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -300,7 +300,8 @@ struct dvb_usb_device {
300 int (*fe_init) (struct dvb_frontend *); 300 int (*fe_init) (struct dvb_frontend *);
301 301
302 /* remote control */ 302 /* remote control */
303 struct input_dev rc_input_dev; 303 struct input_dev *rc_input_dev;
304 char rc_phys[64];
304 struct work_struct rc_query_work; 305 struct work_struct rc_query_work;
305 u32 last_event; 306 u32 last_event;
306 int last_state; 307 int last_state;
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 357a3728ec68..f5e59fc924af 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -15,7 +15,7 @@
15 15
16static int av_cnt; 16static int av_cnt;
17static struct av7110 *av_list[4]; 17static struct av7110 *av_list[4];
18static struct input_dev input_dev; 18static struct input_dev *input_dev;
19 19
20static u16 key_map [256] = { 20static u16 key_map [256] = {
21 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, 21 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7,
@@ -43,10 +43,10 @@ static u16 key_map [256] = {
43 43
44static void av7110_emit_keyup(unsigned long data) 44static void av7110_emit_keyup(unsigned long data)
45{ 45{
46 if (!data || !test_bit(data, input_dev.key)) 46 if (!data || !test_bit(data, input_dev->key))
47 return; 47 return;
48 48
49 input_event(&input_dev, EV_KEY, data, !!0); 49 input_event(input_dev, EV_KEY, data, !!0);
50} 50}
51 51
52 52
@@ -112,13 +112,13 @@ static void av7110_emit_key(unsigned long parm)
112 if (timer_pending(&keyup_timer)) { 112 if (timer_pending(&keyup_timer)) {
113 del_timer(&keyup_timer); 113 del_timer(&keyup_timer);
114 if (keyup_timer.data != keycode || new_toggle != old_toggle) { 114 if (keyup_timer.data != keycode || new_toggle != old_toggle) {
115 input_event(&input_dev, EV_KEY, keyup_timer.data, !!0); 115 input_event(input_dev, EV_KEY, keyup_timer.data, !!0);
116 input_event(&input_dev, EV_KEY, keycode, !0); 116 input_event(input_dev, EV_KEY, keycode, !0);
117 } else 117 } else
118 input_event(&input_dev, EV_KEY, keycode, 2); 118 input_event(input_dev, EV_KEY, keycode, 2);
119 119
120 } else 120 } else
121 input_event(&input_dev, EV_KEY, keycode, !0); 121 input_event(input_dev, EV_KEY, keycode, !0);
122 122
123 keyup_timer.expires = jiffies + UP_TIMEOUT; 123 keyup_timer.expires = jiffies + UP_TIMEOUT;
124 keyup_timer.data = keycode; 124 keyup_timer.data = keycode;
@@ -132,13 +132,13 @@ static void input_register_keys(void)
132{ 132{
133 int i; 133 int i;
134 134
135 memset(input_dev.keybit, 0, sizeof(input_dev.keybit)); 135 memset(input_dev->keybit, 0, sizeof(input_dev->keybit));
136 136
137 for (i = 0; i < sizeof(key_map) / sizeof(key_map[0]); i++) { 137 for (i = 0; i < ARRAY_SIZE(key_map); i++) {
138 if (key_map[i] > KEY_MAX) 138 if (key_map[i] > KEY_MAX)
139 key_map[i] = 0; 139 key_map[i] = 0;
140 else if (key_map[i] > KEY_RESERVED) 140 else if (key_map[i] > KEY_RESERVED)
141 set_bit(key_map[i], input_dev.keybit); 141 set_bit(key_map[i], input_dev->keybit);
142 } 142 }
143} 143}
144 144
@@ -216,12 +216,17 @@ int __init av7110_ir_init(struct av7110 *av7110)
216 init_timer(&keyup_timer); 216 init_timer(&keyup_timer);
217 keyup_timer.data = 0; 217 keyup_timer.data = 0;
218 218
219 input_dev.name = "DVB on-card IR receiver"; 219 input_dev = input_allocate_device();
220 set_bit(EV_KEY, input_dev.evbit); 220 if (!input_dev)
221 set_bit(EV_REP, input_dev.evbit); 221 return -ENOMEM;
222
223 input_dev->name = "DVB on-card IR receiver";
224
225 set_bit(EV_KEY, input_dev->evbit);
226 set_bit(EV_REP, input_dev->evbit);
222 input_register_keys(); 227 input_register_keys();
223 input_register_device(&input_dev); 228 input_register_device(input_dev);
224 input_dev.timer.function = input_repeat_key; 229 input_dev->timer.function = input_repeat_key;
225 230
226 e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); 231 e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL);
227 if (e) { 232 if (e) {
@@ -256,7 +261,7 @@ void __exit av7110_ir_exit(struct av7110 *av7110)
256 if (av_cnt == 1) { 261 if (av_cnt == 1) {
257 del_timer_sync(&keyup_timer); 262 del_timer_sync(&keyup_timer);
258 remove_proc_entry("av7110_ir", NULL); 263 remove_proc_entry("av7110_ir", NULL);
259 input_unregister_device(&input_dev); 264 input_unregister_device(input_dev);
260 } 265 }
261 266
262 av_cnt--; 267 av_cnt--;
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 2980db3ef22f..51c30ba68140 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -64,7 +64,7 @@
64 64
65struct budget_ci { 65struct budget_ci {
66 struct budget budget; 66 struct budget budget;
67 struct input_dev input_dev; 67 struct input_dev *input_dev;
68 struct tasklet_struct msp430_irq_tasklet; 68 struct tasklet_struct msp430_irq_tasklet;
69 struct tasklet_struct ciintf_irq_tasklet; 69 struct tasklet_struct ciintf_irq_tasklet;
70 int slot_status; 70 int slot_status;
@@ -145,7 +145,7 @@ static void msp430_ir_debounce(unsigned long data)
145static void msp430_ir_interrupt(unsigned long data) 145static void msp430_ir_interrupt(unsigned long data)
146{ 146{
147 struct budget_ci *budget_ci = (struct budget_ci *) data; 147 struct budget_ci *budget_ci = (struct budget_ci *) data;
148 struct input_dev *dev = &budget_ci->input_dev; 148 struct input_dev *dev = budget_ci->input_dev;
149 unsigned int code = 149 unsigned int code =
150 ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; 150 ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
151 151
@@ -181,25 +181,27 @@ static void msp430_ir_interrupt(unsigned long data)
181static int msp430_ir_init(struct budget_ci *budget_ci) 181static int msp430_ir_init(struct budget_ci *budget_ci)
182{ 182{
183 struct saa7146_dev *saa = budget_ci->budget.dev; 183 struct saa7146_dev *saa = budget_ci->budget.dev;
184 struct input_dev *input_dev;
184 int i; 185 int i;
185 186
186 memset(&budget_ci->input_dev, 0, sizeof(struct input_dev)); 187 budget_ci->input_dev = input_dev = input_allocate_device();
188 if (!input_dev)
189 return -ENOMEM;
187 190
188 sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name); 191 sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name);
189 budget_ci->input_dev.name = budget_ci->ir_dev_name;
190 192
191 set_bit(EV_KEY, budget_ci->input_dev.evbit); 193 input_dev->name = budget_ci->ir_dev_name;
192 194
193 for (i = 0; i < sizeof(key_map) / sizeof(*key_map); i++) 195 set_bit(EV_KEY, input_dev->evbit);
196 for (i = 0; i < ARRAY_SIZE(key_map); i++)
194 if (key_map[i]) 197 if (key_map[i])
195 set_bit(key_map[i], budget_ci->input_dev.keybit); 198 set_bit(key_map[i], input_dev->keybit);
196 199
197 input_register_device(&budget_ci->input_dev); 200 input_register_device(budget_ci->input_dev);
198 201
199 budget_ci->input_dev.timer.function = msp430_ir_debounce; 202 input_dev->timer.function = msp430_ir_debounce;
200 203
201 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06); 204 saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06);
202
203 saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); 205 saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI);
204 206
205 return 0; 207 return 0;
@@ -208,7 +210,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
208static void msp430_ir_deinit(struct budget_ci *budget_ci) 210static void msp430_ir_deinit(struct budget_ci *budget_ci)
209{ 211{
210 struct saa7146_dev *saa = budget_ci->budget.dev; 212 struct saa7146_dev *saa = budget_ci->budget.dev;
211 struct input_dev *dev = &budget_ci->input_dev; 213 struct input_dev *dev = budget_ci->input_dev;
212 214
213 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06); 215 saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06);
214 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT); 216 saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 3d08fc83a754..832d179f26fa 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -152,7 +152,8 @@ struct ttusb_dec {
152 struct list_head filter_info_list; 152 struct list_head filter_info_list;
153 spinlock_t filter_info_list_lock; 153 spinlock_t filter_info_list_lock;
154 154
155 struct input_dev rc_input_dev; 155 struct input_dev *rc_input_dev;
156 char rc_phys[64];
156 157
157 int active; /* Loaded successfully */ 158 int active; /* Loaded successfully */
158}; 159};
@@ -235,9 +236,9 @@ static void ttusb_dec_handle_irq( struct urb *urb, struct pt_regs *regs)
235 * this should/could be added later ... 236 * this should/could be added later ...
236 * for now lets report each signal as a key down and up*/ 237 * for now lets report each signal as a key down and up*/
237 dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); 238 dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]);
238 input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],1); 239 input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1);
239 input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],0); 240 input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0);
240 input_sync(&dec->rc_input_dev); 241 input_sync(dec->rc_input_dev);
241 } 242 }
242 243
243exit: retval = usb_submit_urb(urb, GFP_ATOMIC); 244exit: retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -1181,29 +1182,38 @@ static void ttusb_dec_init_tasklet(struct ttusb_dec *dec)
1181 (unsigned long)dec); 1182 (unsigned long)dec);
1182} 1183}
1183 1184
1184static void ttusb_init_rc( struct ttusb_dec *dec) 1185static int ttusb_init_rc(struct ttusb_dec *dec)
1185{ 1186{
1187 struct input_dev *input_dev;
1186 u8 b[] = { 0x00, 0x01 }; 1188 u8 b[] = { 0x00, 0x01 };
1187 int i; 1189 int i;
1188 1190
1189 init_input_dev(&dec->rc_input_dev); 1191 usb_make_path(dec->udev, dec->rc_phys, sizeof(dec->rc_phys));
1192 strlcpy(dec->rc_phys, "/input0", sizeof(dec->rc_phys));
1190 1193
1191 dec->rc_input_dev.name = "ttusb_dec remote control"; 1194 dec->rc_input_dev = input_dev = input_allocate_device();
1192 dec->rc_input_dev.evbit[0] = BIT(EV_KEY); 1195 if (!input_dev)
1193 dec->rc_input_dev.keycodesize = sizeof(u16); 1196 return -ENOMEM;
1194 dec->rc_input_dev.keycodemax = 0x1a; 1197
1195 dec->rc_input_dev.keycode = rc_keys; 1198 input_dev->name = "ttusb_dec remote control";
1199 input_dev->phys = dec->rc_phys;
1200 input_dev->evbit[0] = BIT(EV_KEY);
1201 input_dev->keycodesize = sizeof(u16);
1202 input_dev->keycodemax = 0x1a;
1203 input_dev->keycode = rc_keys;
1196 1204
1197 for (i = 0; i < sizeof(rc_keys)/sizeof(rc_keys[0]); i++) 1205 for (i = 0; i < ARRAY_SIZE(rc_keys); i++)
1198 set_bit(rc_keys[i], dec->rc_input_dev.keybit); 1206 set_bit(rc_keys[i], input_dev->keybit);
1199 1207
1200 input_register_device(&dec->rc_input_dev); 1208 input_register_device(input_dev);
1201 1209
1202 if(usb_submit_urb(dec->irq_urb,GFP_KERNEL)) { 1210 if (usb_submit_urb(dec->irq_urb, GFP_KERNEL))
1203 printk("%s: usb_submit_urb failed\n",__FUNCTION__); 1211 printk("%s: usb_submit_urb failed\n",__FUNCTION__);
1204 } 1212
1205 /* enable irq pipe */ 1213 /* enable irq pipe */
1206 ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); 1214 ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL);
1215
1216 return 0;
1207} 1217}
1208 1218
1209static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) 1219static void ttusb_dec_init_v_pes(struct ttusb_dec *dec)
@@ -1513,7 +1523,7 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
1513 * As the irq is submitted after the interface is changed, 1523 * As the irq is submitted after the interface is changed,
1514 * this is the best method i figured out. 1524 * this is the best method i figured out.
1515 * Any others?*/ 1525 * Any others?*/
1516 if(dec->interface == TTUSB_DEC_INTERFACE_IN) 1526 if (dec->interface == TTUSB_DEC_INTERFACE_IN)
1517 usb_kill_urb(dec->irq_urb); 1527 usb_kill_urb(dec->irq_urb);
1518 1528
1519 usb_free_urb(dec->irq_urb); 1529 usb_free_urb(dec->irq_urb);
@@ -1521,7 +1531,10 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
1521 usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, 1531 usb_buffer_free(dec->udev,IRQ_PACKET_SIZE,
1522 dec->irq_buffer, dec->irq_dma_handle); 1532 dec->irq_buffer, dec->irq_dma_handle);
1523 1533
1524 input_unregister_device(&dec->rc_input_dev); 1534 if (dec->rc_input_dev) {
1535 input_unregister_device(dec->rc_input_dev);
1536 dec->rc_input_dev = NULL;
1537 }
1525} 1538}
1526 1539
1527 1540
@@ -1659,7 +1672,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1659 1672
1660 ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); 1673 ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN);
1661 1674
1662 if(enable_rc) 1675 if (enable_rc)
1663 ttusb_init_rc(dec); 1676 ttusb_init_rc(dec);
1664 1677
1665 return 0; 1678 return 0;
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index 7a312f79340a..e0e7c7a84bc5 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bttvp.h
@@ -240,7 +240,7 @@ struct bttv_pll_info {
240 240
241/* for gpio-connected remote control */ 241/* for gpio-connected remote control */
242struct bttv_input { 242struct bttv_input {
243 struct input_dev dev; 243 struct input_dev *dev;
244 struct ir_input_state ir; 244 struct ir_input_state ir;
245 char name[32]; 245 char name[32];
246 char phys[32]; 246 char phys[32];
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index d81b21d6e05d..c27fe4c36f69 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -260,7 +260,7 @@ static IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = {
260 260
261struct cx88_IR { 261struct cx88_IR {
262 struct cx88_core *core; 262 struct cx88_core *core;
263 struct input_dev input; 263 struct input_dev *input;
264 struct ir_input_state ir; 264 struct ir_input_state ir;
265 char name[32]; 265 char name[32];
266 char phys[32]; 266 char phys[32];
@@ -315,23 +315,23 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
315 if (ir->mask_keydown) { 315 if (ir->mask_keydown) {
316 /* bit set on keydown */ 316 /* bit set on keydown */
317 if (gpio & ir->mask_keydown) { 317 if (gpio & ir->mask_keydown) {
318 ir_input_keydown(&ir->input, &ir->ir, data, data); 318 ir_input_keydown(ir->input, &ir->ir, data, data);
319 } else { 319 } else {
320 ir_input_nokey(&ir->input, &ir->ir); 320 ir_input_nokey(ir->input, &ir->ir);
321 } 321 }
322 322
323 } else if (ir->mask_keyup) { 323 } else if (ir->mask_keyup) {
324 /* bit cleared on keydown */ 324 /* bit cleared on keydown */
325 if (0 == (gpio & ir->mask_keyup)) { 325 if (0 == (gpio & ir->mask_keyup)) {
326 ir_input_keydown(&ir->input, &ir->ir, data, data); 326 ir_input_keydown(ir->input, &ir->ir, data, data);
327 } else { 327 } else {
328 ir_input_nokey(&ir->input, &ir->ir); 328 ir_input_nokey(ir->input, &ir->ir);
329 } 329 }
330 330
331 } else { 331 } else {
332 /* can't distinguish keydown/up :-/ */ 332 /* can't distinguish keydown/up :-/ */
333 ir_input_keydown(&ir->input, &ir->ir, data, data); 333 ir_input_keydown(ir->input, &ir->ir, data, data);
334 ir_input_nokey(&ir->input, &ir->ir); 334 ir_input_nokey(ir->input, &ir->ir);
335 } 335 }
336} 336}
337 337
@@ -357,13 +357,19 @@ static void cx88_ir_work(void *data)
357int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) 357int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
358{ 358{
359 struct cx88_IR *ir; 359 struct cx88_IR *ir;
360 struct input_dev *input_dev;
360 IR_KEYTAB_TYPE *ir_codes = NULL; 361 IR_KEYTAB_TYPE *ir_codes = NULL;
361 int ir_type = IR_TYPE_OTHER; 362 int ir_type = IR_TYPE_OTHER;
362 363
363 ir = kmalloc(sizeof(*ir), GFP_KERNEL); 364 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
364 if (NULL == ir) 365 input_dev = input_allocate_device();
366 if (!ir || !input_dev) {
367 kfree(ir);
368 input_free_device(input_dev);
365 return -ENOMEM; 369 return -ENOMEM;
366 memset(ir, 0, sizeof(*ir)); 370 }
371
372 ir->input = input_dev;
367 373
368 /* detect & configure */ 374 /* detect & configure */
369 switch (core->board) { 375 switch (core->board) {
@@ -425,6 +431,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
425 431
426 if (NULL == ir_codes) { 432 if (NULL == ir_codes) {
427 kfree(ir); 433 kfree(ir);
434 input_free_device(input_dev);
428 return -ENODEV; 435 return -ENODEV;
429 } 436 }
430 437
@@ -433,19 +440,19 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
433 cx88_boards[core->board].name); 440 cx88_boards[core->board].name);
434 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 441 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
435 442
436 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 443 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
437 ir->input.name = ir->name; 444 input_dev->name = ir->name;
438 ir->input.phys = ir->phys; 445 input_dev->phys = ir->phys;
439 ir->input.id.bustype = BUS_PCI; 446 input_dev->id.bustype = BUS_PCI;
440 ir->input.id.version = 1; 447 input_dev->id.version = 1;
441 if (pci->subsystem_vendor) { 448 if (pci->subsystem_vendor) {
442 ir->input.id.vendor = pci->subsystem_vendor; 449 input_dev->id.vendor = pci->subsystem_vendor;
443 ir->input.id.product = pci->subsystem_device; 450 input_dev->id.product = pci->subsystem_device;
444 } else { 451 } else {
445 ir->input.id.vendor = pci->vendor; 452 input_dev->id.vendor = pci->vendor;
446 ir->input.id.product = pci->device; 453 input_dev->id.product = pci->device;
447 } 454 }
448 ir->input.dev = &pci->dev; 455 input_dev->cdev.dev = &pci->dev;
449 456
450 /* record handles to ourself */ 457 /* record handles to ourself */
451 ir->core = core; 458 ir->core = core;
@@ -465,8 +472,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
465 } 472 }
466 473
467 /* all done */ 474 /* all done */
468 input_register_device(&ir->input); 475 input_register_device(ir->input);
469 printk("%s: registered IR remote control\n", core->name);
470 476
471 return 0; 477 return 0;
472} 478}
@@ -484,7 +490,7 @@ int cx88_ir_fini(struct cx88_core *core)
484 flush_scheduled_work(); 490 flush_scheduled_work();
485 } 491 }
486 492
487 input_unregister_device(&ir->input); 493 input_unregister_device(ir->input);
488 kfree(ir); 494 kfree(ir);
489 495
490 /* done */ 496 /* done */
@@ -515,7 +521,7 @@ void cx88_ir_irq(struct cx88_core *core)
515 if (!ir->scount) { 521 if (!ir->scount) {
516 /* nothing to sample */ 522 /* nothing to sample */
517 if (ir->ir.keypressed && time_after(jiffies, ir->release)) 523 if (ir->ir.keypressed && time_after(jiffies, ir->release))
518 ir_input_nokey(&ir->input, &ir->ir); 524 ir_input_nokey(ir->input, &ir->ir);
519 return; 525 return;
520 } 526 }
521 527
@@ -557,7 +563,7 @@ void cx88_ir_irq(struct cx88_core *core)
557 563
558 ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f); 564 ir_dprintk("Key Code: %x\n", (ircode >> 16) & 0x7f);
559 565
560 ir_input_keydown(&ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff); 566 ir_input_keydown(ir->input, &ir->ir, (ircode >> 16) & 0x7f, (ircode >> 16) & 0xff);
561 ir->release = jiffies + msecs_to_jiffies(120); 567 ir->release = jiffies + msecs_to_jiffies(120);
562 break; 568 break;
563 case CX88_BOARD_HAUPPAUGE: 569 case CX88_BOARD_HAUPPAUGE:
@@ -566,7 +572,7 @@ void cx88_ir_irq(struct cx88_core *core)
566 ir_dprintk("biphase decoded: %x\n", ircode); 572 ir_dprintk("biphase decoded: %x\n", ircode);
567 if ((ircode & 0xfffff000) != 0x3000) 573 if ((ircode & 0xfffff000) != 0x3000)
568 break; 574 break;
569 ir_input_keydown(&ir->input, &ir->ir, ircode & 0x3f, ircode); 575 ir_input_keydown(ir->input, &ir->ir, ircode & 0x3f, ircode);
570 ir->release = jiffies + msecs_to_jiffies(120); 576 ir->release = jiffies + msecs_to_jiffies(120);
571 break; 577 break;
572 } 578 }
diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c
index cf292da8fdd5..234151e48edc 100644
--- a/drivers/media/video/ir-kbd-gpio.c
+++ b/drivers/media/video/ir-kbd-gpio.c
@@ -158,7 +158,7 @@ static IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = {
158 158
159struct IR { 159struct IR {
160 struct bttv_sub_device *sub; 160 struct bttv_sub_device *sub;
161 struct input_dev input; 161 struct input_dev *input;
162 struct ir_input_state ir; 162 struct ir_input_state ir;
163 char name[32]; 163 char name[32];
164 char phys[32]; 164 char phys[32];
@@ -217,23 +217,23 @@ static void ir_handle_key(struct IR *ir)
217 if (ir->mask_keydown) { 217 if (ir->mask_keydown) {
218 /* bit set on keydown */ 218 /* bit set on keydown */
219 if (gpio & ir->mask_keydown) { 219 if (gpio & ir->mask_keydown) {
220 ir_input_keydown(&ir->input,&ir->ir,data,data); 220 ir_input_keydown(ir->input, &ir->ir, data, data);
221 } else { 221 } else {
222 ir_input_nokey(&ir->input,&ir->ir); 222 ir_input_nokey(ir->input, &ir->ir);
223 } 223 }
224 224
225 } else if (ir->mask_keyup) { 225 } else if (ir->mask_keyup) {
226 /* bit cleared on keydown */ 226 /* bit cleared on keydown */
227 if (0 == (gpio & ir->mask_keyup)) { 227 if (0 == (gpio & ir->mask_keyup)) {
228 ir_input_keydown(&ir->input,&ir->ir,data,data); 228 ir_input_keydown(ir->input, &ir->ir, data, data);
229 } else { 229 } else {
230 ir_input_nokey(&ir->input,&ir->ir); 230 ir_input_nokey(ir->input, &ir->ir);
231 } 231 }
232 232
233 } else { 233 } else {
234 /* can't disturgissh keydown/up :-/ */ 234 /* can't disturgissh keydown/up :-/ */
235 ir_input_keydown(&ir->input,&ir->ir,data,data); 235 ir_input_keydown(ir->input, &ir->ir, data, data);
236 ir_input_nokey(&ir->input,&ir->ir); 236 ir_input_nokey(ir->input, &ir->ir);
237 } 237 }
238} 238}
239 239
@@ -268,13 +268,17 @@ static int ir_probe(struct device *dev)
268{ 268{
269 struct bttv_sub_device *sub = to_bttv_sub_dev(dev); 269 struct bttv_sub_device *sub = to_bttv_sub_dev(dev);
270 struct IR *ir; 270 struct IR *ir;
271 struct input_dev *input_dev;
271 IR_KEYTAB_TYPE *ir_codes = NULL; 272 IR_KEYTAB_TYPE *ir_codes = NULL;
272 int ir_type = IR_TYPE_OTHER; 273 int ir_type = IR_TYPE_OTHER;
273 274
274 ir = kmalloc(sizeof(*ir),GFP_KERNEL); 275 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
275 if (NULL == ir) 276 input_dev = input_allocate_device();
277 if (!ir || !input_dev) {
278 kfree(ir);
279 input_free_device(input_dev);
276 return -ENOMEM; 280 return -ENOMEM;
277 memset(ir,0,sizeof(*ir)); 281 }
278 282
279 /* detect & configure */ 283 /* detect & configure */
280 switch (sub->core->type) { 284 switch (sub->core->type) {
@@ -328,6 +332,7 @@ static int ir_probe(struct device *dev)
328 } 332 }
329 if (NULL == ir_codes) { 333 if (NULL == ir_codes) {
330 kfree(ir); 334 kfree(ir);
335 input_free_device(input_dev);
331 return -ENODEV; 336 return -ENODEV;
332 } 337 }
333 338
@@ -341,19 +346,19 @@ static int ir_probe(struct device *dev)
341 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 346 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
342 pci_name(sub->core->pci)); 347 pci_name(sub->core->pci));
343 348
344 ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes); 349 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
345 ir->input.name = ir->name; 350 input_dev->name = ir->name;
346 ir->input.phys = ir->phys; 351 input_dev->phys = ir->phys;
347 ir->input.id.bustype = BUS_PCI; 352 input_dev->id.bustype = BUS_PCI;
348 ir->input.id.version = 1; 353 input_dev->id.version = 1;
349 if (sub->core->pci->subsystem_vendor) { 354 if (sub->core->pci->subsystem_vendor) {
350 ir->input.id.vendor = sub->core->pci->subsystem_vendor; 355 input_dev->id.vendor = sub->core->pci->subsystem_vendor;
351 ir->input.id.product = sub->core->pci->subsystem_device; 356 input_dev->id.product = sub->core->pci->subsystem_device;
352 } else { 357 } else {
353 ir->input.id.vendor = sub->core->pci->vendor; 358 input_dev->id.vendor = sub->core->pci->vendor;
354 ir->input.id.product = sub->core->pci->device; 359 input_dev->id.product = sub->core->pci->device;
355 } 360 }
356 ir->input.dev = &sub->core->pci->dev; 361 input_dev->cdev.dev = &sub->core->pci->dev;
357 362
358 if (ir->polling) { 363 if (ir->polling) {
359 INIT_WORK(&ir->work, ir_work, ir); 364 INIT_WORK(&ir->work, ir_work, ir);
@@ -364,9 +369,8 @@ static int ir_probe(struct device *dev)
364 } 369 }
365 370
366 /* all done */ 371 /* all done */
367 dev_set_drvdata(dev,ir); 372 dev_set_drvdata(dev, ir);
368 input_register_device(&ir->input); 373 input_register_device(ir->input);
369 printk(DEVNAME ": %s detected at %s\n",ir->input.name,ir->input.phys);
370 374
371 return 0; 375 return 0;
372} 376}
@@ -380,7 +384,7 @@ static int ir_remove(struct device *dev)
380 flush_scheduled_work(); 384 flush_scheduled_work();
381 } 385 }
382 386
383 input_unregister_device(&ir->input); 387 input_unregister_device(ir->input);
384 kfree(ir); 388 kfree(ir);
385 return 0; 389 return 0;
386} 390}
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 67105b9804a2..9703d3d351f9 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -121,10 +121,9 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
121 121
122}; 122};
123 123
124struct IR;
125struct IR { 124struct IR {
126 struct i2c_client c; 125 struct i2c_client c;
127 struct input_dev input; 126 struct input_dev *input;
128 struct ir_input_state ir; 127 struct ir_input_state ir;
129 128
130 struct work_struct work; 129 struct work_struct work;
@@ -271,9 +270,9 @@ static void ir_key_poll(struct IR *ir)
271 } 270 }
272 271
273 if (0 == rc) { 272 if (0 == rc) {
274 ir_input_nokey(&ir->input,&ir->ir); 273 ir_input_nokey(ir->input, &ir->ir);
275 } else { 274 } else {
276 ir_input_keydown(&ir->input,&ir->ir, ir_key, ir_raw); 275 ir_input_keydown(ir->input, &ir->ir, ir_key, ir_raw);
277 } 276 }
278} 277}
279 278
@@ -318,11 +317,18 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
318 char *name; 317 char *name;
319 int ir_type; 318 int ir_type;
320 struct IR *ir; 319 struct IR *ir;
320 struct input_dev *input_dev;
321 321
322 if (NULL == (ir = kmalloc(sizeof(struct IR),GFP_KERNEL))) 322 ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
323 input_dev = input_allocate_device();
324 if (!ir || !input_dev) {
325 kfree(ir);
326 input_free_device(input_dev);
323 return -ENOMEM; 327 return -ENOMEM;
324 memset(ir,0,sizeof(*ir)); 328 }
329
325 ir->c = client_template; 330 ir->c = client_template;
331 ir->input = input_dev;
326 332
327 i2c_set_clientdata(&ir->c, ir); 333 i2c_set_clientdata(&ir->c, ir);
328 ir->c.adapter = adap; 334 ir->c.adapter = adap;
@@ -375,13 +381,12 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
375 ir->c.dev.bus_id); 381 ir->c.dev.bus_id);
376 382
377 /* init + register input device */ 383 /* init + register input device */
378 ir_input_init(&ir->input,&ir->ir,ir_type,ir_codes); 384 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
379 ir->input.id.bustype = BUS_I2C; 385 input_dev->id.bustype = BUS_I2C;
380 ir->input.name = ir->c.name; 386 input_dev->name = ir->c.name;
381 ir->input.phys = ir->phys; 387 input_dev->phys = ir->phys;
382 input_register_device(&ir->input); 388
383 printk(DEVNAME ": %s detected at %s [%s]\n", 389 input_register_device(ir->input);
384 ir->input.name,ir->input.phys,adap->name);
385 390
386 /* start polling via eventd */ 391 /* start polling via eventd */
387 INIT_WORK(&ir->work, ir_work, ir); 392 INIT_WORK(&ir->work, ir_work, ir);
@@ -402,7 +407,7 @@ static int ir_detach(struct i2c_client *client)
402 flush_scheduled_work(); 407 flush_scheduled_work();
403 408
404 /* unregister devices */ 409 /* unregister devices */
405 input_unregister_device(&ir->input); 410 input_unregister_device(ir->input);
406 i2c_detach_client(&ir->c); 411 i2c_detach_client(&ir->c);
407 412
408 /* free memory */ 413 /* free memory */
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index f0d43fc2632f..262890cb20a7 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -1420,8 +1420,8 @@ static int msp_detach(struct i2c_client *client);
1420static int msp_probe(struct i2c_adapter *adap); 1420static int msp_probe(struct i2c_adapter *adap);
1421static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); 1421static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
1422 1422
1423static int msp_suspend(struct device * dev, pm_message_t state, u32 level); 1423static int msp_suspend(struct device * dev, pm_message_t state);
1424static int msp_resume(struct device * dev, u32 level); 1424static int msp_resume(struct device * dev);
1425 1425
1426static void msp_wake_thread(struct i2c_client *client); 1426static void msp_wake_thread(struct i2c_client *client);
1427 1427
@@ -1821,7 +1821,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
1821 return 0; 1821 return 0;
1822} 1822}
1823 1823
1824static int msp_suspend(struct device * dev, pm_message_t state, u32 level) 1824static int msp_suspend(struct device * dev, pm_message_t state)
1825{ 1825{
1826 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 1826 struct i2c_client *c = container_of(dev, struct i2c_client, dev);
1827 1827
@@ -1830,7 +1830,7 @@ static int msp_suspend(struct device * dev, pm_message_t state, u32 level)
1830 return 0; 1830 return 0;
1831} 1831}
1832 1832
1833static int msp_resume(struct device * dev, u32 level) 1833static int msp_resume(struct device * dev)
1834{ 1834{
1835 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 1835 struct i2c_client *c = container_of(dev, struct i2c_client, dev);
1836 1836
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 1f456c4d76f2..242cb235cf92 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -425,9 +425,9 @@ static int build_key(struct saa7134_dev *dev)
425 425
426 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 426 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
427 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 427 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
428 ir_input_keydown(&ir->dev,&ir->ir,data,data); 428 ir_input_keydown(ir->dev, &ir->ir, data, data);
429 } else { 429 } else {
430 ir_input_nokey(&ir->dev,&ir->ir); 430 ir_input_nokey(ir->dev, &ir->ir);
431 } 431 }
432 return 0; 432 return 0;
433} 433}
@@ -456,6 +456,7 @@ static void saa7134_input_timer(unsigned long data)
456int saa7134_input_init1(struct saa7134_dev *dev) 456int saa7134_input_init1(struct saa7134_dev *dev)
457{ 457{
458 struct saa7134_ir *ir; 458 struct saa7134_ir *ir;
459 struct input_dev *input_dev;
459 IR_KEYTAB_TYPE *ir_codes = NULL; 460 IR_KEYTAB_TYPE *ir_codes = NULL;
460 u32 mask_keycode = 0; 461 u32 mask_keycode = 0;
461 u32 mask_keydown = 0; 462 u32 mask_keydown = 0;
@@ -535,10 +536,13 @@ int saa7134_input_init1(struct saa7134_dev *dev)
535 return -ENODEV; 536 return -ENODEV;
536 } 537 }
537 538
538 ir = kmalloc(sizeof(*ir),GFP_KERNEL); 539 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
539 if (NULL == ir) 540 input_dev = input_allocate_device();
541 if (!ir || !input_dev) {
542 kfree(ir);
543 input_free_device(input_dev);
540 return -ENOMEM; 544 return -ENOMEM;
541 memset(ir,0,sizeof(*ir)); 545 }
542 546
543 /* init hardware-specific stuff */ 547 /* init hardware-specific stuff */
544 ir->mask_keycode = mask_keycode; 548 ir->mask_keycode = mask_keycode;
@@ -552,19 +556,19 @@ int saa7134_input_init1(struct saa7134_dev *dev)
552 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 556 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
553 pci_name(dev->pci)); 557 pci_name(dev->pci));
554 558
555 ir_input_init(&ir->dev, &ir->ir, ir_type, ir_codes); 559 ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
556 ir->dev.name = ir->name; 560 input_dev->name = ir->name;
557 ir->dev.phys = ir->phys; 561 input_dev->phys = ir->phys;
558 ir->dev.id.bustype = BUS_PCI; 562 input_dev->id.bustype = BUS_PCI;
559 ir->dev.id.version = 1; 563 input_dev->id.version = 1;
560 if (dev->pci->subsystem_vendor) { 564 if (dev->pci->subsystem_vendor) {
561 ir->dev.id.vendor = dev->pci->subsystem_vendor; 565 input_dev->id.vendor = dev->pci->subsystem_vendor;
562 ir->dev.id.product = dev->pci->subsystem_device; 566 input_dev->id.product = dev->pci->subsystem_device;
563 } else { 567 } else {
564 ir->dev.id.vendor = dev->pci->vendor; 568 input_dev->id.vendor = dev->pci->vendor;
565 ir->dev.id.product = dev->pci->device; 569 input_dev->id.product = dev->pci->device;
566 } 570 }
567 ir->dev.dev = &dev->pci->dev; 571 input_dev->cdev.dev = &dev->pci->dev;
568 572
569 /* all done */ 573 /* all done */
570 dev->remote = ir; 574 dev->remote = ir;
@@ -576,8 +580,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
576 add_timer(&ir->timer); 580 add_timer(&ir->timer);
577 } 581 }
578 582
579 input_register_device(&dev->remote->dev); 583 input_register_device(ir->dev);
580 printk("%s: registered input device for IR\n",dev->name);
581 return 0; 584 return 0;
582} 585}
583 586
@@ -586,9 +589,9 @@ void saa7134_input_fini(struct saa7134_dev *dev)
586 if (NULL == dev->remote) 589 if (NULL == dev->remote)
587 return; 590 return;
588 591
589 input_unregister_device(&dev->remote->dev);
590 if (dev->remote->polling) 592 if (dev->remote->polling)
591 del_timer_sync(&dev->remote->timer); 593 del_timer_sync(&dev->remote->timer);
594 input_unregister_device(dev->remote->dev);
592 kfree(dev->remote); 595 kfree(dev->remote);
593 dev->remote = NULL; 596 dev->remote = NULL;
594} 597}
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 3ea09142ec9c..860b89530e2a 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -351,7 +351,7 @@ struct saa7134_oss {
351 351
352/* IR input */ 352/* IR input */
353struct saa7134_ir { 353struct saa7134_ir {
354 struct input_dev dev; 354 struct input_dev *dev;
355 struct ir_input_state ir; 355 struct ir_input_state ir;
356 char name[32]; 356 char name[32];
357 char phys[32]; 357 char phys[32];
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 0456dda2624d..94053f149ddf 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -784,13 +784,13 @@ tda9887_command(struct i2c_client *client, unsigned int cmd, void *arg)
784 return 0; 784 return 0;
785} 785}
786 786
787static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level) 787static int tda9887_suspend(struct device * dev, pm_message_t state)
788{ 788{
789 dprintk("tda9887: suspend\n"); 789 dprintk("tda9887: suspend\n");
790 return 0; 790 return 0;
791} 791}
792 792
793static int tda9887_resume(struct device * dev, u32 level) 793static int tda9887_resume(struct device * dev)
794{ 794{
795 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 795 struct i2c_client *c = container_of(dev, struct i2c_client, dev);
796 struct tda9887 *t = i2c_get_clientdata(c); 796 struct tda9887 *t = i2c_get_clientdata(c);
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 05572020af4d..ad85bef1c3d5 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -697,7 +697,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
697 return 0; 697 return 0;
698} 698}
699 699
700static int tuner_suspend(struct device *dev, pm_message_t state, u32 level) 700static int tuner_suspend(struct device *dev, pm_message_t state)
701{ 701{
702 struct i2c_client *c = container_of (dev, struct i2c_client, dev); 702 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
703 struct tuner *t = i2c_get_clientdata (c); 703 struct tuner *t = i2c_get_clientdata (c);
@@ -707,7 +707,7 @@ static int tuner_suspend(struct device *dev, pm_message_t state, u32 level)
707 return 0; 707 return 0;
708} 708}
709 709
710static int tuner_resume(struct device *dev, u32 level) 710static int tuner_resume(struct device *dev)
711{ 711{
712 struct i2c_client *c = container_of (dev, struct i2c_client, dev); 712 struct i2c_client *c = container_of (dev, struct i2c_client, dev);
713 struct tuner *t = i2c_get_clientdata (c); 713 struct tuner *t = i2c_get_clientdata (c);
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index c5bcfd70f711..9eefedb16211 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -36,9 +36,6 @@ extern void __exit i2o_pci_exit(void);
36extern void i2o_device_remove(struct i2o_device *); 36extern void i2o_device_remove(struct i2o_device *);
37extern int i2o_device_parse_lct(struct i2o_controller *); 37extern int i2o_device_parse_lct(struct i2o_controller *);
38 38
39extern int i2o_device_init(void);
40extern void i2o_device_exit(void);
41
42/* IOP */ 39/* IOP */
43extern struct i2o_controller *i2o_iop_alloc(void); 40extern struct i2o_controller *i2o_iop_alloc(void);
44extern void i2o_iop_free(struct i2o_controller *); 41extern void i2o_iop_free(struct i2o_controller *);
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 21f16ba3ac38..d9879965eb50 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -45,10 +45,10 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
45 writel(type, &msg->body[0]); 45 writel(type, &msg->body[0]);
46 46
47 return i2o_msg_post_wait(dev->iop, m, 60); 47 return i2o_msg_post_wait(dev->iop, m, 60);
48}; 48}
49 49
50/** 50/**
51 * i2o_device_claim - claim a device for use by an OSM 51 * i2o_device_claim - claim a device for use by an OSM
52 * @dev: I2O device to claim 52 * @dev: I2O device to claim
53 * @drv: I2O driver which wants to claim the device 53 * @drv: I2O driver which wants to claim the device
54 * 54 *
@@ -73,7 +73,7 @@ int i2o_device_claim(struct i2o_device *dev)
73 up(&dev->lock); 73 up(&dev->lock);
74 74
75 return rc; 75 return rc;
76}; 76}
77 77
78/** 78/**
79 * i2o_device_claim_release - release a device that the OSM is using 79 * i2o_device_claim_release - release a device that the OSM is using
@@ -119,7 +119,8 @@ int i2o_device_claim_release(struct i2o_device *dev)
119 up(&dev->lock); 119 up(&dev->lock);
120 120
121 return rc; 121 return rc;
122}; 122}
123
123 124
124/** 125/**
125 * i2o_device_release - release the memory for a I2O device 126 * i2o_device_release - release the memory for a I2O device
@@ -135,39 +136,47 @@ static void i2o_device_release(struct device *dev)
135 pr_debug("i2o: device %s released\n", dev->bus_id); 136 pr_debug("i2o: device %s released\n", dev->bus_id);
136 137
137 kfree(i2o_dev); 138 kfree(i2o_dev);
138}; 139}
140
139 141
140/** 142/**
141 * i2o_device_class_release - Remove I2O device attributes 143 * i2o_device_class_show_class_id - Displays class id of I2O device
142 * @cd: I2O class device which is added to the I2O device class 144 * @cd: class device of which the class id should be displayed
145 * @buf: buffer into which the class id should be printed
143 * 146 *
144 * Removes attributes from the I2O device again. Also search each device 147 * Returns the number of bytes which are printed into the buffer.
145 * on the controller for I2O devices which refert to this device as parent
146 * or user and remove this links also.
147 */ 148 */
148static void i2o_device_class_release(struct class_device *cd) 149static ssize_t i2o_device_show_class_id(struct device *dev,
150 struct device_attribute *attr,
151 char *buf)
149{ 152{
150 struct i2o_device *i2o_dev, *tmp; 153 struct i2o_device *i2o_dev = to_i2o_device(dev);
151 struct i2o_controller *c;
152 154
153 i2o_dev = to_i2o_device(cd->dev); 155 sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id);
154 c = i2o_dev->iop; 156 return strlen(buf) + 1;
157}
155 158
156 sysfs_remove_link(&i2o_dev->device.kobj, "parent"); 159/**
157 sysfs_remove_link(&i2o_dev->device.kobj, "user"); 160 * i2o_device_class_show_tid - Displays TID of I2O device
161 * @cd: class device of which the TID should be displayed
162 * @buf: buffer into which the class id should be printed
163 *
164 * Returns the number of bytes which are printed into the buffer.
165 */
166static ssize_t i2o_device_show_tid(struct device *dev,
167 struct device_attribute *attr,
168 char *buf)
169{
170 struct i2o_device *i2o_dev = to_i2o_device(dev);
158 171
159 list_for_each_entry(tmp, &c->devices, list) { 172 sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid);
160 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) 173 return strlen(buf) + 1;
161 sysfs_remove_link(&tmp->device.kobj, "parent"); 174}
162 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
163 sysfs_remove_link(&tmp->device.kobj, "user");
164 }
165};
166 175
167/* I2O device class */ 176struct device_attribute i2o_device_attrs[] = {
168static struct class i2o_device_class = { 177 __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL),
169 .name = "i2o_device", 178 __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL),
170 .release = i2o_device_class_release 179 __ATTR_NULL
171}; 180};
172 181
173/** 182/**
@@ -193,11 +202,69 @@ static struct i2o_device *i2o_device_alloc(void)
193 202
194 dev->device.bus = &i2o_bus_type; 203 dev->device.bus = &i2o_bus_type;
195 dev->device.release = &i2o_device_release; 204 dev->device.release = &i2o_device_release;
196 dev->classdev.class = &i2o_device_class;
197 dev->classdev.dev = &dev->device;
198 205
199 return dev; 206 return dev;
200}; 207}
208
209/**
210 * i2o_setup_sysfs_links - Adds attributes to the I2O device
211 * @cd: I2O class device which is added to the I2O device class
212 *
213 * This function get called when a I2O device is added to the class. It
214 * creates the attributes for each device and creates user/parent symlink
215 * if necessary.
216 *
217 * Returns 0 on success or negative error code on failure.
218 */
219static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev)
220{
221 struct i2o_controller *c = i2o_dev->iop;
222 struct i2o_device *tmp;
223
224 /* create user entries for this device */
225 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
226 if (tmp && tmp != i2o_dev)
227 sysfs_create_link(&i2o_dev->device.kobj,
228 &tmp->device.kobj, "user");
229
230 /* create user entries refering to this device */
231 list_for_each_entry(tmp, &c->devices, list)
232 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid &&
233 tmp != i2o_dev)
234 sysfs_create_link(&tmp->device.kobj,
235 &i2o_dev->device.kobj, "user");
236
237 /* create parent entries for this device */
238 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
239 if (tmp && tmp != i2o_dev)
240 sysfs_create_link(&i2o_dev->device.kobj,
241 &tmp->device.kobj, "parent");
242
243 /* create parent entries refering to this device */
244 list_for_each_entry(tmp, &c->devices, list)
245 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid &&
246 tmp != i2o_dev)
247 sysfs_create_link(&tmp->device.kobj,
248 &i2o_dev->device.kobj, "parent");
249}
250
251static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
252{
253 struct i2o_controller *c = i2o_dev->iop;
254 struct i2o_device *tmp;
255
256 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
257 sysfs_remove_link(&i2o_dev->device.kobj, "user");
258
259 list_for_each_entry(tmp, &c->devices, list) {
260 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
261 sysfs_remove_link(&tmp->device.kobj, "parent");
262 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
263 sysfs_remove_link(&tmp->device.kobj, "user");
264 }
265}
266
267
201 268
202/** 269/**
203 * i2o_device_add - allocate a new I2O device and add it to the IOP 270 * i2o_device_add - allocate a new I2O device and add it to the IOP
@@ -222,28 +289,25 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
222 } 289 }
223 290
224 dev->lct_data = *entry; 291 dev->lct_data = *entry;
292 dev->iop = c;
225 293
226 snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, 294 snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
227 dev->lct_data.tid); 295 dev->lct_data.tid);
228 296
229 snprintf(dev->classdev.class_id, BUS_ID_SIZE, "%d:%03x", c->unit,
230 dev->lct_data.tid);
231
232 dev->iop = c;
233 dev->device.parent = &c->device; 297 dev->device.parent = &c->device;
234 298
235 device_register(&dev->device); 299 device_register(&dev->device);
236 300
237 list_add_tail(&dev->list, &c->devices); 301 list_add_tail(&dev->list, &c->devices);
238 302
239 class_device_register(&dev->classdev); 303 i2o_setup_sysfs_links(dev);
240 304
241 i2o_driver_notify_device_add_all(dev); 305 i2o_driver_notify_device_add_all(dev);
242 306
243 pr_debug("i2o: device %s added\n", dev->device.bus_id); 307 pr_debug("i2o: device %s added\n", dev->device.bus_id);
244 308
245 return dev; 309 return dev;
246}; 310}
247 311
248/** 312/**
249 * i2o_device_remove - remove an I2O device from the I2O core 313 * i2o_device_remove - remove an I2O device from the I2O core
@@ -256,10 +320,10 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
256void i2o_device_remove(struct i2o_device *i2o_dev) 320void i2o_device_remove(struct i2o_device *i2o_dev)
257{ 321{
258 i2o_driver_notify_device_remove_all(i2o_dev); 322 i2o_driver_notify_device_remove_all(i2o_dev);
259 class_device_unregister(&i2o_dev->classdev); 323 i2o_remove_sysfs_links(i2o_dev);
260 list_del(&i2o_dev->list); 324 list_del(&i2o_dev->list);
261 device_unregister(&i2o_dev->device); 325 device_unregister(&i2o_dev->device);
262}; 326}
263 327
264/** 328/**
265 * i2o_device_parse_lct - Parse a previously fetched LCT and create devices 329 * i2o_device_parse_lct - Parse a previously fetched LCT and create devices
@@ -337,99 +401,8 @@ int i2o_device_parse_lct(struct i2o_controller *c)
337 up(&c->lct_lock); 401 up(&c->lct_lock);
338 402
339 return 0; 403 return 0;
340}; 404}
341
342/**
343 * i2o_device_class_show_class_id - Displays class id of I2O device
344 * @cd: class device of which the class id should be displayed
345 * @buf: buffer into which the class id should be printed
346 *
347 * Returns the number of bytes which are printed into the buffer.
348 */
349static ssize_t i2o_device_class_show_class_id(struct class_device *cd,
350 char *buf)
351{
352 struct i2o_device *dev = to_i2o_device(cd->dev);
353
354 sprintf(buf, "0x%03x\n", dev->lct_data.class_id);
355 return strlen(buf) + 1;
356};
357
358/**
359 * i2o_device_class_show_tid - Displays TID of I2O device
360 * @cd: class device of which the TID should be displayed
361 * @buf: buffer into which the class id should be printed
362 *
363 * Returns the number of bytes which are printed into the buffer.
364 */
365static ssize_t i2o_device_class_show_tid(struct class_device *cd, char *buf)
366{
367 struct i2o_device *dev = to_i2o_device(cd->dev);
368
369 sprintf(buf, "0x%03x\n", dev->lct_data.tid);
370 return strlen(buf) + 1;
371};
372
373/* I2O device class attributes */
374static CLASS_DEVICE_ATTR(class_id, S_IRUGO, i2o_device_class_show_class_id,
375 NULL);
376static CLASS_DEVICE_ATTR(tid, S_IRUGO, i2o_device_class_show_tid, NULL);
377
378/**
379 * i2o_device_class_add - Adds attributes to the I2O device
380 * @cd: I2O class device which is added to the I2O device class
381 *
382 * This function get called when a I2O device is added to the class. It
383 * creates the attributes for each device and creates user/parent symlink
384 * if necessary.
385 *
386 * Returns 0 on success or negative error code on failure.
387 */
388static int i2o_device_class_add(struct class_device *cd)
389{
390 struct i2o_device *i2o_dev, *tmp;
391 struct i2o_controller *c;
392
393 i2o_dev = to_i2o_device(cd->dev);
394 c = i2o_dev->iop;
395
396 class_device_create_file(cd, &class_device_attr_class_id);
397 class_device_create_file(cd, &class_device_attr_tid);
398
399 /* create user entries for this device */
400 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
401 if (tmp && (tmp != i2o_dev))
402 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
403 "user");
404
405 /* create user entries refering to this device */
406 list_for_each_entry(tmp, &c->devices, list)
407 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
408 && (tmp != i2o_dev))
409 sysfs_create_link(&tmp->device.kobj,
410 &i2o_dev->device.kobj, "user");
411
412 /* create parent entries for this device */
413 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
414 if (tmp && (tmp != i2o_dev))
415 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
416 "parent");
417
418 /* create parent entries refering to this device */
419 list_for_each_entry(tmp, &c->devices, list)
420 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
421 && (tmp != i2o_dev))
422 sysfs_create_link(&tmp->device.kobj,
423 &i2o_dev->device.kobj, "parent");
424
425 return 0;
426};
427 405
428/* I2O device class interface */
429static struct class_interface i2o_device_class_interface = {
430 .class = &i2o_device_class,
431 .add = i2o_device_class_add
432};
433 406
434/* 407/*
435 * Run time support routines 408 * Run time support routines
@@ -553,11 +526,11 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
553} 526}
554 527
555/* 528/*
556 * if oper == I2O_PARAMS_TABLE_GET, get from all rows 529 * if oper == I2O_PARAMS_TABLE_GET, get from all rows
557 * if fieldcount == -1 return all fields 530 * if fieldcount == -1 return all fields
558 * ibuf and ibuflen are unused (use NULL, 0) 531 * ibuf and ibuflen are unused (use NULL, 0)
559 * else return specific fields 532 * else return specific fields
560 * ibuf contains fieldindexes 533 * ibuf contains fieldindexes
561 * 534 *
562 * if oper == I2O_PARAMS_LIST_GET, get from specific rows 535 * if oper == I2O_PARAMS_LIST_GET, get from specific rows
563 * if fieldcount == -1 return all fields 536 * if fieldcount == -1 return all fields
@@ -602,35 +575,6 @@ int i2o_parm_table_get(struct i2o_device *dev, int oper, int group,
602 return size; 575 return size;
603} 576}
604 577
605/**
606 * i2o_device_init - Initialize I2O devices
607 *
608 * Registers the I2O device class.
609 *
610 * Returns 0 on success or negative error code on failure.
611 */
612int i2o_device_init(void)
613{
614 int rc;
615
616 rc = class_register(&i2o_device_class);
617 if (rc)
618 return rc;
619
620 return class_interface_register(&i2o_device_class_interface);
621};
622
623/**
624 * i2o_device_exit - I2O devices exit function
625 *
626 * Unregisters the I2O device class.
627 */
628void i2o_device_exit(void)
629{
630 class_interface_register(&i2o_device_class_interface);
631 class_unregister(&i2o_device_class);
632};
633
634EXPORT_SYMBOL(i2o_device_claim); 578EXPORT_SYMBOL(i2o_device_claim);
635EXPORT_SYMBOL(i2o_device_claim_release); 579EXPORT_SYMBOL(i2o_device_claim_release);
636EXPORT_SYMBOL(i2o_parm_field_get); 580EXPORT_SYMBOL(i2o_parm_field_get);
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 739bfdef0c6d..0079a4be0af2 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -58,9 +58,12 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv)
58}; 58};
59 59
60/* I2O bus type */ 60/* I2O bus type */
61extern struct device_attribute i2o_device_attrs[];
62
61struct bus_type i2o_bus_type = { 63struct bus_type i2o_bus_type = {
62 .name = "i2o", 64 .name = "i2o",
63 .match = i2o_bus_match, 65 .match = i2o_bus_match,
66 .dev_attrs = i2o_device_attrs,
64}; 67};
65 68
66/** 69/**
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 42f8b810d6e5..361da8d1d5e7 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -833,6 +833,7 @@ void i2o_iop_remove(struct i2o_controller *c)
833 list_for_each_entry_safe(dev, tmp, &c->devices, list) 833 list_for_each_entry_safe(dev, tmp, &c->devices, list)
834 i2o_device_remove(dev); 834 i2o_device_remove(dev);
835 835
836 class_device_unregister(c->classdev);
836 device_del(&c->device); 837 device_del(&c->device);
837 838
838 /* Ask the IOP to switch to RESET state */ 839 /* Ask the IOP to switch to RESET state */
@@ -1077,9 +1078,7 @@ static void i2o_iop_release(struct device *dev)
1077}; 1078};
1078 1079
1079/* I2O controller class */ 1080/* I2O controller class */
1080static struct class i2o_controller_class = { 1081static struct class *i2o_controller_class;
1081 .name = "i2o_controller",
1082};
1083 1082
1084/** 1083/**
1085 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct 1084 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
@@ -1110,14 +1109,10 @@ struct i2o_controller *i2o_iop_alloc(void)
1110 sprintf(c->name, "iop%d", c->unit); 1109 sprintf(c->name, "iop%d", c->unit);
1111 1110
1112 device_initialize(&c->device); 1111 device_initialize(&c->device);
1113 class_device_initialize(&c->classdev);
1114 1112
1115 c->device.release = &i2o_iop_release; 1113 c->device.release = &i2o_iop_release;
1116 c->classdev.class = &i2o_controller_class;
1117 c->classdev.dev = &c->device;
1118 1114
1119 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit); 1115 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
1120 snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit);
1121 1116
1122#if BITS_PER_LONG == 64 1117#if BITS_PER_LONG == 64
1123 spin_lock_init(&c->context_list_lock); 1118 spin_lock_init(&c->context_list_lock);
@@ -1146,7 +1141,9 @@ int i2o_iop_add(struct i2o_controller *c)
1146 goto iop_reset; 1141 goto iop_reset;
1147 } 1142 }
1148 1143
1149 if ((rc = class_device_add(&c->classdev))) { 1144 c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
1145 &c->device, "iop%d", c->unit);
1146 if (IS_ERR(c->classdev)) {
1150 osm_err("%s: could not add controller class\n", c->name); 1147 osm_err("%s: could not add controller class\n", c->name);
1151 goto device_del; 1148 goto device_del;
1152 } 1149 }
@@ -1184,7 +1181,7 @@ int i2o_iop_add(struct i2o_controller *c)
1184 return 0; 1181 return 0;
1185 1182
1186 class_del: 1183 class_del:
1187 class_device_del(&c->classdev); 1184 class_device_unregister(c->classdev);
1188 1185
1189 device_del: 1186 device_del:
1190 device_del(&c->device); 1187 device_del(&c->device);
@@ -1246,13 +1243,10 @@ static int __init i2o_iop_init(void)
1246 1243
1247 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); 1244 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
1248 1245
1249 rc = i2o_device_init(); 1246 i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
1250 if (rc) 1247 if (IS_ERR(i2o_controller_class)) {
1251 goto exit;
1252
1253 if ((rc = class_register(&i2o_controller_class))) {
1254 osm_err("can't register class i2o_controller\n"); 1248 osm_err("can't register class i2o_controller\n");
1255 goto device_exit; 1249 goto exit;
1256 } 1250 }
1257 1251
1258 if ((rc = i2o_driver_init())) 1252 if ((rc = i2o_driver_init()))
@@ -1273,10 +1267,7 @@ static int __init i2o_iop_init(void)
1273 i2o_driver_exit(); 1267 i2o_driver_exit();
1274 1268
1275 class_exit: 1269 class_exit:
1276 class_unregister(&i2o_controller_class); 1270 class_destroy(i2o_controller_class);
1277
1278 device_exit:
1279 i2o_device_exit();
1280 1271
1281 exit: 1272 exit:
1282 return rc; 1273 return rc;
@@ -1292,8 +1283,7 @@ static void __exit i2o_iop_exit(void)
1292 i2o_pci_exit(); 1283 i2o_pci_exit();
1293 i2o_exec_exit(); 1284 i2o_exec_exit();
1294 i2o_driver_exit(); 1285 i2o_driver_exit();
1295 class_unregister(&i2o_controller_class); 1286 class_destroy(i2o_controller_class);
1296 i2o_device_exit();
1297}; 1287};
1298 1288
1299module_init(i2o_iop_init); 1289module_init(i2o_iop_init);
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index e9806fbbe696..720e7a326308 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -219,26 +219,24 @@ static int mcp_sa11x0_remove(struct device *dev)
219 return 0; 219 return 0;
220} 220}
221 221
222static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state, u32 level) 222static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state)
223{ 223{
224 struct mcp *mcp = dev_get_drvdata(dev); 224 struct mcp *mcp = dev_get_drvdata(dev);
225 225
226 if (level == SUSPEND_DISABLE) { 226 priv(mcp)->mccr0 = Ser4MCCR0;
227 priv(mcp)->mccr0 = Ser4MCCR0; 227 priv(mcp)->mccr1 = Ser4MCCR1;
228 priv(mcp)->mccr1 = Ser4MCCR1; 228 Ser4MCCR0 &= ~MCCR0_MCE;
229 Ser4MCCR0 &= ~MCCR0_MCE; 229
230 }
231 return 0; 230 return 0;
232} 231}
233 232
234static int mcp_sa11x0_resume(struct device *dev, u32 level) 233static int mcp_sa11x0_resume(struct device *dev)
235{ 234{
236 struct mcp *mcp = dev_get_drvdata(dev); 235 struct mcp *mcp = dev_get_drvdata(dev);
237 236
238 if (level == RESUME_RESTORE_STATE) { 237 Ser4MCCR1 = priv(mcp)->mccr1;
239 Ser4MCCR1 = priv(mcp)->mccr1; 238 Ser4MCCR0 = priv(mcp)->mccr0;
240 Ser4MCCR0 = priv(mcp)->mccr0; 239
241 }
242 return 0; 240 return 0;
243} 241}
244 242
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index a260f83bcb02..585cded3d365 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -40,7 +40,7 @@
40 40
41 41
42struct ucb1x00_ts { 42struct ucb1x00_ts {
43 struct input_dev idev; 43 struct input_dev *idev;
44 struct ucb1x00 *ucb; 44 struct ucb1x00 *ucb;
45 45
46 wait_queue_head_t irq_wait; 46 wait_queue_head_t irq_wait;
@@ -56,16 +56,16 @@ static int adcsync;
56 56
57static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) 57static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
58{ 58{
59 input_report_abs(&ts->idev, ABS_X, x); 59 input_report_abs(ts->idev, ABS_X, x);
60 input_report_abs(&ts->idev, ABS_Y, y); 60 input_report_abs(ts->idev, ABS_Y, y);
61 input_report_abs(&ts->idev, ABS_PRESSURE, pressure); 61 input_report_abs(ts->idev, ABS_PRESSURE, pressure);
62 input_sync(&ts->idev); 62 input_sync(ts->idev);
63} 63}
64 64
65static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts) 65static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
66{ 66{
67 input_report_abs(&ts->idev, ABS_PRESSURE, 0); 67 input_report_abs(ts->idev, ABS_PRESSURE, 0);
68 input_sync(&ts->idev); 68 input_sync(ts->idev);
69} 69}
70 70
71/* 71/*
@@ -341,26 +341,30 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
341{ 341{
342 struct ucb1x00_ts *ts; 342 struct ucb1x00_ts *ts;
343 343
344 ts = kmalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL); 344 ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
345 if (!ts) 345 if (!ts)
346 return -ENOMEM; 346 return -ENOMEM;
347 347
348 memset(ts, 0, sizeof(struct ucb1x00_ts)); 348 ts->idev = input_allocate_device();
349 if (!ts->idev) {
350 kfree(ts);
351 return -ENOMEM;
352 }
349 353
350 ts->ucb = dev->ucb; 354 ts->ucb = dev->ucb;
351 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; 355 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
352 356
353 ts->idev.name = "Touchscreen panel"; 357 ts->idev->name = "Touchscreen panel";
354 ts->idev.id.product = ts->ucb->id; 358 ts->idev->id.product = ts->ucb->id;
355 ts->idev.open = ucb1x00_ts_open; 359 ts->idev->open = ucb1x00_ts_open;
356 ts->idev.close = ucb1x00_ts_close; 360 ts->idev->close = ucb1x00_ts_close;
357 361
358 __set_bit(EV_ABS, ts->idev.evbit); 362 __set_bit(EV_ABS, ts->idev->evbit);
359 __set_bit(ABS_X, ts->idev.absbit); 363 __set_bit(ABS_X, ts->idev->absbit);
360 __set_bit(ABS_Y, ts->idev.absbit); 364 __set_bit(ABS_Y, ts->idev->absbit);
361 __set_bit(ABS_PRESSURE, ts->idev.absbit); 365 __set_bit(ABS_PRESSURE, ts->idev->absbit);
362 366
363 input_register_device(&ts->idev); 367 input_register_device(ts->idev);
364 368
365 dev->priv = ts; 369 dev->priv = ts;
366 370
@@ -370,7 +374,8 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
370static void ucb1x00_ts_remove(struct ucb1x00_dev *dev) 374static void ucb1x00_ts_remove(struct ucb1x00_dev *dev)
371{ 375{
372 struct ucb1x00_ts *ts = dev->priv; 376 struct ucb1x00_ts *ts = dev->priv;
373 input_unregister_device(&ts->idev); 377
378 input_unregister_device(ts->idev);
374 kfree(ts); 379 kfree(ts);
375} 380}
376 381
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 91c74843dc0d..1e6bdba26756 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -24,6 +24,7 @@
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/scatterlist.h> 26#include <asm/scatterlist.h>
27#include <asm/sizes.h>
27#include <asm/hardware/amba.h> 28#include <asm/hardware/amba.h>
28#include <asm/hardware/clock.h> 29#include <asm/hardware/clock.h>
29#include <asm/mach/mmc.h> 30#include <asm/mach/mmc.h>
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index b53af57074e3..8eba373d42d7 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -571,23 +571,23 @@ static int pxamci_remove(struct device *dev)
571} 571}
572 572
573#ifdef CONFIG_PM 573#ifdef CONFIG_PM
574static int pxamci_suspend(struct device *dev, pm_message_t state, u32 level) 574static int pxamci_suspend(struct device *dev, pm_message_t state)
575{ 575{
576 struct mmc_host *mmc = dev_get_drvdata(dev); 576 struct mmc_host *mmc = dev_get_drvdata(dev);
577 int ret = 0; 577 int ret = 0;
578 578
579 if (mmc && level == SUSPEND_DISABLE) 579 if (mmc)
580 ret = mmc_suspend_host(mmc, state); 580 ret = mmc_suspend_host(mmc, state);
581 581
582 return ret; 582 return ret;
583} 583}
584 584
585static int pxamci_resume(struct device *dev, u32 level) 585static int pxamci_resume(struct device *dev)
586{ 586{
587 struct mmc_host *mmc = dev_get_drvdata(dev); 587 struct mmc_host *mmc = dev_get_drvdata(dev);
588 int ret = 0; 588 int ret = 0;
589 589
590 if (mmc && level == RESUME_ENABLE) 590 if (mmc)
591 ret = mmc_resume_host(mmc); 591 ret = mmc_resume_host(mmc);
592 592
593 return ret; 593 return ret;
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index 3cbca7cbea80..3ace875decc4 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1033,13 +1033,16 @@ static void wbsd_set_ios(struct mmc_host* mmc, struct mmc_ios* ios)
1033 } 1033 }
1034 else 1034 else
1035 { 1035 {
1036 setup &= ~WBSD_DAT3_H; 1036 if (setup & WBSD_DAT3_H)
1037 {
1038 setup &= ~WBSD_DAT3_H;
1037 1039
1038 /* 1040 /*
1039 * We cannot resume card detection immediatly 1041 * We cannot resume card detection immediatly
1040 * because of capacitance and delays in the chip. 1042 * because of capacitance and delays in the chip.
1041 */ 1043 */
1042 mod_timer(&host->ignore_timer, jiffies + HZ/100); 1044 mod_timer(&host->ignore_timer, jiffies + HZ/100);
1045 }
1043 } 1046 }
1044 wbsd_write_index(host, WBSD_IDX_SETUP, setup); 1047 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
1045 1048
@@ -1461,8 +1464,10 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1461 { 1464 {
1462 id = 0xFFFF; 1465 id = 0xFFFF;
1463 1466
1464 outb(unlock_codes[j], config_ports[i]); 1467 host->config = config_ports[i];
1465 outb(unlock_codes[j], config_ports[i]); 1468 host->unlock_code = unlock_codes[j];
1469
1470 wbsd_unlock_config(host);
1466 1471
1467 outb(WBSD_CONF_ID_HI, config_ports[i]); 1472 outb(WBSD_CONF_ID_HI, config_ports[i]);
1468 id = inb(config_ports[i] + 1) << 8; 1473 id = inb(config_ports[i] + 1) << 8;
@@ -1470,13 +1475,13 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1470 outb(WBSD_CONF_ID_LO, config_ports[i]); 1475 outb(WBSD_CONF_ID_LO, config_ports[i]);
1471 id |= inb(config_ports[i] + 1); 1476 id |= inb(config_ports[i] + 1);
1472 1477
1478 wbsd_lock_config(host);
1479
1473 for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++) 1480 for (k = 0;k < sizeof(valid_ids)/sizeof(int);k++)
1474 { 1481 {
1475 if (id == valid_ids[k]) 1482 if (id == valid_ids[k])
1476 { 1483 {
1477 host->chip_id = id; 1484 host->chip_id = id;
1478 host->config = config_ports[i];
1479 host->unlock_code = unlock_codes[i];
1480 1485
1481 return 0; 1486 return 0;
1482 } 1487 }
@@ -1487,13 +1492,14 @@ static int __devinit wbsd_scan(struct wbsd_host* host)
1487 DBG("Unknown hardware (id %x) found at %x\n", 1492 DBG("Unknown hardware (id %x) found at %x\n",
1488 id, config_ports[i]); 1493 id, config_ports[i]);
1489 } 1494 }
1490
1491 outb(LOCK_CODE, config_ports[i]);
1492 } 1495 }
1493 1496
1494 release_region(config_ports[i], 2); 1497 release_region(config_ports[i], 2);
1495 } 1498 }
1496 1499
1500 host->config = 0;
1501 host->unlock_code = 0;
1502
1497 return -ENODEV; 1503 return -ENODEV;
1498} 1504}
1499 1505
@@ -1699,8 +1705,10 @@ static void __devexit wbsd_release_resources(struct wbsd_host* host)
1699 * Configure the resources the chip should use. 1705 * Configure the resources the chip should use.
1700 */ 1706 */
1701 1707
1702static void __devinit wbsd_chip_config(struct wbsd_host* host) 1708static void wbsd_chip_config(struct wbsd_host* host)
1703{ 1709{
1710 wbsd_unlock_config(host);
1711
1704 /* 1712 /*
1705 * Reset the chip. 1713 * Reset the chip.
1706 */ 1714 */
@@ -1733,16 +1741,20 @@ static void __devinit wbsd_chip_config(struct wbsd_host* host)
1733 */ 1741 */
1734 wbsd_write_config(host, WBSD_CONF_ENABLE, 1); 1742 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1735 wbsd_write_config(host, WBSD_CONF_POWER, 0x20); 1743 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1744
1745 wbsd_lock_config(host);
1736} 1746}
1737 1747
1738/* 1748/*
1739 * Check that configured resources are correct. 1749 * Check that configured resources are correct.
1740 */ 1750 */
1741 1751
1742static int __devinit wbsd_chip_validate(struct wbsd_host* host) 1752static int wbsd_chip_validate(struct wbsd_host* host)
1743{ 1753{
1744 int base, irq, dma; 1754 int base, irq, dma;
1745 1755
1756 wbsd_unlock_config(host);
1757
1746 /* 1758 /*
1747 * Select SD/MMC function. 1759 * Select SD/MMC function.
1748 */ 1760 */
@@ -1758,6 +1770,8 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1758 1770
1759 dma = wbsd_read_config(host, WBSD_CONF_DRQ); 1771 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1760 1772
1773 wbsd_lock_config(host);
1774
1761 /* 1775 /*
1762 * Validate against given configuration. 1776 * Validate against given configuration.
1763 */ 1777 */
@@ -1771,6 +1785,20 @@ static int __devinit wbsd_chip_validate(struct wbsd_host* host)
1771 return 1; 1785 return 1;
1772} 1786}
1773 1787
1788/*
1789 * Powers down the SD function
1790 */
1791
1792static void wbsd_chip_poweroff(struct wbsd_host* host)
1793{
1794 wbsd_unlock_config(host);
1795
1796 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1797 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1798
1799 wbsd_lock_config(host);
1800}
1801
1774/*****************************************************************************\ 1802/*****************************************************************************\
1775 * * 1803 * *
1776 * Devices setup and shutdown * 1804 * Devices setup and shutdown *
@@ -1844,7 +1872,11 @@ static int __devinit wbsd_init(struct device* dev, int base, int irq, int dma,
1844 */ 1872 */
1845#ifdef CONFIG_PM 1873#ifdef CONFIG_PM
1846 if (host->config) 1874 if (host->config)
1875 {
1876 wbsd_unlock_config(host);
1847 wbsd_write_config(host, WBSD_CONF_PME, 0xA0); 1877 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1878 wbsd_lock_config(host);
1879 }
1848#endif 1880#endif
1849 /* 1881 /*
1850 * Allow device to initialise itself properly. 1882 * Allow device to initialise itself properly.
@@ -1885,16 +1917,11 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1885 1917
1886 mmc_remove_host(mmc); 1918 mmc_remove_host(mmc);
1887 1919
1920 /*
1921 * Power down the SD/MMC function.
1922 */
1888 if (!pnp) 1923 if (!pnp)
1889 { 1924 wbsd_chip_poweroff(host);
1890 /*
1891 * Power down the SD/MMC function.
1892 */
1893 wbsd_unlock_config(host);
1894 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1895 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1896 wbsd_lock_config(host);
1897 }
1898 1925
1899 wbsd_release_resources(host); 1926 wbsd_release_resources(host);
1900 1927
@@ -1955,23 +1982,59 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev)
1955 */ 1982 */
1956 1983
1957#ifdef CONFIG_PM 1984#ifdef CONFIG_PM
1958static int wbsd_suspend(struct device *dev, pm_message_t state, u32 level) 1985
1986static int wbsd_suspend(struct device *dev, pm_message_t state)
1959{ 1987{
1960 DBGF("Not yet supported\n"); 1988 struct mmc_host *mmc = dev_get_drvdata(dev);
1989 struct wbsd_host *host;
1990 int ret;
1991
1992 if (!mmc)
1993 return 0;
1994
1995 DBG("Suspending...\n");
1996
1997 ret = mmc_suspend_host(mmc, state);
1998 if (!ret)
1999 return ret;
2000
2001 host = mmc_priv(mmc);
2002
2003 wbsd_chip_poweroff(host);
1961 2004
1962 return 0; 2005 return 0;
1963} 2006}
1964 2007
1965static int wbsd_resume(struct device *dev, u32 level) 2008static int wbsd_resume(struct device *dev)
1966{ 2009{
1967 DBGF("Not yet supported\n"); 2010 struct mmc_host *mmc = dev_get_drvdata(dev);
2011 struct wbsd_host *host;
1968 2012
1969 return 0; 2013 if (!mmc)
2014 return 0;
2015
2016 DBG("Resuming...\n");
2017
2018 host = mmc_priv(mmc);
2019
2020 wbsd_chip_config(host);
2021
2022 /*
2023 * Allow device to initialise itself properly.
2024 */
2025 mdelay(5);
2026
2027 wbsd_init_device(host);
2028
2029 return mmc_resume_host(mmc);
1970} 2030}
1971#else 2031
2032#else /* CONFIG_PM */
2033
1972#define wbsd_suspend NULL 2034#define wbsd_suspend NULL
1973#define wbsd_resume NULL 2035#define wbsd_resume NULL
1974#endif 2036
2037#endif /* CONFIG_PM */
1975 2038
1976static struct platform_device *wbsd_device; 2039static struct platform_device *wbsd_device;
1977 2040
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 8dcaa357b4bb..6a8e0caf9fdc 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -21,6 +21,7 @@
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/mtd/concat.h> 22#include <linux/mtd/concat.h>
23 23
24#include <asm/hardware.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/sizes.h> 26#include <asm/sizes.h>
26#include <asm/mach/flash.h> 27#include <asm/mach/flash.h>
@@ -402,21 +403,21 @@ static int __exit sa1100_mtd_remove(struct device *dev)
402} 403}
403 404
404#ifdef CONFIG_PM 405#ifdef CONFIG_PM
405static int sa1100_mtd_suspend(struct device *dev, pm_message_t state, u32 level) 406static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
406{ 407{
407 struct sa_info *info = dev_get_drvdata(dev); 408 struct sa_info *info = dev_get_drvdata(dev);
408 int ret = 0; 409 int ret = 0;
409 410
410 if (info && level == SUSPEND_SAVE_STATE) 411 if (info)
411 ret = info->mtd->suspend(info->mtd); 412 ret = info->mtd->suspend(info->mtd);
412 413
413 return ret; 414 return ret;
414} 415}
415 416
416static int sa1100_mtd_resume(struct device *dev, u32 level) 417static int sa1100_mtd_resume(struct device *dev)
417{ 418{
418 struct sa_info *info = dev_get_drvdata(dev); 419 struct sa_info *info = dev_get_drvdata(dev);
419 if (info && level == RESUME_RESTORE_STATE) 420 if (info)
420 info->mtd->resume(info->mtd); 421 info->mtd->resume(info->mtd);
421 return 0; 422 return 0;
422} 423}
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 1ed602a0f24c..c534fd5d95cb 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -24,10 +24,10 @@ static void mtd_notify_add(struct mtd_info* mtd)
24 if (!mtd) 24 if (!mtd)
25 return; 25 return;
26 26
27 class_device_create(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 27 class_device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
28 NULL, "mtd%d", mtd->index); 28 NULL, "mtd%d", mtd->index);
29 29
30 class_device_create(mtd_class, 30 class_device_create(mtd_class, NULL,
31 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 31 MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
32 NULL, "mtd%dro", mtd->index); 32 NULL, "mtd%dro", mtd->index);
33} 33}
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index bc537440ca02..f822cd3025ff 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1027,8 +1027,7 @@ static void cp_reset_hw (struct cp_private *cp)
1027 if (!(cpr8(Cmd) & CmdReset)) 1027 if (!(cpr8(Cmd) & CmdReset))
1028 return; 1028 return;
1029 1029
1030 set_current_state(TASK_UNINTERRUPTIBLE); 1030 schedule_timeout_uninterruptible(10);
1031 schedule_timeout(10);
1032 } 1031 }
1033 1032
1034 printk(KERN_ERR "%s: hardware reset timeout\n", cp->dev->name); 1033 printk(KERN_ERR "%s: hardware reset timeout\n", cp->dev->name);
@@ -1575,6 +1574,7 @@ static struct ethtool_ops cp_ethtool_ops = {
1575 .set_wol = cp_set_wol, 1574 .set_wol = cp_set_wol,
1576 .get_strings = cp_get_strings, 1575 .get_strings = cp_get_strings,
1577 .get_ethtool_stats = cp_get_ethtool_stats, 1576 .get_ethtool_stats = cp_get_ethtool_stats,
1577 .get_perm_addr = ethtool_op_get_perm_addr,
1578}; 1578};
1579 1579
1580static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) 1580static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1773,6 +1773,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1773 for (i = 0; i < 3; i++) 1773 for (i = 0; i < 3; i++)
1774 ((u16 *) (dev->dev_addr))[i] = 1774 ((u16 *) (dev->dev_addr))[i] =
1775 le16_to_cpu (read_eeprom (regs, i + 7, addr_len)); 1775 le16_to_cpu (read_eeprom (regs, i + 7, addr_len));
1776 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1776 1777
1777 dev->open = cp_open; 1778 dev->open = cp_open;
1778 dev->stop = cp_close; 1779 dev->stop = cp_close;
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 4c2cf7bbd252..30bee11c48bd 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -552,7 +552,8 @@ const static struct {
552 552
553 { "RTL-8100B/8139D", 553 { "RTL-8100B/8139D",
554 HW_REVID(1, 1, 1, 0, 1, 0, 1), 554 HW_REVID(1, 1, 1, 0, 1, 0, 1),
555 HasLWake, 555 HasHltClk /* XXX undocumented? */
556 | HasLWake,
556 }, 557 },
557 558
558 { "RTL-8101", 559 { "RTL-8101",
@@ -970,6 +971,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
970 for (i = 0; i < 3; i++) 971 for (i = 0; i < 3; i++)
971 ((u16 *) (dev->dev_addr))[i] = 972 ((u16 *) (dev->dev_addr))[i] =
972 le16_to_cpu (read_eeprom (ioaddr, i + 7, addr_len)); 973 le16_to_cpu (read_eeprom (ioaddr, i + 7, addr_len));
974 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
973 975
974 /* The Rtl8139-specific entries in the device structure. */ 976 /* The Rtl8139-specific entries in the device structure. */
975 dev->open = rtl8139_open; 977 dev->open = rtl8139_open;
@@ -2465,6 +2467,7 @@ static struct ethtool_ops rtl8139_ethtool_ops = {
2465 .get_strings = rtl8139_get_strings, 2467 .get_strings = rtl8139_get_strings,
2466 .get_stats_count = rtl8139_get_stats_count, 2468 .get_stats_count = rtl8139_get_stats_count,
2467 .get_ethtool_stats = rtl8139_get_ethtool_stats, 2469 .get_ethtool_stats = rtl8139_get_ethtool_stats,
2470 .get_perm_addr = ethtool_op_get_perm_addr,
2468}; 2471};
2469 2472
2470static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2473static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index c748b0e16419..fee8c5cf1f3a 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -475,6 +475,14 @@ config SGI_IOC3_ETH_HW_TX_CSUM
475 the moment only acceleration of IPv4 is supported. This option 475 the moment only acceleration of IPv4 is supported. This option
476 enables offloading for checksums on transmit. If unsure, say Y. 476 enables offloading for checksums on transmit. If unsure, say Y.
477 477
478config MIPS_SIM_NET
479 tristate "MIPS simulator Network device (EXPERIMENTAL)"
480 depends on NETDEVICES && MIPS_SIM && EXPERIMENTAL
481 help
482 The MIPSNET device is a simple Ethernet network device which is
483 emulated by the MIPS Simulator.
484 If you are not using a MIPSsim or are unsure, say N.
485
478config SGI_O2MACE_ETH 486config SGI_O2MACE_ETH
479 tristate "SGI O2 MACE Fast Ethernet support" 487 tristate "SGI O2 MACE Fast Ethernet support"
480 depends on NET_ETHERNET && SGI_IP32=y 488 depends on NET_ETHERNET && SGI_IP32=y
@@ -1330,7 +1338,7 @@ config FORCEDETH
1330 1338
1331config CS89x0 1339config CS89x0
1332 tristate "CS89x0 support" 1340 tristate "CS89x0 support"
1333 depends on (NET_PCI && (ISA || ARCH_IXDP2X01)) || ARCH_PNX0105 1341 depends on (NET_PCI && (ISA || ARCH_IXDP2X01)) || ARCH_PNX0105 || MACH_MP1000
1334 ---help--- 1342 ---help---
1335 Support for CS89x0 chipset based Ethernet cards. If you have a 1343 Support for CS89x0 chipset based Ethernet cards. If you have a
1336 network (Ethernet) card of this type, say Y and read the 1344 network (Ethernet) card of this type, say Y and read the
@@ -2083,6 +2091,7 @@ config SPIDER_NET
2083config GIANFAR 2091config GIANFAR
2084 tristate "Gianfar Ethernet" 2092 tristate "Gianfar Ethernet"
2085 depends on 85xx || 83xx 2093 depends on 85xx || 83xx
2094 select PHYLIB
2086 help 2095 help
2087 This driver supports the Gigabit TSEC on the MPC85xx 2096 This driver supports the Gigabit TSEC on the MPC85xx
2088 family of chips, and the FEC on the 8540 2097 family of chips, and the FEC on the 8540
@@ -2243,6 +2252,20 @@ config ISERIES_VETH
2243 tristate "iSeries Virtual Ethernet driver support" 2252 tristate "iSeries Virtual Ethernet driver support"
2244 depends on PPC_ISERIES 2253 depends on PPC_ISERIES
2245 2254
2255config RIONET
2256 tristate "RapidIO Ethernet over messaging driver support"
2257 depends on NETDEVICES && RAPIDIO
2258
2259config RIONET_TX_SIZE
2260 int "Number of outbound queue entries"
2261 depends on RIONET
2262 default "128"
2263
2264config RIONET_RX_SIZE
2265 int "Number of inbound queue entries"
2266 depends on RIONET
2267 default "128"
2268
2246config FDDI 2269config FDDI
2247 bool "FDDI driver support" 2270 bool "FDDI driver support"
2248 depends on (PCI || EISA) 2271 depends on (PCI || EISA)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 8aeec9f2495b..1a84e0435f64 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_CHELSIO_T1) += chelsio/
13obj-$(CONFIG_BONDING) += bonding/ 13obj-$(CONFIG_BONDING) += bonding/
14obj-$(CONFIG_GIANFAR) += gianfar_driver.o 14obj-$(CONFIG_GIANFAR) += gianfar_driver.o
15 15
16gianfar_driver-objs := gianfar.o gianfar_ethtool.o gianfar_phy.o 16gianfar_driver-objs := gianfar.o gianfar_ethtool.o gianfar_mii.o
17 17
18# 18#
19# link order important here 19# link order important here
@@ -64,6 +64,7 @@ obj-$(CONFIG_SKFP) += skfp/
64obj-$(CONFIG_VIA_RHINE) += via-rhine.o 64obj-$(CONFIG_VIA_RHINE) += via-rhine.o
65obj-$(CONFIG_VIA_VELOCITY) += via-velocity.o 65obj-$(CONFIG_VIA_VELOCITY) += via-velocity.o
66obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o 66obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o
67obj-$(CONFIG_RIONET) += rionet.o
67 68
68# 69#
69# end link order section 70# end link order section
@@ -166,6 +167,7 @@ obj-$(CONFIG_EQUALIZER) += eql.o
166obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o 167obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o
167obj-$(CONFIG_MIPS_GT96100ETH) += gt96100eth.o 168obj-$(CONFIG_MIPS_GT96100ETH) += gt96100eth.o
168obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o 169obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o
170obj-$(CONFIG_MIPS_SIM_NET) += mipsnet.o
169obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o 171obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o
170obj-$(CONFIG_DECLANCE) += declance.o 172obj-$(CONFIG_DECLANCE) += declance.o
171obj-$(CONFIG_ATARILANCE) += atarilance.o 173obj-$(CONFIG_ATARILANCE) += atarilance.o
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c
index c56d86d371a9..3d50e953faaa 100644
--- a/drivers/net/arm/am79c961a.c
+++ b/drivers/net/arm/am79c961a.c
@@ -29,6 +29,7 @@
29 29
30#include <asm/system.h> 30#include <asm/system.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/hardware.h>
32#include <asm/io.h> 33#include <asm/io.h>
33 34
34#define TX_BUFFERS 15 35#define TX_BUFFERS 15
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index c82b9cd1c924..78506911d656 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -151,13 +151,6 @@ struct au1000_private *au_macs[NUM_ETH_INTERFACES];
151 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \ 151 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
152 SUPPORTED_Autoneg 152 SUPPORTED_Autoneg
153 153
154static char *phy_link[] =
155{ "unknown",
156 "10Base2", "10BaseT",
157 "AUI",
158 "100BaseT", "100BaseTX", "100BaseFX"
159};
160
161int bcm_5201_init(struct net_device *dev, int phy_addr) 154int bcm_5201_init(struct net_device *dev, int phy_addr)
162{ 155{
163 s16 data; 156 s16 data;
@@ -785,6 +778,7 @@ static struct mii_chip_info {
785 {"Broadcom BCM5201 10/100 BaseT PHY",0x0040,0x6212, &bcm_5201_ops,0}, 778 {"Broadcom BCM5201 10/100 BaseT PHY",0x0040,0x6212, &bcm_5201_ops,0},
786 {"Broadcom BCM5221 10/100 BaseT PHY",0x0040,0x61e4, &bcm_5201_ops,0}, 779 {"Broadcom BCM5221 10/100 BaseT PHY",0x0040,0x61e4, &bcm_5201_ops,0},
787 {"Broadcom BCM5222 10/100 BaseT PHY",0x0040,0x6322, &bcm_5201_ops,1}, 780 {"Broadcom BCM5222 10/100 BaseT PHY",0x0040,0x6322, &bcm_5201_ops,1},
781 {"NS DP83847 PHY", 0x2000, 0x5c30, &bcm_5201_ops ,0},
788 {"AMD 79C901 HomePNA PHY",0x0000,0x35c8, &am79c901_ops,0}, 782 {"AMD 79C901 HomePNA PHY",0x0000,0x35c8, &am79c901_ops,0},
789 {"AMD 79C874 10/100 BaseT PHY",0x0022,0x561b, &am79c874_ops,0}, 783 {"AMD 79C874 10/100 BaseT PHY",0x0022,0x561b, &am79c874_ops,0},
790 {"LSI 80227 10/100 BaseT PHY",0x0016,0xf840, &lsi_80227_ops,0}, 784 {"LSI 80227 10/100 BaseT PHY",0x0016,0xf840, &lsi_80227_ops,0},
@@ -1045,7 +1039,7 @@ found:
1045#endif 1039#endif
1046 1040
1047 if (aup->mii->chip_info == NULL) { 1041 if (aup->mii->chip_info == NULL) {
1048 printk(KERN_ERR "%s: Au1x No MII transceivers found!\n", 1042 printk(KERN_ERR "%s: Au1x No known MII transceivers found!\n",
1049 dev->name); 1043 dev->name);
1050 return -1; 1044 return -1;
1051 } 1045 }
@@ -1546,6 +1540,9 @@ au1000_probe(u32 ioaddr, int irq, int port_num)
1546 printk(KERN_ERR "%s: out of memory\n", dev->name); 1540 printk(KERN_ERR "%s: out of memory\n", dev->name);
1547 goto err_out; 1541 goto err_out;
1548 } 1542 }
1543 aup->mii->next = NULL;
1544 aup->mii->chip_info = NULL;
1545 aup->mii->status = 0;
1549 aup->mii->mii_control_reg = 0; 1546 aup->mii->mii_control_reg = 0;
1550 aup->mii->mii_data_reg = 0; 1547 aup->mii->mii_data_reg = 0;
1551 1548
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 94939f570f78..282ebd15f011 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -106,6 +106,29 @@ static int b44_poll(struct net_device *dev, int *budget);
106static void b44_poll_controller(struct net_device *dev); 106static void b44_poll_controller(struct net_device *dev);
107#endif 107#endif
108 108
109static int dma_desc_align_mask;
110static int dma_desc_sync_size;
111
112static inline void b44_sync_dma_desc_for_device(struct pci_dev *pdev,
113 dma_addr_t dma_base,
114 unsigned long offset,
115 enum dma_data_direction dir)
116{
117 dma_sync_single_range_for_device(&pdev->dev, dma_base,
118 offset & dma_desc_align_mask,
119 dma_desc_sync_size, dir);
120}
121
122static inline void b44_sync_dma_desc_for_cpu(struct pci_dev *pdev,
123 dma_addr_t dma_base,
124 unsigned long offset,
125 enum dma_data_direction dir)
126{
127 dma_sync_single_range_for_cpu(&pdev->dev, dma_base,
128 offset & dma_desc_align_mask,
129 dma_desc_sync_size, dir);
130}
131
109static inline unsigned long br32(const struct b44 *bp, unsigned long reg) 132static inline unsigned long br32(const struct b44 *bp, unsigned long reg)
110{ 133{
111 return readl(bp->regs + reg); 134 return readl(bp->regs + reg);
@@ -668,6 +691,11 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
668 dp->ctrl = cpu_to_le32(ctrl); 691 dp->ctrl = cpu_to_le32(ctrl);
669 dp->addr = cpu_to_le32((u32) mapping + bp->rx_offset + bp->dma_offset); 692 dp->addr = cpu_to_le32((u32) mapping + bp->rx_offset + bp->dma_offset);
670 693
694 if (bp->flags & B44_FLAG_RX_RING_HACK)
695 b44_sync_dma_desc_for_device(bp->pdev, bp->rx_ring_dma,
696 dest_idx * sizeof(dp),
697 DMA_BIDIRECTIONAL);
698
671 return RX_PKT_BUF_SZ; 699 return RX_PKT_BUF_SZ;
672} 700}
673 701
@@ -692,6 +720,11 @@ static void b44_recycle_rx(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
692 pci_unmap_addr_set(dest_map, mapping, 720 pci_unmap_addr_set(dest_map, mapping,
693 pci_unmap_addr(src_map, mapping)); 721 pci_unmap_addr(src_map, mapping));
694 722
723 if (bp->flags & B44_FLAG_RX_RING_HACK)
724 b44_sync_dma_desc_for_cpu(bp->pdev, bp->rx_ring_dma,
725 src_idx * sizeof(src_desc),
726 DMA_BIDIRECTIONAL);
727
695 ctrl = src_desc->ctrl; 728 ctrl = src_desc->ctrl;
696 if (dest_idx == (B44_RX_RING_SIZE - 1)) 729 if (dest_idx == (B44_RX_RING_SIZE - 1))
697 ctrl |= cpu_to_le32(DESC_CTRL_EOT); 730 ctrl |= cpu_to_le32(DESC_CTRL_EOT);
@@ -700,8 +733,14 @@ static void b44_recycle_rx(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
700 733
701 dest_desc->ctrl = ctrl; 734 dest_desc->ctrl = ctrl;
702 dest_desc->addr = src_desc->addr; 735 dest_desc->addr = src_desc->addr;
736
703 src_map->skb = NULL; 737 src_map->skb = NULL;
704 738
739 if (bp->flags & B44_FLAG_RX_RING_HACK)
740 b44_sync_dma_desc_for_device(bp->pdev, bp->rx_ring_dma,
741 dest_idx * sizeof(dest_desc),
742 DMA_BIDIRECTIONAL);
743
705 pci_dma_sync_single_for_device(bp->pdev, src_desc->addr, 744 pci_dma_sync_single_for_device(bp->pdev, src_desc->addr,
706 RX_PKT_BUF_SZ, 745 RX_PKT_BUF_SZ,
707 PCI_DMA_FROMDEVICE); 746 PCI_DMA_FROMDEVICE);
@@ -959,6 +998,11 @@ static int b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
959 bp->tx_ring[entry].ctrl = cpu_to_le32(ctrl); 998 bp->tx_ring[entry].ctrl = cpu_to_le32(ctrl);
960 bp->tx_ring[entry].addr = cpu_to_le32((u32) mapping+bp->dma_offset); 999 bp->tx_ring[entry].addr = cpu_to_le32((u32) mapping+bp->dma_offset);
961 1000
1001 if (bp->flags & B44_FLAG_TX_RING_HACK)
1002 b44_sync_dma_desc_for_device(bp->pdev, bp->tx_ring_dma,
1003 entry * sizeof(bp->tx_ring[0]),
1004 DMA_TO_DEVICE);
1005
962 entry = NEXT_TX(entry); 1006 entry = NEXT_TX(entry);
963 1007
964 bp->tx_prod = entry; 1008 bp->tx_prod = entry;
@@ -1064,6 +1108,16 @@ static void b44_init_rings(struct b44 *bp)
1064 memset(bp->rx_ring, 0, B44_RX_RING_BYTES); 1108 memset(bp->rx_ring, 0, B44_RX_RING_BYTES);
1065 memset(bp->tx_ring, 0, B44_TX_RING_BYTES); 1109 memset(bp->tx_ring, 0, B44_TX_RING_BYTES);
1066 1110
1111 if (bp->flags & B44_FLAG_RX_RING_HACK)
1112 dma_sync_single_for_device(&bp->pdev->dev, bp->rx_ring_dma,
1113 DMA_TABLE_BYTES,
1114 PCI_DMA_BIDIRECTIONAL);
1115
1116 if (bp->flags & B44_FLAG_TX_RING_HACK)
1117 dma_sync_single_for_device(&bp->pdev->dev, bp->tx_ring_dma,
1118 DMA_TABLE_BYTES,
1119 PCI_DMA_TODEVICE);
1120
1067 for (i = 0; i < bp->rx_pending; i++) { 1121 for (i = 0; i < bp->rx_pending; i++) {
1068 if (b44_alloc_rx_skb(bp, -1, i) < 0) 1122 if (b44_alloc_rx_skb(bp, -1, i) < 0)
1069 break; 1123 break;
@@ -1085,14 +1139,28 @@ static void b44_free_consistent(struct b44 *bp)
1085 bp->tx_buffers = NULL; 1139 bp->tx_buffers = NULL;
1086 } 1140 }
1087 if (bp->rx_ring) { 1141 if (bp->rx_ring) {
1088 pci_free_consistent(bp->pdev, DMA_TABLE_BYTES, 1142 if (bp->flags & B44_FLAG_RX_RING_HACK) {
1089 bp->rx_ring, bp->rx_ring_dma); 1143 dma_unmap_single(&bp->pdev->dev, bp->rx_ring_dma,
1144 DMA_TABLE_BYTES,
1145 DMA_BIDIRECTIONAL);
1146 kfree(bp->rx_ring);
1147 } else
1148 pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
1149 bp->rx_ring, bp->rx_ring_dma);
1090 bp->rx_ring = NULL; 1150 bp->rx_ring = NULL;
1151 bp->flags &= ~B44_FLAG_RX_RING_HACK;
1091 } 1152 }
1092 if (bp->tx_ring) { 1153 if (bp->tx_ring) {
1093 pci_free_consistent(bp->pdev, DMA_TABLE_BYTES, 1154 if (bp->flags & B44_FLAG_TX_RING_HACK) {
1094 bp->tx_ring, bp->tx_ring_dma); 1155 dma_unmap_single(&bp->pdev->dev, bp->tx_ring_dma,
1156 DMA_TABLE_BYTES,
1157 DMA_TO_DEVICE);
1158 kfree(bp->tx_ring);
1159 } else
1160 pci_free_consistent(bp->pdev, DMA_TABLE_BYTES,
1161 bp->tx_ring, bp->tx_ring_dma);
1095 bp->tx_ring = NULL; 1162 bp->tx_ring = NULL;
1163 bp->flags &= ~B44_FLAG_TX_RING_HACK;
1096 } 1164 }
1097} 1165}
1098 1166
@@ -1118,12 +1186,56 @@ static int b44_alloc_consistent(struct b44 *bp)
1118 1186
1119 size = DMA_TABLE_BYTES; 1187 size = DMA_TABLE_BYTES;
1120 bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma); 1188 bp->rx_ring = pci_alloc_consistent(bp->pdev, size, &bp->rx_ring_dma);
1121 if (!bp->rx_ring) 1189 if (!bp->rx_ring) {
1122 goto out_err; 1190 /* Allocation may have failed due to pci_alloc_consistent
1191 insisting on use of GFP_DMA, which is more restrictive
1192 than necessary... */
1193 struct dma_desc *rx_ring;
1194 dma_addr_t rx_ring_dma;
1195
1196 if (!(rx_ring = (struct dma_desc *)kmalloc(size, GFP_KERNEL)))
1197 goto out_err;
1198
1199 memset(rx_ring, 0, size);
1200 rx_ring_dma = dma_map_single(&bp->pdev->dev, rx_ring,
1201 DMA_TABLE_BYTES,
1202 DMA_BIDIRECTIONAL);
1203
1204 if (rx_ring_dma + size > B44_DMA_MASK) {
1205 kfree(rx_ring);
1206 goto out_err;
1207 }
1208
1209 bp->rx_ring = rx_ring;
1210 bp->rx_ring_dma = rx_ring_dma;
1211 bp->flags |= B44_FLAG_RX_RING_HACK;
1212 }
1123 1213
1124 bp->tx_ring = pci_alloc_consistent(bp->pdev, size, &bp->tx_ring_dma); 1214 bp->tx_ring = pci_alloc_consistent(bp->pdev, size, &bp->tx_ring_dma);
1125 if (!bp->tx_ring) 1215 if (!bp->tx_ring) {
1126 goto out_err; 1216 /* Allocation may have failed due to pci_alloc_consistent
1217 insisting on use of GFP_DMA, which is more restrictive
1218 than necessary... */
1219 struct dma_desc *tx_ring;
1220 dma_addr_t tx_ring_dma;
1221
1222 if (!(tx_ring = (struct dma_desc *)kmalloc(size, GFP_KERNEL)))
1223 goto out_err;
1224
1225 memset(tx_ring, 0, size);
1226 tx_ring_dma = dma_map_single(&bp->pdev->dev, tx_ring,
1227 DMA_TABLE_BYTES,
1228 DMA_TO_DEVICE);
1229
1230 if (tx_ring_dma + size > B44_DMA_MASK) {
1231 kfree(tx_ring);
1232 goto out_err;
1233 }
1234
1235 bp->tx_ring = tx_ring;
1236 bp->tx_ring_dma = tx_ring_dma;
1237 bp->flags |= B44_FLAG_TX_RING_HACK;
1238 }
1127 1239
1128 return 0; 1240 return 0;
1129 1241
@@ -1676,6 +1788,7 @@ static struct ethtool_ops b44_ethtool_ops = {
1676 .set_pauseparam = b44_set_pauseparam, 1788 .set_pauseparam = b44_set_pauseparam,
1677 .get_msglevel = b44_get_msglevel, 1789 .get_msglevel = b44_get_msglevel,
1678 .set_msglevel = b44_set_msglevel, 1790 .set_msglevel = b44_set_msglevel,
1791 .get_perm_addr = ethtool_op_get_perm_addr,
1679}; 1792};
1680 1793
1681static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 1794static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
@@ -1718,6 +1831,7 @@ static int __devinit b44_get_invariants(struct b44 *bp)
1718 bp->dev->dev_addr[3] = eeprom[80]; 1831 bp->dev->dev_addr[3] = eeprom[80];
1719 bp->dev->dev_addr[4] = eeprom[83]; 1832 bp->dev->dev_addr[4] = eeprom[83];
1720 bp->dev->dev_addr[5] = eeprom[82]; 1833 bp->dev->dev_addr[5] = eeprom[82];
1834 memcpy(bp->dev->perm_addr, bp->dev->dev_addr, bp->dev->addr_len);
1721 1835
1722 bp->phy_addr = eeprom[90] & 0x1f; 1836 bp->phy_addr = eeprom[90] & 0x1f;
1723 1837
@@ -1971,6 +2085,12 @@ static struct pci_driver b44_driver = {
1971 2085
1972static int __init b44_init(void) 2086static int __init b44_init(void)
1973{ 2087{
2088 unsigned int dma_desc_align_size = dma_get_cache_alignment();
2089
2090 /* Setup paramaters for syncing RX/TX DMA descriptors */
2091 dma_desc_align_mask = ~(dma_desc_align_size - 1);
2092 dma_desc_sync_size = max(dma_desc_align_size, sizeof(struct dma_desc));
2093
1974 return pci_module_init(&b44_driver); 2094 return pci_module_init(&b44_driver);
1975} 2095}
1976 2096
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index 11c40a2e71c7..593cb0ad4100 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -400,6 +400,8 @@ struct b44 {
400#define B44_FLAG_ADV_100HALF 0x04000000 400#define B44_FLAG_ADV_100HALF 0x04000000
401#define B44_FLAG_ADV_100FULL 0x08000000 401#define B44_FLAG_ADV_100FULL 0x08000000
402#define B44_FLAG_INTERNAL_PHY 0x10000000 402#define B44_FLAG_INTERNAL_PHY 0x10000000
403#define B44_FLAG_RX_RING_HACK 0x20000000
404#define B44_FLAG_TX_RING_HACK 0x40000000
403 405
404 u32 rx_offset; 406 u32 rx_offset;
405 407
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f264ff162979..8032126fd589 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4241,6 +4241,43 @@ out:
4241 return 0; 4241 return 0;
4242} 4242}
4243 4243
4244static void bond_activebackup_xmit_copy(struct sk_buff *skb,
4245 struct bonding *bond,
4246 struct slave *slave)
4247{
4248 struct sk_buff *skb2 = skb_copy(skb, GFP_ATOMIC);
4249 struct ethhdr *eth_data;
4250 u8 *hwaddr;
4251 int res;
4252
4253 if (!skb2) {
4254 printk(KERN_ERR DRV_NAME ": Error: "
4255 "bond_activebackup_xmit_copy(): skb_copy() failed\n");
4256 return;
4257 }
4258
4259 skb2->mac.raw = (unsigned char *)skb2->data;
4260 eth_data = eth_hdr(skb2);
4261
4262 /* Pick an appropriate source MAC address
4263 * -- use slave's perm MAC addr, unless used by bond
4264 * -- otherwise, borrow active slave's perm MAC addr
4265 * since that will not be used
4266 */
4267 hwaddr = slave->perm_hwaddr;
4268 if (!memcmp(eth_data->h_source, hwaddr, ETH_ALEN))
4269 hwaddr = bond->curr_active_slave->perm_hwaddr;
4270
4271 /* Set source MAC address appropriately */
4272 memcpy(eth_data->h_source, hwaddr, ETH_ALEN);
4273
4274 res = bond_dev_queue_xmit(bond, skb2, slave->dev);
4275 if (res)
4276 dev_kfree_skb(skb2);
4277
4278 return;
4279}
4280
4244/* 4281/*
4245 * in active-backup mode, we know that bond->curr_active_slave is always valid if 4282 * in active-backup mode, we know that bond->curr_active_slave is always valid if
4246 * the bond has a usable interface. 4283 * the bond has a usable interface.
@@ -4257,10 +4294,26 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
4257 goto out; 4294 goto out;
4258 } 4295 }
4259 4296
4260 if (bond->curr_active_slave) { /* one usable interface */ 4297 if (!bond->curr_active_slave)
4261 res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev); 4298 goto out;
4299
4300 /* Xmit IGMP frames on all slaves to ensure rapid fail-over
4301 for multicast traffic on snooping switches */
4302 if (skb->protocol == __constant_htons(ETH_P_IP) &&
4303 skb->nh.iph->protocol == IPPROTO_IGMP) {
4304 struct slave *slave, *active_slave;
4305 int i;
4306
4307 active_slave = bond->curr_active_slave;
4308 bond_for_each_slave_from_to(bond, slave, i, active_slave->next,
4309 active_slave->prev)
4310 if (IS_UP(slave->dev) &&
4311 (slave->link == BOND_LINK_UP))
4312 bond_activebackup_xmit_copy(skb, bond, slave);
4262 } 4313 }
4263 4314
4315 res = bond_dev_queue_xmit(bond, skb, bond->curr_active_slave->dev);
4316
4264out: 4317out:
4265 if (res) { 4318 if (res) {
4266 /* no suitable interface, frame not sent */ 4319 /* no suitable interface, frame not sent */
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 2e617424d3fb..50f43dbf31ae 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -489,7 +489,7 @@ static int cas_page_free(struct cas *cp, cas_page_t *page)
489/* local page allocation routines for the receive buffers. jumbo pages 489/* local page allocation routines for the receive buffers. jumbo pages
490 * require at least 8K contiguous and 8K aligned buffers. 490 * require at least 8K contiguous and 8K aligned buffers.
491 */ 491 */
492static cas_page_t *cas_page_alloc(struct cas *cp, const int flags) 492static cas_page_t *cas_page_alloc(struct cas *cp, const gfp_t flags)
493{ 493{
494 cas_page_t *page; 494 cas_page_t *page;
495 495
@@ -561,7 +561,7 @@ static void cas_spare_free(struct cas *cp)
561} 561}
562 562
563/* replenish spares if needed */ 563/* replenish spares if needed */
564static void cas_spare_recover(struct cas *cp, const int flags) 564static void cas_spare_recover(struct cas *cp, const gfp_t flags)
565{ 565{
566 struct list_head list, *elem, *tmp; 566 struct list_head list, *elem, *tmp;
567 int needed, i; 567 int needed, i;
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index a6078ad9b654..bfdae10036ed 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -182,6 +182,10 @@ static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0};
182#define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */ 182#define CIRRUS_DEFAULT_IRQ VH_INTC_INT_NUM_CASCADED_INTERRUPT_1 /* Event inputs bank 1 - ID 35/bit 3 */
183static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0}; 183static unsigned int netcard_portlist[] __initdata = {CIRRUS_DEFAULT_BASE, 0};
184static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0}; 184static unsigned int cs8900_irq_map[] = {CIRRUS_DEFAULT_IRQ, 0, 0, 0};
185#elif defined(CONFIG_MACH_MP1000)
186#include <asm/arch/mp1000-seprom.h>
187static unsigned int netcard_portlist[] __initdata = {MP1000_EIO_BASE+0x300, 0};
188static unsigned int cs8900_irq_map[] = {IRQ_EINT3,0,0,0};
185#else 189#else
186static unsigned int netcard_portlist[] __initdata = 190static unsigned int netcard_portlist[] __initdata =
187 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0}; 191 { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -590,6 +594,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
590 cnt -= j; 594 cnt -= j;
591 } 595 }
592 } else 596 } else
597#elif defined(CONFIG_MACH_MP1000)
598 if (1) {
599 memcpy(dev->dev_addr, get_eeprom_mac_address(), ETH_ALEN);
600 } else
593#endif 601#endif
594 602
595 if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) == 603 if ((readreg(dev, PP_SelfST) & (EEPROM_OK | EEPROM_PRESENT)) ==
@@ -649,6 +657,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
649 if (1) { 657 if (1) {
650 printk(KERN_NOTICE "cs89x0: No EEPROM on HiCO.SH4\n"); 658 printk(KERN_NOTICE "cs89x0: No EEPROM on HiCO.SH4\n");
651 } else 659 } else
660#elif defined(CONFIG_MACH_MP1000)
661 if (1) {
662 lp->force |= FORCE_RJ45;
663 } else
652#endif 664#endif
653 if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0) 665 if ((readreg(dev, PP_SelfST) & EEPROM_PRESENT) == 0)
654 printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n"); 666 printk(KERN_WARNING "cs89x0: No EEPROM, relying on command line....\n");
@@ -1231,7 +1243,7 @@ net_open(struct net_device *dev)
1231 else 1243 else
1232#endif 1244#endif
1233 { 1245 {
1234#if !defined(CONFIG_ARCH_IXDP2X01) && !defined(CONFIG_ARCH_PNX0105) 1246#if !defined(CONFIG_ARCH_IXDP2X01) && !defined(CONFIG_ARCH_PNX0105) && !defined(CONFIG_MACH_MP1000)
1235 if (((1 << dev->irq) & lp->irq_map) == 0) { 1247 if (((1 << dev->irq) & lp->irq_map) == 0) {
1236 printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", 1248 printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
1237 dev->name, dev->irq, lp->irq_map); 1249 dev->name, dev->irq, lp->irq_map);
diff --git a/drivers/net/cs89x0.h b/drivers/net/cs89x0.h
index decea264f121..f19d1ebe0183 100644
--- a/drivers/net/cs89x0.h
+++ b/drivers/net/cs89x0.h
@@ -16,7 +16,7 @@
16 16
17#include <linux/config.h> 17#include <linux/config.h>
18 18
19#if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105) 19#if defined(CONFIG_ARCH_IXDP2X01) || defined(CONFIG_ARCH_PNX0105) || defined (CONFIG_MACH_MP1000)
20/* IXDP2401/IXDP2801 uses dword-aligned register addressing */ 20/* IXDP2401/IXDP2801 uses dword-aligned register addressing */
21#define CS89x0_PORT(reg) ((reg) * 2) 21#define CS89x0_PORT(reg) ((reg) * 2)
22#else 22#else
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 521c83137bf6..f130bdab3fd3 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * adopted from sunlance.c by Richard van den Berg 6 * adopted from sunlance.c by Richard van den Berg
7 * 7 *
8 * Copyright (C) 2002, 2003 Maciej W. Rozycki 8 * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki
9 * 9 *
10 * additional sources: 10 * additional sources:
11 * - PMAD-AA TURBOchannel Ethernet Module Functional Specification, 11 * - PMAD-AA TURBOchannel Ethernet Module Functional Specification,
@@ -57,13 +57,15 @@
57#include <linux/string.h> 57#include <linux/string.h>
58 58
59#include <asm/addrspace.h> 59#include <asm/addrspace.h>
60#include <asm/system.h>
61
60#include <asm/dec/interrupts.h> 62#include <asm/dec/interrupts.h>
61#include <asm/dec/ioasic.h> 63#include <asm/dec/ioasic.h>
62#include <asm/dec/ioasic_addrs.h> 64#include <asm/dec/ioasic_addrs.h>
63#include <asm/dec/kn01.h> 65#include <asm/dec/kn01.h>
64#include <asm/dec/machtype.h> 66#include <asm/dec/machtype.h>
67#include <asm/dec/system.h>
65#include <asm/dec/tc.h> 68#include <asm/dec/tc.h>
66#include <asm/system.h>
67 69
68static char version[] __devinitdata = 70static char version[] __devinitdata =
69"declance.c: v0.009 by Linux MIPS DECstation task force\n"; 71"declance.c: v0.009 by Linux MIPS DECstation task force\n";
@@ -79,10 +81,6 @@ MODULE_LICENSE("GPL");
79#define PMAD_LANCE 2 81#define PMAD_LANCE 2
80#define PMAX_LANCE 3 82#define PMAX_LANCE 3
81 83
82#ifndef CONFIG_TC
83unsigned long system_base;
84unsigned long dmaptr;
85#endif
86 84
87#define LE_CSR0 0 85#define LE_CSR0 0
88#define LE_CSR1 1 86#define LE_CSR1 1
@@ -237,7 +235,7 @@ struct lance_init_block {
237/* 235/*
238 * This works *only* for the ring descriptors 236 * This works *only* for the ring descriptors
239 */ 237 */
240#define LANCE_ADDR(x) (PHYSADDR(x) >> 1) 238#define LANCE_ADDR(x) (CPHYSADDR(x) >> 1)
241 239
242struct lance_private { 240struct lance_private {
243 struct net_device *next; 241 struct net_device *next;
@@ -697,12 +695,13 @@ out:
697 spin_unlock(&lp->lock); 695 spin_unlock(&lp->lock);
698} 696}
699 697
700static void lance_dma_merr_int(const int irq, void *dev_id, 698static irqreturn_t lance_dma_merr_int(const int irq, void *dev_id,
701 struct pt_regs *regs) 699 struct pt_regs *regs)
702{ 700{
703 struct net_device *dev = (struct net_device *) dev_id; 701 struct net_device *dev = (struct net_device *) dev_id;
704 702
705 printk("%s: DMA error\n", dev->name); 703 printk("%s: DMA error\n", dev->name);
704 return IRQ_HANDLED;
706} 705}
707 706
708static irqreturn_t 707static irqreturn_t
@@ -1026,10 +1025,6 @@ static int __init dec_lance_init(const int type, const int slot)
1026 unsigned long esar_base; 1025 unsigned long esar_base;
1027 unsigned char *esar; 1026 unsigned char *esar;
1028 1027
1029#ifndef CONFIG_TC
1030 system_base = KN01_LANCE_BASE;
1031#endif
1032
1033 if (dec_lance_debug && version_printed++ == 0) 1028 if (dec_lance_debug && version_printed++ == 0)
1034 printk(version); 1029 printk(version);
1035 1030
@@ -1062,16 +1057,16 @@ static int __init dec_lance_init(const int type, const int slot)
1062 switch (type) { 1057 switch (type) {
1063#ifdef CONFIG_TC 1058#ifdef CONFIG_TC
1064 case ASIC_LANCE: 1059 case ASIC_LANCE:
1065 dev->base_addr = system_base + IOASIC_LANCE; 1060 dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE);
1066 1061
1067 /* buffer space for the on-board LANCE shared memory */ 1062 /* buffer space for the on-board LANCE shared memory */
1068 /* 1063 /*
1069 * FIXME: ugly hack! 1064 * FIXME: ugly hack!
1070 */ 1065 */
1071 dev->mem_start = KSEG1ADDR(0x00020000); 1066 dev->mem_start = CKSEG1ADDR(0x00020000);
1072 dev->mem_end = dev->mem_start + 0x00020000; 1067 dev->mem_end = dev->mem_start + 0x00020000;
1073 dev->irq = dec_interrupt[DEC_IRQ_LANCE]; 1068 dev->irq = dec_interrupt[DEC_IRQ_LANCE];
1074 esar_base = system_base + IOASIC_ESAR; 1069 esar_base = CKSEG1ADDR(dec_kn_slot_base + IOASIC_ESAR);
1075 1070
1076 /* Workaround crash with booting KN04 2.1k from Disk */ 1071 /* Workaround crash with booting KN04 2.1k from Disk */
1077 memset((void *)dev->mem_start, 0, 1072 memset((void *)dev->mem_start, 0,
@@ -1101,14 +1096,14 @@ static int __init dec_lance_init(const int type, const int slot)
1101 /* Setup I/O ASIC LANCE DMA. */ 1096 /* Setup I/O ASIC LANCE DMA. */
1102 lp->dma_irq = dec_interrupt[DEC_IRQ_LANCE_MERR]; 1097 lp->dma_irq = dec_interrupt[DEC_IRQ_LANCE_MERR];
1103 ioasic_write(IO_REG_LANCE_DMA_P, 1098 ioasic_write(IO_REG_LANCE_DMA_P,
1104 PHYSADDR(dev->mem_start) << 3); 1099 CPHYSADDR(dev->mem_start) << 3);
1105 1100
1106 break; 1101 break;
1107 1102
1108 case PMAD_LANCE: 1103 case PMAD_LANCE:
1109 claim_tc_card(slot); 1104 claim_tc_card(slot);
1110 1105
1111 dev->mem_start = get_tc_base_addr(slot); 1106 dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot));
1112 dev->base_addr = dev->mem_start + 0x100000; 1107 dev->base_addr = dev->mem_start + 0x100000;
1113 dev->irq = get_tc_irq_nr(slot); 1108 dev->irq = get_tc_irq_nr(slot);
1114 esar_base = dev->mem_start + 0x1c0002; 1109 esar_base = dev->mem_start + 0x1c0002;
@@ -1137,9 +1132,9 @@ static int __init dec_lance_init(const int type, const int slot)
1137 1132
1138 case PMAX_LANCE: 1133 case PMAX_LANCE:
1139 dev->irq = dec_interrupt[DEC_IRQ_LANCE]; 1134 dev->irq = dec_interrupt[DEC_IRQ_LANCE];
1140 dev->base_addr = KN01_LANCE_BASE; 1135 dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE);
1141 dev->mem_start = KN01_LANCE_BASE + 0x01000000; 1136 dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM);
1142 esar_base = KN01_RTC_BASE + 1; 1137 esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1);
1143 lp->dma_irq = -1; 1138 lp->dma_irq = -1;
1144 1139
1145 /* 1140 /*
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index e54fc10f6846..abce1f730d00 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -1140,11 +1140,11 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1140} 1140}
1141 1141
1142static int 1142static int
1143dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level) 1143dm9000_drv_suspend(struct device *dev, pm_message_t state)
1144{ 1144{
1145 struct net_device *ndev = dev_get_drvdata(dev); 1145 struct net_device *ndev = dev_get_drvdata(dev);
1146 1146
1147 if (ndev && level == SUSPEND_DISABLE) { 1147 if (ndev) {
1148 if (netif_running(ndev)) { 1148 if (netif_running(ndev)) {
1149 netif_device_detach(ndev); 1149 netif_device_detach(ndev);
1150 dm9000_shutdown(ndev); 1150 dm9000_shutdown(ndev);
@@ -1154,12 +1154,12 @@ dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level)
1154} 1154}
1155 1155
1156static int 1156static int
1157dm9000_drv_resume(struct device *dev, u32 level) 1157dm9000_drv_resume(struct device *dev)
1158{ 1158{
1159 struct net_device *ndev = dev_get_drvdata(dev); 1159 struct net_device *ndev = dev_get_drvdata(dev);
1160 board_info_t *db = (board_info_t *) ndev->priv; 1160 board_info_t *db = (board_info_t *) ndev->priv;
1161 1161
1162 if (ndev && level == RESUME_ENABLE) { 1162 if (ndev) {
1163 1163
1164 if (netif_running(ndev)) { 1164 if (netif_running(ndev)) {
1165 dm9000_reset(db); 1165 dm9000_reset(db);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 40887f09b681..eb169a8e8773 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2201,6 +2201,7 @@ static struct ethtool_ops e100_ethtool_ops = {
2201 .phys_id = e100_phys_id, 2201 .phys_id = e100_phys_id,
2202 .get_stats_count = e100_get_stats_count, 2202 .get_stats_count = e100_get_stats_count,
2203 .get_ethtool_stats = e100_get_ethtool_stats, 2203 .get_ethtool_stats = e100_get_ethtool_stats,
2204 .get_perm_addr = ethtool_op_get_perm_addr,
2204}; 2205};
2205 2206
2206static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 2207static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
@@ -2351,7 +2352,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2351 e100_phy_init(nic); 2352 e100_phy_init(nic);
2352 2353
2353 memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN); 2354 memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN);
2354 if(!is_valid_ether_addr(netdev->dev_addr)) { 2355 memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN);
2356 if(!is_valid_ether_addr(netdev->perm_addr)) {
2355 DPRINTK(PROBE, ERR, "Invalid MAC address from " 2357 DPRINTK(PROBE, ERR, "Invalid MAC address from "
2356 "EEPROM, aborting.\n"); 2358 "EEPROM, aborting.\n");
2357 err = -EAGAIN; 2359 err = -EAGAIN;
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 092757bc721f..3f653a93e1bc 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -72,6 +72,10 @@
72#include <linux/mii.h> 72#include <linux/mii.h>
73#include <linux/ethtool.h> 73#include <linux/ethtool.h>
74#include <linux/if_vlan.h> 74#include <linux/if_vlan.h>
75#ifdef CONFIG_E1000_MQ
76#include <linux/cpu.h>
77#include <linux/smp.h>
78#endif
75 79
76#define BAR_0 0 80#define BAR_0 0
77#define BAR_1 1 81#define BAR_1 1
@@ -165,10 +169,33 @@ struct e1000_buffer {
165 uint16_t next_to_watch; 169 uint16_t next_to_watch;
166}; 170};
167 171
168struct e1000_ps_page { struct page *ps_page[MAX_PS_BUFFERS]; }; 172struct e1000_ps_page { struct page *ps_page[PS_PAGE_BUFFERS]; };
169struct e1000_ps_page_dma { uint64_t ps_page_dma[MAX_PS_BUFFERS]; }; 173struct e1000_ps_page_dma { uint64_t ps_page_dma[PS_PAGE_BUFFERS]; };
174
175struct e1000_tx_ring {
176 /* pointer to the descriptor ring memory */
177 void *desc;
178 /* physical address of the descriptor ring */
179 dma_addr_t dma;
180 /* length of descriptor ring in bytes */
181 unsigned int size;
182 /* number of descriptors in the ring */
183 unsigned int count;
184 /* next descriptor to associate a buffer with */
185 unsigned int next_to_use;
186 /* next descriptor to check for DD status bit */
187 unsigned int next_to_clean;
188 /* array of buffer information structs */
189 struct e1000_buffer *buffer_info;
190
191 struct e1000_buffer previous_buffer_info;
192 spinlock_t tx_lock;
193 uint16_t tdh;
194 uint16_t tdt;
195 uint64_t pkt;
196};
170 197
171struct e1000_desc_ring { 198struct e1000_rx_ring {
172 /* pointer to the descriptor ring memory */ 199 /* pointer to the descriptor ring memory */
173 void *desc; 200 void *desc;
174 /* physical address of the descriptor ring */ 201 /* physical address of the descriptor ring */
@@ -186,6 +213,10 @@ struct e1000_desc_ring {
186 /* arrays of page information for packet split */ 213 /* arrays of page information for packet split */
187 struct e1000_ps_page *ps_page; 214 struct e1000_ps_page *ps_page;
188 struct e1000_ps_page_dma *ps_page_dma; 215 struct e1000_ps_page_dma *ps_page_dma;
216
217 uint16_t rdh;
218 uint16_t rdt;
219 uint64_t pkt;
189}; 220};
190 221
191#define E1000_DESC_UNUSED(R) \ 222#define E1000_DESC_UNUSED(R) \
@@ -227,9 +258,10 @@ struct e1000_adapter {
227 unsigned long led_status; 258 unsigned long led_status;
228 259
229 /* TX */ 260 /* TX */
230 struct e1000_desc_ring tx_ring; 261 struct e1000_tx_ring *tx_ring; /* One per active queue */
231 struct e1000_buffer previous_buffer_info; 262#ifdef CONFIG_E1000_MQ
232 spinlock_t tx_lock; 263 struct e1000_tx_ring **cpu_tx_ring; /* per-cpu */
264#endif
233 uint32_t txd_cmd; 265 uint32_t txd_cmd;
234 uint32_t tx_int_delay; 266 uint32_t tx_int_delay;
235 uint32_t tx_abs_int_delay; 267 uint32_t tx_abs_int_delay;
@@ -246,19 +278,33 @@ struct e1000_adapter {
246 278
247 /* RX */ 279 /* RX */
248#ifdef CONFIG_E1000_NAPI 280#ifdef CONFIG_E1000_NAPI
249 boolean_t (*clean_rx) (struct e1000_adapter *adapter, int *work_done, 281 boolean_t (*clean_rx) (struct e1000_adapter *adapter,
250 int work_to_do); 282 struct e1000_rx_ring *rx_ring,
283 int *work_done, int work_to_do);
251#else 284#else
252 boolean_t (*clean_rx) (struct e1000_adapter *adapter); 285 boolean_t (*clean_rx) (struct e1000_adapter *adapter,
286 struct e1000_rx_ring *rx_ring);
253#endif 287#endif
254 void (*alloc_rx_buf) (struct e1000_adapter *adapter); 288 void (*alloc_rx_buf) (struct e1000_adapter *adapter,
255 struct e1000_desc_ring rx_ring; 289 struct e1000_rx_ring *rx_ring);
290 struct e1000_rx_ring *rx_ring; /* One per active queue */
291#ifdef CONFIG_E1000_NAPI
292 struct net_device *polling_netdev; /* One per active queue */
293#endif
294#ifdef CONFIG_E1000_MQ
295 struct net_device **cpu_netdev; /* per-cpu */
296 struct call_async_data_struct rx_sched_call_data;
297 int cpu_for_queue[4];
298#endif
299 int num_queues;
300
256 uint64_t hw_csum_err; 301 uint64_t hw_csum_err;
257 uint64_t hw_csum_good; 302 uint64_t hw_csum_good;
303 uint64_t rx_hdr_split;
258 uint32_t rx_int_delay; 304 uint32_t rx_int_delay;
259 uint32_t rx_abs_int_delay; 305 uint32_t rx_abs_int_delay;
260 boolean_t rx_csum; 306 boolean_t rx_csum;
261 boolean_t rx_ps; 307 unsigned int rx_ps_pages;
262 uint32_t gorcl; 308 uint32_t gorcl;
263 uint64_t gorcl_old; 309 uint64_t gorcl_old;
264 uint16_t rx_ps_bsize0; 310 uint16_t rx_ps_bsize0;
@@ -278,8 +324,8 @@ struct e1000_adapter {
278 struct e1000_phy_stats phy_stats; 324 struct e1000_phy_stats phy_stats;
279 325
280 uint32_t test_icr; 326 uint32_t test_icr;
281 struct e1000_desc_ring test_tx_ring; 327 struct e1000_tx_ring test_tx_ring;
282 struct e1000_desc_ring test_rx_ring; 328 struct e1000_rx_ring test_rx_ring;
283 329
284 330
285 int msg_enable; 331 int msg_enable;
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index f133ff0b0b94..6b9acc7f94a3 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -39,10 +39,10 @@ extern int e1000_up(struct e1000_adapter *adapter);
39extern void e1000_down(struct e1000_adapter *adapter); 39extern void e1000_down(struct e1000_adapter *adapter);
40extern void e1000_reset(struct e1000_adapter *adapter); 40extern void e1000_reset(struct e1000_adapter *adapter);
41extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx); 41extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
42extern int e1000_setup_rx_resources(struct e1000_adapter *adapter); 42extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
43extern int e1000_setup_tx_resources(struct e1000_adapter *adapter); 43extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
44extern void e1000_free_rx_resources(struct e1000_adapter *adapter); 44extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
45extern void e1000_free_tx_resources(struct e1000_adapter *adapter); 45extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
46extern void e1000_update_stats(struct e1000_adapter *adapter); 46extern void e1000_update_stats(struct e1000_adapter *adapter);
47 47
48struct e1000_stats { 48struct e1000_stats {
@@ -91,7 +91,8 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
91 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) }, 91 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
92 { "rx_long_byte_count", E1000_STAT(stats.gorcl) }, 92 { "rx_long_byte_count", E1000_STAT(stats.gorcl) },
93 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) }, 93 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
94 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) } 94 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
95 { "rx_header_split", E1000_STAT(rx_hdr_split) },
95}; 96};
96#define E1000_STATS_LEN \ 97#define E1000_STATS_LEN \
97 sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats) 98 sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
@@ -546,8 +547,10 @@ e1000_set_eeprom(struct net_device *netdev,
546 ret_val = e1000_write_eeprom(hw, first_word, 547 ret_val = e1000_write_eeprom(hw, first_word,
547 last_word - first_word + 1, eeprom_buff); 548 last_word - first_word + 1, eeprom_buff);
548 549
549 /* Update the checksum over the first part of the EEPROM if needed */ 550 /* Update the checksum over the first part of the EEPROM if needed
550 if((ret_val == 0) && first_word <= EEPROM_CHECKSUM_REG) 551 * and flush shadow RAM for 82573 conrollers */
552 if((ret_val == 0) && ((first_word <= EEPROM_CHECKSUM_REG) ||
553 (hw->mac_type == e1000_82573)))
551 e1000_update_eeprom_checksum(hw); 554 e1000_update_eeprom_checksum(hw);
552 555
553 kfree(eeprom_buff); 556 kfree(eeprom_buff);
@@ -576,8 +579,8 @@ e1000_get_ringparam(struct net_device *netdev,
576{ 579{
577 struct e1000_adapter *adapter = netdev_priv(netdev); 580 struct e1000_adapter *adapter = netdev_priv(netdev);
578 e1000_mac_type mac_type = adapter->hw.mac_type; 581 e1000_mac_type mac_type = adapter->hw.mac_type;
579 struct e1000_desc_ring *txdr = &adapter->tx_ring; 582 struct e1000_tx_ring *txdr = adapter->tx_ring;
580 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 583 struct e1000_rx_ring *rxdr = adapter->rx_ring;
581 584
582 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD : 585 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
583 E1000_MAX_82544_RXD; 586 E1000_MAX_82544_RXD;
@@ -597,20 +600,40 @@ e1000_set_ringparam(struct net_device *netdev,
597{ 600{
598 struct e1000_adapter *adapter = netdev_priv(netdev); 601 struct e1000_adapter *adapter = netdev_priv(netdev);
599 e1000_mac_type mac_type = adapter->hw.mac_type; 602 e1000_mac_type mac_type = adapter->hw.mac_type;
600 struct e1000_desc_ring *txdr = &adapter->tx_ring; 603 struct e1000_tx_ring *txdr, *tx_old, *tx_new;
601 struct e1000_desc_ring *rxdr = &adapter->rx_ring; 604 struct e1000_rx_ring *rxdr, *rx_old, *rx_new;
602 struct e1000_desc_ring tx_old, tx_new, rx_old, rx_new; 605 int i, err, tx_ring_size, rx_ring_size;
603 int err; 606
607 tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_queues;
608 rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_queues;
609
610 if (netif_running(adapter->netdev))
611 e1000_down(adapter);
604 612
605 tx_old = adapter->tx_ring; 613 tx_old = adapter->tx_ring;
606 rx_old = adapter->rx_ring; 614 rx_old = adapter->rx_ring;
607 615
616 adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
617 if (!adapter->tx_ring) {
618 err = -ENOMEM;
619 goto err_setup_rx;
620 }
621 memset(adapter->tx_ring, 0, tx_ring_size);
622
623 adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
624 if (!adapter->rx_ring) {
625 kfree(adapter->tx_ring);
626 err = -ENOMEM;
627 goto err_setup_rx;
628 }
629 memset(adapter->rx_ring, 0, rx_ring_size);
630
631 txdr = adapter->tx_ring;
632 rxdr = adapter->rx_ring;
633
608 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 634 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
609 return -EINVAL; 635 return -EINVAL;
610 636
611 if(netif_running(adapter->netdev))
612 e1000_down(adapter);
613
614 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD); 637 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
615 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ? 638 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
616 E1000_MAX_RXD : E1000_MAX_82544_RXD)); 639 E1000_MAX_RXD : E1000_MAX_82544_RXD));
@@ -621,11 +644,16 @@ e1000_set_ringparam(struct net_device *netdev,
621 E1000_MAX_TXD : E1000_MAX_82544_TXD)); 644 E1000_MAX_TXD : E1000_MAX_82544_TXD));
622 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE); 645 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
623 646
647 for (i = 0; i < adapter->num_queues; i++) {
648 txdr[i].count = txdr->count;
649 rxdr[i].count = rxdr->count;
650 }
651
624 if(netif_running(adapter->netdev)) { 652 if(netif_running(adapter->netdev)) {
625 /* Try to get new resources before deleting old */ 653 /* Try to get new resources before deleting old */
626 if((err = e1000_setup_rx_resources(adapter))) 654 if ((err = e1000_setup_all_rx_resources(adapter)))
627 goto err_setup_rx; 655 goto err_setup_rx;
628 if((err = e1000_setup_tx_resources(adapter))) 656 if ((err = e1000_setup_all_tx_resources(adapter)))
629 goto err_setup_tx; 657 goto err_setup_tx;
630 658
631 /* save the new, restore the old in order to free it, 659 /* save the new, restore the old in order to free it,
@@ -635,8 +663,10 @@ e1000_set_ringparam(struct net_device *netdev,
635 tx_new = adapter->tx_ring; 663 tx_new = adapter->tx_ring;
636 adapter->rx_ring = rx_old; 664 adapter->rx_ring = rx_old;
637 adapter->tx_ring = tx_old; 665 adapter->tx_ring = tx_old;
638 e1000_free_rx_resources(adapter); 666 e1000_free_all_rx_resources(adapter);
639 e1000_free_tx_resources(adapter); 667 e1000_free_all_tx_resources(adapter);
668 kfree(tx_old);
669 kfree(rx_old);
640 adapter->rx_ring = rx_new; 670 adapter->rx_ring = rx_new;
641 adapter->tx_ring = tx_new; 671 adapter->tx_ring = tx_new;
642 if((err = e1000_up(adapter))) 672 if((err = e1000_up(adapter)))
@@ -645,7 +675,7 @@ e1000_set_ringparam(struct net_device *netdev,
645 675
646 return 0; 676 return 0;
647err_setup_tx: 677err_setup_tx:
648 e1000_free_rx_resources(adapter); 678 e1000_free_all_rx_resources(adapter);
649err_setup_rx: 679err_setup_rx:
650 adapter->rx_ring = rx_old; 680 adapter->rx_ring = rx_old;
651 adapter->tx_ring = tx_old; 681 adapter->tx_ring = tx_old;
@@ -696,6 +726,11 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
696 * Some bits that get toggled are ignored. 726 * Some bits that get toggled are ignored.
697 */ 727 */
698 switch (adapter->hw.mac_type) { 728 switch (adapter->hw.mac_type) {
729 /* there are several bits on newer hardware that are r/w */
730 case e1000_82571:
731 case e1000_82572:
732 toggle = 0x7FFFF3FF;
733 break;
699 case e1000_82573: 734 case e1000_82573:
700 toggle = 0x7FFFF033; 735 toggle = 0x7FFFF033;
701 break; 736 break;
@@ -898,8 +933,8 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
898static void 933static void
899e1000_free_desc_rings(struct e1000_adapter *adapter) 934e1000_free_desc_rings(struct e1000_adapter *adapter)
900{ 935{
901 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 936 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
902 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 937 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
903 struct pci_dev *pdev = adapter->pdev; 938 struct pci_dev *pdev = adapter->pdev;
904 int i; 939 int i;
905 940
@@ -941,8 +976,8 @@ e1000_free_desc_rings(struct e1000_adapter *adapter)
941static int 976static int
942e1000_setup_desc_rings(struct e1000_adapter *adapter) 977e1000_setup_desc_rings(struct e1000_adapter *adapter)
943{ 978{
944 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 979 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
945 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 980 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
946 struct pci_dev *pdev = adapter->pdev; 981 struct pci_dev *pdev = adapter->pdev;
947 uint32_t rctl; 982 uint32_t rctl;
948 int size, i, ret_val; 983 int size, i, ret_val;
@@ -1245,6 +1280,8 @@ e1000_set_phy_loopback(struct e1000_adapter *adapter)
1245 case e1000_82541_rev_2: 1280 case e1000_82541_rev_2:
1246 case e1000_82547: 1281 case e1000_82547:
1247 case e1000_82547_rev_2: 1282 case e1000_82547_rev_2:
1283 case e1000_82571:
1284 case e1000_82572:
1248 case e1000_82573: 1285 case e1000_82573:
1249 return e1000_integrated_phy_loopback(adapter); 1286 return e1000_integrated_phy_loopback(adapter);
1250 break; 1287 break;
@@ -1340,8 +1377,8 @@ e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1340static int 1377static int
1341e1000_run_loopback_test(struct e1000_adapter *adapter) 1378e1000_run_loopback_test(struct e1000_adapter *adapter)
1342{ 1379{
1343 struct e1000_desc_ring *txdr = &adapter->test_tx_ring; 1380 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1344 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring; 1381 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1345 struct pci_dev *pdev = adapter->pdev; 1382 struct pci_dev *pdev = adapter->pdev;
1346 int i, j, k, l, lc, good_cnt, ret_val=0; 1383 int i, j, k, l, lc, good_cnt, ret_val=0;
1347 unsigned long time; 1384 unsigned long time;
@@ -1509,6 +1546,7 @@ e1000_diag_test(struct net_device *netdev,
1509 data[2] = 0; 1546 data[2] = 0;
1510 data[3] = 0; 1547 data[3] = 0;
1511 } 1548 }
1549 msleep_interruptible(4 * 1000);
1512} 1550}
1513 1551
1514static void 1552static void
@@ -1625,7 +1663,7 @@ e1000_phys_id(struct net_device *netdev, uint32_t data)
1625 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ)) 1663 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
1626 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ); 1664 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
1627 1665
1628 if(adapter->hw.mac_type < e1000_82573) { 1666 if(adapter->hw.mac_type < e1000_82571) {
1629 if(!adapter->blink_timer.function) { 1667 if(!adapter->blink_timer.function) {
1630 init_timer(&adapter->blink_timer); 1668 init_timer(&adapter->blink_timer);
1631 adapter->blink_timer.function = e1000_led_blink_callback; 1669 adapter->blink_timer.function = e1000_led_blink_callback;
@@ -1739,6 +1777,7 @@ struct ethtool_ops e1000_ethtool_ops = {
1739 .phys_id = e1000_phys_id, 1777 .phys_id = e1000_phys_id,
1740 .get_stats_count = e1000_get_stats_count, 1778 .get_stats_count = e1000_get_stats_count,
1741 .get_ethtool_stats = e1000_get_ethtool_stats, 1779 .get_ethtool_stats = e1000_get_ethtool_stats,
1780 .get_perm_addr = ethtool_op_get_perm_addr,
1742}; 1781};
1743 1782
1744void e1000_set_ethtool_ops(struct net_device *netdev) 1783void e1000_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 045f5426ab9a..8fc876da43b4 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -83,14 +83,14 @@ uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] =
83 83
84static const 84static const
85uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] = 85uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] =
86 { 8, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 86 { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
87 22, 24, 27, 30, 32, 35, 37, 40, 42, 44, 47, 49, 51, 54, 56, 58, 87 0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
88 32, 35, 38, 41, 44, 47, 50, 53, 55, 58, 61, 63, 66, 69, 71, 74, 88 6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
89 43, 47, 51, 54, 58, 61, 64, 67, 71, 74, 77, 80, 82, 85, 88, 90, 89 21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
90 57, 62, 66, 70, 74, 77, 81, 85, 88, 91, 94, 97, 100, 103, 106, 108, 90 40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
91 73, 78, 82, 87, 91, 95, 98, 102, 105, 109, 112, 114, 117, 119, 122, 124, 91 60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
92 91, 96, 101, 105, 109, 113, 116, 119, 122, 125, 127, 128, 128, 128, 128, 128, 92 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
93 108, 113, 117, 121, 124, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}; 93 104, 109, 114, 118, 121, 124};
94 94
95 95
96/****************************************************************************** 96/******************************************************************************
@@ -286,7 +286,6 @@ e1000_set_mac_type(struct e1000_hw *hw)
286 case E1000_DEV_ID_82546GB_FIBER: 286 case E1000_DEV_ID_82546GB_FIBER:
287 case E1000_DEV_ID_82546GB_SERDES: 287 case E1000_DEV_ID_82546GB_SERDES:
288 case E1000_DEV_ID_82546GB_PCIE: 288 case E1000_DEV_ID_82546GB_PCIE:
289 case E1000_DEV_ID_82546GB_QUAD_COPPER:
290 hw->mac_type = e1000_82546_rev_3; 289 hw->mac_type = e1000_82546_rev_3;
291 break; 290 break;
292 case E1000_DEV_ID_82541EI: 291 case E1000_DEV_ID_82541EI:
@@ -305,8 +304,19 @@ e1000_set_mac_type(struct e1000_hw *hw)
305 case E1000_DEV_ID_82547GI: 304 case E1000_DEV_ID_82547GI:
306 hw->mac_type = e1000_82547_rev_2; 305 hw->mac_type = e1000_82547_rev_2;
307 break; 306 break;
307 case E1000_DEV_ID_82571EB_COPPER:
308 case E1000_DEV_ID_82571EB_FIBER:
309 case E1000_DEV_ID_82571EB_SERDES:
310 hw->mac_type = e1000_82571;
311 break;
312 case E1000_DEV_ID_82572EI_COPPER:
313 case E1000_DEV_ID_82572EI_FIBER:
314 case E1000_DEV_ID_82572EI_SERDES:
315 hw->mac_type = e1000_82572;
316 break;
308 case E1000_DEV_ID_82573E: 317 case E1000_DEV_ID_82573E:
309 case E1000_DEV_ID_82573E_IAMT: 318 case E1000_DEV_ID_82573E_IAMT:
319 case E1000_DEV_ID_82573L:
310 hw->mac_type = e1000_82573; 320 hw->mac_type = e1000_82573;
311 break; 321 break;
312 default: 322 default:
@@ -315,6 +325,8 @@ e1000_set_mac_type(struct e1000_hw *hw)
315 } 325 }
316 326
317 switch(hw->mac_type) { 327 switch(hw->mac_type) {
328 case e1000_82571:
329 case e1000_82572:
318 case e1000_82573: 330 case e1000_82573:
319 hw->eeprom_semaphore_present = TRUE; 331 hw->eeprom_semaphore_present = TRUE;
320 /* fall through */ 332 /* fall through */
@@ -351,6 +363,8 @@ e1000_set_media_type(struct e1000_hw *hw)
351 switch (hw->device_id) { 363 switch (hw->device_id) {
352 case E1000_DEV_ID_82545GM_SERDES: 364 case E1000_DEV_ID_82545GM_SERDES:
353 case E1000_DEV_ID_82546GB_SERDES: 365 case E1000_DEV_ID_82546GB_SERDES:
366 case E1000_DEV_ID_82571EB_SERDES:
367 case E1000_DEV_ID_82572EI_SERDES:
354 hw->media_type = e1000_media_type_internal_serdes; 368 hw->media_type = e1000_media_type_internal_serdes;
355 break; 369 break;
356 default: 370 default:
@@ -523,6 +537,8 @@ e1000_reset_hw(struct e1000_hw *hw)
523 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 537 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
524 E1000_WRITE_FLUSH(hw); 538 E1000_WRITE_FLUSH(hw);
525 /* fall through */ 539 /* fall through */
540 case e1000_82571:
541 case e1000_82572:
526 ret_val = e1000_get_auto_rd_done(hw); 542 ret_val = e1000_get_auto_rd_done(hw);
527 if(ret_val) 543 if(ret_val)
528 /* We don't want to continue accessing MAC registers. */ 544 /* We don't want to continue accessing MAC registers. */
@@ -683,6 +699,9 @@ e1000_init_hw(struct e1000_hw *hw)
683 switch (hw->mac_type) { 699 switch (hw->mac_type) {
684 default: 700 default:
685 break; 701 break;
702 case e1000_82571:
703 case e1000_82572:
704 ctrl |= (1 << 22);
686 case e1000_82573: 705 case e1000_82573:
687 ctrl |= E1000_TXDCTL_COUNT_DESC; 706 ctrl |= E1000_TXDCTL_COUNT_DESC;
688 break; 707 break;
@@ -694,6 +713,26 @@ e1000_init_hw(struct e1000_hw *hw)
694 e1000_enable_tx_pkt_filtering(hw); 713 e1000_enable_tx_pkt_filtering(hw);
695 } 714 }
696 715
716 switch (hw->mac_type) {
717 default:
718 break;
719 case e1000_82571:
720 case e1000_82572:
721 ctrl = E1000_READ_REG(hw, TXDCTL1);
722 ctrl &= ~E1000_TXDCTL_WTHRESH;
723 ctrl |= E1000_TXDCTL_COUNT_DESC | E1000_TXDCTL_FULL_TX_DESC_WB;
724 ctrl |= (1 << 22);
725 E1000_WRITE_REG(hw, TXDCTL1, ctrl);
726 break;
727 }
728
729
730
731 if (hw->mac_type == e1000_82573) {
732 uint32_t gcr = E1000_READ_REG(hw, GCR);
733 gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
734 E1000_WRITE_REG(hw, GCR, gcr);
735 }
697 736
698 /* Clear all of the statistics registers (clear on read). It is 737 /* Clear all of the statistics registers (clear on read). It is
699 * important that we do this after we have tried to establish link 738 * important that we do this after we have tried to establish link
@@ -878,6 +917,14 @@ e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
878 917
879 DEBUGFUNC("e1000_setup_fiber_serdes_link"); 918 DEBUGFUNC("e1000_setup_fiber_serdes_link");
880 919
920 /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
921 * until explicitly turned off or a power cycle is performed. A read to
922 * the register does not indicate its status. Therefore, we ensure
923 * loopback mode is disabled during initialization.
924 */
925 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572)
926 E1000_WRITE_REG(hw, SCTL, E1000_DISABLE_SERDES_LOOPBACK);
927
881 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be 928 /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
882 * set when the optics detect a signal. On older adapters, it will be 929 * set when the optics detect a signal. On older adapters, it will be
883 * cleared when there is a signal. This applies to fiber media only. 930 * cleared when there is a signal. This applies to fiber media only.
@@ -2943,6 +2990,8 @@ e1000_phy_reset(struct e1000_hw *hw)
2943 2990
2944 switch (hw->mac_type) { 2991 switch (hw->mac_type) {
2945 case e1000_82541_rev_2: 2992 case e1000_82541_rev_2:
2993 case e1000_82571:
2994 case e1000_82572:
2946 ret_val = e1000_phy_hw_reset(hw); 2995 ret_val = e1000_phy_hw_reset(hw);
2947 if(ret_val) 2996 if(ret_val)
2948 return ret_val; 2997 return ret_val;
@@ -2981,6 +3030,16 @@ e1000_detect_gig_phy(struct e1000_hw *hw)
2981 3030
2982 DEBUGFUNC("e1000_detect_gig_phy"); 3031 DEBUGFUNC("e1000_detect_gig_phy");
2983 3032
3033 /* The 82571 firmware may still be configuring the PHY. In this
3034 * case, we cannot access the PHY until the configuration is done. So
3035 * we explicitly set the PHY values. */
3036 if(hw->mac_type == e1000_82571 ||
3037 hw->mac_type == e1000_82572) {
3038 hw->phy_id = IGP01E1000_I_PHY_ID;
3039 hw->phy_type = e1000_phy_igp_2;
3040 return E1000_SUCCESS;
3041 }
3042
2984 /* Read the PHY ID Registers to identify which PHY is onboard. */ 3043 /* Read the PHY ID Registers to identify which PHY is onboard. */
2985 ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high); 3044 ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high);
2986 if(ret_val) 3045 if(ret_val)
@@ -3334,6 +3393,21 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
3334 eeprom->use_eerd = FALSE; 3393 eeprom->use_eerd = FALSE;
3335 eeprom->use_eewr = FALSE; 3394 eeprom->use_eewr = FALSE;
3336 break; 3395 break;
3396 case e1000_82571:
3397 case e1000_82572:
3398 eeprom->type = e1000_eeprom_spi;
3399 eeprom->opcode_bits = 8;
3400 eeprom->delay_usec = 1;
3401 if (eecd & E1000_EECD_ADDR_BITS) {
3402 eeprom->page_size = 32;
3403 eeprom->address_bits = 16;
3404 } else {
3405 eeprom->page_size = 8;
3406 eeprom->address_bits = 8;
3407 }
3408 eeprom->use_eerd = FALSE;
3409 eeprom->use_eewr = FALSE;
3410 break;
3337 case e1000_82573: 3411 case e1000_82573:
3338 eeprom->type = e1000_eeprom_spi; 3412 eeprom->type = e1000_eeprom_spi;
3339 eeprom->opcode_bits = 8; 3413 eeprom->opcode_bits = 8;
@@ -3543,25 +3617,26 @@ e1000_acquire_eeprom(struct e1000_hw *hw)
3543 eecd = E1000_READ_REG(hw, EECD); 3617 eecd = E1000_READ_REG(hw, EECD);
3544 3618
3545 if (hw->mac_type != e1000_82573) { 3619 if (hw->mac_type != e1000_82573) {
3546 /* Request EEPROM Access */ 3620 /* Request EEPROM Access */
3547 if(hw->mac_type > e1000_82544) { 3621 if(hw->mac_type > e1000_82544) {
3548 eecd |= E1000_EECD_REQ; 3622 eecd |= E1000_EECD_REQ;
3549 E1000_WRITE_REG(hw, EECD, eecd);
3550 eecd = E1000_READ_REG(hw, EECD);
3551 while((!(eecd & E1000_EECD_GNT)) &&
3552 (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
3553 i++;
3554 udelay(5);
3555 eecd = E1000_READ_REG(hw, EECD);
3556 }
3557 if(!(eecd & E1000_EECD_GNT)) {
3558 eecd &= ~E1000_EECD_REQ;
3559 E1000_WRITE_REG(hw, EECD, eecd); 3623 E1000_WRITE_REG(hw, EECD, eecd);
3560 DEBUGOUT("Could not acquire EEPROM grant\n"); 3624 eecd = E1000_READ_REG(hw, EECD);
3561 return -E1000_ERR_EEPROM; 3625 while((!(eecd & E1000_EECD_GNT)) &&
3626 (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
3627 i++;
3628 udelay(5);
3629 eecd = E1000_READ_REG(hw, EECD);
3630 }
3631 if(!(eecd & E1000_EECD_GNT)) {
3632 eecd &= ~E1000_EECD_REQ;
3633 E1000_WRITE_REG(hw, EECD, eecd);
3634 DEBUGOUT("Could not acquire EEPROM grant\n");
3635 e1000_put_hw_eeprom_semaphore(hw);
3636 return -E1000_ERR_EEPROM;
3637 }
3562 } 3638 }
3563 } 3639 }
3564 }
3565 3640
3566 /* Setup EEPROM for Read/Write */ 3641 /* Setup EEPROM for Read/Write */
3567 3642
@@ -4064,7 +4139,7 @@ e1000_write_eeprom(struct e1000_hw *hw,
4064 return -E1000_ERR_EEPROM; 4139 return -E1000_ERR_EEPROM;
4065 } 4140 }
4066 4141
4067 /* 82573 reads only through eerd */ 4142 /* 82573 writes only through eewr */
4068 if(eeprom->use_eewr == TRUE) 4143 if(eeprom->use_eewr == TRUE)
4069 return e1000_write_eeprom_eewr(hw, offset, words, data); 4144 return e1000_write_eeprom_eewr(hw, offset, words, data);
4070 4145
@@ -4353,9 +4428,16 @@ e1000_read_mac_addr(struct e1000_hw * hw)
4353 hw->perm_mac_addr[i] = (uint8_t) (eeprom_data & 0x00FF); 4428 hw->perm_mac_addr[i] = (uint8_t) (eeprom_data & 0x00FF);
4354 hw->perm_mac_addr[i+1] = (uint8_t) (eeprom_data >> 8); 4429 hw->perm_mac_addr[i+1] = (uint8_t) (eeprom_data >> 8);
4355 } 4430 }
4356 if(((hw->mac_type == e1000_82546) || (hw->mac_type == e1000_82546_rev_3)) && 4431 switch (hw->mac_type) {
4357 (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) 4432 default:
4433 break;
4434 case e1000_82546:
4435 case e1000_82546_rev_3:
4436 case e1000_82571:
4437 if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
4358 hw->perm_mac_addr[5] ^= 0x01; 4438 hw->perm_mac_addr[5] ^= 0x01;
4439 break;
4440 }
4359 4441
4360 for(i = 0; i < NODE_ADDRESS_SIZE; i++) 4442 for(i = 0; i < NODE_ADDRESS_SIZE; i++)
4361 hw->mac_addr[i] = hw->perm_mac_addr[i]; 4443 hw->mac_addr[i] = hw->perm_mac_addr[i];
@@ -4385,6 +4467,12 @@ e1000_init_rx_addrs(struct e1000_hw *hw)
4385 e1000_rar_set(hw, hw->mac_addr, 0); 4467 e1000_rar_set(hw, hw->mac_addr, 0);
4386 4468
4387 rar_num = E1000_RAR_ENTRIES; 4469 rar_num = E1000_RAR_ENTRIES;
4470
4471 /* Reserve a spot for the Locally Administered Address to work around
4472 * an 82571 issue in which a reset on one port will reload the MAC on
4473 * the other port. */
4474 if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE))
4475 rar_num -= 1;
4388 /* Zero out the other 15 receive addresses. */ 4476 /* Zero out the other 15 receive addresses. */
4389 DEBUGOUT("Clearing RAR[1-15]\n"); 4477 DEBUGOUT("Clearing RAR[1-15]\n");
4390 for(i = 1; i < rar_num; i++) { 4478 for(i = 1; i < rar_num; i++) {
@@ -4427,6 +4515,12 @@ e1000_mc_addr_list_update(struct e1000_hw *hw,
4427 /* Clear RAR[1-15] */ 4515 /* Clear RAR[1-15] */
4428 DEBUGOUT(" Clearing RAR[1-15]\n"); 4516 DEBUGOUT(" Clearing RAR[1-15]\n");
4429 num_rar_entry = E1000_RAR_ENTRIES; 4517 num_rar_entry = E1000_RAR_ENTRIES;
4518 /* Reserve a spot for the Locally Administered Address to work around
4519 * an 82571 issue in which a reset on one port will reload the MAC on
4520 * the other port. */
4521 if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE))
4522 num_rar_entry -= 1;
4523
4430 for(i = rar_used_count; i < num_rar_entry; i++) { 4524 for(i = rar_used_count; i < num_rar_entry; i++) {
4431 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0); 4525 E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
4432 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0); 4526 E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
@@ -4984,7 +5078,6 @@ e1000_clear_hw_cntrs(struct e1000_hw *hw)
4984 temp = E1000_READ_REG(hw, ICTXQEC); 5078 temp = E1000_READ_REG(hw, ICTXQEC);
4985 temp = E1000_READ_REG(hw, ICTXQMTC); 5079 temp = E1000_READ_REG(hw, ICTXQMTC);
4986 temp = E1000_READ_REG(hw, ICRXDMTC); 5080 temp = E1000_READ_REG(hw, ICRXDMTC);
4987
4988} 5081}
4989 5082
4990/****************************************************************************** 5083/******************************************************************************
@@ -5151,6 +5244,8 @@ e1000_get_bus_info(struct e1000_hw *hw)
5151 hw->bus_speed = e1000_bus_speed_unknown; 5244 hw->bus_speed = e1000_bus_speed_unknown;
5152 hw->bus_width = e1000_bus_width_unknown; 5245 hw->bus_width = e1000_bus_width_unknown;
5153 break; 5246 break;
5247 case e1000_82571:
5248 case e1000_82572:
5154 case e1000_82573: 5249 case e1000_82573:
5155 hw->bus_type = e1000_bus_type_pci_express; 5250 hw->bus_type = e1000_bus_type_pci_express;
5156 hw->bus_speed = e1000_bus_speed_2500; 5251 hw->bus_speed = e1000_bus_speed_2500;
@@ -5250,6 +5345,7 @@ e1000_get_cable_length(struct e1000_hw *hw,
5250 int32_t ret_val; 5345 int32_t ret_val;
5251 uint16_t agc_value = 0; 5346 uint16_t agc_value = 0;
5252 uint16_t cur_agc, min_agc = IGP01E1000_AGC_LENGTH_TABLE_SIZE; 5347 uint16_t cur_agc, min_agc = IGP01E1000_AGC_LENGTH_TABLE_SIZE;
5348 uint16_t max_agc = 0;
5253 uint16_t i, phy_data; 5349 uint16_t i, phy_data;
5254 uint16_t cable_length; 5350 uint16_t cable_length;
5255 5351
@@ -5338,6 +5434,40 @@ e1000_get_cable_length(struct e1000_hw *hw,
5338 IGP01E1000_AGC_RANGE) : 0; 5434 IGP01E1000_AGC_RANGE) : 0;
5339 *max_length = e1000_igp_cable_length_table[agc_value] + 5435 *max_length = e1000_igp_cable_length_table[agc_value] +
5340 IGP01E1000_AGC_RANGE; 5436 IGP01E1000_AGC_RANGE;
5437 } else if (hw->phy_type == e1000_phy_igp_2) {
5438 uint16_t agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
5439 {IGP02E1000_PHY_AGC_A,
5440 IGP02E1000_PHY_AGC_B,
5441 IGP02E1000_PHY_AGC_C,
5442 IGP02E1000_PHY_AGC_D};
5443 /* Read the AGC registers for all channels */
5444 for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
5445 ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);
5446 if (ret_val)
5447 return ret_val;
5448
5449 /* Getting bits 15:9, which represent the combination of course and
5450 * fine gain values. The result is a number that can be put into
5451 * the lookup table to obtain the approximate cable length. */
5452 cur_agc = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
5453 IGP02E1000_AGC_LENGTH_MASK;
5454
5455 /* Remove min & max AGC values from calculation. */
5456 if (e1000_igp_2_cable_length_table[min_agc] > e1000_igp_2_cable_length_table[cur_agc])
5457 min_agc = cur_agc;
5458 if (e1000_igp_2_cable_length_table[max_agc] < e1000_igp_2_cable_length_table[cur_agc])
5459 max_agc = cur_agc;
5460
5461 agc_value += e1000_igp_2_cable_length_table[cur_agc];
5462 }
5463
5464 agc_value -= (e1000_igp_2_cable_length_table[min_agc] + e1000_igp_2_cable_length_table[max_agc]);
5465 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
5466
5467 /* Calculate cable length with the error range of +/- 10 meters. */
5468 *min_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
5469 (agc_value - IGP02E1000_AGC_RANGE) : 0;
5470 *max_length = agc_value + IGP02E1000_AGC_RANGE;
5341 } 5471 }
5342 5472
5343 return E1000_SUCCESS; 5473 return E1000_SUCCESS;
@@ -6465,6 +6595,8 @@ e1000_get_auto_rd_done(struct e1000_hw *hw)
6465 default: 6595 default:
6466 msec_delay(5); 6596 msec_delay(5);
6467 break; 6597 break;
6598 case e1000_82571:
6599 case e1000_82572:
6468 case e1000_82573: 6600 case e1000_82573:
6469 while(timeout) { 6601 while(timeout) {
6470 if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD) break; 6602 if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD) break;
@@ -6494,10 +6626,31 @@ e1000_get_auto_rd_done(struct e1000_hw *hw)
6494int32_t 6626int32_t
6495e1000_get_phy_cfg_done(struct e1000_hw *hw) 6627e1000_get_phy_cfg_done(struct e1000_hw *hw)
6496{ 6628{
6629 int32_t timeout = PHY_CFG_TIMEOUT;
6630 uint32_t cfg_mask = E1000_EEPROM_CFG_DONE;
6631
6497 DEBUGFUNC("e1000_get_phy_cfg_done"); 6632 DEBUGFUNC("e1000_get_phy_cfg_done");
6498 6633
6499 /* Simply wait for 10ms */ 6634 switch (hw->mac_type) {
6500 msec_delay(10); 6635 default:
6636 msec_delay(10);
6637 break;
6638 case e1000_82571:
6639 case e1000_82572:
6640 while (timeout) {
6641 if (E1000_READ_REG(hw, EEMNGCTL) & cfg_mask)
6642 break;
6643 else
6644 msec_delay(1);
6645 timeout--;
6646 }
6647
6648 if (!timeout) {
6649 DEBUGOUT("MNG configuration cycle has not completed.\n");
6650 return -E1000_ERR_RESET;
6651 }
6652 break;
6653 }
6501 6654
6502 return E1000_SUCCESS; 6655 return E1000_SUCCESS;
6503} 6656}
@@ -6569,8 +6722,7 @@ e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw)
6569 return; 6722 return;
6570 6723
6571 swsm = E1000_READ_REG(hw, SWSM); 6724 swsm = E1000_READ_REG(hw, SWSM);
6572 /* Release both semaphores. */ 6725 swsm &= ~(E1000_SWSM_SWESMBI);
6573 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
6574 E1000_WRITE_REG(hw, SWSM, swsm); 6726 E1000_WRITE_REG(hw, SWSM, swsm);
6575} 6727}
6576 6728
@@ -6606,6 +6758,8 @@ e1000_arc_subsystem_valid(struct e1000_hw *hw)
6606 * if this is the case. We read FWSM to determine the manageability mode. 6758 * if this is the case. We read FWSM to determine the manageability mode.
6607 */ 6759 */
6608 switch (hw->mac_type) { 6760 switch (hw->mac_type) {
6761 case e1000_82571:
6762 case e1000_82572:
6609 case e1000_82573: 6763 case e1000_82573:
6610 fwsm = E1000_READ_REG(hw, FWSM); 6764 fwsm = E1000_READ_REG(hw, FWSM);
6611 if((fwsm & E1000_FWSM_MODE_MASK) != 0) 6765 if((fwsm & E1000_FWSM_MODE_MASK) != 0)
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 51c2b3a18b6f..4f2c196dc314 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -57,6 +57,8 @@ typedef enum {
57 e1000_82541_rev_2, 57 e1000_82541_rev_2,
58 e1000_82547, 58 e1000_82547,
59 e1000_82547_rev_2, 59 e1000_82547_rev_2,
60 e1000_82571,
61 e1000_82572,
60 e1000_82573, 62 e1000_82573,
61 e1000_num_macs 63 e1000_num_macs
62} e1000_mac_type; 64} e1000_mac_type;
@@ -478,10 +480,16 @@ uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
478#define E1000_DEV_ID_82546GB_SERDES 0x107B 480#define E1000_DEV_ID_82546GB_SERDES 0x107B
479#define E1000_DEV_ID_82546GB_PCIE 0x108A 481#define E1000_DEV_ID_82546GB_PCIE 0x108A
480#define E1000_DEV_ID_82547EI 0x1019 482#define E1000_DEV_ID_82547EI 0x1019
483#define E1000_DEV_ID_82571EB_COPPER 0x105E
484#define E1000_DEV_ID_82571EB_FIBER 0x105F
485#define E1000_DEV_ID_82571EB_SERDES 0x1060
486#define E1000_DEV_ID_82572EI_COPPER 0x107D
487#define E1000_DEV_ID_82572EI_FIBER 0x107E
488#define E1000_DEV_ID_82572EI_SERDES 0x107F
481#define E1000_DEV_ID_82573E 0x108B 489#define E1000_DEV_ID_82573E 0x108B
482#define E1000_DEV_ID_82573E_IAMT 0x108C 490#define E1000_DEV_ID_82573E_IAMT 0x108C
491#define E1000_DEV_ID_82573L 0x109A
483 492
484#define E1000_DEV_ID_82546GB_QUAD_COPPER 0x1099
485 493
486#define NODE_ADDRESS_SIZE 6 494#define NODE_ADDRESS_SIZE 6
487#define ETH_LENGTH_OF_ADDRESS 6 495#define ETH_LENGTH_OF_ADDRESS 6
@@ -833,6 +841,8 @@ struct e1000_ffvt_entry {
833#define E1000_FFMT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX 841#define E1000_FFMT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
834#define E1000_FFVT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX 842#define E1000_FFVT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
835 843
844#define E1000_DISABLE_SERDES_LOOPBACK 0x0400
845
836/* Register Set. (82543, 82544) 846/* Register Set. (82543, 82544)
837 * 847 *
838 * Registers are defined to be 32 bits and should be accessed as 32 bit values. 848 * Registers are defined to be 32 bits and should be accessed as 32 bit values.
@@ -853,6 +863,7 @@ struct e1000_ffvt_entry {
853#define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */ 863#define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */
854#define E1000_FLA 0x0001C /* Flash Access - RW */ 864#define E1000_FLA 0x0001C /* Flash Access - RW */
855#define E1000_MDIC 0x00020 /* MDI Control - RW */ 865#define E1000_MDIC 0x00020 /* MDI Control - RW */
866#define E1000_SCTL 0x00024 /* SerDes Control - RW */
856#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */ 867#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */
857#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */ 868#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */
858#define E1000_FCT 0x00030 /* Flow Control Type - RW */ 869#define E1000_FCT 0x00030 /* Flow Control Type - RW */
@@ -864,6 +875,12 @@ struct e1000_ffvt_entry {
864#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */ 875#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
865#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */ 876#define E1000_IAM 0x000E0 /* Interrupt Acknowledge Auto Mask */
866#define E1000_RCTL 0x00100 /* RX Control - RW */ 877#define E1000_RCTL 0x00100 /* RX Control - RW */
878#define E1000_RDTR1 0x02820 /* RX Delay Timer (1) - RW */
879#define E1000_RDBAL1 0x02900 /* RX Descriptor Base Address Low (1) - RW */
880#define E1000_RDBAH1 0x02904 /* RX Descriptor Base Address High (1) - RW */
881#define E1000_RDLEN1 0x02908 /* RX Descriptor Length (1) - RW */
882#define E1000_RDH1 0x02910 /* RX Descriptor Head (1) - RW */
883#define E1000_RDT1 0x02918 /* RX Descriptor Tail (1) - RW */
867#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */ 884#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
868#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */ 885#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
869#define E1000_RXCW 0x00180 /* RX Configuration Word - RO */ 886#define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
@@ -895,6 +912,12 @@ struct e1000_ffvt_entry {
895#define E1000_RDH 0x02810 /* RX Descriptor Head - RW */ 912#define E1000_RDH 0x02810 /* RX Descriptor Head - RW */
896#define E1000_RDT 0x02818 /* RX Descriptor Tail - RW */ 913#define E1000_RDT 0x02818 /* RX Descriptor Tail - RW */
897#define E1000_RDTR 0x02820 /* RX Delay Timer - RW */ 914#define E1000_RDTR 0x02820 /* RX Delay Timer - RW */
915#define E1000_RDBAL0 E1000_RDBAL /* RX Desc Base Address Low (0) - RW */
916#define E1000_RDBAH0 E1000_RDBAH /* RX Desc Base Address High (0) - RW */
917#define E1000_RDLEN0 E1000_RDLEN /* RX Desc Length (0) - RW */
918#define E1000_RDH0 E1000_RDH /* RX Desc Head (0) - RW */
919#define E1000_RDT0 E1000_RDT /* RX Desc Tail (0) - RW */
920#define E1000_RDTR0 E1000_RDTR /* RX Delay Timer (0) - RW */
898#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */ 921#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */
899#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */ 922#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */
900#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */ 923#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */
@@ -980,15 +1003,15 @@ struct e1000_ffvt_entry {
980#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */ 1003#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */
981#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */ 1004#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */
982#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */ 1005#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */
983#define E1000_IAC 0x4100 /* Interrupt Assertion Count */ 1006#define E1000_IAC 0x04100 /* Interrupt Assertion Count */
984#define E1000_ICRXPTC 0x4104 /* Interrupt Cause Rx Packet Timer Expire Count */ 1007#define E1000_ICRXPTC 0x04104 /* Interrupt Cause Rx Packet Timer Expire Count */
985#define E1000_ICRXATC 0x4108 /* Interrupt Cause Rx Absolute Timer Expire Count */ 1008#define E1000_ICRXATC 0x04108 /* Interrupt Cause Rx Absolute Timer Expire Count */
986#define E1000_ICTXPTC 0x410C /* Interrupt Cause Tx Packet Timer Expire Count */ 1009#define E1000_ICTXPTC 0x0410C /* Interrupt Cause Tx Packet Timer Expire Count */
987#define E1000_ICTXATC 0x4110 /* Interrupt Cause Tx Absolute Timer Expire Count */ 1010#define E1000_ICTXATC 0x04110 /* Interrupt Cause Tx Absolute Timer Expire Count */
988#define E1000_ICTXQEC 0x4118 /* Interrupt Cause Tx Queue Empty Count */ 1011#define E1000_ICTXQEC 0x04118 /* Interrupt Cause Tx Queue Empty Count */
989#define E1000_ICTXQMTC 0x411C /* Interrupt Cause Tx Queue Minimum Threshold Count */ 1012#define E1000_ICTXQMTC 0x0411C /* Interrupt Cause Tx Queue Minimum Threshold Count */
990#define E1000_ICRXDMTC 0x4120 /* Interrupt Cause Rx Descriptor Minimum Threshold Count */ 1013#define E1000_ICRXDMTC 0x04120 /* Interrupt Cause Rx Descriptor Minimum Threshold Count */
991#define E1000_ICRXOC 0x4124 /* Interrupt Cause Receiver Overrun Count */ 1014#define E1000_ICRXOC 0x04124 /* Interrupt Cause Receiver Overrun Count */
992#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */ 1015#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */
993#define E1000_RFCTL 0x05008 /* Receive Filter Control*/ 1016#define E1000_RFCTL 0x05008 /* Receive Filter Control*/
994#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */ 1017#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */
@@ -1018,6 +1041,14 @@ struct e1000_ffvt_entry {
1018#define E1000_FWSM 0x05B54 /* FW Semaphore */ 1041#define E1000_FWSM 0x05B54 /* FW Semaphore */
1019#define E1000_FFLT_DBG 0x05F04 /* Debug Register */ 1042#define E1000_FFLT_DBG 0x05F04 /* Debug Register */
1020#define E1000_HICR 0x08F00 /* Host Inteface Control */ 1043#define E1000_HICR 0x08F00 /* Host Inteface Control */
1044
1045/* RSS registers */
1046#define E1000_CPUVEC 0x02C10 /* CPU Vector Register - RW */
1047#define E1000_MRQC 0x05818 /* Multiple Receive Control - RW */
1048#define E1000_RETA 0x05C00 /* Redirection Table - RW Array */
1049#define E1000_RSSRK 0x05C80 /* RSS Random Key - RW Array */
1050#define E1000_RSSIM 0x05864 /* RSS Interrupt Mask */
1051#define E1000_RSSIR 0x05868 /* RSS Interrupt Request */
1021/* Register Set (82542) 1052/* Register Set (82542)
1022 * 1053 *
1023 * Some of the 82542 registers are located at different offsets than they are 1054 * Some of the 82542 registers are located at different offsets than they are
@@ -1032,6 +1063,7 @@ struct e1000_ffvt_entry {
1032#define E1000_82542_CTRL_EXT E1000_CTRL_EXT 1063#define E1000_82542_CTRL_EXT E1000_CTRL_EXT
1033#define E1000_82542_FLA E1000_FLA 1064#define E1000_82542_FLA E1000_FLA
1034#define E1000_82542_MDIC E1000_MDIC 1065#define E1000_82542_MDIC E1000_MDIC
1066#define E1000_82542_SCTL E1000_SCTL
1035#define E1000_82542_FCAL E1000_FCAL 1067#define E1000_82542_FCAL E1000_FCAL
1036#define E1000_82542_FCAH E1000_FCAH 1068#define E1000_82542_FCAH E1000_FCAH
1037#define E1000_82542_FCT E1000_FCT 1069#define E1000_82542_FCT E1000_FCT
@@ -1049,6 +1081,18 @@ struct e1000_ffvt_entry {
1049#define E1000_82542_RDLEN 0x00118 1081#define E1000_82542_RDLEN 0x00118
1050#define E1000_82542_RDH 0x00120 1082#define E1000_82542_RDH 0x00120
1051#define E1000_82542_RDT 0x00128 1083#define E1000_82542_RDT 0x00128
1084#define E1000_82542_RDTR0 E1000_82542_RDTR
1085#define E1000_82542_RDBAL0 E1000_82542_RDBAL
1086#define E1000_82542_RDBAH0 E1000_82542_RDBAH
1087#define E1000_82542_RDLEN0 E1000_82542_RDLEN
1088#define E1000_82542_RDH0 E1000_82542_RDH
1089#define E1000_82542_RDT0 E1000_82542_RDT
1090#define E1000_82542_RDTR1 0x00130
1091#define E1000_82542_RDBAL1 0x00138
1092#define E1000_82542_RDBAH1 0x0013C
1093#define E1000_82542_RDLEN1 0x00140
1094#define E1000_82542_RDH1 0x00148
1095#define E1000_82542_RDT1 0x00150
1052#define E1000_82542_FCRTH 0x00160 1096#define E1000_82542_FCRTH 0x00160
1053#define E1000_82542_FCRTL 0x00168 1097#define E1000_82542_FCRTL 0x00168
1054#define E1000_82542_FCTTV E1000_FCTTV 1098#define E1000_82542_FCTTV E1000_FCTTV
@@ -1197,6 +1241,13 @@ struct e1000_ffvt_entry {
1197#define E1000_82542_ICRXOC E1000_ICRXOC 1241#define E1000_82542_ICRXOC E1000_ICRXOC
1198#define E1000_82542_HICR E1000_HICR 1242#define E1000_82542_HICR E1000_HICR
1199 1243
1244#define E1000_82542_CPUVEC E1000_CPUVEC
1245#define E1000_82542_MRQC E1000_MRQC
1246#define E1000_82542_RETA E1000_RETA
1247#define E1000_82542_RSSRK E1000_RSSRK
1248#define E1000_82542_RSSIM E1000_RSSIM
1249#define E1000_82542_RSSIR E1000_RSSIR
1250
1200/* Statistics counters collected by the MAC */ 1251/* Statistics counters collected by the MAC */
1201struct e1000_hw_stats { 1252struct e1000_hw_stats {
1202 uint64_t crcerrs; 1253 uint64_t crcerrs;
@@ -1336,6 +1387,7 @@ struct e1000_hw {
1336 boolean_t serdes_link_down; 1387 boolean_t serdes_link_down;
1337 boolean_t tbi_compatibility_en; 1388 boolean_t tbi_compatibility_en;
1338 boolean_t tbi_compatibility_on; 1389 boolean_t tbi_compatibility_on;
1390 boolean_t laa_is_present;
1339 boolean_t phy_reset_disable; 1391 boolean_t phy_reset_disable;
1340 boolean_t fc_send_xon; 1392 boolean_t fc_send_xon;
1341 boolean_t fc_strict_ieee; 1393 boolean_t fc_strict_ieee;
@@ -1374,6 +1426,7 @@ struct e1000_hw {
1374#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */ 1426#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */
1375#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */ 1427#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */
1376#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */ 1428#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */
1429#define E1000_CTRL_D_UD_EN 0x00002000 /* Dock/Undock enable */
1377#define E1000_CTRL_D_UD_POLARITY 0x00004000 /* Defined polarity of Dock/Undock indication in SDP[0] */ 1430#define E1000_CTRL_D_UD_POLARITY 0x00004000 /* Defined polarity of Dock/Undock indication in SDP[0] */
1378#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */ 1431#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
1379#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */ 1432#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
@@ -1491,6 +1544,8 @@ struct e1000_hw {
1491#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000 1544#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000
1492#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000 1545#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000
1493#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000 1546#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000
1547#define E1000_CTRL_EXT_CANC 0x04000000 /* Interrupt delay cancellation */
1548#define E1000_CTRL_EXT_DRV_LOAD 0x10000000 /* Driver loaded bit for FW */
1494#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */ 1549#define E1000_CTRL_EXT_IAME 0x08000000 /* Interrupt acknowledge Auto-mask */
1495#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */ 1550#define E1000_CTRL_EXT_INT_TIMER_CLR 0x20000000 /* Clear Interrupt timers after IMS clear */
1496 1551
@@ -1524,6 +1579,7 @@ struct e1000_hw {
1524#define E1000_LEDCTL_LED2_BLINK 0x00800000 1579#define E1000_LEDCTL_LED2_BLINK 0x00800000
1525#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000 1580#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000
1526#define E1000_LEDCTL_LED3_MODE_SHIFT 24 1581#define E1000_LEDCTL_LED3_MODE_SHIFT 24
1582#define E1000_LEDCTL_LED3_BLINK_RATE 0x20000000
1527#define E1000_LEDCTL_LED3_IVRT 0x40000000 1583#define E1000_LEDCTL_LED3_IVRT 0x40000000
1528#define E1000_LEDCTL_LED3_BLINK 0x80000000 1584#define E1000_LEDCTL_LED3_BLINK 0x80000000
1529 1585
@@ -1784,6 +1840,16 @@ struct e1000_hw {
1784#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */ 1840#define E1000_RXCSUM_IPPCSE 0x00001000 /* IP payload checksum enable */
1785#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */ 1841#define E1000_RXCSUM_PCSD 0x00002000 /* packet checksum disabled */
1786 1842
1843/* Multiple Receive Queue Control */
1844#define E1000_MRQC_ENABLE_MASK 0x00000003
1845#define E1000_MRQC_ENABLE_RSS_2Q 0x00000001
1846#define E1000_MRQC_ENABLE_RSS_INT 0x00000004
1847#define E1000_MRQC_RSS_FIELD_MASK 0xFFFF0000
1848#define E1000_MRQC_RSS_FIELD_IPV4_TCP 0x00010000
1849#define E1000_MRQC_RSS_FIELD_IPV4 0x00020000
1850#define E1000_MRQC_RSS_FIELD_IPV6_TCP 0x00040000
1851#define E1000_MRQC_RSS_FIELD_IPV6_EX 0x00080000
1852#define E1000_MRQC_RSS_FIELD_IPV6 0x00100000
1787 1853
1788/* Definitions for power management and wakeup registers */ 1854/* Definitions for power management and wakeup registers */
1789/* Wake Up Control */ 1855/* Wake Up Control */
@@ -1928,6 +1994,7 @@ struct e1000_host_command_info {
1928#define E1000_MDALIGN 4096 1994#define E1000_MDALIGN 4096
1929 1995
1930#define E1000_GCR_BEM32 0x00400000 1996#define E1000_GCR_BEM32 0x00400000
1997#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
1931/* Function Active and Power State to MNG */ 1998/* Function Active and Power State to MNG */
1932#define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003 1999#define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003
1933#define E1000_FACTPS_LAN0_VALID 0x00000004 2000#define E1000_FACTPS_LAN0_VALID 0x00000004
@@ -1980,6 +2047,7 @@ struct e1000_host_command_info {
1980/* EEPROM Word Offsets */ 2047/* EEPROM Word Offsets */
1981#define EEPROM_COMPAT 0x0003 2048#define EEPROM_COMPAT 0x0003
1982#define EEPROM_ID_LED_SETTINGS 0x0004 2049#define EEPROM_ID_LED_SETTINGS 0x0004
2050#define EEPROM_VERSION 0x0005
1983#define EEPROM_SERDES_AMPLITUDE 0x0006 /* For SERDES output amplitude adjustment. */ 2051#define EEPROM_SERDES_AMPLITUDE 0x0006 /* For SERDES output amplitude adjustment. */
1984#define EEPROM_PHY_CLASS_WORD 0x0007 2052#define EEPROM_PHY_CLASS_WORD 0x0007
1985#define EEPROM_INIT_CONTROL1_REG 0x000A 2053#define EEPROM_INIT_CONTROL1_REG 0x000A
@@ -1990,6 +2058,8 @@ struct e1000_host_command_info {
1990#define EEPROM_FLASH_VERSION 0x0032 2058#define EEPROM_FLASH_VERSION 0x0032
1991#define EEPROM_CHECKSUM_REG 0x003F 2059#define EEPROM_CHECKSUM_REG 0x003F
1992 2060
2061#define E1000_EEPROM_CFG_DONE 0x00040000 /* MNG config cycle done */
2062
1993/* Word definitions for ID LED Settings */ 2063/* Word definitions for ID LED Settings */
1994#define ID_LED_RESERVED_0000 0x0000 2064#define ID_LED_RESERVED_0000 0x0000
1995#define ID_LED_RESERVED_FFFF 0xFFFF 2065#define ID_LED_RESERVED_FFFF 0xFFFF
@@ -2108,6 +2178,8 @@ struct e1000_host_command_info {
2108#define E1000_PBA_22K 0x0016 2178#define E1000_PBA_22K 0x0016
2109#define E1000_PBA_24K 0x0018 2179#define E1000_PBA_24K 0x0018
2110#define E1000_PBA_30K 0x001E 2180#define E1000_PBA_30K 0x001E
2181#define E1000_PBA_32K 0x0020
2182#define E1000_PBA_38K 0x0026
2111#define E1000_PBA_40K 0x0028 2183#define E1000_PBA_40K 0x0028
2112#define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */ 2184#define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
2113 2185
@@ -2592,11 +2664,11 @@ struct e1000_host_command_info {
2592 2664
2593/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */ 2665/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */
2594#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128 2666#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128
2595#define IGP02E1000_AGC_LENGTH_TABLE_SIZE 128 2667#define IGP02E1000_AGC_LENGTH_TABLE_SIZE 113
2596 2668
2597/* The precision error of the cable length is +/- 10 meters */ 2669/* The precision error of the cable length is +/- 10 meters */
2598#define IGP01E1000_AGC_RANGE 10 2670#define IGP01E1000_AGC_RANGE 10
2599#define IGP02E1000_AGC_RANGE 10 2671#define IGP02E1000_AGC_RANGE 15
2600 2672
2601/* IGP01E1000 PCS Initialization register */ 2673/* IGP01E1000 PCS Initialization register */
2602/* bits 3:6 in the PCS registers stores the channels polarity */ 2674/* bits 3:6 in the PCS registers stores the channels polarity */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ee687c902a20..6b72f6acdd54 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -43,7 +43,7 @@ char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
43#else 43#else
44#define DRIVERNAPI "-NAPI" 44#define DRIVERNAPI "-NAPI"
45#endif 45#endif
46#define DRV_VERSION "6.0.60-k2"DRIVERNAPI 46#define DRV_VERSION "6.1.16-k2"DRIVERNAPI
47char e1000_driver_version[] = DRV_VERSION; 47char e1000_driver_version[] = DRV_VERSION;
48char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation."; 48char e1000_copyright[] = "Copyright (c) 1999-2005 Intel Corporation.";
49 49
@@ -80,6 +80,9 @@ static struct pci_device_id e1000_pci_tbl[] = {
80 INTEL_E1000_ETHERNET_DEVICE(0x1026), 80 INTEL_E1000_ETHERNET_DEVICE(0x1026),
81 INTEL_E1000_ETHERNET_DEVICE(0x1027), 81 INTEL_E1000_ETHERNET_DEVICE(0x1027),
82 INTEL_E1000_ETHERNET_DEVICE(0x1028), 82 INTEL_E1000_ETHERNET_DEVICE(0x1028),
83 INTEL_E1000_ETHERNET_DEVICE(0x105E),
84 INTEL_E1000_ETHERNET_DEVICE(0x105F),
85 INTEL_E1000_ETHERNET_DEVICE(0x1060),
83 INTEL_E1000_ETHERNET_DEVICE(0x1075), 86 INTEL_E1000_ETHERNET_DEVICE(0x1075),
84 INTEL_E1000_ETHERNET_DEVICE(0x1076), 87 INTEL_E1000_ETHERNET_DEVICE(0x1076),
85 INTEL_E1000_ETHERNET_DEVICE(0x1077), 88 INTEL_E1000_ETHERNET_DEVICE(0x1077),
@@ -88,10 +91,13 @@ static struct pci_device_id e1000_pci_tbl[] = {
88 INTEL_E1000_ETHERNET_DEVICE(0x107A), 91 INTEL_E1000_ETHERNET_DEVICE(0x107A),
89 INTEL_E1000_ETHERNET_DEVICE(0x107B), 92 INTEL_E1000_ETHERNET_DEVICE(0x107B),
90 INTEL_E1000_ETHERNET_DEVICE(0x107C), 93 INTEL_E1000_ETHERNET_DEVICE(0x107C),
94 INTEL_E1000_ETHERNET_DEVICE(0x107D),
95 INTEL_E1000_ETHERNET_DEVICE(0x107E),
96 INTEL_E1000_ETHERNET_DEVICE(0x107F),
91 INTEL_E1000_ETHERNET_DEVICE(0x108A), 97 INTEL_E1000_ETHERNET_DEVICE(0x108A),
92 INTEL_E1000_ETHERNET_DEVICE(0x108B), 98 INTEL_E1000_ETHERNET_DEVICE(0x108B),
93 INTEL_E1000_ETHERNET_DEVICE(0x108C), 99 INTEL_E1000_ETHERNET_DEVICE(0x108C),
94 INTEL_E1000_ETHERNET_DEVICE(0x1099), 100 INTEL_E1000_ETHERNET_DEVICE(0x109A),
95 /* required last entry */ 101 /* required last entry */
96 {0,} 102 {0,}
97}; 103};
@@ -102,10 +108,18 @@ int e1000_up(struct e1000_adapter *adapter);
102void e1000_down(struct e1000_adapter *adapter); 108void e1000_down(struct e1000_adapter *adapter);
103void e1000_reset(struct e1000_adapter *adapter); 109void e1000_reset(struct e1000_adapter *adapter);
104int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx); 110int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
105int e1000_setup_tx_resources(struct e1000_adapter *adapter); 111int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
106int e1000_setup_rx_resources(struct e1000_adapter *adapter); 112int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
107void e1000_free_tx_resources(struct e1000_adapter *adapter); 113void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
108void e1000_free_rx_resources(struct e1000_adapter *adapter); 114void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
115int e1000_setup_tx_resources(struct e1000_adapter *adapter,
116 struct e1000_tx_ring *txdr);
117int e1000_setup_rx_resources(struct e1000_adapter *adapter,
118 struct e1000_rx_ring *rxdr);
119void e1000_free_tx_resources(struct e1000_adapter *adapter,
120 struct e1000_tx_ring *tx_ring);
121void e1000_free_rx_resources(struct e1000_adapter *adapter,
122 struct e1000_rx_ring *rx_ring);
109void e1000_update_stats(struct e1000_adapter *adapter); 123void e1000_update_stats(struct e1000_adapter *adapter);
110 124
111/* Local Function Prototypes */ 125/* Local Function Prototypes */
@@ -114,14 +128,22 @@ static int e1000_init_module(void);
114static void e1000_exit_module(void); 128static void e1000_exit_module(void);
115static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 129static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
116static void __devexit e1000_remove(struct pci_dev *pdev); 130static void __devexit e1000_remove(struct pci_dev *pdev);
131static int e1000_alloc_queues(struct e1000_adapter *adapter);
132#ifdef CONFIG_E1000_MQ
133static void e1000_setup_queue_mapping(struct e1000_adapter *adapter);
134#endif
117static int e1000_sw_init(struct e1000_adapter *adapter); 135static int e1000_sw_init(struct e1000_adapter *adapter);
118static int e1000_open(struct net_device *netdev); 136static int e1000_open(struct net_device *netdev);
119static int e1000_close(struct net_device *netdev); 137static int e1000_close(struct net_device *netdev);
120static void e1000_configure_tx(struct e1000_adapter *adapter); 138static void e1000_configure_tx(struct e1000_adapter *adapter);
121static void e1000_configure_rx(struct e1000_adapter *adapter); 139static void e1000_configure_rx(struct e1000_adapter *adapter);
122static void e1000_setup_rctl(struct e1000_adapter *adapter); 140static void e1000_setup_rctl(struct e1000_adapter *adapter);
123static void e1000_clean_tx_ring(struct e1000_adapter *adapter); 141static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter);
124static void e1000_clean_rx_ring(struct e1000_adapter *adapter); 142static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter);
143static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
144 struct e1000_tx_ring *tx_ring);
145static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
146 struct e1000_rx_ring *rx_ring);
125static void e1000_set_multi(struct net_device *netdev); 147static void e1000_set_multi(struct net_device *netdev);
126static void e1000_update_phy_info(unsigned long data); 148static void e1000_update_phy_info(unsigned long data);
127static void e1000_watchdog(unsigned long data); 149static void e1000_watchdog(unsigned long data);
@@ -132,19 +154,26 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
132static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 154static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
133static int e1000_set_mac(struct net_device *netdev, void *p); 155static int e1000_set_mac(struct net_device *netdev, void *p);
134static irqreturn_t e1000_intr(int irq, void *data, struct pt_regs *regs); 156static irqreturn_t e1000_intr(int irq, void *data, struct pt_regs *regs);
135static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter); 157static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
158 struct e1000_tx_ring *tx_ring);
136#ifdef CONFIG_E1000_NAPI 159#ifdef CONFIG_E1000_NAPI
137static int e1000_clean(struct net_device *netdev, int *budget); 160static int e1000_clean(struct net_device *poll_dev, int *budget);
138static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter, 161static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
162 struct e1000_rx_ring *rx_ring,
139 int *work_done, int work_to_do); 163 int *work_done, int work_to_do);
140static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, 164static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
165 struct e1000_rx_ring *rx_ring,
141 int *work_done, int work_to_do); 166 int *work_done, int work_to_do);
142#else 167#else
143static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter); 168static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
144static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter); 169 struct e1000_rx_ring *rx_ring);
170static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
171 struct e1000_rx_ring *rx_ring);
145#endif 172#endif
146static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter); 173static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
147static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter); 174 struct e1000_rx_ring *rx_ring);
175static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
176 struct e1000_rx_ring *rx_ring);
148static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); 177static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
149static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, 178static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
150 int cmd); 179 int cmd);
@@ -172,6 +201,11 @@ static int e1000_resume(struct pci_dev *pdev);
172static void e1000_netpoll (struct net_device *netdev); 201static void e1000_netpoll (struct net_device *netdev);
173#endif 202#endif
174 203
204#ifdef CONFIG_E1000_MQ
205/* for multiple Rx queues */
206void e1000_rx_schedule(void *data);
207#endif
208
175/* Exported from other modules */ 209/* Exported from other modules */
176 210
177extern void e1000_check_options(struct e1000_adapter *adapter); 211extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -289,7 +323,7 @@ int
289e1000_up(struct e1000_adapter *adapter) 323e1000_up(struct e1000_adapter *adapter)
290{ 324{
291 struct net_device *netdev = adapter->netdev; 325 struct net_device *netdev = adapter->netdev;
292 int err; 326 int i, err;
293 327
294 /* hardware has been reset, we need to reload some things */ 328 /* hardware has been reset, we need to reload some things */
295 329
@@ -308,7 +342,8 @@ e1000_up(struct e1000_adapter *adapter)
308 e1000_configure_tx(adapter); 342 e1000_configure_tx(adapter);
309 e1000_setup_rctl(adapter); 343 e1000_setup_rctl(adapter);
310 e1000_configure_rx(adapter); 344 e1000_configure_rx(adapter);
311 adapter->alloc_rx_buf(adapter); 345 for (i = 0; i < adapter->num_queues; i++)
346 adapter->alloc_rx_buf(adapter, &adapter->rx_ring[i]);
312 347
313#ifdef CONFIG_PCI_MSI 348#ifdef CONFIG_PCI_MSI
314 if(adapter->hw.mac_type > e1000_82547_rev_2) { 349 if(adapter->hw.mac_type > e1000_82547_rev_2) {
@@ -344,6 +379,9 @@ e1000_down(struct e1000_adapter *adapter)
344 struct net_device *netdev = adapter->netdev; 379 struct net_device *netdev = adapter->netdev;
345 380
346 e1000_irq_disable(adapter); 381 e1000_irq_disable(adapter);
382#ifdef CONFIG_E1000_MQ
383 while (atomic_read(&adapter->rx_sched_call_data.count) != 0);
384#endif
347 free_irq(adapter->pdev->irq, netdev); 385 free_irq(adapter->pdev->irq, netdev);
348#ifdef CONFIG_PCI_MSI 386#ifdef CONFIG_PCI_MSI
349 if(adapter->hw.mac_type > e1000_82547_rev_2 && 387 if(adapter->hw.mac_type > e1000_82547_rev_2 &&
@@ -363,11 +401,10 @@ e1000_down(struct e1000_adapter *adapter)
363 netif_stop_queue(netdev); 401 netif_stop_queue(netdev);
364 402
365 e1000_reset(adapter); 403 e1000_reset(adapter);
366 e1000_clean_tx_ring(adapter); 404 e1000_clean_all_tx_rings(adapter);
367 e1000_clean_rx_ring(adapter); 405 e1000_clean_all_rx_rings(adapter);
368 406
369 /* If WoL is not enabled 407 /* If WoL is not enabled and management mode is not IAMT
370 * and management mode is not IAMT
371 * Power down the PHY so no link is implied when interface is down */ 408 * Power down the PHY so no link is implied when interface is down */
372 if(!adapter->wol && adapter->hw.mac_type >= e1000_82540 && 409 if(!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
373 adapter->hw.media_type == e1000_media_type_copper && 410 adapter->hw.media_type == e1000_media_type_copper &&
@@ -398,6 +435,10 @@ e1000_reset(struct e1000_adapter *adapter)
398 case e1000_82547_rev_2: 435 case e1000_82547_rev_2:
399 pba = E1000_PBA_30K; 436 pba = E1000_PBA_30K;
400 break; 437 break;
438 case e1000_82571:
439 case e1000_82572:
440 pba = E1000_PBA_38K;
441 break;
401 case e1000_82573: 442 case e1000_82573:
402 pba = E1000_PBA_12K; 443 pba = E1000_PBA_12K;
403 break; 444 break;
@@ -475,6 +516,7 @@ e1000_probe(struct pci_dev *pdev,
475 struct net_device *netdev; 516 struct net_device *netdev;
476 struct e1000_adapter *adapter; 517 struct e1000_adapter *adapter;
477 unsigned long mmio_start, mmio_len; 518 unsigned long mmio_start, mmio_len;
519 uint32_t ctrl_ext;
478 uint32_t swsm; 520 uint32_t swsm;
479 521
480 static int cards_found = 0; 522 static int cards_found = 0;
@@ -614,8 +656,9 @@ e1000_probe(struct pci_dev *pdev,
614 if(e1000_read_mac_addr(&adapter->hw)) 656 if(e1000_read_mac_addr(&adapter->hw))
615 DPRINTK(PROBE, ERR, "EEPROM Read Error\n"); 657 DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
616 memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len); 658 memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
659 memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len);
617 660
618 if(!is_valid_ether_addr(netdev->dev_addr)) { 661 if(!is_valid_ether_addr(netdev->perm_addr)) {
619 DPRINTK(PROBE, ERR, "Invalid MAC Address\n"); 662 DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
620 err = -EIO; 663 err = -EIO;
621 goto err_eeprom; 664 goto err_eeprom;
@@ -687,6 +730,12 @@ e1000_probe(struct pci_dev *pdev,
687 730
688 /* Let firmware know the driver has taken over */ 731 /* Let firmware know the driver has taken over */
689 switch(adapter->hw.mac_type) { 732 switch(adapter->hw.mac_type) {
733 case e1000_82571:
734 case e1000_82572:
735 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
736 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
737 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
738 break;
690 case e1000_82573: 739 case e1000_82573:
691 swsm = E1000_READ_REG(&adapter->hw, SWSM); 740 swsm = E1000_READ_REG(&adapter->hw, SWSM);
692 E1000_WRITE_REG(&adapter->hw, SWSM, 741 E1000_WRITE_REG(&adapter->hw, SWSM,
@@ -731,7 +780,11 @@ e1000_remove(struct pci_dev *pdev)
731{ 780{
732 struct net_device *netdev = pci_get_drvdata(pdev); 781 struct net_device *netdev = pci_get_drvdata(pdev);
733 struct e1000_adapter *adapter = netdev_priv(netdev); 782 struct e1000_adapter *adapter = netdev_priv(netdev);
783 uint32_t ctrl_ext;
734 uint32_t manc, swsm; 784 uint32_t manc, swsm;
785#ifdef CONFIG_E1000_NAPI
786 int i;
787#endif
735 788
736 flush_scheduled_work(); 789 flush_scheduled_work();
737 790
@@ -745,6 +798,12 @@ e1000_remove(struct pci_dev *pdev)
745 } 798 }
746 799
747 switch(adapter->hw.mac_type) { 800 switch(adapter->hw.mac_type) {
801 case e1000_82571:
802 case e1000_82572:
803 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
804 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
805 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
806 break;
748 case e1000_82573: 807 case e1000_82573:
749 swsm = E1000_READ_REG(&adapter->hw, SWSM); 808 swsm = E1000_READ_REG(&adapter->hw, SWSM);
750 E1000_WRITE_REG(&adapter->hw, SWSM, 809 E1000_WRITE_REG(&adapter->hw, SWSM,
@@ -756,13 +815,27 @@ e1000_remove(struct pci_dev *pdev)
756 } 815 }
757 816
758 unregister_netdev(netdev); 817 unregister_netdev(netdev);
818#ifdef CONFIG_E1000_NAPI
819 for (i = 0; i < adapter->num_queues; i++)
820 __dev_put(&adapter->polling_netdev[i]);
821#endif
759 822
760 if(!e1000_check_phy_reset_block(&adapter->hw)) 823 if(!e1000_check_phy_reset_block(&adapter->hw))
761 e1000_phy_hw_reset(&adapter->hw); 824 e1000_phy_hw_reset(&adapter->hw);
762 825
826 kfree(adapter->tx_ring);
827 kfree(adapter->rx_ring);
828#ifdef CONFIG_E1000_NAPI
829 kfree(adapter->polling_netdev);
830#endif
831
763 iounmap(adapter->hw.hw_addr); 832 iounmap(adapter->hw.hw_addr);
764 pci_release_regions(pdev); 833 pci_release_regions(pdev);
765 834
835#ifdef CONFIG_E1000_MQ
836 free_percpu(adapter->cpu_netdev);
837 free_percpu(adapter->cpu_tx_ring);
838#endif
766 free_netdev(netdev); 839 free_netdev(netdev);
767 840
768 pci_disable_device(pdev); 841 pci_disable_device(pdev);
@@ -783,6 +856,9 @@ e1000_sw_init(struct e1000_adapter *adapter)
783 struct e1000_hw *hw = &adapter->hw; 856 struct e1000_hw *hw = &adapter->hw;
784 struct net_device *netdev = adapter->netdev; 857 struct net_device *netdev = adapter->netdev;
785 struct pci_dev *pdev = adapter->pdev; 858 struct pci_dev *pdev = adapter->pdev;
859#ifdef CONFIG_E1000_NAPI
860 int i;
861#endif
786 862
787 /* PCI config space info */ 863 /* PCI config space info */
788 864
@@ -840,14 +916,123 @@ e1000_sw_init(struct e1000_adapter *adapter)
840 hw->master_slave = E1000_MASTER_SLAVE; 916 hw->master_slave = E1000_MASTER_SLAVE;
841 } 917 }
842 918
919#ifdef CONFIG_E1000_MQ
920 /* Number of supported queues */
921 switch (hw->mac_type) {
922 case e1000_82571:
923 case e1000_82572:
924 adapter->num_queues = 2;
925 break;
926 default:
927 adapter->num_queues = 1;
928 break;
929 }
930 adapter->num_queues = min(adapter->num_queues, num_online_cpus());
931#else
932 adapter->num_queues = 1;
933#endif
934
935 if (e1000_alloc_queues(adapter)) {
936 DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
937 return -ENOMEM;
938 }
939
940#ifdef CONFIG_E1000_NAPI
941 for (i = 0; i < adapter->num_queues; i++) {
942 adapter->polling_netdev[i].priv = adapter;
943 adapter->polling_netdev[i].poll = &e1000_clean;
944 adapter->polling_netdev[i].weight = 64;
945 dev_hold(&adapter->polling_netdev[i]);
946 set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
947 }
948#endif
949
950#ifdef CONFIG_E1000_MQ
951 e1000_setup_queue_mapping(adapter);
952#endif
953
843 atomic_set(&adapter->irq_sem, 1); 954 atomic_set(&adapter->irq_sem, 1);
844 spin_lock_init(&adapter->stats_lock); 955 spin_lock_init(&adapter->stats_lock);
845 spin_lock_init(&adapter->tx_lock);
846 956
847 return 0; 957 return 0;
848} 958}
849 959
850/** 960/**
961 * e1000_alloc_queues - Allocate memory for all rings
962 * @adapter: board private structure to initialize
963 *
964 * We allocate one ring per queue at run-time since we don't know the
965 * number of queues at compile-time. The polling_netdev array is
966 * intended for Multiqueue, but should work fine with a single queue.
967 **/
968
969static int __devinit
970e1000_alloc_queues(struct e1000_adapter *adapter)
971{
972 int size;
973
974 size = sizeof(struct e1000_tx_ring) * adapter->num_queues;
975 adapter->tx_ring = kmalloc(size, GFP_KERNEL);
976 if (!adapter->tx_ring)
977 return -ENOMEM;
978 memset(adapter->tx_ring, 0, size);
979
980 size = sizeof(struct e1000_rx_ring) * adapter->num_queues;
981 adapter->rx_ring = kmalloc(size, GFP_KERNEL);
982 if (!adapter->rx_ring) {
983 kfree(adapter->tx_ring);
984 return -ENOMEM;
985 }
986 memset(adapter->rx_ring, 0, size);
987
988#ifdef CONFIG_E1000_NAPI
989 size = sizeof(struct net_device) * adapter->num_queues;
990 adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
991 if (!adapter->polling_netdev) {
992 kfree(adapter->tx_ring);
993 kfree(adapter->rx_ring);
994 return -ENOMEM;
995 }
996 memset(adapter->polling_netdev, 0, size);
997#endif
998
999 return E1000_SUCCESS;
1000}
1001
1002#ifdef CONFIG_E1000_MQ
1003static void __devinit
1004e1000_setup_queue_mapping(struct e1000_adapter *adapter)
1005{
1006 int i, cpu;
1007
1008 adapter->rx_sched_call_data.func = e1000_rx_schedule;
1009 adapter->rx_sched_call_data.info = adapter->netdev;
1010 cpus_clear(adapter->rx_sched_call_data.cpumask);
1011
1012 adapter->cpu_netdev = alloc_percpu(struct net_device *);
1013 adapter->cpu_tx_ring = alloc_percpu(struct e1000_tx_ring *);
1014
1015 lock_cpu_hotplug();
1016 i = 0;
1017 for_each_online_cpu(cpu) {
1018 *per_cpu_ptr(adapter->cpu_tx_ring, cpu) = &adapter->tx_ring[i % adapter->num_queues];
1019 /* This is incomplete because we'd like to assign separate
1020 * physical cpus to these netdev polling structures and
1021 * avoid saturating a subset of cpus.
1022 */
1023 if (i < adapter->num_queues) {
1024 *per_cpu_ptr(adapter->cpu_netdev, cpu) = &adapter->polling_netdev[i];
1025 adapter->cpu_for_queue[i] = cpu;
1026 } else
1027 *per_cpu_ptr(adapter->cpu_netdev, cpu) = NULL;
1028
1029 i++;
1030 }
1031 unlock_cpu_hotplug();
1032}
1033#endif
1034
1035/**
851 * e1000_open - Called when a network interface is made active 1036 * e1000_open - Called when a network interface is made active
852 * @netdev: network interface device structure 1037 * @netdev: network interface device structure
853 * 1038 *
@@ -868,12 +1053,12 @@ e1000_open(struct net_device *netdev)
868 1053
869 /* allocate transmit descriptors */ 1054 /* allocate transmit descriptors */
870 1055
871 if((err = e1000_setup_tx_resources(adapter))) 1056 if ((err = e1000_setup_all_tx_resources(adapter)))
872 goto err_setup_tx; 1057 goto err_setup_tx;
873 1058
874 /* allocate receive descriptors */ 1059 /* allocate receive descriptors */
875 1060
876 if((err = e1000_setup_rx_resources(adapter))) 1061 if ((err = e1000_setup_all_rx_resources(adapter)))
877 goto err_setup_rx; 1062 goto err_setup_rx;
878 1063
879 if((err = e1000_up(adapter))) 1064 if((err = e1000_up(adapter)))
@@ -887,9 +1072,9 @@ e1000_open(struct net_device *netdev)
887 return E1000_SUCCESS; 1072 return E1000_SUCCESS;
888 1073
889err_up: 1074err_up:
890 e1000_free_rx_resources(adapter); 1075 e1000_free_all_rx_resources(adapter);
891err_setup_rx: 1076err_setup_rx:
892 e1000_free_tx_resources(adapter); 1077 e1000_free_all_tx_resources(adapter);
893err_setup_tx: 1078err_setup_tx:
894 e1000_reset(adapter); 1079 e1000_reset(adapter);
895 1080
@@ -915,8 +1100,8 @@ e1000_close(struct net_device *netdev)
915 1100
916 e1000_down(adapter); 1101 e1000_down(adapter);
917 1102
918 e1000_free_tx_resources(adapter); 1103 e1000_free_all_tx_resources(adapter);
919 e1000_free_rx_resources(adapter); 1104 e1000_free_all_rx_resources(adapter);
920 1105
921 if((adapter->hw.mng_cookie.status & 1106 if((adapter->hw.mng_cookie.status &
922 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { 1107 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
@@ -951,14 +1136,15 @@ e1000_check_64k_bound(struct e1000_adapter *adapter,
951/** 1136/**
952 * e1000_setup_tx_resources - allocate Tx resources (Descriptors) 1137 * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
953 * @adapter: board private structure 1138 * @adapter: board private structure
1139 * @txdr: tx descriptor ring (for a specific queue) to setup
954 * 1140 *
955 * Return 0 on success, negative on failure 1141 * Return 0 on success, negative on failure
956 **/ 1142 **/
957 1143
958int 1144int
959e1000_setup_tx_resources(struct e1000_adapter *adapter) 1145e1000_setup_tx_resources(struct e1000_adapter *adapter,
1146 struct e1000_tx_ring *txdr)
960{ 1147{
961 struct e1000_desc_ring *txdr = &adapter->tx_ring;
962 struct pci_dev *pdev = adapter->pdev; 1148 struct pci_dev *pdev = adapter->pdev;
963 int size; 1149 int size;
964 1150
@@ -970,6 +1156,7 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter)
970 return -ENOMEM; 1156 return -ENOMEM;
971 } 1157 }
972 memset(txdr->buffer_info, 0, size); 1158 memset(txdr->buffer_info, 0, size);
1159 memset(&txdr->previous_buffer_info, 0, sizeof(struct e1000_buffer));
973 1160
974 /* round up to nearest 4K */ 1161 /* round up to nearest 4K */
975 1162
@@ -1018,11 +1205,41 @@ setup_tx_desc_die:
1018 1205
1019 txdr->next_to_use = 0; 1206 txdr->next_to_use = 0;
1020 txdr->next_to_clean = 0; 1207 txdr->next_to_clean = 0;
1208 spin_lock_init(&txdr->tx_lock);
1021 1209
1022 return 0; 1210 return 0;
1023} 1211}
1024 1212
1025/** 1213/**
1214 * e1000_setup_all_tx_resources - wrapper to allocate Tx resources
1215 * (Descriptors) for all queues
1216 * @adapter: board private structure
1217 *
1218 * If this function returns with an error, then it's possible one or
1219 * more of the rings is populated (while the rest are not). It is the
1220 * callers duty to clean those orphaned rings.
1221 *
1222 * Return 0 on success, negative on failure
1223 **/
1224
1225int
1226e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
1227{
1228 int i, err = 0;
1229
1230 for (i = 0; i < adapter->num_queues; i++) {
1231 err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]);
1232 if (err) {
1233 DPRINTK(PROBE, ERR,
1234 "Allocation for Tx Queue %u failed\n", i);
1235 break;
1236 }
1237 }
1238
1239 return err;
1240}
1241
1242/**
1026 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset 1243 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
1027 * @adapter: board private structure 1244 * @adapter: board private structure
1028 * 1245 *
@@ -1032,23 +1249,43 @@ setup_tx_desc_die:
1032static void 1249static void
1033e1000_configure_tx(struct e1000_adapter *adapter) 1250e1000_configure_tx(struct e1000_adapter *adapter)
1034{ 1251{
1035 uint64_t tdba = adapter->tx_ring.dma; 1252 uint64_t tdba;
1036 uint32_t tdlen = adapter->tx_ring.count * sizeof(struct e1000_tx_desc); 1253 struct e1000_hw *hw = &adapter->hw;
1037 uint32_t tctl, tipg; 1254 uint32_t tdlen, tctl, tipg, tarc;
1038
1039 E1000_WRITE_REG(&adapter->hw, TDBAL, (tdba & 0x00000000ffffffffULL));
1040 E1000_WRITE_REG(&adapter->hw, TDBAH, (tdba >> 32));
1041
1042 E1000_WRITE_REG(&adapter->hw, TDLEN, tdlen);
1043 1255
1044 /* Setup the HW Tx Head and Tail descriptor pointers */ 1256 /* Setup the HW Tx Head and Tail descriptor pointers */
1045 1257
1046 E1000_WRITE_REG(&adapter->hw, TDH, 0); 1258 switch (adapter->num_queues) {
1047 E1000_WRITE_REG(&adapter->hw, TDT, 0); 1259 case 2:
1260 tdba = adapter->tx_ring[1].dma;
1261 tdlen = adapter->tx_ring[1].count *
1262 sizeof(struct e1000_tx_desc);
1263 E1000_WRITE_REG(hw, TDBAL1, (tdba & 0x00000000ffffffffULL));
1264 E1000_WRITE_REG(hw, TDBAH1, (tdba >> 32));
1265 E1000_WRITE_REG(hw, TDLEN1, tdlen);
1266 E1000_WRITE_REG(hw, TDH1, 0);
1267 E1000_WRITE_REG(hw, TDT1, 0);
1268 adapter->tx_ring[1].tdh = E1000_TDH1;
1269 adapter->tx_ring[1].tdt = E1000_TDT1;
1270 /* Fall Through */
1271 case 1:
1272 default:
1273 tdba = adapter->tx_ring[0].dma;
1274 tdlen = adapter->tx_ring[0].count *
1275 sizeof(struct e1000_tx_desc);
1276 E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
1277 E1000_WRITE_REG(hw, TDBAH, (tdba >> 32));
1278 E1000_WRITE_REG(hw, TDLEN, tdlen);
1279 E1000_WRITE_REG(hw, TDH, 0);
1280 E1000_WRITE_REG(hw, TDT, 0);
1281 adapter->tx_ring[0].tdh = E1000_TDH;
1282 adapter->tx_ring[0].tdt = E1000_TDT;
1283 break;
1284 }
1048 1285
1049 /* Set the default values for the Tx Inter Packet Gap timer */ 1286 /* Set the default values for the Tx Inter Packet Gap timer */
1050 1287
1051 switch (adapter->hw.mac_type) { 1288 switch (hw->mac_type) {
1052 case e1000_82542_rev2_0: 1289 case e1000_82542_rev2_0:
1053 case e1000_82542_rev2_1: 1290 case e1000_82542_rev2_1:
1054 tipg = DEFAULT_82542_TIPG_IPGT; 1291 tipg = DEFAULT_82542_TIPG_IPGT;
@@ -1056,67 +1293,81 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1056 tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; 1293 tipg |= DEFAULT_82542_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
1057 break; 1294 break;
1058 default: 1295 default:
1059 if(adapter->hw.media_type == e1000_media_type_fiber || 1296 if (hw->media_type == e1000_media_type_fiber ||
1060 adapter->hw.media_type == e1000_media_type_internal_serdes) 1297 hw->media_type == e1000_media_type_internal_serdes)
1061 tipg = DEFAULT_82543_TIPG_IPGT_FIBER; 1298 tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
1062 else 1299 else
1063 tipg = DEFAULT_82543_TIPG_IPGT_COPPER; 1300 tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
1064 tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT; 1301 tipg |= DEFAULT_82543_TIPG_IPGR1 << E1000_TIPG_IPGR1_SHIFT;
1065 tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT; 1302 tipg |= DEFAULT_82543_TIPG_IPGR2 << E1000_TIPG_IPGR2_SHIFT;
1066 } 1303 }
1067 E1000_WRITE_REG(&adapter->hw, TIPG, tipg); 1304 E1000_WRITE_REG(hw, TIPG, tipg);
1068 1305
1069 /* Set the Tx Interrupt Delay register */ 1306 /* Set the Tx Interrupt Delay register */
1070 1307
1071 E1000_WRITE_REG(&adapter->hw, TIDV, adapter->tx_int_delay); 1308 E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
1072 if(adapter->hw.mac_type >= e1000_82540) 1309 if (hw->mac_type >= e1000_82540)
1073 E1000_WRITE_REG(&adapter->hw, TADV, adapter->tx_abs_int_delay); 1310 E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
1074 1311
1075 /* Program the Transmit Control Register */ 1312 /* Program the Transmit Control Register */
1076 1313
1077 tctl = E1000_READ_REG(&adapter->hw, TCTL); 1314 tctl = E1000_READ_REG(hw, TCTL);
1078 1315
1079 tctl &= ~E1000_TCTL_CT; 1316 tctl &= ~E1000_TCTL_CT;
1080 tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | 1317 tctl |= E1000_TCTL_EN | E1000_TCTL_PSP | E1000_TCTL_RTLC |
1081 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); 1318 (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
1082 1319
1083 E1000_WRITE_REG(&adapter->hw, TCTL, tctl); 1320 E1000_WRITE_REG(hw, TCTL, tctl);
1084 1321
1085 e1000_config_collision_dist(&adapter->hw); 1322 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1323 tarc = E1000_READ_REG(hw, TARC0);
1324 tarc |= ((1 << 25) | (1 << 21));
1325 E1000_WRITE_REG(hw, TARC0, tarc);
1326 tarc = E1000_READ_REG(hw, TARC1);
1327 tarc |= (1 << 25);
1328 if (tctl & E1000_TCTL_MULR)
1329 tarc &= ~(1 << 28);
1330 else
1331 tarc |= (1 << 28);
1332 E1000_WRITE_REG(hw, TARC1, tarc);
1333 }
1334
1335 e1000_config_collision_dist(hw);
1086 1336
1087 /* Setup Transmit Descriptor Settings for eop descriptor */ 1337 /* Setup Transmit Descriptor Settings for eop descriptor */
1088 adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP | 1338 adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP |
1089 E1000_TXD_CMD_IFCS; 1339 E1000_TXD_CMD_IFCS;
1090 1340
1091 if(adapter->hw.mac_type < e1000_82543) 1341 if (hw->mac_type < e1000_82543)
1092 adapter->txd_cmd |= E1000_TXD_CMD_RPS; 1342 adapter->txd_cmd |= E1000_TXD_CMD_RPS;
1093 else 1343 else
1094 adapter->txd_cmd |= E1000_TXD_CMD_RS; 1344 adapter->txd_cmd |= E1000_TXD_CMD_RS;
1095 1345
1096 /* Cache if we're 82544 running in PCI-X because we'll 1346 /* Cache if we're 82544 running in PCI-X because we'll
1097 * need this to apply a workaround later in the send path. */ 1347 * need this to apply a workaround later in the send path. */
1098 if(adapter->hw.mac_type == e1000_82544 && 1348 if (hw->mac_type == e1000_82544 &&
1099 adapter->hw.bus_type == e1000_bus_type_pcix) 1349 hw->bus_type == e1000_bus_type_pcix)
1100 adapter->pcix_82544 = 1; 1350 adapter->pcix_82544 = 1;
1101} 1351}
1102 1352
1103/** 1353/**
1104 * e1000_setup_rx_resources - allocate Rx resources (Descriptors) 1354 * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
1105 * @adapter: board private structure 1355 * @adapter: board private structure
1356 * @rxdr: rx descriptor ring (for a specific queue) to setup
1106 * 1357 *
1107 * Returns 0 on success, negative on failure 1358 * Returns 0 on success, negative on failure
1108 **/ 1359 **/
1109 1360
1110int 1361int
1111e1000_setup_rx_resources(struct e1000_adapter *adapter) 1362e1000_setup_rx_resources(struct e1000_adapter *adapter,
1363 struct e1000_rx_ring *rxdr)
1112{ 1364{
1113 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
1114 struct pci_dev *pdev = adapter->pdev; 1365 struct pci_dev *pdev = adapter->pdev;
1115 int size, desc_len; 1366 int size, desc_len;
1116 1367
1117 size = sizeof(struct e1000_buffer) * rxdr->count; 1368 size = sizeof(struct e1000_buffer) * rxdr->count;
1118 rxdr->buffer_info = vmalloc(size); 1369 rxdr->buffer_info = vmalloc(size);
1119 if(!rxdr->buffer_info) { 1370 if (!rxdr->buffer_info) {
1120 DPRINTK(PROBE, ERR, 1371 DPRINTK(PROBE, ERR,
1121 "Unable to allocate memory for the receive descriptor ring\n"); 1372 "Unable to allocate memory for the receive descriptor ring\n");
1122 return -ENOMEM; 1373 return -ENOMEM;
@@ -1156,13 +1407,13 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter)
1156 1407
1157 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); 1408 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1158 1409
1159 if(!rxdr->desc) { 1410 if (!rxdr->desc) {
1411 DPRINTK(PROBE, ERR,
1412 "Unable to allocate memory for the receive descriptor ring\n");
1160setup_rx_desc_die: 1413setup_rx_desc_die:
1161 vfree(rxdr->buffer_info); 1414 vfree(rxdr->buffer_info);
1162 kfree(rxdr->ps_page); 1415 kfree(rxdr->ps_page);
1163 kfree(rxdr->ps_page_dma); 1416 kfree(rxdr->ps_page_dma);
1164 DPRINTK(PROBE, ERR,
1165 "Unable to allocate memory for the receive descriptor ring\n");
1166 return -ENOMEM; 1417 return -ENOMEM;
1167 } 1418 }
1168 1419
@@ -1174,9 +1425,12 @@ setup_rx_desc_die:
1174 "at %p\n", rxdr->size, rxdr->desc); 1425 "at %p\n", rxdr->size, rxdr->desc);
1175 /* Try again, without freeing the previous */ 1426 /* Try again, without freeing the previous */
1176 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma); 1427 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1177 if(!rxdr->desc) {
1178 /* Failed allocation, critical failure */ 1428 /* Failed allocation, critical failure */
1429 if (!rxdr->desc) {
1179 pci_free_consistent(pdev, rxdr->size, olddesc, olddma); 1430 pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
1431 DPRINTK(PROBE, ERR,
1432 "Unable to allocate memory "
1433 "for the receive descriptor ring\n");
1180 goto setup_rx_desc_die; 1434 goto setup_rx_desc_die;
1181 } 1435 }
1182 1436
@@ -1188,10 +1442,7 @@ setup_rx_desc_die:
1188 DPRINTK(PROBE, ERR, 1442 DPRINTK(PROBE, ERR,
1189 "Unable to allocate aligned memory " 1443 "Unable to allocate aligned memory "
1190 "for the receive descriptor ring\n"); 1444 "for the receive descriptor ring\n");
1191 vfree(rxdr->buffer_info); 1445 goto setup_rx_desc_die;
1192 kfree(rxdr->ps_page);
1193 kfree(rxdr->ps_page_dma);
1194 return -ENOMEM;
1195 } else { 1446 } else {
1196 /* Free old allocation, new allocation was successful */ 1447 /* Free old allocation, new allocation was successful */
1197 pci_free_consistent(pdev, rxdr->size, olddesc, olddma); 1448 pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
@@ -1206,15 +1457,48 @@ setup_rx_desc_die:
1206} 1457}
1207 1458
1208/** 1459/**
1460 * e1000_setup_all_rx_resources - wrapper to allocate Rx resources
1461 * (Descriptors) for all queues
1462 * @adapter: board private structure
1463 *
1464 * If this function returns with an error, then it's possible one or
1465 * more of the rings is populated (while the rest are not). It is the
1466 * callers duty to clean those orphaned rings.
1467 *
1468 * Return 0 on success, negative on failure
1469 **/
1470
1471int
1472e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
1473{
1474 int i, err = 0;
1475
1476 for (i = 0; i < adapter->num_queues; i++) {
1477 err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]);
1478 if (err) {
1479 DPRINTK(PROBE, ERR,
1480 "Allocation for Rx Queue %u failed\n", i);
1481 break;
1482 }
1483 }
1484
1485 return err;
1486}
1487
1488/**
1209 * e1000_setup_rctl - configure the receive control registers 1489 * e1000_setup_rctl - configure the receive control registers
1210 * @adapter: Board private structure 1490 * @adapter: Board private structure
1211 **/ 1491 **/
1212 1492#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
1493 (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
1213static void 1494static void
1214e1000_setup_rctl(struct e1000_adapter *adapter) 1495e1000_setup_rctl(struct e1000_adapter *adapter)
1215{ 1496{
1216 uint32_t rctl, rfctl; 1497 uint32_t rctl, rfctl;
1217 uint32_t psrctl = 0; 1498 uint32_t psrctl = 0;
1499#ifdef CONFIG_E1000_PACKET_SPLIT
1500 uint32_t pages = 0;
1501#endif
1218 1502
1219 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1503 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1220 1504
@@ -1235,7 +1519,7 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1235 rctl |= E1000_RCTL_LPE; 1519 rctl |= E1000_RCTL_LPE;
1236 1520
1237 /* Setup buffer sizes */ 1521 /* Setup buffer sizes */
1238 if(adapter->hw.mac_type == e1000_82573) { 1522 if(adapter->hw.mac_type >= e1000_82571) {
1239 /* We can now specify buffers in 1K increments. 1523 /* We can now specify buffers in 1K increments.
1240 * BSIZE and BSEX are ignored in this case. */ 1524 * BSIZE and BSEX are ignored in this case. */
1241 rctl |= adapter->rx_buffer_len << 0x11; 1525 rctl |= adapter->rx_buffer_len << 0x11;
@@ -1268,11 +1552,14 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1268 * followed by the page buffers. Therefore, skb->data is 1552 * followed by the page buffers. Therefore, skb->data is
1269 * sized to hold the largest protocol header. 1553 * sized to hold the largest protocol header.
1270 */ 1554 */
1271 adapter->rx_ps = (adapter->hw.mac_type > e1000_82547_rev_2) 1555 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
1272 && (adapter->netdev->mtu 1556 if ((adapter->hw.mac_type > e1000_82547_rev_2) && (pages <= 3) &&
1273 < ((3 * PAGE_SIZE) + adapter->rx_ps_bsize0)); 1557 PAGE_SIZE <= 16384)
1558 adapter->rx_ps_pages = pages;
1559 else
1560 adapter->rx_ps_pages = 0;
1274#endif 1561#endif
1275 if(adapter->rx_ps) { 1562 if (adapter->rx_ps_pages) {
1276 /* Configure extra packet-split registers */ 1563 /* Configure extra packet-split registers */
1277 rfctl = E1000_READ_REG(&adapter->hw, RFCTL); 1564 rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
1278 rfctl |= E1000_RFCTL_EXTEN; 1565 rfctl |= E1000_RFCTL_EXTEN;
@@ -1284,12 +1571,19 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1284 1571
1285 psrctl |= adapter->rx_ps_bsize0 >> 1572 psrctl |= adapter->rx_ps_bsize0 >>
1286 E1000_PSRCTL_BSIZE0_SHIFT; 1573 E1000_PSRCTL_BSIZE0_SHIFT;
1287 psrctl |= PAGE_SIZE >> 1574
1288 E1000_PSRCTL_BSIZE1_SHIFT; 1575 switch (adapter->rx_ps_pages) {
1289 psrctl |= PAGE_SIZE << 1576 case 3:
1290 E1000_PSRCTL_BSIZE2_SHIFT; 1577 psrctl |= PAGE_SIZE <<
1291 psrctl |= PAGE_SIZE << 1578 E1000_PSRCTL_BSIZE3_SHIFT;
1292 E1000_PSRCTL_BSIZE3_SHIFT; 1579 case 2:
1580 psrctl |= PAGE_SIZE <<
1581 E1000_PSRCTL_BSIZE2_SHIFT;
1582 case 1:
1583 psrctl |= PAGE_SIZE >>
1584 E1000_PSRCTL_BSIZE1_SHIFT;
1585 break;
1586 }
1293 1587
1294 E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl); 1588 E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
1295 } 1589 }
@@ -1307,91 +1601,181 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1307static void 1601static void
1308e1000_configure_rx(struct e1000_adapter *adapter) 1602e1000_configure_rx(struct e1000_adapter *adapter)
1309{ 1603{
1310 uint64_t rdba = adapter->rx_ring.dma; 1604 uint64_t rdba;
1311 uint32_t rdlen, rctl, rxcsum; 1605 struct e1000_hw *hw = &adapter->hw;
1606 uint32_t rdlen, rctl, rxcsum, ctrl_ext;
1607#ifdef CONFIG_E1000_MQ
1608 uint32_t reta, mrqc;
1609 int i;
1610#endif
1312 1611
1313 if(adapter->rx_ps) { 1612 if (adapter->rx_ps_pages) {
1314 rdlen = adapter->rx_ring.count * 1613 rdlen = adapter->rx_ring[0].count *
1315 sizeof(union e1000_rx_desc_packet_split); 1614 sizeof(union e1000_rx_desc_packet_split);
1316 adapter->clean_rx = e1000_clean_rx_irq_ps; 1615 adapter->clean_rx = e1000_clean_rx_irq_ps;
1317 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; 1616 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
1318 } else { 1617 } else {
1319 rdlen = adapter->rx_ring.count * sizeof(struct e1000_rx_desc); 1618 rdlen = adapter->rx_ring[0].count *
1619 sizeof(struct e1000_rx_desc);
1320 adapter->clean_rx = e1000_clean_rx_irq; 1620 adapter->clean_rx = e1000_clean_rx_irq;
1321 adapter->alloc_rx_buf = e1000_alloc_rx_buffers; 1621 adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
1322 } 1622 }
1323 1623
1324 /* disable receives while setting up the descriptors */ 1624 /* disable receives while setting up the descriptors */
1325 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1625 rctl = E1000_READ_REG(hw, RCTL);
1326 E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN); 1626 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
1327 1627
1328 /* set the Receive Delay Timer Register */ 1628 /* set the Receive Delay Timer Register */
1329 E1000_WRITE_REG(&adapter->hw, RDTR, adapter->rx_int_delay); 1629 E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
1330 1630
1331 if(adapter->hw.mac_type >= e1000_82540) { 1631 if (hw->mac_type >= e1000_82540) {
1332 E1000_WRITE_REG(&adapter->hw, RADV, adapter->rx_abs_int_delay); 1632 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
1333 if(adapter->itr > 1) 1633 if(adapter->itr > 1)
1334 E1000_WRITE_REG(&adapter->hw, ITR, 1634 E1000_WRITE_REG(hw, ITR,
1335 1000000000 / (adapter->itr * 256)); 1635 1000000000 / (adapter->itr * 256));
1336 } 1636 }
1337 1637
1338 /* Setup the Base and Length of the Rx Descriptor Ring */ 1638 if (hw->mac_type >= e1000_82571) {
1339 E1000_WRITE_REG(&adapter->hw, RDBAL, (rdba & 0x00000000ffffffffULL)); 1639 /* Reset delay timers after every interrupt */
1340 E1000_WRITE_REG(&adapter->hw, RDBAH, (rdba >> 32)); 1640 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
1641 ctrl_ext |= E1000_CTRL_EXT_CANC;
1642 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
1643 E1000_WRITE_FLUSH(hw);
1644 }
1645
1646 /* Setup the HW Rx Head and Tail Descriptor Pointers and
1647 * the Base and Length of the Rx Descriptor Ring */
1648 switch (adapter->num_queues) {
1649#ifdef CONFIG_E1000_MQ
1650 case 2:
1651 rdba = adapter->rx_ring[1].dma;
1652 E1000_WRITE_REG(hw, RDBAL1, (rdba & 0x00000000ffffffffULL));
1653 E1000_WRITE_REG(hw, RDBAH1, (rdba >> 32));
1654 E1000_WRITE_REG(hw, RDLEN1, rdlen);
1655 E1000_WRITE_REG(hw, RDH1, 0);
1656 E1000_WRITE_REG(hw, RDT1, 0);
1657 adapter->rx_ring[1].rdh = E1000_RDH1;
1658 adapter->rx_ring[1].rdt = E1000_RDT1;
1659 /* Fall Through */
1660#endif
1661 case 1:
1662 default:
1663 rdba = adapter->rx_ring[0].dma;
1664 E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
1665 E1000_WRITE_REG(hw, RDBAH, (rdba >> 32));
1666 E1000_WRITE_REG(hw, RDLEN, rdlen);
1667 E1000_WRITE_REG(hw, RDH, 0);
1668 E1000_WRITE_REG(hw, RDT, 0);
1669 adapter->rx_ring[0].rdh = E1000_RDH;
1670 adapter->rx_ring[0].rdt = E1000_RDT;
1671 break;
1672 }
1673
1674#ifdef CONFIG_E1000_MQ
1675 if (adapter->num_queues > 1) {
1676 uint32_t random[10];
1677
1678 get_random_bytes(&random[0], 40);
1679
1680 if (hw->mac_type <= e1000_82572) {
1681 E1000_WRITE_REG(hw, RSSIR, 0);
1682 E1000_WRITE_REG(hw, RSSIM, 0);
1683 }
1684
1685 switch (adapter->num_queues) {
1686 case 2:
1687 default:
1688 reta = 0x00800080;
1689 mrqc = E1000_MRQC_ENABLE_RSS_2Q;
1690 break;
1691 }
1692
1693 /* Fill out redirection table */
1694 for (i = 0; i < 32; i++)
1695 E1000_WRITE_REG_ARRAY(hw, RETA, i, reta);
1696 /* Fill out hash function seeds */
1697 for (i = 0; i < 10; i++)
1698 E1000_WRITE_REG_ARRAY(hw, RSSRK, i, random[i]);
1699
1700 mrqc |= (E1000_MRQC_RSS_FIELD_IPV4 |
1701 E1000_MRQC_RSS_FIELD_IPV4_TCP);
1702 E1000_WRITE_REG(hw, MRQC, mrqc);
1703 }
1341 1704
1342 E1000_WRITE_REG(&adapter->hw, RDLEN, rdlen); 1705 /* Multiqueue and packet checksumming are mutually exclusive. */
1706 if (hw->mac_type >= e1000_82571) {
1707 rxcsum = E1000_READ_REG(hw, RXCSUM);
1708 rxcsum |= E1000_RXCSUM_PCSD;
1709 E1000_WRITE_REG(hw, RXCSUM, rxcsum);
1710 }
1343 1711
1344 /* Setup the HW Rx Head and Tail Descriptor Pointers */ 1712#else
1345 E1000_WRITE_REG(&adapter->hw, RDH, 0);
1346 E1000_WRITE_REG(&adapter->hw, RDT, 0);
1347 1713
1348 /* Enable 82543 Receive Checksum Offload for TCP and UDP */ 1714 /* Enable 82543 Receive Checksum Offload for TCP and UDP */
1349 if(adapter->hw.mac_type >= e1000_82543) { 1715 if (hw->mac_type >= e1000_82543) {
1350 rxcsum = E1000_READ_REG(&adapter->hw, RXCSUM); 1716 rxcsum = E1000_READ_REG(hw, RXCSUM);
1351 if(adapter->rx_csum == TRUE) { 1717 if(adapter->rx_csum == TRUE) {
1352 rxcsum |= E1000_RXCSUM_TUOFL; 1718 rxcsum |= E1000_RXCSUM_TUOFL;
1353 1719
1354 /* Enable 82573 IPv4 payload checksum for UDP fragments 1720 /* Enable 82571 IPv4 payload checksum for UDP fragments
1355 * Must be used in conjunction with packet-split. */ 1721 * Must be used in conjunction with packet-split. */
1356 if((adapter->hw.mac_type > e1000_82547_rev_2) && 1722 if ((hw->mac_type >= e1000_82571) &&
1357 (adapter->rx_ps)) { 1723 (adapter->rx_ps_pages)) {
1358 rxcsum |= E1000_RXCSUM_IPPCSE; 1724 rxcsum |= E1000_RXCSUM_IPPCSE;
1359 } 1725 }
1360 } else { 1726 } else {
1361 rxcsum &= ~E1000_RXCSUM_TUOFL; 1727 rxcsum &= ~E1000_RXCSUM_TUOFL;
1362 /* don't need to clear IPPCSE as it defaults to 0 */ 1728 /* don't need to clear IPPCSE as it defaults to 0 */
1363 } 1729 }
1364 E1000_WRITE_REG(&adapter->hw, RXCSUM, rxcsum); 1730 E1000_WRITE_REG(hw, RXCSUM, rxcsum);
1365 } 1731 }
1732#endif /* CONFIG_E1000_MQ */
1366 1733
1367 if (adapter->hw.mac_type == e1000_82573) 1734 if (hw->mac_type == e1000_82573)
1368 E1000_WRITE_REG(&adapter->hw, ERT, 0x0100); 1735 E1000_WRITE_REG(hw, ERT, 0x0100);
1369 1736
1370 /* Enable Receives */ 1737 /* Enable Receives */
1371 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1738 E1000_WRITE_REG(hw, RCTL, rctl);
1372} 1739}
1373 1740
1374/** 1741/**
1375 * e1000_free_tx_resources - Free Tx Resources 1742 * e1000_free_tx_resources - Free Tx Resources per Queue
1376 * @adapter: board private structure 1743 * @adapter: board private structure
1744 * @tx_ring: Tx descriptor ring for a specific queue
1377 * 1745 *
1378 * Free all transmit software resources 1746 * Free all transmit software resources
1379 **/ 1747 **/
1380 1748
1381void 1749void
1382e1000_free_tx_resources(struct e1000_adapter *adapter) 1750e1000_free_tx_resources(struct e1000_adapter *adapter,
1751 struct e1000_tx_ring *tx_ring)
1383{ 1752{
1384 struct pci_dev *pdev = adapter->pdev; 1753 struct pci_dev *pdev = adapter->pdev;
1385 1754
1386 e1000_clean_tx_ring(adapter); 1755 e1000_clean_tx_ring(adapter, tx_ring);
1756
1757 vfree(tx_ring->buffer_info);
1758 tx_ring->buffer_info = NULL;
1387 1759
1388 vfree(adapter->tx_ring.buffer_info); 1760 pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
1389 adapter->tx_ring.buffer_info = NULL; 1761
1762 tx_ring->desc = NULL;
1763}
1390 1764
1391 pci_free_consistent(pdev, adapter->tx_ring.size, 1765/**
1392 adapter->tx_ring.desc, adapter->tx_ring.dma); 1766 * e1000_free_all_tx_resources - Free Tx Resources for All Queues
1767 * @adapter: board private structure
1768 *
1769 * Free all transmit software resources
1770 **/
1771
1772void
1773e1000_free_all_tx_resources(struct e1000_adapter *adapter)
1774{
1775 int i;
1393 1776
1394 adapter->tx_ring.desc = NULL; 1777 for (i = 0; i < adapter->num_queues; i++)
1778 e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
1395} 1779}
1396 1780
1397static inline void 1781static inline void
@@ -1414,21 +1798,22 @@ e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
1414/** 1798/**
1415 * e1000_clean_tx_ring - Free Tx Buffers 1799 * e1000_clean_tx_ring - Free Tx Buffers
1416 * @adapter: board private structure 1800 * @adapter: board private structure
1801 * @tx_ring: ring to be cleaned
1417 **/ 1802 **/
1418 1803
1419static void 1804static void
1420e1000_clean_tx_ring(struct e1000_adapter *adapter) 1805e1000_clean_tx_ring(struct e1000_adapter *adapter,
1806 struct e1000_tx_ring *tx_ring)
1421{ 1807{
1422 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
1423 struct e1000_buffer *buffer_info; 1808 struct e1000_buffer *buffer_info;
1424 unsigned long size; 1809 unsigned long size;
1425 unsigned int i; 1810 unsigned int i;
1426 1811
1427 /* Free all the Tx ring sk_buffs */ 1812 /* Free all the Tx ring sk_buffs */
1428 1813
1429 if (likely(adapter->previous_buffer_info.skb != NULL)) { 1814 if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
1430 e1000_unmap_and_free_tx_resource(adapter, 1815 e1000_unmap_and_free_tx_resource(adapter,
1431 &adapter->previous_buffer_info); 1816 &tx_ring->previous_buffer_info);
1432 } 1817 }
1433 1818
1434 for(i = 0; i < tx_ring->count; i++) { 1819 for(i = 0; i < tx_ring->count; i++) {
@@ -1446,24 +1831,39 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter)
1446 tx_ring->next_to_use = 0; 1831 tx_ring->next_to_use = 0;
1447 tx_ring->next_to_clean = 0; 1832 tx_ring->next_to_clean = 0;
1448 1833
1449 E1000_WRITE_REG(&adapter->hw, TDH, 0); 1834 writel(0, adapter->hw.hw_addr + tx_ring->tdh);
1450 E1000_WRITE_REG(&adapter->hw, TDT, 0); 1835 writel(0, adapter->hw.hw_addr + tx_ring->tdt);
1836}
1837
1838/**
1839 * e1000_clean_all_tx_rings - Free Tx Buffers for all queues
1840 * @adapter: board private structure
1841 **/
1842
1843static void
1844e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
1845{
1846 int i;
1847
1848 for (i = 0; i < adapter->num_queues; i++)
1849 e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]);
1451} 1850}
1452 1851
1453/** 1852/**
1454 * e1000_free_rx_resources - Free Rx Resources 1853 * e1000_free_rx_resources - Free Rx Resources
1455 * @adapter: board private structure 1854 * @adapter: board private structure
1855 * @rx_ring: ring to clean the resources from
1456 * 1856 *
1457 * Free all receive software resources 1857 * Free all receive software resources
1458 **/ 1858 **/
1459 1859
1460void 1860void
1461e1000_free_rx_resources(struct e1000_adapter *adapter) 1861e1000_free_rx_resources(struct e1000_adapter *adapter,
1862 struct e1000_rx_ring *rx_ring)
1462{ 1863{
1463 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
1464 struct pci_dev *pdev = adapter->pdev; 1864 struct pci_dev *pdev = adapter->pdev;
1465 1865
1466 e1000_clean_rx_ring(adapter); 1866 e1000_clean_rx_ring(adapter, rx_ring);
1467 1867
1468 vfree(rx_ring->buffer_info); 1868 vfree(rx_ring->buffer_info);
1469 rx_ring->buffer_info = NULL; 1869 rx_ring->buffer_info = NULL;
@@ -1478,14 +1878,31 @@ e1000_free_rx_resources(struct e1000_adapter *adapter)
1478} 1878}
1479 1879
1480/** 1880/**
1481 * e1000_clean_rx_ring - Free Rx Buffers 1881 * e1000_free_all_rx_resources - Free Rx Resources for All Queues
1882 * @adapter: board private structure
1883 *
1884 * Free all receive software resources
1885 **/
1886
1887void
1888e1000_free_all_rx_resources(struct e1000_adapter *adapter)
1889{
1890 int i;
1891
1892 for (i = 0; i < adapter->num_queues; i++)
1893 e1000_free_rx_resources(adapter, &adapter->rx_ring[i]);
1894}
1895
1896/**
1897 * e1000_clean_rx_ring - Free Rx Buffers per Queue
1482 * @adapter: board private structure 1898 * @adapter: board private structure
1899 * @rx_ring: ring to free buffers from
1483 **/ 1900 **/
1484 1901
1485static void 1902static void
1486e1000_clean_rx_ring(struct e1000_adapter *adapter) 1903e1000_clean_rx_ring(struct e1000_adapter *adapter,
1904 struct e1000_rx_ring *rx_ring)
1487{ 1905{
1488 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
1489 struct e1000_buffer *buffer_info; 1906 struct e1000_buffer *buffer_info;
1490 struct e1000_ps_page *ps_page; 1907 struct e1000_ps_page *ps_page;
1491 struct e1000_ps_page_dma *ps_page_dma; 1908 struct e1000_ps_page_dma *ps_page_dma;
@@ -1508,7 +1925,7 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
1508 dev_kfree_skb(buffer_info->skb); 1925 dev_kfree_skb(buffer_info->skb);
1509 buffer_info->skb = NULL; 1926 buffer_info->skb = NULL;
1510 1927
1511 for(j = 0; j < PS_PAGE_BUFFERS; j++) { 1928 for(j = 0; j < adapter->rx_ps_pages; j++) {
1512 if(!ps_page->ps_page[j]) break; 1929 if(!ps_page->ps_page[j]) break;
1513 pci_unmap_single(pdev, 1930 pci_unmap_single(pdev,
1514 ps_page_dma->ps_page_dma[j], 1931 ps_page_dma->ps_page_dma[j],
@@ -1534,8 +1951,22 @@ e1000_clean_rx_ring(struct e1000_adapter *adapter)
1534 rx_ring->next_to_clean = 0; 1951 rx_ring->next_to_clean = 0;
1535 rx_ring->next_to_use = 0; 1952 rx_ring->next_to_use = 0;
1536 1953
1537 E1000_WRITE_REG(&adapter->hw, RDH, 0); 1954 writel(0, adapter->hw.hw_addr + rx_ring->rdh);
1538 E1000_WRITE_REG(&adapter->hw, RDT, 0); 1955 writel(0, adapter->hw.hw_addr + rx_ring->rdt);
1956}
1957
1958/**
1959 * e1000_clean_all_rx_rings - Free Rx Buffers for all queues
1960 * @adapter: board private structure
1961 **/
1962
1963static void
1964e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
1965{
1966 int i;
1967
1968 for (i = 0; i < adapter->num_queues; i++)
1969 e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]);
1539} 1970}
1540 1971
1541/* The 82542 2.0 (revision 2) needs to have the receive unit in reset 1972/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
@@ -1556,7 +1987,7 @@ e1000_enter_82542_rst(struct e1000_adapter *adapter)
1556 mdelay(5); 1987 mdelay(5);
1557 1988
1558 if(netif_running(netdev)) 1989 if(netif_running(netdev))
1559 e1000_clean_rx_ring(adapter); 1990 e1000_clean_all_rx_rings(adapter);
1560} 1991}
1561 1992
1562static void 1993static void
@@ -1576,7 +2007,7 @@ e1000_leave_82542_rst(struct e1000_adapter *adapter)
1576 2007
1577 if(netif_running(netdev)) { 2008 if(netif_running(netdev)) {
1578 e1000_configure_rx(adapter); 2009 e1000_configure_rx(adapter);
1579 e1000_alloc_rx_buffers(adapter); 2010 e1000_alloc_rx_buffers(adapter, &adapter->rx_ring[0]);
1580 } 2011 }
1581} 2012}
1582 2013
@@ -1607,6 +2038,22 @@ e1000_set_mac(struct net_device *netdev, void *p)
1607 2038
1608 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0); 2039 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
1609 2040
2041 /* With 82571 controllers, LAA may be overwritten (with the default)
2042 * due to controller reset from the other port. */
2043 if (adapter->hw.mac_type == e1000_82571) {
2044 /* activate the work around */
2045 adapter->hw.laa_is_present = 1;
2046
2047 /* Hold a copy of the LAA in RAR[14] This is done so that
2048 * between the time RAR[0] gets clobbered and the time it
2049 * gets fixed (in e1000_watchdog), the actual LAA is in one
2050 * of the RARs and no incoming packets directed to this port
2051 * are dropped. Eventaully the LAA will be in RAR[0] and
2052 * RAR[14] */
2053 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr,
2054 E1000_RAR_ENTRIES - 1);
2055 }
2056
1610 if(adapter->hw.mac_type == e1000_82542_rev2_0) 2057 if(adapter->hw.mac_type == e1000_82542_rev2_0)
1611 e1000_leave_82542_rst(adapter); 2058 e1000_leave_82542_rst(adapter);
1612 2059
@@ -1629,12 +2076,13 @@ e1000_set_multi(struct net_device *netdev)
1629 struct e1000_adapter *adapter = netdev_priv(netdev); 2076 struct e1000_adapter *adapter = netdev_priv(netdev);
1630 struct e1000_hw *hw = &adapter->hw; 2077 struct e1000_hw *hw = &adapter->hw;
1631 struct dev_mc_list *mc_ptr; 2078 struct dev_mc_list *mc_ptr;
1632 unsigned long flags;
1633 uint32_t rctl; 2079 uint32_t rctl;
1634 uint32_t hash_value; 2080 uint32_t hash_value;
1635 int i; 2081 int i, rar_entries = E1000_RAR_ENTRIES;
1636 2082
1637 spin_lock_irqsave(&adapter->tx_lock, flags); 2083 /* reserve RAR[14] for LAA over-write work-around */
2084 if (adapter->hw.mac_type == e1000_82571)
2085 rar_entries--;
1638 2086
1639 /* Check for Promiscuous and All Multicast modes */ 2087 /* Check for Promiscuous and All Multicast modes */
1640 2088
@@ -1659,11 +2107,12 @@ e1000_set_multi(struct net_device *netdev)
1659 /* load the first 14 multicast address into the exact filters 1-14 2107 /* load the first 14 multicast address into the exact filters 1-14
1660 * RAR 0 is used for the station MAC adddress 2108 * RAR 0 is used for the station MAC adddress
1661 * if there are not 14 addresses, go ahead and clear the filters 2109 * if there are not 14 addresses, go ahead and clear the filters
2110 * -- with 82571 controllers only 0-13 entries are filled here
1662 */ 2111 */
1663 mc_ptr = netdev->mc_list; 2112 mc_ptr = netdev->mc_list;
1664 2113
1665 for(i = 1; i < E1000_RAR_ENTRIES; i++) { 2114 for(i = 1; i < rar_entries; i++) {
1666 if(mc_ptr) { 2115 if (mc_ptr) {
1667 e1000_rar_set(hw, mc_ptr->dmi_addr, i); 2116 e1000_rar_set(hw, mc_ptr->dmi_addr, i);
1668 mc_ptr = mc_ptr->next; 2117 mc_ptr = mc_ptr->next;
1669 } else { 2118 } else {
@@ -1686,8 +2135,6 @@ e1000_set_multi(struct net_device *netdev)
1686 2135
1687 if(hw->mac_type == e1000_82542_rev2_0) 2136 if(hw->mac_type == e1000_82542_rev2_0)
1688 e1000_leave_82542_rst(adapter); 2137 e1000_leave_82542_rst(adapter);
1689
1690 spin_unlock_irqrestore(&adapter->tx_lock, flags);
1691} 2138}
1692 2139
1693/* Need to wait a few seconds after link up to get diagnostic information from 2140/* Need to wait a few seconds after link up to get diagnostic information from
@@ -1759,7 +2206,7 @@ static void
1759e1000_watchdog_task(struct e1000_adapter *adapter) 2206e1000_watchdog_task(struct e1000_adapter *adapter)
1760{ 2207{
1761 struct net_device *netdev = adapter->netdev; 2208 struct net_device *netdev = adapter->netdev;
1762 struct e1000_desc_ring *txdr = &adapter->tx_ring; 2209 struct e1000_tx_ring *txdr = &adapter->tx_ring[0];
1763 uint32_t link; 2210 uint32_t link;
1764 2211
1765 e1000_check_for_link(&adapter->hw); 2212 e1000_check_for_link(&adapter->hw);
@@ -1818,8 +2265,8 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1818 2265
1819 e1000_update_adaptive(&adapter->hw); 2266 e1000_update_adaptive(&adapter->hw);
1820 2267
1821 if(!netif_carrier_ok(netdev)) { 2268 if (adapter->num_queues == 1 && !netif_carrier_ok(netdev)) {
1822 if(E1000_DESC_UNUSED(txdr) + 1 < txdr->count) { 2269 if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
1823 /* We've lost link, so the controller stops DMA, 2270 /* We've lost link, so the controller stops DMA,
1824 * but we've got queued Tx work that's never going 2271 * but we've got queued Tx work that's never going
1825 * to get done, so reset controller to flush Tx. 2272 * to get done, so reset controller to flush Tx.
@@ -1847,6 +2294,11 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1847 /* Force detection of hung controller every watchdog period */ 2294 /* Force detection of hung controller every watchdog period */
1848 adapter->detect_tx_hung = TRUE; 2295 adapter->detect_tx_hung = TRUE;
1849 2296
2297 /* With 82571 controllers, LAA may be overwritten due to controller
2298 * reset from the other port. Set the appropriate LAA in RAR[0] */
2299 if (adapter->hw.mac_type == e1000_82571 && adapter->hw.laa_is_present)
2300 e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
2301
1850 /* Reset the timer */ 2302 /* Reset the timer */
1851 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 2303 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1852} 2304}
@@ -1859,7 +2311,8 @@ e1000_watchdog_task(struct e1000_adapter *adapter)
1859#define E1000_TX_FLAGS_VLAN_SHIFT 16 2311#define E1000_TX_FLAGS_VLAN_SHIFT 16
1860 2312
1861static inline int 2313static inline int
1862e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb) 2314e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2315 struct sk_buff *skb)
1863{ 2316{
1864#ifdef NETIF_F_TSO 2317#ifdef NETIF_F_TSO
1865 struct e1000_context_desc *context_desc; 2318 struct e1000_context_desc *context_desc;
@@ -1910,8 +2363,8 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
1910 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | 2363 cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
1911 E1000_TXD_CMD_TCP | (skb->len - (hdr_len))); 2364 E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
1912 2365
1913 i = adapter->tx_ring.next_to_use; 2366 i = tx_ring->next_to_use;
1914 context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); 2367 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
1915 2368
1916 context_desc->lower_setup.ip_fields.ipcss = ipcss; 2369 context_desc->lower_setup.ip_fields.ipcss = ipcss;
1917 context_desc->lower_setup.ip_fields.ipcso = ipcso; 2370 context_desc->lower_setup.ip_fields.ipcso = ipcso;
@@ -1923,8 +2376,8 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
1923 context_desc->tcp_seg_setup.fields.hdr_len = hdr_len; 2376 context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
1924 context_desc->cmd_and_length = cpu_to_le32(cmd_length); 2377 context_desc->cmd_and_length = cpu_to_le32(cmd_length);
1925 2378
1926 if(++i == adapter->tx_ring.count) i = 0; 2379 if (++i == tx_ring->count) i = 0;
1927 adapter->tx_ring.next_to_use = i; 2380 tx_ring->next_to_use = i;
1928 2381
1929 return 1; 2382 return 1;
1930 } 2383 }
@@ -1934,7 +2387,8 @@ e1000_tso(struct e1000_adapter *adapter, struct sk_buff *skb)
1934} 2387}
1935 2388
1936static inline boolean_t 2389static inline boolean_t
1937e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) 2390e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2391 struct sk_buff *skb)
1938{ 2392{
1939 struct e1000_context_desc *context_desc; 2393 struct e1000_context_desc *context_desc;
1940 unsigned int i; 2394 unsigned int i;
@@ -1943,8 +2397,8 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
1943 if(likely(skb->ip_summed == CHECKSUM_HW)) { 2397 if(likely(skb->ip_summed == CHECKSUM_HW)) {
1944 css = skb->h.raw - skb->data; 2398 css = skb->h.raw - skb->data;
1945 2399
1946 i = adapter->tx_ring.next_to_use; 2400 i = tx_ring->next_to_use;
1947 context_desc = E1000_CONTEXT_DESC(adapter->tx_ring, i); 2401 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
1948 2402
1949 context_desc->upper_setup.tcp_fields.tucss = css; 2403 context_desc->upper_setup.tcp_fields.tucss = css;
1950 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum; 2404 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum;
@@ -1952,8 +2406,8 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
1952 context_desc->tcp_seg_setup.data = 0; 2406 context_desc->tcp_seg_setup.data = 0;
1953 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT); 2407 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
1954 2408
1955 if(unlikely(++i == adapter->tx_ring.count)) i = 0; 2409 if (unlikely(++i == tx_ring->count)) i = 0;
1956 adapter->tx_ring.next_to_use = i; 2410 tx_ring->next_to_use = i;
1957 2411
1958 return TRUE; 2412 return TRUE;
1959 } 2413 }
@@ -1965,11 +2419,10 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb)
1965#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR) 2419#define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR)
1966 2420
1967static inline int 2421static inline int
1968e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb, 2422e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
1969 unsigned int first, unsigned int max_per_txd, 2423 struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
1970 unsigned int nr_frags, unsigned int mss) 2424 unsigned int nr_frags, unsigned int mss)
1971{ 2425{
1972 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
1973 struct e1000_buffer *buffer_info; 2426 struct e1000_buffer *buffer_info;
1974 unsigned int len = skb->len; 2427 unsigned int len = skb->len;
1975 unsigned int offset = 0, size, count = 0, i; 2428 unsigned int offset = 0, size, count = 0, i;
@@ -2065,9 +2518,9 @@ e1000_tx_map(struct e1000_adapter *adapter, struct sk_buff *skb,
2065} 2518}
2066 2519
2067static inline void 2520static inline void
2068e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags) 2521e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2522 int tx_flags, int count)
2069{ 2523{
2070 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
2071 struct e1000_tx_desc *tx_desc = NULL; 2524 struct e1000_tx_desc *tx_desc = NULL;
2072 struct e1000_buffer *buffer_info; 2525 struct e1000_buffer *buffer_info;
2073 uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS; 2526 uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
@@ -2113,7 +2566,7 @@ e1000_tx_queue(struct e1000_adapter *adapter, int count, int tx_flags)
2113 wmb(); 2566 wmb();
2114 2567
2115 tx_ring->next_to_use = i; 2568 tx_ring->next_to_use = i;
2116 E1000_WRITE_REG(&adapter->hw, TDT, i); 2569 writel(i, adapter->hw.hw_addr + tx_ring->tdt);
2117} 2570}
2118 2571
2119/** 2572/**
@@ -2206,6 +2659,7 @@ static int
2206e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 2659e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2207{ 2660{
2208 struct e1000_adapter *adapter = netdev_priv(netdev); 2661 struct e1000_adapter *adapter = netdev_priv(netdev);
2662 struct e1000_tx_ring *tx_ring;
2209 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD; 2663 unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
2210 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR; 2664 unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
2211 unsigned int tx_flags = 0; 2665 unsigned int tx_flags = 0;
@@ -2218,7 +2672,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2218 unsigned int f; 2672 unsigned int f;
2219 len -= skb->data_len; 2673 len -= skb->data_len;
2220 2674
2221 if(unlikely(skb->len <= 0)) { 2675#ifdef CONFIG_E1000_MQ
2676 tx_ring = *per_cpu_ptr(adapter->cpu_tx_ring, smp_processor_id());
2677#else
2678 tx_ring = adapter->tx_ring;
2679#endif
2680
2681 if (unlikely(skb->len <= 0)) {
2222 dev_kfree_skb_any(skb); 2682 dev_kfree_skb_any(skb);
2223 return NETDEV_TX_OK; 2683 return NETDEV_TX_OK;
2224 } 2684 }
@@ -2262,21 +2722,42 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2262 if(adapter->pcix_82544) 2722 if(adapter->pcix_82544)
2263 count += nr_frags; 2723 count += nr_frags;
2264 2724
2265 local_irq_save(flags); 2725#ifdef NETIF_F_TSO
2266 if (!spin_trylock(&adapter->tx_lock)) { 2726 /* TSO Workaround for 82571/2 Controllers -- if skb->data
2267 /* Collision - tell upper layer to requeue */ 2727 * points to just header, pull a few bytes of payload from
2268 local_irq_restore(flags); 2728 * frags into skb->data */
2269 return NETDEV_TX_LOCKED; 2729 if (skb_shinfo(skb)->tso_size) {
2270 } 2730 uint8_t hdr_len;
2731 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
2732 if (skb->data_len && (hdr_len < (skb->len - skb->data_len)) &&
2733 (adapter->hw.mac_type == e1000_82571 ||
2734 adapter->hw.mac_type == e1000_82572)) {
2735 unsigned int pull_size;
2736 pull_size = min((unsigned int)4, skb->data_len);
2737 if (!__pskb_pull_tail(skb, pull_size)) {
2738 printk(KERN_ERR "__pskb_pull_tail failed.\n");
2739 dev_kfree_skb_any(skb);
2740 return -EFAULT;
2741 }
2742 }
2743 }
2744#endif
2745
2271 if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == e1000_82573) ) 2746 if(adapter->hw.tx_pkt_filtering && (adapter->hw.mac_type == e1000_82573) )
2272 e1000_transfer_dhcp_info(adapter, skb); 2747 e1000_transfer_dhcp_info(adapter, skb);
2273 2748
2749 local_irq_save(flags);
2750 if (!spin_trylock(&tx_ring->tx_lock)) {
2751 /* Collision - tell upper layer to requeue */
2752 local_irq_restore(flags);
2753 return NETDEV_TX_LOCKED;
2754 }
2274 2755
2275 /* need: count + 2 desc gap to keep tail from touching 2756 /* need: count + 2 desc gap to keep tail from touching
2276 * head, otherwise try next time */ 2757 * head, otherwise try next time */
2277 if(unlikely(E1000_DESC_UNUSED(&adapter->tx_ring) < count + 2)) { 2758 if (unlikely(E1000_DESC_UNUSED(tx_ring) < count + 2)) {
2278 netif_stop_queue(netdev); 2759 netif_stop_queue(netdev);
2279 spin_unlock_irqrestore(&adapter->tx_lock, flags); 2760 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
2280 return NETDEV_TX_BUSY; 2761 return NETDEV_TX_BUSY;
2281 } 2762 }
2282 2763
@@ -2284,7 +2765,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2284 if(unlikely(e1000_82547_fifo_workaround(adapter, skb))) { 2765 if(unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
2285 netif_stop_queue(netdev); 2766 netif_stop_queue(netdev);
2286 mod_timer(&adapter->tx_fifo_stall_timer, jiffies); 2767 mod_timer(&adapter->tx_fifo_stall_timer, jiffies);
2287 spin_unlock_irqrestore(&adapter->tx_lock, flags); 2768 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
2288 return NETDEV_TX_BUSY; 2769 return NETDEV_TX_BUSY;
2289 } 2770 }
2290 } 2771 }
@@ -2294,37 +2775,37 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2294 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); 2775 tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
2295 } 2776 }
2296 2777
2297 first = adapter->tx_ring.next_to_use; 2778 first = tx_ring->next_to_use;
2298 2779
2299 tso = e1000_tso(adapter, skb); 2780 tso = e1000_tso(adapter, tx_ring, skb);
2300 if (tso < 0) { 2781 if (tso < 0) {
2301 dev_kfree_skb_any(skb); 2782 dev_kfree_skb_any(skb);
2302 spin_unlock_irqrestore(&adapter->tx_lock, flags); 2783 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
2303 return NETDEV_TX_OK; 2784 return NETDEV_TX_OK;
2304 } 2785 }
2305 2786
2306 if (likely(tso)) 2787 if (likely(tso))
2307 tx_flags |= E1000_TX_FLAGS_TSO; 2788 tx_flags |= E1000_TX_FLAGS_TSO;
2308 else if(likely(e1000_tx_csum(adapter, skb))) 2789 else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
2309 tx_flags |= E1000_TX_FLAGS_CSUM; 2790 tx_flags |= E1000_TX_FLAGS_CSUM;
2310 2791
2311 /* Old method was to assume IPv4 packet by default if TSO was enabled. 2792 /* Old method was to assume IPv4 packet by default if TSO was enabled.
2312 * 82573 hardware supports TSO capabilities for IPv6 as well... 2793 * 82571 hardware supports TSO capabilities for IPv6 as well...
2313 * no longer assume, we must. */ 2794 * no longer assume, we must. */
2314 if(likely(skb->protocol == ntohs(ETH_P_IP))) 2795 if (likely(skb->protocol == ntohs(ETH_P_IP)))
2315 tx_flags |= E1000_TX_FLAGS_IPV4; 2796 tx_flags |= E1000_TX_FLAGS_IPV4;
2316 2797
2317 e1000_tx_queue(adapter, 2798 e1000_tx_queue(adapter, tx_ring, tx_flags,
2318 e1000_tx_map(adapter, skb, first, max_per_txd, nr_frags, mss), 2799 e1000_tx_map(adapter, tx_ring, skb, first,
2319 tx_flags); 2800 max_per_txd, nr_frags, mss));
2320 2801
2321 netdev->trans_start = jiffies; 2802 netdev->trans_start = jiffies;
2322 2803
2323 /* Make sure there is space in the ring for the next send. */ 2804 /* Make sure there is space in the ring for the next send. */
2324 if(unlikely(E1000_DESC_UNUSED(&adapter->tx_ring) < MAX_SKB_FRAGS + 2)) 2805 if (unlikely(E1000_DESC_UNUSED(tx_ring) < MAX_SKB_FRAGS + 2))
2325 netif_stop_queue(netdev); 2806 netif_stop_queue(netdev);
2326 2807
2327 spin_unlock_irqrestore(&adapter->tx_lock, flags); 2808 spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
2328 return NETDEV_TX_OK; 2809 return NETDEV_TX_OK;
2329} 2810}
2330 2811
@@ -2388,9 +2869,18 @@ e1000_change_mtu(struct net_device *netdev, int new_mtu)
2388 return -EINVAL; 2869 return -EINVAL;
2389 } 2870 }
2390 2871
2391#define MAX_STD_JUMBO_FRAME_SIZE 9216 2872#define MAX_STD_JUMBO_FRAME_SIZE 9234
2392 /* might want this to be bigger enum check... */ 2873 /* might want this to be bigger enum check... */
2393 if (adapter->hw.mac_type == e1000_82573 && 2874 /* 82571 controllers limit jumbo frame size to 10500 bytes */
2875 if ((adapter->hw.mac_type == e1000_82571 ||
2876 adapter->hw.mac_type == e1000_82572) &&
2877 max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
2878 DPRINTK(PROBE, ERR, "MTU > 9216 bytes not supported "
2879 "on 82571 and 82572 controllers.\n");
2880 return -EINVAL;
2881 }
2882
2883 if(adapter->hw.mac_type == e1000_82573 &&
2394 max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 2884 max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
2395 DPRINTK(PROBE, ERR, "Jumbo Frames not supported " 2885 DPRINTK(PROBE, ERR, "Jumbo Frames not supported "
2396 "on 82573\n"); 2886 "on 82573\n");
@@ -2578,6 +3068,29 @@ e1000_update_stats(struct e1000_adapter *adapter)
2578 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3068 spin_unlock_irqrestore(&adapter->stats_lock, flags);
2579} 3069}
2580 3070
3071#ifdef CONFIG_E1000_MQ
3072void
3073e1000_rx_schedule(void *data)
3074{
3075 struct net_device *poll_dev, *netdev = data;
3076 struct e1000_adapter *adapter = netdev->priv;
3077 int this_cpu = get_cpu();
3078
3079 poll_dev = *per_cpu_ptr(adapter->cpu_netdev, this_cpu);
3080 if (poll_dev == NULL) {
3081 put_cpu();
3082 return;
3083 }
3084
3085 if (likely(netif_rx_schedule_prep(poll_dev)))
3086 __netif_rx_schedule(poll_dev);
3087 else
3088 e1000_irq_enable(adapter);
3089
3090 put_cpu();
3091}
3092#endif
3093
2581/** 3094/**
2582 * e1000_intr - Interrupt Handler 3095 * e1000_intr - Interrupt Handler
2583 * @irq: interrupt number 3096 * @irq: interrupt number
@@ -2592,8 +3105,8 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2592 struct e1000_adapter *adapter = netdev_priv(netdev); 3105 struct e1000_adapter *adapter = netdev_priv(netdev);
2593 struct e1000_hw *hw = &adapter->hw; 3106 struct e1000_hw *hw = &adapter->hw;
2594 uint32_t icr = E1000_READ_REG(hw, ICR); 3107 uint32_t icr = E1000_READ_REG(hw, ICR);
2595#ifndef CONFIG_E1000_NAPI 3108#if defined(CONFIG_E1000_NAPI) && defined(CONFIG_E1000_MQ) || !defined(CONFIG_E1000_NAPI)
2596 unsigned int i; 3109 int i;
2597#endif 3110#endif
2598 3111
2599 if(unlikely(!icr)) 3112 if(unlikely(!icr))
@@ -2605,17 +3118,31 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2605 } 3118 }
2606 3119
2607#ifdef CONFIG_E1000_NAPI 3120#ifdef CONFIG_E1000_NAPI
2608 if(likely(netif_rx_schedule_prep(netdev))) { 3121 atomic_inc(&adapter->irq_sem);
2609 3122 E1000_WRITE_REG(hw, IMC, ~0);
2610 /* Disable interrupts and register for poll. The flush 3123 E1000_WRITE_FLUSH(hw);
2611 of the posted write is intentionally left out. 3124#ifdef CONFIG_E1000_MQ
2612 */ 3125 if (atomic_read(&adapter->rx_sched_call_data.count) == 0) {
2613 3126 cpu_set(adapter->cpu_for_queue[0],
2614 atomic_inc(&adapter->irq_sem); 3127 adapter->rx_sched_call_data.cpumask);
2615 E1000_WRITE_REG(hw, IMC, ~0); 3128 for (i = 1; i < adapter->num_queues; i++) {
2616 __netif_rx_schedule(netdev); 3129 cpu_set(adapter->cpu_for_queue[i],
3130 adapter->rx_sched_call_data.cpumask);
3131 atomic_inc(&adapter->irq_sem);
3132 }
3133 atomic_set(&adapter->rx_sched_call_data.count, i);
3134 smp_call_async_mask(&adapter->rx_sched_call_data);
3135 } else {
3136 printk("call_data.count == %u\n", atomic_read(&adapter->rx_sched_call_data.count));
2617 } 3137 }
2618#else 3138#else /* if !CONFIG_E1000_MQ */
3139 if (likely(netif_rx_schedule_prep(&adapter->polling_netdev[0])))
3140 __netif_rx_schedule(&adapter->polling_netdev[0]);
3141 else
3142 e1000_irq_enable(adapter);
3143#endif /* CONFIG_E1000_MQ */
3144
3145#else /* if !CONFIG_E1000_NAPI */
2619 /* Writing IMC and IMS is needed for 82547. 3146 /* Writing IMC and IMS is needed for 82547.
2620 Due to Hub Link bus being occupied, an interrupt 3147 Due to Hub Link bus being occupied, an interrupt
2621 de-assertion message is not able to be sent. 3148 de-assertion message is not able to be sent.
@@ -2632,13 +3159,14 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2632 } 3159 }
2633 3160
2634 for(i = 0; i < E1000_MAX_INTR; i++) 3161 for(i = 0; i < E1000_MAX_INTR; i++)
2635 if(unlikely(!adapter->clean_rx(adapter) & 3162 if(unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
2636 !e1000_clean_tx_irq(adapter))) 3163 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
2637 break; 3164 break;
2638 3165
2639 if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2) 3166 if(hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
2640 e1000_irq_enable(adapter); 3167 e1000_irq_enable(adapter);
2641#endif 3168
3169#endif /* CONFIG_E1000_NAPI */
2642 3170
2643 return IRQ_HANDLED; 3171 return IRQ_HANDLED;
2644} 3172}
@@ -2650,22 +3178,37 @@ e1000_intr(int irq, void *data, struct pt_regs *regs)
2650 **/ 3178 **/
2651 3179
2652static int 3180static int
2653e1000_clean(struct net_device *netdev, int *budget) 3181e1000_clean(struct net_device *poll_dev, int *budget)
2654{ 3182{
2655 struct e1000_adapter *adapter = netdev_priv(netdev); 3183 struct e1000_adapter *adapter;
2656 int work_to_do = min(*budget, netdev->quota); 3184 int work_to_do = min(*budget, poll_dev->quota);
2657 int tx_cleaned; 3185 int tx_cleaned, i = 0, work_done = 0;
2658 int work_done = 0;
2659 3186
2660 tx_cleaned = e1000_clean_tx_irq(adapter); 3187 /* Must NOT use netdev_priv macro here. */
2661 adapter->clean_rx(adapter, &work_done, work_to_do); 3188 adapter = poll_dev->priv;
3189
3190 /* Keep link state information with original netdev */
3191 if (!netif_carrier_ok(adapter->netdev))
3192 goto quit_polling;
3193
3194 while (poll_dev != &adapter->polling_netdev[i]) {
3195 i++;
3196 if (unlikely(i == adapter->num_queues))
3197 BUG();
3198 }
3199
3200 tx_cleaned = e1000_clean_tx_irq(adapter, &adapter->tx_ring[i]);
3201 adapter->clean_rx(adapter, &adapter->rx_ring[i],
3202 &work_done, work_to_do);
2662 3203
2663 *budget -= work_done; 3204 *budget -= work_done;
2664 netdev->quota -= work_done; 3205 poll_dev->quota -= work_done;
2665 3206
2666 if ((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
2667 /* If no Tx and not enough Rx work done, exit the polling mode */ 3207 /* If no Tx and not enough Rx work done, exit the polling mode */
2668 netif_rx_complete(netdev); 3208 if((!tx_cleaned && (work_done == 0)) ||
3209 !netif_running(adapter->netdev)) {
3210quit_polling:
3211 netif_rx_complete(poll_dev);
2669 e1000_irq_enable(adapter); 3212 e1000_irq_enable(adapter);
2670 return 0; 3213 return 0;
2671 } 3214 }
@@ -2680,9 +3223,9 @@ e1000_clean(struct net_device *netdev, int *budget)
2680 **/ 3223 **/
2681 3224
2682static boolean_t 3225static boolean_t
2683e1000_clean_tx_irq(struct e1000_adapter *adapter) 3226e1000_clean_tx_irq(struct e1000_adapter *adapter,
3227 struct e1000_tx_ring *tx_ring)
2684{ 3228{
2685 struct e1000_desc_ring *tx_ring = &adapter->tx_ring;
2686 struct net_device *netdev = adapter->netdev; 3229 struct net_device *netdev = adapter->netdev;
2687 struct e1000_tx_desc *tx_desc, *eop_desc; 3230 struct e1000_tx_desc *tx_desc, *eop_desc;
2688 struct e1000_buffer *buffer_info; 3231 struct e1000_buffer *buffer_info;
@@ -2693,12 +3236,12 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2693 eop = tx_ring->buffer_info[i].next_to_watch; 3236 eop = tx_ring->buffer_info[i].next_to_watch;
2694 eop_desc = E1000_TX_DESC(*tx_ring, eop); 3237 eop_desc = E1000_TX_DESC(*tx_ring, eop);
2695 3238
2696 while(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { 3239 while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
2697 /* Premature writeback of Tx descriptors clear (free buffers 3240 /* Premature writeback of Tx descriptors clear (free buffers
2698 * and unmap pci_mapping) previous_buffer_info */ 3241 * and unmap pci_mapping) previous_buffer_info */
2699 if (likely(adapter->previous_buffer_info.skb != NULL)) { 3242 if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
2700 e1000_unmap_and_free_tx_resource(adapter, 3243 e1000_unmap_and_free_tx_resource(adapter,
2701 &adapter->previous_buffer_info); 3244 &tx_ring->previous_buffer_info);
2702 } 3245 }
2703 3246
2704 for(cleaned = FALSE; !cleaned; ) { 3247 for(cleaned = FALSE; !cleaned; ) {
@@ -2714,7 +3257,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2714#ifdef NETIF_F_TSO 3257#ifdef NETIF_F_TSO
2715 } else { 3258 } else {
2716 if (cleaned) { 3259 if (cleaned) {
2717 memcpy(&adapter->previous_buffer_info, 3260 memcpy(&tx_ring->previous_buffer_info,
2718 buffer_info, 3261 buffer_info,
2719 sizeof(struct e1000_buffer)); 3262 sizeof(struct e1000_buffer));
2720 memset(buffer_info, 0, 3263 memset(buffer_info, 0,
@@ -2732,6 +3275,8 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2732 3275
2733 if(unlikely(++i == tx_ring->count)) i = 0; 3276 if(unlikely(++i == tx_ring->count)) i = 0;
2734 } 3277 }
3278
3279 tx_ring->pkt++;
2735 3280
2736 eop = tx_ring->buffer_info[i].next_to_watch; 3281 eop = tx_ring->buffer_info[i].next_to_watch;
2737 eop_desc = E1000_TX_DESC(*tx_ring, eop); 3282 eop_desc = E1000_TX_DESC(*tx_ring, eop);
@@ -2739,15 +3284,15 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2739 3284
2740 tx_ring->next_to_clean = i; 3285 tx_ring->next_to_clean = i;
2741 3286
2742 spin_lock(&adapter->tx_lock); 3287 spin_lock(&tx_ring->tx_lock);
2743 3288
2744 if(unlikely(cleaned && netif_queue_stopped(netdev) && 3289 if(unlikely(cleaned && netif_queue_stopped(netdev) &&
2745 netif_carrier_ok(netdev))) 3290 netif_carrier_ok(netdev)))
2746 netif_wake_queue(netdev); 3291 netif_wake_queue(netdev);
2747 3292
2748 spin_unlock(&adapter->tx_lock); 3293 spin_unlock(&tx_ring->tx_lock);
2749 if(adapter->detect_tx_hung) {
2750 3294
3295 if (adapter->detect_tx_hung) {
2751 /* Detect a transmit hang in hardware, this serializes the 3296 /* Detect a transmit hang in hardware, this serializes the
2752 * check with the clearing of time_stamp and movement of i */ 3297 * check with the clearing of time_stamp and movement of i */
2753 adapter->detect_tx_hung = FALSE; 3298 adapter->detect_tx_hung = FALSE;
@@ -2771,8 +3316,8 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2771 " next_to_watch <%x>\n" 3316 " next_to_watch <%x>\n"
2772 " jiffies <%lx>\n" 3317 " jiffies <%lx>\n"
2773 " next_to_watch.status <%x>\n", 3318 " next_to_watch.status <%x>\n",
2774 E1000_READ_REG(&adapter->hw, TDH), 3319 readl(adapter->hw.hw_addr + tx_ring->tdh),
2775 E1000_READ_REG(&adapter->hw, TDT), 3320 readl(adapter->hw.hw_addr + tx_ring->tdt),
2776 tx_ring->next_to_use, 3321 tx_ring->next_to_use,
2777 i, 3322 i,
2778 (unsigned long long)tx_ring->buffer_info[i].dma, 3323 (unsigned long long)tx_ring->buffer_info[i].dma,
@@ -2784,12 +3329,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter)
2784 } 3329 }
2785 } 3330 }
2786#ifdef NETIF_F_TSO 3331#ifdef NETIF_F_TSO
2787 3332 if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
2788 if( unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && 3333 time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ)))
2789 time_after(jiffies, adapter->previous_buffer_info.time_stamp + HZ)))
2790 e1000_unmap_and_free_tx_resource( 3334 e1000_unmap_and_free_tx_resource(
2791 adapter, &adapter->previous_buffer_info); 3335 adapter, &tx_ring->previous_buffer_info);
2792
2793#endif 3336#endif
2794 return cleaned; 3337 return cleaned;
2795} 3338}
@@ -2852,13 +3395,14 @@ e1000_rx_checksum(struct e1000_adapter *adapter,
2852 3395
2853static boolean_t 3396static boolean_t
2854#ifdef CONFIG_E1000_NAPI 3397#ifdef CONFIG_E1000_NAPI
2855e1000_clean_rx_irq(struct e1000_adapter *adapter, int *work_done, 3398e1000_clean_rx_irq(struct e1000_adapter *adapter,
2856 int work_to_do) 3399 struct e1000_rx_ring *rx_ring,
3400 int *work_done, int work_to_do)
2857#else 3401#else
2858e1000_clean_rx_irq(struct e1000_adapter *adapter) 3402e1000_clean_rx_irq(struct e1000_adapter *adapter,
3403 struct e1000_rx_ring *rx_ring)
2859#endif 3404#endif
2860{ 3405{
2861 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
2862 struct net_device *netdev = adapter->netdev; 3406 struct net_device *netdev = adapter->netdev;
2863 struct pci_dev *pdev = adapter->pdev; 3407 struct pci_dev *pdev = adapter->pdev;
2864 struct e1000_rx_desc *rx_desc; 3408 struct e1000_rx_desc *rx_desc;
@@ -2944,6 +3488,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter)
2944 } 3488 }
2945#endif /* CONFIG_E1000_NAPI */ 3489#endif /* CONFIG_E1000_NAPI */
2946 netdev->last_rx = jiffies; 3490 netdev->last_rx = jiffies;
3491 rx_ring->pkt++;
2947 3492
2948next_desc: 3493next_desc:
2949 rx_desc->status = 0; 3494 rx_desc->status = 0;
@@ -2953,7 +3498,7 @@ next_desc:
2953 rx_desc = E1000_RX_DESC(*rx_ring, i); 3498 rx_desc = E1000_RX_DESC(*rx_ring, i);
2954 } 3499 }
2955 rx_ring->next_to_clean = i; 3500 rx_ring->next_to_clean = i;
2956 adapter->alloc_rx_buf(adapter); 3501 adapter->alloc_rx_buf(adapter, rx_ring);
2957 3502
2958 return cleaned; 3503 return cleaned;
2959} 3504}
@@ -2965,13 +3510,14 @@ next_desc:
2965 3510
2966static boolean_t 3511static boolean_t
2967#ifdef CONFIG_E1000_NAPI 3512#ifdef CONFIG_E1000_NAPI
2968e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, int *work_done, 3513e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
2969 int work_to_do) 3514 struct e1000_rx_ring *rx_ring,
3515 int *work_done, int work_to_do)
2970#else 3516#else
2971e1000_clean_rx_irq_ps(struct e1000_adapter *adapter) 3517e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3518 struct e1000_rx_ring *rx_ring)
2972#endif 3519#endif
2973{ 3520{
2974 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
2975 union e1000_rx_desc_packet_split *rx_desc; 3521 union e1000_rx_desc_packet_split *rx_desc;
2976 struct net_device *netdev = adapter->netdev; 3522 struct net_device *netdev = adapter->netdev;
2977 struct pci_dev *pdev = adapter->pdev; 3523 struct pci_dev *pdev = adapter->pdev;
@@ -3027,7 +3573,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
3027 /* Good Receive */ 3573 /* Good Receive */
3028 skb_put(skb, length); 3574 skb_put(skb, length);
3029 3575
3030 for(j = 0; j < PS_PAGE_BUFFERS; j++) { 3576 for(j = 0; j < adapter->rx_ps_pages; j++) {
3031 if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j]))) 3577 if(!(length = le16_to_cpu(rx_desc->wb.upper.length[j])))
3032 break; 3578 break;
3033 3579
@@ -3048,11 +3594,13 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
3048 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb); 3594 rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
3049 skb->protocol = eth_type_trans(skb, netdev); 3595 skb->protocol = eth_type_trans(skb, netdev);
3050 3596
3051#ifdef HAVE_RX_ZERO_COPY
3052 if(likely(rx_desc->wb.upper.header_status & 3597 if(likely(rx_desc->wb.upper.header_status &
3053 E1000_RXDPS_HDRSTAT_HDRSP)) 3598 E1000_RXDPS_HDRSTAT_HDRSP)) {
3599 adapter->rx_hdr_split++;
3600#ifdef HAVE_RX_ZERO_COPY
3054 skb_shinfo(skb)->zero_copy = TRUE; 3601 skb_shinfo(skb)->zero_copy = TRUE;
3055#endif 3602#endif
3603 }
3056#ifdef CONFIG_E1000_NAPI 3604#ifdef CONFIG_E1000_NAPI
3057 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) { 3605 if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
3058 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 3606 vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
@@ -3071,6 +3619,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter)
3071 } 3619 }
3072#endif /* CONFIG_E1000_NAPI */ 3620#endif /* CONFIG_E1000_NAPI */
3073 netdev->last_rx = jiffies; 3621 netdev->last_rx = jiffies;
3622 rx_ring->pkt++;
3074 3623
3075next_desc: 3624next_desc:
3076 rx_desc->wb.middle.status_error &= ~0xFF; 3625 rx_desc->wb.middle.status_error &= ~0xFF;
@@ -3081,7 +3630,7 @@ next_desc:
3081 staterr = le32_to_cpu(rx_desc->wb.middle.status_error); 3630 staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
3082 } 3631 }
3083 rx_ring->next_to_clean = i; 3632 rx_ring->next_to_clean = i;
3084 adapter->alloc_rx_buf(adapter); 3633 adapter->alloc_rx_buf(adapter, rx_ring);
3085 3634
3086 return cleaned; 3635 return cleaned;
3087} 3636}
@@ -3092,9 +3641,9 @@ next_desc:
3092 **/ 3641 **/
3093 3642
3094static void 3643static void
3095e1000_alloc_rx_buffers(struct e1000_adapter *adapter) 3644e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
3645 struct e1000_rx_ring *rx_ring)
3096{ 3646{
3097 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
3098 struct net_device *netdev = adapter->netdev; 3647 struct net_device *netdev = adapter->netdev;
3099 struct pci_dev *pdev = adapter->pdev; 3648 struct pci_dev *pdev = adapter->pdev;
3100 struct e1000_rx_desc *rx_desc; 3649 struct e1000_rx_desc *rx_desc;
@@ -3178,7 +3727,7 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
3178 * applicable for weak-ordered memory model archs, 3727 * applicable for weak-ordered memory model archs,
3179 * such as IA-64). */ 3728 * such as IA-64). */
3180 wmb(); 3729 wmb();
3181 E1000_WRITE_REG(&adapter->hw, RDT, i); 3730 writel(i, adapter->hw.hw_addr + rx_ring->rdt);
3182 } 3731 }
3183 3732
3184 if(unlikely(++i == rx_ring->count)) i = 0; 3733 if(unlikely(++i == rx_ring->count)) i = 0;
@@ -3194,9 +3743,9 @@ e1000_alloc_rx_buffers(struct e1000_adapter *adapter)
3194 **/ 3743 **/
3195 3744
3196static void 3745static void
3197e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter) 3746e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
3747 struct e1000_rx_ring *rx_ring)
3198{ 3748{
3199 struct e1000_desc_ring *rx_ring = &adapter->rx_ring;
3200 struct net_device *netdev = adapter->netdev; 3749 struct net_device *netdev = adapter->netdev;
3201 struct pci_dev *pdev = adapter->pdev; 3750 struct pci_dev *pdev = adapter->pdev;
3202 union e1000_rx_desc_packet_split *rx_desc; 3751 union e1000_rx_desc_packet_split *rx_desc;
@@ -3215,22 +3764,26 @@ e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter)
3215 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 3764 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
3216 3765
3217 for(j = 0; j < PS_PAGE_BUFFERS; j++) { 3766 for(j = 0; j < PS_PAGE_BUFFERS; j++) {
3218 if(unlikely(!ps_page->ps_page[j])) { 3767 if (j < adapter->rx_ps_pages) {
3219 ps_page->ps_page[j] = 3768 if (likely(!ps_page->ps_page[j])) {
3220 alloc_page(GFP_ATOMIC); 3769 ps_page->ps_page[j] =
3221 if(unlikely(!ps_page->ps_page[j])) 3770 alloc_page(GFP_ATOMIC);
3222 goto no_buffers; 3771 if (unlikely(!ps_page->ps_page[j]))
3223 ps_page_dma->ps_page_dma[j] = 3772 goto no_buffers;
3224 pci_map_page(pdev, 3773 ps_page_dma->ps_page_dma[j] =
3225 ps_page->ps_page[j], 3774 pci_map_page(pdev,
3226 0, PAGE_SIZE, 3775 ps_page->ps_page[j],
3227 PCI_DMA_FROMDEVICE); 3776 0, PAGE_SIZE,
3228 } 3777 PCI_DMA_FROMDEVICE);
3229 /* Refresh the desc even if buffer_addrs didn't 3778 }
3230 * change because each write-back erases this info. 3779 /* Refresh the desc even if buffer_addrs didn't
3231 */ 3780 * change because each write-back erases
3232 rx_desc->read.buffer_addr[j+1] = 3781 * this info.
3233 cpu_to_le64(ps_page_dma->ps_page_dma[j]); 3782 */
3783 rx_desc->read.buffer_addr[j+1] =
3784 cpu_to_le64(ps_page_dma->ps_page_dma[j]);
3785 } else
3786 rx_desc->read.buffer_addr[j+1] = ~0;
3234 } 3787 }
3235 3788
3236 skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN); 3789 skb = dev_alloc_skb(adapter->rx_ps_bsize0 + NET_IP_ALIGN);
@@ -3264,7 +3817,7 @@ e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter)
3264 * descriptors are 32 bytes...so we increment tail 3817 * descriptors are 32 bytes...so we increment tail
3265 * twice as much. 3818 * twice as much.
3266 */ 3819 */
3267 E1000_WRITE_REG(&adapter->hw, RDT, i<<1); 3820 writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
3268 } 3821 }
3269 3822
3270 if(unlikely(++i == rx_ring->count)) i = 0; 3823 if(unlikely(++i == rx_ring->count)) i = 0;
@@ -3715,6 +4268,12 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
3715 } 4268 }
3716 4269
3717 switch(adapter->hw.mac_type) { 4270 switch(adapter->hw.mac_type) {
4271 case e1000_82571:
4272 case e1000_82572:
4273 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
4274 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
4275 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
4276 break;
3718 case e1000_82573: 4277 case e1000_82573:
3719 swsm = E1000_READ_REG(&adapter->hw, SWSM); 4278 swsm = E1000_READ_REG(&adapter->hw, SWSM);
3720 E1000_WRITE_REG(&adapter->hw, SWSM, 4279 E1000_WRITE_REG(&adapter->hw, SWSM,
@@ -3737,6 +4296,7 @@ e1000_resume(struct pci_dev *pdev)
3737 struct net_device *netdev = pci_get_drvdata(pdev); 4296 struct net_device *netdev = pci_get_drvdata(pdev);
3738 struct e1000_adapter *adapter = netdev_priv(netdev); 4297 struct e1000_adapter *adapter = netdev_priv(netdev);
3739 uint32_t manc, ret_val, swsm; 4298 uint32_t manc, ret_val, swsm;
4299 uint32_t ctrl_ext;
3740 4300
3741 pci_set_power_state(pdev, PCI_D0); 4301 pci_set_power_state(pdev, PCI_D0);
3742 pci_restore_state(pdev); 4302 pci_restore_state(pdev);
@@ -3762,6 +4322,12 @@ e1000_resume(struct pci_dev *pdev)
3762 } 4322 }
3763 4323
3764 switch(adapter->hw.mac_type) { 4324 switch(adapter->hw.mac_type) {
4325 case e1000_82571:
4326 case e1000_82572:
4327 ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
4328 E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
4329 ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
4330 break;
3765 case e1000_82573: 4331 case e1000_82573:
3766 swsm = E1000_READ_REG(&adapter->hw, SWSM); 4332 swsm = E1000_READ_REG(&adapter->hw, SWSM);
3767 E1000_WRITE_REG(&adapter->hw, SWSM, 4333 E1000_WRITE_REG(&adapter->hw, SWSM,
@@ -3786,7 +4352,7 @@ e1000_netpoll(struct net_device *netdev)
3786 struct e1000_adapter *adapter = netdev_priv(netdev); 4352 struct e1000_adapter *adapter = netdev_priv(netdev);
3787 disable_irq(adapter->pdev->irq); 4353 disable_irq(adapter->pdev->irq);
3788 e1000_intr(adapter->pdev->irq, netdev, NULL); 4354 e1000_intr(adapter->pdev->irq, netdev, NULL);
3789 e1000_clean_tx_irq(adapter); 4355 e1000_clean_tx_irq(adapter, adapter->tx_ring);
3790 enable_irq(adapter->pdev->irq); 4356 enable_irq(adapter->pdev->irq);
3791} 4357}
3792#endif 4358#endif
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index 676247f9f1cc..38695d5b4637 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -306,7 +306,8 @@ e1000_check_options(struct e1000_adapter *adapter)
306 .def = E1000_DEFAULT_TXD, 306 .def = E1000_DEFAULT_TXD,
307 .arg = { .r = { .min = E1000_MIN_TXD }} 307 .arg = { .r = { .min = E1000_MIN_TXD }}
308 }; 308 };
309 struct e1000_desc_ring *tx_ring = &adapter->tx_ring; 309 struct e1000_tx_ring *tx_ring = adapter->tx_ring;
310 int i;
310 e1000_mac_type mac_type = adapter->hw.mac_type; 311 e1000_mac_type mac_type = adapter->hw.mac_type;
311 opt.arg.r.max = mac_type < e1000_82544 ? 312 opt.arg.r.max = mac_type < e1000_82544 ?
312 E1000_MAX_TXD : E1000_MAX_82544_TXD; 313 E1000_MAX_TXD : E1000_MAX_82544_TXD;
@@ -319,6 +320,8 @@ e1000_check_options(struct e1000_adapter *adapter)
319 } else { 320 } else {
320 tx_ring->count = opt.def; 321 tx_ring->count = opt.def;
321 } 322 }
323 for (i = 0; i < adapter->num_queues; i++)
324 tx_ring[i].count = tx_ring->count;
322 } 325 }
323 { /* Receive Descriptor Count */ 326 { /* Receive Descriptor Count */
324 struct e1000_option opt = { 327 struct e1000_option opt = {
@@ -329,7 +332,8 @@ e1000_check_options(struct e1000_adapter *adapter)
329 .def = E1000_DEFAULT_RXD, 332 .def = E1000_DEFAULT_RXD,
330 .arg = { .r = { .min = E1000_MIN_RXD }} 333 .arg = { .r = { .min = E1000_MIN_RXD }}
331 }; 334 };
332 struct e1000_desc_ring *rx_ring = &adapter->rx_ring; 335 struct e1000_rx_ring *rx_ring = adapter->rx_ring;
336 int i;
333 e1000_mac_type mac_type = adapter->hw.mac_type; 337 e1000_mac_type mac_type = adapter->hw.mac_type;
334 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD : 338 opt.arg.r.max = mac_type < e1000_82544 ? E1000_MAX_RXD :
335 E1000_MAX_82544_RXD; 339 E1000_MAX_82544_RXD;
@@ -342,6 +346,8 @@ e1000_check_options(struct e1000_adapter *adapter)
342 } else { 346 } else {
343 rx_ring->count = opt.def; 347 rx_ring->count = opt.def;
344 } 348 }
349 for (i = 0; i < adapter->num_queues; i++)
350 rx_ring[i].count = rx_ring->count;
345 } 351 }
346 { /* Checksum Offload Enable/Disable */ 352 { /* Checksum Offload Enable/Disable */
347 struct e1000_option opt = { 353 struct e1000_option opt = {
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 87f522738bfc..f119ec4e89ea 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -1334,7 +1334,7 @@ static void epic_rx_err(struct net_device *dev, struct epic_private *ep)
1334static int epic_poll(struct net_device *dev, int *budget) 1334static int epic_poll(struct net_device *dev, int *budget)
1335{ 1335{
1336 struct epic_private *ep = dev->priv; 1336 struct epic_private *ep = dev->priv;
1337 int work_done, orig_budget; 1337 int work_done = 0, orig_budget;
1338 long ioaddr = dev->base_addr; 1338 long ioaddr = dev->base_addr;
1339 1339
1340 orig_budget = (*budget > dev->quota) ? dev->quota : *budget; 1340 orig_budget = (*budget > dev->quota) ? dev->quota : *budget;
@@ -1343,7 +1343,7 @@ rx_action:
1343 1343
1344 epic_tx(dev, ep); 1344 epic_tx(dev, ep);
1345 1345
1346 work_done = epic_rx(dev, *budget); 1346 work_done += epic_rx(dev, *budget);
1347 1347
1348 epic_rx_err(dev, ep); 1348 epic_rx_err(dev, ep);
1349 1349
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index d6eefdb71c17..22aec6ed80f5 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -95,6 +95,8 @@
95 * of nv_remove 95 * of nv_remove
96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization 96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization
97 * in the second (and later) nv_open call 97 * in the second (and later) nv_open call
98 * 0.43: 10 Aug 2005: Add support for tx checksum.
99 * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation.
98 * 100 *
99 * Known bugs: 101 * Known bugs:
100 * We suspect that on some hardware no TX done interrupts are generated. 102 * We suspect that on some hardware no TX done interrupts are generated.
@@ -106,7 +108,7 @@
106 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 108 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
107 * superfluous timer interrupts from the nic. 109 * superfluous timer interrupts from the nic.
108 */ 110 */
109#define FORCEDETH_VERSION "0.41" 111#define FORCEDETH_VERSION "0.44"
110#define DRV_NAME "forcedeth" 112#define DRV_NAME "forcedeth"
111 113
112#include <linux/module.h> 114#include <linux/module.h>
@@ -145,6 +147,7 @@
145#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */ 147#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */
146#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */ 148#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */
147#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */ 149#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */
150#define DEV_HAS_CHECKSUM 0x0010 /* device supports tx and rx checksum offloads */
148 151
149enum { 152enum {
150 NvRegIrqStatus = 0x000, 153 NvRegIrqStatus = 0x000,
@@ -241,6 +244,9 @@ enum {
241#define NVREG_TXRXCTL_IDLE 0x0008 244#define NVREG_TXRXCTL_IDLE 0x0008
242#define NVREG_TXRXCTL_RESET 0x0010 245#define NVREG_TXRXCTL_RESET 0x0010
243#define NVREG_TXRXCTL_RXCHECK 0x0400 246#define NVREG_TXRXCTL_RXCHECK 0x0400
247#define NVREG_TXRXCTL_DESC_1 0
248#define NVREG_TXRXCTL_DESC_2 0x02100
249#define NVREG_TXRXCTL_DESC_3 0x02200
244 NvRegMIIStatus = 0x180, 250 NvRegMIIStatus = 0x180,
245#define NVREG_MIISTAT_ERROR 0x0001 251#define NVREG_MIISTAT_ERROR 0x0001
246#define NVREG_MIISTAT_LINKCHANGE 0x0008 252#define NVREG_MIISTAT_LINKCHANGE 0x0008
@@ -335,6 +341,10 @@ typedef union _ring_type {
335/* error and valid are the same for both */ 341/* error and valid are the same for both */
336#define NV_TX2_ERROR (1<<30) 342#define NV_TX2_ERROR (1<<30)
337#define NV_TX2_VALID (1<<31) 343#define NV_TX2_VALID (1<<31)
344#define NV_TX2_TSO (1<<28)
345#define NV_TX2_TSO_SHIFT 14
346#define NV_TX2_CHECKSUM_L3 (1<<27)
347#define NV_TX2_CHECKSUM_L4 (1<<26)
338 348
339#define NV_RX_DESCRIPTORVALID (1<<16) 349#define NV_RX_DESCRIPTORVALID (1<<16)
340#define NV_RX_MISSEDFRAME (1<<17) 350#define NV_RX_MISSEDFRAME (1<<17)
@@ -417,14 +427,14 @@ typedef union _ring_type {
417 427
418/* 428/*
419 * desc_ver values: 429 * desc_ver values:
420 * This field has two purposes: 430 * The nic supports three different descriptor types:
421 * - Newer nics uses a different ring layout. The layout is selected by 431 * - DESC_VER_1: Original
422 * comparing np->desc_ver with DESC_VER_xy. 432 * - DESC_VER_2: support for jumbo frames.
423 * - It contains bits that are forced on when writing to NvRegTxRxControl. 433 * - DESC_VER_3: 64-bit format.
424 */ 434 */
425#define DESC_VER_1 0x0 435#define DESC_VER_1 1
426#define DESC_VER_2 (0x02100|NVREG_TXRXCTL_RXCHECK) 436#define DESC_VER_2 2
427#define DESC_VER_3 (0x02200|NVREG_TXRXCTL_RXCHECK) 437#define DESC_VER_3 3
428 438
429/* PHY defines */ 439/* PHY defines */
430#define PHY_OUI_MARVELL 0x5043 440#define PHY_OUI_MARVELL 0x5043
@@ -491,6 +501,7 @@ struct fe_priv {
491 u32 orig_mac[2]; 501 u32 orig_mac[2];
492 u32 irqmask; 502 u32 irqmask;
493 u32 desc_ver; 503 u32 desc_ver;
504 u32 txrxctl_bits;
494 505
495 void __iomem *base; 506 void __iomem *base;
496 507
@@ -534,7 +545,7 @@ static inline struct fe_priv *get_nvpriv(struct net_device *dev)
534 545
535static inline u8 __iomem *get_hwbase(struct net_device *dev) 546static inline u8 __iomem *get_hwbase(struct net_device *dev)
536{ 547{
537 return get_nvpriv(dev)->base; 548 return ((struct fe_priv *)netdev_priv(dev))->base;
538} 549}
539 550
540static inline void pci_push(u8 __iomem *base) 551static inline void pci_push(u8 __iomem *base)
@@ -623,7 +634,7 @@ static int mii_rw(struct net_device *dev, int addr, int miireg, int value)
623 634
624static int phy_reset(struct net_device *dev) 635static int phy_reset(struct net_device *dev)
625{ 636{
626 struct fe_priv *np = get_nvpriv(dev); 637 struct fe_priv *np = netdev_priv(dev);
627 u32 miicontrol; 638 u32 miicontrol;
628 unsigned int tries = 0; 639 unsigned int tries = 0;
629 640
@@ -726,7 +737,7 @@ static int phy_init(struct net_device *dev)
726 737
727static void nv_start_rx(struct net_device *dev) 738static void nv_start_rx(struct net_device *dev)
728{ 739{
729 struct fe_priv *np = get_nvpriv(dev); 740 struct fe_priv *np = netdev_priv(dev);
730 u8 __iomem *base = get_hwbase(dev); 741 u8 __iomem *base = get_hwbase(dev);
731 742
732 dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name); 743 dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name);
@@ -782,14 +793,14 @@ static void nv_stop_tx(struct net_device *dev)
782 793
783static void nv_txrx_reset(struct net_device *dev) 794static void nv_txrx_reset(struct net_device *dev)
784{ 795{
785 struct fe_priv *np = get_nvpriv(dev); 796 struct fe_priv *np = netdev_priv(dev);
786 u8 __iomem *base = get_hwbase(dev); 797 u8 __iomem *base = get_hwbase(dev);
787 798
788 dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name); 799 dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name);
789 writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->desc_ver, base + NvRegTxRxControl); 800 writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->txrxctl_bits, base + NvRegTxRxControl);
790 pci_push(base); 801 pci_push(base);
791 udelay(NV_TXRX_RESET_DELAY); 802 udelay(NV_TXRX_RESET_DELAY);
792 writel(NVREG_TXRXCTL_BIT2 | np->desc_ver, base + NvRegTxRxControl); 803 writel(NVREG_TXRXCTL_BIT2 | np->txrxctl_bits, base + NvRegTxRxControl);
793 pci_push(base); 804 pci_push(base);
794} 805}
795 806
@@ -801,7 +812,7 @@ static void nv_txrx_reset(struct net_device *dev)
801 */ 812 */
802static struct net_device_stats *nv_get_stats(struct net_device *dev) 813static struct net_device_stats *nv_get_stats(struct net_device *dev)
803{ 814{
804 struct fe_priv *np = get_nvpriv(dev); 815 struct fe_priv *np = netdev_priv(dev);
805 816
806 /* It seems that the nic always generates interrupts and doesn't 817 /* It seems that the nic always generates interrupts and doesn't
807 * accumulate errors internally. Thus the current values in np->stats 818 * accumulate errors internally. Thus the current values in np->stats
@@ -817,7 +828,7 @@ static struct net_device_stats *nv_get_stats(struct net_device *dev)
817 */ 828 */
818static int nv_alloc_rx(struct net_device *dev) 829static int nv_alloc_rx(struct net_device *dev)
819{ 830{
820 struct fe_priv *np = get_nvpriv(dev); 831 struct fe_priv *np = netdev_priv(dev);
821 unsigned int refill_rx = np->refill_rx; 832 unsigned int refill_rx = np->refill_rx;
822 int nr; 833 int nr;
823 834
@@ -861,7 +872,7 @@ static int nv_alloc_rx(struct net_device *dev)
861static void nv_do_rx_refill(unsigned long data) 872static void nv_do_rx_refill(unsigned long data)
862{ 873{
863 struct net_device *dev = (struct net_device *) data; 874 struct net_device *dev = (struct net_device *) data;
864 struct fe_priv *np = get_nvpriv(dev); 875 struct fe_priv *np = netdev_priv(dev);
865 876
866 disable_irq(dev->irq); 877 disable_irq(dev->irq);
867 if (nv_alloc_rx(dev)) { 878 if (nv_alloc_rx(dev)) {
@@ -875,7 +886,7 @@ static void nv_do_rx_refill(unsigned long data)
875 886
876static void nv_init_rx(struct net_device *dev) 887static void nv_init_rx(struct net_device *dev)
877{ 888{
878 struct fe_priv *np = get_nvpriv(dev); 889 struct fe_priv *np = netdev_priv(dev);
879 int i; 890 int i;
880 891
881 np->cur_rx = RX_RING; 892 np->cur_rx = RX_RING;
@@ -889,15 +900,17 @@ static void nv_init_rx(struct net_device *dev)
889 900
890static void nv_init_tx(struct net_device *dev) 901static void nv_init_tx(struct net_device *dev)
891{ 902{
892 struct fe_priv *np = get_nvpriv(dev); 903 struct fe_priv *np = netdev_priv(dev);
893 int i; 904 int i;
894 905
895 np->next_tx = np->nic_tx = 0; 906 np->next_tx = np->nic_tx = 0;
896 for (i = 0; i < TX_RING; i++) 907 for (i = 0; i < TX_RING; i++) {
897 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 908 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
898 np->tx_ring.orig[i].FlagLen = 0; 909 np->tx_ring.orig[i].FlagLen = 0;
899 else 910 else
900 np->tx_ring.ex[i].FlagLen = 0; 911 np->tx_ring.ex[i].FlagLen = 0;
912 np->tx_skbuff[i] = NULL;
913 }
901} 914}
902 915
903static int nv_init_ring(struct net_device *dev) 916static int nv_init_ring(struct net_device *dev)
@@ -907,21 +920,44 @@ static int nv_init_ring(struct net_device *dev)
907 return nv_alloc_rx(dev); 920 return nv_alloc_rx(dev);
908} 921}
909 922
923static void nv_release_txskb(struct net_device *dev, unsigned int skbnr)
924{
925 struct fe_priv *np = netdev_priv(dev);
926 struct sk_buff *skb = np->tx_skbuff[skbnr];
927 unsigned int j, entry, fragments;
928
929 dprintk(KERN_INFO "%s: nv_release_txskb for skbnr %d, skb %p\n",
930 dev->name, skbnr, np->tx_skbuff[skbnr]);
931
932 entry = skbnr;
933 if ((fragments = skb_shinfo(skb)->nr_frags) != 0) {
934 for (j = fragments; j >= 1; j--) {
935 skb_frag_t *frag = &skb_shinfo(skb)->frags[j-1];
936 pci_unmap_page(np->pci_dev, np->tx_dma[entry],
937 frag->size,
938 PCI_DMA_TODEVICE);
939 entry = (entry - 1) % TX_RING;
940 }
941 }
942 pci_unmap_single(np->pci_dev, np->tx_dma[entry],
943 skb->len - skb->data_len,
944 PCI_DMA_TODEVICE);
945 dev_kfree_skb_irq(skb);
946 np->tx_skbuff[skbnr] = NULL;
947}
948
910static void nv_drain_tx(struct net_device *dev) 949static void nv_drain_tx(struct net_device *dev)
911{ 950{
912 struct fe_priv *np = get_nvpriv(dev); 951 struct fe_priv *np = netdev_priv(dev);
913 int i; 952 unsigned int i;
953
914 for (i = 0; i < TX_RING; i++) { 954 for (i = 0; i < TX_RING; i++) {
915 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 955 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
916 np->tx_ring.orig[i].FlagLen = 0; 956 np->tx_ring.orig[i].FlagLen = 0;
917 else 957 else
918 np->tx_ring.ex[i].FlagLen = 0; 958 np->tx_ring.ex[i].FlagLen = 0;
919 if (np->tx_skbuff[i]) { 959 if (np->tx_skbuff[i]) {
920 pci_unmap_single(np->pci_dev, np->tx_dma[i], 960 nv_release_txskb(dev, i);
921 np->tx_skbuff[i]->len,
922 PCI_DMA_TODEVICE);
923 dev_kfree_skb(np->tx_skbuff[i]);
924 np->tx_skbuff[i] = NULL;
925 np->stats.tx_dropped++; 961 np->stats.tx_dropped++;
926 } 962 }
927 } 963 }
@@ -929,7 +965,7 @@ static void nv_drain_tx(struct net_device *dev)
929 965
930static void nv_drain_rx(struct net_device *dev) 966static void nv_drain_rx(struct net_device *dev)
931{ 967{
932 struct fe_priv *np = get_nvpriv(dev); 968 struct fe_priv *np = netdev_priv(dev);
933 int i; 969 int i;
934 for (i = 0; i < RX_RING; i++) { 970 for (i = 0; i < RX_RING; i++) {
935 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 971 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
@@ -959,28 +995,69 @@ static void drain_ring(struct net_device *dev)
959 */ 995 */
960static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) 996static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
961{ 997{
962 struct fe_priv *np = get_nvpriv(dev); 998 struct fe_priv *np = netdev_priv(dev);
963 int nr = np->next_tx % TX_RING; 999 u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET);
1000 unsigned int fragments = skb_shinfo(skb)->nr_frags;
1001 unsigned int nr = (np->next_tx + fragments) % TX_RING;
1002 unsigned int i;
1003
1004 spin_lock_irq(&np->lock);
1005
1006 if ((np->next_tx - np->nic_tx + fragments) > TX_LIMIT_STOP) {
1007 spin_unlock_irq(&np->lock);
1008 netif_stop_queue(dev);
1009 return NETDEV_TX_BUSY;
1010 }
964 1011
965 np->tx_skbuff[nr] = skb; 1012 np->tx_skbuff[nr] = skb;
966 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len, 1013
967 PCI_DMA_TODEVICE); 1014 if (fragments) {
1015 dprintk(KERN_DEBUG "%s: nv_start_xmit: buffer contains %d fragments\n", dev->name, fragments);
1016 /* setup descriptors in reverse order */
1017 for (i = fragments; i >= 1; i--) {
1018 skb_frag_t *frag = &skb_shinfo(skb)->frags[i-1];
1019 np->tx_dma[nr] = pci_map_page(np->pci_dev, frag->page, frag->page_offset, frag->size,
1020 PCI_DMA_TODEVICE);
968 1021
969 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 1022 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
1023 np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]);
1024 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (frag->size-1) | np->tx_flags | tx_flags_extra);
1025 } else {
1026 np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32;
1027 np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF;
1028 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (frag->size-1) | np->tx_flags | tx_flags_extra);
1029 }
1030
1031 nr = (nr - 1) % TX_RING;
1032
1033 if (np->desc_ver == DESC_VER_1)
1034 tx_flags_extra &= ~NV_TX_LASTPACKET;
1035 else
1036 tx_flags_extra &= ~NV_TX2_LASTPACKET;
1037 }
1038 }
1039
1040#ifdef NETIF_F_TSO
1041 if (skb_shinfo(skb)->tso_size)
1042 tx_flags_extra |= NV_TX2_TSO | (skb_shinfo(skb)->tso_size << NV_TX2_TSO_SHIFT);
1043 else
1044#endif
1045 tx_flags_extra |= (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0);
1046
1047 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len-skb->data_len,
1048 PCI_DMA_TODEVICE);
1049
1050 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
970 np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); 1051 np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]);
971 else { 1052 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-skb->data_len-1) | np->tx_flags | tx_flags_extra);
1053 } else {
972 np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32; 1054 np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32;
973 np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF; 1055 np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF;
974 } 1056 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-skb->data_len-1) | np->tx_flags | tx_flags_extra);
1057 }
975 1058
976 spin_lock_irq(&np->lock); 1059 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission. tx_flags_extra: %x\n",
977 wmb(); 1060 dev->name, np->next_tx, tx_flags_extra);
978 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
979 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags );
980 else
981 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags );
982 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission.\n",
983 dev->name, np->next_tx);
984 { 1061 {
985 int j; 1062 int j;
986 for (j=0; j<64; j++) { 1063 for (j=0; j<64; j++) {
@@ -991,15 +1068,13 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
991 dprintk("\n"); 1068 dprintk("\n");
992 } 1069 }
993 1070
994 np->next_tx++; 1071 np->next_tx += 1 + fragments;
995 1072
996 dev->trans_start = jiffies; 1073 dev->trans_start = jiffies;
997 if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP)
998 netif_stop_queue(dev);
999 spin_unlock_irq(&np->lock); 1074 spin_unlock_irq(&np->lock);
1000 writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl); 1075 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
1001 pci_push(get_hwbase(dev)); 1076 pci_push(get_hwbase(dev));
1002 return 0; 1077 return NETDEV_TX_OK;
1003} 1078}
1004 1079
1005/* 1080/*
@@ -1009,9 +1084,10 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1009 */ 1084 */
1010static void nv_tx_done(struct net_device *dev) 1085static void nv_tx_done(struct net_device *dev)
1011{ 1086{
1012 struct fe_priv *np = get_nvpriv(dev); 1087 struct fe_priv *np = netdev_priv(dev);
1013 u32 Flags; 1088 u32 Flags;
1014 int i; 1089 unsigned int i;
1090 struct sk_buff *skb;
1015 1091
1016 while (np->nic_tx != np->next_tx) { 1092 while (np->nic_tx != np->next_tx) {
1017 i = np->nic_tx % TX_RING; 1093 i = np->nic_tx % TX_RING;
@@ -1026,35 +1102,38 @@ static void nv_tx_done(struct net_device *dev)
1026 if (Flags & NV_TX_VALID) 1102 if (Flags & NV_TX_VALID)
1027 break; 1103 break;
1028 if (np->desc_ver == DESC_VER_1) { 1104 if (np->desc_ver == DESC_VER_1) {
1029 if (Flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION| 1105 if (Flags & NV_TX_LASTPACKET) {
1030 NV_TX_UNDERFLOW|NV_TX_ERROR)) { 1106 skb = np->tx_skbuff[i];
1031 if (Flags & NV_TX_UNDERFLOW) 1107 if (Flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION|
1032 np->stats.tx_fifo_errors++; 1108 NV_TX_UNDERFLOW|NV_TX_ERROR)) {
1033 if (Flags & NV_TX_CARRIERLOST) 1109 if (Flags & NV_TX_UNDERFLOW)
1034 np->stats.tx_carrier_errors++; 1110 np->stats.tx_fifo_errors++;
1035 np->stats.tx_errors++; 1111 if (Flags & NV_TX_CARRIERLOST)
1036 } else { 1112 np->stats.tx_carrier_errors++;
1037 np->stats.tx_packets++; 1113 np->stats.tx_errors++;
1038 np->stats.tx_bytes += np->tx_skbuff[i]->len; 1114 } else {
1115 np->stats.tx_packets++;
1116 np->stats.tx_bytes += skb->len;
1117 }
1118 nv_release_txskb(dev, i);
1039 } 1119 }
1040 } else { 1120 } else {
1041 if (Flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION| 1121 if (Flags & NV_TX2_LASTPACKET) {
1042 NV_TX2_UNDERFLOW|NV_TX2_ERROR)) { 1122 skb = np->tx_skbuff[i];
1043 if (Flags & NV_TX2_UNDERFLOW) 1123 if (Flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION|
1044 np->stats.tx_fifo_errors++; 1124 NV_TX2_UNDERFLOW|NV_TX2_ERROR)) {
1045 if (Flags & NV_TX2_CARRIERLOST) 1125 if (Flags & NV_TX2_UNDERFLOW)
1046 np->stats.tx_carrier_errors++; 1126 np->stats.tx_fifo_errors++;
1047 np->stats.tx_errors++; 1127 if (Flags & NV_TX2_CARRIERLOST)
1048 } else { 1128 np->stats.tx_carrier_errors++;
1049 np->stats.tx_packets++; 1129 np->stats.tx_errors++;
1050 np->stats.tx_bytes += np->tx_skbuff[i]->len; 1130 } else {
1131 np->stats.tx_packets++;
1132 np->stats.tx_bytes += skb->len;
1133 }
1134 nv_release_txskb(dev, i);
1051 } 1135 }
1052 } 1136 }
1053 pci_unmap_single(np->pci_dev, np->tx_dma[i],
1054 np->tx_skbuff[i]->len,
1055 PCI_DMA_TODEVICE);
1056 dev_kfree_skb_irq(np->tx_skbuff[i]);
1057 np->tx_skbuff[i] = NULL;
1058 np->nic_tx++; 1137 np->nic_tx++;
1059 } 1138 }
1060 if (np->next_tx - np->nic_tx < TX_LIMIT_START) 1139 if (np->next_tx - np->nic_tx < TX_LIMIT_START)
@@ -1067,7 +1146,7 @@ static void nv_tx_done(struct net_device *dev)
1067 */ 1146 */
1068static void nv_tx_timeout(struct net_device *dev) 1147static void nv_tx_timeout(struct net_device *dev)
1069{ 1148{
1070 struct fe_priv *np = get_nvpriv(dev); 1149 struct fe_priv *np = netdev_priv(dev);
1071 u8 __iomem *base = get_hwbase(dev); 1150 u8 __iomem *base = get_hwbase(dev);
1072 1151
1073 printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name, 1152 printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name,
@@ -1200,7 +1279,7 @@ static int nv_getlen(struct net_device *dev, void *packet, int datalen)
1200 1279
1201static void nv_rx_process(struct net_device *dev) 1280static void nv_rx_process(struct net_device *dev)
1202{ 1281{
1203 struct fe_priv *np = get_nvpriv(dev); 1282 struct fe_priv *np = netdev_priv(dev);
1204 u32 Flags; 1283 u32 Flags;
1205 1284
1206 for (;;) { 1285 for (;;) {
@@ -1355,7 +1434,7 @@ static void set_bufsize(struct net_device *dev)
1355 */ 1434 */
1356static int nv_change_mtu(struct net_device *dev, int new_mtu) 1435static int nv_change_mtu(struct net_device *dev, int new_mtu)
1357{ 1436{
1358 struct fe_priv *np = get_nvpriv(dev); 1437 struct fe_priv *np = netdev_priv(dev);
1359 int old_mtu; 1438 int old_mtu;
1360 1439
1361 if (new_mtu < 64 || new_mtu > np->pkt_limit) 1440 if (new_mtu < 64 || new_mtu > np->pkt_limit)
@@ -1408,7 +1487,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
1408 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), 1487 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT),
1409 base + NvRegRingSizes); 1488 base + NvRegRingSizes);
1410 pci_push(base); 1489 pci_push(base);
1411 writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl); 1490 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
1412 pci_push(base); 1491 pci_push(base);
1413 1492
1414 /* restart rx engine */ 1493 /* restart rx engine */
@@ -1440,7 +1519,7 @@ static void nv_copy_mac_to_hw(struct net_device *dev)
1440 */ 1519 */
1441static int nv_set_mac_address(struct net_device *dev, void *addr) 1520static int nv_set_mac_address(struct net_device *dev, void *addr)
1442{ 1521{
1443 struct fe_priv *np = get_nvpriv(dev); 1522 struct fe_priv *np = netdev_priv(dev);
1444 struct sockaddr *macaddr = (struct sockaddr*)addr; 1523 struct sockaddr *macaddr = (struct sockaddr*)addr;
1445 1524
1446 if(!is_valid_ether_addr(macaddr->sa_data)) 1525 if(!is_valid_ether_addr(macaddr->sa_data))
@@ -1475,7 +1554,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr)
1475 */ 1554 */
1476static void nv_set_multicast(struct net_device *dev) 1555static void nv_set_multicast(struct net_device *dev)
1477{ 1556{
1478 struct fe_priv *np = get_nvpriv(dev); 1557 struct fe_priv *np = netdev_priv(dev);
1479 u8 __iomem *base = get_hwbase(dev); 1558 u8 __iomem *base = get_hwbase(dev);
1480 u32 addr[2]; 1559 u32 addr[2];
1481 u32 mask[2]; 1560 u32 mask[2];
@@ -1535,7 +1614,7 @@ static void nv_set_multicast(struct net_device *dev)
1535 1614
1536static int nv_update_linkspeed(struct net_device *dev) 1615static int nv_update_linkspeed(struct net_device *dev)
1537{ 1616{
1538 struct fe_priv *np = get_nvpriv(dev); 1617 struct fe_priv *np = netdev_priv(dev);
1539 u8 __iomem *base = get_hwbase(dev); 1618 u8 __iomem *base = get_hwbase(dev);
1540 int adv, lpa; 1619 int adv, lpa;
1541 int newls = np->linkspeed; 1620 int newls = np->linkspeed;
@@ -1705,7 +1784,7 @@ static void nv_link_irq(struct net_device *dev)
1705static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs) 1784static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
1706{ 1785{
1707 struct net_device *dev = (struct net_device *) data; 1786 struct net_device *dev = (struct net_device *) data;
1708 struct fe_priv *np = get_nvpriv(dev); 1787 struct fe_priv *np = netdev_priv(dev);
1709 u8 __iomem *base = get_hwbase(dev); 1788 u8 __iomem *base = get_hwbase(dev);
1710 u32 events; 1789 u32 events;
1711 int i; 1790 int i;
@@ -1777,7 +1856,7 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
1777static void nv_do_nic_poll(unsigned long data) 1856static void nv_do_nic_poll(unsigned long data)
1778{ 1857{
1779 struct net_device *dev = (struct net_device *) data; 1858 struct net_device *dev = (struct net_device *) data;
1780 struct fe_priv *np = get_nvpriv(dev); 1859 struct fe_priv *np = netdev_priv(dev);
1781 u8 __iomem *base = get_hwbase(dev); 1860 u8 __iomem *base = get_hwbase(dev);
1782 1861
1783 disable_irq(dev->irq); 1862 disable_irq(dev->irq);
@@ -1801,7 +1880,7 @@ static void nv_poll_controller(struct net_device *dev)
1801 1880
1802static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1881static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1803{ 1882{
1804 struct fe_priv *np = get_nvpriv(dev); 1883 struct fe_priv *np = netdev_priv(dev);
1805 strcpy(info->driver, "forcedeth"); 1884 strcpy(info->driver, "forcedeth");
1806 strcpy(info->version, FORCEDETH_VERSION); 1885 strcpy(info->version, FORCEDETH_VERSION);
1807 strcpy(info->bus_info, pci_name(np->pci_dev)); 1886 strcpy(info->bus_info, pci_name(np->pci_dev));
@@ -1809,7 +1888,7 @@ static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1809 1888
1810static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) 1889static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
1811{ 1890{
1812 struct fe_priv *np = get_nvpriv(dev); 1891 struct fe_priv *np = netdev_priv(dev);
1813 wolinfo->supported = WAKE_MAGIC; 1892 wolinfo->supported = WAKE_MAGIC;
1814 1893
1815 spin_lock_irq(&np->lock); 1894 spin_lock_irq(&np->lock);
@@ -1820,7 +1899,7 @@ static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
1820 1899
1821static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) 1900static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo)
1822{ 1901{
1823 struct fe_priv *np = get_nvpriv(dev); 1902 struct fe_priv *np = netdev_priv(dev);
1824 u8 __iomem *base = get_hwbase(dev); 1903 u8 __iomem *base = get_hwbase(dev);
1825 1904
1826 spin_lock_irq(&np->lock); 1905 spin_lock_irq(&np->lock);
@@ -2021,7 +2100,7 @@ static int nv_get_regs_len(struct net_device *dev)
2021 2100
2022static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) 2101static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf)
2023{ 2102{
2024 struct fe_priv *np = get_nvpriv(dev); 2103 struct fe_priv *np = netdev_priv(dev);
2025 u8 __iomem *base = get_hwbase(dev); 2104 u8 __iomem *base = get_hwbase(dev);
2026 u32 *rbuf = buf; 2105 u32 *rbuf = buf;
2027 int i; 2106 int i;
@@ -2035,7 +2114,7 @@ static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void
2035 2114
2036static int nv_nway_reset(struct net_device *dev) 2115static int nv_nway_reset(struct net_device *dev)
2037{ 2116{
2038 struct fe_priv *np = get_nvpriv(dev); 2117 struct fe_priv *np = netdev_priv(dev);
2039 int ret; 2118 int ret;
2040 2119
2041 spin_lock_irq(&np->lock); 2120 spin_lock_irq(&np->lock);
@@ -2065,11 +2144,12 @@ static struct ethtool_ops ops = {
2065 .get_regs_len = nv_get_regs_len, 2144 .get_regs_len = nv_get_regs_len,
2066 .get_regs = nv_get_regs, 2145 .get_regs = nv_get_regs,
2067 .nway_reset = nv_nway_reset, 2146 .nway_reset = nv_nway_reset,
2147 .get_perm_addr = ethtool_op_get_perm_addr,
2068}; 2148};
2069 2149
2070static int nv_open(struct net_device *dev) 2150static int nv_open(struct net_device *dev)
2071{ 2151{
2072 struct fe_priv *np = get_nvpriv(dev); 2152 struct fe_priv *np = netdev_priv(dev);
2073 u8 __iomem *base = get_hwbase(dev); 2153 u8 __iomem *base = get_hwbase(dev);
2074 int ret, oom, i; 2154 int ret, oom, i;
2075 2155
@@ -2114,9 +2194,9 @@ static int nv_open(struct net_device *dev)
2114 /* 5) continue setup */ 2194 /* 5) continue setup */
2115 writel(np->linkspeed, base + NvRegLinkSpeed); 2195 writel(np->linkspeed, base + NvRegLinkSpeed);
2116 writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3); 2196 writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3);
2117 writel(np->desc_ver, base + NvRegTxRxControl); 2197 writel(np->txrxctl_bits, base + NvRegTxRxControl);
2118 pci_push(base); 2198 pci_push(base);
2119 writel(NVREG_TXRXCTL_BIT1|np->desc_ver, base + NvRegTxRxControl); 2199 writel(NVREG_TXRXCTL_BIT1|np->txrxctl_bits, base + NvRegTxRxControl);
2120 reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31, 2200 reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31,
2121 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, 2201 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
2122 KERN_INFO "open: SetupReg5, Bit 31 remained off\n"); 2202 KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
@@ -2205,7 +2285,7 @@ out_drain:
2205 2285
2206static int nv_close(struct net_device *dev) 2286static int nv_close(struct net_device *dev)
2207{ 2287{
2208 struct fe_priv *np = get_nvpriv(dev); 2288 struct fe_priv *np = netdev_priv(dev);
2209 u8 __iomem *base; 2289 u8 __iomem *base;
2210 2290
2211 spin_lock_irq(&np->lock); 2291 spin_lock_irq(&np->lock);
@@ -2261,7 +2341,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2261 if (!dev) 2341 if (!dev)
2262 goto out; 2342 goto out;
2263 2343
2264 np = get_nvpriv(dev); 2344 np = netdev_priv(dev);
2265 np->pci_dev = pci_dev; 2345 np->pci_dev = pci_dev;
2266 spin_lock_init(&np->lock); 2346 spin_lock_init(&np->lock);
2267 SET_MODULE_OWNER(dev); 2347 SET_MODULE_OWNER(dev);
@@ -2313,19 +2393,32 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2313 if (pci_set_dma_mask(pci_dev, 0x0000007fffffffffULL)) { 2393 if (pci_set_dma_mask(pci_dev, 0x0000007fffffffffULL)) {
2314 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", 2394 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n",
2315 pci_name(pci_dev)); 2395 pci_name(pci_dev));
2396 } else {
2397 dev->features |= NETIF_F_HIGHDMA;
2316 } 2398 }
2399 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3;
2317 } else if (id->driver_data & DEV_HAS_LARGEDESC) { 2400 } else if (id->driver_data & DEV_HAS_LARGEDESC) {
2318 /* packet format 2: supports jumbo frames */ 2401 /* packet format 2: supports jumbo frames */
2319 np->desc_ver = DESC_VER_2; 2402 np->desc_ver = DESC_VER_2;
2403 np->txrxctl_bits = NVREG_TXRXCTL_DESC_2;
2320 } else { 2404 } else {
2321 /* original packet format */ 2405 /* original packet format */
2322 np->desc_ver = DESC_VER_1; 2406 np->desc_ver = DESC_VER_1;
2407 np->txrxctl_bits = NVREG_TXRXCTL_DESC_1;
2323 } 2408 }
2324 2409
2325 np->pkt_limit = NV_PKTLIMIT_1; 2410 np->pkt_limit = NV_PKTLIMIT_1;
2326 if (id->driver_data & DEV_HAS_LARGEDESC) 2411 if (id->driver_data & DEV_HAS_LARGEDESC)
2327 np->pkt_limit = NV_PKTLIMIT_2; 2412 np->pkt_limit = NV_PKTLIMIT_2;
2328 2413
2414 if (id->driver_data & DEV_HAS_CHECKSUM) {
2415 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2416 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
2417#ifdef NETIF_F_TSO
2418 dev->features |= NETIF_F_TSO;
2419#endif
2420 }
2421
2329 err = -ENOMEM; 2422 err = -ENOMEM;
2330 np->base = ioremap(addr, NV_PCI_REGSZ); 2423 np->base = ioremap(addr, NV_PCI_REGSZ);
2331 if (!np->base) 2424 if (!np->base)
@@ -2377,8 +2470,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2377 dev->dev_addr[3] = (np->orig_mac[0] >> 16) & 0xff; 2470 dev->dev_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
2378 dev->dev_addr[4] = (np->orig_mac[0] >> 8) & 0xff; 2471 dev->dev_addr[4] = (np->orig_mac[0] >> 8) & 0xff;
2379 dev->dev_addr[5] = (np->orig_mac[0] >> 0) & 0xff; 2472 dev->dev_addr[5] = (np->orig_mac[0] >> 0) & 0xff;
2473 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
2380 2474
2381 if (!is_valid_ether_addr(dev->dev_addr)) { 2475 if (!is_valid_ether_addr(dev->perm_addr)) {
2382 /* 2476 /*
2383 * Bad mac address. At least one bios sets the mac address 2477 * Bad mac address. At least one bios sets the mac address
2384 * to 01:23:45:67:89:ab 2478 * to 01:23:45:67:89:ab
@@ -2403,9 +2497,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2403 np->wolenabled = 0; 2497 np->wolenabled = 0;
2404 2498
2405 if (np->desc_ver == DESC_VER_1) { 2499 if (np->desc_ver == DESC_VER_1) {
2406 np->tx_flags = NV_TX_LASTPACKET|NV_TX_VALID; 2500 np->tx_flags = NV_TX_VALID;
2407 } else { 2501 } else {
2408 np->tx_flags = NV_TX2_LASTPACKET|NV_TX2_VALID; 2502 np->tx_flags = NV_TX2_VALID;
2409 } 2503 }
2410 np->irqmask = NVREG_IRQMASK_WANTED; 2504 np->irqmask = NVREG_IRQMASK_WANTED;
2411 if (id->driver_data & DEV_NEED_TIMERIRQ) 2505 if (id->driver_data & DEV_NEED_TIMERIRQ)
@@ -2494,7 +2588,7 @@ out:
2494static void __devexit nv_remove(struct pci_dev *pci_dev) 2588static void __devexit nv_remove(struct pci_dev *pci_dev)
2495{ 2589{
2496 struct net_device *dev = pci_get_drvdata(pci_dev); 2590 struct net_device *dev = pci_get_drvdata(pci_dev);
2497 struct fe_priv *np = get_nvpriv(dev); 2591 struct fe_priv *np = netdev_priv(dev);
2498 2592
2499 unregister_netdev(dev); 2593 unregister_netdev(dev);
2500 2594
@@ -2525,35 +2619,35 @@ static struct pci_device_id pci_tbl[] = {
2525 }, 2619 },
2526 { /* nForce3 Ethernet Controller */ 2620 { /* nForce3 Ethernet Controller */
2527 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4), 2621 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4),
2528 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2622 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2529 }, 2623 },
2530 { /* nForce3 Ethernet Controller */ 2624 { /* nForce3 Ethernet Controller */
2531 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5), 2625 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5),
2532 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2626 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2533 }, 2627 },
2534 { /* nForce3 Ethernet Controller */ 2628 { /* nForce3 Ethernet Controller */
2535 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6), 2629 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6),
2536 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2630 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2537 }, 2631 },
2538 { /* nForce3 Ethernet Controller */ 2632 { /* nForce3 Ethernet Controller */
2539 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7), 2633 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7),
2540 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2634 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2541 }, 2635 },
2542 { /* CK804 Ethernet Controller */ 2636 { /* CK804 Ethernet Controller */
2543 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8), 2637 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8),
2544 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2638 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2545 }, 2639 },
2546 { /* CK804 Ethernet Controller */ 2640 { /* CK804 Ethernet Controller */
2547 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9), 2641 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9),
2548 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2642 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2549 }, 2643 },
2550 { /* MCP04 Ethernet Controller */ 2644 { /* MCP04 Ethernet Controller */
2551 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10), 2645 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10),
2552 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2646 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2553 }, 2647 },
2554 { /* MCP04 Ethernet Controller */ 2648 { /* MCP04 Ethernet Controller */
2555 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11), 2649 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11),
2556 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2650 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2557 }, 2651 },
2558 { /* MCP51 Ethernet Controller */ 2652 { /* MCP51 Ethernet Controller */
2559 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12), 2653 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12),
@@ -2565,11 +2659,11 @@ static struct pci_device_id pci_tbl[] = {
2565 }, 2659 },
2566 { /* MCP55 Ethernet Controller */ 2660 { /* MCP55 Ethernet Controller */
2567 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 2661 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
2568 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2662 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2569 }, 2663 },
2570 { /* MCP55 Ethernet Controller */ 2664 { /* MCP55 Ethernet Controller */
2571 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 2665 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
2572 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2666 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2573 }, 2667 },
2574 {0,}, 2668 {0,},
2575}; 2669};
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6518334b9280..ae5a2ed3b264 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -29,12 +29,7 @@
29 * define the configuration needed by the board are defined in a 29 * define the configuration needed by the board are defined in a
30 * board structure in arch/ppc/platforms (though I do not 30 * board structure in arch/ppc/platforms (though I do not
31 * discount the possibility that other architectures could one 31 * discount the possibility that other architectures could one
32 * day be supported. One assumption the driver currently makes 32 * day be supported.
33 * is that the PHY is configured in such a way to advertise all
34 * capabilities. This is a sensible default, and on certain
35 * PHYs, changing this default encounters substantial errata
36 * issues. Future versions may remove this requirement, but for
37 * now, it is best for the firmware to ensure this is the case.
38 * 33 *
39 * The Gianfar Ethernet Controller uses a ring of buffer 34 * The Gianfar Ethernet Controller uses a ring of buffer
40 * descriptors. The beginning is indicated by a register 35 * descriptors. The beginning is indicated by a register
@@ -47,7 +42,7 @@
47 * corresponding bit in the IMASK register is also set (if 42 * corresponding bit in the IMASK register is also set (if
48 * interrupt coalescing is active, then the interrupt may not 43 * interrupt coalescing is active, then the interrupt may not
49 * happen immediately, but will wait until either a set number 44 * happen immediately, but will wait until either a set number
50 * of frames or amount of time have passed.). In NAPI, the 45 * of frames or amount of time have passed). In NAPI, the
51 * interrupt handler will signal there is work to be done, and 46 * interrupt handler will signal there is work to be done, and
52 * exit. Without NAPI, the packet(s) will be handled 47 * exit. Without NAPI, the packet(s) will be handled
53 * immediately. Both methods will start at the last known empty 48 * immediately. Both methods will start at the last known empty
@@ -75,6 +70,7 @@
75#include <linux/sched.h> 70#include <linux/sched.h>
76#include <linux/string.h> 71#include <linux/string.h>
77#include <linux/errno.h> 72#include <linux/errno.h>
73#include <linux/unistd.h>
78#include <linux/slab.h> 74#include <linux/slab.h>
79#include <linux/interrupt.h> 75#include <linux/interrupt.h>
80#include <linux/init.h> 76#include <linux/init.h>
@@ -97,9 +93,11 @@
97#include <linux/version.h> 93#include <linux/version.h>
98#include <linux/dma-mapping.h> 94#include <linux/dma-mapping.h>
99#include <linux/crc32.h> 95#include <linux/crc32.h>
96#include <linux/mii.h>
97#include <linux/phy.h>
100 98
101#include "gianfar.h" 99#include "gianfar.h"
102#include "gianfar_phy.h" 100#include "gianfar_mii.h"
103 101
104#define TX_TIMEOUT (1*HZ) 102#define TX_TIMEOUT (1*HZ)
105#define SKB_ALLOC_TIMEOUT 1000000 103#define SKB_ALLOC_TIMEOUT 1000000
@@ -113,9 +111,8 @@
113#endif 111#endif
114 112
115const char gfar_driver_name[] = "Gianfar Ethernet"; 113const char gfar_driver_name[] = "Gianfar Ethernet";
116const char gfar_driver_version[] = "1.1"; 114const char gfar_driver_version[] = "1.2";
117 115
118int startup_gfar(struct net_device *dev);
119static int gfar_enet_open(struct net_device *dev); 116static int gfar_enet_open(struct net_device *dev);
120static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); 117static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
121static void gfar_timeout(struct net_device *dev); 118static void gfar_timeout(struct net_device *dev);
@@ -126,17 +123,13 @@ static int gfar_set_mac_address(struct net_device *dev);
126static int gfar_change_mtu(struct net_device *dev, int new_mtu); 123static int gfar_change_mtu(struct net_device *dev, int new_mtu);
127static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs); 124static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs);
128static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs); 125static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs);
129static irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs);
130static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs); 126static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs);
131static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
132static void gfar_phy_change(void *data);
133static void gfar_phy_timer(unsigned long data);
134static void adjust_link(struct net_device *dev); 127static void adjust_link(struct net_device *dev);
135static void init_registers(struct net_device *dev); 128static void init_registers(struct net_device *dev);
136static int init_phy(struct net_device *dev); 129static int init_phy(struct net_device *dev);
137static int gfar_probe(struct device *device); 130static int gfar_probe(struct device *device);
138static int gfar_remove(struct device *device); 131static int gfar_remove(struct device *device);
139void free_skb_resources(struct gfar_private *priv); 132static void free_skb_resources(struct gfar_private *priv);
140static void gfar_set_multi(struct net_device *dev); 133static void gfar_set_multi(struct net_device *dev);
141static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); 134static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
142#ifdef CONFIG_GFAR_NAPI 135#ifdef CONFIG_GFAR_NAPI
@@ -144,7 +137,6 @@ static int gfar_poll(struct net_device *dev, int *budget);
144#endif 137#endif
145int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 138int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
146static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 139static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
147static void gfar_phy_startup_timer(unsigned long data);
148static void gfar_vlan_rx_register(struct net_device *netdev, 140static void gfar_vlan_rx_register(struct net_device *netdev,
149 struct vlan_group *grp); 141 struct vlan_group *grp);
150static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); 142static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
@@ -162,6 +154,9 @@ int gfar_uses_fcb(struct gfar_private *priv)
162 else 154 else
163 return 0; 155 return 0;
164} 156}
157
158/* Set up the ethernet device structure, private data,
159 * and anything else we need before we start */
165static int gfar_probe(struct device *device) 160static int gfar_probe(struct device *device)
166{ 161{
167 u32 tempval; 162 u32 tempval;
@@ -175,7 +170,7 @@ static int gfar_probe(struct device *device)
175 170
176 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data; 171 einfo = (struct gianfar_platform_data *) pdev->dev.platform_data;
177 172
178 if (einfo == NULL) { 173 if (NULL == einfo) {
179 printk(KERN_ERR "gfar %d: Missing additional data!\n", 174 printk(KERN_ERR "gfar %d: Missing additional data!\n",
180 pdev->id); 175 pdev->id);
181 176
@@ -185,7 +180,7 @@ static int gfar_probe(struct device *device)
185 /* Create an ethernet device instance */ 180 /* Create an ethernet device instance */
186 dev = alloc_etherdev(sizeof (*priv)); 181 dev = alloc_etherdev(sizeof (*priv));
187 182
188 if (dev == NULL) 183 if (NULL == dev)
189 return -ENOMEM; 184 return -ENOMEM;
190 185
191 priv = netdev_priv(dev); 186 priv = netdev_priv(dev);
@@ -207,20 +202,11 @@ static int gfar_probe(struct device *device)
207 priv->regs = (struct gfar *) 202 priv->regs = (struct gfar *)
208 ioremap(r->start, sizeof (struct gfar)); 203 ioremap(r->start, sizeof (struct gfar));
209 204
210 if (priv->regs == NULL) { 205 if (NULL == priv->regs) {
211 err = -ENOMEM; 206 err = -ENOMEM;
212 goto regs_fail; 207 goto regs_fail;
213 } 208 }
214 209
215 /* Set the PHY base address */
216 priv->phyregs = (struct gfar *)
217 ioremap(einfo->phy_reg_addr, sizeof (struct gfar));
218
219 if (priv->phyregs == NULL) {
220 err = -ENOMEM;
221 goto phy_regs_fail;
222 }
223
224 spin_lock_init(&priv->lock); 210 spin_lock_init(&priv->lock);
225 211
226 dev_set_drvdata(device, dev); 212 dev_set_drvdata(device, dev);
@@ -386,12 +372,10 @@ static int gfar_probe(struct device *device)
386 return 0; 372 return 0;
387 373
388register_fail: 374register_fail:
389 iounmap((void *) priv->phyregs);
390phy_regs_fail:
391 iounmap((void *) priv->regs); 375 iounmap((void *) priv->regs);
392regs_fail: 376regs_fail:
393 free_netdev(dev); 377 free_netdev(dev);
394 return -ENOMEM; 378 return err;
395} 379}
396 380
397static int gfar_remove(struct device *device) 381static int gfar_remove(struct device *device)
@@ -402,108 +386,41 @@ static int gfar_remove(struct device *device)
402 dev_set_drvdata(device, NULL); 386 dev_set_drvdata(device, NULL);
403 387
404 iounmap((void *) priv->regs); 388 iounmap((void *) priv->regs);
405 iounmap((void *) priv->phyregs);
406 free_netdev(dev); 389 free_netdev(dev);
407 390
408 return 0; 391 return 0;
409} 392}
410 393
411 394
412/* Configure the PHY for dev. 395/* Initializes driver's PHY state, and attaches to the PHY.
413 * returns 0 if success. -1 if failure 396 * Returns 0 on success.
414 */ 397 */
415static int init_phy(struct net_device *dev) 398static int init_phy(struct net_device *dev)
416{ 399{
417 struct gfar_private *priv = netdev_priv(dev); 400 struct gfar_private *priv = netdev_priv(dev);
418 struct phy_info *curphy; 401 uint gigabit_support =
419 unsigned int timeout = PHY_INIT_TIMEOUT; 402 priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ?
420 struct gfar *phyregs = priv->phyregs; 403 SUPPORTED_1000baseT_Full : 0;
421 struct gfar_mii_info *mii_info; 404 struct phy_device *phydev;
422 int err;
423 405
424 priv->oldlink = 0; 406 priv->oldlink = 0;
425 priv->oldspeed = 0; 407 priv->oldspeed = 0;
426 priv->oldduplex = -1; 408 priv->oldduplex = -1;
427 409
428 mii_info = kmalloc(sizeof(struct gfar_mii_info), 410 phydev = phy_connect(dev, priv->einfo->bus_id, &adjust_link, 0);
429 GFP_KERNEL);
430
431 if(NULL == mii_info) {
432 if (netif_msg_ifup(priv))
433 printk(KERN_ERR "%s: Could not allocate mii_info\n",
434 dev->name);
435 return -ENOMEM;
436 }
437
438 mii_info->speed = SPEED_1000;
439 mii_info->duplex = DUPLEX_FULL;
440 mii_info->pause = 0;
441 mii_info->link = 1;
442
443 mii_info->advertising = (ADVERTISED_10baseT_Half |
444 ADVERTISED_10baseT_Full |
445 ADVERTISED_100baseT_Half |
446 ADVERTISED_100baseT_Full |
447 ADVERTISED_1000baseT_Full);
448 mii_info->autoneg = 1;
449 411
450 spin_lock_init(&mii_info->mdio_lock); 412 if (IS_ERR(phydev)) {
451 413 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
452 mii_info->mii_id = priv->einfo->phyid; 414 return PTR_ERR(phydev);
453
454 mii_info->dev = dev;
455
456 mii_info->mdio_read = &read_phy_reg;
457 mii_info->mdio_write = &write_phy_reg;
458
459 priv->mii_info = mii_info;
460
461 /* Reset the management interface */
462 gfar_write(&phyregs->miimcfg, MIIMCFG_RESET);
463
464 /* Setup the MII Mgmt clock speed */
465 gfar_write(&phyregs->miimcfg, MIIMCFG_INIT_VALUE);
466
467 /* Wait until the bus is free */
468 while ((gfar_read(&phyregs->miimind) & MIIMIND_BUSY) &&
469 timeout--)
470 cpu_relax();
471
472 if(timeout <= 0) {
473 printk(KERN_ERR "%s: The MII Bus is stuck!\n",
474 dev->name);
475 err = -1;
476 goto bus_fail;
477 }
478
479 /* get info for this PHY */
480 curphy = get_phy_info(priv->mii_info);
481
482 if (curphy == NULL) {
483 if (netif_msg_ifup(priv))
484 printk(KERN_ERR "%s: No PHY found\n", dev->name);
485 err = -1;
486 goto no_phy;
487 } 415 }
488 416
489 mii_info->phyinfo = curphy; 417 /* Remove any features not supported by the controller */
418 phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
419 phydev->advertising = phydev->supported;
490 420
491 /* Run the commands which initialize the PHY */ 421 priv->phydev = phydev;
492 if(curphy->init) {
493 err = curphy->init(priv->mii_info);
494
495 if (err)
496 goto phy_init_fail;
497 }
498 422
499 return 0; 423 return 0;
500
501phy_init_fail:
502no_phy:
503bus_fail:
504 kfree(mii_info);
505
506 return err;
507} 424}
508 425
509static void init_registers(struct net_device *dev) 426static void init_registers(struct net_device *dev)
@@ -603,24 +520,13 @@ void stop_gfar(struct net_device *dev)
603 struct gfar *regs = priv->regs; 520 struct gfar *regs = priv->regs;
604 unsigned long flags; 521 unsigned long flags;
605 522
523 phy_stop(priv->phydev);
524
606 /* Lock it down */ 525 /* Lock it down */
607 spin_lock_irqsave(&priv->lock, flags); 526 spin_lock_irqsave(&priv->lock, flags);
608 527
609 /* Tell the kernel the link is down */
610 priv->mii_info->link = 0;
611 adjust_link(dev);
612
613 gfar_halt(dev); 528 gfar_halt(dev);
614 529
615 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) {
616 /* Clear any pending interrupts */
617 mii_clear_phy_interrupt(priv->mii_info);
618
619 /* Disable PHY Interrupts */
620 mii_configure_phy_interrupt(priv->mii_info,
621 MII_INTERRUPT_DISABLED);
622 }
623
624 spin_unlock_irqrestore(&priv->lock, flags); 530 spin_unlock_irqrestore(&priv->lock, flags);
625 531
626 /* Free the IRQs */ 532 /* Free the IRQs */
@@ -629,13 +535,7 @@ void stop_gfar(struct net_device *dev)
629 free_irq(priv->interruptTransmit, dev); 535 free_irq(priv->interruptTransmit, dev);
630 free_irq(priv->interruptReceive, dev); 536 free_irq(priv->interruptReceive, dev);
631 } else { 537 } else {
632 free_irq(priv->interruptTransmit, dev); 538 free_irq(priv->interruptTransmit, dev);
633 }
634
635 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) {
636 free_irq(priv->einfo->interruptPHY, dev);
637 } else {
638 del_timer_sync(&priv->phy_info_timer);
639 } 539 }
640 540
641 free_skb_resources(priv); 541 free_skb_resources(priv);
@@ -649,7 +549,7 @@ void stop_gfar(struct net_device *dev)
649 549
650/* If there are any tx skbs or rx skbs still around, free them. 550/* If there are any tx skbs or rx skbs still around, free them.
651 * Then free tx_skbuff and rx_skbuff */ 551 * Then free tx_skbuff and rx_skbuff */
652void free_skb_resources(struct gfar_private *priv) 552static void free_skb_resources(struct gfar_private *priv)
653{ 553{
654 struct rxbd8 *rxbdp; 554 struct rxbd8 *rxbdp;
655 struct txbd8 *txbdp; 555 struct txbd8 *txbdp;
@@ -770,7 +670,7 @@ int startup_gfar(struct net_device *dev)
770 (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) * 670 (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) *
771 priv->tx_ring_size, GFP_KERNEL); 671 priv->tx_ring_size, GFP_KERNEL);
772 672
773 if (priv->tx_skbuff == NULL) { 673 if (NULL == priv->tx_skbuff) {
774 if (netif_msg_ifup(priv)) 674 if (netif_msg_ifup(priv))
775 printk(KERN_ERR "%s: Could not allocate tx_skbuff\n", 675 printk(KERN_ERR "%s: Could not allocate tx_skbuff\n",
776 dev->name); 676 dev->name);
@@ -785,7 +685,7 @@ int startup_gfar(struct net_device *dev)
785 (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) * 685 (struct sk_buff **) kmalloc(sizeof (struct sk_buff *) *
786 priv->rx_ring_size, GFP_KERNEL); 686 priv->rx_ring_size, GFP_KERNEL);
787 687
788 if (priv->rx_skbuff == NULL) { 688 if (NULL == priv->rx_skbuff) {
789 if (netif_msg_ifup(priv)) 689 if (netif_msg_ifup(priv))
790 printk(KERN_ERR "%s: Could not allocate rx_skbuff\n", 690 printk(KERN_ERR "%s: Could not allocate rx_skbuff\n",
791 dev->name); 691 dev->name);
@@ -879,13 +779,7 @@ int startup_gfar(struct net_device *dev)
879 } 779 }
880 } 780 }
881 781
882 /* Set up the PHY change work queue */ 782 phy_start(priv->phydev);
883 INIT_WORK(&priv->tq, gfar_phy_change, dev);
884
885 init_timer(&priv->phy_info_timer);
886 priv->phy_info_timer.function = &gfar_phy_startup_timer;
887 priv->phy_info_timer.data = (unsigned long) priv->mii_info;
888 mod_timer(&priv->phy_info_timer, jiffies + HZ);
889 783
890 /* Configure the coalescing support */ 784 /* Configure the coalescing support */
891 if (priv->txcoalescing) 785 if (priv->txcoalescing)
@@ -933,11 +827,6 @@ tx_skb_fail:
933 priv->tx_bd_base, 827 priv->tx_bd_base,
934 gfar_read(&regs->tbase0)); 828 gfar_read(&regs->tbase0));
935 829
936 if (priv->mii_info->phyinfo->close)
937 priv->mii_info->phyinfo->close(priv->mii_info);
938
939 kfree(priv->mii_info);
940
941 return err; 830 return err;
942} 831}
943 832
@@ -1035,7 +924,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
1035 txbdp->status &= TXBD_WRAP; 924 txbdp->status &= TXBD_WRAP;
1036 925
1037 /* Set up checksumming */ 926 /* Set up checksumming */
1038 if ((dev->features & NETIF_F_IP_CSUM) 927 if ((dev->features & NETIF_F_IP_CSUM)
1039 && (CHECKSUM_HW == skb->ip_summed)) { 928 && (CHECKSUM_HW == skb->ip_summed)) {
1040 fcb = gfar_add_fcb(skb, txbdp); 929 fcb = gfar_add_fcb(skb, txbdp);
1041 gfar_tx_checksum(skb, fcb); 930 gfar_tx_checksum(skb, fcb);
@@ -1103,11 +992,9 @@ static int gfar_close(struct net_device *dev)
1103 struct gfar_private *priv = netdev_priv(dev); 992 struct gfar_private *priv = netdev_priv(dev);
1104 stop_gfar(dev); 993 stop_gfar(dev);
1105 994
1106 /* Shutdown the PHY */ 995 /* Disconnect from the PHY */
1107 if (priv->mii_info->phyinfo->close) 996 phy_disconnect(priv->phydev);
1108 priv->mii_info->phyinfo->close(priv->mii_info); 997 priv->phydev = NULL;
1109
1110 kfree(priv->mii_info);
1111 998
1112 netif_stop_queue(dev); 999 netif_stop_queue(dev);
1113 1000
@@ -1343,7 +1230,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1343 while ((!skb) && timeout--) 1230 while ((!skb) && timeout--)
1344 skb = dev_alloc_skb(priv->rx_buffer_size + RXBUF_ALIGNMENT); 1231 skb = dev_alloc_skb(priv->rx_buffer_size + RXBUF_ALIGNMENT);
1345 1232
1346 if (skb == NULL) 1233 if (NULL == skb)
1347 return NULL; 1234 return NULL;
1348 1235
1349 /* We need the data buffer to be aligned properly. We will reserve 1236 /* We need the data buffer to be aligned properly. We will reserve
@@ -1490,7 +1377,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
1490 struct gfar_private *priv = netdev_priv(dev); 1377 struct gfar_private *priv = netdev_priv(dev);
1491 struct rxfcb *fcb = NULL; 1378 struct rxfcb *fcb = NULL;
1492 1379
1493 if (skb == NULL) { 1380 if (NULL == skb) {
1494 if (netif_msg_rx_err(priv)) 1381 if (netif_msg_rx_err(priv))
1495 printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name); 1382 printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name);
1496 priv->stats.rx_dropped++; 1383 priv->stats.rx_dropped++;
@@ -1718,131 +1605,9 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1718 return IRQ_HANDLED; 1605 return IRQ_HANDLED;
1719} 1606}
1720 1607
1721static irqreturn_t phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1722{
1723 struct net_device *dev = (struct net_device *) dev_id;
1724 struct gfar_private *priv = netdev_priv(dev);
1725
1726 /* Clear the interrupt */
1727 mii_clear_phy_interrupt(priv->mii_info);
1728
1729 /* Disable PHY interrupts */
1730 mii_configure_phy_interrupt(priv->mii_info,
1731 MII_INTERRUPT_DISABLED);
1732
1733 /* Schedule the phy change */
1734 schedule_work(&priv->tq);
1735
1736 return IRQ_HANDLED;
1737}
1738
1739/* Scheduled by the phy_interrupt/timer to handle PHY changes */
1740static void gfar_phy_change(void *data)
1741{
1742 struct net_device *dev = (struct net_device *) data;
1743 struct gfar_private *priv = netdev_priv(dev);
1744 int result = 0;
1745
1746 /* Delay to give the PHY a chance to change the
1747 * register state */
1748 msleep(1);
1749
1750 /* Update the link, speed, duplex */
1751 result = priv->mii_info->phyinfo->read_status(priv->mii_info);
1752
1753 /* Adjust the known status as long as the link
1754 * isn't still coming up */
1755 if((0 == result) || (priv->mii_info->link == 0))
1756 adjust_link(dev);
1757
1758 /* Reenable interrupts, if needed */
1759 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR)
1760 mii_configure_phy_interrupt(priv->mii_info,
1761 MII_INTERRUPT_ENABLED);
1762}
1763
1764/* Called every so often on systems that don't interrupt
1765 * the core for PHY changes */
1766static void gfar_phy_timer(unsigned long data)
1767{
1768 struct net_device *dev = (struct net_device *) data;
1769 struct gfar_private *priv = netdev_priv(dev);
1770
1771 schedule_work(&priv->tq);
1772
1773 mod_timer(&priv->phy_info_timer, jiffies +
1774 GFAR_PHY_CHANGE_TIME * HZ);
1775}
1776
1777/* Keep trying aneg for some time
1778 * If, after GFAR_AN_TIMEOUT seconds, it has not
1779 * finished, we switch to forced.
1780 * Either way, once the process has completed, we either
1781 * request the interrupt, or switch the timer over to
1782 * using gfar_phy_timer to check status */
1783static void gfar_phy_startup_timer(unsigned long data)
1784{
1785 int result;
1786 static int secondary = GFAR_AN_TIMEOUT;
1787 struct gfar_mii_info *mii_info = (struct gfar_mii_info *)data;
1788 struct gfar_private *priv = netdev_priv(mii_info->dev);
1789
1790 /* Configure the Auto-negotiation */
1791 result = mii_info->phyinfo->config_aneg(mii_info);
1792
1793 /* If autonegotiation failed to start, and
1794 * we haven't timed out, reset the timer, and return */
1795 if (result && secondary--) {
1796 mod_timer(&priv->phy_info_timer, jiffies + HZ);
1797 return;
1798 } else if (result) {
1799 /* Couldn't start autonegotiation.
1800 * Try switching to forced */
1801 mii_info->autoneg = 0;
1802 result = mii_info->phyinfo->config_aneg(mii_info);
1803
1804 /* Forcing failed! Give up */
1805 if(result) {
1806 if (netif_msg_link(priv))
1807 printk(KERN_ERR "%s: Forcing failed!\n",
1808 mii_info->dev->name);
1809 return;
1810 }
1811 }
1812
1813 /* Kill the timer so it can be restarted */
1814 del_timer_sync(&priv->phy_info_timer);
1815
1816 /* Grab the PHY interrupt, if necessary/possible */
1817 if (priv->einfo->board_flags & FSL_GIANFAR_BRD_HAS_PHY_INTR) {
1818 if (request_irq(priv->einfo->interruptPHY,
1819 phy_interrupt,
1820 SA_SHIRQ,
1821 "phy_interrupt",
1822 mii_info->dev) < 0) {
1823 if (netif_msg_intr(priv))
1824 printk(KERN_ERR "%s: Can't get IRQ %d (PHY)\n",
1825 mii_info->dev->name,
1826 priv->einfo->interruptPHY);
1827 } else {
1828 mii_configure_phy_interrupt(priv->mii_info,
1829 MII_INTERRUPT_ENABLED);
1830 return;
1831 }
1832 }
1833
1834 /* Start the timer again, this time in order to
1835 * handle a change in status */
1836 init_timer(&priv->phy_info_timer);
1837 priv->phy_info_timer.function = &gfar_phy_timer;
1838 priv->phy_info_timer.data = (unsigned long) mii_info->dev;
1839 mod_timer(&priv->phy_info_timer, jiffies +
1840 GFAR_PHY_CHANGE_TIME * HZ);
1841}
1842
1843/* Called every time the controller might need to be made 1608/* Called every time the controller might need to be made
1844 * aware of new link state. The PHY code conveys this 1609 * aware of new link state. The PHY code conveys this
1845 * information through variables in the priv structure, and this 1610 * information through variables in the phydev structure, and this
1846 * function converts those variables into the appropriate 1611 * function converts those variables into the appropriate
1847 * register values, and can bring down the device if needed. 1612 * register values, and can bring down the device if needed.
1848 */ 1613 */
@@ -1850,84 +1615,68 @@ static void adjust_link(struct net_device *dev)
1850{ 1615{
1851 struct gfar_private *priv = netdev_priv(dev); 1616 struct gfar_private *priv = netdev_priv(dev);
1852 struct gfar *regs = priv->regs; 1617 struct gfar *regs = priv->regs;
1853 u32 tempval; 1618 unsigned long flags;
1854 struct gfar_mii_info *mii_info = priv->mii_info; 1619 struct phy_device *phydev = priv->phydev;
1620 int new_state = 0;
1621
1622 spin_lock_irqsave(&priv->lock, flags);
1623 if (phydev->link) {
1624 u32 tempval = gfar_read(&regs->maccfg2);
1855 1625
1856 if (mii_info->link) {
1857 /* Now we make sure that we can be in full duplex mode. 1626 /* Now we make sure that we can be in full duplex mode.
1858 * If not, we operate in half-duplex mode. */ 1627 * If not, we operate in half-duplex mode. */
1859 if (mii_info->duplex != priv->oldduplex) { 1628 if (phydev->duplex != priv->oldduplex) {
1860 if (!(mii_info->duplex)) { 1629 new_state = 1;
1861 tempval = gfar_read(&regs->maccfg2); 1630 if (!(phydev->duplex))
1862 tempval &= ~(MACCFG2_FULL_DUPLEX); 1631 tempval &= ~(MACCFG2_FULL_DUPLEX);
1863 gfar_write(&regs->maccfg2, tempval); 1632 else
1864
1865 if (netif_msg_link(priv))
1866 printk(KERN_INFO "%s: Half Duplex\n",
1867 dev->name);
1868 } else {
1869 tempval = gfar_read(&regs->maccfg2);
1870 tempval |= MACCFG2_FULL_DUPLEX; 1633 tempval |= MACCFG2_FULL_DUPLEX;
1871 gfar_write(&regs->maccfg2, tempval);
1872 1634
1873 if (netif_msg_link(priv)) 1635 priv->oldduplex = phydev->duplex;
1874 printk(KERN_INFO "%s: Full Duplex\n",
1875 dev->name);
1876 }
1877
1878 priv->oldduplex = mii_info->duplex;
1879 } 1636 }
1880 1637
1881 if (mii_info->speed != priv->oldspeed) { 1638 if (phydev->speed != priv->oldspeed) {
1882 switch (mii_info->speed) { 1639 new_state = 1;
1640 switch (phydev->speed) {
1883 case 1000: 1641 case 1000:
1884 tempval = gfar_read(&regs->maccfg2);
1885 tempval = 1642 tempval =
1886 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII); 1643 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
1887 gfar_write(&regs->maccfg2, tempval);
1888 break; 1644 break;
1889 case 100: 1645 case 100:
1890 case 10: 1646 case 10:
1891 tempval = gfar_read(&regs->maccfg2);
1892 tempval = 1647 tempval =
1893 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII); 1648 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII);
1894 gfar_write(&regs->maccfg2, tempval);
1895 break; 1649 break;
1896 default: 1650 default:
1897 if (netif_msg_link(priv)) 1651 if (netif_msg_link(priv))
1898 printk(KERN_WARNING 1652 printk(KERN_WARNING
1899 "%s: Ack! Speed (%d) is not 10/100/1000!\n", 1653 "%s: Ack! Speed (%d) is not 10/100/1000!\n",
1900 dev->name, mii_info->speed); 1654 dev->name, phydev->speed);
1901 break; 1655 break;
1902 } 1656 }
1903 1657
1904 if (netif_msg_link(priv)) 1658 priv->oldspeed = phydev->speed;
1905 printk(KERN_INFO "%s: Speed %dBT\n", dev->name,
1906 mii_info->speed);
1907
1908 priv->oldspeed = mii_info->speed;
1909 } 1659 }
1910 1660
1661 gfar_write(&regs->maccfg2, tempval);
1662
1911 if (!priv->oldlink) { 1663 if (!priv->oldlink) {
1912 if (netif_msg_link(priv)) 1664 new_state = 1;
1913 printk(KERN_INFO "%s: Link is up\n", dev->name);
1914 priv->oldlink = 1; 1665 priv->oldlink = 1;
1915 netif_carrier_on(dev);
1916 netif_schedule(dev); 1666 netif_schedule(dev);
1917 } 1667 }
1918 } else { 1668 } else if (priv->oldlink) {
1919 if (priv->oldlink) { 1669 new_state = 1;
1920 if (netif_msg_link(priv)) 1670 priv->oldlink = 0;
1921 printk(KERN_INFO "%s: Link is down\n", 1671 priv->oldspeed = 0;
1922 dev->name); 1672 priv->oldduplex = -1;
1923 priv->oldlink = 0;
1924 priv->oldspeed = 0;
1925 priv->oldduplex = -1;
1926 netif_carrier_off(dev);
1927 }
1928 } 1673 }
1929}
1930 1674
1675 if (new_state && netif_msg_link(priv))
1676 phy_print_status(phydev);
1677
1678 spin_unlock_irqrestore(&priv->lock, flags);
1679}
1931 1680
1932/* Update the hash table based on the current list of multicast 1681/* Update the hash table based on the current list of multicast
1933 * addresses we subscribe to. Also, change the promiscuity of 1682 * addresses we subscribe to. Also, change the promiscuity of
@@ -2122,12 +1871,23 @@ static struct device_driver gfar_driver = {
2122 1871
2123static int __init gfar_init(void) 1872static int __init gfar_init(void)
2124{ 1873{
2125 return driver_register(&gfar_driver); 1874 int err = gfar_mdio_init();
1875
1876 if (err)
1877 return err;
1878
1879 err = driver_register(&gfar_driver);
1880
1881 if (err)
1882 gfar_mdio_exit();
1883
1884 return err;
2126} 1885}
2127 1886
2128static void __exit gfar_exit(void) 1887static void __exit gfar_exit(void)
2129{ 1888{
2130 driver_unregister(&gfar_driver); 1889 driver_unregister(&gfar_driver);
1890 gfar_mdio_exit();
2131} 1891}
2132 1892
2133module_init(gfar_init); 1893module_init(gfar_init);
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 28af087d9fbb..c77ca6c0d04a 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -17,7 +17,6 @@
17 * 17 *
18 * Still left to do: 18 * Still left to do:
19 * -Add support for module parameters 19 * -Add support for module parameters
20 * -Add support for ethtool -s
21 * -Add patch for ethtool phys id 20 * -Add patch for ethtool phys id
22 */ 21 */
23#ifndef __GIANFAR_H 22#ifndef __GIANFAR_H
@@ -37,7 +36,8 @@
37#include <linux/skbuff.h> 36#include <linux/skbuff.h>
38#include <linux/spinlock.h> 37#include <linux/spinlock.h>
39#include <linux/mm.h> 38#include <linux/mm.h>
40#include <linux/fsl_devices.h> 39#include <linux/mii.h>
40#include <linux/phy.h>
41 41
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/irq.h> 43#include <asm/irq.h>
@@ -48,7 +48,8 @@
48#include <linux/workqueue.h> 48#include <linux/workqueue.h>
49#include <linux/ethtool.h> 49#include <linux/ethtool.h>
50#include <linux/netdevice.h> 50#include <linux/netdevice.h>
51#include "gianfar_phy.h" 51#include <linux/fsl_devices.h>
52#include "gianfar_mii.h"
52 53
53/* The maximum number of packets to be handled in one call of gfar_poll */ 54/* The maximum number of packets to be handled in one call of gfar_poll */
54#define GFAR_DEV_WEIGHT 64 55#define GFAR_DEV_WEIGHT 64
@@ -73,7 +74,7 @@
73#define PHY_INIT_TIMEOUT 100000 74#define PHY_INIT_TIMEOUT 100000
74#define GFAR_PHY_CHANGE_TIME 2 75#define GFAR_PHY_CHANGE_TIME 2
75 76
76#define DEVICE_NAME "%s: Gianfar Ethernet Controller Version 1.1, " 77#define DEVICE_NAME "%s: Gianfar Ethernet Controller Version 1.2, "
77#define DRV_NAME "gfar-enet" 78#define DRV_NAME "gfar-enet"
78extern const char gfar_driver_name[]; 79extern const char gfar_driver_name[];
79extern const char gfar_driver_version[]; 80extern const char gfar_driver_version[];
@@ -578,12 +579,7 @@ struct gfar {
578 u32 hafdup; /* 0x.50c - Half Duplex Register */ 579 u32 hafdup; /* 0x.50c - Half Duplex Register */
579 u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */ 580 u32 maxfrm; /* 0x.510 - Maximum Frame Length Register */
580 u8 res18[12]; 581 u8 res18[12];
581 u32 miimcfg; /* 0x.520 - MII Management Configuration Register */ 582 u8 gfar_mii_regs[24]; /* See gianfar_phy.h */
582 u32 miimcom; /* 0x.524 - MII Management Command Register */
583 u32 miimadd; /* 0x.528 - MII Management Address Register */
584 u32 miimcon; /* 0x.52c - MII Management Control Register */
585 u32 miimstat; /* 0x.530 - MII Management Status Register */
586 u32 miimind; /* 0x.534 - MII Management Indicator Register */
587 u8 res19[4]; 583 u8 res19[4];
588 u32 ifstat; /* 0x.53c - Interface Status Register */ 584 u32 ifstat; /* 0x.53c - Interface Status Register */
589 u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */ 585 u32 macstnaddr1; /* 0x.540 - Station Address Part 1 Register */
@@ -688,9 +684,6 @@ struct gfar_private {
688 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */ 684 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */
689 u32 *hash_regs[16]; 685 u32 *hash_regs[16];
690 int hash_width; 686 int hash_width;
691 struct gfar *phyregs;
692 struct work_struct tq;
693 struct timer_list phy_info_timer;
694 struct net_device_stats stats; /* linux network statistics */ 687 struct net_device_stats stats; /* linux network statistics */
695 struct gfar_extra_stats extra_stats; 688 struct gfar_extra_stats extra_stats;
696 spinlock_t lock; 689 spinlock_t lock;
@@ -710,7 +703,8 @@ struct gfar_private {
710 unsigned int interruptError; 703 unsigned int interruptError;
711 struct gianfar_platform_data *einfo; 704 struct gianfar_platform_data *einfo;
712 705
713 struct gfar_mii_info *mii_info; 706 struct phy_device *phydev;
707 struct mii_bus *mii_bus;
714 int oldspeed; 708 int oldspeed;
715 int oldduplex; 709 int oldduplex;
716 int oldlink; 710 int oldlink;
@@ -732,4 +726,12 @@ extern inline void gfar_write(volatile unsigned *addr, u32 val)
732 726
733extern struct ethtool_ops *gfar_op_array[]; 727extern struct ethtool_ops *gfar_op_array[];
734 728
729extern irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs);
730extern int startup_gfar(struct net_device *dev);
731extern void stop_gfar(struct net_device *dev);
732extern void gfar_halt(struct net_device *dev);
733extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
734 int enable, u32 regnum, u32 read);
735void gfar_setup_stashing(struct net_device *dev);
736
735#endif /* __GIANFAR_H */ 737#endif /* __GIANFAR_H */
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index a451de629197..68e3578e7613 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -39,17 +39,18 @@
39#include <asm/types.h> 39#include <asm/types.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <linux/ethtool.h> 41#include <linux/ethtool.h>
42#include <linux/mii.h>
43#include <linux/phy.h>
42 44
43#include "gianfar.h" 45#include "gianfar.h"
44 46
45#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0)) 47#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
46 48
47extern int startup_gfar(struct net_device *dev);
48extern void stop_gfar(struct net_device *dev);
49extern void gfar_halt(struct net_device *dev);
50extern void gfar_start(struct net_device *dev); 49extern void gfar_start(struct net_device *dev);
51extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 50extern int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
52 51
52#define GFAR_MAX_COAL_USECS 0xffff
53#define GFAR_MAX_COAL_FRAMES 0xff
53static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy, 54static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
54 u64 * buf); 55 u64 * buf);
55static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf); 56static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf);
@@ -182,38 +183,32 @@ static void gfar_gdrvinfo(struct net_device *dev, struct
182 drvinfo->eedump_len = 0; 183 drvinfo->eedump_len = 0;
183} 184}
184 185
186
187static int gfar_ssettings(struct net_device *dev, struct ethtool_cmd *cmd)
188{
189 struct gfar_private *priv = netdev_priv(dev);
190 struct phy_device *phydev = priv->phydev;
191
192 if (NULL == phydev)
193 return -ENODEV;
194
195 return phy_ethtool_sset(phydev, cmd);
196}
197
198
185/* Return the current settings in the ethtool_cmd structure */ 199/* Return the current settings in the ethtool_cmd structure */
186static int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd) 200static int gfar_gsettings(struct net_device *dev, struct ethtool_cmd *cmd)
187{ 201{
188 struct gfar_private *priv = netdev_priv(dev); 202 struct gfar_private *priv = netdev_priv(dev);
189 uint gigabit_support = 203 struct phy_device *phydev = priv->phydev;
190 priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ? 204
191 SUPPORTED_1000baseT_Full : 0; 205 if (NULL == phydev)
192 uint gigabit_advert = 206 return -ENODEV;
193 priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT ? 207
194 ADVERTISED_1000baseT_Full: 0;
195
196 cmd->supported = (SUPPORTED_10baseT_Half
197 | SUPPORTED_100baseT_Half
198 | SUPPORTED_100baseT_Full
199 | gigabit_support | SUPPORTED_Autoneg);
200
201 /* For now, we always advertise everything */
202 cmd->advertising = (ADVERTISED_10baseT_Half
203 | ADVERTISED_100baseT_Half
204 | ADVERTISED_100baseT_Full
205 | gigabit_advert | ADVERTISED_Autoneg);
206
207 cmd->speed = priv->mii_info->speed;
208 cmd->duplex = priv->mii_info->duplex;
209 cmd->port = PORT_MII;
210 cmd->phy_address = priv->mii_info->mii_id;
211 cmd->transceiver = XCVR_EXTERNAL;
212 cmd->autoneg = AUTONEG_ENABLE;
213 cmd->maxtxpkt = priv->txcount; 208 cmd->maxtxpkt = priv->txcount;
214 cmd->maxrxpkt = priv->rxcount; 209 cmd->maxrxpkt = priv->rxcount;
215 210
216 return 0; 211 return phy_ethtool_gset(phydev, cmd);
217} 212}
218 213
219/* Return the length of the register structure */ 214/* Return the length of the register structure */
@@ -241,14 +236,14 @@ static unsigned int gfar_usecs2ticks(struct gfar_private *priv, unsigned int use
241 unsigned int count; 236 unsigned int count;
242 237
243 /* The timer is different, depending on the interface speed */ 238 /* The timer is different, depending on the interface speed */
244 switch (priv->mii_info->speed) { 239 switch (priv->phydev->speed) {
245 case 1000: 240 case SPEED_1000:
246 count = GFAR_GBIT_TIME; 241 count = GFAR_GBIT_TIME;
247 break; 242 break;
248 case 100: 243 case SPEED_100:
249 count = GFAR_100_TIME; 244 count = GFAR_100_TIME;
250 break; 245 break;
251 case 10: 246 case SPEED_10:
252 default: 247 default:
253 count = GFAR_10_TIME; 248 count = GFAR_10_TIME;
254 break; 249 break;
@@ -265,14 +260,14 @@ static unsigned int gfar_ticks2usecs(struct gfar_private *priv, unsigned int tic
265 unsigned int count; 260 unsigned int count;
266 261
267 /* The timer is different, depending on the interface speed */ 262 /* The timer is different, depending on the interface speed */
268 switch (priv->mii_info->speed) { 263 switch (priv->phydev->speed) {
269 case 1000: 264 case SPEED_1000:
270 count = GFAR_GBIT_TIME; 265 count = GFAR_GBIT_TIME;
271 break; 266 break;
272 case 100: 267 case SPEED_100:
273 count = GFAR_100_TIME; 268 count = GFAR_100_TIME;
274 break; 269 break;
275 case 10: 270 case SPEED_10:
276 default: 271 default:
277 count = GFAR_10_TIME; 272 count = GFAR_10_TIME;
278 break; 273 break;
@@ -292,6 +287,9 @@ static int gfar_gcoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
292 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE)) 287 if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_COALESCE))
293 return -EOPNOTSUPP; 288 return -EOPNOTSUPP;
294 289
290 if (NULL == priv->phydev)
291 return -ENODEV;
292
295 cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, priv->rxtime); 293 cvals->rx_coalesce_usecs = gfar_ticks2usecs(priv, priv->rxtime);
296 cvals->rx_max_coalesced_frames = priv->rxcount; 294 cvals->rx_max_coalesced_frames = priv->rxcount;
297 295
@@ -348,6 +346,22 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
348 else 346 else
349 priv->rxcoalescing = 1; 347 priv->rxcoalescing = 1;
350 348
349 if (NULL == priv->phydev)
350 return -ENODEV;
351
352 /* Check the bounds of the values */
353 if (cvals->rx_coalesce_usecs > GFAR_MAX_COAL_USECS) {
354 pr_info("Coalescing is limited to %d microseconds\n",
355 GFAR_MAX_COAL_USECS);
356 return -EINVAL;
357 }
358
359 if (cvals->rx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {
360 pr_info("Coalescing is limited to %d frames\n",
361 GFAR_MAX_COAL_FRAMES);
362 return -EINVAL;
363 }
364
351 priv->rxtime = gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs); 365 priv->rxtime = gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs);
352 priv->rxcount = cvals->rx_max_coalesced_frames; 366 priv->rxcount = cvals->rx_max_coalesced_frames;
353 367
@@ -358,6 +372,19 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
358 else 372 else
359 priv->txcoalescing = 1; 373 priv->txcoalescing = 1;
360 374
375 /* Check the bounds of the values */
376 if (cvals->tx_coalesce_usecs > GFAR_MAX_COAL_USECS) {
377 pr_info("Coalescing is limited to %d microseconds\n",
378 GFAR_MAX_COAL_USECS);
379 return -EINVAL;
380 }
381
382 if (cvals->tx_max_coalesced_frames > GFAR_MAX_COAL_FRAMES) {
383 pr_info("Coalescing is limited to %d frames\n",
384 GFAR_MAX_COAL_FRAMES);
385 return -EINVAL;
386 }
387
361 priv->txtime = gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs); 388 priv->txtime = gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs);
362 priv->txcount = cvals->tx_max_coalesced_frames; 389 priv->txcount = cvals->tx_max_coalesced_frames;
363 390
@@ -536,6 +563,7 @@ static void gfar_set_msglevel(struct net_device *dev, uint32_t data)
536 563
537struct ethtool_ops gfar_ethtool_ops = { 564struct ethtool_ops gfar_ethtool_ops = {
538 .get_settings = gfar_gsettings, 565 .get_settings = gfar_gsettings,
566 .set_settings = gfar_ssettings,
539 .get_drvinfo = gfar_gdrvinfo, 567 .get_drvinfo = gfar_gdrvinfo,
540 .get_regs_len = gfar_reglen, 568 .get_regs_len = gfar_reglen,
541 .get_regs = gfar_get_regs, 569 .get_regs = gfar_get_regs,
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
new file mode 100644
index 000000000000..1eca1dbca7f1
--- /dev/null
+++ b/drivers/net/gianfar_mii.c
@@ -0,0 +1,219 @@
1/*
2 * drivers/net/gianfar_mii.c
3 *
4 * Gianfar Ethernet Driver -- MIIM bus implementation
5 * Provides Bus interface for MIIM regs
6 *
7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 */
18
19#include <linux/config.h>
20#include <linux/kernel.h>
21#include <linux/sched.h>
22#include <linux/string.h>
23#include <linux/errno.h>
24#include <linux/unistd.h>
25#include <linux/slab.h>
26#include <linux/interrupt.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/netdevice.h>
30#include <linux/etherdevice.h>
31#include <linux/skbuff.h>
32#include <linux/spinlock.h>
33#include <linux/mm.h>
34#include <linux/module.h>
35#include <linux/version.h>
36#include <asm/ocp.h>
37#include <linux/crc32.h>
38#include <linux/mii.h>
39#include <linux/phy.h>
40
41#include <asm/io.h>
42#include <asm/irq.h>
43#include <asm/uaccess.h>
44
45#include "gianfar.h"
46#include "gianfar_mii.h"
47
48/* Write value to the PHY at mii_id at register regnum,
49 * on the bus, waiting until the write is done before returning.
50 * All PHY configuration is done through the TSEC1 MIIM regs */
51int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)
52{
53 struct gfar_mii *regs = bus->priv;
54
55 /* Set the PHY address and the register address we want to write */
56 gfar_write(&regs->miimadd, (mii_id << 8) | regnum);
57
58 /* Write out the value we want */
59 gfar_write(&regs->miimcon, value);
60
61 /* Wait for the transaction to finish */
62 while (gfar_read(&regs->miimind) & MIIMIND_BUSY)
63 cpu_relax();
64
65 return 0;
66}
67
68/* Read the bus for PHY at addr mii_id, register regnum, and
69 * return the value. Clears miimcom first. All PHY
70 * configuration has to be done through the TSEC1 MIIM regs */
71int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
72{
73 struct gfar_mii *regs = bus->priv;
74 u16 value;
75
76 /* Set the PHY address and the register address we want to read */
77 gfar_write(&regs->miimadd, (mii_id << 8) | regnum);
78
79 /* Clear miimcom, and then initiate a read */
80 gfar_write(&regs->miimcom, 0);
81 gfar_write(&regs->miimcom, MII_READ_COMMAND);
82
83 /* Wait for the transaction to finish */
84 while (gfar_read(&regs->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY))
85 cpu_relax();
86
87 /* Grab the value of the register from miimstat */
88 value = gfar_read(&regs->miimstat);
89
90 return value;
91}
92
93
94/* Reset the MIIM registers, and wait for the bus to free */
95int gfar_mdio_reset(struct mii_bus *bus)
96{
97 struct gfar_mii *regs = bus->priv;
98 unsigned int timeout = PHY_INIT_TIMEOUT;
99
100 spin_lock_bh(&bus->mdio_lock);
101
102 /* Reset the management interface */
103 gfar_write(&regs->miimcfg, MIIMCFG_RESET);
104
105 /* Setup the MII Mgmt clock speed */
106 gfar_write(&regs->miimcfg, MIIMCFG_INIT_VALUE);
107
108 /* Wait until the bus is free */
109 while ((gfar_read(&regs->miimind) & MIIMIND_BUSY) &&
110 timeout--)
111 cpu_relax();
112
113 spin_unlock_bh(&bus->mdio_lock);
114
115 if(timeout <= 0) {
116 printk(KERN_ERR "%s: The MII Bus is stuck!\n",
117 bus->name);
118 return -EBUSY;
119 }
120
121 return 0;
122}
123
124
125int gfar_mdio_probe(struct device *dev)
126{
127 struct platform_device *pdev = to_platform_device(dev);
128 struct gianfar_mdio_data *pdata;
129 struct gfar_mii *regs;
130 struct mii_bus *new_bus;
131 int err = 0;
132
133 if (NULL == dev)
134 return -EINVAL;
135
136 new_bus = kmalloc(sizeof(struct mii_bus), GFP_KERNEL);
137
138 if (NULL == new_bus)
139 return -ENOMEM;
140
141 new_bus->name = "Gianfar MII Bus",
142 new_bus->read = &gfar_mdio_read,
143 new_bus->write = &gfar_mdio_write,
144 new_bus->reset = &gfar_mdio_reset,
145 new_bus->id = pdev->id;
146
147 pdata = (struct gianfar_mdio_data *)pdev->dev.platform_data;
148
149 if (NULL == pdata) {
150 printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
151 return -ENODEV;
152 }
153
154 /* Set the PHY base address */
155 regs = (struct gfar_mii *) ioremap(pdata->paddr,
156 sizeof (struct gfar_mii));
157
158 if (NULL == regs) {
159 err = -ENOMEM;
160 goto reg_map_fail;
161 }
162
163 new_bus->priv = regs;
164
165 new_bus->irq = pdata->irq;
166
167 new_bus->dev = dev;
168 dev_set_drvdata(dev, new_bus);
169
170 err = mdiobus_register(new_bus);
171
172 if (0 != err) {
173 printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
174 new_bus->name);
175 goto bus_register_fail;
176 }
177
178 return 0;
179
180bus_register_fail:
181 iounmap((void *) regs);
182reg_map_fail:
183 kfree(new_bus);
184
185 return err;
186}
187
188
189int gfar_mdio_remove(struct device *dev)
190{
191 struct mii_bus *bus = dev_get_drvdata(dev);
192
193 mdiobus_unregister(bus);
194
195 dev_set_drvdata(dev, NULL);
196
197 iounmap((void *) (&bus->priv));
198 bus->priv = NULL;
199 kfree(bus);
200
201 return 0;
202}
203
204static struct device_driver gianfar_mdio_driver = {
205 .name = "fsl-gianfar_mdio",
206 .bus = &platform_bus_type,
207 .probe = gfar_mdio_probe,
208 .remove = gfar_mdio_remove,
209};
210
211int __init gfar_mdio_init(void)
212{
213 return driver_register(&gianfar_mdio_driver);
214}
215
216void __exit gfar_mdio_exit(void)
217{
218 driver_unregister(&gianfar_mdio_driver);
219}
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
new file mode 100644
index 000000000000..56e5665d5c9b
--- /dev/null
+++ b/drivers/net/gianfar_mii.h
@@ -0,0 +1,45 @@
1/*
2 * drivers/net/gianfar_mii.h
3 *
4 * Gianfar Ethernet Driver -- MII Management Bus Implementation
5 * Driver for the MDIO bus controller in the Gianfar register space
6 *
7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 */
18#ifndef __GIANFAR_MII_H
19#define __GIANFAR_MII_H
20
21#define MIIMIND_BUSY 0x00000001
22#define MIIMIND_NOTVALID 0x00000004
23
24#define MII_READ_COMMAND 0x00000001
25
26#define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \
27 | SUPPORTED_100baseT_Half \
28 | SUPPORTED_100baseT_Full \
29 | SUPPORTED_Autoneg \
30 | SUPPORTED_MII)
31
32struct gfar_mii {
33 u32 miimcfg; /* 0x.520 - MII Management Config Register */
34 u32 miimcom; /* 0x.524 - MII Management Command Register */
35 u32 miimadd; /* 0x.528 - MII Management Address Register */
36 u32 miimcon; /* 0x.52c - MII Management Control Register */
37 u32 miimstat; /* 0x.530 - MII Management Status Register */
38 u32 miimind; /* 0x.534 - MII Management Indicator Register */
39};
40
41int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum);
42int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value);
43int __init gfar_mdio_init(void);
44void __exit gfar_mdio_exit(void);
45#endif /* GIANFAR_PHY_H */
diff --git a/drivers/net/gianfar_phy.c b/drivers/net/gianfar_phy.c
deleted file mode 100644
index 7c965f268a82..000000000000
--- a/drivers/net/gianfar_phy.c
+++ /dev/null
@@ -1,661 +0,0 @@
1/*
2 * drivers/net/gianfar_phy.c
3 *
4 * Gianfar Ethernet Driver -- PHY handling
5 * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
6 * Based on 8260_io/fcc_enet.c
7 *
8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 */
19
20#include <linux/config.h>
21#include <linux/kernel.h>
22#include <linux/sched.h>
23#include <linux/string.h>
24#include <linux/errno.h>
25#include <linux/slab.h>
26#include <linux/interrupt.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/netdevice.h>
30#include <linux/etherdevice.h>
31#include <linux/skbuff.h>
32#include <linux/spinlock.h>
33#include <linux/mm.h>
34
35#include <asm/io.h>
36#include <asm/irq.h>
37#include <asm/uaccess.h>
38#include <linux/module.h>
39#include <linux/version.h>
40#include <linux/crc32.h>
41#include <linux/mii.h>
42
43#include "gianfar.h"
44#include "gianfar_phy.h"
45
46static void config_genmii_advert(struct gfar_mii_info *mii_info);
47static void genmii_setup_forced(struct gfar_mii_info *mii_info);
48static void genmii_restart_aneg(struct gfar_mii_info *mii_info);
49static int gbit_config_aneg(struct gfar_mii_info *mii_info);
50static int genmii_config_aneg(struct gfar_mii_info *mii_info);
51static int genmii_update_link(struct gfar_mii_info *mii_info);
52static int genmii_read_status(struct gfar_mii_info *mii_info);
53u16 phy_read(struct gfar_mii_info *mii_info, u16 regnum);
54void phy_write(struct gfar_mii_info *mii_info, u16 regnum, u16 val);
55
56/* Write value to the PHY for this device to the register at regnum, */
57/* waiting until the write is done before it returns. All PHY */
58/* configuration has to be done through the TSEC1 MIIM regs */
59void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
60{
61 struct gfar_private *priv = netdev_priv(dev);
62 struct gfar *regbase = priv->phyregs;
63
64 /* Set the PHY address and the register address we want to write */
65 gfar_write(&regbase->miimadd, (mii_id << 8) | regnum);
66
67 /* Write out the value we want */
68 gfar_write(&regbase->miimcon, value);
69
70 /* Wait for the transaction to finish */
71 while (gfar_read(&regbase->miimind) & MIIMIND_BUSY)
72 cpu_relax();
73}
74
75/* Reads from register regnum in the PHY for device dev, */
76/* returning the value. Clears miimcom first. All PHY */
77/* configuration has to be done through the TSEC1 MIIM regs */
78int read_phy_reg(struct net_device *dev, int mii_id, int regnum)
79{
80 struct gfar_private *priv = netdev_priv(dev);
81 struct gfar *regbase = priv->phyregs;
82 u16 value;
83
84 /* Set the PHY address and the register address we want to read */
85 gfar_write(&regbase->miimadd, (mii_id << 8) | regnum);
86
87 /* Clear miimcom, and then initiate a read */
88 gfar_write(&regbase->miimcom, 0);
89 gfar_write(&regbase->miimcom, MII_READ_COMMAND);
90
91 /* Wait for the transaction to finish */
92 while (gfar_read(&regbase->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY))
93 cpu_relax();
94
95 /* Grab the value of the register from miimstat */
96 value = gfar_read(&regbase->miimstat);
97
98 return value;
99}
100
101void mii_clear_phy_interrupt(struct gfar_mii_info *mii_info)
102{
103 if(mii_info->phyinfo->ack_interrupt)
104 mii_info->phyinfo->ack_interrupt(mii_info);
105}
106
107
108void mii_configure_phy_interrupt(struct gfar_mii_info *mii_info, u32 interrupts)
109{
110 mii_info->interrupts = interrupts;
111 if(mii_info->phyinfo->config_intr)
112 mii_info->phyinfo->config_intr(mii_info);
113}
114
115
116/* Writes MII_ADVERTISE with the appropriate values, after
117 * sanitizing advertise to make sure only supported features
118 * are advertised
119 */
120static void config_genmii_advert(struct gfar_mii_info *mii_info)
121{
122 u32 advertise;
123 u16 adv;
124
125 /* Only allow advertising what this PHY supports */
126 mii_info->advertising &= mii_info->phyinfo->features;
127 advertise = mii_info->advertising;
128
129 /* Setup standard advertisement */
130 adv = phy_read(mii_info, MII_ADVERTISE);
131 adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4);
132 if (advertise & ADVERTISED_10baseT_Half)
133 adv |= ADVERTISE_10HALF;
134 if (advertise & ADVERTISED_10baseT_Full)
135 adv |= ADVERTISE_10FULL;
136 if (advertise & ADVERTISED_100baseT_Half)
137 adv |= ADVERTISE_100HALF;
138 if (advertise & ADVERTISED_100baseT_Full)
139 adv |= ADVERTISE_100FULL;
140 phy_write(mii_info, MII_ADVERTISE, adv);
141}
142
143static void genmii_setup_forced(struct gfar_mii_info *mii_info)
144{
145 u16 ctrl;
146 u32 features = mii_info->phyinfo->features;
147
148 ctrl = phy_read(mii_info, MII_BMCR);
149
150 ctrl &= ~(BMCR_FULLDPLX|BMCR_SPEED100|BMCR_SPEED1000|BMCR_ANENABLE);
151 ctrl |= BMCR_RESET;
152
153 switch(mii_info->speed) {
154 case SPEED_1000:
155 if(features & (SUPPORTED_1000baseT_Half
156 | SUPPORTED_1000baseT_Full)) {
157 ctrl |= BMCR_SPEED1000;
158 break;
159 }
160 mii_info->speed = SPEED_100;
161 case SPEED_100:
162 if (features & (SUPPORTED_100baseT_Half
163 | SUPPORTED_100baseT_Full)) {
164 ctrl |= BMCR_SPEED100;
165 break;
166 }
167 mii_info->speed = SPEED_10;
168 case SPEED_10:
169 if (features & (SUPPORTED_10baseT_Half
170 | SUPPORTED_10baseT_Full))
171 break;
172 default: /* Unsupported speed! */
173 printk(KERN_ERR "%s: Bad speed!\n",
174 mii_info->dev->name);
175 break;
176 }
177
178 phy_write(mii_info, MII_BMCR, ctrl);
179}
180
181
182/* Enable and Restart Autonegotiation */
183static void genmii_restart_aneg(struct gfar_mii_info *mii_info)
184{
185 u16 ctl;
186
187 ctl = phy_read(mii_info, MII_BMCR);
188 ctl |= (BMCR_ANENABLE | BMCR_ANRESTART);
189 phy_write(mii_info, MII_BMCR, ctl);
190}
191
192
193static int gbit_config_aneg(struct gfar_mii_info *mii_info)
194{
195 u16 adv;
196 u32 advertise;
197
198 if(mii_info->autoneg) {
199 /* Configure the ADVERTISE register */
200 config_genmii_advert(mii_info);
201 advertise = mii_info->advertising;
202
203 adv = phy_read(mii_info, MII_1000BASETCONTROL);
204 adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP |
205 MII_1000BASETCONTROL_HALFDUPLEXCAP);
206 if (advertise & SUPPORTED_1000baseT_Half)
207 adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP;
208 if (advertise & SUPPORTED_1000baseT_Full)
209 adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP;
210 phy_write(mii_info, MII_1000BASETCONTROL, adv);
211
212 /* Start/Restart aneg */
213 genmii_restart_aneg(mii_info);
214 } else
215 genmii_setup_forced(mii_info);
216
217 return 0;
218}
219
220static int marvell_config_aneg(struct gfar_mii_info *mii_info)
221{
222 /* The Marvell PHY has an errata which requires
223 * that certain registers get written in order
224 * to restart autonegotiation */
225 phy_write(mii_info, MII_BMCR, BMCR_RESET);
226
227 phy_write(mii_info, 0x1d, 0x1f);
228 phy_write(mii_info, 0x1e, 0x200c);
229 phy_write(mii_info, 0x1d, 0x5);
230 phy_write(mii_info, 0x1e, 0);
231 phy_write(mii_info, 0x1e, 0x100);
232
233 gbit_config_aneg(mii_info);
234
235 return 0;
236}
237static int genmii_config_aneg(struct gfar_mii_info *mii_info)
238{
239 if (mii_info->autoneg) {
240 config_genmii_advert(mii_info);
241 genmii_restart_aneg(mii_info);
242 } else
243 genmii_setup_forced(mii_info);
244
245 return 0;
246}
247
248
249static int genmii_update_link(struct gfar_mii_info *mii_info)
250{
251 u16 status;
252
253 /* Do a fake read */
254 phy_read(mii_info, MII_BMSR);
255
256 /* Read link and autonegotiation status */
257 status = phy_read(mii_info, MII_BMSR);
258 if ((status & BMSR_LSTATUS) == 0)
259 mii_info->link = 0;
260 else
261 mii_info->link = 1;
262
263 /* If we are autonegotiating, and not done,
264 * return an error */
265 if (mii_info->autoneg && !(status & BMSR_ANEGCOMPLETE))
266 return -EAGAIN;
267
268 return 0;
269}
270
271static int genmii_read_status(struct gfar_mii_info *mii_info)
272{
273 u16 status;
274 int err;
275
276 /* Update the link, but return if there
277 * was an error */
278 err = genmii_update_link(mii_info);
279 if (err)
280 return err;
281
282 if (mii_info->autoneg) {
283 status = phy_read(mii_info, MII_LPA);
284
285 if (status & (LPA_10FULL | LPA_100FULL))
286 mii_info->duplex = DUPLEX_FULL;
287 else
288 mii_info->duplex = DUPLEX_HALF;
289 if (status & (LPA_100FULL | LPA_100HALF))
290 mii_info->speed = SPEED_100;
291 else
292 mii_info->speed = SPEED_10;
293 mii_info->pause = 0;
294 }
295 /* On non-aneg, we assume what we put in BMCR is the speed,
296 * though magic-aneg shouldn't prevent this case from occurring
297 */
298
299 return 0;
300}
301static int marvell_read_status(struct gfar_mii_info *mii_info)
302{
303 u16 status;
304 int err;
305
306 /* Update the link, but return if there
307 * was an error */
308 err = genmii_update_link(mii_info);
309 if (err)
310 return err;
311
312 /* If the link is up, read the speed and duplex */
313 /* If we aren't autonegotiating, assume speeds
314 * are as set */
315 if (mii_info->autoneg && mii_info->link) {
316 int speed;
317 status = phy_read(mii_info, MII_M1011_PHY_SPEC_STATUS);
318
319#if 0
320 /* If speed and duplex aren't resolved,
321 * return an error. Isn't this handled
322 * by checking aneg?
323 */
324 if ((status & MII_M1011_PHY_SPEC_STATUS_RESOLVED) == 0)
325 return -EAGAIN;
326#endif
327
328 /* Get the duplexity */
329 if (status & MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX)
330 mii_info->duplex = DUPLEX_FULL;
331 else
332 mii_info->duplex = DUPLEX_HALF;
333
334 /* Get the speed */
335 speed = status & MII_M1011_PHY_SPEC_STATUS_SPD_MASK;
336 switch(speed) {
337 case MII_M1011_PHY_SPEC_STATUS_1000:
338 mii_info->speed = SPEED_1000;
339 break;
340 case MII_M1011_PHY_SPEC_STATUS_100:
341 mii_info->speed = SPEED_100;
342 break;
343 default:
344 mii_info->speed = SPEED_10;
345 break;
346 }
347 mii_info->pause = 0;
348 }
349
350 return 0;
351}
352
353
354static int cis820x_read_status(struct gfar_mii_info *mii_info)
355{
356 u16 status;
357 int err;
358
359 /* Update the link, but return if there
360 * was an error */
361 err = genmii_update_link(mii_info);
362 if (err)
363 return err;
364
365 /* If the link is up, read the speed and duplex */
366 /* If we aren't autonegotiating, assume speeds
367 * are as set */
368 if (mii_info->autoneg && mii_info->link) {
369 int speed;
370
371 status = phy_read(mii_info, MII_CIS8201_AUX_CONSTAT);
372 if (status & MII_CIS8201_AUXCONSTAT_DUPLEX)
373 mii_info->duplex = DUPLEX_FULL;
374 else
375 mii_info->duplex = DUPLEX_HALF;
376
377 speed = status & MII_CIS8201_AUXCONSTAT_SPEED;
378
379 switch (speed) {
380 case MII_CIS8201_AUXCONSTAT_GBIT:
381 mii_info->speed = SPEED_1000;
382 break;
383 case MII_CIS8201_AUXCONSTAT_100:
384 mii_info->speed = SPEED_100;
385 break;
386 default:
387 mii_info->speed = SPEED_10;
388 break;
389 }
390 }
391
392 return 0;
393}
394
395static int marvell_ack_interrupt(struct gfar_mii_info *mii_info)
396{
397 /* Clear the interrupts by reading the reg */
398 phy_read(mii_info, MII_M1011_IEVENT);
399
400 return 0;
401}
402
403static int marvell_config_intr(struct gfar_mii_info *mii_info)
404{
405 if(mii_info->interrupts == MII_INTERRUPT_ENABLED)
406 phy_write(mii_info, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
407 else
408 phy_write(mii_info, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
409
410 return 0;
411}
412
413static int cis820x_init(struct gfar_mii_info *mii_info)
414{
415 phy_write(mii_info, MII_CIS8201_AUX_CONSTAT,
416 MII_CIS8201_AUXCONSTAT_INIT);
417 phy_write(mii_info, MII_CIS8201_EXT_CON1,
418 MII_CIS8201_EXTCON1_INIT);
419
420 return 0;
421}
422
423static int cis820x_ack_interrupt(struct gfar_mii_info *mii_info)
424{
425 phy_read(mii_info, MII_CIS8201_ISTAT);
426
427 return 0;
428}
429
430static int cis820x_config_intr(struct gfar_mii_info *mii_info)
431{
432 if(mii_info->interrupts == MII_INTERRUPT_ENABLED)
433 phy_write(mii_info, MII_CIS8201_IMASK, MII_CIS8201_IMASK_MASK);
434 else
435 phy_write(mii_info, MII_CIS8201_IMASK, 0);
436
437 return 0;
438}
439
440#define DM9161_DELAY 10
441
442static int dm9161_read_status(struct gfar_mii_info *mii_info)
443{
444 u16 status;
445 int err;
446
447 /* Update the link, but return if there
448 * was an error */
449 err = genmii_update_link(mii_info);
450 if (err)
451 return err;
452
453 /* If the link is up, read the speed and duplex */
454 /* If we aren't autonegotiating, assume speeds
455 * are as set */
456 if (mii_info->autoneg && mii_info->link) {
457 status = phy_read(mii_info, MII_DM9161_SCSR);
458 if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_100H))
459 mii_info->speed = SPEED_100;
460 else
461 mii_info->speed = SPEED_10;
462
463 if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_10F))
464 mii_info->duplex = DUPLEX_FULL;
465 else
466 mii_info->duplex = DUPLEX_HALF;
467 }
468
469 return 0;
470}
471
472
473static int dm9161_config_aneg(struct gfar_mii_info *mii_info)
474{
475 struct dm9161_private *priv = mii_info->priv;
476
477 if(0 == priv->resetdone)
478 return -EAGAIN;
479
480 return 0;
481}
482
483static void dm9161_timer(unsigned long data)
484{
485 struct gfar_mii_info *mii_info = (struct gfar_mii_info *)data;
486 struct dm9161_private *priv = mii_info->priv;
487 u16 status = phy_read(mii_info, MII_BMSR);
488
489 if (status & BMSR_ANEGCOMPLETE) {
490 priv->resetdone = 1;
491 } else
492 mod_timer(&priv->timer, jiffies + DM9161_DELAY * HZ);
493}
494
495static int dm9161_init(struct gfar_mii_info *mii_info)
496{
497 struct dm9161_private *priv;
498
499 /* Allocate the private data structure */
500 priv = kmalloc(sizeof(struct dm9161_private), GFP_KERNEL);
501
502 if (NULL == priv)
503 return -ENOMEM;
504
505 mii_info->priv = priv;
506
507 /* Reset is not done yet */
508 priv->resetdone = 0;
509
510 /* Isolate the PHY */
511 phy_write(mii_info, MII_BMCR, BMCR_ISOLATE);
512
513 /* Do not bypass the scrambler/descrambler */
514 phy_write(mii_info, MII_DM9161_SCR, MII_DM9161_SCR_INIT);
515
516 /* Clear 10BTCSR to default */
517 phy_write(mii_info, MII_DM9161_10BTCSR, MII_DM9161_10BTCSR_INIT);
518
519 /* Reconnect the PHY, and enable Autonegotiation */
520 phy_write(mii_info, MII_BMCR, BMCR_ANENABLE);
521
522 /* Start a timer for DM9161_DELAY seconds to wait
523 * for the PHY to be ready */
524 init_timer(&priv->timer);
525 priv->timer.function = &dm9161_timer;
526 priv->timer.data = (unsigned long) mii_info;
527 mod_timer(&priv->timer, jiffies + DM9161_DELAY * HZ);
528
529 return 0;
530}
531
532static void dm9161_close(struct gfar_mii_info *mii_info)
533{
534 struct dm9161_private *priv = mii_info->priv;
535
536 del_timer_sync(&priv->timer);
537 kfree(priv);
538}
539
540#if 0
541static int dm9161_ack_interrupt(struct gfar_mii_info *mii_info)
542{
543 phy_read(mii_info, MII_DM9161_INTR);
544
545 return 0;
546}
547#endif
548
549/* Cicada 820x */
550static struct phy_info phy_info_cis820x = {
551 0x000fc440,
552 "Cicada Cis8204",
553 0x000fffc0,
554 .features = MII_GBIT_FEATURES,
555 .init = &cis820x_init,
556 .config_aneg = &gbit_config_aneg,
557 .read_status = &cis820x_read_status,
558 .ack_interrupt = &cis820x_ack_interrupt,
559 .config_intr = &cis820x_config_intr,
560};
561
562static struct phy_info phy_info_dm9161 = {
563 .phy_id = 0x0181b880,
564 .name = "Davicom DM9161E",
565 .phy_id_mask = 0x0ffffff0,
566 .init = dm9161_init,
567 .config_aneg = dm9161_config_aneg,
568 .read_status = dm9161_read_status,
569 .close = dm9161_close,
570};
571
572static struct phy_info phy_info_marvell = {
573 .phy_id = 0x01410c00,
574 .phy_id_mask = 0xffffff00,
575 .name = "Marvell 88E1101/88E1111",
576 .features = MII_GBIT_FEATURES,
577 .config_aneg = &marvell_config_aneg,
578 .read_status = &marvell_read_status,
579 .ack_interrupt = &marvell_ack_interrupt,
580 .config_intr = &marvell_config_intr,
581};
582
583static struct phy_info phy_info_genmii= {
584 .phy_id = 0x00000000,
585 .phy_id_mask = 0x00000000,
586 .name = "Generic MII",
587 .features = MII_BASIC_FEATURES,
588 .config_aneg = genmii_config_aneg,
589 .read_status = genmii_read_status,
590};
591
592static struct phy_info *phy_info[] = {
593 &phy_info_cis820x,
594 &phy_info_marvell,
595 &phy_info_dm9161,
596 &phy_info_genmii,
597 NULL
598};
599
600u16 phy_read(struct gfar_mii_info *mii_info, u16 regnum)
601{
602 u16 retval;
603 unsigned long flags;
604
605 spin_lock_irqsave(&mii_info->mdio_lock, flags);
606 retval = mii_info->mdio_read(mii_info->dev, mii_info->mii_id, regnum);
607 spin_unlock_irqrestore(&mii_info->mdio_lock, flags);
608
609 return retval;
610}
611
612void phy_write(struct gfar_mii_info *mii_info, u16 regnum, u16 val)
613{
614 unsigned long flags;
615
616 spin_lock_irqsave(&mii_info->mdio_lock, flags);
617 mii_info->mdio_write(mii_info->dev,
618 mii_info->mii_id,
619 regnum, val);
620 spin_unlock_irqrestore(&mii_info->mdio_lock, flags);
621}
622
623/* Use the PHY ID registers to determine what type of PHY is attached
624 * to device dev. return a struct phy_info structure describing that PHY
625 */
626struct phy_info * get_phy_info(struct gfar_mii_info *mii_info)
627{
628 u16 phy_reg;
629 u32 phy_ID;
630 int i;
631 struct phy_info *theInfo = NULL;
632 struct net_device *dev = mii_info->dev;
633
634 /* Grab the bits from PHYIR1, and put them in the upper half */
635 phy_reg = phy_read(mii_info, MII_PHYSID1);
636 phy_ID = (phy_reg & 0xffff) << 16;
637
638 /* Grab the bits from PHYIR2, and put them in the lower half */
639 phy_reg = phy_read(mii_info, MII_PHYSID2);
640 phy_ID |= (phy_reg & 0xffff);
641
642 /* loop through all the known PHY types, and find one that */
643 /* matches the ID we read from the PHY. */
644 for (i = 0; phy_info[i]; i++)
645 if (phy_info[i]->phy_id ==
646 (phy_ID & phy_info[i]->phy_id_mask)) {
647 theInfo = phy_info[i];
648 break;
649 }
650
651 /* This shouldn't happen, as we have generic PHY support */
652 if (theInfo == NULL) {
653 printk("%s: PHY id %x is not supported!\n", dev->name, phy_ID);
654 return NULL;
655 } else {
656 printk("%s: PHY is %s (%x)\n", dev->name, theInfo->name,
657 phy_ID);
658 }
659
660 return theInfo;
661}
diff --git a/drivers/net/gianfar_phy.h b/drivers/net/gianfar_phy.h
deleted file mode 100644
index 1e9b3abf1e6d..000000000000
--- a/drivers/net/gianfar_phy.h
+++ /dev/null
@@ -1,213 +0,0 @@
1/*
2 * drivers/net/gianfar_phy.h
3 *
4 * Gianfar Ethernet Driver -- PHY handling
5 * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560
6 * Based on 8260_io/fcc_enet.c
7 *
8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 */
19#ifndef __GIANFAR_PHY_H
20#define __GIANFAR_PHY_H
21
22#define MII_end ((u32)-2)
23#define MII_read ((u32)-1)
24
25#define MIIMIND_BUSY 0x00000001
26#define MIIMIND_NOTVALID 0x00000004
27
28#define GFAR_AN_TIMEOUT 2000
29
30/* 1000BT control (Marvell & BCM54xx at least) */
31#define MII_1000BASETCONTROL 0x09
32#define MII_1000BASETCONTROL_FULLDUPLEXCAP 0x0200
33#define MII_1000BASETCONTROL_HALFDUPLEXCAP 0x0100
34
35/* Cicada Extended Control Register 1 */
36#define MII_CIS8201_EXT_CON1 0x17
37#define MII_CIS8201_EXTCON1_INIT 0x0000
38
39/* Cicada Interrupt Mask Register */
40#define MII_CIS8201_IMASK 0x19
41#define MII_CIS8201_IMASK_IEN 0x8000
42#define MII_CIS8201_IMASK_SPEED 0x4000
43#define MII_CIS8201_IMASK_LINK 0x2000
44#define MII_CIS8201_IMASK_DUPLEX 0x1000
45#define MII_CIS8201_IMASK_MASK 0xf000
46
47/* Cicada Interrupt Status Register */
48#define MII_CIS8201_ISTAT 0x1a
49#define MII_CIS8201_ISTAT_STATUS 0x8000
50#define MII_CIS8201_ISTAT_SPEED 0x4000
51#define MII_CIS8201_ISTAT_LINK 0x2000
52#define MII_CIS8201_ISTAT_DUPLEX 0x1000
53
54/* Cicada Auxiliary Control/Status Register */
55#define MII_CIS8201_AUX_CONSTAT 0x1c
56#define MII_CIS8201_AUXCONSTAT_INIT 0x0004
57#define MII_CIS8201_AUXCONSTAT_DUPLEX 0x0020
58#define MII_CIS8201_AUXCONSTAT_SPEED 0x0018
59#define MII_CIS8201_AUXCONSTAT_GBIT 0x0010
60#define MII_CIS8201_AUXCONSTAT_100 0x0008
61
62/* 88E1011 PHY Status Register */
63#define MII_M1011_PHY_SPEC_STATUS 0x11
64#define MII_M1011_PHY_SPEC_STATUS_1000 0x8000
65#define MII_M1011_PHY_SPEC_STATUS_100 0x4000
66#define MII_M1011_PHY_SPEC_STATUS_SPD_MASK 0xc000
67#define MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX 0x2000
68#define MII_M1011_PHY_SPEC_STATUS_RESOLVED 0x0800
69#define MII_M1011_PHY_SPEC_STATUS_LINK 0x0400
70
71#define MII_M1011_IEVENT 0x13
72#define MII_M1011_IEVENT_CLEAR 0x0000
73
74#define MII_M1011_IMASK 0x12
75#define MII_M1011_IMASK_INIT 0x6400
76#define MII_M1011_IMASK_CLEAR 0x0000
77
78#define MII_DM9161_SCR 0x10
79#define MII_DM9161_SCR_INIT 0x0610
80
81/* DM9161 Specified Configuration and Status Register */
82#define MII_DM9161_SCSR 0x11
83#define MII_DM9161_SCSR_100F 0x8000
84#define MII_DM9161_SCSR_100H 0x4000
85#define MII_DM9161_SCSR_10F 0x2000
86#define MII_DM9161_SCSR_10H 0x1000
87
88/* DM9161 Interrupt Register */
89#define MII_DM9161_INTR 0x15
90#define MII_DM9161_INTR_PEND 0x8000
91#define MII_DM9161_INTR_DPLX_MASK 0x0800
92#define MII_DM9161_INTR_SPD_MASK 0x0400
93#define MII_DM9161_INTR_LINK_MASK 0x0200
94#define MII_DM9161_INTR_MASK 0x0100
95#define MII_DM9161_INTR_DPLX_CHANGE 0x0010
96#define MII_DM9161_INTR_SPD_CHANGE 0x0008
97#define MII_DM9161_INTR_LINK_CHANGE 0x0004
98#define MII_DM9161_INTR_INIT 0x0000
99#define MII_DM9161_INTR_STOP \
100(MII_DM9161_INTR_DPLX_MASK | MII_DM9161_INTR_SPD_MASK \
101 | MII_DM9161_INTR_LINK_MASK | MII_DM9161_INTR_MASK)
102
103/* DM9161 10BT Configuration/Status */
104#define MII_DM9161_10BTCSR 0x12
105#define MII_DM9161_10BTCSR_INIT 0x7800
106
107#define MII_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
108 SUPPORTED_10baseT_Full | \
109 SUPPORTED_100baseT_Half | \
110 SUPPORTED_100baseT_Full | \
111 SUPPORTED_Autoneg | \
112 SUPPORTED_TP | \
113 SUPPORTED_MII)
114
115#define MII_GBIT_FEATURES (MII_BASIC_FEATURES | \
116 SUPPORTED_1000baseT_Half | \
117 SUPPORTED_1000baseT_Full)
118
119#define MII_READ_COMMAND 0x00000001
120
121#define MII_INTERRUPT_DISABLED 0x0
122#define MII_INTERRUPT_ENABLED 0x1
123/* Taken from mii_if_info and sungem_phy.h */
124struct gfar_mii_info {
125 /* Information about the PHY type */
126 /* And management functions */
127 struct phy_info *phyinfo;
128
129 /* forced speed & duplex (no autoneg)
130 * partner speed & duplex & pause (autoneg)
131 */
132 int speed;
133 int duplex;
134 int pause;
135
136 /* The most recently read link state */
137 int link;
138
139 /* Enabled Interrupts */
140 u32 interrupts;
141
142 u32 advertising;
143 int autoneg;
144 int mii_id;
145
146 /* private data pointer */
147 /* For use by PHYs to maintain extra state */
148 void *priv;
149
150 /* Provided by host chip */
151 struct net_device *dev;
152
153 /* A lock to ensure that only one thing can read/write
154 * the MDIO bus at a time */
155 spinlock_t mdio_lock;
156
157 /* Provided by ethernet driver */
158 int (*mdio_read) (struct net_device *dev, int mii_id, int reg);
159 void (*mdio_write) (struct net_device *dev, int mii_id, int reg, int val);
160};
161
162/* struct phy_info: a structure which defines attributes for a PHY
163 *
164 * id will contain a number which represents the PHY. During
165 * startup, the driver will poll the PHY to find out what its
166 * UID--as defined by registers 2 and 3--is. The 32-bit result
167 * gotten from the PHY will be ANDed with phy_id_mask to
168 * discard any bits which may change based on revision numbers
169 * unimportant to functionality
170 *
171 * There are 6 commands which take a gfar_mii_info structure.
172 * Each PHY must declare config_aneg, and read_status.
173 */
174struct phy_info {
175 u32 phy_id;
176 char *name;
177 unsigned int phy_id_mask;
178 u32 features;
179
180 /* Called to initialize the PHY */
181 int (*init)(struct gfar_mii_info *mii_info);
182
183 /* Called to suspend the PHY for power */
184 int (*suspend)(struct gfar_mii_info *mii_info);
185
186 /* Reconfigures autonegotiation (or disables it) */
187 int (*config_aneg)(struct gfar_mii_info *mii_info);
188
189 /* Determines the negotiated speed and duplex */
190 int (*read_status)(struct gfar_mii_info *mii_info);
191
192 /* Clears any pending interrupts */
193 int (*ack_interrupt)(struct gfar_mii_info *mii_info);
194
195 /* Enables or disables interrupts */
196 int (*config_intr)(struct gfar_mii_info *mii_info);
197
198 /* Clears up any memory if needed */
199 void (*close)(struct gfar_mii_info *mii_info);
200};
201
202struct phy_info *get_phy_info(struct gfar_mii_info *mii_info);
203int read_phy_reg(struct net_device *dev, int mii_id, int regnum);
204void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value);
205void mii_clear_phy_interrupt(struct gfar_mii_info *mii_info);
206void mii_configure_phy_interrupt(struct gfar_mii_info *mii_info, u32 interrupts);
207
208struct dm9161_private {
209 struct timer_list timer;
210 int resetdone;
211};
212
213#endif /* GIANFAR_PHY_H */
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index de087cd609d9..896aa02000d7 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -1,6 +1,7 @@
1config MKISS 1config MKISS
2 tristate "Serial port KISS driver" 2 tristate "Serial port KISS driver"
3 depends on AX25 3 depends on AX25
4 select CRC16
4 ---help--- 5 ---help---
5 KISS is a protocol used for the exchange of data between a computer 6 KISS is a protocol used for the exchange of data between a computer
6 and a Terminal Node Controller (a small embedded system commonly 7 and a Terminal Node Controller (a small embedded system commonly
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 1756f0ed54cc..cb43a9d28774 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -144,7 +144,7 @@ static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev)
144{ 144{
145 struct bpqdev *bpq; 145 struct bpqdev *bpq;
146 146
147 list_for_each_entry(bpq, &bpq_devices, bpq_list) { 147 list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list) {
148 if (bpq->ethdev == dev) 148 if (bpq->ethdev == dev)
149 return bpq->axdev; 149 return bpq->axdev;
150 } 150 }
@@ -399,7 +399,7 @@ static void *bpq_seq_start(struct seq_file *seq, loff_t *pos)
399 if (*pos == 0) 399 if (*pos == 0)
400 return SEQ_START_TOKEN; 400 return SEQ_START_TOKEN;
401 401
402 list_for_each_entry(bpqdev, &bpq_devices, bpq_list) { 402 list_for_each_entry_rcu(bpqdev, &bpq_devices, bpq_list) {
403 if (i == *pos) 403 if (i == *pos)
404 return bpqdev; 404 return bpqdev;
405 } 405 }
@@ -418,7 +418,7 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos)
418 p = ((struct bpqdev *)v)->bpq_list.next; 418 p = ((struct bpqdev *)v)->bpq_list.next;
419 419
420 return (p == &bpq_devices) ? NULL 420 return (p == &bpq_devices) ? NULL
421 : list_entry(p, struct bpqdev, bpq_list); 421 : rcu_dereference(list_entry(p, struct bpqdev, bpq_list));
422} 422}
423 423
424static void bpq_seq_stop(struct seq_file *seq, void *v) 424static void bpq_seq_stop(struct seq_file *seq, void *v)
@@ -561,8 +561,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
561 if (!dev_is_ethdev(dev)) 561 if (!dev_is_ethdev(dev))
562 return NOTIFY_DONE; 562 return NOTIFY_DONE;
563 563
564 rcu_read_lock();
565
566 switch (event) { 564 switch (event) {
567 case NETDEV_UP: /* new ethernet device -> new BPQ interface */ 565 case NETDEV_UP: /* new ethernet device -> new BPQ interface */
568 if (bpq_get_ax25_dev(dev) == NULL) 566 if (bpq_get_ax25_dev(dev) == NULL)
@@ -581,7 +579,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
581 default: 579 default:
582 break; 580 break;
583 } 581 }
584 rcu_read_unlock();
585 582
586 return NOTIFY_DONE; 583 return NOTIFY_DONE;
587} 584}
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index d9fe64b46f4b..85d6dc005be0 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -14,13 +14,14 @@
14 * 14 *
15 * Copyright (C) Hans Alblas PE1AYX <hans@esrac.ele.tue.nl> 15 * Copyright (C) Hans Alblas PE1AYX <hans@esrac.ele.tue.nl>
16 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org> 16 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org>
17 * Copyright (C) 2004, 05 Thomas Osterried DL9SAU <thomas@x-berg.in-berlin.de>
17 */ 18 */
18
19#include <linux/config.h> 19#include <linux/config.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <asm/system.h> 21#include <asm/system.h>
22#include <linux/bitops.h> 22#include <linux/bitops.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/crc16.h>
24#include <linux/string.h> 25#include <linux/string.h>
25#include <linux/mm.h> 26#include <linux/mm.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
@@ -39,11 +40,6 @@
39 40
40#include <net/ax25.h> 41#include <net/ax25.h>
41 42
42#ifdef CONFIG_INET
43#include <linux/ip.h>
44#include <linux/tcp.h>
45#endif
46
47#define AX_MTU 236 43#define AX_MTU 236
48 44
49/* SLIP/KISS protocol characters. */ 45/* SLIP/KISS protocol characters. */
@@ -80,9 +76,13 @@ struct mkiss {
80 76
81 int mode; 77 int mode;
82 int crcmode; /* MW: for FlexNet, SMACK etc. */ 78 int crcmode; /* MW: for FlexNet, SMACK etc. */
83#define CRC_MODE_NONE 0 79 int crcauto; /* CRC auto mode */
84#define CRC_MODE_FLEX 1 80
85#define CRC_MODE_SMACK 2 81#define CRC_MODE_NONE 0
82#define CRC_MODE_FLEX 1
83#define CRC_MODE_SMACK 2
84#define CRC_MODE_FLEX_TEST 3
85#define CRC_MODE_SMACK_TEST 4
86 86
87 atomic_t refcnt; 87 atomic_t refcnt;
88 struct semaphore dead_sem; 88 struct semaphore dead_sem;
@@ -151,6 +151,21 @@ static int check_crc_flex(unsigned char *cp, int size)
151 return 0; 151 return 0;
152} 152}
153 153
154static int check_crc_16(unsigned char *cp, int size)
155{
156 unsigned short crc = 0x0000;
157
158 if (size < 3)
159 return -1;
160
161 crc = crc16(0, cp, size);
162
163 if (crc != 0x0000)
164 return -1;
165
166 return 0;
167}
168
154/* 169/*
155 * Standard encapsulation 170 * Standard encapsulation
156 */ 171 */
@@ -237,19 +252,42 @@ static void ax_bump(struct mkiss *ax)
237 252
238 spin_lock_bh(&ax->buflock); 253 spin_lock_bh(&ax->buflock);
239 if (ax->rbuff[0] > 0x0f) { 254 if (ax->rbuff[0] > 0x0f) {
240 if (ax->rbuff[0] & 0x20) { 255 if (ax->rbuff[0] & 0x80) {
241 ax->crcmode = CRC_MODE_FLEX; 256 if (check_crc_16(ax->rbuff, ax->rcount) < 0) {
257 ax->stats.rx_errors++;
258 spin_unlock_bh(&ax->buflock);
259
260 return;
261 }
262 if (ax->crcmode != CRC_MODE_SMACK && ax->crcauto) {
263 printk(KERN_INFO
264 "mkiss: %s: Switchting to crc-smack\n",
265 ax->dev->name);
266 ax->crcmode = CRC_MODE_SMACK;
267 }
268 ax->rcount -= 2;
269 *ax->rbuff &= ~0x80;
270 } else if (ax->rbuff[0] & 0x20) {
242 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) { 271 if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
243 ax->stats.rx_errors++; 272 ax->stats.rx_errors++;
273 spin_unlock_bh(&ax->buflock);
244 return; 274 return;
245 } 275 }
276 if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) {
277 printk(KERN_INFO
278 "mkiss: %s: Switchting to crc-flexnet\n",
279 ax->dev->name);
280 ax->crcmode = CRC_MODE_FLEX;
281 }
246 ax->rcount -= 2; 282 ax->rcount -= 2;
247 /* dl9sau bugfix: the trailling two bytes flexnet crc 283
248 * will not be passed to the kernel. thus we have 284 /*
249 * to correct the kissparm signature, because it 285 * dl9sau bugfix: the trailling two bytes flexnet crc
250 * indicates a crc but there's none 286 * will not be passed to the kernel. thus we have to
287 * correct the kissparm signature, because it indicates
288 * a crc but there's none
251 */ 289 */
252 *ax->rbuff &= ~0x20; 290 *ax->rbuff &= ~0x20;
253 } 291 }
254 } 292 }
255 spin_unlock_bh(&ax->buflock); 293 spin_unlock_bh(&ax->buflock);
@@ -417,20 +455,69 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
417 p = icp; 455 p = icp;
418 456
419 spin_lock_bh(&ax->buflock); 457 spin_lock_bh(&ax->buflock);
420 switch (ax->crcmode) { 458 if ((*p & 0x0f) != 0) {
421 unsigned short crc; 459 /* Configuration Command (kissparms(1).
460 * Protocol spec says: never append CRC.
461 * This fixes a very old bug in the linux
462 * kiss driver. -- dl9sau */
463 switch (*p & 0xff) {
464 case 0x85:
465 /* command from userspace especially for us,
466 * not for delivery to the tnc */
467 if (len > 1) {
468 int cmd = (p[1] & 0xff);
469 switch(cmd) {
470 case 3:
471 ax->crcmode = CRC_MODE_SMACK;
472 break;
473 case 2:
474 ax->crcmode = CRC_MODE_FLEX;
475 break;
476 case 1:
477 ax->crcmode = CRC_MODE_NONE;
478 break;
479 case 0:
480 default:
481 ax->crcmode = CRC_MODE_SMACK_TEST;
482 cmd = 0;
483 }
484 ax->crcauto = (cmd ? 0 : 1);
485 printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd);
486 }
487 spin_unlock_bh(&ax->buflock);
488 netif_start_queue(dev);
422 489
423 case CRC_MODE_FLEX: 490 return;
424 *p |= 0x20; 491 default:
425 crc = calc_crc_flex(p, len); 492 count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
426 count = kiss_esc_crc(p, (unsigned char *)ax->xbuff, crc, len+2); 493 }
427 break; 494 } else {
495 unsigned short crc;
496 switch (ax->crcmode) {
497 case CRC_MODE_SMACK_TEST:
498 ax->crcmode = CRC_MODE_FLEX_TEST;
499 printk(KERN_INFO "mkiss: %s: Trying crc-smack\n", ax->dev->name);
500 // fall through
501 case CRC_MODE_SMACK:
502 *p |= 0x80;
503 crc = swab16(crc16(0, p, len));
504 count = kiss_esc_crc(p, (unsigned char *)ax->xbuff, crc, len+2);
505 break;
506 case CRC_MODE_FLEX_TEST:
507 ax->crcmode = CRC_MODE_NONE;
508 printk(KERN_INFO "mkiss: %s: Trying crc-flexnet\n", ax->dev->name);
509 // fall through
510 case CRC_MODE_FLEX:
511 *p |= 0x20;
512 crc = calc_crc_flex(p, len);
513 count = kiss_esc_crc(p, (unsigned char *)ax->xbuff, crc, len+2);
514 break;
515
516 default:
517 count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
518 }
519 }
428 520
429 default:
430 count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
431 break;
432 }
433
434 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); 521 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
435 actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); 522 actual = ax->tty->driver->write(ax->tty, ax->xbuff, count);
436 ax->stats.tx_packets++; 523 ax->stats.tx_packets++;
@@ -439,8 +526,6 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
439 ax->dev->trans_start = jiffies; 526 ax->dev->trans_start = jiffies;
440 ax->xleft = count - actual; 527 ax->xleft = count - actual;
441 ax->xhead = ax->xbuff + actual; 528 ax->xhead = ax->xbuff + actual;
442
443 spin_unlock_bh(&ax->buflock);
444} 529}
445 530
446/* Encapsulate an AX.25 packet and kick it into a TTY queue. */ 531/* Encapsulate an AX.25 packet and kick it into a TTY queue. */
@@ -622,7 +707,7 @@ static void ax_setup(struct net_device *dev)
622 * best way to fix this is to use a rwlock in the tty struct, but for now we 707 * best way to fix this is to use a rwlock in the tty struct, but for now we
623 * use a single global rwlock for all ttys in ppp line discipline. 708 * use a single global rwlock for all ttys in ppp line discipline.
624 */ 709 */
625static rwlock_t disc_data_lock = RW_LOCK_UNLOCKED; 710static DEFINE_RWLOCK(disc_data_lock);
626 711
627static struct mkiss *mkiss_get(struct tty_struct *tty) 712static struct mkiss *mkiss_get(struct tty_struct *tty)
628{ 713{
@@ -643,6 +728,8 @@ static void mkiss_put(struct mkiss *ax)
643 up(&ax->dead_sem); 728 up(&ax->dead_sem);
644} 729}
645 730
731static int crc_force = 0; /* Can be overridden with insmod */
732
646static int mkiss_open(struct tty_struct *tty) 733static int mkiss_open(struct tty_struct *tty)
647{ 734{
648 struct net_device *dev; 735 struct net_device *dev;
@@ -682,6 +769,33 @@ static int mkiss_open(struct tty_struct *tty)
682 if (register_netdev(dev)) 769 if (register_netdev(dev))
683 goto out_free_buffers; 770 goto out_free_buffers;
684 771
772 /* after register_netdev() - because else printk smashes the kernel */
773 switch (crc_force) {
774 case 3:
775 ax->crcmode = CRC_MODE_SMACK;
776 printk(KERN_INFO "mkiss: %s: crc mode smack forced.\n",
777 ax->dev->name);
778 break;
779 case 2:
780 ax->crcmode = CRC_MODE_FLEX;
781 printk(KERN_INFO "mkiss: %s: crc mode flexnet forced.\n",
782 ax->dev->name);
783 break;
784 case 1:
785 ax->crcmode = CRC_MODE_NONE;
786 printk(KERN_INFO "mkiss: %s: crc mode disabled.\n",
787 ax->dev->name);
788 break;
789 case 0:
790 /* fall through */
791 default:
792 crc_force = 0;
793 printk(KERN_INFO "mkiss: %s: crc mode is auto.\n",
794 ax->dev->name);
795 ax->crcmode = CRC_MODE_SMACK_TEST;
796 }
797 ax->crcauto = (crc_force ? 0 : 1);
798
685 netif_start_queue(dev); 799 netif_start_queue(dev);
686 800
687 /* Done. We have linked the TTY line to a channel. */ 801 /* Done. We have linked the TTY line to a channel. */
@@ -765,7 +879,6 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
765 879
766 case SIOCSIFHWADDR: { 880 case SIOCSIFHWADDR: {
767 char addr[AX25_ADDR_LEN]; 881 char addr[AX25_ADDR_LEN];
768printk(KERN_INFO "In SIOCSIFHWADDR");
769 882
770 if (copy_from_user(&addr, 883 if (copy_from_user(&addr,
771 (void __user *) arg, AX25_ADDR_LEN)) { 884 (void __user *) arg, AX25_ADDR_LEN)) {
@@ -864,6 +977,7 @@ out:
864} 977}
865 978
866static struct tty_ldisc ax_ldisc = { 979static struct tty_ldisc ax_ldisc = {
980 .owner = THIS_MODULE,
867 .magic = TTY_LDISC_MAGIC, 981 .magic = TTY_LDISC_MAGIC,
868 .name = "mkiss", 982 .name = "mkiss",
869 .open = mkiss_open, 983 .open = mkiss_open,
@@ -904,6 +1018,8 @@ static void __exit mkiss_exit_driver(void)
904 1018
905MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>"); 1019MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
906MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs"); 1020MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs");
1021MODULE_PARM(crc_force, "i");
1022MODULE_PARM_DESC(crc_force, "crc [0 = auto | 1 = none | 2 = flexnet | 3 = smack]");
907MODULE_LICENSE("GPL"); 1023MODULE_LICENSE("GPL");
908MODULE_ALIAS_LDISC(N_AX25); 1024MODULE_ALIAS_LDISC(N_AX25);
909 1025
diff --git a/drivers/net/hamradio/mkiss.h b/drivers/net/hamradio/mkiss.h
deleted file mode 100644
index 4ab700478598..000000000000
--- a/drivers/net/hamradio/mkiss.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/****************************************************************************
2 * Defines for the Multi-KISS driver.
3 ****************************************************************************/
4
5#define AX25_MAXDEV 16 /* MAX number of AX25 channels;
6 This can be overridden with
7 insmod -oax25_maxdev=nnn */
8#define AX_MTU 236
9
10/* SLIP/KISS protocol characters. */
11#define END 0300 /* indicates end of frame */
12#define ESC 0333 /* indicates byte stuffing */
13#define ESC_END 0334 /* ESC ESC_END means END 'data' */
14#define ESC_ESC 0335 /* ESC ESC_ESC means ESC 'data' */
15
16struct ax_disp {
17 int magic;
18
19 /* Various fields. */
20 struct tty_struct *tty; /* ptr to TTY structure */
21 struct net_device *dev; /* easy for intr handling */
22
23 /* These are pointers to the malloc()ed frame buffers. */
24 unsigned char *rbuff; /* receiver buffer */
25 int rcount; /* received chars counter */
26 unsigned char *xbuff; /* transmitter buffer */
27 unsigned char *xhead; /* pointer to next byte to XMIT */
28 int xleft; /* bytes left in XMIT queue */
29
30 /* SLIP interface statistics. */
31 unsigned long rx_packets; /* inbound frames counter */
32 unsigned long tx_packets; /* outbound frames counter */
33 unsigned long rx_bytes; /* inbound bytes counter */
34 unsigned long tx_bytes; /* outbound bytes counter */
35 unsigned long rx_errors; /* Parity, etc. errors */
36 unsigned long tx_errors; /* Planned stuff */
37 unsigned long rx_dropped; /* No memory for skb */
38 unsigned long tx_dropped; /* When MTU change */
39 unsigned long rx_over_errors; /* Frame bigger then SLIP buf. */
40
41 /* Detailed SLIP statistics. */
42 int mtu; /* Our mtu (to spot changes!) */
43 int buffsize; /* Max buffers sizes */
44
45
46 unsigned long flags; /* Flag values/ mode etc */
47 /* long req'd: used by set_bit --RR */
48#define AXF_INUSE 0 /* Channel in use */
49#define AXF_ESCAPE 1 /* ESC received */
50#define AXF_ERROR 2 /* Parity, etc. error */
51#define AXF_KEEPTEST 3 /* Keepalive test flag */
52#define AXF_OUTWAIT 4 /* is outpacket was flag */
53
54 int mode;
55 int crcmode; /* MW: for FlexNet, SMACK etc. */
56#define CRC_MODE_NONE 0
57#define CRC_MODE_FLEX 1
58#define CRC_MODE_SMACK 2
59 spinlock_t buflock; /* lock for rbuf and xbuf */
60};
61
62#define AX25_MAGIC 0x5316
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index cf0ac6fda1a1..b71fab6e34f4 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -2517,10 +2517,8 @@ static int hp100_down_vg_link(struct net_device *dev)
2517 do { 2517 do {
2518 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) 2518 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST)
2519 break; 2519 break;
2520 if (!in_interrupt()) { 2520 if (!in_interrupt())
2521 set_current_state(TASK_INTERRUPTIBLE); 2521 schedule_timeout_interruptible(1);
2522 schedule_timeout(1);
2523 }
2524 } while (time_after(time, jiffies)); 2522 } while (time_after(time, jiffies));
2525 2523
2526 if (time_after_eq(jiffies, time)) /* no signal->no logout */ 2524 if (time_after_eq(jiffies, time)) /* no signal->no logout */
@@ -2536,10 +2534,8 @@ static int hp100_down_vg_link(struct net_device *dev)
2536 do { 2534 do {
2537 if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) 2535 if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST))
2538 break; 2536 break;
2539 if (!in_interrupt()) { 2537 if (!in_interrupt())
2540 set_current_state(TASK_INTERRUPTIBLE); 2538 schedule_timeout_interruptible(1);
2541 schedule_timeout(1);
2542 }
2543 } while (time_after(time, jiffies)); 2539 } while (time_after(time, jiffies));
2544 2540
2545#ifdef HP100_DEBUG 2541#ifdef HP100_DEBUG
@@ -2577,10 +2573,8 @@ static int hp100_down_vg_link(struct net_device *dev)
2577 do { 2573 do {
2578 if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST)) 2574 if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST))
2579 break; 2575 break;
2580 if (!in_interrupt()) { 2576 if (!in_interrupt())
2581 set_current_state(TASK_INTERRUPTIBLE); 2577 schedule_timeout_interruptible(1);
2582 schedule_timeout(1);
2583 }
2584 } while (time_after(time, jiffies)); 2578 } while (time_after(time, jiffies));
2585 2579
2586 hp100_orb(HP100_AUTO_MODE, MAC_CFG_3); /* Autosel back on */ 2580 hp100_orb(HP100_AUTO_MODE, MAC_CFG_3); /* Autosel back on */
@@ -2591,10 +2585,8 @@ static int hp100_down_vg_link(struct net_device *dev)
2591 do { 2585 do {
2592 if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0) 2586 if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0)
2593 break; 2587 break;
2594 if (!in_interrupt()) { 2588 if (!in_interrupt())
2595 set_current_state(TASK_INTERRUPTIBLE); 2589 schedule_timeout_interruptible(1);
2596 schedule_timeout(1);
2597 }
2598 } while (time_after(time, jiffies)); 2590 } while (time_after(time, jiffies));
2599 2591
2600 if (time_before_eq(time, jiffies)) { 2592 if (time_before_eq(time, jiffies)) {
@@ -2606,10 +2598,8 @@ static int hp100_down_vg_link(struct net_device *dev)
2606 2598
2607 time = jiffies + (2 * HZ); /* This seems to take a while.... */ 2599 time = jiffies + (2 * HZ); /* This seems to take a while.... */
2608 do { 2600 do {
2609 if (!in_interrupt()) { 2601 if (!in_interrupt())
2610 set_current_state(TASK_INTERRUPTIBLE); 2602 schedule_timeout_interruptible(1);
2611 schedule_timeout(1);
2612 }
2613 } while (time_after(time, jiffies)); 2603 } while (time_after(time, jiffies));
2614 2604
2615 return 0; 2605 return 0;
@@ -2659,10 +2649,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
2659 do { 2649 do {
2660 if (~(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) 2650 if (~(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST))
2661 break; 2651 break;
2662 if (!in_interrupt()) { 2652 if (!in_interrupt())
2663 set_current_state(TASK_INTERRUPTIBLE); 2653 schedule_timeout_interruptible(1);
2664 schedule_timeout(1);
2665 }
2666 } while (time_after(time, jiffies)); 2654 } while (time_after(time, jiffies));
2667 2655
2668 /* Start an addressed training and optionally request promiscuous port */ 2656 /* Start an addressed training and optionally request promiscuous port */
@@ -2697,10 +2685,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
2697 do { 2685 do {
2698 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) 2686 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST)
2699 break; 2687 break;
2700 if (!in_interrupt()) { 2688 if (!in_interrupt())
2701 set_current_state(TASK_INTERRUPTIBLE); 2689 schedule_timeout_interruptible(1);
2702 schedule_timeout(1);
2703 }
2704 } while (time_before(jiffies, time)); 2690 } while (time_before(jiffies, time));
2705 2691
2706 if (time_after_eq(jiffies, time)) { 2692 if (time_after_eq(jiffies, time)) {
@@ -2723,10 +2709,8 @@ static int hp100_login_to_vg_hub(struct net_device *dev, u_short force_relogin)
2723#endif 2709#endif
2724 break; 2710 break;
2725 } 2711 }
2726 if (!in_interrupt()) { 2712 if (!in_interrupt())
2727 set_current_state(TASK_INTERRUPTIBLE); 2713 schedule_timeout_interruptible(1);
2728 schedule_timeout(1);
2729 }
2730 } while (time_after(time, jiffies)); 2714 } while (time_after(time, jiffies));
2731 } 2715 }
2732 2716
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index ca5914091d3a..d54156f11e61 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -400,5 +400,15 @@ config VIA_FIR
400 To compile it as a module, choose M here: the module will be called 400 To compile it as a module, choose M here: the module will be called
401 via-ircc. 401 via-ircc.
402 402
403config PXA_FICP
404 tristate "Intel PXA2xx Internal FICP"
405 depends on ARCH_PXA && IRDA
406 help
407 Say Y or M here if you want to build support for the PXA2xx
408 built-in IRDA interface which can support both SIR and FIR.
409 This driver relies on platform specific helper routines so
410 available capabilities may vary from one PXA2xx target to
411 another.
412
403endmenu 413endmenu
404 414
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 29a8bd812b21..e7a8b7f7f5dd 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_SMC_IRCC_FIR) += smsc-ircc2.o
18obj-$(CONFIG_ALI_FIR) += ali-ircc.o 18obj-$(CONFIG_ALI_FIR) += ali-ircc.o
19obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o 19obj-$(CONFIG_VLSI_FIR) += vlsi_ir.o
20obj-$(CONFIG_VIA_FIR) += via-ircc.o 20obj-$(CONFIG_VIA_FIR) += via-ircc.o
21obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o
21# Old dongle drivers for old SIR drivers 22# Old dongle drivers for old SIR drivers
22obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o 23obj-$(CONFIG_ESI_DONGLE_OLD) += esi.o
23obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o 24obj-$(CONFIG_TEKRAM_DONGLE_OLD) += tekram.o
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
new file mode 100644
index 000000000000..aef80f5e7c9c
--- /dev/null
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -0,0 +1,871 @@
1/*
2 * linux/drivers/net/irda/pxaficp_ir.c
3 *
4 * Based on sa1100_ir.c by Russell King
5 *
6 * Changes copyright (C) 2003-2005 MontaVista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Infra-red driver (SIR/FIR) for the PXA2xx embedded microprocessor
13 *
14 */
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/netdevice.h>
21#include <linux/slab.h>
22#include <linux/rtnetlink.h>
23#include <linux/interrupt.h>
24#include <linux/dma-mapping.h>
25#include <linux/pm.h>
26
27#include <net/irda/irda.h>
28#include <net/irda/irmod.h>
29#include <net/irda/wrapper.h>
30#include <net/irda/irda_device.h>
31
32#include <asm/irq.h>
33#include <asm/dma.h>
34#include <asm/delay.h>
35#include <asm/hardware.h>
36#include <asm/arch/irda.h>
37#include <asm/arch/pxa-regs.h>
38
39#ifdef CONFIG_MACH_MAINSTONE
40#include <asm/arch/mainstone.h>
41#endif
42
43#define IrSR_RXPL_NEG_IS_ZERO (1<<4)
44#define IrSR_RXPL_POS_IS_ZERO 0x0
45#define IrSR_TXPL_NEG_IS_ZERO (1<<3)
46#define IrSR_TXPL_POS_IS_ZERO 0x0
47#define IrSR_XMODE_PULSE_1_6 (1<<2)
48#define IrSR_XMODE_PULSE_3_16 0x0
49#define IrSR_RCVEIR_IR_MODE (1<<1)
50#define IrSR_RCVEIR_UART_MODE 0x0
51#define IrSR_XMITIR_IR_MODE (1<<0)
52#define IrSR_XMITIR_UART_MODE 0x0
53
54#define IrSR_IR_RECEIVE_ON (\
55 IrSR_RXPL_NEG_IS_ZERO | \
56 IrSR_TXPL_POS_IS_ZERO | \
57 IrSR_XMODE_PULSE_3_16 | \
58 IrSR_RCVEIR_IR_MODE | \
59 IrSR_XMITIR_UART_MODE)
60
61#define IrSR_IR_TRANSMIT_ON (\
62 IrSR_RXPL_NEG_IS_ZERO | \
63 IrSR_TXPL_POS_IS_ZERO | \
64 IrSR_XMODE_PULSE_3_16 | \
65 IrSR_RCVEIR_UART_MODE | \
66 IrSR_XMITIR_IR_MODE)
67
68struct pxa_irda {
69 int speed;
70 int newspeed;
71 unsigned long last_oscr;
72
73 unsigned char *dma_rx_buff;
74 unsigned char *dma_tx_buff;
75 dma_addr_t dma_rx_buff_phy;
76 dma_addr_t dma_tx_buff_phy;
77 unsigned int dma_tx_buff_len;
78 int txdma;
79 int rxdma;
80
81 struct net_device_stats stats;
82 struct irlap_cb *irlap;
83 struct qos_info qos;
84
85 iobuff_t tx_buff;
86 iobuff_t rx_buff;
87
88 struct device *dev;
89 struct pxaficp_platform_data *pdata;
90};
91
92
93#define IS_FIR(si) ((si)->speed >= 4000000)
94#define IRDA_FRAME_SIZE_LIMIT 2047
95
96inline static void pxa_irda_fir_dma_rx_start(struct pxa_irda *si)
97{
98 DCSR(si->rxdma) = DCSR_NODESC;
99 DSADR(si->rxdma) = __PREG(ICDR);
100 DTADR(si->rxdma) = si->dma_rx_buff_phy;
101 DCMD(si->rxdma) = DCMD_INCTRGADDR | DCMD_FLOWSRC | DCMD_WIDTH1 | DCMD_BURST32 | IRDA_FRAME_SIZE_LIMIT;
102 DCSR(si->rxdma) |= DCSR_RUN;
103}
104
105inline static void pxa_irda_fir_dma_tx_start(struct pxa_irda *si)
106{
107 DCSR(si->txdma) = DCSR_NODESC;
108 DSADR(si->txdma) = si->dma_tx_buff_phy;
109 DTADR(si->txdma) = __PREG(ICDR);
110 DCMD(si->txdma) = DCMD_INCSRCADDR | DCMD_FLOWTRG | DCMD_ENDIRQEN | DCMD_WIDTH1 | DCMD_BURST32 | si->dma_tx_buff_len;
111 DCSR(si->txdma) |= DCSR_RUN;
112}
113
114/*
115 * Set the IrDA communications speed.
116 */
117static int pxa_irda_set_speed(struct pxa_irda *si, int speed)
118{
119 unsigned long flags;
120 unsigned int divisor;
121
122 switch (speed) {
123 case 9600: case 19200: case 38400:
124 case 57600: case 115200:
125
126 /* refer to PXA250/210 Developer's Manual 10-7 */
127 /* BaudRate = 14.7456 MHz / (16*Divisor) */
128 divisor = 14745600 / (16 * speed);
129
130 local_irq_save(flags);
131
132 if (IS_FIR(si)) {
133 /* stop RX DMA */
134 DCSR(si->rxdma) &= ~DCSR_RUN;
135 /* disable FICP */
136 ICCR0 = 0;
137 pxa_set_cken(CKEN13_FICP, 0);
138
139 /* set board transceiver to SIR mode */
140 si->pdata->transceiver_mode(si->dev, IR_SIRMODE);
141
142 /* configure GPIO46/47 */
143 pxa_gpio_mode(GPIO46_STRXD_MD);
144 pxa_gpio_mode(GPIO47_STTXD_MD);
145
146 /* enable the STUART clock */
147 pxa_set_cken(CKEN5_STUART, 1);
148 }
149
150 /* disable STUART first */
151 STIER = 0;
152
153 /* access DLL & DLH */
154 STLCR |= LCR_DLAB;
155 STDLL = divisor & 0xff;
156 STDLH = divisor >> 8;
157 STLCR &= ~LCR_DLAB;
158
159 si->speed = speed;
160 STISR = IrSR_IR_RECEIVE_ON | IrSR_XMODE_PULSE_1_6;
161 STIER = IER_UUE | IER_RLSE | IER_RAVIE | IER_RTIOE;
162
163 local_irq_restore(flags);
164 break;
165
166 case 4000000:
167 local_irq_save(flags);
168
169 /* disable STUART */
170 STIER = 0;
171 STISR = 0;
172 pxa_set_cken(CKEN5_STUART, 0);
173
174 /* disable FICP first */
175 ICCR0 = 0;
176
177 /* set board transceiver to FIR mode */
178 si->pdata->transceiver_mode(si->dev, IR_FIRMODE);
179
180 /* configure GPIO46/47 */
181 pxa_gpio_mode(GPIO46_ICPRXD_MD);
182 pxa_gpio_mode(GPIO47_ICPTXD_MD);
183
184 /* enable the FICP clock */
185 pxa_set_cken(CKEN13_FICP, 1);
186
187 si->speed = speed;
188 pxa_irda_fir_dma_rx_start(si);
189 ICCR0 = ICCR0_ITR | ICCR0_RXE;
190
191 local_irq_restore(flags);
192 break;
193
194 default:
195 return -EINVAL;
196 }
197
198 return 0;
199}
200
201/* SIR interrupt service routine. */
202static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id, struct pt_regs *regs)
203{
204 struct net_device *dev = dev_id;
205 struct pxa_irda *si = netdev_priv(dev);
206 int iir, lsr, data;
207
208 iir = STIIR;
209
210 switch (iir & 0x0F) {
211 case 0x06: /* Receiver Line Status */
212 lsr = STLSR;
213 while (lsr & LSR_FIFOE) {
214 data = STRBR;
215 if (lsr & (LSR_OE | LSR_PE | LSR_FE | LSR_BI)) {
216 printk(KERN_DEBUG "pxa_ir: sir receiving error\n");
217 si->stats.rx_errors++;
218 if (lsr & LSR_FE)
219 si->stats.rx_frame_errors++;
220 if (lsr & LSR_OE)
221 si->stats.rx_fifo_errors++;
222 } else {
223 si->stats.rx_bytes++;
224 async_unwrap_char(dev, &si->stats, &si->rx_buff, data);
225 }
226 lsr = STLSR;
227 }
228 dev->last_rx = jiffies;
229 si->last_oscr = OSCR;
230 break;
231
232 case 0x04: /* Received Data Available */
233 /* forth through */
234
235 case 0x0C: /* Character Timeout Indication */
236 do {
237 si->stats.rx_bytes++;
238 async_unwrap_char(dev, &si->stats, &si->rx_buff, STRBR);
239 } while (STLSR & LSR_DR);
240 dev->last_rx = jiffies;
241 si->last_oscr = OSCR;
242 break;
243
244 case 0x02: /* Transmit FIFO Data Request */
245 while ((si->tx_buff.len) && (STLSR & LSR_TDRQ)) {
246 STTHR = *si->tx_buff.data++;
247 si->tx_buff.len -= 1;
248 }
249
250 if (si->tx_buff.len == 0) {
251 si->stats.tx_packets++;
252 si->stats.tx_bytes += si->tx_buff.data -
253 si->tx_buff.head;
254
255 /* We need to ensure that the transmitter has finished. */
256 while ((STLSR & LSR_TEMT) == 0)
257 cpu_relax();
258 si->last_oscr = OSCR;
259
260 /*
261 * Ok, we've finished transmitting. Now enable
262 * the receiver. Sometimes we get a receive IRQ
263 * immediately after a transmit...
264 */
265 if (si->newspeed) {
266 pxa_irda_set_speed(si, si->newspeed);
267 si->newspeed = 0;
268 } else {
269 /* enable IR Receiver, disable IR Transmitter */
270 STISR = IrSR_IR_RECEIVE_ON | IrSR_XMODE_PULSE_1_6;
271 /* enable STUART and receive interrupts */
272 STIER = IER_UUE | IER_RLSE | IER_RAVIE | IER_RTIOE;
273 }
274 /* I'm hungry! */
275 netif_wake_queue(dev);
276 }
277 break;
278 }
279
280 return IRQ_HANDLED;
281}
282
283/* FIR Receive DMA interrupt handler */
284static void pxa_irda_fir_dma_rx_irq(int channel, void *data, struct pt_regs *regs)
285{
286 int dcsr = DCSR(channel);
287
288 DCSR(channel) = dcsr & ~DCSR_RUN;
289
290 printk(KERN_DEBUG "pxa_ir: fir rx dma bus error %#x\n", dcsr);
291}
292
293/* FIR Transmit DMA interrupt handler */
294static void pxa_irda_fir_dma_tx_irq(int channel, void *data, struct pt_regs *regs)
295{
296 struct net_device *dev = data;
297 struct pxa_irda *si = netdev_priv(dev);
298 int dcsr;
299
300 dcsr = DCSR(channel);
301 DCSR(channel) = dcsr & ~DCSR_RUN;
302
303 if (dcsr & DCSR_ENDINTR) {
304 si->stats.tx_packets++;
305 si->stats.tx_bytes += si->dma_tx_buff_len;
306 } else {
307 si->stats.tx_errors++;
308 }
309
310 while (ICSR1 & ICSR1_TBY)
311 cpu_relax();
312 si->last_oscr = OSCR;
313
314 /*
315 * HACK: It looks like the TBY bit is dropped too soon.
316 * Without this delay things break.
317 */
318 udelay(120);
319
320 if (si->newspeed) {
321 pxa_irda_set_speed(si, si->newspeed);
322 si->newspeed = 0;
323 } else {
324 ICCR0 = 0;
325 pxa_irda_fir_dma_rx_start(si);
326 ICCR0 = ICCR0_ITR | ICCR0_RXE;
327 }
328 netif_wake_queue(dev);
329}
330
331/* EIF(Error in FIFO/End in Frame) handler for FIR */
332static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev)
333{
334 unsigned int len, stat, data;
335
336 /* Get the current data position. */
337 len = DTADR(si->rxdma) - si->dma_rx_buff_phy;
338
339 do {
340 /* Read Status, and then Data. */
341 stat = ICSR1;
342 rmb();
343 data = ICDR;
344
345 if (stat & (ICSR1_CRE | ICSR1_ROR)) {
346 si->stats.rx_errors++;
347 if (stat & ICSR1_CRE) {
348 printk(KERN_DEBUG "pxa_ir: fir receive CRC error\n");
349 si->stats.rx_crc_errors++;
350 }
351 if (stat & ICSR1_ROR) {
352 printk(KERN_DEBUG "pxa_ir: fir receive overrun\n");
353 si->stats.rx_frame_errors++;
354 }
355 } else {
356 si->dma_rx_buff[len++] = data;
357 }
358 /* If we hit the end of frame, there's no point in continuing. */
359 if (stat & ICSR1_EOF)
360 break;
361 } while (ICSR0 & ICSR0_EIF);
362
363 if (stat & ICSR1_EOF) {
364 /* end of frame. */
365 struct sk_buff *skb = alloc_skb(len+1,GFP_ATOMIC);
366 if (!skb) {
367 printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n");
368 si->stats.rx_dropped++;
369 return;
370 }
371
372 /* Align IP header to 20 bytes */
373 skb_reserve(skb, 1);
374 memcpy(skb->data, si->dma_rx_buff, len);
375 skb_put(skb, len);
376
377 /* Feed it to IrLAP */
378 skb->dev = dev;
379 skb->mac.raw = skb->data;
380 skb->protocol = htons(ETH_P_IRDA);
381 netif_rx(skb);
382
383 si->stats.rx_packets++;
384 si->stats.rx_bytes += len;
385
386 dev->last_rx = jiffies;
387 }
388}
389
390/* FIR interrupt handler */
391static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id, struct pt_regs *regs)
392{
393 struct net_device *dev = dev_id;
394 struct pxa_irda *si = netdev_priv(dev);
395 int icsr0;
396
397 /* stop RX DMA */
398 DCSR(si->rxdma) &= ~DCSR_RUN;
399 si->last_oscr = OSCR;
400 icsr0 = ICSR0;
401
402 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) {
403 if (icsr0 & ICSR0_FRE) {
404 printk(KERN_DEBUG "pxa_ir: fir receive frame error\n");
405 si->stats.rx_frame_errors++;
406 } else {
407 printk(KERN_DEBUG "pxa_ir: fir receive abort\n");
408 si->stats.rx_errors++;
409 }
410 ICSR0 = icsr0 & (ICSR0_FRE | ICSR0_RAB);
411 }
412
413 if (icsr0 & ICSR0_EIF) {
414 /* An error in FIFO occured, or there is a end of frame */
415 pxa_irda_fir_irq_eif(si, dev);
416 }
417
418 ICCR0 = 0;
419 pxa_irda_fir_dma_rx_start(si);
420 ICCR0 = ICCR0_ITR | ICCR0_RXE;
421
422 return IRQ_HANDLED;
423}
424
425/* hard_xmit interface of irda device */
426static int pxa_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
427{
428 struct pxa_irda *si = netdev_priv(dev);
429 int speed = irda_get_next_speed(skb);
430
431 /*
432 * Does this packet contain a request to change the interface
433 * speed? If so, remember it until we complete the transmission
434 * of this frame.
435 */
436 if (speed != si->speed && speed != -1)
437 si->newspeed = speed;
438
439 /*
440 * If this is an empty frame, we can bypass a lot.
441 */
442 if (skb->len == 0) {
443 if (si->newspeed) {
444 si->newspeed = 0;
445 pxa_irda_set_speed(si, speed);
446 }
447 dev_kfree_skb(skb);
448 return 0;
449 }
450
451 netif_stop_queue(dev);
452
453 if (!IS_FIR(si)) {
454 si->tx_buff.data = si->tx_buff.head;
455 si->tx_buff.len = async_wrap_skb(skb, si->tx_buff.data, si->tx_buff.truesize);
456
457 /* Disable STUART interrupts and switch to transmit mode. */
458 STIER = 0;
459 STISR = IrSR_IR_TRANSMIT_ON | IrSR_XMODE_PULSE_1_6;
460
461 /* enable STUART and transmit interrupts */
462 STIER = IER_UUE | IER_TIE;
463 } else {
464 unsigned long mtt = irda_get_mtt(skb);
465
466 si->dma_tx_buff_len = skb->len;
467 memcpy(si->dma_tx_buff, skb->data, skb->len);
468
469 if (mtt)
470 while ((unsigned)(OSCR - si->last_oscr)/4 < mtt)
471 cpu_relax();
472
473 /* stop RX DMA, disable FICP */
474 DCSR(si->rxdma) &= ~DCSR_RUN;
475 ICCR0 = 0;
476
477 pxa_irda_fir_dma_tx_start(si);
478 ICCR0 = ICCR0_ITR | ICCR0_TXE;
479 }
480
481 dev_kfree_skb(skb);
482 dev->trans_start = jiffies;
483 return 0;
484}
485
486static int pxa_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
487{
488 struct if_irda_req *rq = (struct if_irda_req *)ifreq;
489 struct pxa_irda *si = netdev_priv(dev);
490 int ret;
491
492 switch (cmd) {
493 case SIOCSBANDWIDTH:
494 ret = -EPERM;
495 if (capable(CAP_NET_ADMIN)) {
496 /*
497 * We are unable to set the speed if the
498 * device is not running.
499 */
500 if (netif_running(dev)) {
501 ret = pxa_irda_set_speed(si,
502 rq->ifr_baudrate);
503 } else {
504 printk(KERN_INFO "pxa_ir: SIOCSBANDWIDTH: !netif_running\n");
505 ret = 0;
506 }
507 }
508 break;
509
510 case SIOCSMEDIABUSY:
511 ret = -EPERM;
512 if (capable(CAP_NET_ADMIN)) {
513 irda_device_set_media_busy(dev, TRUE);
514 ret = 0;
515 }
516 break;
517
518 case SIOCGRECEIVING:
519 ret = 0;
520 rq->ifr_receiving = IS_FIR(si) ? 0
521 : si->rx_buff.state != OUTSIDE_FRAME;
522 break;
523
524 default:
525 ret = -EOPNOTSUPP;
526 break;
527 }
528
529 return ret;
530}
531
532static struct net_device_stats *pxa_irda_stats(struct net_device *dev)
533{
534 struct pxa_irda *si = netdev_priv(dev);
535 return &si->stats;
536}
537
538static void pxa_irda_startup(struct pxa_irda *si)
539{
540 /* Disable STUART interrupts */
541 STIER = 0;
542 /* enable STUART interrupt to the processor */
543 STMCR = MCR_OUT2;
544 /* configure SIR frame format: StartBit - Data 7 ... Data 0 - Stop Bit */
545 STLCR = LCR_WLS0 | LCR_WLS1;
546 /* enable FIFO, we use FIFO to improve performance */
547 STFCR = FCR_TRFIFOE | FCR_ITL_32;
548
549 /* disable FICP */
550 ICCR0 = 0;
551 /* configure FICP ICCR2 */
552 ICCR2 = ICCR2_TXP | ICCR2_TRIG_32;
553
554 /* configure DMAC */
555 DRCMR17 = si->rxdma | DRCMR_MAPVLD;
556 DRCMR18 = si->txdma | DRCMR_MAPVLD;
557
558 /* force SIR reinitialization */
559 si->speed = 4000000;
560 pxa_irda_set_speed(si, 9600);
561
562 printk(KERN_DEBUG "pxa_ir: irda startup\n");
563}
564
565static void pxa_irda_shutdown(struct pxa_irda *si)
566{
567 unsigned long flags;
568
569 local_irq_save(flags);
570
571 /* disable STUART and interrupt */
572 STIER = 0;
573 /* disable STUART SIR mode */
574 STISR = 0;
575 /* disable the STUART clock */
576 pxa_set_cken(CKEN5_STUART, 0);
577
578 /* disable DMA */
579 DCSR(si->txdma) &= ~DCSR_RUN;
580 DCSR(si->rxdma) &= ~DCSR_RUN;
581 /* disable FICP */
582 ICCR0 = 0;
583 /* disable the FICP clock */
584 pxa_set_cken(CKEN13_FICP, 0);
585
586 DRCMR17 = 0;
587 DRCMR18 = 0;
588
589 local_irq_restore(flags);
590
591 /* power off board transceiver */
592 si->pdata->transceiver_mode(si->dev, IR_OFF);
593
594 printk(KERN_DEBUG "pxa_ir: irda shutdown\n");
595}
596
597static int pxa_irda_start(struct net_device *dev)
598{
599 struct pxa_irda *si = netdev_priv(dev);
600 int err;
601
602 si->speed = 9600;
603
604 err = request_irq(IRQ_STUART, pxa_irda_sir_irq, 0, dev->name, dev);
605 if (err)
606 goto err_irq1;
607
608 err = request_irq(IRQ_ICP, pxa_irda_fir_irq, 0, dev->name, dev);
609 if (err)
610 goto err_irq2;
611
612 /*
613 * The interrupt must remain disabled for now.
614 */
615 disable_irq(IRQ_STUART);
616 disable_irq(IRQ_ICP);
617
618 err = -EBUSY;
619 si->rxdma = pxa_request_dma("FICP_RX",DMA_PRIO_LOW, pxa_irda_fir_dma_rx_irq, dev);
620 if (si->rxdma < 0)
621 goto err_rx_dma;
622
623 si->txdma = pxa_request_dma("FICP_TX",DMA_PRIO_LOW, pxa_irda_fir_dma_tx_irq, dev);
624 if (si->txdma < 0)
625 goto err_tx_dma;
626
627 err = -ENOMEM;
628 si->dma_rx_buff = dma_alloc_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT,
629 &si->dma_rx_buff_phy, GFP_KERNEL );
630 if (!si->dma_rx_buff)
631 goto err_dma_rx_buff;
632
633 si->dma_tx_buff = dma_alloc_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT,
634 &si->dma_tx_buff_phy, GFP_KERNEL );
635 if (!si->dma_tx_buff)
636 goto err_dma_tx_buff;
637
638 /* Setup the serial port for the initial speed. */
639 pxa_irda_startup(si);
640
641 /*
642 * Open a new IrLAP layer instance.
643 */
644 si->irlap = irlap_open(dev, &si->qos, "pxa");
645 err = -ENOMEM;
646 if (!si->irlap)
647 goto err_irlap;
648
649 /*
650 * Now enable the interrupt and start the queue
651 */
652 enable_irq(IRQ_STUART);
653 enable_irq(IRQ_ICP);
654 netif_start_queue(dev);
655
656 printk(KERN_DEBUG "pxa_ir: irda driver opened\n");
657
658 return 0;
659
660err_irlap:
661 pxa_irda_shutdown(si);
662 dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_tx_buff, si->dma_tx_buff_phy);
663err_dma_tx_buff:
664 dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_rx_buff, si->dma_rx_buff_phy);
665err_dma_rx_buff:
666 pxa_free_dma(si->txdma);
667err_tx_dma:
668 pxa_free_dma(si->rxdma);
669err_rx_dma:
670 free_irq(IRQ_ICP, dev);
671err_irq2:
672 free_irq(IRQ_STUART, dev);
673err_irq1:
674
675 return err;
676}
677
678static int pxa_irda_stop(struct net_device *dev)
679{
680 struct pxa_irda *si = netdev_priv(dev);
681
682 netif_stop_queue(dev);
683
684 pxa_irda_shutdown(si);
685
686 /* Stop IrLAP */
687 if (si->irlap) {
688 irlap_close(si->irlap);
689 si->irlap = NULL;
690 }
691
692 free_irq(IRQ_STUART, dev);
693 free_irq(IRQ_ICP, dev);
694
695 pxa_free_dma(si->rxdma);
696 pxa_free_dma(si->txdma);
697
698 if (si->dma_rx_buff)
699 dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_tx_buff, si->dma_tx_buff_phy);
700 if (si->dma_tx_buff)
701 dma_free_coherent(si->dev, IRDA_FRAME_SIZE_LIMIT, si->dma_rx_buff, si->dma_rx_buff_phy);
702
703 printk(KERN_DEBUG "pxa_ir: irda driver closed\n");
704 return 0;
705}
706
707static int pxa_irda_suspend(struct device *_dev, pm_message_t state, u32 level)
708{
709 struct net_device *dev = dev_get_drvdata(_dev);
710 struct pxa_irda *si;
711
712 if (!dev || level != SUSPEND_DISABLE)
713 return 0;
714
715 if (netif_running(dev)) {
716 si = netdev_priv(dev);
717 netif_device_detach(dev);
718 pxa_irda_shutdown(si);
719 }
720
721 return 0;
722}
723
724static int pxa_irda_resume(struct device *_dev, u32 level)
725{
726 struct net_device *dev = dev_get_drvdata(_dev);
727 struct pxa_irda *si;
728
729 if (!dev || level != RESUME_ENABLE)
730 return 0;
731
732 if (netif_running(dev)) {
733 si = netdev_priv(dev);
734 pxa_irda_startup(si);
735 netif_device_attach(dev);
736 netif_wake_queue(dev);
737 }
738
739 return 0;
740}
741
742
743static int pxa_irda_init_iobuf(iobuff_t *io, int size)
744{
745 io->head = kmalloc(size, GFP_KERNEL | GFP_DMA);
746 if (io->head != NULL) {
747 io->truesize = size;
748 io->in_frame = FALSE;
749 io->state = OUTSIDE_FRAME;
750 io->data = io->head;
751 }
752 return io->head ? 0 : -ENOMEM;
753}
754
755static int pxa_irda_probe(struct device *_dev)
756{
757 struct platform_device *pdev = to_platform_device(_dev);
758 struct net_device *dev;
759 struct pxa_irda *si;
760 unsigned int baudrate_mask;
761 int err;
762
763 if (!pdev->dev.platform_data)
764 return -ENODEV;
765
766 err = request_mem_region(__PREG(STUART), 0x24, "IrDA") ? 0 : -EBUSY;
767 if (err)
768 goto err_mem_1;
769
770 err = request_mem_region(__PREG(FICP), 0x1c, "IrDA") ? 0 : -EBUSY;
771 if (err)
772 goto err_mem_2;
773
774 dev = alloc_irdadev(sizeof(struct pxa_irda));
775 if (!dev)
776 goto err_mem_3;
777
778 si = netdev_priv(dev);
779 si->dev = &pdev->dev;
780 si->pdata = pdev->dev.platform_data;
781
782 /*
783 * Initialise the SIR buffers
784 */
785 err = pxa_irda_init_iobuf(&si->rx_buff, 14384);
786 if (err)
787 goto err_mem_4;
788 err = pxa_irda_init_iobuf(&si->tx_buff, 4000);
789 if (err)
790 goto err_mem_5;
791
792 dev->hard_start_xmit = pxa_irda_hard_xmit;
793 dev->open = pxa_irda_start;
794 dev->stop = pxa_irda_stop;
795 dev->do_ioctl = pxa_irda_ioctl;
796 dev->get_stats = pxa_irda_stats;
797
798 irda_init_max_qos_capabilies(&si->qos);
799
800 baudrate_mask = 0;
801 if (si->pdata->transceiver_cap & IR_SIRMODE)
802 baudrate_mask |= IR_9600|IR_19200|IR_38400|IR_57600|IR_115200;
803 if (si->pdata->transceiver_cap & IR_FIRMODE)
804 baudrate_mask |= IR_4000000 << 8;
805
806 si->qos.baud_rate.bits &= baudrate_mask;
807 si->qos.min_turn_time.bits = 7; /* 1ms or more */
808
809 irda_qos_bits_to_value(&si->qos);
810
811 err = register_netdev(dev);
812
813 if (err == 0)
814 dev_set_drvdata(&pdev->dev, dev);
815
816 if (err) {
817 kfree(si->tx_buff.head);
818err_mem_5:
819 kfree(si->rx_buff.head);
820err_mem_4:
821 free_netdev(dev);
822err_mem_3:
823 release_mem_region(__PREG(FICP), 0x1c);
824err_mem_2:
825 release_mem_region(__PREG(STUART), 0x24);
826 }
827err_mem_1:
828 return err;
829}
830
831static int pxa_irda_remove(struct device *_dev)
832{
833 struct net_device *dev = dev_get_drvdata(_dev);
834
835 if (dev) {
836 struct pxa_irda *si = netdev_priv(dev);
837 unregister_netdev(dev);
838 kfree(si->tx_buff.head);
839 kfree(si->rx_buff.head);
840 free_netdev(dev);
841 }
842
843 release_mem_region(__PREG(STUART), 0x24);
844 release_mem_region(__PREG(FICP), 0x1c);
845
846 return 0;
847}
848
849static struct device_driver pxa_ir_driver = {
850 .name = "pxa2xx-ir",
851 .bus = &platform_bus_type,
852 .probe = pxa_irda_probe,
853 .remove = pxa_irda_remove,
854 .suspend = pxa_irda_suspend,
855 .resume = pxa_irda_resume,
856};
857
858static int __init pxa_irda_init(void)
859{
860 return driver_register(&pxa_ir_driver);
861}
862
863static void __exit pxa_irda_exit(void)
864{
865 driver_unregister(&pxa_ir_driver);
866}
867
868module_init(pxa_irda_init);
869module_exit(pxa_irda_exit);
870
871MODULE_LICENSE("GPL");
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 8d34ac60d906..06883309916d 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -291,12 +291,12 @@ static void sa1100_irda_shutdown(struct sa1100_irda *si)
291/* 291/*
292 * Suspend the IrDA interface. 292 * Suspend the IrDA interface.
293 */ 293 */
294static int sa1100_irda_suspend(struct device *_dev, pm_message_t state, u32 level) 294static int sa1100_irda_suspend(struct device *_dev, pm_message_t state)
295{ 295{
296 struct net_device *dev = dev_get_drvdata(_dev); 296 struct net_device *dev = dev_get_drvdata(_dev);
297 struct sa1100_irda *si; 297 struct sa1100_irda *si;
298 298
299 if (!dev || level != SUSPEND_DISABLE) 299 if (!dev)
300 return 0; 300 return 0;
301 301
302 si = dev->priv; 302 si = dev->priv;
@@ -316,12 +316,12 @@ static int sa1100_irda_suspend(struct device *_dev, pm_message_t state, u32 leve
316/* 316/*
317 * Resume the IrDA interface. 317 * Resume the IrDA interface.
318 */ 318 */
319static int sa1100_irda_resume(struct device *_dev, u32 level) 319static int sa1100_irda_resume(struct device *_dev)
320{ 320{
321 struct net_device *dev = dev_get_drvdata(_dev); 321 struct net_device *dev = dev_get_drvdata(_dev);
322 struct sa1100_irda *si; 322 struct sa1100_irda *si;
323 323
324 if (!dev || level != RESUME_ENABLE) 324 if (!dev)
325 return 0; 325 return 0;
326 326
327 si = dev->priv; 327 si = dev->priv;
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index dd89bda1f131..bbac720cca63 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -213,8 +213,8 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
213 213
214/* Power Management */ 214/* Power Management */
215 215
216static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level); 216static int smsc_ircc_suspend(struct device *dev, pm_message_t state);
217static int smsc_ircc_resume(struct device *dev, u32 level); 217static int smsc_ircc_resume(struct device *dev);
218 218
219static struct device_driver smsc_ircc_driver = { 219static struct device_driver smsc_ircc_driver = {
220 .name = SMSC_IRCC2_DRIVER_NAME, 220 .name = SMSC_IRCC2_DRIVER_NAME,
@@ -1646,13 +1646,13 @@ static int smsc_ircc_net_close(struct net_device *dev)
1646 return 0; 1646 return 0;
1647} 1647}
1648 1648
1649static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level) 1649static int smsc_ircc_suspend(struct device *dev, pm_message_t state)
1650{ 1650{
1651 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1651 struct smsc_ircc_cb *self = dev_get_drvdata(dev);
1652 1652
1653 IRDA_MESSAGE("%s, Suspending\n", driver_name); 1653 IRDA_MESSAGE("%s, Suspending\n", driver_name);
1654 1654
1655 if (level == SUSPEND_DISABLE && !self->io.suspended) { 1655 if (!self->io.suspended) {
1656 smsc_ircc_net_close(self->netdev); 1656 smsc_ircc_net_close(self->netdev);
1657 self->io.suspended = 1; 1657 self->io.suspended = 1;
1658 } 1658 }
@@ -1660,11 +1660,11 @@ static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level)
1660 return 0; 1660 return 0;
1661} 1661}
1662 1662
1663static int smsc_ircc_resume(struct device *dev, u32 level) 1663static int smsc_ircc_resume(struct device *dev)
1664{ 1664{
1665 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1665 struct smsc_ircc_cb *self = dev_get_drvdata(dev);
1666 1666
1667 if (level == RESUME_ENABLE && self->io.suspended) { 1667 if (self->io.suspended) {
1668 1668
1669 smsc_ircc_net_open(self->netdev); 1669 smsc_ircc_net_open(self->netdev);
1670 self->io.suspended = 0; 1670 self->io.suspended = 0;
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 15f207323d97..3961a754e920 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -678,10 +678,9 @@ static void turnaround_delay(const struct stir_cb *stir, long us)
678 return; 678 return;
679 679
680 ticks = us / (1000000 / HZ); 680 ticks = us / (1000000 / HZ);
681 if (ticks > 0) { 681 if (ticks > 0)
682 current->state = TASK_INTERRUPTIBLE; 682 schedule_timeout_interruptible(1 + ticks);
683 schedule_timeout(1 + ticks); 683 else
684 } else
685 udelay(us); 684 udelay(us);
686} 685}
687 686
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index 9d026ed77ddd..04e47189d830 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -645,11 +645,10 @@ ixgb_phys_id(struct net_device *netdev, uint32_t data)
645 645
646 mod_timer(&adapter->blink_timer, jiffies); 646 mod_timer(&adapter->blink_timer, jiffies);
647 647
648 set_current_state(TASK_INTERRUPTIBLE); 648 if (data)
649 if(data) 649 schedule_timeout_interruptible(data * HZ);
650 schedule_timeout(data * HZ);
651 else 650 else
652 schedule_timeout(MAX_SCHEDULE_TIMEOUT); 651 schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
653 652
654 del_timer_sync(&adapter->blink_timer); 653 del_timer_sync(&adapter->blink_timer);
655 ixgb_led_off(&adapter->hw); 654 ixgb_led_off(&adapter->hw);
@@ -723,6 +722,7 @@ struct ethtool_ops ixgb_ethtool_ops = {
723 .phys_id = ixgb_phys_id, 722 .phys_id = ixgb_phys_id,
724 .get_stats_count = ixgb_get_stats_count, 723 .get_stats_count = ixgb_get_stats_count,
725 .get_ethtool_stats = ixgb_get_ethtool_stats, 724 .get_ethtool_stats = ixgb_get_ethtool_stats,
725 .get_perm_addr = ethtool_op_get_perm_addr,
726}; 726};
727 727
728void ixgb_set_ethtool_ops(struct net_device *netdev) 728void ixgb_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 89d6d69be382..176680cb153e 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -460,8 +460,9 @@ ixgb_probe(struct pci_dev *pdev,
460 } 460 }
461 461
462 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr); 462 ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr);
463 memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len);
463 464
464 if(!is_valid_ether_addr(netdev->dev_addr)) { 465 if(!is_valid_ether_addr(netdev->perm_addr)) {
465 err = -EIO; 466 err = -EIO;
466 goto err_eeprom; 467 goto err_eeprom;
467 } 468 }
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index b4929beb33b2..1d75ca0bb939 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -298,7 +298,7 @@ enum {OLD_LANCE = 0, PCNET_ISA=1, PCNET_ISAP=2, PCNET_PCI=3, PCNET_VLB=4, PCNET_
298static unsigned char lance_need_isa_bounce_buffers = 1; 298static unsigned char lance_need_isa_bounce_buffers = 1;
299 299
300static int lance_open(struct net_device *dev); 300static int lance_open(struct net_device *dev);
301static void lance_init_ring(struct net_device *dev, int mode); 301static void lance_init_ring(struct net_device *dev, gfp_t mode);
302static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev); 302static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev);
303static int lance_rx(struct net_device *dev); 303static int lance_rx(struct net_device *dev);
304static irqreturn_t lance_interrupt(int irq, void *dev_id, struct pt_regs *regs); 304static irqreturn_t lance_interrupt(int irq, void *dev_id, struct pt_regs *regs);
@@ -846,7 +846,7 @@ lance_purge_ring(struct net_device *dev)
846 846
847/* Initialize the LANCE Rx and Tx rings. */ 847/* Initialize the LANCE Rx and Tx rings. */
848static void 848static void
849lance_init_ring(struct net_device *dev, int gfp) 849lance_init_ring(struct net_device *dev, gfp_t gfp)
850{ 850{
851 struct lance_private *lp = dev->priv; 851 struct lance_private *lp = dev->priv;
852 int i; 852 int i;
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index 41bad07ac1ac..f7b7238d8352 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -415,6 +415,10 @@ static int rx_ring_size = RX_RING_SIZE;
415static int ticks_limit = 100; 415static int ticks_limit = 100;
416static int max_cmd_backlog = TX_RING_SIZE-1; 416static int max_cmd_backlog = TX_RING_SIZE-1;
417 417
418#ifdef CONFIG_NET_POLL_CONTROLLER
419static void i596_poll_controller(struct net_device *dev);
420#endif
421
418 422
419static inline void CA(struct net_device *dev) 423static inline void CA(struct net_device *dev)
420{ 424{
@@ -636,11 +640,11 @@ static int init_i596_mem(struct net_device *dev)
636 640
637 disable_irq(dev->irq); /* disable IRQs from LAN */ 641 disable_irq(dev->irq); /* disable IRQs from LAN */
638 DEB(DEB_INIT, 642 DEB(DEB_INIT,
639 printk("RESET 82596 port: %p (with IRQ %d disabled)\n", 643 printk("RESET 82596 port: %lx (with IRQ %d disabled)\n",
640 (void*)(dev->base_addr + PA_I82596_RESET), 644 (dev->base_addr + PA_I82596_RESET),
641 dev->irq)); 645 dev->irq));
642 646
643 gsc_writel(0, (void*)(dev->base_addr + PA_I82596_RESET)); /* Hard Reset */ 647 gsc_writel(0, (dev->base_addr + PA_I82596_RESET)); /* Hard Reset */
644 udelay(100); /* Wait 100us - seems to help */ 648 udelay(100); /* Wait 100us - seems to help */
645 649
646 /* change the scp address */ 650 /* change the scp address */
@@ -1209,6 +1213,9 @@ static int __devinit i82596_probe(struct net_device *dev,
1209 dev->set_multicast_list = set_multicast_list; 1213 dev->set_multicast_list = set_multicast_list;
1210 dev->tx_timeout = i596_tx_timeout; 1214 dev->tx_timeout = i596_tx_timeout;
1211 dev->watchdog_timeo = TX_TIMEOUT; 1215 dev->watchdog_timeo = TX_TIMEOUT;
1216#ifdef CONFIG_NET_POLL_CONTROLLER
1217 dev->poll_controller = i596_poll_controller;
1218#endif
1212 1219
1213 dev->priv = (void *)(dev->mem_start); 1220 dev->priv = (void *)(dev->mem_start);
1214 1221
@@ -1242,6 +1249,14 @@ static int __devinit i82596_probe(struct net_device *dev,
1242 return 0; 1249 return 0;
1243} 1250}
1244 1251
1252#ifdef CONFIG_NET_POLL_CONTROLLER
1253static void i596_poll_controller(struct net_device *dev)
1254{
1255 disable_irq(dev->irq);
1256 i596_interrupt(dev->irq, dev, NULL);
1257 enable_irq(dev->irq);
1258}
1259#endif
1245 1260
1246static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1261static irqreturn_t i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1247{ 1262{
@@ -1528,17 +1543,18 @@ lan_init_chip(struct parisc_device *dev)
1528 1543
1529 if (!dev->irq) { 1544 if (!dev->irq) {
1530 printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n", 1545 printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
1531 __FILE__, dev->hpa); 1546 __FILE__, dev->hpa.start);
1532 return -ENODEV; 1547 return -ENODEV;
1533 } 1548 }
1534 1549
1535 printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa, dev->irq); 1550 printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa.start,
1551 dev->irq);
1536 1552
1537 netdevice = alloc_etherdev(0); 1553 netdevice = alloc_etherdev(0);
1538 if (!netdevice) 1554 if (!netdevice)
1539 return -ENOMEM; 1555 return -ENOMEM;
1540 1556
1541 netdevice->base_addr = dev->hpa; 1557 netdevice->base_addr = dev->hpa.start;
1542 netdevice->irq = dev->irq; 1558 netdevice->irq = dev->irq;
1543 1559
1544 retval = i82596_probe(netdevice, &dev->dev); 1560 retval = i82596_probe(netdevice, &dev->dev);
@@ -1566,7 +1582,7 @@ static struct parisc_device_id lan_tbl[] = {
1566MODULE_DEVICE_TABLE(parisc, lan_tbl); 1582MODULE_DEVICE_TABLE(parisc, lan_tbl);
1567 1583
1568static struct parisc_driver lan_driver = { 1584static struct parisc_driver lan_driver = {
1569 .name = "Apricot", 1585 .name = "lasi_82596",
1570 .id_table = lan_tbl, 1586 .id_table = lan_tbl,
1571 .probe = lan_init_chip, 1587 .probe = lan_init_chip,
1572}; 1588};
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index 27f0d8ac4c40..309d254842cf 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -298,7 +298,7 @@ static int __init lne390_probe1(struct net_device *dev, int ioaddr)
298 return 0; 298 return 0;
299unmap: 299unmap:
300 if (ei_status.reg0) 300 if (ei_status.reg0)
301 iounmap((void *)dev->mem_start); 301 iounmap(ei_status.mem);
302cleanup: 302cleanup:
303 free_irq(dev->irq, dev); 303 free_irq(dev->irq, dev);
304 return ret; 304 return ret;
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index c33cb3dc942b..e42aa797f08b 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -207,6 +207,20 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
207 return 0; 207 return 0;
208} 208}
209 209
210int mii_check_gmii_support(struct mii_if_info *mii)
211{
212 int reg;
213
214 reg = mii->mdio_read(mii->dev, mii->phy_id, MII_BMSR);
215 if (reg & BMSR_ESTATEN) {
216 reg = mii->mdio_read(mii->dev, mii->phy_id, MII_ESTATUS);
217 if (reg & (ESTATUS_1000_TFULL | ESTATUS_1000_THALF))
218 return 1;
219 }
220
221 return 0;
222}
223
210int mii_link_ok (struct mii_if_info *mii) 224int mii_link_ok (struct mii_if_info *mii)
211{ 225{
212 /* first, a dummy read, needed to latch some MII phys */ 226 /* first, a dummy read, needed to latch some MII phys */
@@ -394,5 +408,6 @@ EXPORT_SYMBOL(mii_ethtool_gset);
394EXPORT_SYMBOL(mii_ethtool_sset); 408EXPORT_SYMBOL(mii_ethtool_sset);
395EXPORT_SYMBOL(mii_check_link); 409EXPORT_SYMBOL(mii_check_link);
396EXPORT_SYMBOL(mii_check_media); 410EXPORT_SYMBOL(mii_check_media);
411EXPORT_SYMBOL(mii_check_gmii_support);
397EXPORT_SYMBOL(generic_mii_ioctl); 412EXPORT_SYMBOL(generic_mii_ioctl);
398 413
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
new file mode 100644
index 000000000000..f79f7ee72ab8
--- /dev/null
+++ b/drivers/net/mipsnet.c
@@ -0,0 +1,371 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 */
6
7#define DEBUG
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/netdevice.h>
13#include <linux/sched.h>
14#include <linux/etherdevice.h>
15#include <linux/netdevice.h>
16#include <asm/io.h>
17#include <asm/mips-boards/simint.h>
18
19#include "mipsnet.h" /* actual device IO mapping */
20
21#define MIPSNET_VERSION "2005-06-20"
22
23#define mipsnet_reg_address(dev, field) (dev->base_addr + field_offset(field))
24
25struct mipsnet_priv {
26 struct net_device_stats stats;
27};
28
29static struct platform_device *mips_plat_dev;
30
31static char mipsnet_string[] = "mipsnet";
32
33/*
34 * Copy data from the MIPSNET rx data port
35 */
36static int ioiocpy_frommipsnet(struct net_device *dev, unsigned char *kdata,
37 int len)
38{
39 uint32_t available_len = inl(mipsnet_reg_address(dev, rxDataCount));
40 if (available_len < len)
41 return -EFAULT;
42
43 for (; len > 0; len--, kdata++) {
44 *kdata = inb(mipsnet_reg_address(dev, rxDataBuffer));
45 }
46
47 return inl(mipsnet_reg_address(dev, rxDataCount));
48}
49
50static inline ssize_t mipsnet_put_todevice(struct net_device *dev,
51 struct sk_buff *skb)
52{
53 int count_to_go = skb->len;
54 char *buf_ptr = skb->data;
55 struct mipsnet_priv *mp = netdev_priv(dev);
56
57 pr_debug("%s: %s(): telling MIPSNET txDataCount(%d)\n",
58 dev->name, __FUNCTION__, skb->len);
59
60 outl(skb->len, mipsnet_reg_address(dev, txDataCount));
61
62 pr_debug("%s: %s(): sending data to MIPSNET txDataBuffer(%d)\n",
63 dev->name, __FUNCTION__, skb->len);
64
65 for (; count_to_go; buf_ptr++, count_to_go--) {
66 outb(*buf_ptr, mipsnet_reg_address(dev, txDataBuffer));
67 }
68
69 mp->stats.tx_packets++;
70 mp->stats.tx_bytes += skb->len;
71
72 return skb->len;
73}
74
75static int mipsnet_xmit(struct sk_buff *skb, struct net_device *dev)
76{
77 pr_debug("%s:%s(): transmitting %d bytes\n",
78 dev->name, __FUNCTION__, skb->len);
79
80 /* Only one packet at a time. Once TXDONE interrupt is serviced, the
81 * queue will be restarted.
82 */
83 netif_stop_queue(dev);
84 mipsnet_put_todevice(dev, skb);
85
86 return 0;
87}
88
89static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t count)
90{
91 struct sk_buff *skb;
92 size_t len = count;
93 struct mipsnet_priv *mp = netdev_priv(dev);
94
95 if (!(skb = alloc_skb(len + 2, GFP_KERNEL))) {
96 mp->stats.rx_dropped++;
97 return -ENOMEM;
98 }
99
100 skb_reserve(skb, 2);
101 if (ioiocpy_frommipsnet(dev, skb_put(skb, len), len))
102 return -EFAULT;
103
104 skb->dev = dev;
105 skb->protocol = eth_type_trans(skb, dev);
106 skb->ip_summed = CHECKSUM_UNNECESSARY;
107
108 pr_debug("%s:%s(): pushing RXed data to kernel\n",
109 dev->name, __FUNCTION__);
110 netif_rx(skb);
111
112 mp->stats.rx_packets++;
113 mp->stats.rx_bytes += len;
114
115 return count;
116}
117
118static irqreturn_t
119mipsnet_interrupt(int irq, void *dev_id, struct pt_regs *regs)
120{
121 struct net_device *dev = dev_id;
122
123 irqreturn_t retval = IRQ_NONE;
124 uint64_t interruptFlags;
125
126 if (irq == dev->irq) {
127 pr_debug("%s:%s(): irq %d for device\n",
128 dev->name, __FUNCTION__, irq);
129
130 retval = IRQ_HANDLED;
131
132 interruptFlags =
133 inl(mipsnet_reg_address(dev, interruptControl));
134 pr_debug("%s:%s(): intCtl=0x%016llx\n", dev->name,
135 __FUNCTION__, interruptFlags);
136
137 if (interruptFlags & MIPSNET_INTCTL_TXDONE) {
138 pr_debug("%s:%s(): got TXDone\n",
139 dev->name, __FUNCTION__);
140 outl(MIPSNET_INTCTL_TXDONE,
141 mipsnet_reg_address(dev, interruptControl));
142 // only one packet at a time, we are done.
143 netif_wake_queue(dev);
144 } else if (interruptFlags & MIPSNET_INTCTL_RXDONE) {
145 pr_debug("%s:%s(): got RX data\n",
146 dev->name, __FUNCTION__);
147 mipsnet_get_fromdev(dev,
148 inl(mipsnet_reg_address(dev, rxDataCount)));
149 pr_debug("%s:%s(): clearing RX int\n",
150 dev->name, __FUNCTION__);
151 outl(MIPSNET_INTCTL_RXDONE,
152 mipsnet_reg_address(dev, interruptControl));
153
154 } else if (interruptFlags & MIPSNET_INTCTL_TESTBIT) {
155 pr_debug("%s:%s(): got test interrupt\n",
156 dev->name, __FUNCTION__);
157 // TESTBIT is cleared on read.
158 // And takes effect after a write with 0
159 outl(0, mipsnet_reg_address(dev, interruptControl));
160 } else {
161 pr_debug("%s:%s(): no valid fags 0x%016llx\n",
162 dev->name, __FUNCTION__, interruptFlags);
163 // Maybe shared IRQ, just ignore, no clearing.
164 retval = IRQ_NONE;
165 }
166
167 } else {
168 printk(KERN_INFO "%s: %s(): irq %d for unknown device\n",
169 dev->name, __FUNCTION__, irq);
170 retval = IRQ_NONE;
171 }
172 return retval;
173} //mipsnet_interrupt()
174
175static int mipsnet_open(struct net_device *dev)
176{
177 int err;
178 pr_debug("%s: mipsnet_open\n", dev->name);
179
180 err = request_irq(dev->irq, &mipsnet_interrupt,
181 SA_SHIRQ, dev->name, (void *) dev);
182
183 if (err) {
184 pr_debug("%s: %s(): can't get irq %d\n",
185 dev->name, __FUNCTION__, dev->irq);
186 release_region(dev->base_addr, MIPSNET_IO_EXTENT);
187 return err;
188 }
189
190 pr_debug("%s: %s(): got IO region at 0x%04lx and irq %d for dev.\n",
191 dev->name, __FUNCTION__, dev->base_addr, dev->irq);
192
193
194 netif_start_queue(dev);
195
196 // test interrupt handler
197 outl(MIPSNET_INTCTL_TESTBIT,
198 mipsnet_reg_address(dev, interruptControl));
199
200
201 return 0;
202}
203
204static int mipsnet_close(struct net_device *dev)
205{
206 pr_debug("%s: %s()\n", dev->name, __FUNCTION__);
207 netif_stop_queue(dev);
208 return 0;
209}
210
211static struct net_device_stats *mipsnet_get_stats(struct net_device *dev)
212{
213 struct mipsnet_priv *mp = netdev_priv(dev);
214
215 return &mp->stats;
216}
217
218static void mipsnet_set_mclist(struct net_device *dev)
219{
220 // we don't do anything
221 return;
222}
223
224static int __init mipsnet_probe(struct device *dev)
225{
226 struct net_device *netdev;
227 int err;
228
229 netdev = alloc_etherdev(sizeof(struct mipsnet_priv));
230 if (!netdev) {
231 err = -ENOMEM;
232 goto out;
233 }
234
235 dev_set_drvdata(dev, netdev);
236
237 netdev->open = mipsnet_open;
238 netdev->stop = mipsnet_close;
239 netdev->hard_start_xmit = mipsnet_xmit;
240 netdev->get_stats = mipsnet_get_stats;
241 netdev->set_multicast_list = mipsnet_set_mclist;
242
243 /*
244 * TODO: probe for these or load them from PARAM
245 */
246 netdev->base_addr = 0x4200;
247 netdev->irq = MIPSCPU_INT_BASE + MIPSCPU_INT_MB0 +
248 inl(mipsnet_reg_address(netdev, interruptInfo));
249
250 // Get the io region now, get irq on open()
251 if (!request_region(netdev->base_addr, MIPSNET_IO_EXTENT, "mipsnet")) {
252 pr_debug("%s: %s(): IO region {start: 0x%04lux, len: %d} "
253 "for dev is not availble.\n", netdev->name,
254 __FUNCTION__, netdev->base_addr, MIPSNET_IO_EXTENT);
255 err = -EBUSY;
256 goto out_free_netdev;
257 }
258
259 /*
260 * Lacking any better mechanism to allocate a MAC address we use a
261 * random one ...
262 */
263 random_ether_addr(netdev->dev_addr);
264
265 err = register_netdev(netdev);
266 if (err) {
267 printk(KERN_ERR "MIPSNet: failed to register netdev.\n");
268 goto out_free_region;
269 }
270
271 return 0;
272
273out_free_region:
274 release_region(netdev->base_addr, MIPSNET_IO_EXTENT);
275
276out_free_netdev:
277 free_netdev(netdev);
278
279out:
280 return err;
281}
282
283static int __devexit mipsnet_device_remove(struct device *device)
284{
285 struct net_device *dev = dev_get_drvdata(device);
286
287 unregister_netdev(dev);
288 release_region(dev->base_addr, MIPSNET_IO_EXTENT);
289 free_netdev(dev);
290 dev_set_drvdata(device, NULL);
291
292 return 0;
293}
294
295static struct device_driver mipsnet_driver = {
296 .name = mipsnet_string,
297 .bus = &platform_bus_type,
298 .probe = mipsnet_probe,
299 .remove = __devexit_p(mipsnet_device_remove),
300};
301
302static void mipsnet_platform_release(struct device *device)
303{
304 struct platform_device *pldev;
305
306 /* free device */
307 pldev = to_platform_device(device);
308 kfree(pldev);
309}
310
311static int __init mipsnet_init_module(void)
312{
313 struct platform_device *pldev;
314 int err;
315
316 printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. "
317 "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION);
318
319 if (driver_register(&mipsnet_driver)) {
320 printk(KERN_ERR "Driver registration failed\n");
321 err = -ENODEV;
322 goto out;
323 }
324
325 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
326 err = -ENOMEM;
327 goto out_unregister_driver;
328 }
329
330 memset (pldev, 0, sizeof (*pldev));
331 pldev->name = mipsnet_string;
332 pldev->id = 0;
333 pldev->dev.release = mipsnet_platform_release;
334
335 if (platform_device_register(pldev)) {
336 err = -ENODEV;
337 goto out_free_pldev;
338 }
339
340 if (!pldev->dev.driver) {
341 /*
342 * The driver was not bound to this device, there was
343 * no hardware at this address. Unregister it, as the
344 * release fuction will take care of freeing the
345 * allocated structure
346 */
347 platform_device_unregister (pldev);
348 }
349
350 mips_plat_dev = pldev;
351
352 return 0;
353
354out_free_pldev:
355 kfree(pldev);
356
357out_unregister_driver:
358 driver_unregister(&mipsnet_driver);
359out:
360 return err;
361}
362
363static void __exit mipsnet_exit_module(void)
364{
365 pr_debug("MIPSNet Ethernet driver exiting\n");
366
367 driver_unregister(&mipsnet_driver);
368}
369
370module_init(mipsnet_init_module);
371module_exit(mipsnet_exit_module);
diff --git a/drivers/net/mipsnet.h b/drivers/net/mipsnet.h
new file mode 100644
index 000000000000..878535953cb1
--- /dev/null
+++ b/drivers/net/mipsnet.h
@@ -0,0 +1,127 @@
1//
2// <COPYRIGHT CLASS="1B" YEAR="2005">
3// Unpublished work (c) MIPS Technologies, Inc. All rights reserved.
4// Unpublished rights reserved under the copyright laws of the U.S.A. and
5// other countries.
6//
7// PROPRIETARY / SECRET CONFIDENTIAL INFORMATION OF MIPS TECHNOLOGIES, INC.
8// FOR INTERNAL USE ONLY.
9//
10// Under no circumstances (contract or otherwise) may this information be
11// disclosed to, or copied, modified or used by anyone other than employees
12// or contractors of MIPS Technologies having a need to know.
13// </COPYRIGHT>
14//
15//++
16// File: MIPS_Net.h
17//
18// Description:
19// The definition of the emulated MIPSNET device's interface.
20//
21// Notes: This include file needs to work from a Linux device drivers.
22//
23//--
24//
25
26#ifndef __MIPSNET_H
27#define __MIPSNET_H
28
29/*
30 * Id of this Net device, as seen by the core.
31 */
32#define MIPS_NET_DEV_ID ((uint64_t) \
33 ((uint64_t)'M'<< 0)| \
34 ((uint64_t)'I'<< 8)| \
35 ((uint64_t)'P'<<16)| \
36 ((uint64_t)'S'<<24)| \
37 ((uint64_t)'N'<<32)| \
38 ((uint64_t)'E'<<40)| \
39 ((uint64_t)'T'<<48)| \
40 ((uint64_t)'0'<<56))
41
42/*
43 * Net status/control block as seen by sw in the core.
44 * (Why not use bit fields? can't be bothered with cross-platform struct
45 * packing.)
46 */
47typedef struct _net_control_block {
48 /// dev info for probing
49 /// reads as MIPSNET%d where %d is some form of version
50 uint64_t devId; /*0x00 */
51
52 /*
53 * read only busy flag.
54 * Set and cleared by the Net Device to indicate that an rx or a tx
55 * is in progress.
56 */
57 uint32_t busy; /*0x08 */
58
59 /*
60 * Set by the Net Device.
61 * The device will set it once data has been received.
62 * The value is the number of bytes that should be read from
63 * rxDataBuffer. The value will decrease till 0 until all the data
64 * from rxDataBuffer has been read.
65 */
66 uint32_t rxDataCount; /*0x0c */
67#define MIPSNET_MAX_RXTX_DATACOUNT (1<<16)
68
69 /*
70 * Settable from the MIPS core, cleared by the Net Device.
71 * The core should set the number of bytes it wants to send,
72 * then it should write those bytes of data to txDataBuffer.
73 * The device will clear txDataCount has been processed (not necessarily sent).
74 */
75 uint32_t txDataCount; /*0x10 */
76
77 /*
78 * Interrupt control
79 *
80 * Used to clear the interrupted generated by this dev.
81 * Write a 1 to clear the interrupt. (except bit31).
82 *
83 * Bit0 is set if it was a tx-done interrupt.
84 * Bit1 is set when new rx-data is available.
85 * Until this bit is cleared there will be no other RXs.
86 *
87 * Bit31 is used for testing, it clears after a read.
88 * Writing 1 to this bit will cause an interrupt to be generated.
89 * To clear the test interrupt, write 0 to this register.
90 */
91 uint32_t interruptControl; /*0x14 */
92#define MIPSNET_INTCTL_TXDONE ((uint32_t)(1<< 0))
93#define MIPSNET_INTCTL_RXDONE ((uint32_t)(1<< 1))
94#define MIPSNET_INTCTL_TESTBIT ((uint32_t)(1<<31))
95#define MIPSNET_INTCTL_ALLSOURCES (MIPSNET_INTCTL_TXDONE|MIPSNET_INTCTL_RXDONE|MIPSNET_INTCTL_TESTBIT)
96
97 /*
98 * Readonly core-specific interrupt info for the device to signal the core.
99 * The meaning of the contents of this field might change.
100 */
101 /*###\todo: the whole memIntf interrupt scheme is messy: the device should have
102 * no control what so ever of what VPE/register set is being used.
103 * The MemIntf should only expose interrupt lines, and something in the
104 * config should be responsible for the line<->core/vpe bindings.
105 */
106 uint32_t interruptInfo; /*0x18 */
107
108 /*
109 * This is where the received data is read out.
110 * There is more data to read until rxDataReady is 0.
111 * Only 1 byte at this regs offset is used.
112 */
113 uint32_t rxDataBuffer; /*0x1c */
114
115 /*
116 * This is where the data to transmit is written.
117 * Data should be written for the amount specified in the txDataCount register.
118 * Only 1 byte at this regs offset is used.
119 */
120 uint32_t txDataBuffer; /*0x20 */
121} MIPS_T_NetControl;
122
123#define MIPSNET_IO_EXTENT 0x40 /* being generous */
124
125#define field_offset(field) ((int)&((MIPS_T_NetControl*)(0))->field)
126
127#endif /* __MIPSNET_H */
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index f0996ce5c268..6c86dca62e2a 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -277,7 +277,7 @@ static void myri_init_rings(struct myri_eth *mp, int from_irq)
277 struct recvq __iomem *rq = mp->rq; 277 struct recvq __iomem *rq = mp->rq;
278 struct myri_rxd __iomem *rxd = &rq->myri_rxd[0]; 278 struct myri_rxd __iomem *rxd = &rq->myri_rxd[0];
279 struct net_device *dev = mp->dev; 279 struct net_device *dev = mp->dev;
280 int gfp_flags = GFP_KERNEL; 280 gfp_t gfp_flags = GFP_KERNEL;
281 int i; 281 int i;
282 282
283 if (from_irq || in_interrupt()) 283 if (from_irq || in_interrupt())
diff --git a/drivers/net/myri_sbus.h b/drivers/net/myri_sbus.h
index 9391e55a5e92..47722f708a41 100644
--- a/drivers/net/myri_sbus.h
+++ b/drivers/net/myri_sbus.h
@@ -296,7 +296,7 @@ struct myri_eth {
296/* We use this to acquire receive skb's that we can DMA directly into. */ 296/* We use this to acquire receive skb's that we can DMA directly into. */
297#define ALIGNED_RX_SKB_ADDR(addr) \ 297#define ALIGNED_RX_SKB_ADDR(addr) \
298 ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr)) 298 ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr))
299static inline struct sk_buff *myri_alloc_skb(unsigned int length, int gfp_flags) 299static inline struct sk_buff *myri_alloc_skb(unsigned int length, gfp_t gfp_flags)
300{ 300{
301 struct sk_buff *skb; 301 struct sk_buff *skb;
302 302
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index d209a1556b2e..0de8fdd2aa86 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -54,6 +54,10 @@ static const char version2[] =
54#include <asm/system.h> 54#include <asm/system.h>
55#include <asm/io.h> 55#include <asm/io.h>
56 56
57#if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938)
58#include <asm/tx4938/rbtx4938.h>
59#endif
60
57#include "8390.h" 61#include "8390.h"
58 62
59#define DRV_NAME "ne" 63#define DRV_NAME "ne"
@@ -111,6 +115,9 @@ bad_clone_list[] __initdata = {
111 {"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */ 115 {"E-LAN100", "E-LAN200", {0x00, 0x00, 0x5d}}, /* Broken ne1000 clones */
112 {"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */ 116 {"PCM-4823", "PCM-4823", {0x00, 0xc0, 0x6c}}, /* Broken Advantech MoBo */
113 {"REALTEK", "RTL8019", {0x00, 0x00, 0xe8}}, /* no-name with Realtek chip */ 117 {"REALTEK", "RTL8019", {0x00, 0x00, 0xe8}}, /* no-name with Realtek chip */
118#if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938)
119 {"RBHMA4X00-RTL8019", "RBHMA4X00/RTL8019", {0x00, 0x60, 0x0a}}, /* Toshiba built-in */
120#endif
114 {"LCS-8834", "LCS-8836", {0x04, 0x04, 0x37}}, /* ShinyNet (SET) */ 121 {"LCS-8834", "LCS-8836", {0x04, 0x04, 0x37}}, /* ShinyNet (SET) */
115 {NULL,} 122 {NULL,}
116}; 123};
@@ -226,6 +233,10 @@ struct net_device * __init ne_probe(int unit)
226 sprintf(dev->name, "eth%d", unit); 233 sprintf(dev->name, "eth%d", unit);
227 netdev_boot_setup_check(dev); 234 netdev_boot_setup_check(dev);
228 235
236#ifdef CONFIG_TOSHIBA_RBTX4938
237 dev->base_addr = 0x07f20280;
238 dev->irq = RBTX4938_RTL_8019_IRQ;
239#endif
229 err = do_ne_probe(dev); 240 err = do_ne_probe(dev);
230 if (err) 241 if (err)
231 goto out; 242 goto out;
@@ -506,6 +517,10 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
506 ei_status.name = name; 517 ei_status.name = name;
507 ei_status.tx_start_page = start_page; 518 ei_status.tx_start_page = start_page;
508 ei_status.stop_page = stop_page; 519 ei_status.stop_page = stop_page;
520#if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938)
521 wordlength = 1;
522#endif
523
509#ifdef CONFIG_PLAT_OAKS32R 524#ifdef CONFIG_PLAT_OAKS32R
510 ei_status.word16 = 0; 525 ei_status.word16 = 0;
511#else 526#else
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index f1c01ac29102..e531a4eedfee 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -372,6 +372,7 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
372 printk("%2.2X%s", SA_prom[i], i == 5 ? ".\n": ":"); 372 printk("%2.2X%s", SA_prom[i], i == 5 ? ".\n": ":");
373 dev->dev_addr[i] = SA_prom[i]; 373 dev->dev_addr[i] = SA_prom[i];
374 } 374 }
375 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
375 376
376 return 0; 377 return 0;
377 378
@@ -637,6 +638,7 @@ static struct ethtool_ops ne2k_pci_ethtool_ops = {
637 .get_drvinfo = ne2k_pci_get_drvinfo, 638 .get_drvinfo = ne2k_pci_get_drvinfo,
638 .get_tx_csum = ethtool_op_get_tx_csum, 639 .get_tx_csum = ethtool_op_get_tx_csum,
639 .get_sg = ethtool_op_get_sg, 640 .get_sg = ethtool_op_get_sg,
641 .get_perm_addr = ethtool_op_get_perm_addr,
640}; 642};
641 643
642static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) 644static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index e4811b42a6b7..a3c3fc9c0d8a 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1632,8 +1632,7 @@ static void ns83820_run_bist(struct net_device *ndev, const char *name, u32 enab
1632 timed_out = 1; 1632 timed_out = 1;
1633 break; 1633 break;
1634 } 1634 }
1635 set_current_state(TASK_UNINTERRUPTIBLE); 1635 schedule_timeout_uninterruptible(1);
1636 schedule_timeout(1);
1637 } 1636 }
1638 1637
1639 if (status & fail) 1638 if (status & fail)
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 113b68099216..70fe81a89df9 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -22,8 +22,8 @@
22 *************************************************************************/ 22 *************************************************************************/
23 23
24#define DRV_NAME "pcnet32" 24#define DRV_NAME "pcnet32"
25#define DRV_VERSION "1.30j" 25#define DRV_VERSION "1.31a"
26#define DRV_RELDATE "29.04.2005" 26#define DRV_RELDATE "12.Sep.2005"
27#define PFX DRV_NAME ": " 27#define PFX DRV_NAME ": "
28 28
29static const char *version = 29static const char *version =
@@ -257,6 +257,9 @@ static int homepna[MAX_UNITS];
257 * v1.30h 24 Jun 2004 Don Fry correctly select auto, speed, duplex in bcr32. 257 * v1.30h 24 Jun 2004 Don Fry correctly select auto, speed, duplex in bcr32.
258 * v1.30i 28 Jun 2004 Don Fry change to use module_param. 258 * v1.30i 28 Jun 2004 Don Fry change to use module_param.
259 * v1.30j 29 Apr 2005 Don Fry fix skb/map leak with loopback test. 259 * v1.30j 29 Apr 2005 Don Fry fix skb/map leak with loopback test.
260 * v1.31 02 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> added set_ringparam().
261 * v1.31a 12 Sep 2005 Hubert WS Lin <wslin@tw.ibm.c0m> set min ring size to 4
262 * to allow loopback test to work unchanged.
260 */ 263 */
261 264
262 265
@@ -266,17 +269,17 @@ static int homepna[MAX_UNITS];
266 * That translates to 2 (4 == 2^^2) and 4 (16 == 2^^4). 269 * That translates to 2 (4 == 2^^2) and 4 (16 == 2^^4).
267 */ 270 */
268#ifndef PCNET32_LOG_TX_BUFFERS 271#ifndef PCNET32_LOG_TX_BUFFERS
269#define PCNET32_LOG_TX_BUFFERS 4 272#define PCNET32_LOG_TX_BUFFERS 4
270#define PCNET32_LOG_RX_BUFFERS 5 273#define PCNET32_LOG_RX_BUFFERS 5
274#define PCNET32_LOG_MAX_TX_BUFFERS 9 /* 2^9 == 512 */
275#define PCNET32_LOG_MAX_RX_BUFFERS 9
271#endif 276#endif
272 277
273#define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS)) 278#define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS))
274#define TX_RING_MOD_MASK (TX_RING_SIZE - 1) 279#define TX_MAX_RING_SIZE (1 << (PCNET32_LOG_MAX_TX_BUFFERS))
275#define TX_RING_LEN_BITS ((PCNET32_LOG_TX_BUFFERS) << 12)
276 280
277#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS)) 281#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS))
278#define RX_RING_MOD_MASK (RX_RING_SIZE - 1) 282#define RX_MAX_RING_SIZE (1 << (PCNET32_LOG_MAX_RX_BUFFERS))
279#define RX_RING_LEN_BITS ((PCNET32_LOG_RX_BUFFERS) << 4)
280 283
281#define PKT_BUF_SZ 1544 284#define PKT_BUF_SZ 1544
282 285
@@ -334,14 +337,14 @@ struct pcnet32_access {
334}; 337};
335 338
336/* 339/*
337 * The first three fields of pcnet32_private are read by the ethernet device 340 * The first field of pcnet32_private is read by the ethernet device
338 * so we allocate the structure should be allocated by pci_alloc_consistent(). 341 * so the structure should be allocated using pci_alloc_consistent().
339 */ 342 */
340struct pcnet32_private { 343struct pcnet32_private {
341 /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */
342 struct pcnet32_rx_head rx_ring[RX_RING_SIZE];
343 struct pcnet32_tx_head tx_ring[TX_RING_SIZE];
344 struct pcnet32_init_block init_block; 344 struct pcnet32_init_block init_block;
345 /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */
346 struct pcnet32_rx_head *rx_ring;
347 struct pcnet32_tx_head *tx_ring;
345 dma_addr_t dma_addr; /* DMA address of beginning of this 348 dma_addr_t dma_addr; /* DMA address of beginning of this
346 object, returned by 349 object, returned by
347 pci_alloc_consistent */ 350 pci_alloc_consistent */
@@ -349,13 +352,21 @@ struct pcnet32_private {
349 structure */ 352 structure */
350 const char *name; 353 const char *name;
351 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 354 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
352 struct sk_buff *tx_skbuff[TX_RING_SIZE]; 355 struct sk_buff **tx_skbuff;
353 struct sk_buff *rx_skbuff[RX_RING_SIZE]; 356 struct sk_buff **rx_skbuff;
354 dma_addr_t tx_dma_addr[TX_RING_SIZE]; 357 dma_addr_t *tx_dma_addr;
355 dma_addr_t rx_dma_addr[RX_RING_SIZE]; 358 dma_addr_t *rx_dma_addr;
356 struct pcnet32_access a; 359 struct pcnet32_access a;
357 spinlock_t lock; /* Guard lock */ 360 spinlock_t lock; /* Guard lock */
358 unsigned int cur_rx, cur_tx; /* The next free ring entry */ 361 unsigned int cur_rx, cur_tx; /* The next free ring entry */
362 unsigned int rx_ring_size; /* current rx ring size */
363 unsigned int tx_ring_size; /* current tx ring size */
364 unsigned int rx_mod_mask; /* rx ring modular mask */
365 unsigned int tx_mod_mask; /* tx ring modular mask */
366 unsigned short rx_len_bits;
367 unsigned short tx_len_bits;
368 dma_addr_t rx_ring_dma_addr;
369 dma_addr_t tx_ring_dma_addr;
359 unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */ 370 unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */
360 struct net_device_stats stats; 371 struct net_device_stats stats;
361 char tx_full; 372 char tx_full;
@@ -397,6 +408,9 @@ static int pcnet32_get_regs_len(struct net_device *dev);
397static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs, 408static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
398 void *ptr); 409 void *ptr);
399static void pcnet32_purge_tx_ring(struct net_device *dev); 410static void pcnet32_purge_tx_ring(struct net_device *dev);
411static int pcnet32_alloc_ring(struct net_device *dev);
412static void pcnet32_free_ring(struct net_device *dev);
413
400 414
401enum pci_flags_bit { 415enum pci_flags_bit {
402 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, 416 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
@@ -613,10 +627,62 @@ static void pcnet32_get_ringparam(struct net_device *dev, struct ethtool_ringpar
613{ 627{
614 struct pcnet32_private *lp = dev->priv; 628 struct pcnet32_private *lp = dev->priv;
615 629
616 ering->tx_max_pending = TX_RING_SIZE - 1; 630 ering->tx_max_pending = TX_MAX_RING_SIZE - 1;
617 ering->tx_pending = lp->cur_tx - lp->dirty_tx; 631 ering->tx_pending = lp->tx_ring_size - 1;
618 ering->rx_max_pending = RX_RING_SIZE - 1; 632 ering->rx_max_pending = RX_MAX_RING_SIZE - 1;
619 ering->rx_pending = lp->cur_rx & RX_RING_MOD_MASK; 633 ering->rx_pending = lp->rx_ring_size - 1;
634}
635
636static int pcnet32_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ering)
637{
638 struct pcnet32_private *lp = dev->priv;
639 unsigned long flags;
640 int i;
641
642 if (ering->rx_mini_pending || ering->rx_jumbo_pending)
643 return -EINVAL;
644
645 if (netif_running(dev))
646 pcnet32_close(dev);
647
648 spin_lock_irqsave(&lp->lock, flags);
649 pcnet32_free_ring(dev);
650 lp->tx_ring_size = min(ering->tx_pending, (unsigned int) TX_MAX_RING_SIZE);
651 lp->rx_ring_size = min(ering->rx_pending, (unsigned int) RX_MAX_RING_SIZE);
652
653 /* set the minimum ring size to 4, to allow the loopback test to work
654 * unchanged.
655 */
656 for (i = 2; i <= PCNET32_LOG_MAX_TX_BUFFERS; i++) {
657 if (lp->tx_ring_size <= (1 << i))
658 break;
659 }
660 lp->tx_ring_size = (1 << i);
661 lp->tx_mod_mask = lp->tx_ring_size - 1;
662 lp->tx_len_bits = (i << 12);
663
664 for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) {
665 if (lp->rx_ring_size <= (1 << i))
666 break;
667 }
668 lp->rx_ring_size = (1 << i);
669 lp->rx_mod_mask = lp->rx_ring_size - 1;
670 lp->rx_len_bits = (i << 4);
671
672 if (pcnet32_alloc_ring(dev)) {
673 pcnet32_free_ring(dev);
674 return -ENOMEM;
675 }
676
677 spin_unlock_irqrestore(&lp->lock, flags);
678
679 if (pcnet32_debug & NETIF_MSG_DRV)
680 printk(KERN_INFO PFX "Ring Param Settings: RX: %d, TX: %d\n", lp->rx_ring_size, lp->tx_ring_size);
681
682 if (netif_running(dev))
683 pcnet32_open(dev);
684
685 return 0;
620} 686}
621 687
622static void pcnet32_get_strings(struct net_device *dev, u32 stringset, u8 *data) 688static void pcnet32_get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -948,6 +1014,7 @@ static struct ethtool_ops pcnet32_ethtool_ops = {
948 .nway_reset = pcnet32_nway_reset, 1014 .nway_reset = pcnet32_nway_reset,
949 .get_link = pcnet32_get_link, 1015 .get_link = pcnet32_get_link,
950 .get_ringparam = pcnet32_get_ringparam, 1016 .get_ringparam = pcnet32_get_ringparam,
1017 .set_ringparam = pcnet32_set_ringparam,
951 .get_tx_csum = ethtool_op_get_tx_csum, 1018 .get_tx_csum = ethtool_op_get_tx_csum,
952 .get_sg = ethtool_op_get_sg, 1019 .get_sg = ethtool_op_get_sg,
953 .get_tso = ethtool_op_get_tso, 1020 .get_tso = ethtool_op_get_tso,
@@ -957,6 +1024,7 @@ static struct ethtool_ops pcnet32_ethtool_ops = {
957 .phys_id = pcnet32_phys_id, 1024 .phys_id = pcnet32_phys_id,
958 .get_regs_len = pcnet32_get_regs_len, 1025 .get_regs_len = pcnet32_get_regs_len,
959 .get_regs = pcnet32_get_regs, 1026 .get_regs = pcnet32_get_regs,
1027 .get_perm_addr = ethtool_op_get_perm_addr,
960}; 1028};
961 1029
962/* only probes for non-PCI devices, the rest are handled by 1030/* only probes for non-PCI devices, the rest are handled by
@@ -1185,9 +1253,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1185 memcpy(dev->dev_addr, promaddr, 6); 1253 memcpy(dev->dev_addr, promaddr, 6);
1186 } 1254 }
1187 } 1255 }
1256 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1188 1257
1189 /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */ 1258 /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
1190 if (!is_valid_ether_addr(dev->dev_addr)) 1259 if (!is_valid_ether_addr(dev->perm_addr))
1191 memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); 1260 memset(dev->dev_addr, 0, sizeof(dev->dev_addr));
1192 1261
1193 if (pcnet32_debug & NETIF_MSG_PROBE) { 1262 if (pcnet32_debug & NETIF_MSG_PROBE) {
@@ -1239,6 +1308,12 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1239 dev->priv = lp; 1308 dev->priv = lp;
1240 lp->name = chipname; 1309 lp->name = chipname;
1241 lp->shared_irq = shared; 1310 lp->shared_irq = shared;
1311 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */
1312 lp->rx_ring_size = RX_RING_SIZE; /* default rx ring size */
1313 lp->tx_mod_mask = lp->tx_ring_size - 1;
1314 lp->rx_mod_mask = lp->rx_ring_size - 1;
1315 lp->tx_len_bits = (PCNET32_LOG_TX_BUFFERS << 12);
1316 lp->rx_len_bits = (PCNET32_LOG_RX_BUFFERS << 4);
1242 lp->mii_if.full_duplex = fdx; 1317 lp->mii_if.full_duplex = fdx;
1243 lp->mii_if.phy_id_mask = 0x1f; 1318 lp->mii_if.phy_id_mask = 0x1f;
1244 lp->mii_if.reg_num_mask = 0x1f; 1319 lp->mii_if.reg_num_mask = 0x1f;
@@ -1265,21 +1340,23 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1265 } 1340 }
1266 lp->a = *a; 1341 lp->a = *a;
1267 1342
1343 if (pcnet32_alloc_ring(dev)) {
1344 ret = -ENOMEM;
1345 goto err_free_ring;
1346 }
1268 /* detect special T1/E1 WAN card by checking for MAC address */ 1347 /* detect special T1/E1 WAN card by checking for MAC address */
1269 if (dev->dev_addr[0] == 0x00 && dev->dev_addr[1] == 0xe0 1348 if (dev->dev_addr[0] == 0x00 && dev->dev_addr[1] == 0xe0
1270 && dev->dev_addr[2] == 0x75) 1349 && dev->dev_addr[2] == 0x75)
1271 lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI; 1350 lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI;
1272 1351
1273 lp->init_block.mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */ 1352 lp->init_block.mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */
1274 lp->init_block.tlen_rlen = le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS); 1353 lp->init_block.tlen_rlen = le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits);
1275 for (i = 0; i < 6; i++) 1354 for (i = 0; i < 6; i++)
1276 lp->init_block.phys_addr[i] = dev->dev_addr[i]; 1355 lp->init_block.phys_addr[i] = dev->dev_addr[i];
1277 lp->init_block.filter[0] = 0x00000000; 1356 lp->init_block.filter[0] = 0x00000000;
1278 lp->init_block.filter[1] = 0x00000000; 1357 lp->init_block.filter[1] = 0x00000000;
1279 lp->init_block.rx_ring = (u32)le32_to_cpu(lp->dma_addr + 1358 lp->init_block.rx_ring = (u32)le32_to_cpu(lp->rx_ring_dma_addr);
1280 offsetof(struct pcnet32_private, rx_ring)); 1359 lp->init_block.tx_ring = (u32)le32_to_cpu(lp->tx_ring_dma_addr);
1281 lp->init_block.tx_ring = (u32)le32_to_cpu(lp->dma_addr +
1282 offsetof(struct pcnet32_private, tx_ring));
1283 1360
1284 /* switch pcnet32 to 32bit mode */ 1361 /* switch pcnet32 to 32bit mode */
1285 a->write_bcr(ioaddr, 20, 2); 1362 a->write_bcr(ioaddr, 20, 2);
@@ -1310,7 +1387,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1310 if (pcnet32_debug & NETIF_MSG_PROBE) 1387 if (pcnet32_debug & NETIF_MSG_PROBE)
1311 printk(", failed to detect IRQ line.\n"); 1388 printk(", failed to detect IRQ line.\n");
1312 ret = -ENODEV; 1389 ret = -ENODEV;
1313 goto err_free_consistent; 1390 goto err_free_ring;
1314 } 1391 }
1315 if (pcnet32_debug & NETIF_MSG_PROBE) 1392 if (pcnet32_debug & NETIF_MSG_PROBE)
1316 printk(", probed IRQ %d.\n", dev->irq); 1393 printk(", probed IRQ %d.\n", dev->irq);
@@ -1341,7 +1418,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1341 1418
1342 /* Fill in the generic fields of the device structure. */ 1419 /* Fill in the generic fields of the device structure. */
1343 if (register_netdev(dev)) 1420 if (register_netdev(dev))
1344 goto err_free_consistent; 1421 goto err_free_ring;
1345 1422
1346 if (pdev) { 1423 if (pdev) {
1347 pci_set_drvdata(pdev, dev); 1424 pci_set_drvdata(pdev, dev);
@@ -1359,6 +1436,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1359 1436
1360 return 0; 1437 return 0;
1361 1438
1439err_free_ring:
1440 pcnet32_free_ring(dev);
1362err_free_consistent: 1441err_free_consistent:
1363 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 1442 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
1364err_free_netdev: 1443err_free_netdev:
@@ -1369,6 +1448,86 @@ err_release_region:
1369} 1448}
1370 1449
1371 1450
1451static int pcnet32_alloc_ring(struct net_device *dev)
1452{
1453 struct pcnet32_private *lp = dev->priv;
1454
1455 if ((lp->tx_ring = pci_alloc_consistent(lp->pci_dev, sizeof(struct pcnet32_tx_head) * lp->tx_ring_size,
1456 &lp->tx_ring_dma_addr)) == NULL) {
1457 if (pcnet32_debug & NETIF_MSG_DRV)
1458 printk(KERN_ERR PFX "Consistent memory allocation failed.\n");
1459 return -ENOMEM;
1460 }
1461
1462 if ((lp->rx_ring = pci_alloc_consistent(lp->pci_dev, sizeof(struct pcnet32_rx_head) * lp->rx_ring_size,
1463 &lp->rx_ring_dma_addr)) == NULL) {
1464 if (pcnet32_debug & NETIF_MSG_DRV)
1465 printk(KERN_ERR PFX "Consistent memory allocation failed.\n");
1466 return -ENOMEM;
1467 }
1468
1469 if (!(lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size, GFP_ATOMIC))) {
1470 if (pcnet32_debug & NETIF_MSG_DRV)
1471 printk(KERN_ERR PFX "Memory allocation failed.\n");
1472 return -ENOMEM;
1473 }
1474 memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
1475
1476 if (!(lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size, GFP_ATOMIC))) {
1477 if (pcnet32_debug & NETIF_MSG_DRV)
1478 printk(KERN_ERR PFX "Memory allocation failed.\n");
1479 return -ENOMEM;
1480 }
1481 memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
1482
1483 if (!(lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size, GFP_ATOMIC))) {
1484 if (pcnet32_debug & NETIF_MSG_DRV)
1485 printk(KERN_ERR PFX "Memory allocation failed.\n");
1486 return -ENOMEM;
1487 }
1488 memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
1489
1490 if (!(lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size, GFP_ATOMIC))) {
1491 if (pcnet32_debug & NETIF_MSG_DRV)
1492 printk(KERN_ERR PFX "Memory allocation failed.\n");
1493 return -ENOMEM;
1494 }
1495 memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);
1496
1497 return 0;
1498}
1499
1500
1501static void pcnet32_free_ring(struct net_device *dev)
1502{
1503 struct pcnet32_private *lp = dev->priv;
1504
1505 kfree(lp->tx_skbuff);
1506 lp->tx_skbuff = NULL;
1507
1508 kfree(lp->rx_skbuff);
1509 lp->rx_skbuff = NULL;
1510
1511 kfree(lp->tx_dma_addr);
1512 lp->tx_dma_addr = NULL;
1513
1514 kfree(lp->rx_dma_addr);
1515 lp->rx_dma_addr = NULL;
1516
1517 if (lp->tx_ring) {
1518 pci_free_consistent(lp->pci_dev, sizeof(struct pcnet32_tx_head) * lp->tx_ring_size,
1519 lp->tx_ring, lp->tx_ring_dma_addr);
1520 lp->tx_ring = NULL;
1521 }
1522
1523 if (lp->rx_ring) {
1524 pci_free_consistent(lp->pci_dev, sizeof(struct pcnet32_rx_head) * lp->rx_ring_size,
1525 lp->rx_ring, lp->rx_ring_dma_addr);
1526 lp->rx_ring = NULL;
1527 }
1528}
1529
1530
1372static int 1531static int
1373pcnet32_open(struct net_device *dev) 1532pcnet32_open(struct net_device *dev)
1374{ 1533{
@@ -1400,8 +1559,8 @@ pcnet32_open(struct net_device *dev)
1400 if (netif_msg_ifup(lp)) 1559 if (netif_msg_ifup(lp))
1401 printk(KERN_DEBUG "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n", 1560 printk(KERN_DEBUG "%s: pcnet32_open() irq %d tx/rx rings %#x/%#x init %#x.\n",
1402 dev->name, dev->irq, 1561 dev->name, dev->irq,
1403 (u32) (lp->dma_addr + offsetof(struct pcnet32_private, tx_ring)), 1562 (u32) (lp->tx_ring_dma_addr),
1404 (u32) (lp->dma_addr + offsetof(struct pcnet32_private, rx_ring)), 1563 (u32) (lp->rx_ring_dma_addr),
1405 (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block))); 1564 (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block)));
1406 1565
1407 /* set/reset autoselect bit */ 1566 /* set/reset autoselect bit */
@@ -1521,7 +1680,7 @@ pcnet32_open(struct net_device *dev)
1521 1680
1522err_free_ring: 1681err_free_ring:
1523 /* free any allocated skbuffs */ 1682 /* free any allocated skbuffs */
1524 for (i = 0; i < RX_RING_SIZE; i++) { 1683 for (i = 0; i < lp->rx_ring_size; i++) {
1525 lp->rx_ring[i].status = 0; 1684 lp->rx_ring[i].status = 0;
1526 if (lp->rx_skbuff[i]) { 1685 if (lp->rx_skbuff[i]) {
1527 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i], PKT_BUF_SZ-2, 1686 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i], PKT_BUF_SZ-2,
@@ -1531,6 +1690,9 @@ err_free_ring:
1531 lp->rx_skbuff[i] = NULL; 1690 lp->rx_skbuff[i] = NULL;
1532 lp->rx_dma_addr[i] = 0; 1691 lp->rx_dma_addr[i] = 0;
1533 } 1692 }
1693
1694 pcnet32_free_ring(dev);
1695
1534 /* 1696 /*
1535 * Switch back to 16bit mode to avoid problems with dumb 1697 * Switch back to 16bit mode to avoid problems with dumb
1536 * DOS packet driver after a warm reboot 1698 * DOS packet driver after a warm reboot
@@ -1562,7 +1724,7 @@ pcnet32_purge_tx_ring(struct net_device *dev)
1562 struct pcnet32_private *lp = dev->priv; 1724 struct pcnet32_private *lp = dev->priv;
1563 int i; 1725 int i;
1564 1726
1565 for (i = 0; i < TX_RING_SIZE; i++) { 1727 for (i = 0; i < lp->tx_ring_size; i++) {
1566 lp->tx_ring[i].status = 0; /* CPU owns buffer */ 1728 lp->tx_ring[i].status = 0; /* CPU owns buffer */
1567 wmb(); /* Make sure adapter sees owner change */ 1729 wmb(); /* Make sure adapter sees owner change */
1568 if (lp->tx_skbuff[i]) { 1730 if (lp->tx_skbuff[i]) {
@@ -1587,7 +1749,7 @@ pcnet32_init_ring(struct net_device *dev)
1587 lp->cur_rx = lp->cur_tx = 0; 1749 lp->cur_rx = lp->cur_tx = 0;
1588 lp->dirty_rx = lp->dirty_tx = 0; 1750 lp->dirty_rx = lp->dirty_tx = 0;
1589 1751
1590 for (i = 0; i < RX_RING_SIZE; i++) { 1752 for (i = 0; i < lp->rx_ring_size; i++) {
1591 struct sk_buff *rx_skbuff = lp->rx_skbuff[i]; 1753 struct sk_buff *rx_skbuff = lp->rx_skbuff[i];
1592 if (rx_skbuff == NULL) { 1754 if (rx_skbuff == NULL) {
1593 if (!(rx_skbuff = lp->rx_skbuff[i] = dev_alloc_skb (PKT_BUF_SZ))) { 1755 if (!(rx_skbuff = lp->rx_skbuff[i] = dev_alloc_skb (PKT_BUF_SZ))) {
@@ -1611,20 +1773,18 @@ pcnet32_init_ring(struct net_device *dev)
1611 } 1773 }
1612 /* The Tx buffer address is filled in as needed, but we do need to clear 1774 /* The Tx buffer address is filled in as needed, but we do need to clear
1613 * the upper ownership bit. */ 1775 * the upper ownership bit. */
1614 for (i = 0; i < TX_RING_SIZE; i++) { 1776 for (i = 0; i < lp->tx_ring_size; i++) {
1615 lp->tx_ring[i].status = 0; /* CPU owns buffer */ 1777 lp->tx_ring[i].status = 0; /* CPU owns buffer */
1616 wmb(); /* Make sure adapter sees owner change */ 1778 wmb(); /* Make sure adapter sees owner change */
1617 lp->tx_ring[i].base = 0; 1779 lp->tx_ring[i].base = 0;
1618 lp->tx_dma_addr[i] = 0; 1780 lp->tx_dma_addr[i] = 0;
1619 } 1781 }
1620 1782
1621 lp->init_block.tlen_rlen = le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS); 1783 lp->init_block.tlen_rlen = le16_to_cpu(lp->tx_len_bits | lp->rx_len_bits);
1622 for (i = 0; i < 6; i++) 1784 for (i = 0; i < 6; i++)
1623 lp->init_block.phys_addr[i] = dev->dev_addr[i]; 1785 lp->init_block.phys_addr[i] = dev->dev_addr[i];
1624 lp->init_block.rx_ring = (u32)le32_to_cpu(lp->dma_addr + 1786 lp->init_block.rx_ring = (u32)le32_to_cpu(lp->rx_ring_dma_addr);
1625 offsetof(struct pcnet32_private, rx_ring)); 1787 lp->init_block.tx_ring = (u32)le32_to_cpu(lp->tx_ring_dma_addr);
1626 lp->init_block.tx_ring = (u32)le32_to_cpu(lp->dma_addr +
1627 offsetof(struct pcnet32_private, tx_ring));
1628 wmb(); /* Make sure all changes are visible */ 1788 wmb(); /* Make sure all changes are visible */
1629 return 0; 1789 return 0;
1630} 1790}
@@ -1682,13 +1842,13 @@ pcnet32_tx_timeout (struct net_device *dev)
1682 printk(KERN_DEBUG " Ring data dump: dirty_tx %d cur_tx %d%s cur_rx %d.", 1842 printk(KERN_DEBUG " Ring data dump: dirty_tx %d cur_tx %d%s cur_rx %d.",
1683 lp->dirty_tx, lp->cur_tx, lp->tx_full ? " (full)" : "", 1843 lp->dirty_tx, lp->cur_tx, lp->tx_full ? " (full)" : "",
1684 lp->cur_rx); 1844 lp->cur_rx);
1685 for (i = 0 ; i < RX_RING_SIZE; i++) 1845 for (i = 0 ; i < lp->rx_ring_size; i++)
1686 printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ", 1846 printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ",
1687 le32_to_cpu(lp->rx_ring[i].base), 1847 le32_to_cpu(lp->rx_ring[i].base),
1688 (-le16_to_cpu(lp->rx_ring[i].buf_length)) & 0xffff, 1848 (-le16_to_cpu(lp->rx_ring[i].buf_length)) & 0xffff,
1689 le32_to_cpu(lp->rx_ring[i].msg_length), 1849 le32_to_cpu(lp->rx_ring[i].msg_length),
1690 le16_to_cpu(lp->rx_ring[i].status)); 1850 le16_to_cpu(lp->rx_ring[i].status));
1691 for (i = 0 ; i < TX_RING_SIZE; i++) 1851 for (i = 0 ; i < lp->tx_ring_size; i++)
1692 printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ", 1852 printk("%s %08x %04x %08x %04x", i & 1 ? "" : "\n ",
1693 le32_to_cpu(lp->tx_ring[i].base), 1853 le32_to_cpu(lp->tx_ring[i].base),
1694 (-le16_to_cpu(lp->tx_ring[i].length)) & 0xffff, 1854 (-le16_to_cpu(lp->tx_ring[i].length)) & 0xffff,
@@ -1729,7 +1889,7 @@ pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
1729 /* Fill in a Tx ring entry */ 1889 /* Fill in a Tx ring entry */
1730 1890
1731 /* Mask to ring buffer boundary. */ 1891 /* Mask to ring buffer boundary. */
1732 entry = lp->cur_tx & TX_RING_MOD_MASK; 1892 entry = lp->cur_tx & lp->tx_mod_mask;
1733 1893
1734 /* Caution: the write order is important here, set the status 1894 /* Caution: the write order is important here, set the status
1735 * with the "ownership" bits last. */ 1895 * with the "ownership" bits last. */
@@ -1753,7 +1913,7 @@ pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
1753 1913
1754 dev->trans_start = jiffies; 1914 dev->trans_start = jiffies;
1755 1915
1756 if (lp->tx_ring[(entry+1) & TX_RING_MOD_MASK].base != 0) { 1916 if (lp->tx_ring[(entry+1) & lp->tx_mod_mask].base != 0) {
1757 lp->tx_full = 1; 1917 lp->tx_full = 1;
1758 netif_stop_queue(dev); 1918 netif_stop_queue(dev);
1759 } 1919 }
@@ -1806,7 +1966,7 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
1806 int delta; 1966 int delta;
1807 1967
1808 while (dirty_tx != lp->cur_tx) { 1968 while (dirty_tx != lp->cur_tx) {
1809 int entry = dirty_tx & TX_RING_MOD_MASK; 1969 int entry = dirty_tx & lp->tx_mod_mask;
1810 int status = (short)le16_to_cpu(lp->tx_ring[entry].status); 1970 int status = (short)le16_to_cpu(lp->tx_ring[entry].status);
1811 1971
1812 if (status < 0) 1972 if (status < 0)
@@ -1864,18 +2024,18 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
1864 dirty_tx++; 2024 dirty_tx++;
1865 } 2025 }
1866 2026
1867 delta = (lp->cur_tx - dirty_tx) & (TX_RING_MOD_MASK + TX_RING_SIZE); 2027 delta = (lp->cur_tx - dirty_tx) & (lp->tx_mod_mask + lp->tx_ring_size);
1868 if (delta > TX_RING_SIZE) { 2028 if (delta > lp->tx_ring_size) {
1869 if (netif_msg_drv(lp)) 2029 if (netif_msg_drv(lp))
1870 printk(KERN_ERR "%s: out-of-sync dirty pointer, %d vs. %d, full=%d.\n", 2030 printk(KERN_ERR "%s: out-of-sync dirty pointer, %d vs. %d, full=%d.\n",
1871 dev->name, dirty_tx, lp->cur_tx, lp->tx_full); 2031 dev->name, dirty_tx, lp->cur_tx, lp->tx_full);
1872 dirty_tx += TX_RING_SIZE; 2032 dirty_tx += lp->tx_ring_size;
1873 delta -= TX_RING_SIZE; 2033 delta -= lp->tx_ring_size;
1874 } 2034 }
1875 2035
1876 if (lp->tx_full && 2036 if (lp->tx_full &&
1877 netif_queue_stopped(dev) && 2037 netif_queue_stopped(dev) &&
1878 delta < TX_RING_SIZE - 2) { 2038 delta < lp->tx_ring_size - 2) {
1879 /* The ring is no longer full, clear tbusy. */ 2039 /* The ring is no longer full, clear tbusy. */
1880 lp->tx_full = 0; 2040 lp->tx_full = 0;
1881 netif_wake_queue (dev); 2041 netif_wake_queue (dev);
@@ -1932,8 +2092,8 @@ static int
1932pcnet32_rx(struct net_device *dev) 2092pcnet32_rx(struct net_device *dev)
1933{ 2093{
1934 struct pcnet32_private *lp = dev->priv; 2094 struct pcnet32_private *lp = dev->priv;
1935 int entry = lp->cur_rx & RX_RING_MOD_MASK; 2095 int entry = lp->cur_rx & lp->rx_mod_mask;
1936 int boguscnt = RX_RING_SIZE / 2; 2096 int boguscnt = lp->rx_ring_size / 2;
1937 2097
1938 /* If we own the next entry, it's a new packet. Send it up. */ 2098 /* If we own the next entry, it's a new packet. Send it up. */
1939 while ((short)le16_to_cpu(lp->rx_ring[entry].status) >= 0) { 2099 while ((short)le16_to_cpu(lp->rx_ring[entry].status) >= 0) {
@@ -1998,12 +2158,12 @@ pcnet32_rx(struct net_device *dev)
1998 if (netif_msg_drv(lp)) 2158 if (netif_msg_drv(lp))
1999 printk(KERN_ERR "%s: Memory squeeze, deferring packet.\n", 2159 printk(KERN_ERR "%s: Memory squeeze, deferring packet.\n",
2000 dev->name); 2160 dev->name);
2001 for (i = 0; i < RX_RING_SIZE; i++) 2161 for (i = 0; i < lp->rx_ring_size; i++)
2002 if ((short)le16_to_cpu(lp->rx_ring[(entry+i) 2162 if ((short)le16_to_cpu(lp->rx_ring[(entry+i)
2003 & RX_RING_MOD_MASK].status) < 0) 2163 & lp->rx_mod_mask].status) < 0)
2004 break; 2164 break;
2005 2165
2006 if (i > RX_RING_SIZE -2) { 2166 if (i > lp->rx_ring_size -2) {
2007 lp->stats.rx_dropped++; 2167 lp->stats.rx_dropped++;
2008 lp->rx_ring[entry].status |= le16_to_cpu(0x8000); 2168 lp->rx_ring[entry].status |= le16_to_cpu(0x8000);
2009 wmb(); /* Make sure adapter sees owner change */ 2169 wmb(); /* Make sure adapter sees owner change */
@@ -2041,7 +2201,7 @@ pcnet32_rx(struct net_device *dev)
2041 lp->rx_ring[entry].buf_length = le16_to_cpu(2-PKT_BUF_SZ); 2201 lp->rx_ring[entry].buf_length = le16_to_cpu(2-PKT_BUF_SZ);
2042 wmb(); /* Make sure owner changes after all others are visible */ 2202 wmb(); /* Make sure owner changes after all others are visible */
2043 lp->rx_ring[entry].status |= le16_to_cpu(0x8000); 2203 lp->rx_ring[entry].status |= le16_to_cpu(0x8000);
2044 entry = (++lp->cur_rx) & RX_RING_MOD_MASK; 2204 entry = (++lp->cur_rx) & lp->rx_mod_mask;
2045 if (--boguscnt <= 0) break; /* don't stay in loop forever */ 2205 if (--boguscnt <= 0) break; /* don't stay in loop forever */
2046 } 2206 }
2047 2207
@@ -2084,7 +2244,7 @@ pcnet32_close(struct net_device *dev)
2084 spin_lock_irqsave(&lp->lock, flags); 2244 spin_lock_irqsave(&lp->lock, flags);
2085 2245
2086 /* free all allocated skbuffs */ 2246 /* free all allocated skbuffs */
2087 for (i = 0; i < RX_RING_SIZE; i++) { 2247 for (i = 0; i < lp->rx_ring_size; i++) {
2088 lp->rx_ring[i].status = 0; 2248 lp->rx_ring[i].status = 0;
2089 wmb(); /* Make sure adapter sees owner change */ 2249 wmb(); /* Make sure adapter sees owner change */
2090 if (lp->rx_skbuff[i]) { 2250 if (lp->rx_skbuff[i]) {
@@ -2096,7 +2256,7 @@ pcnet32_close(struct net_device *dev)
2096 lp->rx_dma_addr[i] = 0; 2256 lp->rx_dma_addr[i] = 0;
2097 } 2257 }
2098 2258
2099 for (i = 0; i < TX_RING_SIZE; i++) { 2259 for (i = 0; i < lp->tx_ring_size; i++) {
2100 lp->tx_ring[i].status = 0; /* CPU owns buffer */ 2260 lp->tx_ring[i].status = 0; /* CPU owns buffer */
2101 wmb(); /* Make sure adapter sees owner change */ 2261 wmb(); /* Make sure adapter sees owner change */
2102 if (lp->tx_skbuff[i]) { 2262 if (lp->tx_skbuff[i]) {
@@ -2265,6 +2425,7 @@ static void __devexit pcnet32_remove_one(struct pci_dev *pdev)
2265 struct pcnet32_private *lp = dev->priv; 2425 struct pcnet32_private *lp = dev->priv;
2266 2426
2267 unregister_netdev(dev); 2427 unregister_netdev(dev);
2428 pcnet32_free_ring(dev);
2268 release_region(dev->base_addr, PCNET32_TOTAL_SIZE); 2429 release_region(dev->base_addr, PCNET32_TOTAL_SIZE);
2269 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 2430 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
2270 free_netdev(dev); 2431 free_netdev(dev);
@@ -2340,6 +2501,7 @@ static void __exit pcnet32_cleanup_module(void)
2340 struct pcnet32_private *lp = pcnet32_dev->priv; 2501 struct pcnet32_private *lp = pcnet32_dev->priv;
2341 next_dev = lp->next; 2502 next_dev = lp->next;
2342 unregister_netdev(pcnet32_dev); 2503 unregister_netdev(pcnet32_dev);
2504 pcnet32_free_ring(pcnet32_dev);
2343 release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE); 2505 release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE);
2344 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); 2506 pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
2345 free_netdev(pcnet32_dev); 2507 free_netdev(pcnet32_dev);
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 14f4de1a8180..c782a6329805 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -12,14 +12,6 @@ config PHYLIB
12 devices. This option provides infrastructure for 12 devices. This option provides infrastructure for
13 managing PHY devices. 13 managing PHY devices.
14 14
15config PHYCONTROL
16 bool " Support for automatically handling PHY state changes"
17 depends on PHYLIB
18 help
19 Adds code to perform all the work for keeping PHY link
20 state (speed/duplex/etc) up-to-date. Also handles
21 interrupts.
22
23comment "MII PHY device drivers" 15comment "MII PHY device drivers"
24 depends on PHYLIB 16 depends on PHYLIB
25 17
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 90630672703d..ad93b0da87f0 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -133,13 +133,9 @@ static int mdio_bus_suspend(struct device * dev, pm_message_t state)
133 int ret = 0; 133 int ret = 0;
134 struct device_driver *drv = dev->driver; 134 struct device_driver *drv = dev->driver;
135 135
136 if (drv && drv->suspend) { 136 if (drv && drv->suspend)
137 ret = drv->suspend(dev, state, SUSPEND_DISABLE); 137 ret = drv->suspend(dev, state);
138 if (ret == 0) 138
139 ret = drv->suspend(dev, state, SUSPEND_SAVE_STATE);
140 if (ret == 0)
141 ret = drv->suspend(dev, state, SUSPEND_POWER_DOWN);
142 }
143 return ret; 139 return ret;
144} 140}
145 141
@@ -148,13 +144,9 @@ static int mdio_bus_resume(struct device * dev)
148 int ret = 0; 144 int ret = 0;
149 struct device_driver *drv = dev->driver; 145 struct device_driver *drv = dev->driver;
150 146
151 if (drv && drv->resume) { 147 if (drv && drv->resume)
152 ret = drv->resume(dev, RESUME_POWER_ON); 148 ret = drv->resume(dev);
153 if (ret == 0) 149
154 ret = drv->resume(dev, RESUME_RESTORE_STATE);
155 if (ret == 0)
156 ret = drv->resume(dev, RESUME_ENABLE);
157 }
158 return ret; 150 return ret;
159} 151}
160 152
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d9e11f93bf3a..9209da9dde0d 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -242,10 +242,6 @@ EXPORT_SYMBOL(phy_sanitize_settings);
242 * choose the next best ones from the ones selected, so we don't 242 * choose the next best ones from the ones selected, so we don't
243 * care if ethtool tries to give us bad values 243 * care if ethtool tries to give us bad values
244 * 244 *
245 * A note about the PHYCONTROL Layer. If you turn off
246 * CONFIG_PHYCONTROL, you will need to read the PHY status
247 * registers after this function completes, and update your
248 * controller manually.
249 */ 245 */
250int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd) 246int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
251{ 247{
@@ -380,7 +376,6 @@ int phy_start_aneg(struct phy_device *phydev)
380 376
381 err = phydev->drv->config_aneg(phydev); 377 err = phydev->drv->config_aneg(phydev);
382 378
383#ifdef CONFIG_PHYCONTROL
384 if (err < 0) 379 if (err < 0)
385 goto out_unlock; 380 goto out_unlock;
386 381
@@ -395,14 +390,12 @@ int phy_start_aneg(struct phy_device *phydev)
395 } 390 }
396 391
397out_unlock: 392out_unlock:
398#endif
399 spin_unlock(&phydev->lock); 393 spin_unlock(&phydev->lock);
400 return err; 394 return err;
401} 395}
402EXPORT_SYMBOL(phy_start_aneg); 396EXPORT_SYMBOL(phy_start_aneg);
403 397
404 398
405#ifdef CONFIG_PHYCONTROL
406static void phy_change(void *data); 399static void phy_change(void *data);
407static void phy_timer(unsigned long data); 400static void phy_timer(unsigned long data);
408 401
@@ -868,4 +861,3 @@ static void phy_timer(unsigned long data)
868 mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ); 861 mod_timer(&phydev->phy_timer, jiffies + PHY_STATE_TIME * HZ);
869} 862}
870 863
871#endif /* CONFIG_PHYCONTROL */
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 33f7bdb5857c..6da1aa0706a1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -101,7 +101,6 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
101 return dev; 101 return dev;
102} 102}
103 103
104#ifdef CONFIG_PHYCONTROL
105/* phy_prepare_link: 104/* phy_prepare_link:
106 * 105 *
107 * description: Tells the PHY infrastructure to handle the 106 * description: Tells the PHY infrastructure to handle the
@@ -160,8 +159,6 @@ void phy_disconnect(struct phy_device *phydev)
160} 159}
161EXPORT_SYMBOL(phy_disconnect); 160EXPORT_SYMBOL(phy_disconnect);
162 161
163#endif /* CONFIG_PHYCONTROL */
164
165/* phy_attach: 162/* phy_attach:
166 * 163 *
167 * description: Called by drivers to attach to a particular PHY 164 * description: Called by drivers to attach to a particular PHY
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 0df7e92b0bf8..d3c9958b00d0 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -863,7 +863,7 @@ static int __init ppp_init(void)
863 err = PTR_ERR(ppp_class); 863 err = PTR_ERR(ppp_class);
864 goto out_chrdev; 864 goto out_chrdev;
865 } 865 }
866 class_device_create(ppp_class, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 866 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
867 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0), 867 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
868 S_IFCHR|S_IRUSR|S_IWUSR, "ppp"); 868 S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
869 if (err) 869 if (err)
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index afb3f186b884..159b56a56ef4 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1027,6 +1027,7 @@ static struct ethtool_ops rtl8169_ethtool_ops = {
1027 .get_strings = rtl8169_get_strings, 1027 .get_strings = rtl8169_get_strings,
1028 .get_stats_count = rtl8169_get_stats_count, 1028 .get_stats_count = rtl8169_get_stats_count,
1029 .get_ethtool_stats = rtl8169_get_ethtool_stats, 1029 .get_ethtool_stats = rtl8169_get_ethtool_stats,
1030 .get_perm_addr = ethtool_op_get_perm_addr,
1030}; 1031};
1031 1032
1032static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, int bitnum, 1033static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, int bitnum,
@@ -1511,6 +1512,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1511 /* Get MAC address. FIXME: read EEPROM */ 1512 /* Get MAC address. FIXME: read EEPROM */
1512 for (i = 0; i < MAC_ADDR_LEN; i++) 1513 for (i = 0; i < MAC_ADDR_LEN; i++)
1513 dev->dev_addr[i] = RTL_R8(MAC0 + i); 1514 dev->dev_addr[i] = RTL_R8(MAC0 + i);
1515 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1514 1516
1515 dev->open = rtl8169_open; 1517 dev->open = rtl8169_open;
1516 dev->hard_start_xmit = rtl8169_start_xmit; 1518 dev->hard_start_xmit = rtl8169_start_xmit;
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
new file mode 100644
index 000000000000..12cde0604580
--- /dev/null
+++ b/drivers/net/rionet.c
@@ -0,0 +1,574 @@
1/*
2 * rionet - Ethernet driver over RapidIO messaging services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/dma-mapping.h>
16#include <linux/delay.h>
17#include <linux/rio.h>
18#include <linux/rio_drv.h>
19#include <linux/rio_ids.h>
20
21#include <linux/netdevice.h>
22#include <linux/etherdevice.h>
23#include <linux/skbuff.h>
24#include <linux/crc32.h>
25#include <linux/ethtool.h>
26
27#define DRV_NAME "rionet"
28#define DRV_VERSION "0.2"
29#define DRV_AUTHOR "Matt Porter <mporter@kernel.crashing.org>"
30#define DRV_DESC "Ethernet over RapidIO"
31
32MODULE_AUTHOR(DRV_AUTHOR);
33MODULE_DESCRIPTION(DRV_DESC);
34MODULE_LICENSE("GPL");
35
36#define RIONET_DEFAULT_MSGLEVEL \
37 (NETIF_MSG_DRV | \
38 NETIF_MSG_LINK | \
39 NETIF_MSG_RX_ERR | \
40 NETIF_MSG_TX_ERR)
41
42#define RIONET_DOORBELL_JOIN 0x1000
43#define RIONET_DOORBELL_LEAVE 0x1001
44
45#define RIONET_MAILBOX 0
46
47#define RIONET_TX_RING_SIZE CONFIG_RIONET_TX_SIZE
48#define RIONET_RX_RING_SIZE CONFIG_RIONET_RX_SIZE
49
50static LIST_HEAD(rionet_peers);
51
52struct rionet_private {
53 struct rio_mport *mport;
54 struct sk_buff *rx_skb[RIONET_RX_RING_SIZE];
55 struct sk_buff *tx_skb[RIONET_TX_RING_SIZE];
56 struct net_device_stats stats;
57 int rx_slot;
58 int tx_slot;
59 int tx_cnt;
60 int ack_slot;
61 spinlock_t lock;
62 spinlock_t tx_lock;
63 u32 msg_enable;
64};
65
66struct rionet_peer {
67 struct list_head node;
68 struct rio_dev *rdev;
69 struct resource *res;
70};
71
72static int rionet_check = 0;
73static int rionet_capable = 1;
74
75/*
76 * This is a fast lookup table for for translating TX
77 * Ethernet packets into a destination RIO device. It
78 * could be made into a hash table to save memory depending
79 * on system trade-offs.
80 */
81static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
82
83#define is_rionet_capable(pef, src_ops, dst_ops) \
84 ((pef & RIO_PEF_INB_MBOX) && \
85 (pef & RIO_PEF_INB_DOORBELL) && \
86 (src_ops & RIO_SRC_OPS_DOORBELL) && \
87 (dst_ops & RIO_DST_OPS_DOORBELL))
88#define dev_rionet_capable(dev) \
89 is_rionet_capable(dev->pef, dev->src_ops, dev->dst_ops)
90
91#define RIONET_MAC_MATCH(x) (*(u32 *)x == 0x00010001)
92#define RIONET_GET_DESTID(x) (*(u16 *)(x + 4))
93
94static struct net_device_stats *rionet_stats(struct net_device *ndev)
95{
96 struct rionet_private *rnet = ndev->priv;
97 return &rnet->stats;
98}
99
100static int rionet_rx_clean(struct net_device *ndev)
101{
102 int i;
103 int error = 0;
104 struct rionet_private *rnet = ndev->priv;
105 void *data;
106
107 i = rnet->rx_slot;
108
109 do {
110 if (!rnet->rx_skb[i])
111 continue;
112
113 if (!(data = rio_get_inb_message(rnet->mport, RIONET_MAILBOX)))
114 break;
115
116 rnet->rx_skb[i]->data = data;
117 skb_put(rnet->rx_skb[i], RIO_MAX_MSG_SIZE);
118 rnet->rx_skb[i]->dev = ndev;
119 rnet->rx_skb[i]->protocol =
120 eth_type_trans(rnet->rx_skb[i], ndev);
121 error = netif_rx(rnet->rx_skb[i]);
122
123 if (error == NET_RX_DROP) {
124 rnet->stats.rx_dropped++;
125 } else if (error == NET_RX_BAD) {
126 if (netif_msg_rx_err(rnet))
127 printk(KERN_WARNING "%s: bad rx packet\n",
128 DRV_NAME);
129 rnet->stats.rx_errors++;
130 } else {
131 rnet->stats.rx_packets++;
132 rnet->stats.rx_bytes += RIO_MAX_MSG_SIZE;
133 }
134
135 } while ((i = (i + 1) % RIONET_RX_RING_SIZE) != rnet->rx_slot);
136
137 return i;
138}
139
140static void rionet_rx_fill(struct net_device *ndev, int end)
141{
142 int i;
143 struct rionet_private *rnet = ndev->priv;
144
145 i = rnet->rx_slot;
146 do {
147 rnet->rx_skb[i] = dev_alloc_skb(RIO_MAX_MSG_SIZE);
148
149 if (!rnet->rx_skb[i])
150 break;
151
152 rio_add_inb_buffer(rnet->mport, RIONET_MAILBOX,
153 rnet->rx_skb[i]->data);
154 } while ((i = (i + 1) % RIONET_RX_RING_SIZE) != end);
155
156 rnet->rx_slot = i;
157}
158
159static int rionet_queue_tx_msg(struct sk_buff *skb, struct net_device *ndev,
160 struct rio_dev *rdev)
161{
162 struct rionet_private *rnet = ndev->priv;
163
164 rio_add_outb_message(rnet->mport, rdev, 0, skb->data, skb->len);
165 rnet->tx_skb[rnet->tx_slot] = skb;
166
167 rnet->stats.tx_packets++;
168 rnet->stats.tx_bytes += skb->len;
169
170 if (++rnet->tx_cnt == RIONET_TX_RING_SIZE)
171 netif_stop_queue(ndev);
172
173 ++rnet->tx_slot;
174 rnet->tx_slot &= (RIONET_TX_RING_SIZE - 1);
175
176 if (netif_msg_tx_queued(rnet))
177 printk(KERN_INFO "%s: queued skb %8.8x len %8.8x\n", DRV_NAME,
178 (u32) skb, skb->len);
179
180 return 0;
181}
182
183static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
184{
185 int i;
186 struct rionet_private *rnet = ndev->priv;
187 struct ethhdr *eth = (struct ethhdr *)skb->data;
188 u16 destid;
189 unsigned long flags;
190
191 local_irq_save(flags);
192 if (!spin_trylock(&rnet->tx_lock)) {
193 local_irq_restore(flags);
194 return NETDEV_TX_LOCKED;
195 }
196
197 if ((rnet->tx_cnt + 1) > RIONET_TX_RING_SIZE) {
198 netif_stop_queue(ndev);
199 spin_unlock_irqrestore(&rnet->tx_lock, flags);
200 printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n",
201 ndev->name);
202 return NETDEV_TX_BUSY;
203 }
204
205 if (eth->h_dest[0] & 0x01) {
206 for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++)
207 if (rionet_active[i])
208 rionet_queue_tx_msg(skb, ndev,
209 rionet_active[i]);
210 } else if (RIONET_MAC_MATCH(eth->h_dest)) {
211 destid = RIONET_GET_DESTID(eth->h_dest);
212 if (rionet_active[destid])
213 rionet_queue_tx_msg(skb, ndev, rionet_active[destid]);
214 }
215
216 spin_unlock_irqrestore(&rnet->tx_lock, flags);
217
218 return 0;
219}
220
221static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u16 tid,
222 u16 info)
223{
224 struct net_device *ndev = dev_id;
225 struct rionet_private *rnet = ndev->priv;
226 struct rionet_peer *peer;
227
228 if (netif_msg_intr(rnet))
229 printk(KERN_INFO "%s: doorbell sid %4.4x tid %4.4x info %4.4x",
230 DRV_NAME, sid, tid, info);
231 if (info == RIONET_DOORBELL_JOIN) {
232 if (!rionet_active[sid]) {
233 list_for_each_entry(peer, &rionet_peers, node) {
234 if (peer->rdev->destid == sid)
235 rionet_active[sid] = peer->rdev;
236 }
237 rio_mport_send_doorbell(mport, sid,
238 RIONET_DOORBELL_JOIN);
239 }
240 } else if (info == RIONET_DOORBELL_LEAVE) {
241 rionet_active[sid] = NULL;
242 } else {
243 if (netif_msg_intr(rnet))
244 printk(KERN_WARNING "%s: unhandled doorbell\n",
245 DRV_NAME);
246 }
247}
248
249static void rionet_inb_msg_event(struct rio_mport *mport, void *dev_id, int mbox, int slot)
250{
251 int n;
252 struct net_device *ndev = dev_id;
253 struct rionet_private *rnet = (struct rionet_private *)ndev->priv;
254
255 if (netif_msg_intr(rnet))
256 printk(KERN_INFO "%s: inbound message event, mbox %d slot %d\n",
257 DRV_NAME, mbox, slot);
258
259 spin_lock(&rnet->lock);
260 if ((n = rionet_rx_clean(ndev)) != rnet->rx_slot)
261 rionet_rx_fill(ndev, n);
262 spin_unlock(&rnet->lock);
263}
264
265static void rionet_outb_msg_event(struct rio_mport *mport, void *dev_id, int mbox, int slot)
266{
267 struct net_device *ndev = dev_id;
268 struct rionet_private *rnet = ndev->priv;
269
270 spin_lock(&rnet->lock);
271
272 if (netif_msg_intr(rnet))
273 printk(KERN_INFO
274 "%s: outbound message event, mbox %d slot %d\n",
275 DRV_NAME, mbox, slot);
276
277 while (rnet->tx_cnt && (rnet->ack_slot != slot)) {
278 /* dma unmap single */
279 dev_kfree_skb_irq(rnet->tx_skb[rnet->ack_slot]);
280 rnet->tx_skb[rnet->ack_slot] = NULL;
281 ++rnet->ack_slot;
282 rnet->ack_slot &= (RIONET_TX_RING_SIZE - 1);
283 rnet->tx_cnt--;
284 }
285
286 if (rnet->tx_cnt < RIONET_TX_RING_SIZE)
287 netif_wake_queue(ndev);
288
289 spin_unlock(&rnet->lock);
290}
291
292static int rionet_open(struct net_device *ndev)
293{
294 int i, rc = 0;
295 struct rionet_peer *peer, *tmp;
296 u32 pwdcsr;
297 struct rionet_private *rnet = ndev->priv;
298
299 if (netif_msg_ifup(rnet))
300 printk(KERN_INFO "%s: open\n", DRV_NAME);
301
302 if ((rc = rio_request_inb_dbell(rnet->mport,
303 (void *)ndev,
304 RIONET_DOORBELL_JOIN,
305 RIONET_DOORBELL_LEAVE,
306 rionet_dbell_event)) < 0)
307 goto out;
308
309 if ((rc = rio_request_inb_mbox(rnet->mport,
310 (void *)ndev,
311 RIONET_MAILBOX,
312 RIONET_RX_RING_SIZE,
313 rionet_inb_msg_event)) < 0)
314 goto out;
315
316 if ((rc = rio_request_outb_mbox(rnet->mport,
317 (void *)ndev,
318 RIONET_MAILBOX,
319 RIONET_TX_RING_SIZE,
320 rionet_outb_msg_event)) < 0)
321 goto out;
322
323 /* Initialize inbound message ring */
324 for (i = 0; i < RIONET_RX_RING_SIZE; i++)
325 rnet->rx_skb[i] = NULL;
326 rnet->rx_slot = 0;
327 rionet_rx_fill(ndev, 0);
328
329 rnet->tx_slot = 0;
330 rnet->tx_cnt = 0;
331 rnet->ack_slot = 0;
332
333 netif_carrier_on(ndev);
334 netif_start_queue(ndev);
335
336 list_for_each_entry_safe(peer, tmp, &rionet_peers, node) {
337 if (!(peer->res = rio_request_outb_dbell(peer->rdev,
338 RIONET_DOORBELL_JOIN,
339 RIONET_DOORBELL_LEAVE)))
340 {
341 printk(KERN_ERR "%s: error requesting doorbells\n",
342 DRV_NAME);
343 continue;
344 }
345
346 /*
347 * If device has initialized inbound doorbells,
348 * send a join message
349 */
350 rio_read_config_32(peer->rdev, RIO_WRITE_PORT_CSR, &pwdcsr);
351 if (pwdcsr & RIO_DOORBELL_AVAIL)
352 rio_send_doorbell(peer->rdev, RIONET_DOORBELL_JOIN);
353 }
354
355 out:
356 return rc;
357}
358
359static int rionet_close(struct net_device *ndev)
360{
361 struct rionet_private *rnet = (struct rionet_private *)ndev->priv;
362 struct rionet_peer *peer, *tmp;
363 int i;
364
365 if (netif_msg_ifup(rnet))
366 printk(KERN_INFO "%s: close\n", DRV_NAME);
367
368 netif_stop_queue(ndev);
369 netif_carrier_off(ndev);
370
371 for (i = 0; i < RIONET_RX_RING_SIZE; i++)
372 if (rnet->rx_skb[i])
373 kfree_skb(rnet->rx_skb[i]);
374
375 list_for_each_entry_safe(peer, tmp, &rionet_peers, node) {
376 if (rionet_active[peer->rdev->destid]) {
377 rio_send_doorbell(peer->rdev, RIONET_DOORBELL_LEAVE);
378 rionet_active[peer->rdev->destid] = NULL;
379 }
380 rio_release_outb_dbell(peer->rdev, peer->res);
381 }
382
383 rio_release_inb_dbell(rnet->mport, RIONET_DOORBELL_JOIN,
384 RIONET_DOORBELL_LEAVE);
385 rio_release_inb_mbox(rnet->mport, RIONET_MAILBOX);
386 rio_release_outb_mbox(rnet->mport, RIONET_MAILBOX);
387
388 return 0;
389}
390
391static void rionet_remove(struct rio_dev *rdev)
392{
393 struct net_device *ndev = NULL;
394 struct rionet_peer *peer, *tmp;
395
396 unregister_netdev(ndev);
397 kfree(ndev);
398
399 list_for_each_entry_safe(peer, tmp, &rionet_peers, node) {
400 list_del(&peer->node);
401 kfree(peer);
402 }
403}
404
405static void rionet_get_drvinfo(struct net_device *ndev,
406 struct ethtool_drvinfo *info)
407{
408 struct rionet_private *rnet = ndev->priv;
409
410 strcpy(info->driver, DRV_NAME);
411 strcpy(info->version, DRV_VERSION);
412 strcpy(info->fw_version, "n/a");
413 strcpy(info->bus_info, rnet->mport->name);
414}
415
416static u32 rionet_get_msglevel(struct net_device *ndev)
417{
418 struct rionet_private *rnet = ndev->priv;
419
420 return rnet->msg_enable;
421}
422
423static void rionet_set_msglevel(struct net_device *ndev, u32 value)
424{
425 struct rionet_private *rnet = ndev->priv;
426
427 rnet->msg_enable = value;
428}
429
430static struct ethtool_ops rionet_ethtool_ops = {
431 .get_drvinfo = rionet_get_drvinfo,
432 .get_msglevel = rionet_get_msglevel,
433 .set_msglevel = rionet_set_msglevel,
434 .get_link = ethtool_op_get_link,
435};
436
437static int rionet_setup_netdev(struct rio_mport *mport)
438{
439 int rc = 0;
440 struct net_device *ndev = NULL;
441 struct rionet_private *rnet;
442 u16 device_id;
443
444 /* Allocate our net_device structure */
445 ndev = alloc_etherdev(sizeof(struct rionet_private));
446 if (ndev == NULL) {
447 printk(KERN_INFO "%s: could not allocate ethernet device.\n",
448 DRV_NAME);
449 rc = -ENOMEM;
450 goto out;
451 }
452
453 /* Set up private area */
454 rnet = (struct rionet_private *)ndev->priv;
455 rnet->mport = mport;
456
457 /* Set the default MAC address */
458 device_id = rio_local_get_device_id(mport);
459 ndev->dev_addr[0] = 0x00;
460 ndev->dev_addr[1] = 0x01;
461 ndev->dev_addr[2] = 0x00;
462 ndev->dev_addr[3] = 0x01;
463 ndev->dev_addr[4] = device_id >> 8;
464 ndev->dev_addr[5] = device_id & 0xff;
465
466 /* Fill in the driver function table */
467 ndev->open = &rionet_open;
468 ndev->hard_start_xmit = &rionet_start_xmit;
469 ndev->stop = &rionet_close;
470 ndev->get_stats = &rionet_stats;
471 ndev->mtu = RIO_MAX_MSG_SIZE - 14;
472 ndev->features = NETIF_F_LLTX;
473 SET_ETHTOOL_OPS(ndev, &rionet_ethtool_ops);
474
475 SET_MODULE_OWNER(ndev);
476
477 spin_lock_init(&rnet->lock);
478 spin_lock_init(&rnet->tx_lock);
479
480 rnet->msg_enable = RIONET_DEFAULT_MSGLEVEL;
481
482 rc = register_netdev(ndev);
483 if (rc != 0)
484 goto out;
485
486 printk("%s: %s %s Version %s, MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
487 ndev->name,
488 DRV_NAME,
489 DRV_DESC,
490 DRV_VERSION,
491 ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
492 ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
493
494 out:
495 return rc;
496}
497
498/*
499 * XXX Make multi-net safe
500 */
501static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id)
502{
503 int rc = -ENODEV;
504 u32 lpef, lsrc_ops, ldst_ops;
505 struct rionet_peer *peer;
506
507 /* If local device is not rionet capable, give up quickly */
508 if (!rionet_capable)
509 goto out;
510
511 /*
512 * First time through, make sure local device is rionet
513 * capable, setup netdev, and set flags so this is skipped
514 * on later probes
515 */
516 if (!rionet_check) {
517 rio_local_read_config_32(rdev->net->hport, RIO_PEF_CAR, &lpef);
518 rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR,
519 &lsrc_ops);
520 rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR,
521 &ldst_ops);
522 if (!is_rionet_capable(lpef, lsrc_ops, ldst_ops)) {
523 printk(KERN_ERR
524 "%s: local device is not network capable\n",
525 DRV_NAME);
526 rionet_check = 1;
527 rionet_capable = 0;
528 goto out;
529 }
530
531 rc = rionet_setup_netdev(rdev->net->hport);
532 rionet_check = 1;
533 }
534
535 /*
536 * If the remote device has mailbox/doorbell capabilities,
537 * add it to the peer list.
538 */
539 if (dev_rionet_capable(rdev)) {
540 if (!(peer = kmalloc(sizeof(struct rionet_peer), GFP_KERNEL))) {
541 rc = -ENOMEM;
542 goto out;
543 }
544 peer->rdev = rdev;
545 list_add_tail(&peer->node, &rionet_peers);
546 }
547
548 out:
549 return rc;
550}
551
552static struct rio_device_id rionet_id_table[] = {
553 {RIO_DEVICE(RIO_ANY_ID, RIO_ANY_ID)}
554};
555
556static struct rio_driver rionet_driver = {
557 .name = "rionet",
558 .id_table = rionet_id_table,
559 .probe = rionet_probe,
560 .remove = rionet_remove,
561};
562
563static int __init rionet_init(void)
564{
565 return rio_register_driver(&rionet_driver);
566}
567
568static void __exit rionet_exit(void)
569{
570 rio_unregister_driver(&rionet_driver);
571}
572
573module_init(rionet_init);
574module_exit(rionet_exit);
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h
index 7cefe5507b9e..00179bc3437f 100644
--- a/drivers/net/s2io-regs.h
+++ b/drivers/net/s2io-regs.h
@@ -814,6 +814,17 @@ typedef struct _XENA_dev_config {
814 u64 rxgxs_ber_0; /* CHANGED */ 814 u64 rxgxs_ber_0; /* CHANGED */
815 u64 rxgxs_ber_1; /* CHANGED */ 815 u64 rxgxs_ber_1; /* CHANGED */
816 816
817 u64 spi_control;
818#define SPI_CONTROL_KEY(key) vBIT(key,0,4)
819#define SPI_CONTROL_BYTECNT(cnt) vBIT(cnt,29,3)
820#define SPI_CONTROL_CMD(cmd) vBIT(cmd,32,8)
821#define SPI_CONTROL_ADDR(addr) vBIT(addr,40,24)
822#define SPI_CONTROL_SEL1 BIT(4)
823#define SPI_CONTROL_REQ BIT(7)
824#define SPI_CONTROL_NACK BIT(5)
825#define SPI_CONTROL_DONE BIT(6)
826 u64 spi_data;
827#define SPI_DATA_WRITE(data,len) vBIT(data,0,len)
817} XENA_dev_config_t; 828} XENA_dev_config_t;
818 829
819#define XENA_REG_SPACE sizeof(XENA_dev_config_t) 830#define XENA_REG_SPACE sizeof(XENA_dev_config_t)
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index dd451e099a4c..d303d162974f 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -65,9 +65,11 @@
65#include "s2io.h" 65#include "s2io.h"
66#include "s2io-regs.h" 66#include "s2io-regs.h"
67 67
68#define DRV_VERSION "Version 2.0.9.1"
69
68/* S2io Driver name & version. */ 70/* S2io Driver name & version. */
69static char s2io_driver_name[] = "Neterion"; 71static char s2io_driver_name[] = "Neterion";
70static char s2io_driver_version[] = "Version 2.0.8.1"; 72static char s2io_driver_version[] = DRV_VERSION;
71 73
72static inline int RXD_IS_UP2DT(RxD_t *rxdp) 74static inline int RXD_IS_UP2DT(RxD_t *rxdp)
73{ 75{
@@ -307,6 +309,8 @@ static unsigned int indicate_max_pkts;
307#endif 309#endif
308/* Frequency of Rx desc syncs expressed as power of 2 */ 310/* Frequency of Rx desc syncs expressed as power of 2 */
309static unsigned int rxsync_frequency = 3; 311static unsigned int rxsync_frequency = 3;
312/* Interrupt type. Values can be 0(INTA), 1(MSI), 2(MSI_X) */
313static unsigned int intr_type = 0;
310 314
311/* 315/*
312 * S2IO device table. 316 * S2IO device table.
@@ -1396,8 +1400,13 @@ static int init_nic(struct s2io_nic *nic)
1396 writeq(val64, &bar0->rti_data1_mem); 1400 writeq(val64, &bar0->rti_data1_mem);
1397 1401
1398 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) | 1402 val64 = RTI_DATA2_MEM_RX_UFC_A(0x1) |
1399 RTI_DATA2_MEM_RX_UFC_B(0x2) | 1403 RTI_DATA2_MEM_RX_UFC_B(0x2) ;
1400 RTI_DATA2_MEM_RX_UFC_C(0x40) | RTI_DATA2_MEM_RX_UFC_D(0x80); 1404 if (nic->intr_type == MSI_X)
1405 val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x20) | \
1406 RTI_DATA2_MEM_RX_UFC_D(0x40));
1407 else
1408 val64 |= (RTI_DATA2_MEM_RX_UFC_C(0x40) | \
1409 RTI_DATA2_MEM_RX_UFC_D(0x80));
1401 writeq(val64, &bar0->rti_data2_mem); 1410 writeq(val64, &bar0->rti_data2_mem);
1402 1411
1403 for (i = 0; i < config->rx_ring_num; i++) { 1412 for (i = 0; i < config->rx_ring_num; i++) {
@@ -1507,17 +1516,15 @@ static int init_nic(struct s2io_nic *nic)
1507#define LINK_UP_DOWN_INTERRUPT 1 1516#define LINK_UP_DOWN_INTERRUPT 1
1508#define MAC_RMAC_ERR_TIMER 2 1517#define MAC_RMAC_ERR_TIMER 2
1509 1518
1510#if defined(CONFIG_MSI_MODE) || defined(CONFIG_MSIX_MODE)
1511#define s2io_link_fault_indication(x) MAC_RMAC_ERR_TIMER
1512#else
1513int s2io_link_fault_indication(nic_t *nic) 1519int s2io_link_fault_indication(nic_t *nic)
1514{ 1520{
1521 if (nic->intr_type != INTA)
1522 return MAC_RMAC_ERR_TIMER;
1515 if (nic->device_type == XFRAME_II_DEVICE) 1523 if (nic->device_type == XFRAME_II_DEVICE)
1516 return LINK_UP_DOWN_INTERRUPT; 1524 return LINK_UP_DOWN_INTERRUPT;
1517 else 1525 else
1518 return MAC_RMAC_ERR_TIMER; 1526 return MAC_RMAC_ERR_TIMER;
1519} 1527}
1520#endif
1521 1528
1522/** 1529/**
1523 * en_dis_able_nic_intrs - Enable or Disable the interrupts 1530 * en_dis_able_nic_intrs - Enable or Disable the interrupts
@@ -1941,11 +1948,14 @@ static int start_nic(struct s2io_nic *nic)
1941 } 1948 }
1942 1949
1943 /* Enable select interrupts */ 1950 /* Enable select interrupts */
1944 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR; 1951 if (nic->intr_type != INTA)
1945 interruptible |= TX_PIC_INTR | RX_PIC_INTR; 1952 en_dis_able_nic_intrs(nic, ENA_ALL_INTRS, DISABLE_INTRS);
1946 interruptible |= TX_MAC_INTR | RX_MAC_INTR; 1953 else {
1947 1954 interruptible = TX_TRAFFIC_INTR | RX_TRAFFIC_INTR;
1948 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS); 1955 interruptible |= TX_PIC_INTR | RX_PIC_INTR;
1956 interruptible |= TX_MAC_INTR | RX_MAC_INTR;
1957 en_dis_able_nic_intrs(nic, interruptible, ENABLE_INTRS);
1958 }
1949 1959
1950 /* 1960 /*
1951 * With some switches, link might be already up at this point. 1961 * With some switches, link might be already up at this point.
@@ -2633,11 +2643,11 @@ static void tx_intr_handler(fifo_info_t *fifo_data)
2633 err = txdlp->Control_1 & TXD_T_CODE; 2643 err = txdlp->Control_1 & TXD_T_CODE;
2634 if ((err >> 48) == 0xA) { 2644 if ((err >> 48) == 0xA) {
2635 DBG_PRINT(TX_DBG, "TxD returned due \ 2645 DBG_PRINT(TX_DBG, "TxD returned due \
2636 to loss of link\n"); 2646to loss of link\n");
2637 } 2647 }
2638 else { 2648 else {
2639 DBG_PRINT(ERR_DBG, "***TxD error \ 2649 DBG_PRINT(ERR_DBG, "***TxD error \
2640 %llx\n", err); 2650%llx\n", err);
2641 } 2651 }
2642 } 2652 }
2643 2653
@@ -2854,6 +2864,9 @@ void s2io_reset(nic_t * sp)
2854 /* Set swapper to enable I/O register access */ 2864 /* Set swapper to enable I/O register access */
2855 s2io_set_swapper(sp); 2865 s2io_set_swapper(sp);
2856 2866
2867 /* Restore the MSIX table entries from local variables */
2868 restore_xmsi_data(sp);
2869
2857 /* Clear certain PCI/PCI-X fields after reset */ 2870 /* Clear certain PCI/PCI-X fields after reset */
2858 if (sp->device_type == XFRAME_II_DEVICE) { 2871 if (sp->device_type == XFRAME_II_DEVICE) {
2859 /* Clear parity err detect bit */ 2872 /* Clear parity err detect bit */
@@ -2983,8 +2996,9 @@ int s2io_set_swapper(nic_t * sp)
2983 SWAPPER_CTRL_RXD_W_FE | 2996 SWAPPER_CTRL_RXD_W_FE |
2984 SWAPPER_CTRL_RXF_W_FE | 2997 SWAPPER_CTRL_RXF_W_FE |
2985 SWAPPER_CTRL_XMSI_FE | 2998 SWAPPER_CTRL_XMSI_FE |
2986 SWAPPER_CTRL_XMSI_SE |
2987 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); 2999 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
3000 if (sp->intr_type == INTA)
3001 val64 |= SWAPPER_CTRL_XMSI_SE;
2988 writeq(val64, &bar0->swapper_ctrl); 3002 writeq(val64, &bar0->swapper_ctrl);
2989#else 3003#else
2990 /* 3004 /*
@@ -3005,8 +3019,9 @@ int s2io_set_swapper(nic_t * sp)
3005 SWAPPER_CTRL_RXD_W_SE | 3019 SWAPPER_CTRL_RXD_W_SE |
3006 SWAPPER_CTRL_RXF_W_FE | 3020 SWAPPER_CTRL_RXF_W_FE |
3007 SWAPPER_CTRL_XMSI_FE | 3021 SWAPPER_CTRL_XMSI_FE |
3008 SWAPPER_CTRL_XMSI_SE |
3009 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE); 3022 SWAPPER_CTRL_STATS_FE | SWAPPER_CTRL_STATS_SE);
3023 if (sp->intr_type == INTA)
3024 val64 |= SWAPPER_CTRL_XMSI_SE;
3010 writeq(val64, &bar0->swapper_ctrl); 3025 writeq(val64, &bar0->swapper_ctrl);
3011#endif 3026#endif
3012 val64 = readq(&bar0->swapper_ctrl); 3027 val64 = readq(&bar0->swapper_ctrl);
@@ -3028,6 +3043,201 @@ int s2io_set_swapper(nic_t * sp)
3028 return SUCCESS; 3043 return SUCCESS;
3029} 3044}
3030 3045
3046int wait_for_msix_trans(nic_t *nic, int i)
3047{
3048 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
3049 u64 val64;
3050 int ret = 0, cnt = 0;
3051
3052 do {
3053 val64 = readq(&bar0->xmsi_access);
3054 if (!(val64 & BIT(15)))
3055 break;
3056 mdelay(1);
3057 cnt++;
3058 } while(cnt < 5);
3059 if (cnt == 5) {
3060 DBG_PRINT(ERR_DBG, "XMSI # %d Access failed\n", i);
3061 ret = 1;
3062 }
3063
3064 return ret;
3065}
3066
3067void restore_xmsi_data(nic_t *nic)
3068{
3069 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
3070 u64 val64;
3071 int i;
3072
3073 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3074 writeq(nic->msix_info[i].addr, &bar0->xmsi_address);
3075 writeq(nic->msix_info[i].data, &bar0->xmsi_data);
3076 val64 = (BIT(7) | BIT(15) | vBIT(i, 26, 6));
3077 writeq(val64, &bar0->xmsi_access);
3078 if (wait_for_msix_trans(nic, i)) {
3079 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3080 continue;
3081 }
3082 }
3083}
3084
3085void store_xmsi_data(nic_t *nic)
3086{
3087 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
3088 u64 val64, addr, data;
3089 int i;
3090
3091 /* Store and display */
3092 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3093 val64 = (BIT(15) | vBIT(i, 26, 6));
3094 writeq(val64, &bar0->xmsi_access);
3095 if (wait_for_msix_trans(nic, i)) {
3096 DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);
3097 continue;
3098 }
3099 addr = readq(&bar0->xmsi_address);
3100 data = readq(&bar0->xmsi_data);
3101 if (addr && data) {
3102 nic->msix_info[i].addr = addr;
3103 nic->msix_info[i].data = data;
3104 }
3105 }
3106}
3107
3108int s2io_enable_msi(nic_t *nic)
3109{
3110 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
3111 u16 msi_ctrl, msg_val;
3112 struct config_param *config = &nic->config;
3113 struct net_device *dev = nic->dev;
3114 u64 val64, tx_mat, rx_mat;
3115 int i, err;
3116
3117 val64 = readq(&bar0->pic_control);
3118 val64 &= ~BIT(1);
3119 writeq(val64, &bar0->pic_control);
3120
3121 err = pci_enable_msi(nic->pdev);
3122 if (err) {
3123 DBG_PRINT(ERR_DBG, "%s: enabling MSI failed\n",
3124 nic->dev->name);
3125 return err;
3126 }
3127
3128 /*
3129 * Enable MSI and use MSI-1 in stead of the standard MSI-0
3130 * for interrupt handling.
3131 */
3132 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3133 msg_val ^= 0x1;
3134 pci_write_config_word(nic->pdev, 0x4c, msg_val);
3135 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3136
3137 pci_read_config_word(nic->pdev, 0x42, &msi_ctrl);
3138 msi_ctrl |= 0x10;
3139 pci_write_config_word(nic->pdev, 0x42, msi_ctrl);
3140
3141 /* program MSI-1 into all usable Tx_Mat and Rx_Mat fields */
3142 tx_mat = readq(&bar0->tx_mat0_n[0]);
3143 for (i=0; i<config->tx_fifo_num; i++) {
3144 tx_mat |= TX_MAT_SET(i, 1);
3145 }
3146 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3147
3148 rx_mat = readq(&bar0->rx_mat);
3149 for (i=0; i<config->rx_ring_num; i++) {
3150 rx_mat |= RX_MAT_SET(i, 1);
3151 }
3152 writeq(rx_mat, &bar0->rx_mat);
3153
3154 dev->irq = nic->pdev->irq;
3155 return 0;
3156}
3157
3158int s2io_enable_msi_x(nic_t *nic)
3159{
3160 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0;
3161 u64 tx_mat, rx_mat;
3162 u16 msi_control; /* Temp variable */
3163 int ret, i, j, msix_indx = 1;
3164
3165 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
3166 GFP_KERNEL);
3167 if (nic->entries == NULL) {
3168 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
3169 return -ENOMEM;
3170 }
3171 memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3172
3173 nic->s2io_entries =
3174 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
3175 GFP_KERNEL);
3176 if (nic->s2io_entries == NULL) {
3177 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__);
3178 kfree(nic->entries);
3179 return -ENOMEM;
3180 }
3181 memset(nic->s2io_entries, 0,
3182 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3183
3184 for (i=0; i< MAX_REQUESTED_MSI_X; i++) {
3185 nic->entries[i].entry = i;
3186 nic->s2io_entries[i].entry = i;
3187 nic->s2io_entries[i].arg = NULL;
3188 nic->s2io_entries[i].in_use = 0;
3189 }
3190
3191 tx_mat = readq(&bar0->tx_mat0_n[0]);
3192 for (i=0; i<nic->config.tx_fifo_num; i++, msix_indx++) {
3193 tx_mat |= TX_MAT_SET(i, msix_indx);
3194 nic->s2io_entries[msix_indx].arg = &nic->mac_control.fifos[i];
3195 nic->s2io_entries[msix_indx].type = MSIX_FIFO_TYPE;
3196 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3197 }
3198 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3199
3200 if (!nic->config.bimodal) {
3201 rx_mat = readq(&bar0->rx_mat);
3202 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3203 rx_mat |= RX_MAT_SET(j, msix_indx);
3204 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j];
3205 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3206 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3207 }
3208 writeq(rx_mat, &bar0->rx_mat);
3209 } else {
3210 tx_mat = readq(&bar0->tx_mat0_n[7]);
3211 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3212 tx_mat |= TX_MAT_SET(i, msix_indx);
3213 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j];
3214 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3215 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3216 }
3217 writeq(tx_mat, &bar0->tx_mat0_n[7]);
3218 }
3219
3220 ret = pci_enable_msix(nic->pdev, nic->entries, MAX_REQUESTED_MSI_X);
3221 if (ret) {
3222 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3223 kfree(nic->entries);
3224 kfree(nic->s2io_entries);
3225 nic->entries = NULL;
3226 nic->s2io_entries = NULL;
3227 return -ENOMEM;
3228 }
3229
3230 /*
3231 * To enable MSI-X, MSI also needs to be enabled, due to a bug
3232 * in the herc NIC. (Temp change, needs to be removed later)
3233 */
3234 pci_read_config_word(nic->pdev, 0x42, &msi_control);
3235 msi_control |= 0x1; /* Enable MSI */
3236 pci_write_config_word(nic->pdev, 0x42, msi_control);
3237
3238 return 0;
3239}
3240
3031/* ********************************************************* * 3241/* ********************************************************* *
3032 * Functions defined below concern the OS part of the driver * 3242 * Functions defined below concern the OS part of the driver *
3033 * ********************************************************* */ 3243 * ********************************************************* */
@@ -3048,6 +3258,8 @@ int s2io_open(struct net_device *dev)
3048{ 3258{
3049 nic_t *sp = dev->priv; 3259 nic_t *sp = dev->priv;
3050 int err = 0; 3260 int err = 0;
3261 int i;
3262 u16 msi_control; /* Temp variable */
3051 3263
3052 /* 3264 /*
3053 * Make sure you have link off by default every time 3265 * Make sure you have link off by default every time
@@ -3064,13 +3276,55 @@ int s2io_open(struct net_device *dev)
3064 goto hw_init_failed; 3276 goto hw_init_failed;
3065 } 3277 }
3066 3278
3279 /* Store the values of the MSIX table in the nic_t structure */
3280 store_xmsi_data(sp);
3281
3067 /* After proper initialization of H/W, register ISR */ 3282 /* After proper initialization of H/W, register ISR */
3068 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ, 3283 if (sp->intr_type == MSI) {
3069 sp->name, dev); 3284 err = request_irq((int) sp->pdev->irq, s2io_msi_handle,
3070 if (err) { 3285 SA_SHIRQ, sp->name, dev);
3071 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n", 3286 if (err) {
3072 dev->name); 3287 DBG_PRINT(ERR_DBG, "%s: MSI registration \
3073 goto isr_registration_failed; 3288failed\n", dev->name);
3289 goto isr_registration_failed;
3290 }
3291 }
3292 if (sp->intr_type == MSI_X) {
3293 for (i=1; (sp->s2io_entries[i].in_use == MSIX_FLG); i++) {
3294 if (sp->s2io_entries[i].type == MSIX_FIFO_TYPE) {
3295 sprintf(sp->desc1, "%s:MSI-X-%d-TX",
3296 dev->name, i);
3297 err = request_irq(sp->entries[i].vector,
3298 s2io_msix_fifo_handle, 0, sp->desc1,
3299 sp->s2io_entries[i].arg);
3300 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc1,
3301 sp->msix_info[i].addr);
3302 } else {
3303 sprintf(sp->desc2, "%s:MSI-X-%d-RX",
3304 dev->name, i);
3305 err = request_irq(sp->entries[i].vector,
3306 s2io_msix_ring_handle, 0, sp->desc2,
3307 sp->s2io_entries[i].arg);
3308 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc2,
3309 sp->msix_info[i].addr);
3310 }
3311 if (err) {
3312 DBG_PRINT(ERR_DBG, "%s: MSI-X-%d registration \
3313failed\n", dev->name, i);
3314 DBG_PRINT(ERR_DBG, "Returned: %d\n", err);
3315 goto isr_registration_failed;
3316 }
3317 sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
3318 }
3319 }
3320 if (sp->intr_type == INTA) {
3321 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ,
3322 sp->name, dev);
3323 if (err) {
3324 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
3325 dev->name);
3326 goto isr_registration_failed;
3327 }
3074 } 3328 }
3075 3329
3076 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) { 3330 if (s2io_set_mac_addr(dev, dev->dev_addr) == FAILURE) {
@@ -3083,11 +3337,37 @@ int s2io_open(struct net_device *dev)
3083 return 0; 3337 return 0;
3084 3338
3085setting_mac_address_failed: 3339setting_mac_address_failed:
3086 free_irq(sp->pdev->irq, dev); 3340 if (sp->intr_type != MSI_X)
3341 free_irq(sp->pdev->irq, dev);
3087isr_registration_failed: 3342isr_registration_failed:
3088 del_timer_sync(&sp->alarm_timer); 3343 del_timer_sync(&sp->alarm_timer);
3344 if (sp->intr_type == MSI_X) {
3345 if (sp->device_type == XFRAME_II_DEVICE) {
3346 for (i=1; (sp->s2io_entries[i].in_use ==
3347 MSIX_REGISTERED_SUCCESS); i++) {
3348 int vector = sp->entries[i].vector;
3349 void *arg = sp->s2io_entries[i].arg;
3350
3351 free_irq(vector, arg);
3352 }
3353 pci_disable_msix(sp->pdev);
3354
3355 /* Temp */
3356 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3357 msi_control &= 0xFFFE; /* Disable MSI */
3358 pci_write_config_word(sp->pdev, 0x42, msi_control);
3359 }
3360 }
3361 else if (sp->intr_type == MSI)
3362 pci_disable_msi(sp->pdev);
3089 s2io_reset(sp); 3363 s2io_reset(sp);
3090hw_init_failed: 3364hw_init_failed:
3365 if (sp->intr_type == MSI_X) {
3366 if (sp->entries)
3367 kfree(sp->entries);
3368 if (sp->s2io_entries)
3369 kfree(sp->s2io_entries);
3370 }
3091 return err; 3371 return err;
3092} 3372}
3093 3373
@@ -3107,12 +3387,35 @@ hw_init_failed:
3107int s2io_close(struct net_device *dev) 3387int s2io_close(struct net_device *dev)
3108{ 3388{
3109 nic_t *sp = dev->priv; 3389 nic_t *sp = dev->priv;
3390 int i;
3391 u16 msi_control;
3392
3110 flush_scheduled_work(); 3393 flush_scheduled_work();
3111 netif_stop_queue(dev); 3394 netif_stop_queue(dev);
3112 /* Reset card, kill tasklet and free Tx and Rx buffers. */ 3395 /* Reset card, kill tasklet and free Tx and Rx buffers. */
3113 s2io_card_down(sp); 3396 s2io_card_down(sp);
3114 3397
3115 free_irq(sp->pdev->irq, dev); 3398 if (sp->intr_type == MSI_X) {
3399 if (sp->device_type == XFRAME_II_DEVICE) {
3400 for (i=1; (sp->s2io_entries[i].in_use ==
3401 MSIX_REGISTERED_SUCCESS); i++) {
3402 int vector = sp->entries[i].vector;
3403 void *arg = sp->s2io_entries[i].arg;
3404
3405 free_irq(vector, arg);
3406 }
3407 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3408 msi_control &= 0xFFFE; /* Disable MSI */
3409 pci_write_config_word(sp->pdev, 0x42, msi_control);
3410
3411 pci_disable_msix(sp->pdev);
3412 }
3413 }
3414 else {
3415 free_irq(sp->pdev->irq, dev);
3416 if (sp->intr_type == MSI)
3417 pci_disable_msi(sp->pdev);
3418 }
3116 sp->device_close_flag = TRUE; /* Device is shut down. */ 3419 sp->device_close_flag = TRUE; /* Device is shut down. */
3117 return 0; 3420 return 0;
3118} 3421}
@@ -3278,6 +3581,104 @@ s2io_alarm_handle(unsigned long data)
3278 mod_timer(&sp->alarm_timer, jiffies + HZ / 2); 3581 mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
3279} 3582}
3280 3583
3584static irqreturn_t
3585s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs)
3586{
3587 struct net_device *dev = (struct net_device *) dev_id;
3588 nic_t *sp = dev->priv;
3589 int i;
3590 int ret;
3591 mac_info_t *mac_control;
3592 struct config_param *config;
3593
3594 atomic_inc(&sp->isr_cnt);
3595 mac_control = &sp->mac_control;
3596 config = &sp->config;
3597 DBG_PRINT(INTR_DBG, "%s: MSI handler\n", __FUNCTION__);
3598
3599 /* If Intr is because of Rx Traffic */
3600 for (i = 0; i < config->rx_ring_num; i++)
3601 rx_intr_handler(&mac_control->rings[i]);
3602
3603 /* If Intr is because of Tx Traffic */
3604 for (i = 0; i < config->tx_fifo_num; i++)
3605 tx_intr_handler(&mac_control->fifos[i]);
3606
3607 /*
3608 * If the Rx buffer count is below the panic threshold then
3609 * reallocate the buffers from the interrupt handler itself,
3610 * else schedule a tasklet to reallocate the buffers.
3611 */
3612 for (i = 0; i < config->rx_ring_num; i++) {
3613 int rxb_size = atomic_read(&sp->rx_bufs_left[i]);
3614 int level = rx_buffer_level(sp, rxb_size, i);
3615
3616 if ((level == PANIC) && (!TASKLET_IN_USE)) {
3617 DBG_PRINT(INTR_DBG, "%s: Rx BD hit ", dev->name);
3618 DBG_PRINT(INTR_DBG, "PANIC levels\n");
3619 if ((ret = fill_rx_buffers(sp, i)) == -ENOMEM) {
3620 DBG_PRINT(ERR_DBG, "%s:Out of memory",
3621 dev->name);
3622 DBG_PRINT(ERR_DBG, " in ISR!!\n");
3623 clear_bit(0, (&sp->tasklet_status));
3624 atomic_dec(&sp->isr_cnt);
3625 return IRQ_HANDLED;
3626 }
3627 clear_bit(0, (&sp->tasklet_status));
3628 } else if (level == LOW) {
3629 tasklet_schedule(&sp->task);
3630 }
3631 }
3632
3633 atomic_dec(&sp->isr_cnt);
3634 return IRQ_HANDLED;
3635}
3636
3637static irqreturn_t
3638s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs)
3639{
3640 ring_info_t *ring = (ring_info_t *)dev_id;
3641 nic_t *sp = ring->nic;
3642 int rxb_size, level, rng_n;
3643
3644 atomic_inc(&sp->isr_cnt);
3645 rx_intr_handler(ring);
3646
3647 rng_n = ring->ring_no;
3648 rxb_size = atomic_read(&sp->rx_bufs_left[rng_n]);
3649 level = rx_buffer_level(sp, rxb_size, rng_n);
3650
3651 if ((level == PANIC) && (!TASKLET_IN_USE)) {
3652 int ret;
3653 DBG_PRINT(INTR_DBG, "%s: Rx BD hit ", __FUNCTION__);
3654 DBG_PRINT(INTR_DBG, "PANIC levels\n");
3655 if ((ret = fill_rx_buffers(sp, rng_n)) == -ENOMEM) {
3656 DBG_PRINT(ERR_DBG, "Out of memory in %s",
3657 __FUNCTION__);
3658 clear_bit(0, (&sp->tasklet_status));
3659 return IRQ_HANDLED;
3660 }
3661 clear_bit(0, (&sp->tasklet_status));
3662 } else if (level == LOW) {
3663 tasklet_schedule(&sp->task);
3664 }
3665 atomic_dec(&sp->isr_cnt);
3666
3667 return IRQ_HANDLED;
3668}
3669
3670static irqreturn_t
3671s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs)
3672{
3673 fifo_info_t *fifo = (fifo_info_t *)dev_id;
3674 nic_t *sp = fifo->nic;
3675
3676 atomic_inc(&sp->isr_cnt);
3677 tx_intr_handler(fifo);
3678 atomic_dec(&sp->isr_cnt);
3679 return IRQ_HANDLED;
3680}
3681
3281static void s2io_txpic_intr_handle(nic_t *sp) 3682static void s2io_txpic_intr_handle(nic_t *sp)
3282{ 3683{
3283 XENA_dev_config_t __iomem *bar0 = sp->bar0; 3684 XENA_dev_config_t __iomem *bar0 = sp->bar0;
@@ -3778,11 +4179,10 @@ static void s2io_ethtool_gdrvinfo(struct net_device *dev,
3778{ 4179{
3779 nic_t *sp = dev->priv; 4180 nic_t *sp = dev->priv;
3780 4181
3781 strncpy(info->driver, s2io_driver_name, sizeof(s2io_driver_name)); 4182 strncpy(info->driver, s2io_driver_name, sizeof(info->driver));
3782 strncpy(info->version, s2io_driver_version, 4183 strncpy(info->version, s2io_driver_version, sizeof(info->version));
3783 sizeof(s2io_driver_version)); 4184 strncpy(info->fw_version, "", sizeof(info->fw_version));
3784 strncpy(info->fw_version, "", 32); 4185 strncpy(info->bus_info, pci_name(sp->pdev), sizeof(info->bus_info));
3785 strncpy(info->bus_info, pci_name(sp->pdev), 32);
3786 info->regdump_len = XENA_REG_SPACE; 4186 info->regdump_len = XENA_REG_SPACE;
3787 info->eedump_len = XENA_EEPROM_SPACE; 4187 info->eedump_len = XENA_EEPROM_SPACE;
3788 info->testinfo_len = S2IO_TEST_LEN; 4188 info->testinfo_len = S2IO_TEST_LEN;
@@ -3978,29 +4378,53 @@ static int s2io_ethtool_setpause_data(struct net_device *dev,
3978 */ 4378 */
3979 4379
3980#define S2IO_DEV_ID 5 4380#define S2IO_DEV_ID 5
3981static int read_eeprom(nic_t * sp, int off, u32 * data) 4381static int read_eeprom(nic_t * sp, int off, u64 * data)
3982{ 4382{
3983 int ret = -1; 4383 int ret = -1;
3984 u32 exit_cnt = 0; 4384 u32 exit_cnt = 0;
3985 u64 val64; 4385 u64 val64;
3986 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4386 XENA_dev_config_t __iomem *bar0 = sp->bar0;
3987 4387
3988 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | 4388 if (sp->device_type == XFRAME_I_DEVICE) {
3989 I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ | 4389 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
3990 I2C_CONTROL_CNTL_START; 4390 I2C_CONTROL_BYTE_CNT(0x3) | I2C_CONTROL_READ |
3991 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); 4391 I2C_CONTROL_CNTL_START;
4392 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF);
3992 4393
3993 while (exit_cnt < 5) { 4394 while (exit_cnt < 5) {
3994 val64 = readq(&bar0->i2c_control); 4395 val64 = readq(&bar0->i2c_control);
3995 if (I2C_CONTROL_CNTL_END(val64)) { 4396 if (I2C_CONTROL_CNTL_END(val64)) {
3996 *data = I2C_CONTROL_GET_DATA(val64); 4397 *data = I2C_CONTROL_GET_DATA(val64);
3997 ret = 0; 4398 ret = 0;
3998 break; 4399 break;
4400 }
4401 msleep(50);
4402 exit_cnt++;
3999 } 4403 }
4000 msleep(50);
4001 exit_cnt++;
4002 } 4404 }
4003 4405
4406 if (sp->device_type == XFRAME_II_DEVICE) {
4407 val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 |
4408 SPI_CONTROL_BYTECNT(0x3) |
4409 SPI_CONTROL_CMD(0x3) | SPI_CONTROL_ADDR(off);
4410 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4411 val64 |= SPI_CONTROL_REQ;
4412 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4413 while (exit_cnt < 5) {
4414 val64 = readq(&bar0->spi_control);
4415 if (val64 & SPI_CONTROL_NACK) {
4416 ret = 1;
4417 break;
4418 } else if (val64 & SPI_CONTROL_DONE) {
4419 *data = readq(&bar0->spi_data);
4420 *data &= 0xffffff;
4421 ret = 0;
4422 break;
4423 }
4424 msleep(50);
4425 exit_cnt++;
4426 }
4427 }
4004 return ret; 4428 return ret;
4005} 4429}
4006 4430
@@ -4019,28 +4443,53 @@ static int read_eeprom(nic_t * sp, int off, u32 * data)
4019 * 0 on success, -1 on failure. 4443 * 0 on success, -1 on failure.
4020 */ 4444 */
4021 4445
4022static int write_eeprom(nic_t * sp, int off, u32 data, int cnt) 4446static int write_eeprom(nic_t * sp, int off, u64 data, int cnt)
4023{ 4447{
4024 int exit_cnt = 0, ret = -1; 4448 int exit_cnt = 0, ret = -1;
4025 u64 val64; 4449 u64 val64;
4026 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4450 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4027 4451
4028 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) | 4452 if (sp->device_type == XFRAME_I_DEVICE) {
4029 I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA(data) | 4453 val64 = I2C_CONTROL_DEV_ID(S2IO_DEV_ID) | I2C_CONTROL_ADDR(off) |
4030 I2C_CONTROL_CNTL_START; 4454 I2C_CONTROL_BYTE_CNT(cnt) | I2C_CONTROL_SET_DATA((u32)data) |
4031 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF); 4455 I2C_CONTROL_CNTL_START;
4456 SPECIAL_REG_WRITE(val64, &bar0->i2c_control, LF);
4457
4458 while (exit_cnt < 5) {
4459 val64 = readq(&bar0->i2c_control);
4460 if (I2C_CONTROL_CNTL_END(val64)) {
4461 if (!(val64 & I2C_CONTROL_NACK))
4462 ret = 0;
4463 break;
4464 }
4465 msleep(50);
4466 exit_cnt++;
4467 }
4468 }
4032 4469
4033 while (exit_cnt < 5) { 4470 if (sp->device_type == XFRAME_II_DEVICE) {
4034 val64 = readq(&bar0->i2c_control); 4471 int write_cnt = (cnt == 8) ? 0 : cnt;
4035 if (I2C_CONTROL_CNTL_END(val64)) { 4472 writeq(SPI_DATA_WRITE(data,(cnt<<3)), &bar0->spi_data);
4036 if (!(val64 & I2C_CONTROL_NACK)) 4473
4474 val64 = SPI_CONTROL_KEY(0x9) | SPI_CONTROL_SEL1 |
4475 SPI_CONTROL_BYTECNT(write_cnt) |
4476 SPI_CONTROL_CMD(0x2) | SPI_CONTROL_ADDR(off);
4477 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4478 val64 |= SPI_CONTROL_REQ;
4479 SPECIAL_REG_WRITE(val64, &bar0->spi_control, LF);
4480 while (exit_cnt < 5) {
4481 val64 = readq(&bar0->spi_control);
4482 if (val64 & SPI_CONTROL_NACK) {
4483 ret = 1;
4484 break;
4485 } else if (val64 & SPI_CONTROL_DONE) {
4037 ret = 0; 4486 ret = 0;
4038 break; 4487 break;
4488 }
4489 msleep(50);
4490 exit_cnt++;
4039 } 4491 }
4040 msleep(50);
4041 exit_cnt++;
4042 } 4492 }
4043
4044 return ret; 4493 return ret;
4045} 4494}
4046 4495
@@ -4060,7 +4509,8 @@ static int write_eeprom(nic_t * sp, int off, u32 data, int cnt)
4060static int s2io_ethtool_geeprom(struct net_device *dev, 4509static int s2io_ethtool_geeprom(struct net_device *dev,
4061 struct ethtool_eeprom *eeprom, u8 * data_buf) 4510 struct ethtool_eeprom *eeprom, u8 * data_buf)
4062{ 4511{
4063 u32 data, i, valid; 4512 u32 i, valid;
4513 u64 data;
4064 nic_t *sp = dev->priv; 4514 nic_t *sp = dev->priv;
4065 4515
4066 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16); 4516 eeprom->magic = sp->pdev->vendor | (sp->pdev->device << 16);
@@ -4098,7 +4548,7 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
4098 u8 * data_buf) 4548 u8 * data_buf)
4099{ 4549{
4100 int len = eeprom->len, cnt = 0; 4550 int len = eeprom->len, cnt = 0;
4101 u32 valid = 0, data; 4551 u64 valid = 0, data;
4102 nic_t *sp = dev->priv; 4552 nic_t *sp = dev->priv;
4103 4553
4104 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) { 4554 if (eeprom->magic != (sp->pdev->vendor | (sp->pdev->device << 16))) {
@@ -4146,7 +4596,7 @@ static int s2io_ethtool_seeprom(struct net_device *dev,
4146static int s2io_register_test(nic_t * sp, uint64_t * data) 4596static int s2io_register_test(nic_t * sp, uint64_t * data)
4147{ 4597{
4148 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4598 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4149 u64 val64 = 0; 4599 u64 val64 = 0, exp_val;
4150 int fail = 0; 4600 int fail = 0;
4151 4601
4152 val64 = readq(&bar0->pif_rd_swapper_fb); 4602 val64 = readq(&bar0->pif_rd_swapper_fb);
@@ -4162,7 +4612,11 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4162 } 4612 }
4163 4613
4164 val64 = readq(&bar0->rx_queue_cfg); 4614 val64 = readq(&bar0->rx_queue_cfg);
4165 if (val64 != 0x0808080808080808ULL) { 4615 if (sp->device_type == XFRAME_II_DEVICE)
4616 exp_val = 0x0404040404040404ULL;
4617 else
4618 exp_val = 0x0808080808080808ULL;
4619 if (val64 != exp_val) {
4166 fail = 1; 4620 fail = 1;
4167 DBG_PRINT(INFO_DBG, "Read Test level 3 fails\n"); 4621 DBG_PRINT(INFO_DBG, "Read Test level 3 fails\n");
4168 } 4622 }
@@ -4190,7 +4644,7 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4190 } 4644 }
4191 4645
4192 *data = fail; 4646 *data = fail;
4193 return 0; 4647 return fail;
4194} 4648}
4195 4649
4196/** 4650/**
@@ -4209,58 +4663,83 @@ static int s2io_register_test(nic_t * sp, uint64_t * data)
4209static int s2io_eeprom_test(nic_t * sp, uint64_t * data) 4663static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
4210{ 4664{
4211 int fail = 0; 4665 int fail = 0;
4212 u32 ret_data; 4666 u64 ret_data, org_4F0, org_7F0;
4667 u8 saved_4F0 = 0, saved_7F0 = 0;
4668 struct net_device *dev = sp->dev;
4213 4669
4214 /* Test Write Error at offset 0 */ 4670 /* Test Write Error at offset 0 */
4215 if (!write_eeprom(sp, 0, 0, 3)) 4671 /* Note that SPI interface allows write access to all areas
4216 fail = 1; 4672 * of EEPROM. Hence doing all negative testing only for Xframe I.
4673 */
4674 if (sp->device_type == XFRAME_I_DEVICE)
4675 if (!write_eeprom(sp, 0, 0, 3))
4676 fail = 1;
4677
4678 /* Save current values at offsets 0x4F0 and 0x7F0 */
4679 if (!read_eeprom(sp, 0x4F0, &org_4F0))
4680 saved_4F0 = 1;
4681 if (!read_eeprom(sp, 0x7F0, &org_7F0))
4682 saved_7F0 = 1;
4217 4683
4218 /* Test Write at offset 4f0 */ 4684 /* Test Write at offset 4f0 */
4219 if (write_eeprom(sp, 0x4F0, 0x01234567, 3)) 4685 if (write_eeprom(sp, 0x4F0, 0x012345, 3))
4220 fail = 1; 4686 fail = 1;
4221 if (read_eeprom(sp, 0x4F0, &ret_data)) 4687 if (read_eeprom(sp, 0x4F0, &ret_data))
4222 fail = 1; 4688 fail = 1;
4223 4689
4224 if (ret_data != 0x01234567) 4690 if (ret_data != 0x012345) {
4691 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data);
4225 fail = 1; 4692 fail = 1;
4693 }
4226 4694
4227 /* Reset the EEPROM data go FFFF */ 4695 /* Reset the EEPROM data go FFFF */
4228 write_eeprom(sp, 0x4F0, 0xFFFFFFFF, 3); 4696 write_eeprom(sp, 0x4F0, 0xFFFFFF, 3);
4229 4697
4230 /* Test Write Request Error at offset 0x7c */ 4698 /* Test Write Request Error at offset 0x7c */
4231 if (!write_eeprom(sp, 0x07C, 0, 3)) 4699 if (sp->device_type == XFRAME_I_DEVICE)
4232 fail = 1; 4700 if (!write_eeprom(sp, 0x07C, 0, 3))
4701 fail = 1;
4233 4702
4234 /* Test Write Request at offset 0x7fc */ 4703 /* Test Write Request at offset 0x7f0 */
4235 if (write_eeprom(sp, 0x7FC, 0x01234567, 3)) 4704 if (write_eeprom(sp, 0x7F0, 0x012345, 3))
4236 fail = 1; 4705 fail = 1;
4237 if (read_eeprom(sp, 0x7FC, &ret_data)) 4706 if (read_eeprom(sp, 0x7F0, &ret_data))
4238 fail = 1; 4707 fail = 1;
4239 4708
4240 if (ret_data != 0x01234567) 4709 if (ret_data != 0x012345) {
4710 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data);
4241 fail = 1; 4711 fail = 1;
4712 }
4242 4713
4243 /* Reset the EEPROM data go FFFF */ 4714 /* Reset the EEPROM data go FFFF */
4244 write_eeprom(sp, 0x7FC, 0xFFFFFFFF, 3); 4715 write_eeprom(sp, 0x7F0, 0xFFFFFF, 3);
4245 4716
4246 /* Test Write Error at offset 0x80 */ 4717 if (sp->device_type == XFRAME_I_DEVICE) {
4247 if (!write_eeprom(sp, 0x080, 0, 3)) 4718 /* Test Write Error at offset 0x80 */
4248 fail = 1; 4719 if (!write_eeprom(sp, 0x080, 0, 3))
4720 fail = 1;
4249 4721
4250 /* Test Write Error at offset 0xfc */ 4722 /* Test Write Error at offset 0xfc */
4251 if (!write_eeprom(sp, 0x0FC, 0, 3)) 4723 if (!write_eeprom(sp, 0x0FC, 0, 3))
4252 fail = 1; 4724 fail = 1;
4253 4725
4254 /* Test Write Error at offset 0x100 */ 4726 /* Test Write Error at offset 0x100 */
4255 if (!write_eeprom(sp, 0x100, 0, 3)) 4727 if (!write_eeprom(sp, 0x100, 0, 3))
4256 fail = 1; 4728 fail = 1;
4257 4729
4258 /* Test Write Error at offset 4ec */ 4730 /* Test Write Error at offset 4ec */
4259 if (!write_eeprom(sp, 0x4EC, 0, 3)) 4731 if (!write_eeprom(sp, 0x4EC, 0, 3))
4260 fail = 1; 4732 fail = 1;
4733 }
4734
4735 /* Restore values at offsets 0x4F0 and 0x7F0 */
4736 if (saved_4F0)
4737 write_eeprom(sp, 0x4F0, org_4F0, 3);
4738 if (saved_7F0)
4739 write_eeprom(sp, 0x7F0, org_7F0, 3);
4261 4740
4262 *data = fail; 4741 *data = fail;
4263 return 0; 4742 return fail;
4264} 4743}
4265 4744
4266/** 4745/**
@@ -4342,7 +4821,7 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4342{ 4821{
4343 XENA_dev_config_t __iomem *bar0 = sp->bar0; 4822 XENA_dev_config_t __iomem *bar0 = sp->bar0;
4344 u64 val64; 4823 u64 val64;
4345 int cnt, iteration = 0, test_pass = 0; 4824 int cnt, iteration = 0, test_fail = 0;
4346 4825
4347 val64 = readq(&bar0->adapter_control); 4826 val64 = readq(&bar0->adapter_control);
4348 val64 &= ~ADAPTER_ECC_EN; 4827 val64 &= ~ADAPTER_ECC_EN;
@@ -4350,7 +4829,7 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4350 4829
4351 val64 = readq(&bar0->mc_rldram_test_ctrl); 4830 val64 = readq(&bar0->mc_rldram_test_ctrl);
4352 val64 |= MC_RLDRAM_TEST_MODE; 4831 val64 |= MC_RLDRAM_TEST_MODE;
4353 writeq(val64, &bar0->mc_rldram_test_ctrl); 4832 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4354 4833
4355 val64 = readq(&bar0->mc_rldram_mrs); 4834 val64 = readq(&bar0->mc_rldram_mrs);
4356 val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE; 4835 val64 |= MC_RLDRAM_QUEUE_SIZE_ENABLE;
@@ -4378,17 +4857,12 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4378 } 4857 }
4379 writeq(val64, &bar0->mc_rldram_test_d2); 4858 writeq(val64, &bar0->mc_rldram_test_d2);
4380 4859
4381 val64 = (u64) (0x0000003fffff0000ULL); 4860 val64 = (u64) (0x0000003ffffe0100ULL);
4382 writeq(val64, &bar0->mc_rldram_test_add); 4861 writeq(val64, &bar0->mc_rldram_test_add);
4383 4862
4384 4863 val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_WRITE |
4385 val64 = MC_RLDRAM_TEST_MODE; 4864 MC_RLDRAM_TEST_GO;
4386 writeq(val64, &bar0->mc_rldram_test_ctrl); 4865 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4387
4388 val64 |=
4389 MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_WRITE |
4390 MC_RLDRAM_TEST_GO;
4391 writeq(val64, &bar0->mc_rldram_test_ctrl);
4392 4866
4393 for (cnt = 0; cnt < 5; cnt++) { 4867 for (cnt = 0; cnt < 5; cnt++) {
4394 val64 = readq(&bar0->mc_rldram_test_ctrl); 4868 val64 = readq(&bar0->mc_rldram_test_ctrl);
@@ -4400,11 +4874,8 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4400 if (cnt == 5) 4874 if (cnt == 5)
4401 break; 4875 break;
4402 4876
4403 val64 = MC_RLDRAM_TEST_MODE; 4877 val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO;
4404 writeq(val64, &bar0->mc_rldram_test_ctrl); 4878 SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF);
4405
4406 val64 |= MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO;
4407 writeq(val64, &bar0->mc_rldram_test_ctrl);
4408 4879
4409 for (cnt = 0; cnt < 5; cnt++) { 4880 for (cnt = 0; cnt < 5; cnt++) {
4410 val64 = readq(&bar0->mc_rldram_test_ctrl); 4881 val64 = readq(&bar0->mc_rldram_test_ctrl);
@@ -4417,18 +4888,18 @@ static int s2io_rldram_test(nic_t * sp, uint64_t * data)
4417 break; 4888 break;
4418 4889
4419 val64 = readq(&bar0->mc_rldram_test_ctrl); 4890 val64 = readq(&bar0->mc_rldram_test_ctrl);
4420 if (val64 & MC_RLDRAM_TEST_PASS) 4891 if (!(val64 & MC_RLDRAM_TEST_PASS))
4421 test_pass = 1; 4892 test_fail = 1;
4422 4893
4423 iteration++; 4894 iteration++;
4424 } 4895 }
4425 4896
4426 if (!test_pass) 4897 *data = test_fail;
4427 *data = 1;
4428 else
4429 *data = 0;
4430 4898
4431 return 0; 4899 /* Bring the adapter out of test mode */
4900 SPECIAL_REG_WRITE(0, &bar0->mc_rldram_test_ctrl, LF);
4901
4902 return test_fail;
4432} 4903}
4433 4904
4434/** 4905/**
@@ -4932,7 +5403,7 @@ static void s2io_card_down(nic_t * sp)
4932 5403
4933static int s2io_card_up(nic_t * sp) 5404static int s2io_card_up(nic_t * sp)
4934{ 5405{
4935 int i, ret; 5406 int i, ret = 0;
4936 mac_info_t *mac_control; 5407 mac_info_t *mac_control;
4937 struct config_param *config; 5408 struct config_param *config;
4938 struct net_device *dev = (struct net_device *) sp->dev; 5409 struct net_device *dev = (struct net_device *) sp->dev;
@@ -4944,6 +5415,15 @@ static int s2io_card_up(nic_t * sp)
4944 return -ENODEV; 5415 return -ENODEV;
4945 } 5416 }
4946 5417
5418 if (sp->intr_type == MSI)
5419 ret = s2io_enable_msi(sp);
5420 else if (sp->intr_type == MSI_X)
5421 ret = s2io_enable_msi_x(sp);
5422 if (ret) {
5423 DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name);
5424 sp->intr_type = INTA;
5425 }
5426
4947 /* 5427 /*
4948 * Initializing the Rx buffers. For now we are considering only 1 5428 * Initializing the Rx buffers. For now we are considering only 1
4949 * Rx ring and initializing buffers into 30 Rx blocks 5429 * Rx ring and initializing buffers into 30 Rx blocks
@@ -5228,6 +5708,8 @@ static void s2io_init_pci(nic_t * sp)
5228 5708
5229MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>"); 5709MODULE_AUTHOR("Raghavendra Koushik <raghavendra.koushik@neterion.com>");
5230MODULE_LICENSE("GPL"); 5710MODULE_LICENSE("GPL");
5711MODULE_VERSION(DRV_VERSION);
5712
5231module_param(tx_fifo_num, int, 0); 5713module_param(tx_fifo_num, int, 0);
5232module_param(rx_ring_num, int, 0); 5714module_param(rx_ring_num, int, 0);
5233module_param_array(tx_fifo_len, uint, NULL, 0); 5715module_param_array(tx_fifo_len, uint, NULL, 0);
@@ -5245,6 +5727,7 @@ module_param(bimodal, bool, 0);
5245module_param(indicate_max_pkts, int, 0); 5727module_param(indicate_max_pkts, int, 0);
5246#endif 5728#endif
5247module_param(rxsync_frequency, int, 0); 5729module_param(rxsync_frequency, int, 0);
5730module_param(intr_type, int, 0);
5248 5731
5249/** 5732/**
5250 * s2io_init_nic - Initialization of the adapter . 5733 * s2io_init_nic - Initialization of the adapter .
@@ -5274,9 +5757,16 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5274 mac_info_t *mac_control; 5757 mac_info_t *mac_control;
5275 struct config_param *config; 5758 struct config_param *config;
5276 int mode; 5759 int mode;
5760 u8 dev_intr_type = intr_type;
5277 5761
5278#ifdef CONFIG_S2IO_NAPI 5762#ifdef CONFIG_S2IO_NAPI
5279 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n"); 5763 if (dev_intr_type != INTA) {
5764 DBG_PRINT(ERR_DBG, "NAPI cannot be enabled when MSI/MSI-X \
5765is enabled. Defaulting to INTA\n");
5766 dev_intr_type = INTA;
5767 }
5768 else
5769 DBG_PRINT(ERR_DBG, "NAPI support has been enabled\n");
5280#endif 5770#endif
5281 5771
5282 if ((ret = pci_enable_device(pdev))) { 5772 if ((ret = pci_enable_device(pdev))) {
@@ -5303,10 +5793,35 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5303 return -ENOMEM; 5793 return -ENOMEM;
5304 } 5794 }
5305 5795
5306 if (pci_request_regions(pdev, s2io_driver_name)) { 5796 if ((dev_intr_type == MSI_X) &&
5307 DBG_PRINT(ERR_DBG, "Request Regions failed\n"), 5797 ((pdev->device != PCI_DEVICE_ID_HERC_WIN) &&
5308 pci_disable_device(pdev); 5798 (pdev->device != PCI_DEVICE_ID_HERC_UNI))) {
5309 return -ENODEV; 5799 DBG_PRINT(ERR_DBG, "Xframe I does not support MSI_X. \
5800Defaulting to INTA\n");
5801 dev_intr_type = INTA;
5802 }
5803 if (dev_intr_type != MSI_X) {
5804 if (pci_request_regions(pdev, s2io_driver_name)) {
5805 DBG_PRINT(ERR_DBG, "Request Regions failed\n"),
5806 pci_disable_device(pdev);
5807 return -ENODEV;
5808 }
5809 }
5810 else {
5811 if (!(request_mem_region(pci_resource_start(pdev, 0),
5812 pci_resource_len(pdev, 0), s2io_driver_name))) {
5813 DBG_PRINT(ERR_DBG, "bar0 Request Regions failed\n");
5814 pci_disable_device(pdev);
5815 return -ENODEV;
5816 }
5817 if (!(request_mem_region(pci_resource_start(pdev, 2),
5818 pci_resource_len(pdev, 2), s2io_driver_name))) {
5819 DBG_PRINT(ERR_DBG, "bar1 Request Regions failed\n");
5820 release_mem_region(pci_resource_start(pdev, 0),
5821 pci_resource_len(pdev, 0));
5822 pci_disable_device(pdev);
5823 return -ENODEV;
5824 }
5310 } 5825 }
5311 5826
5312 dev = alloc_etherdev(sizeof(nic_t)); 5827 dev = alloc_etherdev(sizeof(nic_t));
@@ -5329,6 +5844,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5329 sp->pdev = pdev; 5844 sp->pdev = pdev;
5330 sp->high_dma_flag = dma_flag; 5845 sp->high_dma_flag = dma_flag;
5331 sp->device_enabled_once = FALSE; 5846 sp->device_enabled_once = FALSE;
5847 sp->intr_type = dev_intr_type;
5332 5848
5333 if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) || 5849 if ((pdev->device == PCI_DEVICE_ID_HERC_WIN) ||
5334 (pdev->device == PCI_DEVICE_ID_HERC_UNI)) 5850 (pdev->device == PCI_DEVICE_ID_HERC_UNI))
@@ -5336,6 +5852,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5336 else 5852 else
5337 sp->device_type = XFRAME_I_DEVICE; 5853 sp->device_type = XFRAME_I_DEVICE;
5338 5854
5855
5339 /* Initialize some PCI/PCI-X fields of the NIC. */ 5856 /* Initialize some PCI/PCI-X fields of the NIC. */
5340 s2io_init_pci(sp); 5857 s2io_init_pci(sp);
5341 5858
@@ -5571,12 +6088,23 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5571 if (sp->device_type & XFRAME_II_DEVICE) { 6088 if (sp->device_type & XFRAME_II_DEVICE) {
5572 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ", 6089 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ",
5573 dev->name); 6090 dev->name);
5574 DBG_PRINT(ERR_DBG, "(rev %d), %s", 6091 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
5575 get_xena_rev_id(sp->pdev), 6092 get_xena_rev_id(sp->pdev),
5576 s2io_driver_version); 6093 s2io_driver_version);
5577#ifdef CONFIG_2BUFF_MODE 6094#ifdef CONFIG_2BUFF_MODE
5578 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); 6095 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5579#endif 6096#endif
6097 switch(sp->intr_type) {
6098 case INTA:
6099 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6100 break;
6101 case MSI:
6102 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6103 break;
6104 case MSI_X:
6105 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6106 break;
6107 }
5580 6108
5581 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); 6109 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5582 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", 6110 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -5595,12 +6123,23 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5595 } else { 6123 } else {
5596 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ", 6124 DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ",
5597 dev->name); 6125 dev->name);
5598 DBG_PRINT(ERR_DBG, "(rev %d), %s", 6126 DBG_PRINT(ERR_DBG, "(rev %d), Version %s",
5599 get_xena_rev_id(sp->pdev), 6127 get_xena_rev_id(sp->pdev),
5600 s2io_driver_version); 6128 s2io_driver_version);
5601#ifdef CONFIG_2BUFF_MODE 6129#ifdef CONFIG_2BUFF_MODE
5602 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); 6130 DBG_PRINT(ERR_DBG, ", Buffer mode %d",2);
5603#endif 6131#endif
6132 switch(sp->intr_type) {
6133 case INTA:
6134 DBG_PRINT(ERR_DBG, ", Intr type INTA");
6135 break;
6136 case MSI:
6137 DBG_PRINT(ERR_DBG, ", Intr type MSI");
6138 break;
6139 case MSI_X:
6140 DBG_PRINT(ERR_DBG, ", Intr type MSI-X");
6141 break;
6142 }
5604 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); 6143 DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n");
5605 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", 6144 DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n",
5606 sp->def_mac_addr[0].mac_addr[0], 6145 sp->def_mac_addr[0].mac_addr[0],
@@ -5644,7 +6183,14 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
5644 mem_alloc_failed: 6183 mem_alloc_failed:
5645 free_shared_mem(sp); 6184 free_shared_mem(sp);
5646 pci_disable_device(pdev); 6185 pci_disable_device(pdev);
5647 pci_release_regions(pdev); 6186 if (dev_intr_type != MSI_X)
6187 pci_release_regions(pdev);
6188 else {
6189 release_mem_region(pci_resource_start(pdev, 0),
6190 pci_resource_len(pdev, 0));
6191 release_mem_region(pci_resource_start(pdev, 2),
6192 pci_resource_len(pdev, 2));
6193 }
5648 pci_set_drvdata(pdev, NULL); 6194 pci_set_drvdata(pdev, NULL);
5649 free_netdev(dev); 6195 free_netdev(dev);
5650 6196
@@ -5678,7 +6224,14 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
5678 iounmap(sp->bar0); 6224 iounmap(sp->bar0);
5679 iounmap(sp->bar1); 6225 iounmap(sp->bar1);
5680 pci_disable_device(pdev); 6226 pci_disable_device(pdev);
5681 pci_release_regions(pdev); 6227 if (sp->intr_type != MSI_X)
6228 pci_release_regions(pdev);
6229 else {
6230 release_mem_region(pci_resource_start(pdev, 0),
6231 pci_resource_len(pdev, 0));
6232 release_mem_region(pci_resource_start(pdev, 2),
6233 pci_resource_len(pdev, 2));
6234 }
5682 pci_set_drvdata(pdev, NULL); 6235 pci_set_drvdata(pdev, NULL);
5683 free_netdev(dev); 6236 free_netdev(dev);
5684} 6237}
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 89151cb52181..1cc24b56760e 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -652,6 +652,30 @@ typedef struct {
652#define SMALL_BLK_CNT 30 652#define SMALL_BLK_CNT 30
653#define LARGE_BLK_CNT 100 653#define LARGE_BLK_CNT 100
654 654
655/*
656 * Structure to keep track of the MSI-X vectors and the corresponding
657 * argument registered against each vector
658 */
659#define MAX_REQUESTED_MSI_X 17
660struct s2io_msix_entry
661{
662 u16 vector;
663 u16 entry;
664 void *arg;
665
666 u8 type;
667#define MSIX_FIFO_TYPE 1
668#define MSIX_RING_TYPE 2
669
670 u8 in_use;
671#define MSIX_REGISTERED_SUCCESS 0xAA
672};
673
674struct msix_info_st {
675 u64 addr;
676 u64 data;
677};
678
655/* Structure representing one instance of the NIC */ 679/* Structure representing one instance of the NIC */
656struct s2io_nic { 680struct s2io_nic {
657#ifdef CONFIG_S2IO_NAPI 681#ifdef CONFIG_S2IO_NAPI
@@ -719,13 +743,8 @@ struct s2io_nic {
719 * a schedule task that will set the correct Link state once the 743 * a schedule task that will set the correct Link state once the
720 * NIC's PHY has stabilized after a state change. 744 * NIC's PHY has stabilized after a state change.
721 */ 745 */
722#ifdef INIT_TQUEUE
723 struct tq_struct rst_timer_task;
724 struct tq_struct set_link_task;
725#else
726 struct work_struct rst_timer_task; 746 struct work_struct rst_timer_task;
727 struct work_struct set_link_task; 747 struct work_struct set_link_task;
728#endif
729 748
730 /* Flag that can be used to turn on or turn off the Rx checksum 749 /* Flag that can be used to turn on or turn off the Rx checksum
731 * offload feature. 750 * offload feature.
@@ -748,10 +767,23 @@ struct s2io_nic {
748 atomic_t card_state; 767 atomic_t card_state;
749 volatile unsigned long link_state; 768 volatile unsigned long link_state;
750 struct vlan_group *vlgrp; 769 struct vlan_group *vlgrp;
770#define MSIX_FLG 0xA5
771 struct msix_entry *entries;
772 struct s2io_msix_entry *s2io_entries;
773 char desc1[35];
774 char desc2[35];
775
776 struct msix_info_st msix_info[0x3f];
777
751#define XFRAME_I_DEVICE 1 778#define XFRAME_I_DEVICE 1
752#define XFRAME_II_DEVICE 2 779#define XFRAME_II_DEVICE 2
753 u8 device_type; 780 u8 device_type;
754 781
782#define INTA 0
783#define MSI 1
784#define MSI_X 2
785 u8 intr_type;
786
755 spinlock_t rx_lock; 787 spinlock_t rx_lock;
756 atomic_t isr_cnt; 788 atomic_t isr_cnt;
757}; 789};
@@ -886,6 +918,13 @@ static int s2io_poll(struct net_device *dev, int *budget);
886static void s2io_init_pci(nic_t * sp); 918static void s2io_init_pci(nic_t * sp);
887int s2io_set_mac_addr(struct net_device *dev, u8 * addr); 919int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
888static void s2io_alarm_handle(unsigned long data); 920static void s2io_alarm_handle(unsigned long data);
921static int s2io_enable_msi(nic_t *nic);
922static irqreturn_t s2io_msi_handle(int irq, void *dev_id, struct pt_regs *regs);
923static irqreturn_t
924s2io_msix_ring_handle(int irq, void *dev_id, struct pt_regs *regs);
925static irqreturn_t
926s2io_msix_fifo_handle(int irq, void *dev_id, struct pt_regs *regs);
927int s2io_enable_msi_x(nic_t *nic);
889static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs); 928static irqreturn_t s2io_isr(int irq, void *dev_id, struct pt_regs *regs);
890static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); 929static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
891static struct ethtool_ops netdev_ethtool_ops; 930static struct ethtool_ops netdev_ethtool_ops;
@@ -894,4 +933,5 @@ int s2io_set_swapper(nic_t * sp);
894static void s2io_card_down(nic_t *nic); 933static void s2io_card_down(nic_t *nic);
895static int s2io_card_up(nic_t *nic); 934static int s2io_card_up(nic_t *nic);
896int get_xena_rev_id(struct pci_dev *pdev); 935int get_xena_rev_id(struct pci_dev *pdev);
936void restore_xmsi_data(nic_t *nic);
897#endif /* _S2IO_H */ 937#endif /* _S2IO_H */
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 7abd55a4fb21..aa4ca1821759 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -10,7 +10,7 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -118,8 +118,6 @@ MODULE_PARM_DESC(int_timeout, "Timeout value");
118 ********************************************************************* */ 118 ********************************************************************* */
119 119
120 120
121typedef unsigned long sbmac_port_t;
122
123typedef enum { sbmac_speed_auto, sbmac_speed_10, 121typedef enum { sbmac_speed_auto, sbmac_speed_10,
124 sbmac_speed_100, sbmac_speed_1000 } sbmac_speed_t; 122 sbmac_speed_100, sbmac_speed_1000 } sbmac_speed_t;
125 123
@@ -129,7 +127,7 @@ typedef enum { sbmac_duplex_auto, sbmac_duplex_half,
129typedef enum { sbmac_fc_auto, sbmac_fc_disabled, sbmac_fc_frame, 127typedef enum { sbmac_fc_auto, sbmac_fc_disabled, sbmac_fc_frame,
130 sbmac_fc_collision, sbmac_fc_carrier } sbmac_fc_t; 128 sbmac_fc_collision, sbmac_fc_carrier } sbmac_fc_t;
131 129
132typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on, 130typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on,
133 sbmac_state_broken } sbmac_state_t; 131 sbmac_state_broken } sbmac_state_t;
134 132
135 133
@@ -144,17 +142,13 @@ typedef enum { sbmac_state_uninit, sbmac_state_off, sbmac_state_on,
144 142
145#define NUMCACHEBLKS(x) (((x)+SMP_CACHE_BYTES-1)/SMP_CACHE_BYTES) 143#define NUMCACHEBLKS(x) (((x)+SMP_CACHE_BYTES-1)/SMP_CACHE_BYTES)
146 144
147#define SBMAC_READCSR(t) __raw_readq((unsigned long)t)
148#define SBMAC_WRITECSR(t,v) __raw_writeq(v, (unsigned long)t)
149
150
151#define SBMAC_MAX_TXDESCR 32 145#define SBMAC_MAX_TXDESCR 32
152#define SBMAC_MAX_RXDESCR 32 146#define SBMAC_MAX_RXDESCR 32
153 147
154#define ETHER_ALIGN 2 148#define ETHER_ALIGN 2
155#define ETHER_ADDR_LEN 6 149#define ETHER_ADDR_LEN 6
156#define ENET_PACKET_SIZE 1518 150#define ENET_PACKET_SIZE 1518
157/*#define ENET_PACKET_SIZE 9216 */ 151/*#define ENET_PACKET_SIZE 9216 */
158 152
159/********************************************************************** 153/**********************************************************************
160 * DMA Descriptor structure 154 * DMA Descriptor structure
@@ -172,12 +166,12 @@ typedef unsigned long paddr_t;
172 ********************************************************************* */ 166 ********************************************************************* */
173 167
174typedef struct sbmacdma_s { 168typedef struct sbmacdma_s {
175 169
176 /* 170 /*
177 * This stuff is used to identify the channel and the registers 171 * This stuff is used to identify the channel and the registers
178 * associated with it. 172 * associated with it.
179 */ 173 */
180 174
181 struct sbmac_softc *sbdma_eth; /* back pointer to associated MAC */ 175 struct sbmac_softc *sbdma_eth; /* back pointer to associated MAC */
182 int sbdma_channel; /* channel number */ 176 int sbdma_channel; /* channel number */
183 int sbdma_txdir; /* direction (1=transmit) */ 177 int sbdma_txdir; /* direction (1=transmit) */
@@ -187,21 +181,21 @@ typedef struct sbmacdma_s {
187 int sbdma_int_timeout; /* # usec rx/tx interrupt */ 181 int sbdma_int_timeout; /* # usec rx/tx interrupt */
188#endif 182#endif
189 183
190 sbmac_port_t sbdma_config0; /* DMA config register 0 */ 184 volatile void __iomem *sbdma_config0; /* DMA config register 0 */
191 sbmac_port_t sbdma_config1; /* DMA config register 1 */ 185 volatile void __iomem *sbdma_config1; /* DMA config register 1 */
192 sbmac_port_t sbdma_dscrbase; /* Descriptor base address */ 186 volatile void __iomem *sbdma_dscrbase; /* Descriptor base address */
193 sbmac_port_t sbdma_dscrcnt; /* Descriptor count register */ 187 volatile void __iomem *sbdma_dscrcnt; /* Descriptor count register */
194 sbmac_port_t sbdma_curdscr; /* current descriptor address */ 188 volatile void __iomem *sbdma_curdscr; /* current descriptor address */
195 189
196 /* 190 /*
197 * This stuff is for maintenance of the ring 191 * This stuff is for maintenance of the ring
198 */ 192 */
199 193
200 sbdmadscr_t *sbdma_dscrtable; /* base of descriptor table */ 194 sbdmadscr_t *sbdma_dscrtable; /* base of descriptor table */
201 sbdmadscr_t *sbdma_dscrtable_end; /* end of descriptor table */ 195 sbdmadscr_t *sbdma_dscrtable_end; /* end of descriptor table */
202 196
203 struct sk_buff **sbdma_ctxtable; /* context table, one per descr */ 197 struct sk_buff **sbdma_ctxtable; /* context table, one per descr */
204 198
205 paddr_t sbdma_dscrtable_phys; /* and also the phys addr */ 199 paddr_t sbdma_dscrtable_phys; /* and also the phys addr */
206 sbdmadscr_t *sbdma_addptr; /* next dscr for sw to add */ 200 sbdmadscr_t *sbdma_addptr; /* next dscr for sw to add */
207 sbdmadscr_t *sbdma_remptr; /* next dscr for sw to remove */ 201 sbdmadscr_t *sbdma_remptr; /* next dscr for sw to remove */
@@ -213,15 +207,15 @@ typedef struct sbmacdma_s {
213 ********************************************************************* */ 207 ********************************************************************* */
214 208
215struct sbmac_softc { 209struct sbmac_softc {
216 210
217 /* 211 /*
218 * Linux-specific things 212 * Linux-specific things
219 */ 213 */
220 214
221 struct net_device *sbm_dev; /* pointer to linux device */ 215 struct net_device *sbm_dev; /* pointer to linux device */
222 spinlock_t sbm_lock; /* spin lock */ 216 spinlock_t sbm_lock; /* spin lock */
223 struct timer_list sbm_timer; /* for monitoring MII */ 217 struct timer_list sbm_timer; /* for monitoring MII */
224 struct net_device_stats sbm_stats; 218 struct net_device_stats sbm_stats;
225 int sbm_devflags; /* current device flags */ 219 int sbm_devflags; /* current device flags */
226 220
227 int sbm_phy_oldbmsr; 221 int sbm_phy_oldbmsr;
@@ -229,31 +223,31 @@ struct sbmac_softc {
229 int sbm_phy_oldk1stsr; 223 int sbm_phy_oldk1stsr;
230 int sbm_phy_oldlinkstat; 224 int sbm_phy_oldlinkstat;
231 int sbm_buffersize; 225 int sbm_buffersize;
232 226
233 unsigned char sbm_phys[2]; 227 unsigned char sbm_phys[2];
234 228
235 /* 229 /*
236 * Controller-specific things 230 * Controller-specific things
237 */ 231 */
238 232
239 unsigned long sbm_base; /* MAC's base address */ 233 volatile void __iomem *sbm_base; /* MAC's base address */
240 sbmac_state_t sbm_state; /* current state */ 234 sbmac_state_t sbm_state; /* current state */
241 235
242 sbmac_port_t sbm_macenable; /* MAC Enable Register */ 236 volatile void __iomem *sbm_macenable; /* MAC Enable Register */
243 sbmac_port_t sbm_maccfg; /* MAC Configuration Register */ 237 volatile void __iomem *sbm_maccfg; /* MAC Configuration Register */
244 sbmac_port_t sbm_fifocfg; /* FIFO configuration register */ 238 volatile void __iomem *sbm_fifocfg; /* FIFO configuration register */
245 sbmac_port_t sbm_framecfg; /* Frame configuration register */ 239 volatile void __iomem *sbm_framecfg; /* Frame configuration register */
246 sbmac_port_t sbm_rxfilter; /* receive filter register */ 240 volatile void __iomem *sbm_rxfilter; /* receive filter register */
247 sbmac_port_t sbm_isr; /* Interrupt status register */ 241 volatile void __iomem *sbm_isr; /* Interrupt status register */
248 sbmac_port_t sbm_imr; /* Interrupt mask register */ 242 volatile void __iomem *sbm_imr; /* Interrupt mask register */
249 sbmac_port_t sbm_mdio; /* MDIO register */ 243 volatile void __iomem *sbm_mdio; /* MDIO register */
250 244
251 sbmac_speed_t sbm_speed; /* current speed */ 245 sbmac_speed_t sbm_speed; /* current speed */
252 sbmac_duplex_t sbm_duplex; /* current duplex */ 246 sbmac_duplex_t sbm_duplex; /* current duplex */
253 sbmac_fc_t sbm_fc; /* current flow control setting */ 247 sbmac_fc_t sbm_fc; /* current flow control setting */
254 248
255 unsigned char sbm_hwaddr[ETHER_ADDR_LEN]; 249 unsigned char sbm_hwaddr[ETHER_ADDR_LEN];
256 250
257 sbmacdma_t sbm_txdma; /* for now, only use channel 0 */ 251 sbmacdma_t sbm_txdma; /* for now, only use channel 0 */
258 sbmacdma_t sbm_rxdma; 252 sbmacdma_t sbm_rxdma;
259 int rx_hw_checksum; 253 int rx_hw_checksum;
@@ -302,6 +296,7 @@ static void sbmac_set_rx_mode(struct net_device *dev);
302static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 296static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
303static int sbmac_close(struct net_device *dev); 297static int sbmac_close(struct net_device *dev);
304static int sbmac_mii_poll(struct sbmac_softc *s,int noisy); 298static int sbmac_mii_poll(struct sbmac_softc *s,int noisy);
299static int sbmac_mii_probe(struct net_device *dev);
305 300
306static void sbmac_mii_sync(struct sbmac_softc *s); 301static void sbmac_mii_sync(struct sbmac_softc *s);
307static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitcnt); 302static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitcnt);
@@ -439,6 +434,9 @@ static uint64_t sbmac_orig_hwaddr[MAX_UNITS];
439 434
440#define MII_BMCR 0x00 /* Basic mode control register (rw) */ 435#define MII_BMCR 0x00 /* Basic mode control register (rw) */
441#define MII_BMSR 0x01 /* Basic mode status register (ro) */ 436#define MII_BMSR 0x01 /* Basic mode status register (ro) */
437#define MII_PHYIDR1 0x02
438#define MII_PHYIDR2 0x03
439
442#define MII_K1STSR 0x0A /* 1K Status Register (ro) */ 440#define MII_K1STSR 0x0A /* 1K Status Register (ro) */
443#define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */ 441#define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */
444 442
@@ -450,13 +448,13 @@ static uint64_t sbmac_orig_hwaddr[MAX_UNITS];
450 448
451/********************************************************************** 449/**********************************************************************
452 * SBMAC_MII_SYNC(s) 450 * SBMAC_MII_SYNC(s)
453 * 451 *
454 * Synchronize with the MII - send a pattern of bits to the MII 452 * Synchronize with the MII - send a pattern of bits to the MII
455 * that will guarantee that it is ready to accept a command. 453 * that will guarantee that it is ready to accept a command.
456 * 454 *
457 * Input parameters: 455 * Input parameters:
458 * s - sbmac structure 456 * s - sbmac structure
459 * 457 *
460 * Return value: 458 * Return value:
461 * nothing 459 * nothing
462 ********************************************************************* */ 460 ********************************************************************* */
@@ -467,25 +465,25 @@ static void sbmac_mii_sync(struct sbmac_softc *s)
467 uint64_t bits; 465 uint64_t bits;
468 int mac_mdio_genc; 466 int mac_mdio_genc;
469 467
470 mac_mdio_genc = SBMAC_READCSR(s->sbm_mdio) & M_MAC_GENC; 468 mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
471 469
472 bits = M_MAC_MDIO_DIR_OUTPUT | M_MAC_MDIO_OUT; 470 bits = M_MAC_MDIO_DIR_OUTPUT | M_MAC_MDIO_OUT;
473 471
474 SBMAC_WRITECSR(s->sbm_mdio,bits | mac_mdio_genc); 472 __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
475 473
476 for (cnt = 0; cnt < 32; cnt++) { 474 for (cnt = 0; cnt < 32; cnt++) {
477 SBMAC_WRITECSR(s->sbm_mdio,bits | M_MAC_MDC | mac_mdio_genc); 475 __raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
478 SBMAC_WRITECSR(s->sbm_mdio,bits | mac_mdio_genc); 476 __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
479 } 477 }
480} 478}
481 479
482/********************************************************************** 480/**********************************************************************
483 * SBMAC_MII_SENDDATA(s,data,bitcnt) 481 * SBMAC_MII_SENDDATA(s,data,bitcnt)
484 * 482 *
485 * Send some bits to the MII. The bits to be sent are right- 483 * Send some bits to the MII. The bits to be sent are right-
486 * justified in the 'data' parameter. 484 * justified in the 'data' parameter.
487 * 485 *
488 * Input parameters: 486 * Input parameters:
489 * s - sbmac structure 487 * s - sbmac structure
490 * data - data to send 488 * data - data to send
491 * bitcnt - number of bits to send 489 * bitcnt - number of bits to send
@@ -498,20 +496,20 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc
498 unsigned int curmask; 496 unsigned int curmask;
499 int mac_mdio_genc; 497 int mac_mdio_genc;
500 498
501 mac_mdio_genc = SBMAC_READCSR(s->sbm_mdio) & M_MAC_GENC; 499 mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
502 500
503 bits = M_MAC_MDIO_DIR_OUTPUT; 501 bits = M_MAC_MDIO_DIR_OUTPUT;
504 SBMAC_WRITECSR(s->sbm_mdio,bits | mac_mdio_genc); 502 __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
505 503
506 curmask = 1 << (bitcnt - 1); 504 curmask = 1 << (bitcnt - 1);
507 505
508 for (i = 0; i < bitcnt; i++) { 506 for (i = 0; i < bitcnt; i++) {
509 if (data & curmask) 507 if (data & curmask)
510 bits |= M_MAC_MDIO_OUT; 508 bits |= M_MAC_MDIO_OUT;
511 else bits &= ~M_MAC_MDIO_OUT; 509 else bits &= ~M_MAC_MDIO_OUT;
512 SBMAC_WRITECSR(s->sbm_mdio,bits | mac_mdio_genc); 510 __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
513 SBMAC_WRITECSR(s->sbm_mdio,bits | M_MAC_MDC | mac_mdio_genc); 511 __raw_writeq(bits | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
514 SBMAC_WRITECSR(s->sbm_mdio,bits | mac_mdio_genc); 512 __raw_writeq(bits | mac_mdio_genc, s->sbm_mdio);
515 curmask >>= 1; 513 curmask >>= 1;
516 } 514 }
517} 515}
@@ -520,14 +518,14 @@ static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitc
520 518
521/********************************************************************** 519/**********************************************************************
522 * SBMAC_MII_READ(s,phyaddr,regidx) 520 * SBMAC_MII_READ(s,phyaddr,regidx)
523 * 521 *
524 * Read a PHY register. 522 * Read a PHY register.
525 * 523 *
526 * Input parameters: 524 * Input parameters:
527 * s - sbmac structure 525 * s - sbmac structure
528 * phyaddr - PHY's address 526 * phyaddr - PHY's address
529 * regidx = index of register to read 527 * regidx = index of register to read
530 * 528 *
531 * Return value: 529 * Return value:
532 * value read, or 0 if an error occurred. 530 * value read, or 0 if an error occurred.
533 ********************************************************************* */ 531 ********************************************************************* */
@@ -543,9 +541,9 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
543 * Synchronize ourselves so that the PHY knows the next 541 * Synchronize ourselves so that the PHY knows the next
544 * thing coming down is a command 542 * thing coming down is a command
545 */ 543 */
546 544
547 sbmac_mii_sync(s); 545 sbmac_mii_sync(s);
548 546
549 /* 547 /*
550 * Send the data to the PHY. The sequence is 548 * Send the data to the PHY. The sequence is
551 * a "start" command (2 bits) 549 * a "start" command (2 bits)
@@ -553,59 +551,55 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
553 * the PHY addr (5 bits) 551 * the PHY addr (5 bits)
554 * the register index (5 bits) 552 * the register index (5 bits)
555 */ 553 */
556 554
557 sbmac_mii_senddata(s,MII_COMMAND_START, 2); 555 sbmac_mii_senddata(s,MII_COMMAND_START, 2);
558 sbmac_mii_senddata(s,MII_COMMAND_READ, 2); 556 sbmac_mii_senddata(s,MII_COMMAND_READ, 2);
559 sbmac_mii_senddata(s,phyaddr, 5); 557 sbmac_mii_senddata(s,phyaddr, 5);
560 sbmac_mii_senddata(s,regidx, 5); 558 sbmac_mii_senddata(s,regidx, 5);
561 559
562 mac_mdio_genc = SBMAC_READCSR(s->sbm_mdio) & M_MAC_GENC; 560 mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
563 561
564 /* 562 /*
565 * Switch the port around without a clock transition. 563 * Switch the port around without a clock transition.
566 */ 564 */
567 SBMAC_WRITECSR(s->sbm_mdio,M_MAC_MDIO_DIR_INPUT | mac_mdio_genc); 565 __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
568 566
569 /* 567 /*
570 * Send out a clock pulse to signal we want the status 568 * Send out a clock pulse to signal we want the status
571 */ 569 */
572 570
573 SBMAC_WRITECSR(s->sbm_mdio, 571 __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
574 M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc); 572 __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
575 SBMAC_WRITECSR(s->sbm_mdio,M_MAC_MDIO_DIR_INPUT | mac_mdio_genc); 573
576 574 /*
577 /*
578 * If an error occurred, the PHY will signal '1' back 575 * If an error occurred, the PHY will signal '1' back
579 */ 576 */
580 error = SBMAC_READCSR(s->sbm_mdio) & M_MAC_MDIO_IN; 577 error = __raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN;
581 578
582 /* 579 /*
583 * Issue an 'idle' clock pulse, but keep the direction 580 * Issue an 'idle' clock pulse, but keep the direction
584 * the same. 581 * the same.
585 */ 582 */
586 SBMAC_WRITECSR(s->sbm_mdio, 583 __raw_writeq(M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
587 M_MAC_MDIO_DIR_INPUT | M_MAC_MDC | mac_mdio_genc); 584 __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
588 SBMAC_WRITECSR(s->sbm_mdio,M_MAC_MDIO_DIR_INPUT | mac_mdio_genc); 585
589
590 regval = 0; 586 regval = 0;
591 587
592 for (idx = 0; idx < 16; idx++) { 588 for (idx = 0; idx < 16; idx++) {
593 regval <<= 1; 589 regval <<= 1;
594 590
595 if (error == 0) { 591 if (error == 0) {
596 if (SBMAC_READCSR(s->sbm_mdio) & M_MAC_MDIO_IN) 592 if (__raw_readq(s->sbm_mdio) & M_MAC_MDIO_IN)
597 regval |= 1; 593 regval |= 1;
598 } 594 }
599 595
600 SBMAC_WRITECSR(s->sbm_mdio, 596 __raw_writeq(M_MAC_MDIO_DIR_INPUT|M_MAC_MDC | mac_mdio_genc, s->sbm_mdio);
601 M_MAC_MDIO_DIR_INPUT|M_MAC_MDC | mac_mdio_genc); 597 __raw_writeq(M_MAC_MDIO_DIR_INPUT | mac_mdio_genc, s->sbm_mdio);
602 SBMAC_WRITECSR(s->sbm_mdio,
603 M_MAC_MDIO_DIR_INPUT | mac_mdio_genc);
604 } 598 }
605 599
606 /* Switch back to output */ 600 /* Switch back to output */
607 SBMAC_WRITECSR(s->sbm_mdio,M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc); 601 __raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, s->sbm_mdio);
608 602
609 if (error == 0) 603 if (error == 0)
610 return regval; 604 return regval;
611 return 0; 605 return 0;
@@ -614,15 +608,15 @@ static unsigned int sbmac_mii_read(struct sbmac_softc *s,int phyaddr,int regidx)
614 608
615/********************************************************************** 609/**********************************************************************
616 * SBMAC_MII_WRITE(s,phyaddr,regidx,regval) 610 * SBMAC_MII_WRITE(s,phyaddr,regidx,regval)
617 * 611 *
618 * Write a value to a PHY register. 612 * Write a value to a PHY register.
619 * 613 *
620 * Input parameters: 614 * Input parameters:
621 * s - sbmac structure 615 * s - sbmac structure
622 * phyaddr - PHY to use 616 * phyaddr - PHY to use
623 * regidx - register within the PHY 617 * regidx - register within the PHY
624 * regval - data to write to register 618 * regval - data to write to register
625 * 619 *
626 * Return value: 620 * Return value:
627 * nothing 621 * nothing
628 ********************************************************************* */ 622 ********************************************************************* */
@@ -633,7 +627,7 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx,
633 int mac_mdio_genc; 627 int mac_mdio_genc;
634 628
635 sbmac_mii_sync(s); 629 sbmac_mii_sync(s);
636 630
637 sbmac_mii_senddata(s,MII_COMMAND_START,2); 631 sbmac_mii_senddata(s,MII_COMMAND_START,2);
638 sbmac_mii_senddata(s,MII_COMMAND_WRITE,2); 632 sbmac_mii_senddata(s,MII_COMMAND_WRITE,2);
639 sbmac_mii_senddata(s,phyaddr, 5); 633 sbmac_mii_senddata(s,phyaddr, 5);
@@ -641,27 +635,27 @@ static void sbmac_mii_write(struct sbmac_softc *s,int phyaddr,int regidx,
641 sbmac_mii_senddata(s,MII_COMMAND_ACK,2); 635 sbmac_mii_senddata(s,MII_COMMAND_ACK,2);
642 sbmac_mii_senddata(s,regval,16); 636 sbmac_mii_senddata(s,regval,16);
643 637
644 mac_mdio_genc = SBMAC_READCSR(s->sbm_mdio) & M_MAC_GENC; 638 mac_mdio_genc = __raw_readq(s->sbm_mdio) & M_MAC_GENC;
645 639
646 SBMAC_WRITECSR(s->sbm_mdio,M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc); 640 __raw_writeq(M_MAC_MDIO_DIR_OUTPUT | mac_mdio_genc, s->sbm_mdio);
647} 641}
648 642
649 643
650 644
651/********************************************************************** 645/**********************************************************************
652 * SBDMA_INITCTX(d,s,chan,txrx,maxdescr) 646 * SBDMA_INITCTX(d,s,chan,txrx,maxdescr)
653 * 647 *
654 * Initialize a DMA channel context. Since there are potentially 648 * Initialize a DMA channel context. Since there are potentially
655 * eight DMA channels per MAC, it's nice to do this in a standard 649 * eight DMA channels per MAC, it's nice to do this in a standard
656 * way. 650 * way.
657 * 651 *
658 * Input parameters: 652 * Input parameters:
659 * d - sbmacdma_t structure (DMA channel context) 653 * d - sbmacdma_t structure (DMA channel context)
660 * s - sbmac_softc structure (pointer to a MAC) 654 * s - sbmac_softc structure (pointer to a MAC)
661 * chan - channel number (0..1 right now) 655 * chan - channel number (0..1 right now)
662 * txrx - Identifies DMA_TX or DMA_RX for channel direction 656 * txrx - Identifies DMA_TX or DMA_RX for channel direction
663 * maxdescr - number of descriptors 657 * maxdescr - number of descriptors
664 * 658 *
665 * Return value: 659 * Return value:
666 * nothing 660 * nothing
667 ********************************************************************* */ 661 ********************************************************************* */
@@ -672,101 +666,87 @@ static void sbdma_initctx(sbmacdma_t *d,
672 int txrx, 666 int txrx,
673 int maxdescr) 667 int maxdescr)
674{ 668{
675 /* 669 /*
676 * Save away interesting stuff in the structure 670 * Save away interesting stuff in the structure
677 */ 671 */
678 672
679 d->sbdma_eth = s; 673 d->sbdma_eth = s;
680 d->sbdma_channel = chan; 674 d->sbdma_channel = chan;
681 d->sbdma_txdir = txrx; 675 d->sbdma_txdir = txrx;
682 676
683#if 0 677#if 0
684 /* RMON clearing */ 678 /* RMON clearing */
685 s->sbe_idx =(s->sbm_base - A_MAC_BASE_0)/MAC_SPACING; 679 s->sbe_idx =(s->sbm_base - A_MAC_BASE_0)/MAC_SPACING;
686#endif 680#endif
687 681
688 SBMAC_WRITECSR(IOADDR( 682 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_BYTES)));
689 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_BYTES)), 0); 683 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_COLLISIONS)));
690 SBMAC_WRITECSR(IOADDR( 684 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_LATE_COL)));
691 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_COLLISIONS)), 0); 685 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_EX_COL)));
692 SBMAC_WRITECSR(IOADDR( 686 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_FCS_ERROR)));
693 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_LATE_COL)), 0); 687 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_ABORT)));
694 SBMAC_WRITECSR(IOADDR( 688 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_BAD)));
695 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_EX_COL)), 0); 689 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_GOOD)));
696 SBMAC_WRITECSR(IOADDR( 690 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_RUNT)));
697 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_FCS_ERROR)), 0); 691 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_OVERSIZE)));
698 SBMAC_WRITECSR(IOADDR( 692 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BYTES)));
699 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_ABORT)), 0); 693 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_MCAST)));
700 SBMAC_WRITECSR(IOADDR( 694 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BCAST)));
701 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_BAD)), 0); 695 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BAD)));
702 SBMAC_WRITECSR(IOADDR( 696 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_GOOD)));
703 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_GOOD)), 0); 697 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_RUNT)));
704 SBMAC_WRITECSR(IOADDR( 698 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_OVERSIZE)));
705 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_RUNT)), 0); 699 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_FCS_ERROR)));
706 SBMAC_WRITECSR(IOADDR( 700 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_LENGTH_ERROR)));
707 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_TX_OVERSIZE)), 0); 701 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_CODE_ERROR)));
708 SBMAC_WRITECSR(IOADDR( 702 __raw_writeq(0, IOADDR(A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_ALIGN_ERROR)));
709 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BYTES)), 0); 703
710 SBMAC_WRITECSR(IOADDR( 704 /*
711 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_MCAST)), 0); 705 * initialize register pointers
712 SBMAC_WRITECSR(IOADDR( 706 */
713 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BCAST)), 0); 707
714 SBMAC_WRITECSR(IOADDR( 708 d->sbdma_config0 =
715 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_BAD)), 0);
716 SBMAC_WRITECSR(IOADDR(
717 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_GOOD)), 0);
718 SBMAC_WRITECSR(IOADDR(
719 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_RUNT)), 0);
720 SBMAC_WRITECSR(IOADDR(
721 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_OVERSIZE)), 0);
722 SBMAC_WRITECSR(IOADDR(
723 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_FCS_ERROR)), 0);
724 SBMAC_WRITECSR(IOADDR(
725 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_LENGTH_ERROR)), 0);
726 SBMAC_WRITECSR(IOADDR(
727 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_CODE_ERROR)), 0);
728 SBMAC_WRITECSR(IOADDR(
729 A_MAC_REGISTER(s->sbe_idx, R_MAC_RMON_RX_ALIGN_ERROR)), 0);
730
731 /*
732 * initialize register pointers
733 */
734
735 d->sbdma_config0 =
736 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG0); 709 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG0);
737 d->sbdma_config1 = 710 d->sbdma_config1 =
738 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG1); 711 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CONFIG1);
739 d->sbdma_dscrbase = 712 d->sbdma_dscrbase =
740 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_BASE); 713 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_BASE);
741 d->sbdma_dscrcnt = 714 d->sbdma_dscrcnt =
742 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_CNT); 715 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_DSCR_CNT);
743 d->sbdma_curdscr = 716 d->sbdma_curdscr =
744 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CUR_DSCRADDR); 717 s->sbm_base + R_MAC_DMA_REGISTER(txrx,chan,R_MAC_DMA_CUR_DSCRADDR);
745 718
746 /* 719 /*
747 * Allocate memory for the ring 720 * Allocate memory for the ring
748 */ 721 */
749 722
750 d->sbdma_maxdescr = maxdescr; 723 d->sbdma_maxdescr = maxdescr;
751 724
752 d->sbdma_dscrtable = (sbdmadscr_t *) 725 d->sbdma_dscrtable = (sbdmadscr_t *)
753 kmalloc(d->sbdma_maxdescr*sizeof(sbdmadscr_t), GFP_KERNEL); 726 kmalloc((d->sbdma_maxdescr+1)*sizeof(sbdmadscr_t), GFP_KERNEL);
754 727
728 /*
729 * The descriptor table must be aligned to at least 16 bytes or the
730 * MAC will corrupt it.
731 */
732 d->sbdma_dscrtable = (sbdmadscr_t *)
733 ALIGN((unsigned long)d->sbdma_dscrtable, sizeof(sbdmadscr_t));
734
755 memset(d->sbdma_dscrtable,0,d->sbdma_maxdescr*sizeof(sbdmadscr_t)); 735 memset(d->sbdma_dscrtable,0,d->sbdma_maxdescr*sizeof(sbdmadscr_t));
756 736
757 d->sbdma_dscrtable_end = d->sbdma_dscrtable + d->sbdma_maxdescr; 737 d->sbdma_dscrtable_end = d->sbdma_dscrtable + d->sbdma_maxdescr;
758 738
759 d->sbdma_dscrtable_phys = virt_to_phys(d->sbdma_dscrtable); 739 d->sbdma_dscrtable_phys = virt_to_phys(d->sbdma_dscrtable);
760 740
761 /* 741 /*
762 * And context table 742 * And context table
763 */ 743 */
764 744
765 d->sbdma_ctxtable = (struct sk_buff **) 745 d->sbdma_ctxtable = (struct sk_buff **)
766 kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL); 746 kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL);
767 747
768 memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *)); 748 memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *));
769 749
770#ifdef CONFIG_SBMAC_COALESCE 750#ifdef CONFIG_SBMAC_COALESCE
771 /* 751 /*
772 * Setup Rx/Tx DMA coalescing defaults 752 * Setup Rx/Tx DMA coalescing defaults
@@ -777,7 +757,7 @@ static void sbdma_initctx(sbmacdma_t *d,
777 } else { 757 } else {
778 d->sbdma_int_pktcnt = 1; 758 d->sbdma_int_pktcnt = 1;
779 } 759 }
780 760
781 if ( int_timeout ) { 761 if ( int_timeout ) {
782 d->sbdma_int_timeout = int_timeout; 762 d->sbdma_int_timeout = int_timeout;
783 } else { 763 } else {
@@ -789,13 +769,13 @@ static void sbdma_initctx(sbmacdma_t *d,
789 769
790/********************************************************************** 770/**********************************************************************
791 * SBDMA_CHANNEL_START(d) 771 * SBDMA_CHANNEL_START(d)
792 * 772 *
793 * Initialize the hardware registers for a DMA channel. 773 * Initialize the hardware registers for a DMA channel.
794 * 774 *
795 * Input parameters: 775 * Input parameters:
796 * d - DMA channel to init (context must be previously init'd 776 * d - DMA channel to init (context must be previously init'd
797 * rxtx - DMA_RX or DMA_TX depending on what type of channel 777 * rxtx - DMA_RX or DMA_TX depending on what type of channel
798 * 778 *
799 * Return value: 779 * Return value:
800 * nothing 780 * nothing
801 ********************************************************************* */ 781 ********************************************************************* */
@@ -805,24 +785,21 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx )
805 /* 785 /*
806 * Turn on the DMA channel 786 * Turn on the DMA channel
807 */ 787 */
808 788
809#ifdef CONFIG_SBMAC_COALESCE 789#ifdef CONFIG_SBMAC_COALESCE
810 SBMAC_WRITECSR(d->sbdma_config1, 790 __raw_writeq(V_DMA_INT_TIMEOUT(d->sbdma_int_timeout) |
811 V_DMA_INT_TIMEOUT(d->sbdma_int_timeout) | 791 0, d->sbdma_config1);
812 0); 792 __raw_writeq(M_DMA_EOP_INT_EN |
813 SBMAC_WRITECSR(d->sbdma_config0,
814 M_DMA_EOP_INT_EN |
815 V_DMA_RINGSZ(d->sbdma_maxdescr) | 793 V_DMA_RINGSZ(d->sbdma_maxdescr) |
816 V_DMA_INT_PKTCNT(d->sbdma_int_pktcnt) | 794 V_DMA_INT_PKTCNT(d->sbdma_int_pktcnt) |
817 0); 795 0, d->sbdma_config0);
818#else 796#else
819 SBMAC_WRITECSR(d->sbdma_config1,0); 797 __raw_writeq(0, d->sbdma_config1);
820 SBMAC_WRITECSR(d->sbdma_config0, 798 __raw_writeq(V_DMA_RINGSZ(d->sbdma_maxdescr) |
821 V_DMA_RINGSZ(d->sbdma_maxdescr) | 799 0, d->sbdma_config0);
822 0);
823#endif 800#endif
824 801
825 SBMAC_WRITECSR(d->sbdma_dscrbase,d->sbdma_dscrtable_phys); 802 __raw_writeq(d->sbdma_dscrtable_phys, d->sbdma_dscrbase);
826 803
827 /* 804 /*
828 * Initialize ring pointers 805 * Initialize ring pointers
@@ -834,12 +811,12 @@ static void sbdma_channel_start(sbmacdma_t *d, int rxtx )
834 811
835/********************************************************************** 812/**********************************************************************
836 * SBDMA_CHANNEL_STOP(d) 813 * SBDMA_CHANNEL_STOP(d)
837 * 814 *
838 * Initialize the hardware registers for a DMA channel. 815 * Initialize the hardware registers for a DMA channel.
839 * 816 *
840 * Input parameters: 817 * Input parameters:
841 * d - DMA channel to init (context must be previously init'd 818 * d - DMA channel to init (context must be previously init'd
842 * 819 *
843 * Return value: 820 * Return value:
844 * nothing 821 * nothing
845 ********************************************************************* */ 822 ********************************************************************* */
@@ -849,44 +826,44 @@ static void sbdma_channel_stop(sbmacdma_t *d)
849 /* 826 /*
850 * Turn off the DMA channel 827 * Turn off the DMA channel
851 */ 828 */
852 829
853 SBMAC_WRITECSR(d->sbdma_config1,0); 830 __raw_writeq(0, d->sbdma_config1);
854 831
855 SBMAC_WRITECSR(d->sbdma_dscrbase,0); 832 __raw_writeq(0, d->sbdma_dscrbase);
856 833
857 SBMAC_WRITECSR(d->sbdma_config0,0); 834 __raw_writeq(0, d->sbdma_config0);
858 835
859 /* 836 /*
860 * Zero ring pointers 837 * Zero ring pointers
861 */ 838 */
862 839
863 d->sbdma_addptr = 0; 840 d->sbdma_addptr = NULL;
864 d->sbdma_remptr = 0; 841 d->sbdma_remptr = NULL;
865} 842}
866 843
867static void sbdma_align_skb(struct sk_buff *skb,int power2,int offset) 844static void sbdma_align_skb(struct sk_buff *skb,int power2,int offset)
868{ 845{
869 unsigned long addr; 846 unsigned long addr;
870 unsigned long newaddr; 847 unsigned long newaddr;
871 848
872 addr = (unsigned long) skb->data; 849 addr = (unsigned long) skb->data;
873 850
874 newaddr = (addr + power2 - 1) & ~(power2 - 1); 851 newaddr = (addr + power2 - 1) & ~(power2 - 1);
875 852
876 skb_reserve(skb,newaddr-addr+offset); 853 skb_reserve(skb,newaddr-addr+offset);
877} 854}
878 855
879 856
880/********************************************************************** 857/**********************************************************************
881 * SBDMA_ADD_RCVBUFFER(d,sb) 858 * SBDMA_ADD_RCVBUFFER(d,sb)
882 * 859 *
883 * Add a buffer to the specified DMA channel. For receive channels, 860 * Add a buffer to the specified DMA channel. For receive channels,
884 * this queues a buffer for inbound packets. 861 * this queues a buffer for inbound packets.
885 * 862 *
886 * Input parameters: 863 * Input parameters:
887 * d - DMA channel descriptor 864 * d - DMA channel descriptor
888 * sb - sk_buff to add, or NULL if we should allocate one 865 * sb - sk_buff to add, or NULL if we should allocate one
889 * 866 *
890 * Return value: 867 * Return value:
891 * 0 if buffer could not be added (ring is full) 868 * 0 if buffer could not be added (ring is full)
892 * 1 if buffer added successfully 869 * 1 if buffer added successfully
@@ -899,24 +876,24 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
899 sbdmadscr_t *nextdsc; 876 sbdmadscr_t *nextdsc;
900 struct sk_buff *sb_new = NULL; 877 struct sk_buff *sb_new = NULL;
901 int pktsize = ENET_PACKET_SIZE; 878 int pktsize = ENET_PACKET_SIZE;
902 879
903 /* get pointer to our current place in the ring */ 880 /* get pointer to our current place in the ring */
904 881
905 dsc = d->sbdma_addptr; 882 dsc = d->sbdma_addptr;
906 nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); 883 nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr);
907 884
908 /* 885 /*
909 * figure out if the ring is full - if the next descriptor 886 * figure out if the ring is full - if the next descriptor
910 * is the same as the one that we're going to remove from 887 * is the same as the one that we're going to remove from
911 * the ring, the ring is full 888 * the ring, the ring is full
912 */ 889 */
913 890
914 if (nextdsc == d->sbdma_remptr) { 891 if (nextdsc == d->sbdma_remptr) {
915 return -ENOSPC; 892 return -ENOSPC;
916 } 893 }
917 894
918 /* 895 /*
919 * Allocate a sk_buff if we don't already have one. 896 * Allocate a sk_buff if we don't already have one.
920 * If we do have an sk_buff, reset it so that it's empty. 897 * If we do have an sk_buff, reset it so that it's empty.
921 * 898 *
922 * Note: sk_buffs don't seem to be guaranteed to have any sort 899 * Note: sk_buffs don't seem to be guaranteed to have any sort
@@ -925,7 +902,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
925 * 902 *
926 * 1. the data does not start in the middle of a cache line. 903 * 1. the data does not start in the middle of a cache line.
927 * 2. The data does not end in the middle of a cache line 904 * 2. The data does not end in the middle of a cache line
928 * 3. The buffer can be aligned such that the IP addresses are 905 * 3. The buffer can be aligned such that the IP addresses are
929 * naturally aligned. 906 * naturally aligned.
930 * 907 *
931 * Remember, the SOCs MAC writes whole cache lines at a time, 908 * Remember, the SOCs MAC writes whole cache lines at a time,
@@ -933,7 +910,7 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
933 * data portion starts in the middle of a cache line, the SOC 910 * data portion starts in the middle of a cache line, the SOC
934 * DMA will trash the beginning (and ending) portions. 911 * DMA will trash the beginning (and ending) portions.
935 */ 912 */
936 913
937 if (sb == NULL) { 914 if (sb == NULL) {
938 sb_new = dev_alloc_skb(ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN); 915 sb_new = dev_alloc_skb(ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN);
939 if (sb_new == NULL) { 916 if (sb_new == NULL) {
@@ -949,23 +926,22 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
949 } 926 }
950 else { 927 else {
951 sb_new = sb; 928 sb_new = sb;
952 /* 929 /*
953 * nothing special to reinit buffer, it's already aligned 930 * nothing special to reinit buffer, it's already aligned
954 * and sb->data already points to a good place. 931 * and sb->data already points to a good place.
955 */ 932 */
956 } 933 }
957 934
958 /* 935 /*
959 * fill in the descriptor 936 * fill in the descriptor
960 */ 937 */
961 938
962#ifdef CONFIG_SBMAC_COALESCE 939#ifdef CONFIG_SBMAC_COALESCE
963 /* 940 /*
964 * Do not interrupt per DMA transfer. 941 * Do not interrupt per DMA transfer.
965 */ 942 */
966 dsc->dscr_a = virt_to_phys(sb_new->data) | 943 dsc->dscr_a = virt_to_phys(sb_new->data) |
967 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 944 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 0;
968 0;
969#else 945#else
970 dsc->dscr_a = virt_to_phys(sb_new->data) | 946 dsc->dscr_a = virt_to_phys(sb_new->data) |
971 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) | 947 V_DMA_DSCRA_A_SIZE(NUMCACHEBLKS(pktsize+ETHER_ALIGN)) |
@@ -974,38 +950,38 @@ static int sbdma_add_rcvbuffer(sbmacdma_t *d,struct sk_buff *sb)
974 950
975 /* receiving: no options */ 951 /* receiving: no options */
976 dsc->dscr_b = 0; 952 dsc->dscr_b = 0;
977 953
978 /* 954 /*
979 * fill in the context 955 * fill in the context
980 */ 956 */
981 957
982 d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new; 958 d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb_new;
983 959
984 /* 960 /*
985 * point at next packet 961 * point at next packet
986 */ 962 */
987 963
988 d->sbdma_addptr = nextdsc; 964 d->sbdma_addptr = nextdsc;
989 965
990 /* 966 /*
991 * Give the buffer to the DMA engine. 967 * Give the buffer to the DMA engine.
992 */ 968 */
993 969
994 SBMAC_WRITECSR(d->sbdma_dscrcnt,1); 970 __raw_writeq(1, d->sbdma_dscrcnt);
995 971
996 return 0; /* we did it */ 972 return 0; /* we did it */
997} 973}
998 974
999/********************************************************************** 975/**********************************************************************
1000 * SBDMA_ADD_TXBUFFER(d,sb) 976 * SBDMA_ADD_TXBUFFER(d,sb)
1001 * 977 *
1002 * Add a transmit buffer to the specified DMA channel, causing a 978 * Add a transmit buffer to the specified DMA channel, causing a
1003 * transmit to start. 979 * transmit to start.
1004 * 980 *
1005 * Input parameters: 981 * Input parameters:
1006 * d - DMA channel descriptor 982 * d - DMA channel descriptor
1007 * sb - sk_buff to add 983 * sb - sk_buff to add
1008 * 984 *
1009 * Return value: 985 * Return value:
1010 * 0 transmit queued successfully 986 * 0 transmit queued successfully
1011 * otherwise error code 987 * otherwise error code
@@ -1019,70 +995,70 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb)
1019 uint64_t phys; 995 uint64_t phys;
1020 uint64_t ncb; 996 uint64_t ncb;
1021 int length; 997 int length;
1022 998
1023 /* get pointer to our current place in the ring */ 999 /* get pointer to our current place in the ring */
1024 1000
1025 dsc = d->sbdma_addptr; 1001 dsc = d->sbdma_addptr;
1026 nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr); 1002 nextdsc = SBDMA_NEXTBUF(d,sbdma_addptr);
1027 1003
1028 /* 1004 /*
1029 * figure out if the ring is full - if the next descriptor 1005 * figure out if the ring is full - if the next descriptor
1030 * is the same as the one that we're going to remove from 1006 * is the same as the one that we're going to remove from
1031 * the ring, the ring is full 1007 * the ring, the ring is full
1032 */ 1008 */
1033 1009
1034 if (nextdsc == d->sbdma_remptr) { 1010 if (nextdsc == d->sbdma_remptr) {
1035 return -ENOSPC; 1011 return -ENOSPC;
1036 } 1012 }
1037 1013
1038 /* 1014 /*
1039 * Under Linux, it's not necessary to copy/coalesce buffers 1015 * Under Linux, it's not necessary to copy/coalesce buffers
1040 * like it is on NetBSD. We think they're all contiguous, 1016 * like it is on NetBSD. We think they're all contiguous,
1041 * but that may not be true for GBE. 1017 * but that may not be true for GBE.
1042 */ 1018 */
1043 1019
1044 length = sb->len; 1020 length = sb->len;
1045 1021
1046 /* 1022 /*
1047 * fill in the descriptor. Note that the number of cache 1023 * fill in the descriptor. Note that the number of cache
1048 * blocks in the descriptor is the number of blocks 1024 * blocks in the descriptor is the number of blocks
1049 * *spanned*, so we need to add in the offset (if any) 1025 * *spanned*, so we need to add in the offset (if any)
1050 * while doing the calculation. 1026 * while doing the calculation.
1051 */ 1027 */
1052 1028
1053 phys = virt_to_phys(sb->data); 1029 phys = virt_to_phys(sb->data);
1054 ncb = NUMCACHEBLKS(length+(phys & (SMP_CACHE_BYTES - 1))); 1030 ncb = NUMCACHEBLKS(length+(phys & (SMP_CACHE_BYTES - 1)));
1055 1031
1056 dsc->dscr_a = phys | 1032 dsc->dscr_a = phys |
1057 V_DMA_DSCRA_A_SIZE(ncb) | 1033 V_DMA_DSCRA_A_SIZE(ncb) |
1058#ifndef CONFIG_SBMAC_COALESCE 1034#ifndef CONFIG_SBMAC_COALESCE
1059 M_DMA_DSCRA_INTERRUPT | 1035 M_DMA_DSCRA_INTERRUPT |
1060#endif 1036#endif
1061 M_DMA_ETHTX_SOP; 1037 M_DMA_ETHTX_SOP;
1062 1038
1063 /* transmitting: set outbound options and length */ 1039 /* transmitting: set outbound options and length */
1064 1040
1065 dsc->dscr_b = V_DMA_DSCRB_OPTIONS(K_DMA_ETHTX_APPENDCRC_APPENDPAD) | 1041 dsc->dscr_b = V_DMA_DSCRB_OPTIONS(K_DMA_ETHTX_APPENDCRC_APPENDPAD) |
1066 V_DMA_DSCRB_PKT_SIZE(length); 1042 V_DMA_DSCRB_PKT_SIZE(length);
1067 1043
1068 /* 1044 /*
1069 * fill in the context 1045 * fill in the context
1070 */ 1046 */
1071 1047
1072 d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb; 1048 d->sbdma_ctxtable[dsc-d->sbdma_dscrtable] = sb;
1073 1049
1074 /* 1050 /*
1075 * point at next packet 1051 * point at next packet
1076 */ 1052 */
1077 1053
1078 d->sbdma_addptr = nextdsc; 1054 d->sbdma_addptr = nextdsc;
1079 1055
1080 /* 1056 /*
1081 * Give the buffer to the DMA engine. 1057 * Give the buffer to the DMA engine.
1082 */ 1058 */
1083 1059
1084 SBMAC_WRITECSR(d->sbdma_dscrcnt,1); 1060 __raw_writeq(1, d->sbdma_dscrcnt);
1085 1061
1086 return 0; /* we did it */ 1062 return 0; /* we did it */
1087} 1063}
1088 1064
@@ -1091,12 +1067,12 @@ static int sbdma_add_txbuffer(sbmacdma_t *d,struct sk_buff *sb)
1091 1067
1092/********************************************************************** 1068/**********************************************************************
1093 * SBDMA_EMPTYRING(d) 1069 * SBDMA_EMPTYRING(d)
1094 * 1070 *
1095 * Free all allocated sk_buffs on the specified DMA channel; 1071 * Free all allocated sk_buffs on the specified DMA channel;
1096 * 1072 *
1097 * Input parameters: 1073 * Input parameters:
1098 * d - DMA channel 1074 * d - DMA channel
1099 * 1075 *
1100 * Return value: 1076 * Return value:
1101 * nothing 1077 * nothing
1102 ********************************************************************* */ 1078 ********************************************************************* */
@@ -1105,7 +1081,7 @@ static void sbdma_emptyring(sbmacdma_t *d)
1105{ 1081{
1106 int idx; 1082 int idx;
1107 struct sk_buff *sb; 1083 struct sk_buff *sb;
1108 1084
1109 for (idx = 0; idx < d->sbdma_maxdescr; idx++) { 1085 for (idx = 0; idx < d->sbdma_maxdescr; idx++) {
1110 sb = d->sbdma_ctxtable[idx]; 1086 sb = d->sbdma_ctxtable[idx];
1111 if (sb) { 1087 if (sb) {
@@ -1118,13 +1094,13 @@ static void sbdma_emptyring(sbmacdma_t *d)
1118 1094
1119/********************************************************************** 1095/**********************************************************************
1120 * SBDMA_FILLRING(d) 1096 * SBDMA_FILLRING(d)
1121 * 1097 *
1122 * Fill the specified DMA channel (must be receive channel) 1098 * Fill the specified DMA channel (must be receive channel)
1123 * with sk_buffs 1099 * with sk_buffs
1124 * 1100 *
1125 * Input parameters: 1101 * Input parameters:
1126 * d - DMA channel 1102 * d - DMA channel
1127 * 1103 *
1128 * Return value: 1104 * Return value:
1129 * nothing 1105 * nothing
1130 ********************************************************************* */ 1106 ********************************************************************* */
@@ -1132,7 +1108,7 @@ static void sbdma_emptyring(sbmacdma_t *d)
1132static void sbdma_fillring(sbmacdma_t *d) 1108static void sbdma_fillring(sbmacdma_t *d)
1133{ 1109{
1134 int idx; 1110 int idx;
1135 1111
1136 for (idx = 0; idx < SBMAC_MAX_RXDESCR-1; idx++) { 1112 for (idx = 0; idx < SBMAC_MAX_RXDESCR-1; idx++) {
1137 if (sbdma_add_rcvbuffer(d,NULL) != 0) 1113 if (sbdma_add_rcvbuffer(d,NULL) != 0)
1138 break; 1114 break;
@@ -1142,16 +1118,16 @@ static void sbdma_fillring(sbmacdma_t *d)
1142 1118
1143/********************************************************************** 1119/**********************************************************************
1144 * SBDMA_RX_PROCESS(sc,d) 1120 * SBDMA_RX_PROCESS(sc,d)
1145 * 1121 *
1146 * Process "completed" receive buffers on the specified DMA channel. 1122 * Process "completed" receive buffers on the specified DMA channel.
1147 * Note that this isn't really ideal for priority channels, since 1123 * Note that this isn't really ideal for priority channels, since
1148 * it processes all of the packets on a given channel before 1124 * it processes all of the packets on a given channel before
1149 * returning. 1125 * returning.
1150 * 1126 *
1151 * Input parameters: 1127 * Input parameters:
1152 * sc - softc structure 1128 * sc - softc structure
1153 * d - DMA channel context 1129 * d - DMA channel context
1154 * 1130 *
1155 * Return value: 1131 * Return value:
1156 * nothing 1132 * nothing
1157 ********************************************************************* */ 1133 ********************************************************************* */
@@ -1163,56 +1139,56 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1163 sbdmadscr_t *dsc; 1139 sbdmadscr_t *dsc;
1164 struct sk_buff *sb; 1140 struct sk_buff *sb;
1165 int len; 1141 int len;
1166 1142
1167 for (;;) { 1143 for (;;) {
1168 /* 1144 /*
1169 * figure out where we are (as an index) and where 1145 * figure out where we are (as an index) and where
1170 * the hardware is (also as an index) 1146 * the hardware is (also as an index)
1171 * 1147 *
1172 * This could be done faster if (for example) the 1148 * This could be done faster if (for example) the
1173 * descriptor table was page-aligned and contiguous in 1149 * descriptor table was page-aligned and contiguous in
1174 * both virtual and physical memory -- you could then 1150 * both virtual and physical memory -- you could then
1175 * just compare the low-order bits of the virtual address 1151 * just compare the low-order bits of the virtual address
1176 * (sbdma_remptr) and the physical address (sbdma_curdscr CSR) 1152 * (sbdma_remptr) and the physical address (sbdma_curdscr CSR)
1177 */ 1153 */
1178 1154
1179 curidx = d->sbdma_remptr - d->sbdma_dscrtable; 1155 curidx = d->sbdma_remptr - d->sbdma_dscrtable;
1180 hwidx = (int) (((SBMAC_READCSR(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - 1156 hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) -
1181 d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t)); 1157 d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t));
1182 1158
1183 /* 1159 /*
1184 * If they're the same, that means we've processed all 1160 * If they're the same, that means we've processed all
1185 * of the descriptors up to (but not including) the one that 1161 * of the descriptors up to (but not including) the one that
1186 * the hardware is working on right now. 1162 * the hardware is working on right now.
1187 */ 1163 */
1188 1164
1189 if (curidx == hwidx) 1165 if (curidx == hwidx)
1190 break; 1166 break;
1191 1167
1192 /* 1168 /*
1193 * Otherwise, get the packet's sk_buff ptr back 1169 * Otherwise, get the packet's sk_buff ptr back
1194 */ 1170 */
1195 1171
1196 dsc = &(d->sbdma_dscrtable[curidx]); 1172 dsc = &(d->sbdma_dscrtable[curidx]);
1197 sb = d->sbdma_ctxtable[curidx]; 1173 sb = d->sbdma_ctxtable[curidx];
1198 d->sbdma_ctxtable[curidx] = NULL; 1174 d->sbdma_ctxtable[curidx] = NULL;
1199 1175
1200 len = (int)G_DMA_DSCRB_PKT_SIZE(dsc->dscr_b) - 4; 1176 len = (int)G_DMA_DSCRB_PKT_SIZE(dsc->dscr_b) - 4;
1201 1177
1202 /* 1178 /*
1203 * Check packet status. If good, process it. 1179 * Check packet status. If good, process it.
1204 * If not, silently drop it and put it back on the 1180 * If not, silently drop it and put it back on the
1205 * receive ring. 1181 * receive ring.
1206 */ 1182 */
1207 1183
1208 if (!(dsc->dscr_a & M_DMA_ETHRX_BAD)) { 1184 if (!(dsc->dscr_a & M_DMA_ETHRX_BAD)) {
1209 1185
1210 /* 1186 /*
1211 * Add a new buffer to replace the old one. If we fail 1187 * Add a new buffer to replace the old one. If we fail
1212 * to allocate a buffer, we're going to drop this 1188 * to allocate a buffer, we're going to drop this
1213 * packet and put it right back on the receive ring. 1189 * packet and put it right back on the receive ring.
1214 */ 1190 */
1215 1191
1216 if (sbdma_add_rcvbuffer(d,NULL) == -ENOBUFS) { 1192 if (sbdma_add_rcvbuffer(d,NULL) == -ENOBUFS) {
1217 sc->sbm_stats.rx_dropped++; 1193 sc->sbm_stats.rx_dropped++;
1218 sbdma_add_rcvbuffer(d,sb); /* re-add old buffer */ 1194 sbdma_add_rcvbuffer(d,sb); /* re-add old buffer */
@@ -1221,7 +1197,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1221 * Set length into the packet 1197 * Set length into the packet
1222 */ 1198 */
1223 skb_put(sb,len); 1199 skb_put(sb,len);
1224 1200
1225 /* 1201 /*
1226 * Buffer has been replaced on the 1202 * Buffer has been replaced on the
1227 * receive ring. Pass the buffer to 1203 * receive ring. Pass the buffer to
@@ -1240,7 +1216,7 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1240 sb->ip_summed = CHECKSUM_NONE; 1216 sb->ip_summed = CHECKSUM_NONE;
1241 } 1217 }
1242 } 1218 }
1243 1219
1244 netif_rx(sb); 1220 netif_rx(sb);
1245 } 1221 }
1246 } else { 1222 } else {
@@ -1251,14 +1227,14 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1251 sc->sbm_stats.rx_errors++; 1227 sc->sbm_stats.rx_errors++;
1252 sbdma_add_rcvbuffer(d,sb); 1228 sbdma_add_rcvbuffer(d,sb);
1253 } 1229 }
1254 1230
1255 1231
1256 /* 1232 /*
1257 * .. and advance to the next buffer. 1233 * .. and advance to the next buffer.
1258 */ 1234 */
1259 1235
1260 d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); 1236 d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr);
1261 1237
1262 } 1238 }
1263} 1239}
1264 1240
@@ -1266,17 +1242,17 @@ static void sbdma_rx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1266 1242
1267/********************************************************************** 1243/**********************************************************************
1268 * SBDMA_TX_PROCESS(sc,d) 1244 * SBDMA_TX_PROCESS(sc,d)
1269 * 1245 *
1270 * Process "completed" transmit buffers on the specified DMA channel. 1246 * Process "completed" transmit buffers on the specified DMA channel.
1271 * This is normally called within the interrupt service routine. 1247 * This is normally called within the interrupt service routine.
1272 * Note that this isn't really ideal for priority channels, since 1248 * Note that this isn't really ideal for priority channels, since
1273 * it processes all of the packets on a given channel before 1249 * it processes all of the packets on a given channel before
1274 * returning. 1250 * returning.
1275 * 1251 *
1276 * Input parameters: 1252 * Input parameters:
1277 * sc - softc structure 1253 * sc - softc structure
1278 * d - DMA channel context 1254 * d - DMA channel context
1279 * 1255 *
1280 * Return value: 1256 * Return value:
1281 * nothing 1257 * nothing
1282 ********************************************************************* */ 1258 ********************************************************************* */
@@ -1290,21 +1266,21 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1290 unsigned long flags; 1266 unsigned long flags;
1291 1267
1292 spin_lock_irqsave(&(sc->sbm_lock), flags); 1268 spin_lock_irqsave(&(sc->sbm_lock), flags);
1293 1269
1294 for (;;) { 1270 for (;;) {
1295 /* 1271 /*
1296 * figure out where we are (as an index) and where 1272 * figure out where we are (as an index) and where
1297 * the hardware is (also as an index) 1273 * the hardware is (also as an index)
1298 * 1274 *
1299 * This could be done faster if (for example) the 1275 * This could be done faster if (for example) the
1300 * descriptor table was page-aligned and contiguous in 1276 * descriptor table was page-aligned and contiguous in
1301 * both virtual and physical memory -- you could then 1277 * both virtual and physical memory -- you could then
1302 * just compare the low-order bits of the virtual address 1278 * just compare the low-order bits of the virtual address
1303 * (sbdma_remptr) and the physical address (sbdma_curdscr CSR) 1279 * (sbdma_remptr) and the physical address (sbdma_curdscr CSR)
1304 */ 1280 */
1305 1281
1306 curidx = d->sbdma_remptr - d->sbdma_dscrtable; 1282 curidx = d->sbdma_remptr - d->sbdma_dscrtable;
1307 hwidx = (int) (((SBMAC_READCSR(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) - 1283 hwidx = (int) (((__raw_readq(d->sbdma_curdscr) & M_DMA_CURDSCR_ADDR) -
1308 d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t)); 1284 d->sbdma_dscrtable_phys) / sizeof(sbdmadscr_t));
1309 1285
1310 /* 1286 /*
@@ -1312,75 +1288,75 @@ static void sbdma_tx_process(struct sbmac_softc *sc,sbmacdma_t *d)
1312 * of the descriptors up to (but not including) the one that 1288 * of the descriptors up to (but not including) the one that
1313 * the hardware is working on right now. 1289 * the hardware is working on right now.
1314 */ 1290 */
1315 1291
1316 if (curidx == hwidx) 1292 if (curidx == hwidx)
1317 break; 1293 break;
1318 1294
1319 /* 1295 /*
1320 * Otherwise, get the packet's sk_buff ptr back 1296 * Otherwise, get the packet's sk_buff ptr back
1321 */ 1297 */
1322 1298
1323 dsc = &(d->sbdma_dscrtable[curidx]); 1299 dsc = &(d->sbdma_dscrtable[curidx]);
1324 sb = d->sbdma_ctxtable[curidx]; 1300 sb = d->sbdma_ctxtable[curidx];
1325 d->sbdma_ctxtable[curidx] = NULL; 1301 d->sbdma_ctxtable[curidx] = NULL;
1326 1302
1327 /* 1303 /*
1328 * Stats 1304 * Stats
1329 */ 1305 */
1330 1306
1331 sc->sbm_stats.tx_bytes += sb->len; 1307 sc->sbm_stats.tx_bytes += sb->len;
1332 sc->sbm_stats.tx_packets++; 1308 sc->sbm_stats.tx_packets++;
1333 1309
1334 /* 1310 /*
1335 * for transmits, we just free buffers. 1311 * for transmits, we just free buffers.
1336 */ 1312 */
1337 1313
1338 dev_kfree_skb_irq(sb); 1314 dev_kfree_skb_irq(sb);
1339 1315
1340 /* 1316 /*
1341 * .. and advance to the next buffer. 1317 * .. and advance to the next buffer.
1342 */ 1318 */
1343 1319
1344 d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr); 1320 d->sbdma_remptr = SBDMA_NEXTBUF(d,sbdma_remptr);
1345 1321
1346 } 1322 }
1347 1323
1348 /* 1324 /*
1349 * Decide if we should wake up the protocol or not. 1325 * Decide if we should wake up the protocol or not.
1350 * Other drivers seem to do this when we reach a low 1326 * Other drivers seem to do this when we reach a low
1351 * watermark on the transmit queue. 1327 * watermark on the transmit queue.
1352 */ 1328 */
1353 1329
1354 netif_wake_queue(d->sbdma_eth->sbm_dev); 1330 netif_wake_queue(d->sbdma_eth->sbm_dev);
1355 1331
1356 spin_unlock_irqrestore(&(sc->sbm_lock), flags); 1332 spin_unlock_irqrestore(&(sc->sbm_lock), flags);
1357 1333
1358} 1334}
1359 1335
1360 1336
1361 1337
1362/********************************************************************** 1338/**********************************************************************
1363 * SBMAC_INITCTX(s) 1339 * SBMAC_INITCTX(s)
1364 * 1340 *
1365 * Initialize an Ethernet context structure - this is called 1341 * Initialize an Ethernet context structure - this is called
1366 * once per MAC on the 1250. Memory is allocated here, so don't 1342 * once per MAC on the 1250. Memory is allocated here, so don't
1367 * call it again from inside the ioctl routines that bring the 1343 * call it again from inside the ioctl routines that bring the
1368 * interface up/down 1344 * interface up/down
1369 * 1345 *
1370 * Input parameters: 1346 * Input parameters:
1371 * s - sbmac context structure 1347 * s - sbmac context structure
1372 * 1348 *
1373 * Return value: 1349 * Return value:
1374 * 0 1350 * 0
1375 ********************************************************************* */ 1351 ********************************************************************* */
1376 1352
1377static int sbmac_initctx(struct sbmac_softc *s) 1353static int sbmac_initctx(struct sbmac_softc *s)
1378{ 1354{
1379 1355
1380 /* 1356 /*
1381 * figure out the addresses of some ports 1357 * figure out the addresses of some ports
1382 */ 1358 */
1383 1359
1384 s->sbm_macenable = s->sbm_base + R_MAC_ENABLE; 1360 s->sbm_macenable = s->sbm_base + R_MAC_ENABLE;
1385 s->sbm_maccfg = s->sbm_base + R_MAC_CFG; 1361 s->sbm_maccfg = s->sbm_base + R_MAC_CFG;
1386 s->sbm_fifocfg = s->sbm_base + R_MAC_THRSH_CFG; 1362 s->sbm_fifocfg = s->sbm_base + R_MAC_THRSH_CFG;
@@ -1397,29 +1373,29 @@ static int sbmac_initctx(struct sbmac_softc *s)
1397 s->sbm_phy_oldanlpar = 0; 1373 s->sbm_phy_oldanlpar = 0;
1398 s->sbm_phy_oldk1stsr = 0; 1374 s->sbm_phy_oldk1stsr = 0;
1399 s->sbm_phy_oldlinkstat = 0; 1375 s->sbm_phy_oldlinkstat = 0;
1400 1376
1401 /* 1377 /*
1402 * Initialize the DMA channels. Right now, only one per MAC is used 1378 * Initialize the DMA channels. Right now, only one per MAC is used
1403 * Note: Only do this _once_, as it allocates memory from the kernel! 1379 * Note: Only do this _once_, as it allocates memory from the kernel!
1404 */ 1380 */
1405 1381
1406 sbdma_initctx(&(s->sbm_txdma),s,0,DMA_TX,SBMAC_MAX_TXDESCR); 1382 sbdma_initctx(&(s->sbm_txdma),s,0,DMA_TX,SBMAC_MAX_TXDESCR);
1407 sbdma_initctx(&(s->sbm_rxdma),s,0,DMA_RX,SBMAC_MAX_RXDESCR); 1383 sbdma_initctx(&(s->sbm_rxdma),s,0,DMA_RX,SBMAC_MAX_RXDESCR);
1408 1384
1409 /* 1385 /*
1410 * initial state is OFF 1386 * initial state is OFF
1411 */ 1387 */
1412 1388
1413 s->sbm_state = sbmac_state_off; 1389 s->sbm_state = sbmac_state_off;
1414 1390
1415 /* 1391 /*
1416 * Initial speed is (XXX TEMP) 10MBit/s HDX no FC 1392 * Initial speed is (XXX TEMP) 10MBit/s HDX no FC
1417 */ 1393 */
1418 1394
1419 s->sbm_speed = sbmac_speed_10; 1395 s->sbm_speed = sbmac_speed_10;
1420 s->sbm_duplex = sbmac_duplex_half; 1396 s->sbm_duplex = sbmac_duplex_half;
1421 s->sbm_fc = sbmac_fc_disabled; 1397 s->sbm_fc = sbmac_fc_disabled;
1422 1398
1423 return 0; 1399 return 0;
1424} 1400}
1425 1401
@@ -1430,7 +1406,7 @@ static void sbdma_uninitctx(struct sbmacdma_s *d)
1430 kfree(d->sbdma_dscrtable); 1406 kfree(d->sbdma_dscrtable);
1431 d->sbdma_dscrtable = NULL; 1407 d->sbdma_dscrtable = NULL;
1432 } 1408 }
1433 1409
1434 if (d->sbdma_ctxtable) { 1410 if (d->sbdma_ctxtable) {
1435 kfree(d->sbdma_ctxtable); 1411 kfree(d->sbdma_ctxtable);
1436 d->sbdma_ctxtable = NULL; 1412 d->sbdma_ctxtable = NULL;
@@ -1447,12 +1423,12 @@ static void sbmac_uninitctx(struct sbmac_softc *sc)
1447 1423
1448/********************************************************************** 1424/**********************************************************************
1449 * SBMAC_CHANNEL_START(s) 1425 * SBMAC_CHANNEL_START(s)
1450 * 1426 *
1451 * Start packet processing on this MAC. 1427 * Start packet processing on this MAC.
1452 * 1428 *
1453 * Input parameters: 1429 * Input parameters:
1454 * s - sbmac structure 1430 * s - sbmac structure
1455 * 1431 *
1456 * Return value: 1432 * Return value:
1457 * nothing 1433 * nothing
1458 ********************************************************************* */ 1434 ********************************************************************* */
@@ -1460,49 +1436,49 @@ static void sbmac_uninitctx(struct sbmac_softc *sc)
1460static void sbmac_channel_start(struct sbmac_softc *s) 1436static void sbmac_channel_start(struct sbmac_softc *s)
1461{ 1437{
1462 uint64_t reg; 1438 uint64_t reg;
1463 sbmac_port_t port; 1439 volatile void __iomem *port;
1464 uint64_t cfg,fifo,framecfg; 1440 uint64_t cfg,fifo,framecfg;
1465 int idx, th_value; 1441 int idx, th_value;
1466 1442
1467 /* 1443 /*
1468 * Don't do this if running 1444 * Don't do this if running
1469 */ 1445 */
1470 1446
1471 if (s->sbm_state == sbmac_state_on) 1447 if (s->sbm_state == sbmac_state_on)
1472 return; 1448 return;
1473 1449
1474 /* 1450 /*
1475 * Bring the controller out of reset, but leave it off. 1451 * Bring the controller out of reset, but leave it off.
1476 */ 1452 */
1477 1453
1478 SBMAC_WRITECSR(s->sbm_macenable,0); 1454 __raw_writeq(0, s->sbm_macenable);
1479 1455
1480 /* 1456 /*
1481 * Ignore all received packets 1457 * Ignore all received packets
1482 */ 1458 */
1483 1459
1484 SBMAC_WRITECSR(s->sbm_rxfilter,0); 1460 __raw_writeq(0, s->sbm_rxfilter);
1485 1461
1486 /* 1462 /*
1487 * Calculate values for various control registers. 1463 * Calculate values for various control registers.
1488 */ 1464 */
1489 1465
1490 cfg = M_MAC_RETRY_EN | 1466 cfg = M_MAC_RETRY_EN |
1491 M_MAC_TX_HOLD_SOP_EN | 1467 M_MAC_TX_HOLD_SOP_EN |
1492 V_MAC_TX_PAUSE_CNT_16K | 1468 V_MAC_TX_PAUSE_CNT_16K |
1493 M_MAC_AP_STAT_EN | 1469 M_MAC_AP_STAT_EN |
1494 M_MAC_FAST_SYNC | 1470 M_MAC_FAST_SYNC |
1495 M_MAC_SS_EN | 1471 M_MAC_SS_EN |
1496 0; 1472 0;
1497 1473
1498 /* 1474 /*
1499 * Be sure that RD_THRSH+WR_THRSH <= 32 for pass1 pars 1475 * Be sure that RD_THRSH+WR_THRSH <= 32 for pass1 pars
1500 * and make sure that RD_THRSH + WR_THRSH <=128 for pass2 and above 1476 * and make sure that RD_THRSH + WR_THRSH <=128 for pass2 and above
1501 * Use a larger RD_THRSH for gigabit 1477 * Use a larger RD_THRSH for gigabit
1502 */ 1478 */
1503 if (periph_rev >= 2) 1479 if (periph_rev >= 2)
1504 th_value = 64; 1480 th_value = 64;
1505 else 1481 else
1506 th_value = 28; 1482 th_value = 28;
1507 1483
1508 fifo = V_MAC_TX_WR_THRSH(4) | /* Must be '4' or '8' */ 1484 fifo = V_MAC_TX_WR_THRSH(4) | /* Must be '4' or '8' */
@@ -1520,51 +1496,51 @@ static void sbmac_channel_start(struct sbmac_softc *s)
1520 V_MAC_BACKOFF_SEL(1); 1496 V_MAC_BACKOFF_SEL(1);
1521 1497
1522 /* 1498 /*
1523 * Clear out the hash address map 1499 * Clear out the hash address map
1524 */ 1500 */
1525 1501
1526 port = s->sbm_base + R_MAC_HASH_BASE; 1502 port = s->sbm_base + R_MAC_HASH_BASE;
1527 for (idx = 0; idx < MAC_HASH_COUNT; idx++) { 1503 for (idx = 0; idx < MAC_HASH_COUNT; idx++) {
1528 SBMAC_WRITECSR(port,0); 1504 __raw_writeq(0, port);
1529 port += sizeof(uint64_t); 1505 port += sizeof(uint64_t);
1530 } 1506 }
1531 1507
1532 /* 1508 /*
1533 * Clear out the exact-match table 1509 * Clear out the exact-match table
1534 */ 1510 */
1535 1511
1536 port = s->sbm_base + R_MAC_ADDR_BASE; 1512 port = s->sbm_base + R_MAC_ADDR_BASE;
1537 for (idx = 0; idx < MAC_ADDR_COUNT; idx++) { 1513 for (idx = 0; idx < MAC_ADDR_COUNT; idx++) {
1538 SBMAC_WRITECSR(port,0); 1514 __raw_writeq(0, port);
1539 port += sizeof(uint64_t); 1515 port += sizeof(uint64_t);
1540 } 1516 }
1541 1517
1542 /* 1518 /*
1543 * Clear out the DMA Channel mapping table registers 1519 * Clear out the DMA Channel mapping table registers
1544 */ 1520 */
1545 1521
1546 port = s->sbm_base + R_MAC_CHUP0_BASE; 1522 port = s->sbm_base + R_MAC_CHUP0_BASE;
1547 for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { 1523 for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) {
1548 SBMAC_WRITECSR(port,0); 1524 __raw_writeq(0, port);
1549 port += sizeof(uint64_t); 1525 port += sizeof(uint64_t);
1550 } 1526 }
1551 1527
1552 1528
1553 port = s->sbm_base + R_MAC_CHLO0_BASE; 1529 port = s->sbm_base + R_MAC_CHLO0_BASE;
1554 for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { 1530 for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) {
1555 SBMAC_WRITECSR(port,0); 1531 __raw_writeq(0, port);
1556 port += sizeof(uint64_t); 1532 port += sizeof(uint64_t);
1557 } 1533 }
1558 1534
1559 /* 1535 /*
1560 * Program the hardware address. It goes into the hardware-address 1536 * Program the hardware address. It goes into the hardware-address
1561 * register as well as the first filter register. 1537 * register as well as the first filter register.
1562 */ 1538 */
1563 1539
1564 reg = sbmac_addr2reg(s->sbm_hwaddr); 1540 reg = sbmac_addr2reg(s->sbm_hwaddr);
1565 1541
1566 port = s->sbm_base + R_MAC_ADDR_BASE; 1542 port = s->sbm_base + R_MAC_ADDR_BASE;
1567 SBMAC_WRITECSR(port,reg); 1543 __raw_writeq(reg, port);
1568 port = s->sbm_base + R_MAC_ETHERNET_ADDR; 1544 port = s->sbm_base + R_MAC_ETHERNET_ADDR;
1569 1545
1570#ifdef CONFIG_SB1_PASS_1_WORKAROUNDS 1546#ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
@@ -1573,108 +1549,105 @@ static void sbmac_channel_start(struct sbmac_softc *s)
1573 * destination address in the R_MAC_ETHERNET_ADDR register. 1549 * destination address in the R_MAC_ETHERNET_ADDR register.
1574 * Set the value to zero. 1550 * Set the value to zero.
1575 */ 1551 */
1576 SBMAC_WRITECSR(port,0); 1552 __raw_writeq(0, port);
1577#else 1553#else
1578 SBMAC_WRITECSR(port,reg); 1554 __raw_writeq(reg, port);
1579#endif 1555#endif
1580 1556
1581 /* 1557 /*
1582 * Set the receive filter for no packets, and write values 1558 * Set the receive filter for no packets, and write values
1583 * to the various config registers 1559 * to the various config registers
1584 */ 1560 */
1585 1561
1586 SBMAC_WRITECSR(s->sbm_rxfilter,0); 1562 __raw_writeq(0, s->sbm_rxfilter);
1587 SBMAC_WRITECSR(s->sbm_imr,0); 1563 __raw_writeq(0, s->sbm_imr);
1588 SBMAC_WRITECSR(s->sbm_framecfg,framecfg); 1564 __raw_writeq(framecfg, s->sbm_framecfg);
1589 SBMAC_WRITECSR(s->sbm_fifocfg,fifo); 1565 __raw_writeq(fifo, s->sbm_fifocfg);
1590 SBMAC_WRITECSR(s->sbm_maccfg,cfg); 1566 __raw_writeq(cfg, s->sbm_maccfg);
1591 1567
1592 /* 1568 /*
1593 * Initialize DMA channels (rings should be ok now) 1569 * Initialize DMA channels (rings should be ok now)
1594 */ 1570 */
1595 1571
1596 sbdma_channel_start(&(s->sbm_rxdma), DMA_RX); 1572 sbdma_channel_start(&(s->sbm_rxdma), DMA_RX);
1597 sbdma_channel_start(&(s->sbm_txdma), DMA_TX); 1573 sbdma_channel_start(&(s->sbm_txdma), DMA_TX);
1598 1574
1599 /* 1575 /*
1600 * Configure the speed, duplex, and flow control 1576 * Configure the speed, duplex, and flow control
1601 */ 1577 */
1602 1578
1603 sbmac_set_speed(s,s->sbm_speed); 1579 sbmac_set_speed(s,s->sbm_speed);
1604 sbmac_set_duplex(s,s->sbm_duplex,s->sbm_fc); 1580 sbmac_set_duplex(s,s->sbm_duplex,s->sbm_fc);
1605 1581
1606 /* 1582 /*
1607 * Fill the receive ring 1583 * Fill the receive ring
1608 */ 1584 */
1609 1585
1610 sbdma_fillring(&(s->sbm_rxdma)); 1586 sbdma_fillring(&(s->sbm_rxdma));
1611 1587
1612 /* 1588 /*
1613 * Turn on the rest of the bits in the enable register 1589 * Turn on the rest of the bits in the enable register
1614 */ 1590 */
1615 1591
1616 SBMAC_WRITECSR(s->sbm_macenable, 1592 __raw_writeq(M_MAC_RXDMA_EN0 |
1617 M_MAC_RXDMA_EN0 |
1618 M_MAC_TXDMA_EN0 | 1593 M_MAC_TXDMA_EN0 |
1619 M_MAC_RX_ENABLE | 1594 M_MAC_RX_ENABLE |
1620 M_MAC_TX_ENABLE); 1595 M_MAC_TX_ENABLE, s->sbm_macenable);
1621 1596
1622 1597
1623 1598
1624 1599
1625#ifdef CONFIG_SBMAC_COALESCE 1600#ifdef CONFIG_SBMAC_COALESCE
1626 /* 1601 /*
1627 * Accept any TX interrupt and EOP count/timer RX interrupts on ch 0 1602 * Accept any TX interrupt and EOP count/timer RX interrupts on ch 0
1628 */ 1603 */
1629 SBMAC_WRITECSR(s->sbm_imr, 1604 __raw_writeq(((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) |
1630 ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_TX_CH0) | 1605 ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0), s->sbm_imr);
1631 ((M_MAC_INT_EOP_COUNT | M_MAC_INT_EOP_TIMER) << S_MAC_RX_CH0));
1632#else 1606#else
1633 /* 1607 /*
1634 * Accept any kind of interrupt on TX and RX DMA channel 0 1608 * Accept any kind of interrupt on TX and RX DMA channel 0
1635 */ 1609 */
1636 SBMAC_WRITECSR(s->sbm_imr, 1610 __raw_writeq((M_MAC_INT_CHANNEL << S_MAC_TX_CH0) |
1637 (M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | 1611 (M_MAC_INT_CHANNEL << S_MAC_RX_CH0), s->sbm_imr);
1638 (M_MAC_INT_CHANNEL << S_MAC_RX_CH0));
1639#endif 1612#endif
1640 1613
1641 /* 1614 /*
1642 * Enable receiving unicasts and broadcasts 1615 * Enable receiving unicasts and broadcasts
1643 */ 1616 */
1644 1617
1645 SBMAC_WRITECSR(s->sbm_rxfilter,M_MAC_UCAST_EN | M_MAC_BCAST_EN); 1618 __raw_writeq(M_MAC_UCAST_EN | M_MAC_BCAST_EN, s->sbm_rxfilter);
1646 1619
1647 /* 1620 /*
1648 * we're running now. 1621 * we're running now.
1649 */ 1622 */
1650 1623
1651 s->sbm_state = sbmac_state_on; 1624 s->sbm_state = sbmac_state_on;
1652 1625
1653 /* 1626 /*
1654 * Program multicast addresses 1627 * Program multicast addresses
1655 */ 1628 */
1656 1629
1657 sbmac_setmulti(s); 1630 sbmac_setmulti(s);
1658 1631
1659 /* 1632 /*
1660 * If channel was in promiscuous mode before, turn that on 1633 * If channel was in promiscuous mode before, turn that on
1661 */ 1634 */
1662 1635
1663 if (s->sbm_devflags & IFF_PROMISC) { 1636 if (s->sbm_devflags & IFF_PROMISC) {
1664 sbmac_promiscuous_mode(s,1); 1637 sbmac_promiscuous_mode(s,1);
1665 } 1638 }
1666 1639
1667} 1640}
1668 1641
1669 1642
1670/********************************************************************** 1643/**********************************************************************
1671 * SBMAC_CHANNEL_STOP(s) 1644 * SBMAC_CHANNEL_STOP(s)
1672 * 1645 *
1673 * Stop packet processing on this MAC. 1646 * Stop packet processing on this MAC.
1674 * 1647 *
1675 * Input parameters: 1648 * Input parameters:
1676 * s - sbmac structure 1649 * s - sbmac structure
1677 * 1650 *
1678 * Return value: 1651 * Return value:
1679 * nothing 1652 * nothing
1680 ********************************************************************* */ 1653 ********************************************************************* */
@@ -1682,49 +1655,49 @@ static void sbmac_channel_start(struct sbmac_softc *s)
1682static void sbmac_channel_stop(struct sbmac_softc *s) 1655static void sbmac_channel_stop(struct sbmac_softc *s)
1683{ 1656{
1684 /* don't do this if already stopped */ 1657 /* don't do this if already stopped */
1685 1658
1686 if (s->sbm_state == sbmac_state_off) 1659 if (s->sbm_state == sbmac_state_off)
1687 return; 1660 return;
1688 1661
1689 /* don't accept any packets, disable all interrupts */ 1662 /* don't accept any packets, disable all interrupts */
1690 1663
1691 SBMAC_WRITECSR(s->sbm_rxfilter,0); 1664 __raw_writeq(0, s->sbm_rxfilter);
1692 SBMAC_WRITECSR(s->sbm_imr,0); 1665 __raw_writeq(0, s->sbm_imr);
1693 1666
1694 /* Turn off ticker */ 1667 /* Turn off ticker */
1695 1668
1696 /* XXX */ 1669 /* XXX */
1697 1670
1698 /* turn off receiver and transmitter */ 1671 /* turn off receiver and transmitter */
1699 1672
1700 SBMAC_WRITECSR(s->sbm_macenable,0); 1673 __raw_writeq(0, s->sbm_macenable);
1701 1674
1702 /* We're stopped now. */ 1675 /* We're stopped now. */
1703 1676
1704 s->sbm_state = sbmac_state_off; 1677 s->sbm_state = sbmac_state_off;
1705 1678
1706 /* 1679 /*
1707 * Stop DMA channels (rings should be ok now) 1680 * Stop DMA channels (rings should be ok now)
1708 */ 1681 */
1709 1682
1710 sbdma_channel_stop(&(s->sbm_rxdma)); 1683 sbdma_channel_stop(&(s->sbm_rxdma));
1711 sbdma_channel_stop(&(s->sbm_txdma)); 1684 sbdma_channel_stop(&(s->sbm_txdma));
1712 1685
1713 /* Empty the receive and transmit rings */ 1686 /* Empty the receive and transmit rings */
1714 1687
1715 sbdma_emptyring(&(s->sbm_rxdma)); 1688 sbdma_emptyring(&(s->sbm_rxdma));
1716 sbdma_emptyring(&(s->sbm_txdma)); 1689 sbdma_emptyring(&(s->sbm_txdma));
1717 1690
1718} 1691}
1719 1692
1720/********************************************************************** 1693/**********************************************************************
1721 * SBMAC_SET_CHANNEL_STATE(state) 1694 * SBMAC_SET_CHANNEL_STATE(state)
1722 * 1695 *
1723 * Set the channel's state ON or OFF 1696 * Set the channel's state ON or OFF
1724 * 1697 *
1725 * Input parameters: 1698 * Input parameters:
1726 * state - new state 1699 * state - new state
1727 * 1700 *
1728 * Return value: 1701 * Return value:
1729 * old state 1702 * old state
1730 ********************************************************************* */ 1703 ********************************************************************* */
@@ -1732,43 +1705,43 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc,
1732 sbmac_state_t state) 1705 sbmac_state_t state)
1733{ 1706{
1734 sbmac_state_t oldstate = sc->sbm_state; 1707 sbmac_state_t oldstate = sc->sbm_state;
1735 1708
1736 /* 1709 /*
1737 * If same as previous state, return 1710 * If same as previous state, return
1738 */ 1711 */
1739 1712
1740 if (state == oldstate) { 1713 if (state == oldstate) {
1741 return oldstate; 1714 return oldstate;
1742 } 1715 }
1743 1716
1744 /* 1717 /*
1745 * If new state is ON, turn channel on 1718 * If new state is ON, turn channel on
1746 */ 1719 */
1747 1720
1748 if (state == sbmac_state_on) { 1721 if (state == sbmac_state_on) {
1749 sbmac_channel_start(sc); 1722 sbmac_channel_start(sc);
1750 } 1723 }
1751 else { 1724 else {
1752 sbmac_channel_stop(sc); 1725 sbmac_channel_stop(sc);
1753 } 1726 }
1754 1727
1755 /* 1728 /*
1756 * Return previous state 1729 * Return previous state
1757 */ 1730 */
1758 1731
1759 return oldstate; 1732 return oldstate;
1760} 1733}
1761 1734
1762 1735
1763/********************************************************************** 1736/**********************************************************************
1764 * SBMAC_PROMISCUOUS_MODE(sc,onoff) 1737 * SBMAC_PROMISCUOUS_MODE(sc,onoff)
1765 * 1738 *
1766 * Turn on or off promiscuous mode 1739 * Turn on or off promiscuous mode
1767 * 1740 *
1768 * Input parameters: 1741 * Input parameters:
1769 * sc - softc 1742 * sc - softc
1770 * onoff - 1 to turn on, 0 to turn off 1743 * onoff - 1 to turn on, 0 to turn off
1771 * 1744 *
1772 * Return value: 1745 * Return value:
1773 * nothing 1746 * nothing
1774 ********************************************************************* */ 1747 ********************************************************************* */
@@ -1776,30 +1749,30 @@ static sbmac_state_t sbmac_set_channel_state(struct sbmac_softc *sc,
1776static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff) 1749static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
1777{ 1750{
1778 uint64_t reg; 1751 uint64_t reg;
1779 1752
1780 if (sc->sbm_state != sbmac_state_on) 1753 if (sc->sbm_state != sbmac_state_on)
1781 return; 1754 return;
1782 1755
1783 if (onoff) { 1756 if (onoff) {
1784 reg = SBMAC_READCSR(sc->sbm_rxfilter); 1757 reg = __raw_readq(sc->sbm_rxfilter);
1785 reg |= M_MAC_ALLPKT_EN; 1758 reg |= M_MAC_ALLPKT_EN;
1786 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 1759 __raw_writeq(reg, sc->sbm_rxfilter);
1787 } 1760 }
1788 else { 1761 else {
1789 reg = SBMAC_READCSR(sc->sbm_rxfilter); 1762 reg = __raw_readq(sc->sbm_rxfilter);
1790 reg &= ~M_MAC_ALLPKT_EN; 1763 reg &= ~M_MAC_ALLPKT_EN;
1791 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 1764 __raw_writeq(reg, sc->sbm_rxfilter);
1792 } 1765 }
1793} 1766}
1794 1767
1795/********************************************************************** 1768/**********************************************************************
1796 * SBMAC_SETIPHDR_OFFSET(sc,onoff) 1769 * SBMAC_SETIPHDR_OFFSET(sc,onoff)
1797 * 1770 *
1798 * Set the iphdr offset as 15 assuming ethernet encapsulation 1771 * Set the iphdr offset as 15 assuming ethernet encapsulation
1799 * 1772 *
1800 * Input parameters: 1773 * Input parameters:
1801 * sc - softc 1774 * sc - softc
1802 * 1775 *
1803 * Return value: 1776 * Return value:
1804 * nothing 1777 * nothing
1805 ********************************************************************* */ 1778 ********************************************************************* */
@@ -1807,12 +1780,12 @@ static void sbmac_promiscuous_mode(struct sbmac_softc *sc,int onoff)
1807static void sbmac_set_iphdr_offset(struct sbmac_softc *sc) 1780static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
1808{ 1781{
1809 uint64_t reg; 1782 uint64_t reg;
1810 1783
1811 /* Hard code the off set to 15 for now */ 1784 /* Hard code the off set to 15 for now */
1812 reg = SBMAC_READCSR(sc->sbm_rxfilter); 1785 reg = __raw_readq(sc->sbm_rxfilter);
1813 reg &= ~M_MAC_IPHDR_OFFSET | V_MAC_IPHDR_OFFSET(15); 1786 reg &= ~M_MAC_IPHDR_OFFSET | V_MAC_IPHDR_OFFSET(15);
1814 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 1787 __raw_writeq(reg, sc->sbm_rxfilter);
1815 1788
1816 /* read system identification to determine revision */ 1789 /* read system identification to determine revision */
1817 if (periph_rev >= 2) { 1790 if (periph_rev >= 2) {
1818 sc->rx_hw_checksum = ENABLE; 1791 sc->rx_hw_checksum = ENABLE;
@@ -1824,13 +1797,13 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
1824 1797
1825/********************************************************************** 1798/**********************************************************************
1826 * SBMAC_ADDR2REG(ptr) 1799 * SBMAC_ADDR2REG(ptr)
1827 * 1800 *
1828 * Convert six bytes into the 64-bit register value that 1801 * Convert six bytes into the 64-bit register value that
1829 * we typically write into the SBMAC's address/mcast registers 1802 * we typically write into the SBMAC's address/mcast registers
1830 * 1803 *
1831 * Input parameters: 1804 * Input parameters:
1832 * ptr - pointer to 6 bytes 1805 * ptr - pointer to 6 bytes
1833 * 1806 *
1834 * Return value: 1807 * Return value:
1835 * register value 1808 * register value
1836 ********************************************************************* */ 1809 ********************************************************************* */
@@ -1838,35 +1811,35 @@ static void sbmac_set_iphdr_offset(struct sbmac_softc *sc)
1838static uint64_t sbmac_addr2reg(unsigned char *ptr) 1811static uint64_t sbmac_addr2reg(unsigned char *ptr)
1839{ 1812{
1840 uint64_t reg = 0; 1813 uint64_t reg = 0;
1841 1814
1842 ptr += 6; 1815 ptr += 6;
1843 1816
1844 reg |= (uint64_t) *(--ptr); 1817 reg |= (uint64_t) *(--ptr);
1845 reg <<= 8; 1818 reg <<= 8;
1846 reg |= (uint64_t) *(--ptr); 1819 reg |= (uint64_t) *(--ptr);
1847 reg <<= 8; 1820 reg <<= 8;
1848 reg |= (uint64_t) *(--ptr); 1821 reg |= (uint64_t) *(--ptr);
1849 reg <<= 8; 1822 reg <<= 8;
1850 reg |= (uint64_t) *(--ptr); 1823 reg |= (uint64_t) *(--ptr);
1851 reg <<= 8; 1824 reg <<= 8;
1852 reg |= (uint64_t) *(--ptr); 1825 reg |= (uint64_t) *(--ptr);
1853 reg <<= 8; 1826 reg <<= 8;
1854 reg |= (uint64_t) *(--ptr); 1827 reg |= (uint64_t) *(--ptr);
1855 1828
1856 return reg; 1829 return reg;
1857} 1830}
1858 1831
1859 1832
1860/********************************************************************** 1833/**********************************************************************
1861 * SBMAC_SET_SPEED(s,speed) 1834 * SBMAC_SET_SPEED(s,speed)
1862 * 1835 *
1863 * Configure LAN speed for the specified MAC. 1836 * Configure LAN speed for the specified MAC.
1864 * Warning: must be called when MAC is off! 1837 * Warning: must be called when MAC is off!
1865 * 1838 *
1866 * Input parameters: 1839 * Input parameters:
1867 * s - sbmac structure 1840 * s - sbmac structure
1868 * speed - speed to set MAC to (see sbmac_speed_t enum) 1841 * speed - speed to set MAC to (see sbmac_speed_t enum)
1869 * 1842 *
1870 * Return value: 1843 * Return value:
1871 * 1 if successful 1844 * 1 if successful
1872 * 0 indicates invalid parameters 1845 * 0 indicates invalid parameters
@@ -1880,31 +1853,31 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
1880 /* 1853 /*
1881 * Save new current values 1854 * Save new current values
1882 */ 1855 */
1883 1856
1884 s->sbm_speed = speed; 1857 s->sbm_speed = speed;
1885 1858
1886 if (s->sbm_state == sbmac_state_on) 1859 if (s->sbm_state == sbmac_state_on)
1887 return 0; /* save for next restart */ 1860 return 0; /* save for next restart */
1888 1861
1889 /* 1862 /*
1890 * Read current register values 1863 * Read current register values
1891 */ 1864 */
1892 1865
1893 cfg = SBMAC_READCSR(s->sbm_maccfg); 1866 cfg = __raw_readq(s->sbm_maccfg);
1894 framecfg = SBMAC_READCSR(s->sbm_framecfg); 1867 framecfg = __raw_readq(s->sbm_framecfg);
1895 1868
1896 /* 1869 /*
1897 * Mask out the stuff we want to change 1870 * Mask out the stuff we want to change
1898 */ 1871 */
1899 1872
1900 cfg &= ~(M_MAC_BURST_EN | M_MAC_SPEED_SEL); 1873 cfg &= ~(M_MAC_BURST_EN | M_MAC_SPEED_SEL);
1901 framecfg &= ~(M_MAC_IFG_RX | M_MAC_IFG_TX | M_MAC_IFG_THRSH | 1874 framecfg &= ~(M_MAC_IFG_RX | M_MAC_IFG_TX | M_MAC_IFG_THRSH |
1902 M_MAC_SLOT_SIZE); 1875 M_MAC_SLOT_SIZE);
1903 1876
1904 /* 1877 /*
1905 * Now add in the new bits 1878 * Now add in the new bits
1906 */ 1879 */
1907 1880
1908 switch (speed) { 1881 switch (speed) {
1909 case sbmac_speed_10: 1882 case sbmac_speed_10:
1910 framecfg |= V_MAC_IFG_RX_10 | 1883 framecfg |= V_MAC_IFG_RX_10 |
@@ -1913,7 +1886,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
1913 V_MAC_SLOT_SIZE_10; 1886 V_MAC_SLOT_SIZE_10;
1914 cfg |= V_MAC_SPEED_SEL_10MBPS; 1887 cfg |= V_MAC_SPEED_SEL_10MBPS;
1915 break; 1888 break;
1916 1889
1917 case sbmac_speed_100: 1890 case sbmac_speed_100:
1918 framecfg |= V_MAC_IFG_RX_100 | 1891 framecfg |= V_MAC_IFG_RX_100 |
1919 V_MAC_IFG_TX_100 | 1892 V_MAC_IFG_TX_100 |
@@ -1921,7 +1894,7 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
1921 V_MAC_SLOT_SIZE_100; 1894 V_MAC_SLOT_SIZE_100;
1922 cfg |= V_MAC_SPEED_SEL_100MBPS ; 1895 cfg |= V_MAC_SPEED_SEL_100MBPS ;
1923 break; 1896 break;
1924 1897
1925 case sbmac_speed_1000: 1898 case sbmac_speed_1000:
1926 framecfg |= V_MAC_IFG_RX_1000 | 1899 framecfg |= V_MAC_IFG_RX_1000 |
1927 V_MAC_IFG_TX_1000 | 1900 V_MAC_IFG_TX_1000 |
@@ -1929,34 +1902,34 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
1929 V_MAC_SLOT_SIZE_1000; 1902 V_MAC_SLOT_SIZE_1000;
1930 cfg |= V_MAC_SPEED_SEL_1000MBPS | M_MAC_BURST_EN; 1903 cfg |= V_MAC_SPEED_SEL_1000MBPS | M_MAC_BURST_EN;
1931 break; 1904 break;
1932 1905
1933 case sbmac_speed_auto: /* XXX not implemented */ 1906 case sbmac_speed_auto: /* XXX not implemented */
1934 /* fall through */ 1907 /* fall through */
1935 default: 1908 default:
1936 return 0; 1909 return 0;
1937 } 1910 }
1938 1911
1939 /* 1912 /*
1940 * Send the bits back to the hardware 1913 * Send the bits back to the hardware
1941 */ 1914 */
1942 1915
1943 SBMAC_WRITECSR(s->sbm_framecfg,framecfg); 1916 __raw_writeq(framecfg, s->sbm_framecfg);
1944 SBMAC_WRITECSR(s->sbm_maccfg,cfg); 1917 __raw_writeq(cfg, s->sbm_maccfg);
1945 1918
1946 return 1; 1919 return 1;
1947} 1920}
1948 1921
1949/********************************************************************** 1922/**********************************************************************
1950 * SBMAC_SET_DUPLEX(s,duplex,fc) 1923 * SBMAC_SET_DUPLEX(s,duplex,fc)
1951 * 1924 *
1952 * Set Ethernet duplex and flow control options for this MAC 1925 * Set Ethernet duplex and flow control options for this MAC
1953 * Warning: must be called when MAC is off! 1926 * Warning: must be called when MAC is off!
1954 * 1927 *
1955 * Input parameters: 1928 * Input parameters:
1956 * s - sbmac structure 1929 * s - sbmac structure
1957 * duplex - duplex setting (see sbmac_duplex_t) 1930 * duplex - duplex setting (see sbmac_duplex_t)
1958 * fc - flow control setting (see sbmac_fc_t) 1931 * fc - flow control setting (see sbmac_fc_t)
1959 * 1932 *
1960 * Return value: 1933 * Return value:
1961 * 1 if ok 1934 * 1 if ok
1962 * 0 if an invalid parameter combination was specified 1935 * 0 if an invalid parameter combination was specified
@@ -1965,67 +1938,67 @@ static int sbmac_set_speed(struct sbmac_softc *s,sbmac_speed_t speed)
1965static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc_t fc) 1938static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc_t fc)
1966{ 1939{
1967 uint64_t cfg; 1940 uint64_t cfg;
1968 1941
1969 /* 1942 /*
1970 * Save new current values 1943 * Save new current values
1971 */ 1944 */
1972 1945
1973 s->sbm_duplex = duplex; 1946 s->sbm_duplex = duplex;
1974 s->sbm_fc = fc; 1947 s->sbm_fc = fc;
1975 1948
1976 if (s->sbm_state == sbmac_state_on) 1949 if (s->sbm_state == sbmac_state_on)
1977 return 0; /* save for next restart */ 1950 return 0; /* save for next restart */
1978 1951
1979 /* 1952 /*
1980 * Read current register values 1953 * Read current register values
1981 */ 1954 */
1982 1955
1983 cfg = SBMAC_READCSR(s->sbm_maccfg); 1956 cfg = __raw_readq(s->sbm_maccfg);
1984 1957
1985 /* 1958 /*
1986 * Mask off the stuff we're about to change 1959 * Mask off the stuff we're about to change
1987 */ 1960 */
1988 1961
1989 cfg &= ~(M_MAC_FC_SEL | M_MAC_FC_CMD | M_MAC_HDX_EN); 1962 cfg &= ~(M_MAC_FC_SEL | M_MAC_FC_CMD | M_MAC_HDX_EN);
1990 1963
1991 1964
1992 switch (duplex) { 1965 switch (duplex) {
1993 case sbmac_duplex_half: 1966 case sbmac_duplex_half:
1994 switch (fc) { 1967 switch (fc) {
1995 case sbmac_fc_disabled: 1968 case sbmac_fc_disabled:
1996 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_DISABLED; 1969 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_DISABLED;
1997 break; 1970 break;
1998 1971
1999 case sbmac_fc_collision: 1972 case sbmac_fc_collision:
2000 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENABLED; 1973 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENABLED;
2001 break; 1974 break;
2002 1975
2003 case sbmac_fc_carrier: 1976 case sbmac_fc_carrier:
2004 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENAB_FALSECARR; 1977 cfg |= M_MAC_HDX_EN | V_MAC_FC_CMD_ENAB_FALSECARR;
2005 break; 1978 break;
2006 1979
2007 case sbmac_fc_auto: /* XXX not implemented */ 1980 case sbmac_fc_auto: /* XXX not implemented */
2008 /* fall through */ 1981 /* fall through */
2009 case sbmac_fc_frame: /* not valid in half duplex */ 1982 case sbmac_fc_frame: /* not valid in half duplex */
2010 default: /* invalid selection */ 1983 default: /* invalid selection */
2011 return 0; 1984 return 0;
2012 } 1985 }
2013 break; 1986 break;
2014 1987
2015 case sbmac_duplex_full: 1988 case sbmac_duplex_full:
2016 switch (fc) { 1989 switch (fc) {
2017 case sbmac_fc_disabled: 1990 case sbmac_fc_disabled:
2018 cfg |= V_MAC_FC_CMD_DISABLED; 1991 cfg |= V_MAC_FC_CMD_DISABLED;
2019 break; 1992 break;
2020 1993
2021 case sbmac_fc_frame: 1994 case sbmac_fc_frame:
2022 cfg |= V_MAC_FC_CMD_ENABLED; 1995 cfg |= V_MAC_FC_CMD_ENABLED;
2023 break; 1996 break;
2024 1997
2025 case sbmac_fc_collision: /* not valid in full duplex */ 1998 case sbmac_fc_collision: /* not valid in full duplex */
2026 case sbmac_fc_carrier: /* not valid in full duplex */ 1999 case sbmac_fc_carrier: /* not valid in full duplex */
2027 case sbmac_fc_auto: /* XXX not implemented */ 2000 case sbmac_fc_auto: /* XXX not implemented */
2028 /* fall through */ 2001 /* fall through */
2029 default: 2002 default:
2030 return 0; 2003 return 0;
2031 } 2004 }
@@ -2034,13 +2007,13 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc
2034 /* XXX not implemented */ 2007 /* XXX not implemented */
2035 break; 2008 break;
2036 } 2009 }
2037 2010
2038 /* 2011 /*
2039 * Send the bits back to the hardware 2012 * Send the bits back to the hardware
2040 */ 2013 */
2041 2014
2042 SBMAC_WRITECSR(s->sbm_maccfg,cfg); 2015 __raw_writeq(cfg, s->sbm_maccfg);
2043 2016
2044 return 1; 2017 return 1;
2045} 2018}
2046 2019
@@ -2049,12 +2022,12 @@ static int sbmac_set_duplex(struct sbmac_softc *s,sbmac_duplex_t duplex,sbmac_fc
2049 2022
2050/********************************************************************** 2023/**********************************************************************
2051 * SBMAC_INTR() 2024 * SBMAC_INTR()
2052 * 2025 *
2053 * Interrupt handler for MAC interrupts 2026 * Interrupt handler for MAC interrupts
2054 * 2027 *
2055 * Input parameters: 2028 * Input parameters:
2056 * MAC structure 2029 * MAC structure
2057 * 2030 *
2058 * Return value: 2031 * Return value:
2059 * nothing 2032 * nothing
2060 ********************************************************************* */ 2033 ********************************************************************* */
@@ -2066,27 +2039,27 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
2066 int handled = 0; 2039 int handled = 0;
2067 2040
2068 for (;;) { 2041 for (;;) {
2069 2042
2070 /* 2043 /*
2071 * Read the ISR (this clears the bits in the real 2044 * Read the ISR (this clears the bits in the real
2072 * register, except for counter addr) 2045 * register, except for counter addr)
2073 */ 2046 */
2074 2047
2075 isr = SBMAC_READCSR(sc->sbm_isr) & ~M_MAC_COUNTER_ADDR; 2048 isr = __raw_readq(sc->sbm_isr) & ~M_MAC_COUNTER_ADDR;
2076 2049
2077 if (isr == 0) 2050 if (isr == 0)
2078 break; 2051 break;
2079 2052
2080 handled = 1; 2053 handled = 1;
2081 2054
2082 /* 2055 /*
2083 * Transmits on channel 0 2056 * Transmits on channel 0
2084 */ 2057 */
2085 2058
2086 if (isr & (M_MAC_INT_CHANNEL << S_MAC_TX_CH0)) { 2059 if (isr & (M_MAC_INT_CHANNEL << S_MAC_TX_CH0)) {
2087 sbdma_tx_process(sc,&(sc->sbm_txdma)); 2060 sbdma_tx_process(sc,&(sc->sbm_txdma));
2088 } 2061 }
2089 2062
2090 /* 2063 /*
2091 * Receives on channel 0 2064 * Receives on channel 0
2092 */ 2065 */
@@ -2106,8 +2079,8 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
2106 * EOP_SEEN here takes care of this case. 2079 * EOP_SEEN here takes care of this case.
2107 * (EOP_SEEN is part of M_MAC_INT_CHANNEL << S_MAC_RX_CH0) 2080 * (EOP_SEEN is part of M_MAC_INT_CHANNEL << S_MAC_RX_CH0)
2108 */ 2081 */
2109 2082
2110 2083
2111 if (isr & (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)) { 2084 if (isr & (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)) {
2112 sbdma_rx_process(sc,&(sc->sbm_rxdma)); 2085 sbdma_rx_process(sc,&(sc->sbm_rxdma));
2113 } 2086 }
@@ -2118,29 +2091,29 @@ static irqreturn_t sbmac_intr(int irq,void *dev_instance,struct pt_regs *rgs)
2118 2091
2119/********************************************************************** 2092/**********************************************************************
2120 * SBMAC_START_TX(skb,dev) 2093 * SBMAC_START_TX(skb,dev)
2121 * 2094 *
2122 * Start output on the specified interface. Basically, we 2095 * Start output on the specified interface. Basically, we
2123 * queue as many buffers as we can until the ring fills up, or 2096 * queue as many buffers as we can until the ring fills up, or
2124 * we run off the end of the queue, whichever comes first. 2097 * we run off the end of the queue, whichever comes first.
2125 * 2098 *
2126 * Input parameters: 2099 * Input parameters:
2127 * 2100 *
2128 * 2101 *
2129 * Return value: 2102 * Return value:
2130 * nothing 2103 * nothing
2131 ********************************************************************* */ 2104 ********************************************************************* */
2132static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev) 2105static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev)
2133{ 2106{
2134 struct sbmac_softc *sc = netdev_priv(dev); 2107 struct sbmac_softc *sc = netdev_priv(dev);
2135 2108
2136 /* lock eth irq */ 2109 /* lock eth irq */
2137 spin_lock_irq (&sc->sbm_lock); 2110 spin_lock_irq (&sc->sbm_lock);
2138 2111
2139 /* 2112 /*
2140 * Put the buffer on the transmit ring. If we 2113 * Put the buffer on the transmit ring. If we
2141 * don't have room, stop the queue. 2114 * don't have room, stop the queue.
2142 */ 2115 */
2143 2116
2144 if (sbdma_add_txbuffer(&(sc->sbm_txdma),skb)) { 2117 if (sbdma_add_txbuffer(&(sc->sbm_txdma),skb)) {
2145 /* XXX save skb that we could not send */ 2118 /* XXX save skb that we could not send */
2146 netif_stop_queue(dev); 2119 netif_stop_queue(dev);
@@ -2148,24 +2121,24 @@ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev)
2148 2121
2149 return 1; 2122 return 1;
2150 } 2123 }
2151 2124
2152 dev->trans_start = jiffies; 2125 dev->trans_start = jiffies;
2153 2126
2154 spin_unlock_irq (&sc->sbm_lock); 2127 spin_unlock_irq (&sc->sbm_lock);
2155 2128
2156 return 0; 2129 return 0;
2157} 2130}
2158 2131
2159/********************************************************************** 2132/**********************************************************************
2160 * SBMAC_SETMULTI(sc) 2133 * SBMAC_SETMULTI(sc)
2161 * 2134 *
2162 * Reprogram the multicast table into the hardware, given 2135 * Reprogram the multicast table into the hardware, given
2163 * the list of multicasts associated with the interface 2136 * the list of multicasts associated with the interface
2164 * structure. 2137 * structure.
2165 * 2138 *
2166 * Input parameters: 2139 * Input parameters:
2167 * sc - softc 2140 * sc - softc
2168 * 2141 *
2169 * Return value: 2142 * Return value:
2170 * nothing 2143 * nothing
2171 ********************************************************************* */ 2144 ********************************************************************* */
@@ -2173,75 +2146,75 @@ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev)
2173static void sbmac_setmulti(struct sbmac_softc *sc) 2146static void sbmac_setmulti(struct sbmac_softc *sc)
2174{ 2147{
2175 uint64_t reg; 2148 uint64_t reg;
2176 sbmac_port_t port; 2149 volatile void __iomem *port;
2177 int idx; 2150 int idx;
2178 struct dev_mc_list *mclist; 2151 struct dev_mc_list *mclist;
2179 struct net_device *dev = sc->sbm_dev; 2152 struct net_device *dev = sc->sbm_dev;
2180 2153
2181 /* 2154 /*
2182 * Clear out entire multicast table. We do this by nuking 2155 * Clear out entire multicast table. We do this by nuking
2183 * the entire hash table and all the direct matches except 2156 * the entire hash table and all the direct matches except
2184 * the first one, which is used for our station address 2157 * the first one, which is used for our station address
2185 */ 2158 */
2186 2159
2187 for (idx = 1; idx < MAC_ADDR_COUNT; idx++) { 2160 for (idx = 1; idx < MAC_ADDR_COUNT; idx++) {
2188 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx*sizeof(uint64_t)); 2161 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx*sizeof(uint64_t));
2189 SBMAC_WRITECSR(port,0); 2162 __raw_writeq(0, port);
2190 } 2163 }
2191 2164
2192 for (idx = 0; idx < MAC_HASH_COUNT; idx++) { 2165 for (idx = 0; idx < MAC_HASH_COUNT; idx++) {
2193 port = sc->sbm_base + R_MAC_HASH_BASE+(idx*sizeof(uint64_t)); 2166 port = sc->sbm_base + R_MAC_HASH_BASE+(idx*sizeof(uint64_t));
2194 SBMAC_WRITECSR(port,0); 2167 __raw_writeq(0, port);
2195 } 2168 }
2196 2169
2197 /* 2170 /*
2198 * Clear the filter to say we don't want any multicasts. 2171 * Clear the filter to say we don't want any multicasts.
2199 */ 2172 */
2200 2173
2201 reg = SBMAC_READCSR(sc->sbm_rxfilter); 2174 reg = __raw_readq(sc->sbm_rxfilter);
2202 reg &= ~(M_MAC_MCAST_INV | M_MAC_MCAST_EN); 2175 reg &= ~(M_MAC_MCAST_INV | M_MAC_MCAST_EN);
2203 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 2176 __raw_writeq(reg, sc->sbm_rxfilter);
2204 2177
2205 if (dev->flags & IFF_ALLMULTI) { 2178 if (dev->flags & IFF_ALLMULTI) {
2206 /* 2179 /*
2207 * Enable ALL multicasts. Do this by inverting the 2180 * Enable ALL multicasts. Do this by inverting the
2208 * multicast enable bit. 2181 * multicast enable bit.
2209 */ 2182 */
2210 reg = SBMAC_READCSR(sc->sbm_rxfilter); 2183 reg = __raw_readq(sc->sbm_rxfilter);
2211 reg |= (M_MAC_MCAST_INV | M_MAC_MCAST_EN); 2184 reg |= (M_MAC_MCAST_INV | M_MAC_MCAST_EN);
2212 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 2185 __raw_writeq(reg, sc->sbm_rxfilter);
2213 return; 2186 return;
2214 } 2187 }
2215
2216 2188
2217 /* 2189
2190 /*
2218 * Progam new multicast entries. For now, only use the 2191 * Progam new multicast entries. For now, only use the
2219 * perfect filter. In the future we'll need to use the 2192 * perfect filter. In the future we'll need to use the
2220 * hash filter if the perfect filter overflows 2193 * hash filter if the perfect filter overflows
2221 */ 2194 */
2222 2195
2223 /* XXX only using perfect filter for now, need to use hash 2196 /* XXX only using perfect filter for now, need to use hash
2224 * XXX if the table overflows */ 2197 * XXX if the table overflows */
2225 2198
2226 idx = 1; /* skip station address */ 2199 idx = 1; /* skip station address */
2227 mclist = dev->mc_list; 2200 mclist = dev->mc_list;
2228 while (mclist && (idx < MAC_ADDR_COUNT)) { 2201 while (mclist && (idx < MAC_ADDR_COUNT)) {
2229 reg = sbmac_addr2reg(mclist->dmi_addr); 2202 reg = sbmac_addr2reg(mclist->dmi_addr);
2230 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t)); 2203 port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t));
2231 SBMAC_WRITECSR(port,reg); 2204 __raw_writeq(reg, port);
2232 idx++; 2205 idx++;
2233 mclist = mclist->next; 2206 mclist = mclist->next;
2234 } 2207 }
2235 2208
2236 /* 2209 /*
2237 * Enable the "accept multicast bits" if we programmed at least one 2210 * Enable the "accept multicast bits" if we programmed at least one
2238 * multicast. 2211 * multicast.
2239 */ 2212 */
2240 2213
2241 if (idx > 1) { 2214 if (idx > 1) {
2242 reg = SBMAC_READCSR(sc->sbm_rxfilter); 2215 reg = __raw_readq(sc->sbm_rxfilter);
2243 reg |= M_MAC_MCAST_EN; 2216 reg |= M_MAC_MCAST_EN;
2244 SBMAC_WRITECSR(sc->sbm_rxfilter,reg); 2217 __raw_writeq(reg, sc->sbm_rxfilter);
2245 } 2218 }
2246} 2219}
2247 2220
@@ -2250,12 +2223,12 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
2250#if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) || defined(SBMAC_ETH2_HWADDR) 2223#if defined(SBMAC_ETH0_HWADDR) || defined(SBMAC_ETH1_HWADDR) || defined(SBMAC_ETH2_HWADDR)
2251/********************************************************************** 2224/**********************************************************************
2252 * SBMAC_PARSE_XDIGIT(str) 2225 * SBMAC_PARSE_XDIGIT(str)
2253 * 2226 *
2254 * Parse a hex digit, returning its value 2227 * Parse a hex digit, returning its value
2255 * 2228 *
2256 * Input parameters: 2229 * Input parameters:
2257 * str - character 2230 * str - character
2258 * 2231 *
2259 * Return value: 2232 * Return value:
2260 * hex value, or -1 if invalid 2233 * hex value, or -1 if invalid
2261 ********************************************************************* */ 2234 ********************************************************************* */
@@ -2263,7 +2236,7 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
2263static int sbmac_parse_xdigit(char str) 2236static int sbmac_parse_xdigit(char str)
2264{ 2237{
2265 int digit; 2238 int digit;
2266 2239
2267 if ((str >= '0') && (str <= '9')) 2240 if ((str >= '0') && (str <= '9'))
2268 digit = str - '0'; 2241 digit = str - '0';
2269 else if ((str >= 'a') && (str <= 'f')) 2242 else if ((str >= 'a') && (str <= 'f'))
@@ -2272,20 +2245,20 @@ static int sbmac_parse_xdigit(char str)
2272 digit = str - 'A' + 10; 2245 digit = str - 'A' + 10;
2273 else 2246 else
2274 return -1; 2247 return -1;
2275 2248
2276 return digit; 2249 return digit;
2277} 2250}
2278 2251
2279/********************************************************************** 2252/**********************************************************************
2280 * SBMAC_PARSE_HWADDR(str,hwaddr) 2253 * SBMAC_PARSE_HWADDR(str,hwaddr)
2281 * 2254 *
2282 * Convert a string in the form xx:xx:xx:xx:xx:xx into a 6-byte 2255 * Convert a string in the form xx:xx:xx:xx:xx:xx into a 6-byte
2283 * Ethernet address. 2256 * Ethernet address.
2284 * 2257 *
2285 * Input parameters: 2258 * Input parameters:
2286 * str - string 2259 * str - string
2287 * hwaddr - pointer to hardware address 2260 * hwaddr - pointer to hardware address
2288 * 2261 *
2289 * Return value: 2262 * Return value:
2290 * 0 if ok, else -1 2263 * 0 if ok, else -1
2291 ********************************************************************* */ 2264 ********************************************************************* */
@@ -2294,7 +2267,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
2294{ 2267{
2295 int digit1,digit2; 2268 int digit1,digit2;
2296 int idx = 6; 2269 int idx = 6;
2297 2270
2298 while (*str && (idx > 0)) { 2271 while (*str && (idx > 0)) {
2299 digit1 = sbmac_parse_xdigit(*str); 2272 digit1 = sbmac_parse_xdigit(*str);
2300 if (digit1 < 0) 2273 if (digit1 < 0)
@@ -2302,7 +2275,7 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
2302 str++; 2275 str++;
2303 if (!*str) 2276 if (!*str)
2304 return -1; 2277 return -1;
2305 2278
2306 if ((*str == ':') || (*str == '-')) { 2279 if ((*str == ':') || (*str == '-')) {
2307 digit2 = digit1; 2280 digit2 = digit1;
2308 digit1 = 0; 2281 digit1 = 0;
@@ -2313,10 +2286,10 @@ static int sbmac_parse_hwaddr(char *str, unsigned char *hwaddr)
2313 return -1; 2286 return -1;
2314 str++; 2287 str++;
2315 } 2288 }
2316 2289
2317 *hwaddr++ = (digit1 << 4) | digit2; 2290 *hwaddr++ = (digit1 << 4) | digit2;
2318 idx--; 2291 idx--;
2319 2292
2320 if (*str == '-') 2293 if (*str == '-')
2321 str++; 2294 str++;
2322 if (*str == ':') 2295 if (*str == ':')
@@ -2337,12 +2310,12 @@ static int sb1250_change_mtu(struct net_device *_dev, int new_mtu)
2337 2310
2338/********************************************************************** 2311/**********************************************************************
2339 * SBMAC_INIT(dev) 2312 * SBMAC_INIT(dev)
2340 * 2313 *
2341 * Attach routine - init hardware and hook ourselves into linux 2314 * Attach routine - init hardware and hook ourselves into linux
2342 * 2315 *
2343 * Input parameters: 2316 * Input parameters:
2344 * dev - net_device structure 2317 * dev - net_device structure
2345 * 2318 *
2346 * Return value: 2319 * Return value:
2347 * status 2320 * status
2348 ********************************************************************* */ 2321 ********************************************************************* */
@@ -2354,53 +2327,53 @@ static int sbmac_init(struct net_device *dev, int idx)
2354 uint64_t ea_reg; 2327 uint64_t ea_reg;
2355 int i; 2328 int i;
2356 int err; 2329 int err;
2357 2330
2358 sc = netdev_priv(dev); 2331 sc = netdev_priv(dev);
2359 2332
2360 /* Determine controller base address */ 2333 /* Determine controller base address */
2361 2334
2362 sc->sbm_base = IOADDR(dev->base_addr); 2335 sc->sbm_base = IOADDR(dev->base_addr);
2363 sc->sbm_dev = dev; 2336 sc->sbm_dev = dev;
2364 sc->sbe_idx = idx; 2337 sc->sbe_idx = idx;
2365 2338
2366 eaddr = sc->sbm_hwaddr; 2339 eaddr = sc->sbm_hwaddr;
2367 2340
2368 /* 2341 /*
2369 * Read the ethernet address. The firwmare left this programmed 2342 * Read the ethernet address. The firwmare left this programmed
2370 * for us in the ethernet address register for each mac. 2343 * for us in the ethernet address register for each mac.
2371 */ 2344 */
2372 2345
2373 ea_reg = SBMAC_READCSR(sc->sbm_base + R_MAC_ETHERNET_ADDR); 2346 ea_reg = __raw_readq(sc->sbm_base + R_MAC_ETHERNET_ADDR);
2374 SBMAC_WRITECSR(sc->sbm_base + R_MAC_ETHERNET_ADDR, 0); 2347 __raw_writeq(0, sc->sbm_base + R_MAC_ETHERNET_ADDR);
2375 for (i = 0; i < 6; i++) { 2348 for (i = 0; i < 6; i++) {
2376 eaddr[i] = (uint8_t) (ea_reg & 0xFF); 2349 eaddr[i] = (uint8_t) (ea_reg & 0xFF);
2377 ea_reg >>= 8; 2350 ea_reg >>= 8;
2378 } 2351 }
2379 2352
2380 for (i = 0; i < 6; i++) { 2353 for (i = 0; i < 6; i++) {
2381 dev->dev_addr[i] = eaddr[i]; 2354 dev->dev_addr[i] = eaddr[i];
2382 } 2355 }
2383 2356
2384 2357
2385 /* 2358 /*
2386 * Init packet size 2359 * Init packet size
2387 */ 2360 */
2388 2361
2389 sc->sbm_buffersize = ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN; 2362 sc->sbm_buffersize = ENET_PACKET_SIZE + SMP_CACHE_BYTES * 2 + ETHER_ALIGN;
2390 2363
2391 /* 2364 /*
2392 * Initialize context (get pointers to registers and stuff), then 2365 * Initialize context (get pointers to registers and stuff), then
2393 * allocate the memory for the descriptor tables. 2366 * allocate the memory for the descriptor tables.
2394 */ 2367 */
2395 2368
2396 sbmac_initctx(sc); 2369 sbmac_initctx(sc);
2397 2370
2398 /* 2371 /*
2399 * Set up Linux device callins 2372 * Set up Linux device callins
2400 */ 2373 */
2401 2374
2402 spin_lock_init(&(sc->sbm_lock)); 2375 spin_lock_init(&(sc->sbm_lock));
2403 2376
2404 dev->open = sbmac_open; 2377 dev->open = sbmac_open;
2405 dev->hard_start_xmit = sbmac_start_tx; 2378 dev->hard_start_xmit = sbmac_start_tx;
2406 dev->stop = sbmac_close; 2379 dev->stop = sbmac_close;
@@ -2419,7 +2392,7 @@ static int sbmac_init(struct net_device *dev, int idx)
2419 if (err) 2392 if (err)
2420 goto out_uninit; 2393 goto out_uninit;
2421 2394
2422 if (periph_rev >= 2) { 2395 if (sc->rx_hw_checksum == ENABLE) {
2423 printk(KERN_INFO "%s: enabling TCP rcv checksum\n", 2396 printk(KERN_INFO "%s: enabling TCP rcv checksum\n",
2424 sc->sbm_dev->name); 2397 sc->sbm_dev->name);
2425 } 2398 }
@@ -2430,10 +2403,10 @@ static int sbmac_init(struct net_device *dev, int idx)
2430 * was being displayed) 2403 * was being displayed)
2431 */ 2404 */
2432 printk(KERN_INFO 2405 printk(KERN_INFO
2433 "%s: SiByte Ethernet at 0x%08lX, address: %02X:%02X:%02X:%02X:%02X:%02X\n", 2406 "%s: SiByte Ethernet at 0x%08lX, address: %02X:%02X:%02X:%02X:%02X:%02X\n",
2434 dev->name, dev->base_addr, 2407 dev->name, dev->base_addr,
2435 eaddr[0],eaddr[1],eaddr[2],eaddr[3],eaddr[4],eaddr[5]); 2408 eaddr[0],eaddr[1],eaddr[2],eaddr[3],eaddr[4],eaddr[5]);
2436 2409
2437 2410
2438 return 0; 2411 return 0;
2439 2412
@@ -2447,54 +2420,86 @@ out_uninit:
2447static int sbmac_open(struct net_device *dev) 2420static int sbmac_open(struct net_device *dev)
2448{ 2421{
2449 struct sbmac_softc *sc = netdev_priv(dev); 2422 struct sbmac_softc *sc = netdev_priv(dev);
2450 2423
2451 if (debug > 1) { 2424 if (debug > 1) {
2452 printk(KERN_DEBUG "%s: sbmac_open() irq %d.\n", dev->name, dev->irq); 2425 printk(KERN_DEBUG "%s: sbmac_open() irq %d.\n", dev->name, dev->irq);
2453 } 2426 }
2454 2427
2455 /* 2428 /*
2456 * map/route interrupt (clear status first, in case something 2429 * map/route interrupt (clear status first, in case something
2457 * weird is pending; we haven't initialized the mac registers 2430 * weird is pending; we haven't initialized the mac registers
2458 * yet) 2431 * yet)
2459 */ 2432 */
2460 2433
2461 SBMAC_READCSR(sc->sbm_isr); 2434 __raw_readq(sc->sbm_isr);
2462 if (request_irq(dev->irq, &sbmac_intr, SA_SHIRQ, dev->name, dev)) 2435 if (request_irq(dev->irq, &sbmac_intr, SA_SHIRQ, dev->name, dev))
2463 return -EBUSY; 2436 return -EBUSY;
2464 2437
2465 /* 2438 /*
2466 * Configure default speed 2439 * Probe phy address
2440 */
2441
2442 if(sbmac_mii_probe(dev) == -1) {
2443 printk("%s: failed to probe PHY.\n", dev->name);
2444 return -EINVAL;
2445 }
2446
2447 /*
2448 * Configure default speed
2467 */ 2449 */
2468 2450
2469 sbmac_mii_poll(sc,noisy_mii); 2451 sbmac_mii_poll(sc,noisy_mii);
2470 2452
2471 /* 2453 /*
2472 * Turn on the channel 2454 * Turn on the channel
2473 */ 2455 */
2474 2456
2475 sbmac_set_channel_state(sc,sbmac_state_on); 2457 sbmac_set_channel_state(sc,sbmac_state_on);
2476 2458
2477 /* 2459 /*
2478 * XXX Station address is in dev->dev_addr 2460 * XXX Station address is in dev->dev_addr
2479 */ 2461 */
2480 2462
2481 if (dev->if_port == 0) 2463 if (dev->if_port == 0)
2482 dev->if_port = 0; 2464 dev->if_port = 0;
2483 2465
2484 netif_start_queue(dev); 2466 netif_start_queue(dev);
2485 2467
2486 sbmac_set_rx_mode(dev); 2468 sbmac_set_rx_mode(dev);
2487 2469
2488 /* Set the timer to check for link beat. */ 2470 /* Set the timer to check for link beat. */
2489 init_timer(&sc->sbm_timer); 2471 init_timer(&sc->sbm_timer);
2490 sc->sbm_timer.expires = jiffies + 2 * HZ/100; 2472 sc->sbm_timer.expires = jiffies + 2 * HZ/100;
2491 sc->sbm_timer.data = (unsigned long)dev; 2473 sc->sbm_timer.data = (unsigned long)dev;
2492 sc->sbm_timer.function = &sbmac_timer; 2474 sc->sbm_timer.function = &sbmac_timer;
2493 add_timer(&sc->sbm_timer); 2475 add_timer(&sc->sbm_timer);
2494 2476
2495 return 0; 2477 return 0;
2496} 2478}
2497 2479
2480static int sbmac_mii_probe(struct net_device *dev)
2481{
2482 int i;
2483 struct sbmac_softc *s = netdev_priv(dev);
2484 u16 bmsr, id1, id2;
2485 u32 vendor, device;
2486
2487 for (i=1; i<31; i++) {
2488 bmsr = sbmac_mii_read(s, i, MII_BMSR);
2489 if (bmsr != 0) {
2490 s->sbm_phys[0] = i;
2491 id1 = sbmac_mii_read(s, i, MII_PHYIDR1);
2492 id2 = sbmac_mii_read(s, i, MII_PHYIDR2);
2493 vendor = ((u32)id1 << 6) | ((id2 >> 10) & 0x3f);
2494 device = (id2 >> 4) & 0x3f;
2495
2496 printk(KERN_INFO "%s: found phy %d, vendor %06x part %02x\n",
2497 dev->name, i, vendor, device);
2498 return i;
2499 }
2500 }
2501 return -1;
2502}
2498 2503
2499 2504
2500static int sbmac_mii_poll(struct sbmac_softc *s,int noisy) 2505static int sbmac_mii_poll(struct sbmac_softc *s,int noisy)
@@ -2609,20 +2614,20 @@ static void sbmac_timer(unsigned long data)
2609 int mii_status; 2614 int mii_status;
2610 2615
2611 spin_lock_irq (&sc->sbm_lock); 2616 spin_lock_irq (&sc->sbm_lock);
2612 2617
2613 /* make IFF_RUNNING follow the MII status bit "Link established" */ 2618 /* make IFF_RUNNING follow the MII status bit "Link established" */
2614 mii_status = sbmac_mii_read(sc, sc->sbm_phys[0], MII_BMSR); 2619 mii_status = sbmac_mii_read(sc, sc->sbm_phys[0], MII_BMSR);
2615 2620
2616 if ( (mii_status & BMSR_LINKSTAT) != (sc->sbm_phy_oldlinkstat) ) { 2621 if ( (mii_status & BMSR_LINKSTAT) != (sc->sbm_phy_oldlinkstat) ) {
2617 sc->sbm_phy_oldlinkstat = mii_status & BMSR_LINKSTAT; 2622 sc->sbm_phy_oldlinkstat = mii_status & BMSR_LINKSTAT;
2618 if (mii_status & BMSR_LINKSTAT) { 2623 if (mii_status & BMSR_LINKSTAT) {
2619 netif_carrier_on(dev); 2624 netif_carrier_on(dev);
2620 } 2625 }
2621 else { 2626 else {
2622 netif_carrier_off(dev); 2627 netif_carrier_off(dev);
2623 } 2628 }
2624 } 2629 }
2625 2630
2626 /* 2631 /*
2627 * Poll the PHY to see what speed we should be running at 2632 * Poll the PHY to see what speed we should be running at
2628 */ 2633 */
@@ -2640,9 +2645,9 @@ static void sbmac_timer(unsigned long data)
2640 sbmac_channel_start(sc); 2645 sbmac_channel_start(sc);
2641 } 2646 }
2642 } 2647 }
2643 2648
2644 spin_unlock_irq (&sc->sbm_lock); 2649 spin_unlock_irq (&sc->sbm_lock);
2645 2650
2646 sc->sbm_timer.expires = jiffies + next_tick; 2651 sc->sbm_timer.expires = jiffies + next_tick;
2647 add_timer(&sc->sbm_timer); 2652 add_timer(&sc->sbm_timer);
2648} 2653}
@@ -2651,13 +2656,13 @@ static void sbmac_timer(unsigned long data)
2651static void sbmac_tx_timeout (struct net_device *dev) 2656static void sbmac_tx_timeout (struct net_device *dev)
2652{ 2657{
2653 struct sbmac_softc *sc = netdev_priv(dev); 2658 struct sbmac_softc *sc = netdev_priv(dev);
2654 2659
2655 spin_lock_irq (&sc->sbm_lock); 2660 spin_lock_irq (&sc->sbm_lock);
2656 2661
2657 2662
2658 dev->trans_start = jiffies; 2663 dev->trans_start = jiffies;
2659 sc->sbm_stats.tx_errors++; 2664 sc->sbm_stats.tx_errors++;
2660 2665
2661 spin_unlock_irq (&sc->sbm_lock); 2666 spin_unlock_irq (&sc->sbm_lock);
2662 2667
2663 printk (KERN_WARNING "%s: Transmit timed out\n",dev->name); 2668 printk (KERN_WARNING "%s: Transmit timed out\n",dev->name);
@@ -2670,13 +2675,13 @@ static struct net_device_stats *sbmac_get_stats(struct net_device *dev)
2670{ 2675{
2671 struct sbmac_softc *sc = netdev_priv(dev); 2676 struct sbmac_softc *sc = netdev_priv(dev);
2672 unsigned long flags; 2677 unsigned long flags;
2673 2678
2674 spin_lock_irqsave(&sc->sbm_lock, flags); 2679 spin_lock_irqsave(&sc->sbm_lock, flags);
2675 2680
2676 /* XXX update other stats here */ 2681 /* XXX update other stats here */
2677 2682
2678 spin_unlock_irqrestore(&sc->sbm_lock, flags); 2683 spin_unlock_irqrestore(&sc->sbm_lock, flags);
2679 2684
2680 return &sc->sbm_stats; 2685 return &sc->sbm_stats;
2681} 2686}
2682 2687
@@ -2693,8 +2698,8 @@ static void sbmac_set_rx_mode(struct net_device *dev)
2693 /* 2698 /*
2694 * Promiscuous changed. 2699 * Promiscuous changed.
2695 */ 2700 */
2696 2701
2697 if (dev->flags & IFF_PROMISC) { 2702 if (dev->flags & IFF_PROMISC) {
2698 /* Unconditionally log net taps. */ 2703 /* Unconditionally log net taps. */
2699 msg_flag = 1; 2704 msg_flag = 1;
2700 sbmac_promiscuous_mode(sc,1); 2705 sbmac_promiscuous_mode(sc,1);
@@ -2705,18 +2710,18 @@ static void sbmac_set_rx_mode(struct net_device *dev)
2705 } 2710 }
2706 } 2711 }
2707 spin_unlock_irqrestore(&sc->sbm_lock, flags); 2712 spin_unlock_irqrestore(&sc->sbm_lock, flags);
2708 2713
2709 if (msg_flag) { 2714 if (msg_flag) {
2710 printk(KERN_NOTICE "%s: Promiscuous mode %sabled.\n", 2715 printk(KERN_NOTICE "%s: Promiscuous mode %sabled.\n",
2711 dev->name,(msg_flag==1)?"en":"dis"); 2716 dev->name,(msg_flag==1)?"en":"dis");
2712 } 2717 }
2713 2718
2714 /* 2719 /*
2715 * Program the multicasts. Do this every time. 2720 * Program the multicasts. Do this every time.
2716 */ 2721 */
2717 2722
2718 sbmac_setmulti(sc); 2723 sbmac_setmulti(sc);
2719 2724
2720} 2725}
2721 2726
2722static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2727static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
@@ -2725,10 +2730,10 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2725 u16 *data = (u16 *)&rq->ifr_ifru; 2730 u16 *data = (u16 *)&rq->ifr_ifru;
2726 unsigned long flags; 2731 unsigned long flags;
2727 int retval; 2732 int retval;
2728 2733
2729 spin_lock_irqsave(&sc->sbm_lock, flags); 2734 spin_lock_irqsave(&sc->sbm_lock, flags);
2730 retval = 0; 2735 retval = 0;
2731 2736
2732 switch(cmd) { 2737 switch(cmd) {
2733 case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */ 2738 case SIOCDEVPRIVATE: /* Get the address of the PHY in use. */
2734 data[0] = sc->sbm_phys[0] & 0x1f; 2739 data[0] = sc->sbm_phys[0] & 0x1f;
@@ -2750,7 +2755,7 @@ static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2750 default: 2755 default:
2751 retval = -EOPNOTSUPP; 2756 retval = -EOPNOTSUPP;
2752 } 2757 }
2753 2758
2754 spin_unlock_irqrestore(&sc->sbm_lock, flags); 2759 spin_unlock_irqrestore(&sc->sbm_lock, flags);
2755 return retval; 2760 return retval;
2756} 2761}
@@ -2781,7 +2786,7 @@ static int sbmac_close(struct net_device *dev)
2781 2786
2782 sbdma_emptyring(&(sc->sbm_txdma)); 2787 sbdma_emptyring(&(sc->sbm_txdma));
2783 sbdma_emptyring(&(sc->sbm_rxdma)); 2788 sbdma_emptyring(&(sc->sbm_rxdma));
2784 2789
2785 return 0; 2790 return 0;
2786} 2791}
2787 2792
@@ -2793,13 +2798,13 @@ sbmac_setup_hwaddr(int chan,char *addr)
2793{ 2798{
2794 uint8_t eaddr[6]; 2799 uint8_t eaddr[6];
2795 uint64_t val; 2800 uint64_t val;
2796 sbmac_port_t port; 2801 unsigned long port;
2797 2802
2798 port = A_MAC_CHANNEL_BASE(chan); 2803 port = A_MAC_CHANNEL_BASE(chan);
2799 sbmac_parse_hwaddr(addr,eaddr); 2804 sbmac_parse_hwaddr(addr,eaddr);
2800 val = sbmac_addr2reg(eaddr); 2805 val = sbmac_addr2reg(eaddr);
2801 SBMAC_WRITECSR(IOADDR(port+R_MAC_ETHERNET_ADDR),val); 2806 __raw_writeq(val, IOADDR(port+R_MAC_ETHERNET_ADDR));
2802 val = SBMAC_READCSR(IOADDR(port+R_MAC_ETHERNET_ADDR)); 2807 val = __raw_readq(IOADDR(port+R_MAC_ETHERNET_ADDR));
2803} 2808}
2804#endif 2809#endif
2805 2810
@@ -2810,9 +2815,9 @@ sbmac_init_module(void)
2810{ 2815{
2811 int idx; 2816 int idx;
2812 struct net_device *dev; 2817 struct net_device *dev;
2813 sbmac_port_t port; 2818 unsigned long port;
2814 int chip_max_units; 2819 int chip_max_units;
2815 2820
2816 /* 2821 /*
2817 * For bringup when not using the firmware, we can pre-fill 2822 * For bringup when not using the firmware, we can pre-fill
2818 * the MAC addresses using the environment variables 2823 * the MAC addresses using the environment variables
@@ -2858,13 +2863,13 @@ sbmac_init_module(void)
2858 2863
2859 port = A_MAC_CHANNEL_BASE(idx); 2864 port = A_MAC_CHANNEL_BASE(idx);
2860 2865
2861 /* 2866 /*
2862 * The R_MAC_ETHERNET_ADDR register will be set to some nonzero 2867 * The R_MAC_ETHERNET_ADDR register will be set to some nonzero
2863 * value for us by the firmware if we're going to use this MAC. 2868 * value for us by the firmware if we're going to use this MAC.
2864 * If we find a zero, skip this MAC. 2869 * If we find a zero, skip this MAC.
2865 */ 2870 */
2866 2871
2867 sbmac_orig_hwaddr[idx] = SBMAC_READCSR(IOADDR(port+R_MAC_ETHERNET_ADDR)); 2872 sbmac_orig_hwaddr[idx] = __raw_readq(IOADDR(port+R_MAC_ETHERNET_ADDR));
2868 if (sbmac_orig_hwaddr[idx] == 0) { 2873 if (sbmac_orig_hwaddr[idx] == 0) {
2869 printk(KERN_DEBUG "sbmac: not configuring MAC at " 2874 printk(KERN_DEBUG "sbmac: not configuring MAC at "
2870 "%lx\n", port); 2875 "%lx\n", port);
@@ -2876,7 +2881,7 @@ sbmac_init_module(void)
2876 */ 2881 */
2877 2882
2878 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2883 dev = alloc_etherdev(sizeof(struct sbmac_softc));
2879 if (!dev) 2884 if (!dev)
2880 return -ENOMEM; /* return ENOMEM */ 2885 return -ENOMEM; /* return ENOMEM */
2881 2886
2882 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port); 2887 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port);
@@ -2886,8 +2891,7 @@ sbmac_init_module(void)
2886 dev->mem_end = 0; 2891 dev->mem_end = 0;
2887 if (sbmac_init(dev, idx)) { 2892 if (sbmac_init(dev, idx)) {
2888 port = A_MAC_CHANNEL_BASE(idx); 2893 port = A_MAC_CHANNEL_BASE(idx);
2889 SBMAC_WRITECSR(IOADDR(port+R_MAC_ETHERNET_ADDR), 2894 __raw_writeq(sbmac_orig_hwaddr[idx], IOADDR(port+R_MAC_ETHERNET_ADDR));
2890 sbmac_orig_hwaddr[idx]);
2891 free_netdev(dev); 2895 free_netdev(dev);
2892 continue; 2896 continue;
2893 } 2897 }
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 9bc3b1c0dd6a..a4614df38a90 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -32,8 +32,6 @@
32 32
33#include "sgiseeq.h" 33#include "sgiseeq.h"
34 34
35static char *version = "sgiseeq.c: David S. Miller (dm@engr.sgi.com)\n";
36
37static char *sgiseeqstr = "SGI Seeq8003"; 35static char *sgiseeqstr = "SGI Seeq8003";
38 36
39/* 37/*
@@ -113,9 +111,9 @@ static struct net_device *root_sgiseeq_dev;
113 111
114static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) 112static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs)
115{ 113{
116 hregs->rx_reset = HPC3_ERXRST_CRESET | HPC3_ERXRST_CLRIRQ; 114 hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ;
117 udelay(20); 115 udelay(20);
118 hregs->rx_reset = 0; 116 hregs->reset = 0;
119} 117}
120 118
121static inline void reset_hpc3_and_seeq(struct hpc3_ethregs *hregs, 119static inline void reset_hpc3_and_seeq(struct hpc3_ethregs *hregs,
@@ -252,7 +250,6 @@ void sgiseeq_dump_rings(void)
252 250
253#define TSTAT_INIT_SEEQ (SEEQ_TCMD_IPT|SEEQ_TCMD_I16|SEEQ_TCMD_IC|SEEQ_TCMD_IUF) 251#define TSTAT_INIT_SEEQ (SEEQ_TCMD_IPT|SEEQ_TCMD_I16|SEEQ_TCMD_IC|SEEQ_TCMD_IUF)
254#define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2) 252#define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2)
255#define RDMACFG_INIT (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ)
256 253
257static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp, 254static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
258 struct sgiseeq_regs *sregs) 255 struct sgiseeq_regs *sregs)
@@ -274,8 +271,6 @@ static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
274 sregs->tstat = TSTAT_INIT_SEEQ; 271 sregs->tstat = TSTAT_INIT_SEEQ;
275 } 272 }
276 273
277 hregs->rx_dconfig |= RDMACFG_INIT;
278
279 hregs->rx_ndptr = CPHYSADDR(sp->rx_desc); 274 hregs->rx_ndptr = CPHYSADDR(sp->rx_desc);
280 hregs->tx_ndptr = CPHYSADDR(sp->tx_desc); 275 hregs->tx_ndptr = CPHYSADDR(sp->tx_desc);
281 276
@@ -446,7 +441,7 @@ static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs
446 spin_lock(&sp->tx_lock); 441 spin_lock(&sp->tx_lock);
447 442
448 /* Ack the IRQ and set software state. */ 443 /* Ack the IRQ and set software state. */
449 hregs->rx_reset = HPC3_ERXRST_CLRIRQ; 444 hregs->reset = HPC3_ERST_CLRIRQ;
450 445
451 /* Always check for received packets. */ 446 /* Always check for received packets. */
452 sgiseeq_rx(dev, sp, hregs, sregs); 447 sgiseeq_rx(dev, sp, hregs, sregs);
@@ -493,11 +488,13 @@ static int sgiseeq_close(struct net_device *dev)
493{ 488{
494 struct sgiseeq_private *sp = netdev_priv(dev); 489 struct sgiseeq_private *sp = netdev_priv(dev);
495 struct sgiseeq_regs *sregs = sp->sregs; 490 struct sgiseeq_regs *sregs = sp->sregs;
491 unsigned int irq = dev->irq;
496 492
497 netif_stop_queue(dev); 493 netif_stop_queue(dev);
498 494
499 /* Shutdown the Seeq. */ 495 /* Shutdown the Seeq. */
500 reset_hpc3_and_seeq(sp->hregs, sregs); 496 reset_hpc3_and_seeq(sp->hregs, sregs);
497 free_irq(irq, dev);
501 498
502 return 0; 499 return 0;
503} 500}
@@ -644,7 +641,7 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs)
644 641
645#define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) 642#define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf))
646 643
647static int sgiseeq_init(struct hpc3_regs* regs, int irq) 644static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
648{ 645{
649 struct sgiseeq_init_block *sr; 646 struct sgiseeq_init_block *sr;
650 struct sgiseeq_private *sp; 647 struct sgiseeq_private *sp;
@@ -680,8 +677,8 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
680 gpriv = sp; 677 gpriv = sp;
681 gdev = dev; 678 gdev = dev;
682#endif 679#endif
683 sp->sregs = (struct sgiseeq_regs *) &hpc3c0->eth_ext[0]; 680 sp->sregs = (struct sgiseeq_regs *) &hpcregs->eth_ext[0];
684 sp->hregs = &hpc3c0->ethregs; 681 sp->hregs = &hpcregs->ethregs;
685 sp->name = sgiseeqstr; 682 sp->name = sgiseeqstr;
686 sp->mode = SEEQ_RCMD_RBCAST; 683 sp->mode = SEEQ_RCMD_RBCAST;
687 684
@@ -698,6 +695,11 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
698 setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS); 695 setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS);
699 setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS); 696 setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS);
700 697
698 /* Setup PIO and DMA transfer timing */
699 sp->hregs->pconfig = 0x161;
700 sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
701 HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026;
702
701 /* Reset the chip. */ 703 /* Reset the chip. */
702 hpc3_eth_reset(sp->hregs); 704 hpc3_eth_reset(sp->hregs);
703 705
@@ -724,7 +726,7 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
724 goto err_out_free_page; 726 goto err_out_free_page;
725 } 727 }
726 728
727 printk(KERN_INFO "%s: SGI Seeq8003 ", dev->name); 729 printk(KERN_INFO "%s: %s ", dev->name, sgiseeqstr);
728 for (i = 0; i < 6; i++) 730 for (i = 0; i < 6; i++)
729 printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); 731 printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':');
730 732
@@ -734,7 +736,7 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
734 return 0; 736 return 0;
735 737
736err_out_free_page: 738err_out_free_page:
737 free_page((unsigned long) sp); 739 free_page((unsigned long) sp->srings);
738err_out_free_dev: 740err_out_free_dev:
739 kfree(dev); 741 kfree(dev);
740 742
@@ -744,8 +746,6 @@ err_out:
744 746
745static int __init sgiseeq_probe(void) 747static int __init sgiseeq_probe(void)
746{ 748{
747 printk(version);
748
749 /* On board adapter on 1st HPC is always present */ 749 /* On board adapter on 1st HPC is always present */
750 return sgiseeq_init(hpc3c0, SGI_ENET_IRQ); 750 return sgiseeq_init(hpc3c0, SGI_ENET_IRQ);
751} 751}
@@ -754,15 +754,12 @@ static void __exit sgiseeq_exit(void)
754{ 754{
755 struct net_device *next, *dev; 755 struct net_device *next, *dev;
756 struct sgiseeq_private *sp; 756 struct sgiseeq_private *sp;
757 int irq;
758 757
759 for (dev = root_sgiseeq_dev; dev; dev = next) { 758 for (dev = root_sgiseeq_dev; dev; dev = next) {
760 sp = (struct sgiseeq_private *) netdev_priv(dev); 759 sp = (struct sgiseeq_private *) netdev_priv(dev);
761 next = sp->next_module; 760 next = sp->next_module;
762 irq = dev->irq;
763 unregister_netdev(dev); 761 unregister_netdev(dev);
764 free_irq(irq, dev); 762 free_page((unsigned long) sp->srings);
765 free_page((unsigned long) sp);
766 free_netdev(dev); 763 free_netdev(dev);
767 } 764 }
768} 765}
@@ -770,4 +767,6 @@ static void __exit sgiseeq_exit(void)
770module_init(sgiseeq_probe); 767module_init(sgiseeq_probe);
771module_exit(sgiseeq_exit); 768module_exit(sgiseeq_exit);
772 769
770MODULE_DESCRIPTION("SGI Seeq 8003 driver");
771MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>");
773MODULE_LICENSE("GPL"); 772MODULE_LICENSE("GPL");
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index c2e6484ef138..572f121b1f4e 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -730,6 +730,7 @@ static struct ethtool_ops skge_ethtool_ops = {
730 .phys_id = skge_phys_id, 730 .phys_id = skge_phys_id,
731 .get_stats_count = skge_get_stats_count, 731 .get_stats_count = skge_get_stats_count,
732 .get_ethtool_stats = skge_get_ethtool_stats, 732 .get_ethtool_stats = skge_get_ethtool_stats,
733 .get_perm_addr = ethtool_op_get_perm_addr,
733}; 734};
734 735
735/* 736/*
@@ -3096,6 +3097,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3096 3097
3097 /* read the mac address */ 3098 /* read the mac address */
3098 memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN); 3099 memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN);
3100 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
3099 3101
3100 /* device is off until link detection */ 3102 /* device is off until link detection */
3101 netif_carrier_off(dev); 3103 netif_carrier_off(dev);
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 1438fdd20826..0ddaa611cc61 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -2291,11 +2291,11 @@ static int smc_drv_remove(struct device *dev)
2291 return 0; 2291 return 0;
2292} 2292}
2293 2293
2294static int smc_drv_suspend(struct device *dev, pm_message_t state, u32 level) 2294static int smc_drv_suspend(struct device *dev, pm_message_t state)
2295{ 2295{
2296 struct net_device *ndev = dev_get_drvdata(dev); 2296 struct net_device *ndev = dev_get_drvdata(dev);
2297 2297
2298 if (ndev && level == SUSPEND_DISABLE) { 2298 if (ndev) {
2299 if (netif_running(ndev)) { 2299 if (netif_running(ndev)) {
2300 netif_device_detach(ndev); 2300 netif_device_detach(ndev);
2301 smc_shutdown(ndev); 2301 smc_shutdown(ndev);
@@ -2305,12 +2305,12 @@ static int smc_drv_suspend(struct device *dev, pm_message_t state, u32 level)
2305 return 0; 2305 return 0;
2306} 2306}
2307 2307
2308static int smc_drv_resume(struct device *dev, u32 level) 2308static int smc_drv_resume(struct device *dev)
2309{ 2309{
2310 struct platform_device *pdev = to_platform_device(dev); 2310 struct platform_device *pdev = to_platform_device(dev);
2311 struct net_device *ndev = dev_get_drvdata(dev); 2311 struct net_device *ndev = dev_get_drvdata(dev);
2312 2312
2313 if (ndev && level == RESUME_ENABLE) { 2313 if (ndev) {
2314 struct smc_local *lp = netdev_priv(ndev); 2314 struct smc_local *lp = netdev_priv(ndev);
2315 smc_enable_device(pdev); 2315 smc_enable_device(pdev);
2316 if (netif_running(ndev)) { 2316 if (netif_running(ndev)) {
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index f88f5e32b714..cfaf47c63c58 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -214,7 +214,8 @@ static void bigmac_init_rings(struct bigmac *bp, int from_irq)
214{ 214{
215 struct bmac_init_block *bb = bp->bmac_block; 215 struct bmac_init_block *bb = bp->bmac_block;
216 struct net_device *dev = bp->dev; 216 struct net_device *dev = bp->dev;
217 int i, gfp_flags = GFP_KERNEL; 217 int i;
218 gfp_t gfp_flags = GFP_KERNEL;
218 219
219 if (from_irq || in_interrupt()) 220 if (from_irq || in_interrupt())
220 gfp_flags = GFP_ATOMIC; 221 gfp_flags = GFP_ATOMIC;
diff --git a/drivers/net/sunbmac.h b/drivers/net/sunbmac.h
index 5674003fc38a..b0dbc5187143 100644
--- a/drivers/net/sunbmac.h
+++ b/drivers/net/sunbmac.h
@@ -339,7 +339,7 @@ struct bigmac {
339#define ALIGNED_RX_SKB_ADDR(addr) \ 339#define ALIGNED_RX_SKB_ADDR(addr) \
340 ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr)) 340 ((((unsigned long)(addr) + (64 - 1)) & ~(64 - 1)) - (unsigned long)(addr))
341 341
342static inline struct sk_buff *big_mac_alloc_skb(unsigned int length, int gfp_flags) 342static inline struct sk_buff *big_mac_alloc_skb(unsigned int length, gfp_t gfp_flags)
343{ 343{
344 struct sk_buff *skb; 344 struct sk_buff *skb;
345 345
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index d500a5771dbc..5de0554fd7c6 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -518,6 +518,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
518#else 518#else
519 int bar = 1; 519 int bar = 1;
520#endif 520#endif
521 int phy, phy_idx = 0;
521 522
522 523
523/* when built into the kernel, we only print version if device is found */ 524/* when built into the kernel, we only print version if device is found */
@@ -549,6 +550,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
549 for (i = 0; i < 3; i++) 550 for (i = 0; i < 3; i++)
550 ((u16 *)dev->dev_addr)[i] = 551 ((u16 *)dev->dev_addr)[i] =
551 le16_to_cpu(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET)); 552 le16_to_cpu(eeprom_read(ioaddr, i + EEPROM_SA_OFFSET));
553 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
552 554
553 dev->base_addr = (unsigned long)ioaddr; 555 dev->base_addr = (unsigned long)ioaddr;
554 dev->irq = irq; 556 dev->irq = irq;
@@ -605,33 +607,31 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
605 printk("%2.2x:", dev->dev_addr[i]); 607 printk("%2.2x:", dev->dev_addr[i]);
606 printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq); 608 printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
607 609
608 if (1) { 610 np->phys[0] = 1; /* Default setting */
609 int phy, phy_idx = 0; 611 np->mii_preamble_required++;
610 np->phys[0] = 1; /* Default setting */ 612 for (phy = 1; phy <= 32 && phy_idx < MII_CNT; phy++) {
611 np->mii_preamble_required++; 613 int mii_status = mdio_read(dev, phy, MII_BMSR);
612 for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) { 614 int phyx = phy & 0x1f;
613 int mii_status = mdio_read(dev, phy, MII_BMSR); 615 if (mii_status != 0xffff && mii_status != 0x0000) {
614 if (mii_status != 0xffff && mii_status != 0x0000) { 616 np->phys[phy_idx++] = phyx;
615 np->phys[phy_idx++] = phy; 617 np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE);
616 np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); 618 if ((mii_status & 0x0040) == 0)
617 if ((mii_status & 0x0040) == 0) 619 np->mii_preamble_required++;
618 np->mii_preamble_required++; 620 printk(KERN_INFO "%s: MII PHY found at address %d, status "
619 printk(KERN_INFO "%s: MII PHY found at address %d, status " 621 "0x%4.4x advertising %4.4x.\n",
620 "0x%4.4x advertising %4.4x.\n", 622 dev->name, phyx, mii_status, np->mii_if.advertising);
621 dev->name, phy, mii_status, np->mii_if.advertising);
622 }
623 }
624 np->mii_preamble_required--;
625
626 if (phy_idx == 0) {
627 printk(KERN_INFO "%s: No MII transceiver found, aborting. ASIC status %x\n",
628 dev->name, ioread32(ioaddr + ASICCtrl));
629 goto err_out_unregister;
630 } 623 }
624 }
625 np->mii_preamble_required--;
631 626
632 np->mii_if.phy_id = np->phys[0]; 627 if (phy_idx == 0) {
628 printk(KERN_INFO "%s: No MII transceiver found, aborting. ASIC status %x\n",
629 dev->name, ioread32(ioaddr + ASICCtrl));
630 goto err_out_unregister;
633 } 631 }
634 632
633 np->mii_if.phy_id = np->phys[0];
634
635 /* Parse override configuration */ 635 /* Parse override configuration */
636 np->an_enable = 1; 636 np->an_enable = 1;
637 if (card_idx < MAX_UNITS) { 637 if (card_idx < MAX_UNITS) {
@@ -692,7 +692,7 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
692 /* Reset the chip to erase previous misconfiguration. */ 692 /* Reset the chip to erase previous misconfiguration. */
693 if (netif_msg_hw(np)) 693 if (netif_msg_hw(np))
694 printk("ASIC Control is %x.\n", ioread32(ioaddr + ASICCtrl)); 694 printk("ASIC Control is %x.\n", ioread32(ioaddr + ASICCtrl));
695 iowrite16(0x007f, ioaddr + ASICCtrl + 2); 695 iowrite16(0x00ff, ioaddr + ASICCtrl + 2);
696 if (netif_msg_hw(np)) 696 if (netif_msg_hw(np))
697 printk("ASIC Control is now %x.\n", ioread32(ioaddr + ASICCtrl)); 697 printk("ASIC Control is now %x.\n", ioread32(ioaddr + ASICCtrl));
698 698
@@ -1619,6 +1619,7 @@ static struct ethtool_ops ethtool_ops = {
1619 .get_link = get_link, 1619 .get_link = get_link,
1620 .get_msglevel = get_msglevel, 1620 .get_msglevel = get_msglevel,
1621 .set_msglevel = set_msglevel, 1621 .set_msglevel = set_msglevel,
1622 .get_perm_addr = ethtool_op_get_perm_addr,
1622}; 1623};
1623 1624
1624static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1625static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 32057e65808b..9f491563944e 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -318,7 +318,7 @@ static void ibmtr_cleanup_card(struct net_device *dev)
318 if (dev->base_addr) { 318 if (dev->base_addr) {
319 outb(0,dev->base_addr+ADAPTRESET); 319 outb(0,dev->base_addr+ADAPTRESET);
320 320
321 schedule_timeout(TR_RST_TIME); /* wait 50ms */ 321 schedule_timeout_uninterruptible(TR_RST_TIME); /* wait 50ms */
322 322
323 outb(0,dev->base_addr+ADAPTRESETREL); 323 outb(0,dev->base_addr+ADAPTRESETREL);
324 } 324 }
@@ -854,8 +854,7 @@ static int tok_init_card(struct net_device *dev)
854 writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN); 854 writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN);
855 outb(0, PIOaddr + ADAPTRESET); 855 outb(0, PIOaddr + ADAPTRESET);
856 856
857 current->state=TASK_UNINTERRUPTIBLE; 857 schedule_timeout_uninterruptible(TR_RST_TIME); /* wait 50ms */
858 schedule_timeout(TR_RST_TIME); /* wait 50ms */
859 858
860 outb(0, PIOaddr + ADAPTRESETREL); 859 outb(0, PIOaddr + ADAPTRESETREL);
861#ifdef ENABLE_PAGING 860#ifdef ENABLE_PAGING
@@ -903,8 +902,8 @@ static int tok_open(struct net_device *dev)
903 DPRINTK("Adapter is up and running\n"); 902 DPRINTK("Adapter is up and running\n");
904 return 0; 903 return 0;
905 } 904 }
906 current->state=TASK_INTERRUPTIBLE; 905 i=schedule_timeout_interruptible(TR_RETRY_INTERVAL);
907 i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */ 906 /* wait 30 seconds */
908 if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */ 907 if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */
909 } 908 }
910 outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/ 909 outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 9e7923192a49..05477d24fd49 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -1101,7 +1101,7 @@ static int olympic_close(struct net_device *dev)
1101 1101
1102 while(olympic_priv->srb_queued) { 1102 while(olympic_priv->srb_queued) {
1103 1103
1104 t = schedule_timeout(60*HZ); 1104 t = schedule_timeout_interruptible(60*HZ);
1105 1105
1106 if(signal_pending(current)) { 1106 if(signal_pending(current)) {
1107 printk(KERN_WARNING "%s: SRB timed out.\n",dev->name); 1107 printk(KERN_WARNING "%s: SRB timed out.\n",dev->name);
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index 2e39bf1f7462..c1925590a0e1 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -1243,8 +1243,7 @@ void tms380tr_wait(unsigned long time)
1243 1243
1244 tmp = jiffies + time/(1000000/HZ); 1244 tmp = jiffies + time/(1000000/HZ);
1245 do { 1245 do {
1246 current->state = TASK_INTERRUPTIBLE; 1246 tmp = schedule_timeout_interruptible(tmp);
1247 tmp = schedule_timeout(tmp);
1248 } while(time_after(tmp, jiffies)); 1247 } while(time_after(tmp, jiffies));
1249#else 1248#else
1250 udelay(time); 1249 udelay(time);
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index a22d00198e4d..6b8eee8f7bfd 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1787,10 +1787,15 @@ static void __init de21041_get_srom_info (struct de_private *de)
1787 /* DEC now has a specification but early board makers 1787 /* DEC now has a specification but early board makers
1788 just put the address in the first EEPROM locations. */ 1788 just put the address in the first EEPROM locations. */
1789 /* This does memcmp(eedata, eedata+16, 8) */ 1789 /* This does memcmp(eedata, eedata+16, 8) */
1790
1791#ifndef CONFIG_MIPS_COBALT
1792
1790 for (i = 0; i < 8; i ++) 1793 for (i = 0; i < 8; i ++)
1791 if (ee_data[i] != ee_data[16+i]) 1794 if (ee_data[i] != ee_data[16+i])
1792 sa_offset = 20; 1795 sa_offset = 20;
1793 1796
1797#endif
1798
1794 /* store MAC address */ 1799 /* store MAC address */
1795 for (i = 0; i < 6; i ++) 1800 for (i = 0; i < 6; i ++)
1796 de->dev->dev_addr[i] = ee_data[i + sa_offset]; 1801 de->dev->dev_addr[i] = ee_data[i + sa_offset];
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index ecfa6f8805ce..4c76cb794bfb 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -419,10 +419,9 @@ typhoon_reset(void __iomem *ioaddr, int wait_type)
419 TYPHOON_STATUS_WAITING_FOR_HOST) 419 TYPHOON_STATUS_WAITING_FOR_HOST)
420 goto out; 420 goto out;
421 421
422 if(wait_type == WaitSleep) { 422 if(wait_type == WaitSleep)
423 set_current_state(TASK_UNINTERRUPTIBLE); 423 schedule_timeout_uninterruptible(1);
424 schedule_timeout(1); 424 else
425 } else
426 udelay(TYPHOON_UDELAY); 425 udelay(TYPHOON_UDELAY);
427 } 426 }
428 427
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index fc7738ffbfff..241871589283 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -490,6 +490,8 @@ struct rhine_private {
490 u8 tx_thresh, rx_thresh; 490 u8 tx_thresh, rx_thresh;
491 491
492 struct mii_if_info mii_if; 492 struct mii_if_info mii_if;
493 struct work_struct tx_timeout_task;
494 struct work_struct check_media_task;
493 void __iomem *base; 495 void __iomem *base;
494}; 496};
495 497
@@ -497,6 +499,8 @@ static int mdio_read(struct net_device *dev, int phy_id, int location);
497static void mdio_write(struct net_device *dev, int phy_id, int location, int value); 499static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
498static int rhine_open(struct net_device *dev); 500static int rhine_open(struct net_device *dev);
499static void rhine_tx_timeout(struct net_device *dev); 501static void rhine_tx_timeout(struct net_device *dev);
502static void rhine_tx_timeout_task(struct net_device *dev);
503static void rhine_check_media_task(struct net_device *dev);
500static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev); 504static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev);
501static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs); 505static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
502static void rhine_tx(struct net_device *dev); 506static void rhine_tx(struct net_device *dev);
@@ -814,8 +818,9 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
814 818
815 for (i = 0; i < 6; i++) 819 for (i = 0; i < 6; i++)
816 dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i); 820 dev->dev_addr[i] = ioread8(ioaddr + StationAddr + i);
821 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
817 822
818 if (!is_valid_ether_addr(dev->dev_addr)) { 823 if (!is_valid_ether_addr(dev->perm_addr)) {
819 rc = -EIO; 824 rc = -EIO;
820 printk(KERN_ERR "Invalid MAC address\n"); 825 printk(KERN_ERR "Invalid MAC address\n");
821 goto err_out_unmap; 826 goto err_out_unmap;
@@ -850,6 +855,12 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
850 if (rp->quirks & rqRhineI) 855 if (rp->quirks & rqRhineI)
851 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; 856 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM;
852 857
858 INIT_WORK(&rp->tx_timeout_task,
859 (void (*)(void *))rhine_tx_timeout_task, dev);
860
861 INIT_WORK(&rp->check_media_task,
862 (void (*)(void *))rhine_check_media_task, dev);
863
853 /* dev->name not defined before register_netdev()! */ 864 /* dev->name not defined before register_netdev()! */
854 rc = register_netdev(dev); 865 rc = register_netdev(dev);
855 if (rc) 866 if (rc)
@@ -1076,6 +1087,11 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
1076 ioaddr + ChipCmd1); 1087 ioaddr + ChipCmd1);
1077} 1088}
1078 1089
1090static void rhine_check_media_task(struct net_device *dev)
1091{
1092 rhine_check_media(dev, 0);
1093}
1094
1079static void init_registers(struct net_device *dev) 1095static void init_registers(struct net_device *dev)
1080{ 1096{
1081 struct rhine_private *rp = netdev_priv(dev); 1097 struct rhine_private *rp = netdev_priv(dev);
@@ -1129,8 +1145,8 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks)
1129 if (quirks & rqRhineI) { 1145 if (quirks & rqRhineI) {
1130 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR 1146 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR
1131 1147
1132 /* Can be called from ISR. Evil. */ 1148 /* Do not call from ISR! */
1133 mdelay(1); 1149 msleep(1);
1134 1150
1135 /* 0x80 must be set immediately before turning it off */ 1151 /* 0x80 must be set immediately before turning it off */
1136 iowrite8(0x80, ioaddr + MIICmd); 1152 iowrite8(0x80, ioaddr + MIICmd);
@@ -1220,6 +1236,16 @@ static int rhine_open(struct net_device *dev)
1220static void rhine_tx_timeout(struct net_device *dev) 1236static void rhine_tx_timeout(struct net_device *dev)
1221{ 1237{
1222 struct rhine_private *rp = netdev_priv(dev); 1238 struct rhine_private *rp = netdev_priv(dev);
1239
1240 /*
1241 * Move bulk of work outside of interrupt context
1242 */
1243 schedule_work(&rp->tx_timeout_task);
1244}
1245
1246static void rhine_tx_timeout_task(struct net_device *dev)
1247{
1248 struct rhine_private *rp = netdev_priv(dev);
1223 void __iomem *ioaddr = rp->base; 1249 void __iomem *ioaddr = rp->base;
1224 1250
1225 printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status " 1251 printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status "
@@ -1625,7 +1651,7 @@ static void rhine_error(struct net_device *dev, int intr_status)
1625 spin_lock(&rp->lock); 1651 spin_lock(&rp->lock);
1626 1652
1627 if (intr_status & IntrLinkChange) 1653 if (intr_status & IntrLinkChange)
1628 rhine_check_media(dev, 0); 1654 schedule_work(&rp->check_media_task);
1629 if (intr_status & IntrStatsMax) { 1655 if (intr_status & IntrStatsMax) {
1630 rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs); 1656 rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs);
1631 rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed); 1657 rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed);
@@ -1829,6 +1855,7 @@ static struct ethtool_ops netdev_ethtool_ops = {
1829 .set_wol = rhine_set_wol, 1855 .set_wol = rhine_set_wol,
1830 .get_sg = ethtool_op_get_sg, 1856 .get_sg = ethtool_op_get_sg,
1831 .get_tx_csum = ethtool_op_get_tx_csum, 1857 .get_tx_csum = ethtool_op_get_tx_csum,
1858 .get_perm_addr = ethtool_op_get_perm_addr,
1832}; 1859};
1833 1860
1834static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1861static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1872,6 +1899,9 @@ static int rhine_close(struct net_device *dev)
1872 spin_unlock_irq(&rp->lock); 1899 spin_unlock_irq(&rp->lock);
1873 1900
1874 free_irq(rp->pdev->irq, dev); 1901 free_irq(rp->pdev->irq, dev);
1902
1903 flush_scheduled_work();
1904
1875 free_rbufs(dev); 1905 free_rbufs(dev);
1876 free_tbufs(dev); 1906 free_tbufs(dev);
1877 free_ring(dev); 1907 free_ring(dev);
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 7ff814fd65d0..e392ee8b37a1 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -400,7 +400,7 @@ static int __init cosa_init(void)
400 goto out_chrdev; 400 goto out_chrdev;
401 } 401 }
402 for (i=0; i<nr_cards; i++) { 402 for (i=0; i<nr_cards; i++) {
403 class_device_create(cosa_class, MKDEV(cosa_major, i), 403 class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
404 NULL, "cosa%d", i); 404 NULL, "cosa%d", i);
405 err = devfs_mk_cdev(MKDEV(cosa_major, i), 405 err = devfs_mk_cdev(MKDEV(cosa_major, i),
406 S_IFCHR|S_IRUSR|S_IWUSR, 406 S_IFCHR|S_IRUSR|S_IWUSR,
@@ -1617,8 +1617,7 @@ static int get_wait_data(struct cosa_data *cosa)
1617 return r; 1617 return r;
1618 } 1618 }
1619 /* sleep if not ready to read */ 1619 /* sleep if not ready to read */
1620 set_current_state(TASK_INTERRUPTIBLE); 1620 schedule_timeout_interruptible(1);
1621 schedule_timeout(1);
1622 } 1621 }
1623 printk(KERN_INFO "cosa: timeout in get_wait_data (status 0x%x)\n", 1622 printk(KERN_INFO "cosa: timeout in get_wait_data (status 0x%x)\n",
1624 cosa_getstatus(cosa)); 1623 cosa_getstatus(cosa));
@@ -1644,8 +1643,7 @@ static int put_wait_data(struct cosa_data *cosa, int data)
1644 } 1643 }
1645#if 0 1644#if 0
1646 /* sleep if not ready to read */ 1645 /* sleep if not ready to read */
1647 current->state = TASK_INTERRUPTIBLE; 1646 schedule_timeout_interruptible(1);
1648 schedule_timeout(1);
1649#endif 1647#endif
1650 } 1648 }
1651 printk(KERN_INFO "cosa%d: timeout in put_wait_data (status 0x%x)\n", 1649 printk(KERN_INFO "cosa%d: timeout in put_wait_data (status 0x%x)\n",
diff --git a/drivers/net/wan/cycx_drv.c b/drivers/net/wan/cycx_drv.c
index 9e56fc346ba4..e6d005726aad 100644
--- a/drivers/net/wan/cycx_drv.c
+++ b/drivers/net/wan/cycx_drv.c
@@ -109,7 +109,7 @@ static long cycx_2x_irq_options[] = { 7, 3, 5, 9, 10, 11, 12, 15 };
109 * < 0 error. 109 * < 0 error.
110 * Context: process */ 110 * Context: process */
111 111
112int __init cycx_drv_init(void) 112static int __init cycx_drv_init(void)
113{ 113{
114 printk(KERN_INFO "%s v%u.%u %s\n", fullname, MOD_VERSION, MOD_RELEASE, 114 printk(KERN_INFO "%s v%u.%u %s\n", fullname, MOD_VERSION, MOD_RELEASE,
115 copyright); 115 copyright);
@@ -119,7 +119,7 @@ int __init cycx_drv_init(void)
119 119
120/* Module 'remove' entry point. 120/* Module 'remove' entry point.
121 * o release all remaining system resources */ 121 * o release all remaining system resources */
122void cycx_drv_cleanup(void) 122static void cycx_drv_cleanup(void)
123{ 123{
124} 124}
125 125
@@ -184,8 +184,7 @@ int cycx_down(struct cycx_hw *hw)
184} 184}
185 185
186/* Enable interrupt generation. */ 186/* Enable interrupt generation. */
187EXPORT_SYMBOL(cycx_inten); 187static void cycx_inten(struct cycx_hw *hw)
188void cycx_inten(struct cycx_hw *hw)
189{ 188{
190 writeb(0, hw->dpmbase); 189 writeb(0, hw->dpmbase);
191} 190}
diff --git a/drivers/net/wan/cycx_main.c b/drivers/net/wan/cycx_main.c
index 7b48064364dc..430b1f630fb4 100644
--- a/drivers/net/wan/cycx_main.c
+++ b/drivers/net/wan/cycx_main.c
@@ -103,7 +103,7 @@ static struct cycx_device *cycx_card_array; /* adapter data space */
103 * < 0 error. 103 * < 0 error.
104 * Context: process 104 * Context: process
105 */ 105 */
106int __init cycx_init(void) 106static int __init cycx_init(void)
107{ 107{
108 int cnt, err = -ENOMEM; 108 int cnt, err = -ENOMEM;
109 109
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 02d57c0b4243..a631d1c2fa14 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -78,6 +78,7 @@
78 78
79#define CYCLOMX_X25_DEBUG 1 79#define CYCLOMX_X25_DEBUG 1
80 80
81#include <linux/ctype.h> /* isdigit() */
81#include <linux/errno.h> /* return codes */ 82#include <linux/errno.h> /* return codes */
82#include <linux/if_arp.h> /* ARPHRD_HWX25 */ 83#include <linux/if_arp.h> /* ARPHRD_HWX25 */
83#include <linux/kernel.h> /* printk(), and other useful stuff */ 84#include <linux/kernel.h> /* printk(), and other useful stuff */
@@ -418,7 +419,7 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
418 419
419 /* Set channel timeouts (default if not specified) */ 420 /* Set channel timeouts (default if not specified) */
420 chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90; 421 chan->idle_tmout = conf->idle_timeout ? conf->idle_timeout : 90;
421 } else if (is_digit(conf->addr[0])) { /* PVC */ 422 } else if (isdigit(conf->addr[0])) { /* PVC */
422 s16 lcn = dec_to_uint(conf->addr, 0); 423 s16 lcn = dec_to_uint(conf->addr, 0);
423 424
424 if (lcn >= card->u.x.lo_pvc && lcn <= card->u.x.hi_pvc) 425 if (lcn >= card->u.x.lo_pvc && lcn <= card->u.x.hi_pvc)
@@ -1531,7 +1532,7 @@ static unsigned dec_to_uint(u8 *str, int len)
1531 if (!len) 1532 if (!len)
1532 len = strlen(str); 1533 len = strlen(str);
1533 1534
1534 for (; len && is_digit(*str); ++str, --len) 1535 for (; len && isdigit(*str); ++str, --len)
1535 val = (val * 10) + (*str - (unsigned) '0'); 1536 val = (val * 10) + (*str - (unsigned) '0');
1536 1537
1537 return val; 1538 return val;
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 520a77a798e2..2f61a47b4716 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -446,8 +446,8 @@ static inline unsigned int dscc4_tx_quiescent(struct dscc4_dev_priv *dpriv,
446 return readl(dpriv->base_addr + CH0FTDA + dpriv->dev_id*4) == dpriv->ltda; 446 return readl(dpriv->base_addr + CH0FTDA + dpriv->dev_id*4) == dpriv->ltda;
447} 447}
448 448
449int state_check(u32 state, struct dscc4_dev_priv *dpriv, struct net_device *dev, 449static int state_check(u32 state, struct dscc4_dev_priv *dpriv,
450 const char *msg) 450 struct net_device *dev, const char *msg)
451{ 451{
452 int ret = 0; 452 int ret = 0;
453 453
@@ -466,8 +466,9 @@ int state_check(u32 state, struct dscc4_dev_priv *dpriv, struct net_device *dev,
466 return ret; 466 return ret;
467} 467}
468 468
469void dscc4_tx_print(struct net_device *dev, struct dscc4_dev_priv *dpriv, 469static void dscc4_tx_print(struct net_device *dev,
470 char *msg) 470 struct dscc4_dev_priv *dpriv,
471 char *msg)
471{ 472{
472 printk(KERN_DEBUG "%s: tx_current=%02d tx_dirty=%02d (%s)\n", 473 printk(KERN_DEBUG "%s: tx_current=%02d tx_dirty=%02d (%s)\n",
473 dev->name, dpriv->tx_current, dpriv->tx_dirty, msg); 474 dev->name, dpriv->tx_current, dpriv->tx_dirty, msg);
@@ -507,7 +508,8 @@ static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
507 } 508 }
508} 509}
509 510
510inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv, struct net_device *dev) 511static inline int try_get_rx_skb(struct dscc4_dev_priv *dpriv,
512 struct net_device *dev)
511{ 513{
512 unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE; 514 unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE;
513 struct RxFD *rx_fd = dpriv->rx_fd + dirty; 515 struct RxFD *rx_fd = dpriv->rx_fd + dirty;
@@ -542,8 +544,7 @@ static int dscc4_wait_ack_cec(struct dscc4_dev_priv *dpriv,
542 msg, i); 544 msg, i);
543 goto done; 545 goto done;
544 } 546 }
545 set_current_state(TASK_UNINTERRUPTIBLE); 547 schedule_timeout_uninterruptible(10);
546 schedule_timeout(10);
547 rmb(); 548 rmb();
548 } while (++i > 0); 549 } while (++i > 0);
549 printk(KERN_ERR "%s: %s timeout\n", dev->name, msg); 550 printk(KERN_ERR "%s: %s timeout\n", dev->name, msg);
@@ -588,8 +589,7 @@ static inline int dscc4_xpr_ack(struct dscc4_dev_priv *dpriv)
588 (dpriv->iqtx[cur] & Xpr)) 589 (dpriv->iqtx[cur] & Xpr))
589 break; 590 break;
590 smp_rmb(); 591 smp_rmb();
591 set_current_state(TASK_UNINTERRUPTIBLE); 592 schedule_timeout_uninterruptible(10);
592 schedule_timeout(10);
593 } while (++i > 0); 593 } while (++i > 0);
594 594
595 return (i >= 0 ) ? i : -EAGAIN; 595 return (i >= 0 ) ? i : -EAGAIN;
@@ -1035,8 +1035,7 @@ static void dscc4_pci_reset(struct pci_dev *pdev, void __iomem *ioaddr)
1035 /* Flush posted writes */ 1035 /* Flush posted writes */
1036 readl(ioaddr + GSTAR); 1036 readl(ioaddr + GSTAR);
1037 1037
1038 set_current_state(TASK_UNINTERRUPTIBLE); 1038 schedule_timeout_uninterruptible(10);
1039 schedule_timeout(10);
1040 1039
1041 for (i = 0; i < 16; i++) 1040 for (i = 0; i < 16; i++)
1042 pci_write_config_dword(pdev, i << 2, dscc4_pci_config_store[i]); 1041 pci_write_config_dword(pdev, i << 2, dscc4_pci_config_store[i]);
@@ -1894,7 +1893,7 @@ try:
1894 * It failed and locked solid. Thus the introduction of a dummy skb. 1893 * It failed and locked solid. Thus the introduction of a dummy skb.
1895 * Problem is acknowledged in errata sheet DS5. Joy :o/ 1894 * Problem is acknowledged in errata sheet DS5. Joy :o/
1896 */ 1895 */
1897struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv) 1896static struct sk_buff *dscc4_init_dummy_skb(struct dscc4_dev_priv *dpriv)
1898{ 1897{
1899 struct sk_buff *skb; 1898 struct sk_buff *skb;
1900 1899
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 2c83cca34b86..7981a2c7906e 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -74,11 +74,11 @@ MODULE_LICENSE("GPL");
74/* 74/*
75 * Modules parameters and associated varaibles 75 * Modules parameters and associated varaibles
76 */ 76 */
77int fst_txq_low = FST_LOW_WATER_MARK; 77static int fst_txq_low = FST_LOW_WATER_MARK;
78int fst_txq_high = FST_HIGH_WATER_MARK; 78static int fst_txq_high = FST_HIGH_WATER_MARK;
79int fst_max_reads = 7; 79static int fst_max_reads = 7;
80int fst_excluded_cards = 0; 80static int fst_excluded_cards = 0;
81int fst_excluded_list[FST_MAX_CARDS]; 81static int fst_excluded_list[FST_MAX_CARDS];
82 82
83module_param(fst_txq_low, int, 0); 83module_param(fst_txq_low, int, 0);
84module_param(fst_txq_high, int, 0); 84module_param(fst_txq_high, int, 0);
@@ -572,13 +572,13 @@ static void do_bottom_half_rx(struct fst_card_info *card);
572static void fst_process_tx_work_q(unsigned long work_q); 572static void fst_process_tx_work_q(unsigned long work_q);
573static void fst_process_int_work_q(unsigned long work_q); 573static void fst_process_int_work_q(unsigned long work_q);
574 574
575DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q, 0); 575static DECLARE_TASKLET(fst_tx_task, fst_process_tx_work_q, 0);
576DECLARE_TASKLET(fst_int_task, fst_process_int_work_q, 0); 576static DECLARE_TASKLET(fst_int_task, fst_process_int_work_q, 0);
577 577
578struct fst_card_info *fst_card_array[FST_MAX_CARDS]; 578static struct fst_card_info *fst_card_array[FST_MAX_CARDS];
579spinlock_t fst_work_q_lock; 579static spinlock_t fst_work_q_lock;
580u64 fst_work_txq; 580static u64 fst_work_txq;
581u64 fst_work_intq; 581static u64 fst_work_intq;
582 582
583static void 583static void
584fst_q_work_item(u64 * queue, int card_index) 584fst_q_work_item(u64 * queue, int card_index)
@@ -980,8 +980,7 @@ fst_issue_cmd(struct fst_port_info *port, unsigned short cmd)
980 /* Wait for any previous command to complete */ 980 /* Wait for any previous command to complete */
981 while (mbval > NAK) { 981 while (mbval > NAK) {
982 spin_unlock_irqrestore(&card->card_lock, flags); 982 spin_unlock_irqrestore(&card->card_lock, flags);
983 set_current_state(TASK_UNINTERRUPTIBLE); 983 schedule_timeout_uninterruptible(1);
984 schedule_timeout(1);
985 spin_lock_irqsave(&card->card_lock, flags); 984 spin_lock_irqsave(&card->card_lock, flags);
986 985
987 if (++safety > 2000) { 986 if (++safety > 2000) {
@@ -1498,7 +1497,7 @@ do_bottom_half_rx(struct fst_card_info *card)
1498 * The interrupt service routine 1497 * The interrupt service routine
1499 * Dev_id is our fst_card_info pointer 1498 * Dev_id is our fst_card_info pointer
1500 */ 1499 */
1501irqreturn_t 1500static irqreturn_t
1502fst_intr(int irq, void *dev_id, struct pt_regs *regs) 1501fst_intr(int irq, void *dev_id, struct pt_regs *regs)
1503{ 1502{
1504 struct fst_card_info *card; 1503 struct fst_card_info *card;
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index a5d6891c9d4c..e1601d35dced 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -330,7 +330,7 @@ static int pvc_close(struct net_device *dev)
330 330
331 331
332 332
333int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 333static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
334{ 334{
335 pvc_device *pvc = dev_to_pvc(dev); 335 pvc_device *pvc = dev_to_pvc(dev);
336 fr_proto_pvc_info info; 336 fr_proto_pvc_info info;
diff --git a/drivers/net/wan/lmc/lmc_debug.c b/drivers/net/wan/lmc/lmc_debug.c
index 9dccd9546a17..3b94352b0d03 100644
--- a/drivers/net/wan/lmc/lmc_debug.c
+++ b/drivers/net/wan/lmc/lmc_debug.c
@@ -8,10 +8,10 @@
8/* 8/*
9 * Prints out len, max to 80 octets using printk, 20 per line 9 * Prints out len, max to 80 octets using printk, 20 per line
10 */ 10 */
11void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
12{
13#ifdef DEBUG 11#ifdef DEBUG
14#ifdef LMC_PACKET_LOG 12#ifdef LMC_PACKET_LOG
13void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
14{
15 int iNewLine = 1; 15 int iNewLine = 1;
16 char str[80], *pstr; 16 char str[80], *pstr;
17 17
@@ -43,26 +43,24 @@ void lmcConsoleLog(char *type, unsigned char *ucData, int iLen)
43 } 43 }
44 sprintf(pstr, "\n"); 44 sprintf(pstr, "\n");
45 printk(str); 45 printk(str);
46}
46#endif 47#endif
47#endif 48#endif
48}
49 49
50#ifdef DEBUG 50#ifdef DEBUG
51u_int32_t lmcEventLogIndex = 0; 51u_int32_t lmcEventLogIndex = 0;
52u_int32_t lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS]; 52u_int32_t lmcEventLogBuf[LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS];
53#endif
54 53
55void lmcEventLog (u_int32_t EventNum, u_int32_t arg2, u_int32_t arg3) 54void lmcEventLog (u_int32_t EventNum, u_int32_t arg2, u_int32_t arg3)
56{ 55{
57#ifdef DEBUG
58 lmcEventLogBuf[lmcEventLogIndex++] = EventNum; 56 lmcEventLogBuf[lmcEventLogIndex++] = EventNum;
59 lmcEventLogBuf[lmcEventLogIndex++] = arg2; 57 lmcEventLogBuf[lmcEventLogIndex++] = arg2;
60 lmcEventLogBuf[lmcEventLogIndex++] = arg3; 58 lmcEventLogBuf[lmcEventLogIndex++] = arg3;
61 lmcEventLogBuf[lmcEventLogIndex++] = jiffies; 59 lmcEventLogBuf[lmcEventLogIndex++] = jiffies;
62 60
63 lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1; 61 lmcEventLogIndex &= (LMC_EVENTLOGSIZE * LMC_EVENTLOGARGS) - 1;
64#endif
65} 62}
63#endif /* DEBUG */
66 64
67void lmc_trace(struct net_device *dev, char *msg){ 65void lmc_trace(struct net_device *dev, char *msg){
68#ifdef LMC_TRACE 66#ifdef LMC_TRACE
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index f55ce76b00ed..af8b55fdd9d9 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -48,14 +48,6 @@
48 */ 48 */
49 49
50/* 50/*
51 * For lack of a better place, put the SSI cable stuff here.
52 */
53char *lmc_t1_cables[] = {
54 "V.10/RS423", "EIA530A", "reserved", "X.21", "V.35",
55 "EIA449/EIA530/V.36", "V.28/EIA232", "none", NULL
56};
57
58/*
59 * protocol independent method. 51 * protocol independent method.
60 */ 52 */
61static void lmc_set_protocol (lmc_softc_t * const, lmc_ctl_t *); 53static void lmc_set_protocol (lmc_softc_t * const, lmc_ctl_t *);
diff --git a/drivers/net/wan/pc300.h b/drivers/net/wan/pc300.h
index 73401b0f0151..2024b26b99e6 100644
--- a/drivers/net/wan/pc300.h
+++ b/drivers/net/wan/pc300.h
@@ -472,24 +472,8 @@ enum pc300_loopback_cmds {
472 472
473#ifdef __KERNEL__ 473#ifdef __KERNEL__
474/* Function Prototypes */ 474/* Function Prototypes */
475int dma_buf_write(pc300_t *, int, ucchar *, int);
476int dma_buf_read(pc300_t *, int, struct sk_buff *);
477void tx_dma_start(pc300_t *, int); 475void tx_dma_start(pc300_t *, int);
478void rx_dma_start(pc300_t *, int);
479void tx_dma_stop(pc300_t *, int);
480void rx_dma_stop(pc300_t *, int);
481int cpc_queue_xmit(struct sk_buff *, struct net_device *);
482void cpc_net_rx(struct net_device *);
483void cpc_sca_status(pc300_t *, int);
484int cpc_change_mtu(struct net_device *, int);
485int cpc_ioctl(struct net_device *, struct ifreq *, int);
486int ch_config(pc300dev_t *);
487int rx_config(pc300dev_t *);
488int tx_config(pc300dev_t *);
489void cpc_opench(pc300dev_t *);
490void cpc_closech(pc300dev_t *);
491int cpc_open(struct net_device *dev); 476int cpc_open(struct net_device *dev);
492int cpc_close(struct net_device *dev);
493int cpc_set_media(hdlc_device *, int); 477int cpc_set_media(hdlc_device *, int);
494#endif /* __KERNEL__ */ 478#endif /* __KERNEL__ */
495 479
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 3e7753b10717..a3e65d1bc19b 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -291,6 +291,7 @@ static uclong detect_ram(pc300_t *);
291static void plx_init(pc300_t *); 291static void plx_init(pc300_t *);
292static void cpc_trace(struct net_device *, struct sk_buff *, char); 292static void cpc_trace(struct net_device *, struct sk_buff *, char);
293static int cpc_attach(struct net_device *, unsigned short, unsigned short); 293static int cpc_attach(struct net_device *, unsigned short, unsigned short);
294static int cpc_close(struct net_device *dev);
294 295
295#ifdef CONFIG_PC300_MLPPP 296#ifdef CONFIG_PC300_MLPPP
296void cpc_tty_init(pc300dev_t * dev); 297void cpc_tty_init(pc300dev_t * dev);
@@ -437,7 +438,7 @@ static void rx_dma_buf_check(pc300_t * card, int ch)
437 printk("\n"); 438 printk("\n");
438} 439}
439 440
440int dma_get_rx_frame_size(pc300_t * card, int ch) 441static int dma_get_rx_frame_size(pc300_t * card, int ch)
441{ 442{
442 volatile pcsca_bd_t __iomem *ptdescr; 443 volatile pcsca_bd_t __iomem *ptdescr;
443 ucshort first_bd = card->chan[ch].rx_first_bd; 444 ucshort first_bd = card->chan[ch].rx_first_bd;
@@ -462,7 +463,7 @@ int dma_get_rx_frame_size(pc300_t * card, int ch)
462 * dma_buf_write: writes a frame to the Tx DMA buffers 463 * dma_buf_write: writes a frame to the Tx DMA buffers
463 * NOTE: this function writes one frame at a time. 464 * NOTE: this function writes one frame at a time.
464 */ 465 */
465int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len) 466static int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
466{ 467{
467 int i, nchar; 468 int i, nchar;
468 volatile pcsca_bd_t __iomem *ptdescr; 469 volatile pcsca_bd_t __iomem *ptdescr;
@@ -503,7 +504,7 @@ int dma_buf_write(pc300_t * card, int ch, ucchar * ptdata, int len)
503 * dma_buf_read: reads a frame from the Rx DMA buffers 504 * dma_buf_read: reads a frame from the Rx DMA buffers
504 * NOTE: this function reads one frame at a time. 505 * NOTE: this function reads one frame at a time.
505 */ 506 */
506int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb) 507static int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
507{ 508{
508 int nchar; 509 int nchar;
509 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 510 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
@@ -560,7 +561,7 @@ int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
560 return (rcvd); 561 return (rcvd);
561} 562}
562 563
563void tx_dma_stop(pc300_t * card, int ch) 564static void tx_dma_stop(pc300_t * card, int ch)
564{ 565{
565 void __iomem *scabase = card->hw.scabase; 566 void __iomem *scabase = card->hw.scabase;
566 ucchar drr_ena_bit = 1 << (5 + 2 * ch); 567 ucchar drr_ena_bit = 1 << (5 + 2 * ch);
@@ -571,7 +572,7 @@ void tx_dma_stop(pc300_t * card, int ch)
571 cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit); 572 cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
572} 573}
573 574
574void rx_dma_stop(pc300_t * card, int ch) 575static void rx_dma_stop(pc300_t * card, int ch)
575{ 576{
576 void __iomem *scabase = card->hw.scabase; 577 void __iomem *scabase = card->hw.scabase;
577 ucchar drr_ena_bit = 1 << (4 + 2 * ch); 578 ucchar drr_ena_bit = 1 << (4 + 2 * ch);
@@ -582,7 +583,7 @@ void rx_dma_stop(pc300_t * card, int ch)
582 cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit); 583 cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
583} 584}
584 585
585void rx_dma_start(pc300_t * card, int ch) 586static void rx_dma_start(pc300_t * card, int ch)
586{ 587{
587 void __iomem *scabase = card->hw.scabase; 588 void __iomem *scabase = card->hw.scabase;
588 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 589 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
@@ -607,7 +608,7 @@ void rx_dma_start(pc300_t * card, int ch)
607/*************************/ 608/*************************/
608/*** FALC Routines ***/ 609/*** FALC Routines ***/
609/*************************/ 610/*************************/
610void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd) 611static void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd)
611{ 612{
612 void __iomem *falcbase = card->hw.falcbase; 613 void __iomem *falcbase = card->hw.falcbase;
613 unsigned long i = 0; 614 unsigned long i = 0;
@@ -622,7 +623,7 @@ void falc_issue_cmd(pc300_t * card, int ch, ucchar cmd)
622 cpc_writeb(falcbase + F_REG(CMDR, ch), cmd); 623 cpc_writeb(falcbase + F_REG(CMDR, ch), cmd);
623} 624}
624 625
625void falc_intr_enable(pc300_t * card, int ch) 626static void falc_intr_enable(pc300_t * card, int ch)
626{ 627{
627 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 628 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
628 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 629 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -672,7 +673,7 @@ void falc_intr_enable(pc300_t * card, int ch)
672 } 673 }
673} 674}
674 675
675void falc_open_timeslot(pc300_t * card, int ch, int timeslot) 676static void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
676{ 677{
677 void __iomem *falcbase = card->hw.falcbase; 678 void __iomem *falcbase = card->hw.falcbase;
678 ucchar tshf = card->chan[ch].falc.offset; 679 ucchar tshf = card->chan[ch].falc.offset;
@@ -688,7 +689,7 @@ void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
688 (0x80 >> (timeslot & 0x07))); 689 (0x80 >> (timeslot & 0x07)));
689} 690}
690 691
691void falc_close_timeslot(pc300_t * card, int ch, int timeslot) 692static void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
692{ 693{
693 void __iomem *falcbase = card->hw.falcbase; 694 void __iomem *falcbase = card->hw.falcbase;
694 ucchar tshf = card->chan[ch].falc.offset; 695 ucchar tshf = card->chan[ch].falc.offset;
@@ -704,7 +705,7 @@ void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
704 ~(0x80 >> (timeslot & 0x07))); 705 ~(0x80 >> (timeslot & 0x07)));
705} 706}
706 707
707void falc_close_all_timeslots(pc300_t * card, int ch) 708static void falc_close_all_timeslots(pc300_t * card, int ch)
708{ 709{
709 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 710 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
710 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 711 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -726,7 +727,7 @@ void falc_close_all_timeslots(pc300_t * card, int ch)
726 } 727 }
727} 728}
728 729
729void falc_open_all_timeslots(pc300_t * card, int ch) 730static void falc_open_all_timeslots(pc300_t * card, int ch)
730{ 731{
731 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 732 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
732 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 733 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -758,7 +759,7 @@ void falc_open_all_timeslots(pc300_t * card, int ch)
758 } 759 }
759} 760}
760 761
761void falc_init_timeslot(pc300_t * card, int ch) 762static void falc_init_timeslot(pc300_t * card, int ch)
762{ 763{
763 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 764 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
764 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 765 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -776,7 +777,7 @@ void falc_init_timeslot(pc300_t * card, int ch)
776 } 777 }
777} 778}
778 779
779void falc_enable_comm(pc300_t * card, int ch) 780static void falc_enable_comm(pc300_t * card, int ch)
780{ 781{
781 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 782 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
782 falc_t *pfalc = (falc_t *) & chan->falc; 783 falc_t *pfalc = (falc_t *) & chan->falc;
@@ -792,7 +793,7 @@ void falc_enable_comm(pc300_t * card, int ch)
792 ~((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch))); 793 ~((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
793} 794}
794 795
795void falc_disable_comm(pc300_t * card, int ch) 796static void falc_disable_comm(pc300_t * card, int ch)
796{ 797{
797 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 798 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
798 falc_t *pfalc = (falc_t *) & chan->falc; 799 falc_t *pfalc = (falc_t *) & chan->falc;
@@ -806,7 +807,7 @@ void falc_disable_comm(pc300_t * card, int ch)
806 ((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch))); 807 ((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
807} 808}
808 809
809void falc_init_t1(pc300_t * card, int ch) 810static void falc_init_t1(pc300_t * card, int ch)
810{ 811{
811 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 812 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
812 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 813 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -975,7 +976,7 @@ void falc_init_t1(pc300_t * card, int ch)
975 falc_close_all_timeslots(card, ch); 976 falc_close_all_timeslots(card, ch);
976} 977}
977 978
978void falc_init_e1(pc300_t * card, int ch) 979static void falc_init_e1(pc300_t * card, int ch)
979{ 980{
980 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 981 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
981 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 982 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1155,7 +1156,7 @@ void falc_init_e1(pc300_t * card, int ch)
1155 falc_close_all_timeslots(card, ch); 1156 falc_close_all_timeslots(card, ch);
1156} 1157}
1157 1158
1158void falc_init_hdlc(pc300_t * card, int ch) 1159static void falc_init_hdlc(pc300_t * card, int ch)
1159{ 1160{
1160 void __iomem *falcbase = card->hw.falcbase; 1161 void __iomem *falcbase = card->hw.falcbase;
1161 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1162 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
@@ -1181,7 +1182,7 @@ void falc_init_hdlc(pc300_t * card, int ch)
1181 falc_intr_enable(card, ch); 1182 falc_intr_enable(card, ch);
1182} 1183}
1183 1184
1184void te_config(pc300_t * card, int ch) 1185static void te_config(pc300_t * card, int ch)
1185{ 1186{
1186 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1187 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1187 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1188 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1241,7 +1242,7 @@ void te_config(pc300_t * card, int ch)
1241 CPC_UNLOCK(card, flags); 1242 CPC_UNLOCK(card, flags);
1242} 1243}
1243 1244
1244void falc_check_status(pc300_t * card, int ch, unsigned char frs0) 1245static void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
1245{ 1246{
1246 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1247 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1247 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1248 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1397,7 +1398,7 @@ void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
1397 } 1398 }
1398} 1399}
1399 1400
1400void falc_update_stats(pc300_t * card, int ch) 1401static void falc_update_stats(pc300_t * card, int ch)
1401{ 1402{
1402 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1403 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1403 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1404 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1450,7 +1451,7 @@ void falc_update_stats(pc300_t * card, int ch)
1450 * the synchronizer and then sent to the system interface. 1451 * the synchronizer and then sent to the system interface.
1451 *---------------------------------------------------------------------------- 1452 *----------------------------------------------------------------------------
1452 */ 1453 */
1453void falc_remote_loop(pc300_t * card, int ch, int loop_on) 1454static void falc_remote_loop(pc300_t * card, int ch, int loop_on)
1454{ 1455{
1455 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1456 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1456 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1457 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1495,7 +1496,7 @@ void falc_remote_loop(pc300_t * card, int ch, int loop_on)
1495 * coding must be identical. 1496 * coding must be identical.
1496 *---------------------------------------------------------------------------- 1497 *----------------------------------------------------------------------------
1497 */ 1498 */
1498void falc_local_loop(pc300_t * card, int ch, int loop_on) 1499static void falc_local_loop(pc300_t * card, int ch, int loop_on)
1499{ 1500{
1500 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1501 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1501 falc_t *pfalc = (falc_t *) & chan->falc; 1502 falc_t *pfalc = (falc_t *) & chan->falc;
@@ -1522,7 +1523,7 @@ void falc_local_loop(pc300_t * card, int ch, int loop_on)
1522 * looped. They are originated by the FALC-LH transmitter. 1523 * looped. They are originated by the FALC-LH transmitter.
1523 *---------------------------------------------------------------------------- 1524 *----------------------------------------------------------------------------
1524 */ 1525 */
1525void falc_payload_loop(pc300_t * card, int ch, int loop_on) 1526static void falc_payload_loop(pc300_t * card, int ch, int loop_on)
1526{ 1527{
1527 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1528 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1528 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1529 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1576,7 +1577,7 @@ void falc_payload_loop(pc300_t * card, int ch, int loop_on)
1576 * Description: Turns XLU bit off in the proper register 1577 * Description: Turns XLU bit off in the proper register
1577 *---------------------------------------------------------------------------- 1578 *----------------------------------------------------------------------------
1578 */ 1579 */
1579void turn_off_xlu(pc300_t * card, int ch) 1580static void turn_off_xlu(pc300_t * card, int ch)
1580{ 1581{
1581 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1582 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1582 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1583 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1597,7 +1598,7 @@ void turn_off_xlu(pc300_t * card, int ch)
1597 * Description: Turns XLD bit off in the proper register 1598 * Description: Turns XLD bit off in the proper register
1598 *---------------------------------------------------------------------------- 1599 *----------------------------------------------------------------------------
1599 */ 1600 */
1600void turn_off_xld(pc300_t * card, int ch) 1601static void turn_off_xld(pc300_t * card, int ch)
1601{ 1602{
1602 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1603 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1603 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1604 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1619,7 +1620,7 @@ void turn_off_xld(pc300_t * card, int ch)
1619 * to generate a LOOP activation code over a T1/E1 line. 1620 * to generate a LOOP activation code over a T1/E1 line.
1620 *---------------------------------------------------------------------------- 1621 *----------------------------------------------------------------------------
1621 */ 1622 */
1622void falc_generate_loop_up_code(pc300_t * card, int ch) 1623static void falc_generate_loop_up_code(pc300_t * card, int ch)
1623{ 1624{
1624 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1625 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1625 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1626 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1652,7 +1653,7 @@ void falc_generate_loop_up_code(pc300_t * card, int ch)
1652 * to generate a LOOP deactivation code over a T1/E1 line. 1653 * to generate a LOOP deactivation code over a T1/E1 line.
1653 *---------------------------------------------------------------------------- 1654 *----------------------------------------------------------------------------
1654 */ 1655 */
1655void falc_generate_loop_down_code(pc300_t * card, int ch) 1656static void falc_generate_loop_down_code(pc300_t * card, int ch)
1656{ 1657{
1657 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1658 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1658 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1659 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1682,7 +1683,7 @@ void falc_generate_loop_down_code(pc300_t * card, int ch)
1682 * it on the reception side. 1683 * it on the reception side.
1683 *---------------------------------------------------------------------------- 1684 *----------------------------------------------------------------------------
1684 */ 1685 */
1685void falc_pattern_test(pc300_t * card, int ch, unsigned int activate) 1686static void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
1686{ 1687{
1687 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1688 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1688 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 1689 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -1729,7 +1730,7 @@ void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
1729 * Description: This routine returns the bit error counter value 1730 * Description: This routine returns the bit error counter value
1730 *---------------------------------------------------------------------------- 1731 *----------------------------------------------------------------------------
1731 */ 1732 */
1732ucshort falc_pattern_test_error(pc300_t * card, int ch) 1733static ucshort falc_pattern_test_error(pc300_t * card, int ch)
1733{ 1734{
1734 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch]; 1735 pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
1735 falc_t *pfalc = (falc_t *) & chan->falc; 1736 falc_t *pfalc = (falc_t *) & chan->falc;
@@ -1769,7 +1770,7 @@ cpc_trace(struct net_device *dev, struct sk_buff *skb_main, char rx_tx)
1769 netif_rx(skb); 1770 netif_rx(skb);
1770} 1771}
1771 1772
1772void cpc_tx_timeout(struct net_device *dev) 1773static void cpc_tx_timeout(struct net_device *dev)
1773{ 1774{
1774 pc300dev_t *d = (pc300dev_t *) dev->priv; 1775 pc300dev_t *d = (pc300dev_t *) dev->priv;
1775 pc300ch_t *chan = (pc300ch_t *) d->chan; 1776 pc300ch_t *chan = (pc300ch_t *) d->chan;
@@ -1797,7 +1798,7 @@ void cpc_tx_timeout(struct net_device *dev)
1797 netif_wake_queue(dev); 1798 netif_wake_queue(dev);
1798} 1799}
1799 1800
1800int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev) 1801static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
1801{ 1802{
1802 pc300dev_t *d = (pc300dev_t *) dev->priv; 1803 pc300dev_t *d = (pc300dev_t *) dev->priv;
1803 pc300ch_t *chan = (pc300ch_t *) d->chan; 1804 pc300ch_t *chan = (pc300ch_t *) d->chan;
@@ -1880,7 +1881,7 @@ int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
1880 return 0; 1881 return 0;
1881} 1882}
1882 1883
1883void cpc_net_rx(struct net_device *dev) 1884static void cpc_net_rx(struct net_device *dev)
1884{ 1885{
1885 pc300dev_t *d = (pc300dev_t *) dev->priv; 1886 pc300dev_t *d = (pc300dev_t *) dev->priv;
1886 pc300ch_t *chan = (pc300ch_t *) d->chan; 1887 pc300ch_t *chan = (pc300ch_t *) d->chan;
@@ -2403,7 +2404,7 @@ static irqreturn_t cpc_intr(int irq, void *dev_id, struct pt_regs *regs)
2403 return IRQ_HANDLED; 2404 return IRQ_HANDLED;
2404} 2405}
2405 2406
2406void cpc_sca_status(pc300_t * card, int ch) 2407static void cpc_sca_status(pc300_t * card, int ch)
2407{ 2408{
2408 ucchar ilar; 2409 ucchar ilar;
2409 void __iomem *scabase = card->hw.scabase; 2410 void __iomem *scabase = card->hw.scabase;
@@ -2495,7 +2496,7 @@ void cpc_sca_status(pc300_t * card, int ch)
2495 } 2496 }
2496} 2497}
2497 2498
2498void cpc_falc_status(pc300_t * card, int ch) 2499static void cpc_falc_status(pc300_t * card, int ch)
2499{ 2500{
2500 pc300ch_t *chan = &card->chan[ch]; 2501 pc300ch_t *chan = &card->chan[ch];
2501 falc_t *pfalc = (falc_t *) & chan->falc; 2502 falc_t *pfalc = (falc_t *) & chan->falc;
@@ -2523,7 +2524,7 @@ void cpc_falc_status(pc300_t * card, int ch)
2523 CPC_UNLOCK(card, flags); 2524 CPC_UNLOCK(card, flags);
2524} 2525}
2525 2526
2526int cpc_change_mtu(struct net_device *dev, int new_mtu) 2527static int cpc_change_mtu(struct net_device *dev, int new_mtu)
2527{ 2528{
2528 if ((new_mtu < 128) || (new_mtu > PC300_DEF_MTU)) 2529 if ((new_mtu < 128) || (new_mtu > PC300_DEF_MTU))
2529 return -EINVAL; 2530 return -EINVAL;
@@ -2531,7 +2532,7 @@ int cpc_change_mtu(struct net_device *dev, int new_mtu)
2531 return 0; 2532 return 0;
2532} 2533}
2533 2534
2534int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2535static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2535{ 2536{
2536 hdlc_device *hdlc = dev_to_hdlc(dev); 2537 hdlc_device *hdlc = dev_to_hdlc(dev);
2537 pc300dev_t *d = (pc300dev_t *) dev->priv; 2538 pc300dev_t *d = (pc300dev_t *) dev->priv;
@@ -2856,7 +2857,7 @@ static int clock_rate_calc(uclong rate, uclong clock, int *br_io)
2856 } 2857 }
2857} 2858}
2858 2859
2859int ch_config(pc300dev_t * d) 2860static int ch_config(pc300dev_t * d)
2860{ 2861{
2861 pc300ch_t *chan = (pc300ch_t *) d->chan; 2862 pc300ch_t *chan = (pc300ch_t *) d->chan;
2862 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf; 2863 pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
@@ -3004,7 +3005,7 @@ int ch_config(pc300dev_t * d)
3004 return 0; 3005 return 0;
3005} 3006}
3006 3007
3007int rx_config(pc300dev_t * d) 3008static int rx_config(pc300dev_t * d)
3008{ 3009{
3009 pc300ch_t *chan = (pc300ch_t *) d->chan; 3010 pc300ch_t *chan = (pc300ch_t *) d->chan;
3010 pc300_t *card = (pc300_t *) chan->card; 3011 pc300_t *card = (pc300_t *) chan->card;
@@ -3035,7 +3036,7 @@ int rx_config(pc300dev_t * d)
3035 return 0; 3036 return 0;
3036} 3037}
3037 3038
3038int tx_config(pc300dev_t * d) 3039static int tx_config(pc300dev_t * d)
3039{ 3040{
3040 pc300ch_t *chan = (pc300ch_t *) d->chan; 3041 pc300ch_t *chan = (pc300ch_t *) d->chan;
3041 pc300_t *card = (pc300_t *) chan->card; 3042 pc300_t *card = (pc300_t *) chan->card;
@@ -3098,7 +3099,7 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding,
3098 return 0; 3099 return 0;
3099} 3100}
3100 3101
3101void cpc_opench(pc300dev_t * d) 3102static void cpc_opench(pc300dev_t * d)
3102{ 3103{
3103 pc300ch_t *chan = (pc300ch_t *) d->chan; 3104 pc300ch_t *chan = (pc300ch_t *) d->chan;
3104 pc300_t *card = (pc300_t *) chan->card; 3105 pc300_t *card = (pc300_t *) chan->card;
@@ -3116,7 +3117,7 @@ void cpc_opench(pc300dev_t * d)
3116 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); 3117 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
3117} 3118}
3118 3119
3119void cpc_closech(pc300dev_t * d) 3120static void cpc_closech(pc300dev_t * d)
3120{ 3121{
3121 pc300ch_t *chan = (pc300ch_t *) d->chan; 3122 pc300ch_t *chan = (pc300ch_t *) d->chan;
3122 pc300_t *card = (pc300_t *) chan->card; 3123 pc300_t *card = (pc300_t *) chan->card;
@@ -3173,7 +3174,7 @@ int cpc_open(struct net_device *dev)
3173 return 0; 3174 return 0;
3174} 3175}
3175 3176
3176int cpc_close(struct net_device *dev) 3177static int cpc_close(struct net_device *dev)
3177{ 3178{
3178 hdlc_device *hdlc = dev_to_hdlc(dev); 3179 hdlc_device *hdlc = dev_to_hdlc(dev);
3179 pc300dev_t *d = (pc300dev_t *) dev->priv; 3180 pc300dev_t *d = (pc300dev_t *) dev->priv;
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 8454bf6caaa7..52f26b9c69d2 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -112,10 +112,10 @@ typedef struct _st_cpc_tty_area {
112static struct tty_driver serial_drv; 112static struct tty_driver serial_drv;
113 113
114/* local variables */ 114/* local variables */
115st_cpc_tty_area cpc_tty_area[CPC_TTY_NPORTS]; 115static st_cpc_tty_area cpc_tty_area[CPC_TTY_NPORTS];
116 116
117int cpc_tty_cnt=0; /* number of intrfaces configured with MLPPP */ 117static int cpc_tty_cnt = 0; /* number of intrfaces configured with MLPPP */
118int cpc_tty_unreg_flag = 0; 118static int cpc_tty_unreg_flag = 0;
119 119
120/* TTY functions prototype */ 120/* TTY functions prototype */
121static int cpc_tty_open(struct tty_struct *tty, struct file *flip); 121static int cpc_tty_open(struct tty_struct *tty, struct file *flip);
@@ -132,9 +132,9 @@ static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx);
132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char); 132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char);
133static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char); 133static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char);
134 134
135int pc300_tiocmset(struct tty_struct *, struct file *, 135static int pc300_tiocmset(struct tty_struct *, struct file *,
136 unsigned int, unsigned int); 136 unsigned int, unsigned int);
137int pc300_tiocmget(struct tty_struct *, struct file *); 137static int pc300_tiocmget(struct tty_struct *, struct file *);
138 138
139/* functions called by PC300 driver */ 139/* functions called by PC300 driver */
140void cpc_tty_init(pc300dev_t *dev); 140void cpc_tty_init(pc300dev_t *dev);
@@ -538,8 +538,8 @@ static int cpc_tty_chars_in_buffer(struct tty_struct *tty)
538 return(0); 538 return(0);
539} 539}
540 540
541int pc300_tiocmset(struct tty_struct *tty, struct file *file, 541static int pc300_tiocmset(struct tty_struct *tty, struct file *file,
542 unsigned int set, unsigned int clear) 542 unsigned int set, unsigned int clear)
543{ 543{
544 st_cpc_tty_area *cpc_tty; 544 st_cpc_tty_area *cpc_tty;
545 545
@@ -565,7 +565,7 @@ int pc300_tiocmset(struct tty_struct *tty, struct file *file,
565 return 0; 565 return 0;
566} 566}
567 567
568int pc300_tiocmget(struct tty_struct *tty, struct file *file) 568static int pc300_tiocmget(struct tty_struct *tty, struct file *file)
569{ 569{
570 unsigned int result; 570 unsigned int result;
571 unsigned char status; 571 unsigned char status;
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 3ac9a45b20fa..036adc4f8ba7 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -182,7 +182,7 @@ static char sdla_byte(struct net_device *dev, int addr)
182 return(byte); 182 return(byte);
183} 183}
184 184
185void sdla_stop(struct net_device *dev) 185static void sdla_stop(struct net_device *dev)
186{ 186{
187 struct frad_local *flp; 187 struct frad_local *flp;
188 188
@@ -209,7 +209,7 @@ void sdla_stop(struct net_device *dev)
209 } 209 }
210} 210}
211 211
212void sdla_start(struct net_device *dev) 212static void sdla_start(struct net_device *dev)
213{ 213{
214 struct frad_local *flp; 214 struct frad_local *flp;
215 215
@@ -247,7 +247,7 @@ void sdla_start(struct net_device *dev)
247 * 247 *
248 ***************************************************/ 248 ***************************************************/
249 249
250int sdla_z80_poll(struct net_device *dev, int z80_addr, int jiffs, char resp1, char resp2) 250static int sdla_z80_poll(struct net_device *dev, int z80_addr, int jiffs, char resp1, char resp2)
251{ 251{
252 unsigned long start, done, now; 252 unsigned long start, done, now;
253 char resp, *temp; 253 char resp, *temp;
@@ -505,7 +505,7 @@ static int sdla_cmd(struct net_device *dev, int cmd, short dlci, short flags,
505 505
506static int sdla_reconfig(struct net_device *dev); 506static int sdla_reconfig(struct net_device *dev);
507 507
508int sdla_activate(struct net_device *slave, struct net_device *master) 508static int sdla_activate(struct net_device *slave, struct net_device *master)
509{ 509{
510 struct frad_local *flp; 510 struct frad_local *flp;
511 int i; 511 int i;
@@ -527,7 +527,7 @@ int sdla_activate(struct net_device *slave, struct net_device *master)
527 return(0); 527 return(0);
528} 528}
529 529
530int sdla_deactivate(struct net_device *slave, struct net_device *master) 530static int sdla_deactivate(struct net_device *slave, struct net_device *master)
531{ 531{
532 struct frad_local *flp; 532 struct frad_local *flp;
533 int i; 533 int i;
@@ -549,7 +549,7 @@ int sdla_deactivate(struct net_device *slave, struct net_device *master)
549 return(0); 549 return(0);
550} 550}
551 551
552int sdla_assoc(struct net_device *slave, struct net_device *master) 552static int sdla_assoc(struct net_device *slave, struct net_device *master)
553{ 553{
554 struct frad_local *flp; 554 struct frad_local *flp;
555 int i; 555 int i;
@@ -585,7 +585,7 @@ int sdla_assoc(struct net_device *slave, struct net_device *master)
585 return(0); 585 return(0);
586} 586}
587 587
588int sdla_deassoc(struct net_device *slave, struct net_device *master) 588static int sdla_deassoc(struct net_device *slave, struct net_device *master)
589{ 589{
590 struct frad_local *flp; 590 struct frad_local *flp;
591 int i; 591 int i;
@@ -613,7 +613,7 @@ int sdla_deassoc(struct net_device *slave, struct net_device *master)
613 return(0); 613 return(0);
614} 614}
615 615
616int sdla_dlci_conf(struct net_device *slave, struct net_device *master, int get) 616static int sdla_dlci_conf(struct net_device *slave, struct net_device *master, int get)
617{ 617{
618 struct frad_local *flp; 618 struct frad_local *flp;
619 struct dlci_local *dlp; 619 struct dlci_local *dlp;
@@ -1324,7 +1324,7 @@ NOTE: This is rather a useless action right now, as the
1324 return(0); 1324 return(0);
1325} 1325}
1326 1326
1327int sdla_change_mtu(struct net_device *dev, int new_mtu) 1327static int sdla_change_mtu(struct net_device *dev, int new_mtu)
1328{ 1328{
1329 struct frad_local *flp; 1329 struct frad_local *flp;
1330 1330
@@ -1337,7 +1337,7 @@ int sdla_change_mtu(struct net_device *dev, int new_mtu)
1337 return(-EOPNOTSUPP); 1337 return(-EOPNOTSUPP);
1338} 1338}
1339 1339
1340int sdla_set_config(struct net_device *dev, struct ifmap *map) 1340static int sdla_set_config(struct net_device *dev, struct ifmap *map)
1341{ 1341{
1342 struct frad_local *flp; 1342 struct frad_local *flp;
1343 int i; 1343 int i;
diff --git a/drivers/net/wan/sdla_fr.c b/drivers/net/wan/sdla_fr.c
index 0497dbdb8631..7f1ce9d4333e 100644
--- a/drivers/net/wan/sdla_fr.c
+++ b/drivers/net/wan/sdla_fr.c
@@ -822,7 +822,7 @@ static int new_if(struct wan_device* wandev, struct net_device* dev,
822 chan->card = card; 822 chan->card = card;
823 823
824 /* verify media address */ 824 /* verify media address */
825 if (is_digit(conf->addr[0])) { 825 if (isdigit(conf->addr[0])) {
826 826
827 dlci = dec_to_uint(conf->addr, 0); 827 dlci = dec_to_uint(conf->addr, 0);
828 828
@@ -3456,7 +3456,7 @@ static unsigned int dec_to_uint (unsigned char* str, int len)
3456 if (!len) 3456 if (!len)
3457 len = strlen(str); 3457 len = strlen(str);
3458 3458
3459 for (val = 0; len && is_digit(*str); ++str, --len) 3459 for (val = 0; len && isdigit(*str); ++str, --len)
3460 val = (val * 10) + (*str - (unsigned)'0'); 3460 val = (val * 10) + (*str - (unsigned)'0');
3461 3461
3462 return val; 3462 return val;
diff --git a/drivers/net/wan/sdla_x25.c b/drivers/net/wan/sdla_x25.c
index 8a95d61a2f8f..63f846d6f3a6 100644
--- a/drivers/net/wan/sdla_x25.c
+++ b/drivers/net/wan/sdla_x25.c
@@ -957,7 +957,7 @@ static int new_if(struct wan_device* wandev, struct net_device* dev,
957 chan->hold_timeout = (conf->hold_timeout) ? 957 chan->hold_timeout = (conf->hold_timeout) ?
958 conf->hold_timeout : 10; 958 conf->hold_timeout : 10;
959 959
960 }else if (is_digit(conf->addr[0])){ /* PVC */ 960 }else if (isdigit(conf->addr[0])){ /* PVC */
961 int lcn = dec_to_uint(conf->addr, 0); 961 int lcn = dec_to_uint(conf->addr, 0);
962 962
963 if ((lcn >= card->u.x.lo_pvc) && (lcn <= card->u.x.hi_pvc)){ 963 if ((lcn >= card->u.x.lo_pvc) && (lcn <= card->u.x.hi_pvc)){
@@ -3875,7 +3875,7 @@ static unsigned int dec_to_uint (unsigned char* str, int len)
3875 if (!len) 3875 if (!len)
3876 len = strlen(str); 3876 len = strlen(str);
3877 3877
3878 for (val = 0; len && is_digit(*str); ++str, --len) 3878 for (val = 0; len && isdigit(*str); ++str, --len)
3879 val = (val * 10) + (*str - (unsigned)'0'); 3879 val = (val * 10) + (*str - (unsigned)'0');
3880 3880
3881 return val; 3881 return val;
@@ -3896,9 +3896,9 @@ static unsigned int hex_to_uint (unsigned char* str, int len)
3896 for (val = 0; len; ++str, --len) 3896 for (val = 0; len; ++str, --len)
3897 { 3897 {
3898 ch = *str; 3898 ch = *str;
3899 if (is_digit(ch)) 3899 if (isdigit(ch))
3900 val = (val << 4) + (ch - (unsigned)'0'); 3900 val = (val << 4) + (ch - (unsigned)'0');
3901 else if (is_hex_digit(ch)) 3901 else if (isxdigit(ch))
3902 val = (val << 4) + ((ch & 0xDF) - (unsigned)'A' + 10); 3902 val = (val << 4) + ((ch & 0xDF) - (unsigned)'A' + 10);
3903 else break; 3903 else break;
3904 } 3904 }
diff --git a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c
index c8bc6da57a41..7c2cf2e76300 100644
--- a/drivers/net/wan/sdladrv.c
+++ b/drivers/net/wan/sdladrv.c
@@ -642,9 +642,7 @@ int sdla_mapmem (sdlahw_t* hw, unsigned long addr)
642 * Enable interrupt generation. 642 * Enable interrupt generation.
643 */ 643 */
644 644
645EXPORT_SYMBOL(sdla_inten); 645static int sdla_inten (sdlahw_t* hw)
646
647int sdla_inten (sdlahw_t* hw)
648{ 646{
649 unsigned port = hw->port; 647 unsigned port = hw->port;
650 int tmp, i; 648 int tmp, i;
@@ -698,8 +696,7 @@ int sdla_inten (sdlahw_t* hw)
698 * Disable interrupt generation. 696 * Disable interrupt generation.
699 */ 697 */
700 698
701EXPORT_SYMBOL(sdla_intde); 699#if 0
702
703int sdla_intde (sdlahw_t* hw) 700int sdla_intde (sdlahw_t* hw)
704{ 701{
705 unsigned port = hw->port; 702 unsigned port = hw->port;
@@ -748,14 +745,13 @@ int sdla_intde (sdlahw_t* hw)
748 } 745 }
749 return 0; 746 return 0;
750} 747}
748#endif /* 0 */
751 749
752/*============================================================================ 750/*============================================================================
753 * Acknowledge SDLA hardware interrupt. 751 * Acknowledge SDLA hardware interrupt.
754 */ 752 */
755 753
756EXPORT_SYMBOL(sdla_intack); 754static int sdla_intack (sdlahw_t* hw)
757
758int sdla_intack (sdlahw_t* hw)
759{ 755{
760 unsigned port = hw->port; 756 unsigned port = hw->port;
761 int tmp; 757 int tmp;
@@ -827,8 +823,7 @@ void read_S514_int_stat (sdlahw_t* hw, u32* int_status)
827 * Generate an interrupt to adapter's CPU. 823 * Generate an interrupt to adapter's CPU.
828 */ 824 */
829 825
830EXPORT_SYMBOL(sdla_intr); 826#if 0
831
832int sdla_intr (sdlahw_t* hw) 827int sdla_intr (sdlahw_t* hw)
833{ 828{
834 unsigned port = hw->port; 829 unsigned port = hw->port;
@@ -863,6 +858,7 @@ int sdla_intr (sdlahw_t* hw)
863 } 858 }
864 return 0; 859 return 0;
865} 860}
861#endif /* 0 */
866 862
867/*============================================================================ 863/*============================================================================
868 * Execute Adapter Command. 864 * Execute Adapter Command.
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
index a6d3b55013a5..2d1bba06a085 100644
--- a/drivers/net/wan/syncppp.c
+++ b/drivers/net/wan/syncppp.c
@@ -221,7 +221,7 @@ static void sppp_clear_timeout(struct sppp *p)
221 * here. 221 * here.
222 */ 222 */
223 223
224void sppp_input (struct net_device *dev, struct sk_buff *skb) 224static void sppp_input (struct net_device *dev, struct sk_buff *skb)
225{ 225{
226 struct ppp_header *h; 226 struct ppp_header *h;
227 struct sppp *sp = (struct sppp *)sppp_of(dev); 227 struct sppp *sp = (struct sppp *)sppp_of(dev);
@@ -355,8 +355,6 @@ done:
355 return; 355 return;
356} 356}
357 357
358EXPORT_SYMBOL(sppp_input);
359
360/* 358/*
361 * Handle transmit packets. 359 * Handle transmit packets.
362 */ 360 */
@@ -990,7 +988,7 @@ EXPORT_SYMBOL(sppp_reopen);
990 * the mtu is out of range. 988 * the mtu is out of range.
991 */ 989 */
992 990
993int sppp_change_mtu(struct net_device *dev, int new_mtu) 991static int sppp_change_mtu(struct net_device *dev, int new_mtu)
994{ 992{
995 if(new_mtu<128||new_mtu>PPP_MTU||(dev->flags&IFF_UP)) 993 if(new_mtu<128||new_mtu>PPP_MTU||(dev->flags&IFF_UP))
996 return -EINVAL; 994 return -EINVAL;
@@ -998,8 +996,6 @@ int sppp_change_mtu(struct net_device *dev, int new_mtu)
998 return 0; 996 return 0;
999} 997}
1000 998
1001EXPORT_SYMBOL(sppp_change_mtu);
1002
1003/** 999/**
1004 * sppp_do_ioctl - Ioctl handler for ppp/hdlc 1000 * sppp_do_ioctl - Ioctl handler for ppp/hdlc
1005 * @dev: Device subject to ioctl 1001 * @dev: Device subject to ioctl
@@ -1456,7 +1452,7 @@ static int sppp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_t
1456 return 0; 1452 return 0;
1457} 1453}
1458 1454
1459struct packet_type sppp_packet_type = { 1455static struct packet_type sppp_packet_type = {
1460 .type = __constant_htons(ETH_P_WAN_PPP), 1456 .type = __constant_htons(ETH_P_WAN_PPP),
1461 .func = sppp_rcv, 1457 .func = sppp_rcv,
1462}; 1458};
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 06998c2240d9..cb429e783749 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -1046,7 +1046,6 @@ static WifiCtlHdr wifictlhdr8023 = {
1046 } 1046 }
1047}; 1047};
1048 1048
1049#ifdef WIRELESS_EXT
1050// Frequency list (map channels to frequencies) 1049// Frequency list (map channels to frequencies)
1051static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 1050static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442,
1052 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; 1051 2447, 2452, 2457, 2462, 2467, 2472, 2484 };
@@ -1067,7 +1066,6 @@ typedef struct wep_key_t {
1067 1066
1068/* List of Wireless Handlers (new API) */ 1067/* List of Wireless Handlers (new API) */
1069static const struct iw_handler_def airo_handler_def; 1068static const struct iw_handler_def airo_handler_def;
1070#endif /* WIRELESS_EXT */
1071 1069
1072static const char version[] = "airo.c 0.6 (Ben Reed & Javier Achirica)"; 1070static const char version[] = "airo.c 0.6 (Ben Reed & Javier Achirica)";
1073 1071
@@ -1110,10 +1108,8 @@ static irqreturn_t airo_interrupt( int irq, void* dev_id, struct pt_regs
1110static int airo_thread(void *data); 1108static int airo_thread(void *data);
1111static void timer_func( struct net_device *dev ); 1109static void timer_func( struct net_device *dev );
1112static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 1110static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
1113#ifdef WIRELESS_EXT
1114static struct iw_statistics *airo_get_wireless_stats (struct net_device *dev); 1111static struct iw_statistics *airo_get_wireless_stats (struct net_device *dev);
1115static void airo_read_wireless_stats (struct airo_info *local); 1112static void airo_read_wireless_stats (struct airo_info *local);
1116#endif /* WIRELESS_EXT */
1117#ifdef CISCO_EXT 1113#ifdef CISCO_EXT
1118static int readrids(struct net_device *dev, aironet_ioctl *comp); 1114static int readrids(struct net_device *dev, aironet_ioctl *comp);
1119static int writerids(struct net_device *dev, aironet_ioctl *comp); 1115static int writerids(struct net_device *dev, aironet_ioctl *comp);
@@ -1187,12 +1183,10 @@ struct airo_info {
1187 int fid; 1183 int fid;
1188 } xmit, xmit11; 1184 } xmit, xmit11;
1189 struct net_device *wifidev; 1185 struct net_device *wifidev;
1190#ifdef WIRELESS_EXT
1191 struct iw_statistics wstats; // wireless stats 1186 struct iw_statistics wstats; // wireless stats
1192 unsigned long scan_timestamp; /* Time started to scan */ 1187 unsigned long scan_timestamp; /* Time started to scan */
1193 struct iw_spy_data spy_data; 1188 struct iw_spy_data spy_data;
1194 struct iw_public_data wireless_data; 1189 struct iw_public_data wireless_data;
1195#endif /* WIRELESS_EXT */
1196#ifdef MICSUPPORT 1190#ifdef MICSUPPORT
1197 /* MIC stuff */ 1191 /* MIC stuff */
1198 struct crypto_tfm *tfm; 1192 struct crypto_tfm *tfm;
@@ -2527,7 +2521,8 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2527 unsigned long mem_start, mem_len, aux_start, aux_len; 2521 unsigned long mem_start, mem_len, aux_start, aux_len;
2528 int rc = -1; 2522 int rc = -1;
2529 int i; 2523 int i;
2530 unsigned char *busaddroff,*vpackoff; 2524 dma_addr_t busaddroff;
2525 unsigned char *vpackoff;
2531 unsigned char __iomem *pciaddroff; 2526 unsigned char __iomem *pciaddroff;
2532 2527
2533 mem_start = pci_resource_start(pci, 1); 2528 mem_start = pci_resource_start(pci, 1);
@@ -2570,7 +2565,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2570 /* 2565 /*
2571 * Setup descriptor RX, TX, CONFIG 2566 * Setup descriptor RX, TX, CONFIG
2572 */ 2567 */
2573 busaddroff = (unsigned char *)ai->shared_dma; 2568 busaddroff = ai->shared_dma;
2574 pciaddroff = ai->pciaux + AUX_OFFSET; 2569 pciaddroff = ai->pciaux + AUX_OFFSET;
2575 vpackoff = ai->shared; 2570 vpackoff = ai->shared;
2576 2571
@@ -2579,7 +2574,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2579 ai->rxfids[i].pending = 0; 2574 ai->rxfids[i].pending = 0;
2580 ai->rxfids[i].card_ram_off = pciaddroff; 2575 ai->rxfids[i].card_ram_off = pciaddroff;
2581 ai->rxfids[i].virtual_host_addr = vpackoff; 2576 ai->rxfids[i].virtual_host_addr = vpackoff;
2582 ai->rxfids[i].rx_desc.host_addr = (dma_addr_t) busaddroff; 2577 ai->rxfids[i].rx_desc.host_addr = busaddroff;
2583 ai->rxfids[i].rx_desc.valid = 1; 2578 ai->rxfids[i].rx_desc.valid = 1;
2584 ai->rxfids[i].rx_desc.len = PKTSIZE; 2579 ai->rxfids[i].rx_desc.len = PKTSIZE;
2585 ai->rxfids[i].rx_desc.rdy = 0; 2580 ai->rxfids[i].rx_desc.rdy = 0;
@@ -2594,7 +2589,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2594 ai->txfids[i].card_ram_off = pciaddroff; 2589 ai->txfids[i].card_ram_off = pciaddroff;
2595 ai->txfids[i].virtual_host_addr = vpackoff; 2590 ai->txfids[i].virtual_host_addr = vpackoff;
2596 ai->txfids[i].tx_desc.valid = 1; 2591 ai->txfids[i].tx_desc.valid = 1;
2597 ai->txfids[i].tx_desc.host_addr = (dma_addr_t) busaddroff; 2592 ai->txfids[i].tx_desc.host_addr = busaddroff;
2598 memcpy(ai->txfids[i].virtual_host_addr, 2593 memcpy(ai->txfids[i].virtual_host_addr,
2599 &wifictlhdr8023, sizeof(wifictlhdr8023)); 2594 &wifictlhdr8023, sizeof(wifictlhdr8023));
2600 2595
@@ -2607,8 +2602,8 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
2607 /* Rid descriptor setup */ 2602 /* Rid descriptor setup */
2608 ai->config_desc.card_ram_off = pciaddroff; 2603 ai->config_desc.card_ram_off = pciaddroff;
2609 ai->config_desc.virtual_host_addr = vpackoff; 2604 ai->config_desc.virtual_host_addr = vpackoff;
2610 ai->config_desc.rid_desc.host_addr = (dma_addr_t) busaddroff; 2605 ai->config_desc.rid_desc.host_addr = busaddroff;
2611 ai->ridbus = (dma_addr_t)busaddroff; 2606 ai->ridbus = busaddroff;
2612 ai->config_desc.rid_desc.rid = 0; 2607 ai->config_desc.rid_desc.rid = 0;
2613 ai->config_desc.rid_desc.len = RIDSIZE; 2608 ai->config_desc.rid_desc.len = RIDSIZE;
2614 ai->config_desc.rid_desc.valid = 1; 2609 ai->config_desc.rid_desc.valid = 1;
@@ -2647,9 +2642,7 @@ static void wifi_setup(struct net_device *dev)
2647 dev->get_stats = &airo_get_stats; 2642 dev->get_stats = &airo_get_stats;
2648 dev->set_mac_address = &airo_set_mac_address; 2643 dev->set_mac_address = &airo_set_mac_address;
2649 dev->do_ioctl = &airo_ioctl; 2644 dev->do_ioctl = &airo_ioctl;
2650#ifdef WIRELESS_EXT
2651 dev->wireless_handlers = &airo_handler_def; 2645 dev->wireless_handlers = &airo_handler_def;
2652#endif /* WIRELESS_EXT */
2653 dev->change_mtu = &airo_change_mtu; 2646 dev->change_mtu = &airo_change_mtu;
2654 dev->open = &airo_open; 2647 dev->open = &airo_open;
2655 dev->stop = &airo_close; 2648 dev->stop = &airo_close;
@@ -2675,9 +2668,7 @@ static struct net_device *init_wifidev(struct airo_info *ai,
2675 dev->priv = ethdev->priv; 2668 dev->priv = ethdev->priv;
2676 dev->irq = ethdev->irq; 2669 dev->irq = ethdev->irq;
2677 dev->base_addr = ethdev->base_addr; 2670 dev->base_addr = ethdev->base_addr;
2678#ifdef WIRELESS_EXT
2679 dev->wireless_data = ethdev->wireless_data; 2671 dev->wireless_data = ethdev->wireless_data;
2680#endif /* WIRELESS_EXT */
2681 memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len); 2672 memcpy(dev->dev_addr, ethdev->dev_addr, dev->addr_len);
2682 err = register_netdev(dev); 2673 err = register_netdev(dev);
2683 if (err<0) { 2674 if (err<0) {
@@ -2755,11 +2746,9 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2755 dev->set_multicast_list = &airo_set_multicast_list; 2746 dev->set_multicast_list = &airo_set_multicast_list;
2756 dev->set_mac_address = &airo_set_mac_address; 2747 dev->set_mac_address = &airo_set_mac_address;
2757 dev->do_ioctl = &airo_ioctl; 2748 dev->do_ioctl = &airo_ioctl;
2758#ifdef WIRELESS_EXT
2759 dev->wireless_handlers = &airo_handler_def; 2749 dev->wireless_handlers = &airo_handler_def;
2760 ai->wireless_data.spy_data = &ai->spy_data; 2750 ai->wireless_data.spy_data = &ai->spy_data;
2761 dev->wireless_data = &ai->wireless_data; 2751 dev->wireless_data = &ai->wireless_data;
2762#endif /* WIRELESS_EXT */
2763 dev->change_mtu = &airo_change_mtu; 2752 dev->change_mtu = &airo_change_mtu;
2764 dev->open = &airo_open; 2753 dev->open = &airo_open;
2765 dev->stop = &airo_close; 2754 dev->stop = &airo_close;
@@ -5515,12 +5504,13 @@ static int airo_pci_resume(struct pci_dev *pdev)
5515 struct net_device *dev = pci_get_drvdata(pdev); 5504 struct net_device *dev = pci_get_drvdata(pdev);
5516 struct airo_info *ai = dev->priv; 5505 struct airo_info *ai = dev->priv;
5517 Resp rsp; 5506 Resp rsp;
5507 pci_power_t prev_state = pdev->current_state;
5518 5508
5519 pci_set_power_state(pdev, 0); 5509 pci_set_power_state(pdev, PCI_D0);
5520 pci_restore_state(pdev); 5510 pci_restore_state(pdev);
5521 pci_enable_wake(pdev, pci_choose_state(pdev, ai->power), 0); 5511 pci_enable_wake(pdev, PCI_D0, 0);
5522 5512
5523 if (ai->power.event > 1) { 5513 if (prev_state != PCI_D1) {
5524 reset_card(dev, 0); 5514 reset_card(dev, 0);
5525 mpi_init_descriptors(ai); 5515 mpi_init_descriptors(ai);
5526 setup_card(ai, dev->dev_addr, 0); 5516 setup_card(ai, dev->dev_addr, 0);
@@ -5598,7 +5588,6 @@ static void __exit airo_cleanup_module( void )
5598 remove_proc_entry("aironet", proc_root_driver); 5588 remove_proc_entry("aironet", proc_root_driver);
5599} 5589}
5600 5590
5601#ifdef WIRELESS_EXT
5602/* 5591/*
5603 * Initial Wireless Extension code for Aironet driver by : 5592 * Initial Wireless Extension code for Aironet driver by :
5604 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00 5593 * Jean Tourrilhes <jt@hpl.hp.com> - HPL - 17 November 00
@@ -7107,8 +7096,6 @@ static const struct iw_handler_def airo_handler_def =
7107 .get_wireless_stats = airo_get_wireless_stats, 7096 .get_wireless_stats = airo_get_wireless_stats,
7108}; 7097};
7109 7098
7110#endif /* WIRELESS_EXT */
7111
7112/* 7099/*
7113 * This defines the configuration part of the Wireless Extensions 7100 * This defines the configuration part of the Wireless Extensions
7114 * Note : irq and spinlock protection will occur in the subroutines 7101 * Note : irq and spinlock protection will occur in the subroutines
@@ -7187,7 +7174,6 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
7187 return rc; 7174 return rc;
7188} 7175}
7189 7176
7190#ifdef WIRELESS_EXT
7191/* 7177/*
7192 * Get the Wireless stats out of the driver 7178 * Get the Wireless stats out of the driver
7193 * Note : irq and spinlock protection will occur in the subroutines 7179 * Note : irq and spinlock protection will occur in the subroutines
@@ -7260,7 +7246,6 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev)
7260 7246
7261 return &local->wstats; 7247 return &local->wstats;
7262} 7248}
7263#endif /* WIRELESS_EXT */
7264 7249
7265#ifdef CISCO_EXT 7250#ifdef CISCO_EXT
7266/* 7251/*
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
index 9d496703c465..7b321f7cf358 100644
--- a/drivers/net/wireless/airport.c
+++ b/drivers/net/wireless/airport.c
@@ -15,28 +15,11 @@
15#define PFX DRIVER_NAME ": " 15#define PFX DRIVER_NAME ": "
16 16
17#include <linux/config.h> 17#include <linux/config.h>
18
19#include <linux/module.h> 18#include <linux/module.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/ptrace.h> 21#include <linux/delay.h>
23#include <linux/slab.h>
24#include <linux/string.h>
25#include <linux/timer.h>
26#include <linux/ioport.h>
27#include <linux/netdevice.h>
28#include <linux/if_arp.h>
29#include <linux/etherdevice.h>
30#include <linux/wireless.h>
31
32#include <asm/io.h>
33#include <asm/system.h>
34#include <asm/current.h>
35#include <asm/prom.h>
36#include <asm/machdep.h>
37#include <asm/pmac_feature.h> 22#include <asm/pmac_feature.h>
38#include <asm/irq.h>
39#include <asm/uaccess.h>
40 23
41#include "orinoco.h" 24#include "orinoco.h"
42 25
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 587869d86eee..d57011028b72 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -618,12 +618,12 @@ static int atmel_lock_mac(struct atmel_private *priv);
618static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data); 618static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
619static void atmel_command_irq(struct atmel_private *priv); 619static void atmel_command_irq(struct atmel_private *priv);
620static int atmel_validate_channel(struct atmel_private *priv, int channel); 620static int atmel_validate_channel(struct atmel_private *priv, int channel);
621static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header, 621static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
622 u16 frame_len, u8 rssi); 622 u16 frame_len, u8 rssi);
623static void atmel_management_timer(u_long a); 623static void atmel_management_timer(u_long a);
624static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size); 624static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size);
625static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size); 625static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size);
626static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header, 626static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
627 u8 *body, int body_len); 627 u8 *body, int body_len);
628 628
629static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index); 629static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
@@ -827,7 +827,7 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
827static int start_tx (struct sk_buff *skb, struct net_device *dev) 827static int start_tx (struct sk_buff *skb, struct net_device *dev)
828{ 828{
829 struct atmel_private *priv = netdev_priv(dev); 829 struct atmel_private *priv = netdev_priv(dev);
830 struct ieee80211_hdr header; 830 struct ieee80211_hdr_4addr header;
831 unsigned long flags; 831 unsigned long flags;
832 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; 832 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
833 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; 833 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
@@ -902,7 +902,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
902} 902}
903 903
904static void atmel_transmit_management_frame(struct atmel_private *priv, 904static void atmel_transmit_management_frame(struct atmel_private *priv,
905 struct ieee80211_hdr *header, 905 struct ieee80211_hdr_4addr *header,
906 u8 *body, int body_len) 906 u8 *body, int body_len)
907{ 907{
908 u16 buff; 908 u16 buff;
@@ -917,7 +917,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
917 tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT); 917 tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT);
918} 918}
919 919
920static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header, 920static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
921 u16 msdu_size, u16 rx_packet_loc, u32 crc) 921 u16 msdu_size, u16 rx_packet_loc, u32 crc)
922{ 922{
923 /* fast path: unfragmented packet copy directly into skbuf */ 923 /* fast path: unfragmented packet copy directly into skbuf */
@@ -990,7 +990,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
990 return (crc ^ 0xffffffff) == netcrc; 990 return (crc ^ 0xffffffff) == netcrc;
991} 991}
992 992
993static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header, 993static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
994 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags) 994 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags)
995{ 995{
996 u8 mac4[6]; 996 u8 mac4[6];
@@ -1082,7 +1082,7 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr *heade
1082static void rx_done_irq(struct atmel_private *priv) 1082static void rx_done_irq(struct atmel_private *priv)
1083{ 1083{
1084 int i; 1084 int i;
1085 struct ieee80211_hdr header; 1085 struct ieee80211_hdr_4addr header;
1086 1086
1087 for (i = 0; 1087 for (i = 0;
1088 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID && 1088 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
@@ -2650,7 +2650,7 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
2650 2650
2651static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len) 2651static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len)
2652{ 2652{
2653 struct ieee80211_hdr header; 2653 struct ieee80211_hdr_4addr header;
2654 struct auth_body auth; 2654 struct auth_body auth;
2655 2655
2656 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 2656 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
@@ -2688,7 +2688,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2688{ 2688{
2689 u8 *ssid_el_p; 2689 u8 *ssid_el_p;
2690 int bodysize; 2690 int bodysize;
2691 struct ieee80211_hdr header; 2691 struct ieee80211_hdr_4addr header;
2692 struct ass_req_format { 2692 struct ass_req_format {
2693 u16 capability; 2693 u16 capability;
2694 u16 listen_interval; 2694 u16 listen_interval;
@@ -2738,7 +2738,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2738 atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize); 2738 atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize);
2739} 2739}
2740 2740
2741static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr *header) 2741static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr_4addr *header)
2742{ 2742{
2743 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 2743 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
2744 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0; 2744 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
@@ -2788,7 +2788,7 @@ static int retrieve_bss(struct atmel_private *priv)
2788} 2788}
2789 2789
2790 2790
2791static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr *header, 2791static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
2792 u16 capability, u16 beacon_period, u8 channel, u8 rssi, 2792 u16 capability, u16 beacon_period, u8 channel, u8 rssi,
2793 u8 ssid_len, u8 *ssid, int is_beacon) 2793 u8 ssid_len, u8 *ssid, int is_beacon)
2794{ 2794{
@@ -3072,7 +3072,7 @@ static void atmel_smooth_qual(struct atmel_private *priv)
3072} 3072}
3073 3073
3074/* deals with incoming managment frames. */ 3074/* deals with incoming managment frames. */
3075static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header, 3075static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header,
3076 u16 frame_len, u8 rssi) 3076 u16 frame_len, u8 rssi)
3077{ 3077{
3078 u16 subtype; 3078 u16 subtype;
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 21c3d0d227e6..eba0d9d2b7c5 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -39,17 +39,10 @@
39 */ 39 */
40 40
41#include <linux/config.h> 41#include <linux/config.h>
42
43#include <linux/module.h> 42#include <linux/module.h>
44#include <linux/types.h>
45#include <linux/threads.h>
46#include <linux/smp.h>
47#include <asm/io.h>
48#include <linux/delay.h>
49#include <linux/init.h>
50#include <linux/kernel.h> 43#include <linux/kernel.h>
51#include <linux/net.h> 44#include <linux/init.h>
52#include <asm/errno.h> 45#include <linux/delay.h>
53 46
54#include "hermes.h" 47#include "hermes.h"
55 48
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index 8c9e874c9118..ad28e3294360 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -30,9 +30,8 @@
30 * access to the hermes_t structure, and to the hardware 30 * access to the hermes_t structure, and to the hardware
31*/ 31*/
32 32
33#include <linux/delay.h>
34#include <linux/if_ether.h> 33#include <linux/if_ether.h>
35#include <asm/byteorder.h> 34#include <asm/io.h>
36 35
37/* 36/*
38 * Limits and constants 37 * Limits and constants
@@ -192,13 +191,13 @@
192#define HERMES_RXSTAT_WMP (0x6000) /* Wavelan-II Management Protocol frame */ 191#define HERMES_RXSTAT_WMP (0x6000) /* Wavelan-II Management Protocol frame */
193 192
194struct hermes_tx_descriptor { 193struct hermes_tx_descriptor {
195 u16 status; 194 __le16 status;
196 u16 reserved1; 195 __le16 reserved1;
197 u16 reserved2; 196 __le16 reserved2;
198 u32 sw_support; 197 __le32 sw_support;
199 u8 retry_count; 198 u8 retry_count;
200 u8 tx_rate; 199 u8 tx_rate;
201 u16 tx_control; 200 __le16 tx_control;
202} __attribute__ ((packed)); 201} __attribute__ ((packed));
203 202
204#define HERMES_TXSTAT_RETRYERR (0x0001) 203#define HERMES_TXSTAT_RETRYERR (0x0001)
@@ -222,60 +221,60 @@ struct hermes_tx_descriptor {
222#define HERMES_INQ_SEC_STAT_AGERE (0xF202) 221#define HERMES_INQ_SEC_STAT_AGERE (0xF202)
223 222
224struct hermes_tallies_frame { 223struct hermes_tallies_frame {
225 u16 TxUnicastFrames; 224 __le16 TxUnicastFrames;
226 u16 TxMulticastFrames; 225 __le16 TxMulticastFrames;
227 u16 TxFragments; 226 __le16 TxFragments;
228 u16 TxUnicastOctets; 227 __le16 TxUnicastOctets;
229 u16 TxMulticastOctets; 228 __le16 TxMulticastOctets;
230 u16 TxDeferredTransmissions; 229 __le16 TxDeferredTransmissions;
231 u16 TxSingleRetryFrames; 230 __le16 TxSingleRetryFrames;
232 u16 TxMultipleRetryFrames; 231 __le16 TxMultipleRetryFrames;
233 u16 TxRetryLimitExceeded; 232 __le16 TxRetryLimitExceeded;
234 u16 TxDiscards; 233 __le16 TxDiscards;
235 u16 RxUnicastFrames; 234 __le16 RxUnicastFrames;
236 u16 RxMulticastFrames; 235 __le16 RxMulticastFrames;
237 u16 RxFragments; 236 __le16 RxFragments;
238 u16 RxUnicastOctets; 237 __le16 RxUnicastOctets;
239 u16 RxMulticastOctets; 238 __le16 RxMulticastOctets;
240 u16 RxFCSErrors; 239 __le16 RxFCSErrors;
241 u16 RxDiscards_NoBuffer; 240 __le16 RxDiscards_NoBuffer;
242 u16 TxDiscardsWrongSA; 241 __le16 TxDiscardsWrongSA;
243 u16 RxWEPUndecryptable; 242 __le16 RxWEPUndecryptable;
244 u16 RxMsgInMsgFragments; 243 __le16 RxMsgInMsgFragments;
245 u16 RxMsgInBadMsgFragments; 244 __le16 RxMsgInBadMsgFragments;
246 /* Those last are probably not available in very old firmwares */ 245 /* Those last are probably not available in very old firmwares */
247 u16 RxDiscards_WEPICVError; 246 __le16 RxDiscards_WEPICVError;
248 u16 RxDiscards_WEPExcluded; 247 __le16 RxDiscards_WEPExcluded;
249} __attribute__ ((packed)); 248} __attribute__ ((packed));
250 249
251/* Grabbed from wlan-ng - Thanks Mark... - Jean II 250/* Grabbed from wlan-ng - Thanks Mark... - Jean II
252 * This is the result of a scan inquiry command */ 251 * This is the result of a scan inquiry command */
253/* Structure describing info about an Access Point */ 252/* Structure describing info about an Access Point */
254struct prism2_scan_apinfo { 253struct prism2_scan_apinfo {
255 u16 channel; /* Channel where the AP sits */ 254 __le16 channel; /* Channel where the AP sits */
256 u16 noise; /* Noise level */ 255 __le16 noise; /* Noise level */
257 u16 level; /* Signal level */ 256 __le16 level; /* Signal level */
258 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */ 257 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
259 u16 beacon_interv; /* Beacon interval */ 258 __le16 beacon_interv; /* Beacon interval */
260 u16 capabilities; /* Capabilities */ 259 __le16 capabilities; /* Capabilities */
261 u16 essid_len; /* ESSID length */ 260 __le16 essid_len; /* ESSID length */
262 u8 essid[32]; /* ESSID of the network */ 261 u8 essid[32]; /* ESSID of the network */
263 u8 rates[10]; /* Bit rate supported */ 262 u8 rates[10]; /* Bit rate supported */
264 u16 proberesp_rate; /* Data rate of the response frame */ 263 __le16 proberesp_rate; /* Data rate of the response frame */
265 u16 atim; /* ATIM window time, Kus (hostscan only) */ 264 __le16 atim; /* ATIM window time, Kus (hostscan only) */
266} __attribute__ ((packed)); 265} __attribute__ ((packed));
267 266
268/* Same stuff for the Lucent/Agere card. 267/* Same stuff for the Lucent/Agere card.
269 * Thanks to h1kari <h1kari AT dachb0den.com> - Jean II */ 268 * Thanks to h1kari <h1kari AT dachb0den.com> - Jean II */
270struct agere_scan_apinfo { 269struct agere_scan_apinfo {
271 u16 channel; /* Channel where the AP sits */ 270 __le16 channel; /* Channel where the AP sits */
272 u16 noise; /* Noise level */ 271 __le16 noise; /* Noise level */
273 u16 level; /* Signal level */ 272 __le16 level; /* Signal level */
274 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */ 273 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
275 u16 beacon_interv; /* Beacon interval */ 274 __le16 beacon_interv; /* Beacon interval */
276 u16 capabilities; /* Capabilities */ 275 __le16 capabilities; /* Capabilities */
277 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */ 276 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
278 u16 essid_len; /* ESSID length */ 277 __le16 essid_len; /* ESSID length */
279 u8 essid[32]; /* ESSID of the network */ 278 u8 essid[32]; /* ESSID of the network */
280} __attribute__ ((packed)); 279} __attribute__ ((packed));
281 280
@@ -283,16 +282,16 @@ struct agere_scan_apinfo {
283struct symbol_scan_apinfo { 282struct symbol_scan_apinfo {
284 u8 channel; /* Channel where the AP sits */ 283 u8 channel; /* Channel where the AP sits */
285 u8 unknown1; /* 8 in 2.9x and 3.9x f/w, 0 otherwise */ 284 u8 unknown1; /* 8 in 2.9x and 3.9x f/w, 0 otherwise */
286 u16 noise; /* Noise level */ 285 __le16 noise; /* Noise level */
287 u16 level; /* Signal level */ 286 __le16 level; /* Signal level */
288 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */ 287 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
289 u16 beacon_interv; /* Beacon interval */ 288 __le16 beacon_interv; /* Beacon interval */
290 u16 capabilities; /* Capabilities */ 289 __le16 capabilities; /* Capabilities */
291 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */ 290 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
292 u16 essid_len; /* ESSID length */ 291 __le16 essid_len; /* ESSID length */
293 u8 essid[32]; /* ESSID of the network */ 292 u8 essid[32]; /* ESSID of the network */
294 u16 rates[5]; /* Bit rate supported */ 293 __le16 rates[5]; /* Bit rate supported */
295 u16 basic_rates; /* Basic rates bitmask */ 294 __le16 basic_rates; /* Basic rates bitmask */
296 u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */ 295 u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */
297 u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */ 296 u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */
298} __attribute__ ((packed)); 297} __attribute__ ((packed));
@@ -312,7 +311,7 @@ union hermes_scan_info {
312#define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006) 311#define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006)
313 312
314struct hermes_linkstatus { 313struct hermes_linkstatus {
315 u16 linkstatus; /* Link status */ 314 __le16 linkstatus; /* Link status */
316} __attribute__ ((packed)); 315} __attribute__ ((packed));
317 316
318struct hermes_response { 317struct hermes_response {
@@ -321,8 +320,8 @@ struct hermes_response {
321 320
322/* "ID" structure - used for ESSID and station nickname */ 321/* "ID" structure - used for ESSID and station nickname */
323struct hermes_idstring { 322struct hermes_idstring {
324 u16 len; 323 __le16 len;
325 u16 val[16]; 324 __le16 val[16];
326} __attribute__ ((packed)); 325} __attribute__ ((packed));
327 326
328struct hermes_multicast { 327struct hermes_multicast {
@@ -447,7 +446,7 @@ static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count
447 446
448static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) 447static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
449{ 448{
450 u16 rec; 449 __le16 rec;
451 int err; 450 int err;
452 451
453 err = HERMES_READ_RECORD(hw, bap, rid, &rec); 452 err = HERMES_READ_RECORD(hw, bap, rid, &rec);
@@ -457,7 +456,7 @@ static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
457 456
458static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word) 457static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word)
459{ 458{
460 u16 rec = cpu_to_le16(word); 459 __le16 rec = cpu_to_le16(word);
461 return HERMES_WRITE_RECORD(hw, bap, rid, &rec); 460 return HERMES_WRITE_RECORD(hw, bap, rid, &rec);
462} 461}
463 462
diff --git a/drivers/net/wireless/hostap/hostap.c b/drivers/net/wireless/hostap/hostap.c
index e7f5821b4942..6a96cd9f2685 100644
--- a/drivers/net/wireless/hostap/hostap.c
+++ b/drivers/net/wireless/hostap/hostap.c
@@ -716,9 +716,6 @@ static int prism2_close(struct net_device *dev)
716 hostap_deauth_all_stas(dev, local->ap, 1); 716 hostap_deauth_all_stas(dev, local->ap, 1);
717#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 717#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
718 718
719 if (local->func->dev_close && local->func->dev_close(local))
720 return 0;
721
722 if (dev == local->dev) { 719 if (dev == local->dev) {
723 local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL); 720 local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL);
724 } 721 }
@@ -766,9 +763,6 @@ static int prism2_open(struct net_device *dev)
766 local->hw_downloading) 763 local->hw_downloading)
767 return -ENODEV; 764 return -ENODEV;
768 765
769 if (local->func->dev_open && local->func->dev_open(local))
770 return 1;
771
772 if (!try_module_get(local->hw_module)) 766 if (!try_module_get(local->hw_module))
773 return -ENODEV; 767 return -ENODEV;
774 local->num_dev_open++; 768 local->num_dev_open++;
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index b0501243b175..ffac50899454 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -6,10 +6,10 @@
6void hostap_dump_rx_80211(const char *name, struct sk_buff *skb, 6void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,
7 struct hostap_80211_rx_status *rx_stats) 7 struct hostap_80211_rx_status *rx_stats)
8{ 8{
9 struct ieee80211_hdr *hdr; 9 struct ieee80211_hdr_4addr *hdr;
10 u16 fc; 10 u16 fc;
11 11
12 hdr = (struct ieee80211_hdr *) skb->data; 12 hdr = (struct ieee80211_hdr_4addr *) skb->data;
13 13
14 printk(KERN_DEBUG "%s: RX signal=%d noise=%d rate=%d len=%d " 14 printk(KERN_DEBUG "%s: RX signal=%d noise=%d rate=%d len=%d "
15 "jiffies=%ld\n", 15 "jiffies=%ld\n",
@@ -51,7 +51,7 @@ int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
51 int hdrlen, phdrlen, head_need, tail_need; 51 int hdrlen, phdrlen, head_need, tail_need;
52 u16 fc; 52 u16 fc;
53 int prism_header, ret; 53 int prism_header, ret;
54 struct ieee80211_hdr *hdr; 54 struct ieee80211_hdr_4addr *hdr;
55 55
56 iface = netdev_priv(dev); 56 iface = netdev_priv(dev);
57 local = iface->local; 57 local = iface->local;
@@ -70,7 +70,7 @@ int prism2_rx_80211(struct net_device *dev, struct sk_buff *skb,
70 phdrlen = 0; 70 phdrlen = 0;
71 } 71 }
72 72
73 hdr = (struct ieee80211_hdr *) skb->data; 73 hdr = (struct ieee80211_hdr_4addr *) skb->data;
74 fc = le16_to_cpu(hdr->frame_ctl); 74 fc = le16_to_cpu(hdr->frame_ctl);
75 75
76 if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) { 76 if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) {
@@ -215,7 +215,7 @@ prism2_frag_cache_find(local_info_t *local, unsigned int seq,
215 215
216/* Called only as a tasklet (software IRQ) */ 216/* Called only as a tasklet (software IRQ) */
217static struct sk_buff * 217static struct sk_buff *
218prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr) 218prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr_4addr *hdr)
219{ 219{
220 struct sk_buff *skb = NULL; 220 struct sk_buff *skb = NULL;
221 u16 sc; 221 u16 sc;
@@ -229,7 +229,7 @@ prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr)
229 if (frag == 0) { 229 if (frag == 0) {
230 /* Reserve enough space to fit maximum frame length */ 230 /* Reserve enough space to fit maximum frame length */
231 skb = dev_alloc_skb(local->dev->mtu + 231 skb = dev_alloc_skb(local->dev->mtu +
232 sizeof(struct ieee80211_hdr) + 232 sizeof(struct ieee80211_hdr_4addr) +
233 8 /* LLC */ + 233 8 /* LLC */ +
234 2 /* alignment */ + 234 2 /* alignment */ +
235 8 /* WEP */ + ETH_ALEN /* WDS */); 235 8 /* WEP */ + ETH_ALEN /* WDS */);
@@ -267,7 +267,7 @@ prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr)
267 267
268/* Called only as a tasklet (software IRQ) */ 268/* Called only as a tasklet (software IRQ) */
269static int prism2_frag_cache_invalidate(local_info_t *local, 269static int prism2_frag_cache_invalidate(local_info_t *local,
270 struct ieee80211_hdr *hdr) 270 struct ieee80211_hdr_4addr *hdr)
271{ 271{
272 u16 sc; 272 u16 sc;
273 unsigned int seq; 273 unsigned int seq;
@@ -441,7 +441,7 @@ hostap_rx_frame_mgmt(local_info_t *local, struct sk_buff *skb,
441 u16 stype) 441 u16 stype)
442{ 442{
443 if (local->iw_mode == IW_MODE_MASTER) { 443 if (local->iw_mode == IW_MODE_MASTER) {
444 hostap_update_sta_ps(local, (struct ieee80211_hdr *) 444 hostap_update_sta_ps(local, (struct ieee80211_hdr_4addr *)
445 skb->data); 445 skb->data);
446 } 446 }
447 447
@@ -520,7 +520,7 @@ static inline struct net_device *prism2_rx_get_wds(local_info_t *local,
520 520
521 521
522static inline int 522static inline int
523hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr, 523hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
524 u16 fc, struct net_device **wds) 524 u16 fc, struct net_device **wds)
525{ 525{
526 /* FIX: is this really supposed to accept WDS frames only in Master 526 /* FIX: is this really supposed to accept WDS frames only in Master
@@ -579,13 +579,13 @@ static int hostap_is_eapol_frame(local_info_t *local, struct sk_buff *skb)
579{ 579{
580 struct net_device *dev = local->dev; 580 struct net_device *dev = local->dev;
581 u16 fc, ethertype; 581 u16 fc, ethertype;
582 struct ieee80211_hdr *hdr; 582 struct ieee80211_hdr_4addr *hdr;
583 u8 *pos; 583 u8 *pos;
584 584
585 if (skb->len < 24) 585 if (skb->len < 24)
586 return 0; 586 return 0;
587 587
588 hdr = (struct ieee80211_hdr *) skb->data; 588 hdr = (struct ieee80211_hdr_4addr *) skb->data;
589 fc = le16_to_cpu(hdr->frame_ctl); 589 fc = le16_to_cpu(hdr->frame_ctl);
590 590
591 /* check that the frame is unicast frame to us */ 591 /* check that the frame is unicast frame to us */
@@ -619,13 +619,13 @@ static inline int
619hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb, 619hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
620 struct ieee80211_crypt_data *crypt) 620 struct ieee80211_crypt_data *crypt)
621{ 621{
622 struct ieee80211_hdr *hdr; 622 struct ieee80211_hdr_4addr *hdr;
623 int res, hdrlen; 623 int res, hdrlen;
624 624
625 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) 625 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
626 return 0; 626 return 0;
627 627
628 hdr = (struct ieee80211_hdr *) skb->data; 628 hdr = (struct ieee80211_hdr_4addr *) skb->data;
629 hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 629 hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
630 630
631 if (local->tkip_countermeasures && 631 if (local->tkip_countermeasures &&
@@ -658,13 +658,13 @@ static inline int
658hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb, 658hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb,
659 int keyidx, struct ieee80211_crypt_data *crypt) 659 int keyidx, struct ieee80211_crypt_data *crypt)
660{ 660{
661 struct ieee80211_hdr *hdr; 661 struct ieee80211_hdr_4addr *hdr;
662 int res, hdrlen; 662 int res, hdrlen;
663 663
664 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) 664 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
665 return 0; 665 return 0;
666 666
667 hdr = (struct ieee80211_hdr *) skb->data; 667 hdr = (struct ieee80211_hdr_4addr *) skb->data;
668 hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 668 hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
669 669
670 atomic_inc(&crypt->refcnt); 670 atomic_inc(&crypt->refcnt);
@@ -689,7 +689,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
689{ 689{
690 struct hostap_interface *iface; 690 struct hostap_interface *iface;
691 local_info_t *local; 691 local_info_t *local;
692 struct ieee80211_hdr *hdr; 692 struct ieee80211_hdr_4addr *hdr;
693 size_t hdrlen; 693 size_t hdrlen;
694 u16 fc, type, stype, sc; 694 u16 fc, type, stype, sc;
695 struct net_device *wds = NULL; 695 struct net_device *wds = NULL;
@@ -716,7 +716,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
716 dev = local->ddev; 716 dev = local->ddev;
717 iface = netdev_priv(dev); 717 iface = netdev_priv(dev);
718 718
719 hdr = (struct ieee80211_hdr *) skb->data; 719 hdr = (struct ieee80211_hdr_4addr *) skb->data;
720 stats = hostap_get_stats(dev); 720 stats = hostap_get_stats(dev);
721 721
722 if (skb->len < 10) 722 if (skb->len < 10)
@@ -737,7 +737,8 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
737 struct iw_quality wstats; 737 struct iw_quality wstats;
738 wstats.level = rx_stats->signal; 738 wstats.level = rx_stats->signal;
739 wstats.noise = rx_stats->noise; 739 wstats.noise = rx_stats->noise;
740 wstats.updated = 6; /* No qual value */ 740 wstats.updated = IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED
741 | IW_QUAL_QUAL_INVALID | IW_QUAL_DBM;
741 /* Update spy records */ 742 /* Update spy records */
742 wireless_spy_update(dev, hdr->addr2, &wstats); 743 wireless_spy_update(dev, hdr->addr2, &wstats);
743 } 744 }
@@ -889,7 +890,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
889 if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) && 890 if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
890 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0) 891 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0)
891 goto rx_dropped; 892 goto rx_dropped;
892 hdr = (struct ieee80211_hdr *) skb->data; 893 hdr = (struct ieee80211_hdr_4addr *) skb->data;
893 894
894 /* skb: hdr + (possibly fragmented) plaintext payload */ 895 /* skb: hdr + (possibly fragmented) plaintext payload */
895 896
@@ -941,7 +942,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
941 /* this was the last fragment and the frame will be 942 /* this was the last fragment and the frame will be
942 * delivered, so remove skb from fragment cache */ 943 * delivered, so remove skb from fragment cache */
943 skb = frag_skb; 944 skb = frag_skb;
944 hdr = (struct ieee80211_hdr *) skb->data; 945 hdr = (struct ieee80211_hdr_4addr *) skb->data;
945 prism2_frag_cache_invalidate(local, hdr); 946 prism2_frag_cache_invalidate(local, hdr);
946 } 947 }
947 948
@@ -952,7 +953,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
952 hostap_rx_frame_decrypt_msdu(local, skb, keyidx, crypt)) 953 hostap_rx_frame_decrypt_msdu(local, skb, keyidx, crypt))
953 goto rx_dropped; 954 goto rx_dropped;
954 955
955 hdr = (struct ieee80211_hdr *) skb->data; 956 hdr = (struct ieee80211_hdr_4addr *) skb->data;
956 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !local->open_wep) { 957 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !local->open_wep) {
957 if (local->ieee_802_1x && 958 if (local->ieee_802_1x &&
958 hostap_is_eapol_frame(local, skb)) { 959 hostap_is_eapol_frame(local, skb)) {
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 6358015f6526..9d24f8a38ac5 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -1,9 +1,9 @@
1void hostap_dump_tx_80211(const char *name, struct sk_buff *skb) 1void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)
2{ 2{
3 struct ieee80211_hdr *hdr; 3 struct ieee80211_hdr_4addr *hdr;
4 u16 fc; 4 u16 fc;
5 5
6 hdr = (struct ieee80211_hdr *) skb->data; 6 hdr = (struct ieee80211_hdr_4addr *) skb->data;
7 7
8 printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n", 8 printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n",
9 name, skb->len, jiffies); 9 name, skb->len, jiffies);
@@ -41,7 +41,7 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev)
41 struct hostap_interface *iface; 41 struct hostap_interface *iface;
42 local_info_t *local; 42 local_info_t *local;
43 int need_headroom, need_tailroom = 0; 43 int need_headroom, need_tailroom = 0;
44 struct ieee80211_hdr hdr; 44 struct ieee80211_hdr_4addr hdr;
45 u16 fc, ethertype = 0; 45 u16 fc, ethertype = 0;
46 enum { 46 enum {
47 WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME 47 WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME
@@ -244,7 +244,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
244 struct hostap_interface *iface; 244 struct hostap_interface *iface;
245 local_info_t *local; 245 local_info_t *local;
246 struct hostap_skb_tx_data *meta; 246 struct hostap_skb_tx_data *meta;
247 struct ieee80211_hdr *hdr; 247 struct ieee80211_hdr_4addr *hdr;
248 u16 fc; 248 u16 fc;
249 249
250 iface = netdev_priv(dev); 250 iface = netdev_priv(dev);
@@ -266,7 +266,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
266 meta->iface = iface; 266 meta->iface = iface;
267 267
268 if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) { 268 if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
269 hdr = (struct ieee80211_hdr *) skb->data; 269 hdr = (struct ieee80211_hdr_4addr *) skb->data;
270 fc = le16_to_cpu(hdr->frame_ctl); 270 fc = le16_to_cpu(hdr->frame_ctl);
271 if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA && 271 if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA &&
272 WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) { 272 WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) {
@@ -289,7 +289,7 @@ struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
289{ 289{
290 struct hostap_interface *iface; 290 struct hostap_interface *iface;
291 local_info_t *local; 291 local_info_t *local;
292 struct ieee80211_hdr *hdr; 292 struct ieee80211_hdr_4addr *hdr;
293 u16 fc; 293 u16 fc;
294 int hdr_len, res; 294 int hdr_len, res;
295 295
@@ -303,7 +303,7 @@ struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
303 303
304 if (local->tkip_countermeasures && 304 if (local->tkip_countermeasures &&
305 crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { 305 crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
306 hdr = (struct ieee80211_hdr *) skb->data; 306 hdr = (struct ieee80211_hdr_4addr *) skb->data;
307 if (net_ratelimit()) { 307 if (net_ratelimit()) {
308 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 308 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
309 "TX packet to " MACSTR "\n", 309 "TX packet to " MACSTR "\n",
@@ -317,15 +317,15 @@ struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
317 if (skb == NULL) 317 if (skb == NULL)
318 return NULL; 318 return NULL;
319 319
320 if ((skb_headroom(skb) < crypt->ops->extra_prefix_len || 320 if ((skb_headroom(skb) < crypt->ops->extra_mpdu_prefix_len ||
321 skb_tailroom(skb) < crypt->ops->extra_postfix_len) && 321 skb_tailroom(skb) < crypt->ops->extra_mpdu_postfix_len) &&
322 pskb_expand_head(skb, crypt->ops->extra_prefix_len, 322 pskb_expand_head(skb, crypt->ops->extra_mpdu_prefix_len,
323 crypt->ops->extra_postfix_len, GFP_ATOMIC)) { 323 crypt->ops->extra_mpdu_postfix_len, GFP_ATOMIC)) {
324 kfree_skb(skb); 324 kfree_skb(skb);
325 return NULL; 325 return NULL;
326 } 326 }
327 327
328 hdr = (struct ieee80211_hdr *) skb->data; 328 hdr = (struct ieee80211_hdr_4addr *) skb->data;
329 fc = le16_to_cpu(hdr->frame_ctl); 329 fc = le16_to_cpu(hdr->frame_ctl);
330 hdr_len = hostap_80211_get_hdrlen(fc); 330 hdr_len = hostap_80211_get_hdrlen(fc);
331 331
@@ -360,7 +360,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
360 ap_tx_ret tx_ret; 360 ap_tx_ret tx_ret;
361 struct hostap_skb_tx_data *meta; 361 struct hostap_skb_tx_data *meta;
362 int no_encrypt = 0; 362 int no_encrypt = 0;
363 struct ieee80211_hdr *hdr; 363 struct ieee80211_hdr_4addr *hdr;
364 364
365 iface = netdev_priv(dev); 365 iface = netdev_priv(dev);
366 local = iface->local; 366 local = iface->local;
@@ -403,7 +403,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
403 tx_ret = hostap_handle_sta_tx(local, &tx); 403 tx_ret = hostap_handle_sta_tx(local, &tx);
404 skb = tx.skb; 404 skb = tx.skb;
405 meta = (struct hostap_skb_tx_data *) skb->cb; 405 meta = (struct hostap_skb_tx_data *) skb->cb;
406 hdr = (struct ieee80211_hdr *) skb->data; 406 hdr = (struct ieee80211_hdr_4addr *) skb->data;
407 fc = le16_to_cpu(hdr->frame_ctl); 407 fc = le16_to_cpu(hdr->frame_ctl);
408 switch (tx_ret) { 408 switch (tx_ret) {
409 case AP_TX_CONTINUE: 409 case AP_TX_CONTINUE:
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 930cef8367f2..9da94ab7f05f 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -591,14 +591,14 @@ static void hostap_ap_tx_cb(struct sk_buff *skb, int ok, void *data)
591{ 591{
592 struct ap_data *ap = data; 592 struct ap_data *ap = data;
593 u16 fc; 593 u16 fc;
594 struct ieee80211_hdr *hdr; 594 struct ieee80211_hdr_4addr *hdr;
595 595
596 if (!ap->local->hostapd || !ap->local->apdev) { 596 if (!ap->local->hostapd || !ap->local->apdev) {
597 dev_kfree_skb(skb); 597 dev_kfree_skb(skb);
598 return; 598 return;
599 } 599 }
600 600
601 hdr = (struct ieee80211_hdr *) skb->data; 601 hdr = (struct ieee80211_hdr_4addr *) skb->data;
602 fc = le16_to_cpu(hdr->frame_ctl); 602 fc = le16_to_cpu(hdr->frame_ctl);
603 603
604 /* Pass the TX callback frame to the hostapd; use 802.11 header version 604 /* Pass the TX callback frame to the hostapd; use 802.11 header version
@@ -623,7 +623,7 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
623{ 623{
624 struct ap_data *ap = data; 624 struct ap_data *ap = data;
625 struct net_device *dev = ap->local->dev; 625 struct net_device *dev = ap->local->dev;
626 struct ieee80211_hdr *hdr; 626 struct ieee80211_hdr_4addr *hdr;
627 u16 fc, *pos, auth_alg, auth_transaction, status; 627 u16 fc, *pos, auth_alg, auth_transaction, status;
628 struct sta_info *sta = NULL; 628 struct sta_info *sta = NULL;
629 char *txt = NULL; 629 char *txt = NULL;
@@ -633,7 +633,7 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
633 return; 633 return;
634 } 634 }
635 635
636 hdr = (struct ieee80211_hdr *) skb->data; 636 hdr = (struct ieee80211_hdr_4addr *) skb->data;
637 fc = le16_to_cpu(hdr->frame_ctl); 637 fc = le16_to_cpu(hdr->frame_ctl);
638 if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT || 638 if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT ||
639 WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_AUTH || 639 WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_AUTH ||
@@ -692,7 +692,7 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
692{ 692{
693 struct ap_data *ap = data; 693 struct ap_data *ap = data;
694 struct net_device *dev = ap->local->dev; 694 struct net_device *dev = ap->local->dev;
695 struct ieee80211_hdr *hdr; 695 struct ieee80211_hdr_4addr *hdr;
696 u16 fc, *pos, status; 696 u16 fc, *pos, status;
697 struct sta_info *sta = NULL; 697 struct sta_info *sta = NULL;
698 char *txt = NULL; 698 char *txt = NULL;
@@ -702,7 +702,7 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
702 return; 702 return;
703 } 703 }
704 704
705 hdr = (struct ieee80211_hdr *) skb->data; 705 hdr = (struct ieee80211_hdr_4addr *) skb->data;
706 fc = le16_to_cpu(hdr->frame_ctl); 706 fc = le16_to_cpu(hdr->frame_ctl);
707 if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT || 707 if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT ||
708 (WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_ASSOC_RESP && 708 (WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_ASSOC_RESP &&
@@ -757,12 +757,12 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
757static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data) 757static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data)
758{ 758{
759 struct ap_data *ap = data; 759 struct ap_data *ap = data;
760 struct ieee80211_hdr *hdr; 760 struct ieee80211_hdr_4addr *hdr;
761 struct sta_info *sta; 761 struct sta_info *sta;
762 762
763 if (skb->len < 24) 763 if (skb->len < 24)
764 goto fail; 764 goto fail;
765 hdr = (struct ieee80211_hdr *) skb->data; 765 hdr = (struct ieee80211_hdr_4addr *) skb->data;
766 if (ok) { 766 if (ok) {
767 spin_lock(&ap->sta_table_lock); 767 spin_lock(&ap->sta_table_lock);
768 sta = ap_get_sta(ap, hdr->addr1); 768 sta = ap_get_sta(ap, hdr->addr1);
@@ -918,7 +918,7 @@ static void prism2_send_mgmt(struct net_device *dev,
918{ 918{
919 struct hostap_interface *iface; 919 struct hostap_interface *iface;
920 local_info_t *local; 920 local_info_t *local;
921 struct ieee80211_hdr *hdr; 921 struct ieee80211_hdr_4addr *hdr;
922 u16 fc; 922 u16 fc;
923 struct sk_buff *skb; 923 struct sk_buff *skb;
924 struct hostap_skb_tx_data *meta; 924 struct hostap_skb_tx_data *meta;
@@ -944,7 +944,7 @@ static void prism2_send_mgmt(struct net_device *dev,
944 944
945 fc = type_subtype; 945 fc = type_subtype;
946 hdrlen = hostap_80211_get_hdrlen(fc); 946 hdrlen = hostap_80211_get_hdrlen(fc);
947 hdr = (struct ieee80211_hdr *) skb_put(skb, hdrlen); 947 hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, hdrlen);
948 if (body) 948 if (body)
949 memcpy(skb_put(skb, body_len), body, body_len); 949 memcpy(skb_put(skb, body_len), body, body_len);
950 950
@@ -1256,14 +1256,14 @@ static char * ap_auth_make_challenge(struct ap_data *ap)
1256 } 1256 }
1257 1257
1258 skb = dev_alloc_skb(WLAN_AUTH_CHALLENGE_LEN + 1258 skb = dev_alloc_skb(WLAN_AUTH_CHALLENGE_LEN +
1259 ap->crypt->extra_prefix_len + 1259 ap->crypt->extra_mpdu_prefix_len +
1260 ap->crypt->extra_postfix_len); 1260 ap->crypt->extra_mpdu_postfix_len);
1261 if (skb == NULL) { 1261 if (skb == NULL) {
1262 kfree(tmpbuf); 1262 kfree(tmpbuf);
1263 return NULL; 1263 return NULL;
1264 } 1264 }
1265 1265
1266 skb_reserve(skb, ap->crypt->extra_prefix_len); 1266 skb_reserve(skb, ap->crypt->extra_mpdu_prefix_len);
1267 memset(skb_put(skb, WLAN_AUTH_CHALLENGE_LEN), 0, 1267 memset(skb_put(skb, WLAN_AUTH_CHALLENGE_LEN), 0,
1268 WLAN_AUTH_CHALLENGE_LEN); 1268 WLAN_AUTH_CHALLENGE_LEN);
1269 if (ap->crypt->encrypt_mpdu(skb, 0, ap->crypt_priv)) { 1269 if (ap->crypt->encrypt_mpdu(skb, 0, ap->crypt_priv)) {
@@ -1272,7 +1272,7 @@ static char * ap_auth_make_challenge(struct ap_data *ap)
1272 return NULL; 1272 return NULL;
1273 } 1273 }
1274 1274
1275 memcpy(tmpbuf, skb->data + ap->crypt->extra_prefix_len, 1275 memcpy(tmpbuf, skb->data + ap->crypt->extra_mpdu_prefix_len,
1276 WLAN_AUTH_CHALLENGE_LEN); 1276 WLAN_AUTH_CHALLENGE_LEN);
1277 dev_kfree_skb(skb); 1277 dev_kfree_skb(skb);
1278 1278
@@ -1285,7 +1285,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
1285 struct hostap_80211_rx_status *rx_stats) 1285 struct hostap_80211_rx_status *rx_stats)
1286{ 1286{
1287 struct net_device *dev = local->dev; 1287 struct net_device *dev = local->dev;
1288 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1288 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
1289 size_t hdrlen; 1289 size_t hdrlen;
1290 struct ap_data *ap = local->ap; 1290 struct ap_data *ap = local->ap;
1291 char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL; 1291 char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL;
@@ -1498,7 +1498,7 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
1498 struct hostap_80211_rx_status *rx_stats, int reassoc) 1498 struct hostap_80211_rx_status *rx_stats, int reassoc)
1499{ 1499{
1500 struct net_device *dev = local->dev; 1500 struct net_device *dev = local->dev;
1501 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1501 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
1502 char body[12], *p, *lpos; 1502 char body[12], *p, *lpos;
1503 int len, left; 1503 int len, left;
1504 u16 *pos; 1504 u16 *pos;
@@ -1705,7 +1705,7 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
1705 struct hostap_80211_rx_status *rx_stats) 1705 struct hostap_80211_rx_status *rx_stats)
1706{ 1706{
1707 struct net_device *dev = local->dev; 1707 struct net_device *dev = local->dev;
1708 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1708 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
1709 char *body = (char *) (skb->data + IEEE80211_MGMT_HDR_LEN); 1709 char *body = (char *) (skb->data + IEEE80211_MGMT_HDR_LEN);
1710 int len; 1710 int len;
1711 u16 reason_code, *pos; 1711 u16 reason_code, *pos;
@@ -1746,7 +1746,7 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1746 struct hostap_80211_rx_status *rx_stats) 1746 struct hostap_80211_rx_status *rx_stats)
1747{ 1747{
1748 struct net_device *dev = local->dev; 1748 struct net_device *dev = local->dev;
1749 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1749 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
1750 char *body = skb->data + IEEE80211_MGMT_HDR_LEN; 1750 char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
1751 int len; 1751 int len;
1752 u16 reason_code, *pos; 1752 u16 reason_code, *pos;
@@ -1784,7 +1784,7 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
1784 1784
1785/* Called only as a scheduled task for pending AP frames. */ 1785/* Called only as a scheduled task for pending AP frames. */
1786static void ap_handle_data_nullfunc(local_info_t *local, 1786static void ap_handle_data_nullfunc(local_info_t *local,
1787 struct ieee80211_hdr *hdr) 1787 struct ieee80211_hdr_4addr *hdr)
1788{ 1788{
1789 struct net_device *dev = local->dev; 1789 struct net_device *dev = local->dev;
1790 1790
@@ -1801,7 +1801,7 @@ static void ap_handle_data_nullfunc(local_info_t *local,
1801 1801
1802/* Called only as a scheduled task for pending AP frames. */ 1802/* Called only as a scheduled task for pending AP frames. */
1803static void ap_handle_dropped_data(local_info_t *local, 1803static void ap_handle_dropped_data(local_info_t *local,
1804 struct ieee80211_hdr *hdr) 1804 struct ieee80211_hdr_4addr *hdr)
1805{ 1805{
1806 struct net_device *dev = local->dev; 1806 struct net_device *dev = local->dev;
1807 struct sta_info *sta; 1807 struct sta_info *sta;
@@ -1860,7 +1860,7 @@ static void pspoll_send_buffered(local_info_t *local, struct sta_info *sta,
1860 1860
1861/* Called only as a scheduled task for pending AP frames. */ 1861/* Called only as a scheduled task for pending AP frames. */
1862static void handle_pspoll(local_info_t *local, 1862static void handle_pspoll(local_info_t *local,
1863 struct ieee80211_hdr *hdr, 1863 struct ieee80211_hdr_4addr *hdr,
1864 struct hostap_80211_rx_status *rx_stats) 1864 struct hostap_80211_rx_status *rx_stats)
1865{ 1865{
1866 struct net_device *dev = local->dev; 1866 struct net_device *dev = local->dev;
@@ -1979,7 +1979,7 @@ static void handle_wds_oper_queue(void *data)
1979static void handle_beacon(local_info_t *local, struct sk_buff *skb, 1979static void handle_beacon(local_info_t *local, struct sk_buff *skb,
1980 struct hostap_80211_rx_status *rx_stats) 1980 struct hostap_80211_rx_status *rx_stats)
1981{ 1981{
1982 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1982 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
1983 char *body = skb->data + IEEE80211_MGMT_HDR_LEN; 1983 char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
1984 int len, left; 1984 int len, left;
1985 u16 *pos, beacon_int, capability; 1985 u16 *pos, beacon_int, capability;
@@ -2137,11 +2137,11 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
2137 struct net_device *dev = local->dev; 2137 struct net_device *dev = local->dev;
2138#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 2138#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2139 u16 fc, type, stype; 2139 u16 fc, type, stype;
2140 struct ieee80211_hdr *hdr; 2140 struct ieee80211_hdr_4addr *hdr;
2141 2141
2142 /* FIX: should give skb->len to handler functions and check that the 2142 /* FIX: should give skb->len to handler functions and check that the
2143 * buffer is long enough */ 2143 * buffer is long enough */
2144 hdr = (struct ieee80211_hdr *) skb->data; 2144 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2145 fc = le16_to_cpu(hdr->frame_ctl); 2145 fc = le16_to_cpu(hdr->frame_ctl);
2146 type = WLAN_FC_GET_TYPE(fc); 2146 type = WLAN_FC_GET_TYPE(fc);
2147 stype = WLAN_FC_GET_STYPE(fc); 2147 stype = WLAN_FC_GET_STYPE(fc);
@@ -2258,7 +2258,7 @@ void hostap_rx(struct net_device *dev, struct sk_buff *skb,
2258 struct hostap_interface *iface; 2258 struct hostap_interface *iface;
2259 local_info_t *local; 2259 local_info_t *local;
2260 u16 fc; 2260 u16 fc;
2261 struct ieee80211_hdr *hdr; 2261 struct ieee80211_hdr_4addr *hdr;
2262 2262
2263 iface = netdev_priv(dev); 2263 iface = netdev_priv(dev);
2264 local = iface->local; 2264 local = iface->local;
@@ -2268,7 +2268,7 @@ void hostap_rx(struct net_device *dev, struct sk_buff *skb,
2268 2268
2269 local->stats.rx_packets++; 2269 local->stats.rx_packets++;
2270 2270
2271 hdr = (struct ieee80211_hdr *) skb->data; 2271 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2272 fc = le16_to_cpu(hdr->frame_ctl); 2272 fc = le16_to_cpu(hdr->frame_ctl);
2273 2273
2274 if (local->ap->ap_policy == AP_OTHER_AP_SKIP_ALL && 2274 if (local->ap->ap_policy == AP_OTHER_AP_SKIP_ALL &&
@@ -2289,7 +2289,7 @@ void hostap_rx(struct net_device *dev, struct sk_buff *skb,
2289static void schedule_packet_send(local_info_t *local, struct sta_info *sta) 2289static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2290{ 2290{
2291 struct sk_buff *skb; 2291 struct sk_buff *skb;
2292 struct ieee80211_hdr *hdr; 2292 struct ieee80211_hdr_4addr *hdr;
2293 struct hostap_80211_rx_status rx_stats; 2293 struct hostap_80211_rx_status rx_stats;
2294 2294
2295 if (skb_queue_empty(&sta->tx_buf)) 2295 if (skb_queue_empty(&sta->tx_buf))
@@ -2302,7 +2302,7 @@ static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2302 return; 2302 return;
2303 } 2303 }
2304 2304
2305 hdr = (struct ieee80211_hdr *) skb_put(skb, 16); 2305 hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, 16);
2306 2306
2307 /* Generate a fake pspoll frame to start packet delivery */ 2307 /* Generate a fake pspoll frame to start packet delivery */
2308 hdr->frame_ctl = __constant_cpu_to_le16( 2308 hdr->frame_ctl = __constant_cpu_to_le16(
@@ -2349,7 +2349,7 @@ static int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[],
2349 qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence); 2349 qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
2350 qual[count].updated = sta->last_rx_updated; 2350 qual[count].updated = sta->last_rx_updated;
2351 2351
2352 sta->last_rx_updated = 0; 2352 sta->last_rx_updated = IW_QUAL_DBM;
2353 2353
2354 count++; 2354 count++;
2355 if (count >= buf_size) 2355 if (count >= buf_size)
@@ -2467,7 +2467,7 @@ static int prism2_ap_translate_scan(struct net_device *dev, char *buffer)
2467 } 2467 }
2468#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 2468#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2469 2469
2470 sta->last_rx_updated = 0; 2470 sta->last_rx_updated = IW_QUAL_DBM;
2471 2471
2472 /* To be continued, we should make good use of IWEVCUSTOM */ 2472 /* To be continued, we should make good use of IWEVCUSTOM */
2473 } 2473 }
@@ -2685,7 +2685,7 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2685 struct sta_info *sta = NULL; 2685 struct sta_info *sta = NULL;
2686 struct sk_buff *skb = tx->skb; 2686 struct sk_buff *skb = tx->skb;
2687 int set_tim, ret; 2687 int set_tim, ret;
2688 struct ieee80211_hdr *hdr; 2688 struct ieee80211_hdr_4addr *hdr;
2689 struct hostap_skb_tx_data *meta; 2689 struct hostap_skb_tx_data *meta;
2690 2690
2691 meta = (struct hostap_skb_tx_data *) skb->cb; 2691 meta = (struct hostap_skb_tx_data *) skb->cb;
@@ -2694,7 +2694,7 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2694 meta->iface->type == HOSTAP_INTERFACE_STA) 2694 meta->iface->type == HOSTAP_INTERFACE_STA)
2695 goto out; 2695 goto out;
2696 2696
2697 hdr = (struct ieee80211_hdr *) skb->data; 2697 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2698 2698
2699 if (hdr->addr1[0] & 0x01) { 2699 if (hdr->addr1[0] & 0x01) {
2700 /* broadcast/multicast frame - no AP related processing */ 2700 /* broadcast/multicast frame - no AP related processing */
@@ -2821,10 +2821,10 @@ void hostap_handle_sta_release(void *ptr)
2821void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb) 2821void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb)
2822{ 2822{
2823 struct sta_info *sta; 2823 struct sta_info *sta;
2824 struct ieee80211_hdr *hdr; 2824 struct ieee80211_hdr_4addr *hdr;
2825 struct hostap_skb_tx_data *meta; 2825 struct hostap_skb_tx_data *meta;
2826 2826
2827 hdr = (struct ieee80211_hdr *) skb->data; 2827 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2828 meta = (struct hostap_skb_tx_data *) skb->cb; 2828 meta = (struct hostap_skb_tx_data *) skb->cb;
2829 2829
2830 spin_lock(&local->ap->sta_table_lock); 2830 spin_lock(&local->ap->sta_table_lock);
@@ -2892,7 +2892,7 @@ static void hostap_update_sta_ps2(local_info_t *local, struct sta_info *sta,
2892 2892
2893/* Called only as a tasklet (software IRQ). Called for each RX frame to update 2893/* Called only as a tasklet (software IRQ). Called for each RX frame to update
2894 * STA power saving state. pwrmgt is a flag from 802.11 frame_ctl field. */ 2894 * STA power saving state. pwrmgt is a flag from 802.11 frame_ctl field. */
2895int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr) 2895int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr_4addr *hdr)
2896{ 2896{
2897 struct sta_info *sta; 2897 struct sta_info *sta;
2898 u16 fc; 2898 u16 fc;
@@ -2925,12 +2925,12 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
2925 int ret; 2925 int ret;
2926 struct sta_info *sta; 2926 struct sta_info *sta;
2927 u16 fc, type, stype; 2927 u16 fc, type, stype;
2928 struct ieee80211_hdr *hdr; 2928 struct ieee80211_hdr_4addr *hdr;
2929 2929
2930 if (local->ap == NULL) 2930 if (local->ap == NULL)
2931 return AP_RX_CONTINUE; 2931 return AP_RX_CONTINUE;
2932 2932
2933 hdr = (struct ieee80211_hdr *) skb->data; 2933 hdr = (struct ieee80211_hdr_4addr *) skb->data;
2934 2934
2935 fc = le16_to_cpu(hdr->frame_ctl); 2935 fc = le16_to_cpu(hdr->frame_ctl);
2936 type = WLAN_FC_GET_TYPE(fc); 2936 type = WLAN_FC_GET_TYPE(fc);
@@ -3058,7 +3058,7 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
3058 3058
3059/* Called only as a tasklet (software IRQ) */ 3059/* Called only as a tasklet (software IRQ) */
3060int hostap_handle_sta_crypto(local_info_t *local, 3060int hostap_handle_sta_crypto(local_info_t *local,
3061 struct ieee80211_hdr *hdr, 3061 struct ieee80211_hdr_4addr *hdr,
3062 struct ieee80211_crypt_data **crypt, 3062 struct ieee80211_crypt_data **crypt,
3063 void **sta_ptr) 3063 void **sta_ptr)
3064{ 3064{
@@ -3160,7 +3160,7 @@ int hostap_add_sta(struct ap_data *ap, u8 *sta_addr)
3160 3160
3161/* Called only as a tasklet (software IRQ) */ 3161/* Called only as a tasklet (software IRQ) */
3162int hostap_update_rx_stats(struct ap_data *ap, 3162int hostap_update_rx_stats(struct ap_data *ap,
3163 struct ieee80211_hdr *hdr, 3163 struct ieee80211_hdr_4addr *hdr,
3164 struct hostap_80211_rx_status *rx_stats) 3164 struct hostap_80211_rx_status *rx_stats)
3165{ 3165{
3166 struct sta_info *sta; 3166 struct sta_info *sta;
@@ -3174,7 +3174,7 @@ int hostap_update_rx_stats(struct ap_data *ap,
3174 sta->last_rx_silence = rx_stats->noise; 3174 sta->last_rx_silence = rx_stats->noise;
3175 sta->last_rx_signal = rx_stats->signal; 3175 sta->last_rx_signal = rx_stats->signal;
3176 sta->last_rx_rate = rx_stats->rate; 3176 sta->last_rx_rate = rx_stats->rate;
3177 sta->last_rx_updated = 7; 3177 sta->last_rx_updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
3178 if (rx_stats->rate == 10) 3178 if (rx_stats->rate == 10)
3179 sta->rx_count[0]++; 3179 sta->rx_count[0]++;
3180 else if (rx_stats->rate == 20) 3180 else if (rx_stats->rate == 20)
diff --git a/drivers/net/wireless/hostap/hostap_ap.h b/drivers/net/wireless/hostap/hostap_ap.h
index 816a52bcea8f..6d00df69c2e3 100644
--- a/drivers/net/wireless/hostap/hostap_ap.h
+++ b/drivers/net/wireless/hostap/hostap_ap.h
@@ -233,7 +233,7 @@ struct hostap_tx_data {
233ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx); 233ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
234void hostap_handle_sta_release(void *ptr); 234void hostap_handle_sta_release(void *ptr);
235void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb); 235void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb);
236int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr); 236int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr_4addr *hdr);
237typedef enum { 237typedef enum {
238 AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED 238 AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
239} ap_rx_ret; 239} ap_rx_ret;
@@ -241,13 +241,13 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
241 struct sk_buff *skb, 241 struct sk_buff *skb,
242 struct hostap_80211_rx_status *rx_stats, 242 struct hostap_80211_rx_status *rx_stats,
243 int wds); 243 int wds);
244int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr *hdr, 244int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr_4addr *hdr,
245 struct ieee80211_crypt_data **crypt, 245 struct ieee80211_crypt_data **crypt,
246 void **sta_ptr); 246 void **sta_ptr);
247int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr); 247int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
248int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr); 248int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);
249int hostap_add_sta(struct ap_data *ap, u8 *sta_addr); 249int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
250int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr *hdr, 250int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr_4addr *hdr,
251 struct hostap_80211_rx_status *rx_stats); 251 struct hostap_80211_rx_status *rx_stats);
252void hostap_update_rates(local_info_t *local); 252void hostap_update_rates(local_info_t *local);
253void hostap_add_wds_links(local_info_t *local); 253void hostap_add_wds_links(local_info_t *local);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index faa83badf0a1..2643976a6677 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -492,42 +492,10 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
492} 492}
493 493
494 494
495static int prism2_pccard_dev_open(local_info_t *local)
496{
497 struct hostap_cs_priv *hw_priv = local->hw_priv;
498 hw_priv->link->open++;
499 return 0;
500}
501
502
503static int prism2_pccard_dev_close(local_info_t *local)
504{
505 struct hostap_cs_priv *hw_priv;
506
507 if (local == NULL || local->hw_priv == NULL)
508 return 1;
509 hw_priv = local->hw_priv;
510 if (hw_priv->link == NULL)
511 return 1;
512
513 if (!hw_priv->link->open) {
514 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
515 "link not open?!\n", local->dev->name);
516 return 1;
517 }
518
519 hw_priv->link->open--;
520
521 return 0;
522}
523
524
525static struct prism2_helper_functions prism2_pccard_funcs = 495static struct prism2_helper_functions prism2_pccard_funcs =
526{ 496{
527 .card_present = prism2_pccard_card_present, 497 .card_present = prism2_pccard_card_present,
528 .cor_sreset = prism2_pccard_cor_sreset, 498 .cor_sreset = prism2_pccard_cor_sreset,
529 .dev_open = prism2_pccard_dev_open,
530 .dev_close = prism2_pccard_dev_close,
531 .genesis_reset = prism2_pccard_genesis_reset, 499 .genesis_reset = prism2_pccard_genesis_reset,
532 .hw_type = HOSTAP_HW_PCCARD, 500 .hw_type = HOSTAP_HW_PCCARD,
533}; 501};
@@ -597,13 +565,14 @@ static void prism2_detach(dev_link_t *link)
597 *linkp = link->next; 565 *linkp = link->next;
598 /* release net devices */ 566 /* release net devices */
599 if (link->priv) { 567 if (link->priv) {
568 struct hostap_cs_priv *hw_priv;
600 struct net_device *dev; 569 struct net_device *dev;
601 struct hostap_interface *iface; 570 struct hostap_interface *iface;
602 dev = link->priv; 571 dev = link->priv;
603 iface = netdev_priv(dev); 572 iface = netdev_priv(dev);
604 kfree(iface->local->hw_priv); 573 hw_priv = iface->local->hw_priv;
605 iface->local->hw_priv = NULL;
606 prism2_free_local_data(dev); 574 prism2_free_local_data(dev);
575 kfree(hw_priv);
607 } 576 }
608 kfree(link); 577 kfree(link);
609} 578}
@@ -883,6 +852,13 @@ static int prism2_event(event_t event, int priority,
883{ 852{
884 dev_link_t *link = args->client_data; 853 dev_link_t *link = args->client_data;
885 struct net_device *dev = (struct net_device *) link->priv; 854 struct net_device *dev = (struct net_device *) link->priv;
855 int dev_open = 0;
856
857 if (link->state & DEV_CONFIG) {
858 struct hostap_interface *iface = netdev_priv(dev);
859 if (iface && iface->local)
860 dev_open = iface->local->num_dev_open > 0;
861 }
886 862
887 switch (event) { 863 switch (event) {
888 case CS_EVENT_CARD_INSERTION: 864 case CS_EVENT_CARD_INSERTION:
@@ -911,7 +887,7 @@ static int prism2_event(event_t event, int priority,
911 case CS_EVENT_RESET_PHYSICAL: 887 case CS_EVENT_RESET_PHYSICAL:
912 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info); 888 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
913 if (link->state & DEV_CONFIG) { 889 if (link->state & DEV_CONFIG) {
914 if (link->open) { 890 if (dev_open) {
915 netif_stop_queue(dev); 891 netif_stop_queue(dev);
916 netif_device_detach(dev); 892 netif_device_detach(dev);
917 } 893 }
@@ -931,8 +907,8 @@ static int prism2_event(event_t event, int priority,
931 pcmcia_request_configuration(link->handle, 907 pcmcia_request_configuration(link->handle,
932 &link->conf); 908 &link->conf);
933 prism2_hw_shutdown(dev, 1); 909 prism2_hw_shutdown(dev, 1);
934 prism2_hw_config(dev, link->open ? 0 : 1); 910 prism2_hw_config(dev, dev_open ? 0 : 1);
935 if (link->open) { 911 if (dev_open) {
936 netif_device_attach(dev); 912 netif_device_attach(dev);
937 netif_start_queue(dev); 913 netif_start_queue(dev);
938 } 914 }
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index e533a663deda..59fc15572395 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -3322,6 +3322,18 @@ static void prism2_free_local_data(struct net_device *dev)
3322 iface = netdev_priv(dev); 3322 iface = netdev_priv(dev);
3323 local = iface->local; 3323 local = iface->local;
3324 3324
3325 /* Unregister all netdevs before freeing local data. */
3326 list_for_each_safe(ptr, n, &local->hostap_interfaces) {
3327 iface = list_entry(ptr, struct hostap_interface, list);
3328 if (iface->type == HOSTAP_INTERFACE_MASTER) {
3329 /* special handling for this interface below */
3330 continue;
3331 }
3332 hostap_remove_interface(iface->dev, 0, 1);
3333 }
3334
3335 unregister_netdev(local->dev);
3336
3325 flush_scheduled_work(); 3337 flush_scheduled_work();
3326 3338
3327 if (timer_pending(&local->crypt_deinit_timer)) 3339 if (timer_pending(&local->crypt_deinit_timer))
@@ -3382,15 +3394,6 @@ static void prism2_free_local_data(struct net_device *dev)
3382 prism2_download_free_data(local->dl_sec); 3394 prism2_download_free_data(local->dl_sec);
3383#endif /* PRISM2_DOWNLOAD_SUPPORT */ 3395#endif /* PRISM2_DOWNLOAD_SUPPORT */
3384 3396
3385 list_for_each_safe(ptr, n, &local->hostap_interfaces) {
3386 iface = list_entry(ptr, struct hostap_interface, list);
3387 if (iface->type == HOSTAP_INTERFACE_MASTER) {
3388 /* special handling for this interface below */
3389 continue;
3390 }
3391 hostap_remove_interface(iface->dev, 0, 1);
3392 }
3393
3394 prism2_clear_set_tim_queue(local); 3397 prism2_clear_set_tim_queue(local);
3395 3398
3396 list_for_each_safe(ptr, n, &local->bss_list) { 3399 list_for_each_safe(ptr, n, &local->bss_list) {
@@ -3403,7 +3406,6 @@ static void prism2_free_local_data(struct net_device *dev)
3403 kfree(local->last_scan_results); 3406 kfree(local->last_scan_results);
3404 kfree(local->generic_elem); 3407 kfree(local->generic_elem);
3405 3408
3406 unregister_netdev(local->dev);
3407 free_netdev(local->dev); 3409 free_netdev(local->dev);
3408} 3410}
3409 3411
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index e720369a3515..53f5246c40aa 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -50,7 +50,8 @@ static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
50#endif /* in_atomic */ 50#endif /* in_atomic */
51 51
52 if (update && prism2_update_comms_qual(dev) == 0) 52 if (update && prism2_update_comms_qual(dev) == 0)
53 wstats->qual.updated = 7; 53 wstats->qual.updated = IW_QUAL_ALL_UPDATED |
54 IW_QUAL_DBM;
54 55
55 wstats->qual.qual = local->comms_qual; 56 wstats->qual.qual = local->comms_qual;
56 wstats->qual.level = local->avg_signal; 57 wstats->qual.level = local->avg_signal;
@@ -59,7 +60,7 @@ static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
59 wstats->qual.qual = 0; 60 wstats->qual.qual = 0;
60 wstats->qual.level = 0; 61 wstats->qual.level = 0;
61 wstats->qual.noise = 0; 62 wstats->qual.noise = 0;
62 wstats->qual.updated = 0; 63 wstats->qual.updated = IW_QUAL_ALL_INVALID;
63 } 64 }
64 65
65 return wstats; 66 return wstats;
@@ -1827,13 +1828,6 @@ static char * __prism2_translate_scan(local_info_t *local,
1827 iwe.cmd = SIOCGIWAP; 1828 iwe.cmd = SIOCGIWAP;
1828 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 1829 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1829 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN); 1830 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
1830 /* FIX:
1831 * I do not know how this is possible, but iwe_stream_add_event
1832 * seems to re-order memcpy execution so that len is set only
1833 * after copying.. Pre-setting len here "fixes" this, but real
1834 * problems should be solved (after which these iwe.len
1835 * settings could be removed from this function). */
1836 iwe.len = IW_EV_ADDR_LEN;
1837 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1831 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1838 IW_EV_ADDR_LEN); 1832 IW_EV_ADDR_LEN);
1839 1833
@@ -1843,7 +1837,6 @@ static char * __prism2_translate_scan(local_info_t *local,
1843 iwe.cmd = SIOCGIWESSID; 1837 iwe.cmd = SIOCGIWESSID;
1844 iwe.u.data.length = ssid_len; 1838 iwe.u.data.length = ssid_len;
1845 iwe.u.data.flags = 1; 1839 iwe.u.data.flags = 1;
1846 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1847 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid); 1840 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid);
1848 1841
1849 memset(&iwe, 0, sizeof(iwe)); 1842 memset(&iwe, 0, sizeof(iwe));
@@ -1859,7 +1852,6 @@ static char * __prism2_translate_scan(local_info_t *local,
1859 iwe.u.mode = IW_MODE_MASTER; 1852 iwe.u.mode = IW_MODE_MASTER;
1860 else 1853 else
1861 iwe.u.mode = IW_MODE_ADHOC; 1854 iwe.u.mode = IW_MODE_ADHOC;
1862 iwe.len = IW_EV_UINT_LEN;
1863 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1855 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1864 IW_EV_UINT_LEN); 1856 IW_EV_UINT_LEN);
1865 } 1857 }
@@ -1877,7 +1869,6 @@ static char * __prism2_translate_scan(local_info_t *local,
1877 if (chan > 0) { 1869 if (chan > 0) {
1878 iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000; 1870 iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000;
1879 iwe.u.freq.e = 1; 1871 iwe.u.freq.e = 1;
1880 iwe.len = IW_EV_FREQ_LEN;
1881 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1872 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1882 IW_EV_FREQ_LEN); 1873 IW_EV_FREQ_LEN);
1883 } 1874 }
@@ -1894,7 +1885,10 @@ static char * __prism2_translate_scan(local_info_t *local,
1894 iwe.u.qual.noise = 1885 iwe.u.qual.noise =
1895 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl)); 1886 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
1896 } 1887 }
1897 iwe.len = IW_EV_QUAL_LEN; 1888 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
1889 | IW_QUAL_NOISE_UPDATED
1890 | IW_QUAL_QUAL_INVALID
1891 | IW_QUAL_DBM;
1898 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, 1892 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1899 IW_EV_QUAL_LEN); 1893 IW_EV_QUAL_LEN);
1900 } 1894 }
@@ -1906,7 +1900,6 @@ static char * __prism2_translate_scan(local_info_t *local,
1906 else 1900 else
1907 iwe.u.data.flags = IW_ENCODE_DISABLED; 1901 iwe.u.data.flags = IW_ENCODE_DISABLED;
1908 iwe.u.data.length = 0; 1902 iwe.u.data.length = 0;
1909 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1910 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ""); 1903 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
1911 1904
1912 /* TODO: add SuppRates into BSS table */ 1905 /* TODO: add SuppRates into BSS table */
@@ -1930,7 +1923,7 @@ static char * __prism2_translate_scan(local_info_t *local,
1930 } 1923 }
1931 1924
1932 /* TODO: add BeaconInt,resp_rate,atim into BSS table */ 1925 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1933 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL); 1926 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);
1934 if (buf && scan) { 1927 if (buf && scan) {
1935 memset(&iwe, 0, sizeof(iwe)); 1928 memset(&iwe, 0, sizeof(iwe));
1936 iwe.cmd = IWEVCUSTOM; 1929 iwe.cmd = IWEVCUSTOM;
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 025f8cdb5566..da0c80fb941c 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -59,11 +59,13 @@ static struct pci_device_id prism2_pci_id_table[] __devinitdata = {
59static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v) 59static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
60{ 60{
61 struct hostap_interface *iface; 61 struct hostap_interface *iface;
62 struct hostap_pci_priv *hw_priv;
62 local_info_t *local; 63 local_info_t *local;
63 unsigned long flags; 64 unsigned long flags;
64 65
65 iface = netdev_priv(dev); 66 iface = netdev_priv(dev);
66 local = iface->local; 67 local = iface->local;
68 hw_priv = local->hw_priv;
67 69
68 spin_lock_irqsave(&local->lock, flags); 70 spin_lock_irqsave(&local->lock, flags);
69 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v); 71 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
@@ -74,12 +76,14 @@ static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
74static inline u8 hfa384x_inb_debug(struct net_device *dev, int a) 76static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
75{ 77{
76 struct hostap_interface *iface; 78 struct hostap_interface *iface;
79 struct hostap_pci_priv *hw_priv;
77 local_info_t *local; 80 local_info_t *local;
78 unsigned long flags; 81 unsigned long flags;
79 u8 v; 82 u8 v;
80 83
81 iface = netdev_priv(dev); 84 iface = netdev_priv(dev);
82 local = iface->local; 85 local = iface->local;
86 hw_priv = local->hw_priv;
83 87
84 spin_lock_irqsave(&local->lock, flags); 88 spin_lock_irqsave(&local->lock, flags);
85 v = readb(hw_priv->mem_start + a); 89 v = readb(hw_priv->mem_start + a);
@@ -91,11 +95,13 @@ static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
91static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v) 95static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
92{ 96{
93 struct hostap_interface *iface; 97 struct hostap_interface *iface;
98 struct hostap_pci_priv *hw_priv;
94 local_info_t *local; 99 local_info_t *local;
95 unsigned long flags; 100 unsigned long flags;
96 101
97 iface = netdev_priv(dev); 102 iface = netdev_priv(dev);
98 local = iface->local; 103 local = iface->local;
104 hw_priv = local->hw_priv;
99 105
100 spin_lock_irqsave(&local->lock, flags); 106 spin_lock_irqsave(&local->lock, flags);
101 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v); 107 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
@@ -106,12 +112,14 @@ static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
106static inline u16 hfa384x_inw_debug(struct net_device *dev, int a) 112static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
107{ 113{
108 struct hostap_interface *iface; 114 struct hostap_interface *iface;
115 struct hostap_pci_priv *hw_priv;
109 local_info_t *local; 116 local_info_t *local;
110 unsigned long flags; 117 unsigned long flags;
111 u16 v; 118 u16 v;
112 119
113 iface = netdev_priv(dev); 120 iface = netdev_priv(dev);
114 local = iface->local; 121 local = iface->local;
122 hw_priv = local->hw_priv;
115 123
116 spin_lock_irqsave(&local->lock, flags); 124 spin_lock_irqsave(&local->lock, flags);
117 v = readw(hw_priv->mem_start + a); 125 v = readw(hw_priv->mem_start + a);
@@ -277,8 +285,6 @@ static struct prism2_helper_functions prism2_pci_funcs =
277{ 285{
278 .card_present = NULL, 286 .card_present = NULL,
279 .cor_sreset = prism2_pci_cor_sreset, 287 .cor_sreset = prism2_pci_cor_sreset,
280 .dev_open = NULL,
281 .dev_close = NULL,
282 .genesis_reset = prism2_pci_genesis_reset, 288 .genesis_reset = prism2_pci_genesis_reset,
283 .hw_type = HOSTAP_HW_PCI, 289 .hw_type = HOSTAP_HW_PCI,
284}; 290};
@@ -352,8 +358,6 @@ static int prism2_pci_probe(struct pci_dev *pdev,
352 return hostap_hw_ready(dev); 358 return hostap_hw_ready(dev);
353 359
354 fail: 360 fail:
355 kfree(hw_priv);
356
357 if (irq_registered && dev) 361 if (irq_registered && dev)
358 free_irq(dev->irq, dev); 362 free_irq(dev->irq, dev);
359 363
@@ -364,10 +368,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
364 368
365 err_out_disable: 369 err_out_disable:
366 pci_disable_device(pdev); 370 pci_disable_device(pdev);
367 kfree(hw_priv);
368 if (local)
369 local->hw_priv = NULL;
370 prism2_free_local_data(dev); 371 prism2_free_local_data(dev);
372 kfree(hw_priv);
371 373
372 return -ENODEV; 374 return -ENODEV;
373} 375}
@@ -392,9 +394,8 @@ static void prism2_pci_remove(struct pci_dev *pdev)
392 free_irq(dev->irq, dev); 394 free_irq(dev->irq, dev);
393 395
394 mem_start = hw_priv->mem_start; 396 mem_start = hw_priv->mem_start;
395 kfree(hw_priv);
396 iface->local->hw_priv = NULL;
397 prism2_free_local_data(dev); 397 prism2_free_local_data(dev);
398 kfree(hw_priv);
398 399
399 iounmap(mem_start); 400 iounmap(mem_start);
400 401
@@ -441,7 +442,7 @@ static int prism2_pci_resume(struct pci_dev *pdev)
441MODULE_DEVICE_TABLE(pci, prism2_pci_id_table); 442MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
442 443
443static struct pci_driver prism2_pci_drv_id = { 444static struct pci_driver prism2_pci_drv_id = {
444 .name = "prism2_pci", 445 .name = "hostap_pci",
445 .id_table = prism2_pci_id_table, 446 .id_table = prism2_pci_id_table,
446 .probe = prism2_pci_probe, 447 .probe = prism2_pci_probe,
447 .remove = prism2_pci_remove, 448 .remove = prism2_pci_remove,
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 474ef83d813e..78d67b408b2f 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -328,8 +328,6 @@ static struct prism2_helper_functions prism2_plx_funcs =
328{ 328{
329 .card_present = NULL, 329 .card_present = NULL,
330 .cor_sreset = prism2_plx_cor_sreset, 330 .cor_sreset = prism2_plx_cor_sreset,
331 .dev_open = NULL,
332 .dev_close = NULL,
333 .genesis_reset = prism2_plx_genesis_reset, 331 .genesis_reset = prism2_plx_genesis_reset,
334 .hw_type = HOSTAP_HW_PLX, 332 .hw_type = HOSTAP_HW_PLX,
335}; 333};
@@ -570,10 +568,8 @@ static int prism2_plx_probe(struct pci_dev *pdev,
570 return hostap_hw_ready(dev); 568 return hostap_hw_ready(dev);
571 569
572 fail: 570 fail:
573 kfree(hw_priv);
574 if (local)
575 local->hw_priv = NULL;
576 prism2_free_local_data(dev); 571 prism2_free_local_data(dev);
572 kfree(hw_priv);
577 573
578 if (irq_registered && dev) 574 if (irq_registered && dev)
579 free_irq(dev->irq, dev); 575 free_irq(dev->irq, dev);
@@ -606,9 +602,8 @@ static void prism2_plx_remove(struct pci_dev *pdev)
606 if (dev->irq) 602 if (dev->irq)
607 free_irq(dev->irq, dev); 603 free_irq(dev->irq, dev);
608 604
609 kfree(iface->local->hw_priv);
610 iface->local->hw_priv = NULL;
611 prism2_free_local_data(dev); 605 prism2_free_local_data(dev);
606 kfree(hw_priv);
612 pci_disable_device(pdev); 607 pci_disable_device(pdev);
613} 608}
614 609
@@ -616,7 +611,7 @@ static void prism2_plx_remove(struct pci_dev *pdev)
616MODULE_DEVICE_TABLE(pci, prism2_plx_id_table); 611MODULE_DEVICE_TABLE(pci, prism2_plx_id_table);
617 612
618static struct pci_driver prism2_plx_drv_id = { 613static struct pci_driver prism2_plx_drv_id = {
619 .name = "prism2_plx", 614 .name = "hostap_plx",
620 .id_table = prism2_plx_id_table, 615 .id_table = prism2_plx_id_table,
621 .probe = prism2_plx_probe, 616 .probe = prism2_plx_probe,
622 .remove = prism2_plx_remove, 617 .remove = prism2_plx_remove,
diff --git a/drivers/net/wireless/hostap/hostap_wlan.h b/drivers/net/wireless/hostap/hostap_wlan.h
index cc061e1560d3..cfd801559492 100644
--- a/drivers/net/wireless/hostap/hostap_wlan.h
+++ b/drivers/net/wireless/hostap/hostap_wlan.h
@@ -552,8 +552,6 @@ struct prism2_helper_functions {
552 * (hostap_{cs,plx,pci}.c */ 552 * (hostap_{cs,plx,pci}.c */
553 int (*card_present)(local_info_t *local); 553 int (*card_present)(local_info_t *local);
554 void (*cor_sreset)(local_info_t *local); 554 void (*cor_sreset)(local_info_t *local);
555 int (*dev_open)(local_info_t *local);
556 int (*dev_close)(local_info_t *local);
557 void (*genesis_reset)(local_info_t *local, int hcr); 555 void (*genesis_reset)(local_info_t *local, int hcr);
558 556
559 /* the following functions are from hostap_hw.c, but they may have some 557 /* the following functions are from hostap_hw.c, but they may have some
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 2414e6493aa5..ad7f8cd76db9 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -800,8 +800,7 @@ static int ipw2100_hw_send_command(struct ipw2100_priv *priv,
800 * doesn't seem to have as many firmware restart cycles... 800 * doesn't seem to have as many firmware restart cycles...
801 * 801 *
802 * As a test, we're sticking in a 1/100s delay here */ 802 * As a test, we're sticking in a 1/100s delay here */
803 set_current_state(TASK_UNINTERRUPTIBLE); 803 schedule_timeout_uninterruptible(msecs_to_jiffies(10));
804 schedule_timeout(HZ / 100);
805 804
806 return 0; 805 return 0;
807 806
@@ -1256,8 +1255,7 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv)
1256 IPW_DEBUG_FW("Waiting for f/w initialization to complete...\n"); 1255 IPW_DEBUG_FW("Waiting for f/w initialization to complete...\n");
1257 i = 5000; 1256 i = 5000;
1258 do { 1257 do {
1259 set_current_state(TASK_UNINTERRUPTIBLE); 1258 schedule_timeout_uninterruptible(msecs_to_jiffies(40));
1260 schedule_timeout(40 * HZ / 1000);
1261 /* Todo... wait for sync command ... */ 1259 /* Todo... wait for sync command ... */
1262 1260
1263 read_register(priv->net_dev, IPW_REG_INTA, &inta); 1261 read_register(priv->net_dev, IPW_REG_INTA, &inta);
@@ -1411,8 +1409,7 @@ static int ipw2100_hw_phy_off(struct ipw2100_priv *priv)
1411 (val2 & IPW2100_COMMAND_PHY_OFF)) 1409 (val2 & IPW2100_COMMAND_PHY_OFF))
1412 return 0; 1410 return 0;
1413 1411
1414 set_current_state(TASK_UNINTERRUPTIBLE); 1412 schedule_timeout_uninterruptible(HW_PHY_OFF_LOOP_DELAY);
1415 schedule_timeout(HW_PHY_OFF_LOOP_DELAY);
1416 } 1413 }
1417 1414
1418 return -EIO; 1415 return -EIO;
@@ -1466,7 +1463,7 @@ fail_up:
1466 1463
1467static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) 1464static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
1468{ 1465{
1469#define HW_POWER_DOWN_DELAY (HZ / 10) 1466#define HW_POWER_DOWN_DELAY (msecs_to_jiffies(100))
1470 1467
1471 struct host_command cmd = { 1468 struct host_command cmd = {
1472 .host_command = HOST_PRE_POWER_DOWN, 1469 .host_command = HOST_PRE_POWER_DOWN,
@@ -1520,10 +1517,8 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
1520 printk(KERN_WARNING DRV_NAME ": " 1517 printk(KERN_WARNING DRV_NAME ": "
1521 "%s: Power down command failed: Error %d\n", 1518 "%s: Power down command failed: Error %d\n",
1522 priv->net_dev->name, err); 1519 priv->net_dev->name, err);
1523 else { 1520 else
1524 set_current_state(TASK_UNINTERRUPTIBLE); 1521 schedule_timeout_uninterruptible(HW_POWER_DOWN_DELAY);
1525 schedule_timeout(HW_POWER_DOWN_DELAY);
1526 }
1527 } 1522 }
1528 1523
1529 priv->status &= ~STATUS_ENABLED; 1524 priv->status &= ~STATUS_ENABLED;
@@ -2953,7 +2948,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2953 int next = txq->next; 2948 int next = txq->next;
2954 int i = 0; 2949 int i = 0;
2955 struct ipw2100_data_header *ipw_hdr; 2950 struct ipw2100_data_header *ipw_hdr;
2956 struct ieee80211_hdr *hdr; 2951 struct ieee80211_hdr_3addr *hdr;
2957 2952
2958 while (!list_empty(&priv->tx_pend_list)) { 2953 while (!list_empty(&priv->tx_pend_list)) {
2959 /* if there isn't enough space in TBD queue, then 2954 /* if there isn't enough space in TBD queue, then
@@ -2989,7 +2984,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2989 packet->index = txq->next; 2984 packet->index = txq->next;
2990 2985
2991 ipw_hdr = packet->info.d_struct.data; 2986 ipw_hdr = packet->info.d_struct.data;
2992 hdr = (struct ieee80211_hdr *)packet->info.d_struct.txb-> 2987 hdr = (struct ieee80211_hdr_3addr *)packet->info.d_struct.txb->
2993 fragments[0]->data; 2988 fragments[0]->data;
2994 2989
2995 if (priv->ieee->iw_mode == IW_MODE_INFRA) { 2990 if (priv->ieee->iw_mode == IW_MODE_INFRA) {
@@ -3274,7 +3269,8 @@ static irqreturn_t ipw2100_interrupt(int irq, void *data,
3274 return IRQ_NONE; 3269 return IRQ_NONE;
3275} 3270}
3276 3271
3277static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev) 3272static int ipw2100_tx(struct ieee80211_txb *txb, struct net_device *dev,
3273 int pri)
3278{ 3274{
3279 struct ipw2100_priv *priv = ieee80211_priv(dev); 3275 struct ipw2100_priv *priv = ieee80211_priv(dev);
3280 struct list_head *element; 3276 struct list_head *element;
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 2a3cdbd50168..c9e99ce15d66 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -808,7 +808,7 @@ struct ipw2100_priv {
808struct ipw2100_rx { 808struct ipw2100_rx {
809 union { 809 union {
810 unsigned char payload[IPW_RX_NIC_BUFFER_LENGTH]; 810 unsigned char payload[IPW_RX_NIC_BUFFER_LENGTH];
811 struct ieee80211_hdr header; 811 struct ieee80211_hdr_4addr header;
812 u32 status; 812 u32 status;
813 struct ipw2100_notification notification; 813 struct ipw2100_notification notification;
814 struct ipw2100_cmd_header command; 814 struct ipw2100_cmd_header command;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index b7f275c00de3..de4e6c23e4b8 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4904,7 +4904,7 @@ static void ipw_rx(struct ipw_priv *priv)
4904{ 4904{
4905 struct ipw_rx_mem_buffer *rxb; 4905 struct ipw_rx_mem_buffer *rxb;
4906 struct ipw_rx_packet *pkt; 4906 struct ipw_rx_packet *pkt;
4907 struct ieee80211_hdr *header; 4907 struct ieee80211_hdr_4addr *header;
4908 u32 r, w, i; 4908 u32 r, w, i;
4909 u8 network_packet; 4909 u8 network_packet;
4910 4910
@@ -4967,8 +4967,9 @@ static void ipw_rx(struct ipw_priv *priv)
4967#endif 4967#endif
4968 4968
4969 header = 4969 header =
4970 (struct ieee80211_hdr *)(rxb->skb->data + 4970 (struct ieee80211_hdr_4addr *)(rxb->skb->
4971 IPW_RX_FRAME_SIZE); 4971 data +
4972 IPW_RX_FRAME_SIZE);
4972 /* TODO: Check Ad-Hoc dest/source and make sure 4973 /* TODO: Check Ad-Hoc dest/source and make sure
4973 * that we are actually parsing these packets 4974 * that we are actually parsing these packets
4974 * correctly -- we should probably use the 4975 * correctly -- we should probably use the
@@ -5317,8 +5318,6 @@ static int ipw_wx_set_freq(struct net_device *dev,
5317 5318
5318 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); 5319 IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m);
5319 return ipw_set_channel(priv, (u8) fwrq->m); 5320 return ipw_set_channel(priv, (u8) fwrq->m);
5320
5321 return 0;
5322} 5321}
5323 5322
5324static int ipw_wx_get_freq(struct net_device *dev, 5323static int ipw_wx_get_freq(struct net_device *dev,
@@ -6010,12 +6009,12 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
6010 } 6009 }
6011 6010
6012 if (priv->adapter == IPW_2915ABG) { 6011 if (priv->adapter == IPW_2915ABG) {
6013 priv->ieee->abg_ture = 1; 6012 priv->ieee->abg_true = 1;
6014 if (mode & IEEE_A) { 6013 if (mode & IEEE_A) {
6015 band |= IEEE80211_52GHZ_BAND; 6014 band |= IEEE80211_52GHZ_BAND;
6016 modulation |= IEEE80211_OFDM_MODULATION; 6015 modulation |= IEEE80211_OFDM_MODULATION;
6017 } else 6016 } else
6018 priv->ieee->abg_ture = 0; 6017 priv->ieee->abg_true = 0;
6019 } else { 6018 } else {
6020 if (mode & IEEE_A) { 6019 if (mode & IEEE_A) {
6021 IPW_WARNING("Attempt to set 2200BG into " 6020 IPW_WARNING("Attempt to set 2200BG into "
@@ -6023,20 +6022,20 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev,
6023 return -EINVAL; 6022 return -EINVAL;
6024 } 6023 }
6025 6024
6026 priv->ieee->abg_ture = 0; 6025 priv->ieee->abg_true = 0;
6027 } 6026 }
6028 6027
6029 if (mode & IEEE_B) { 6028 if (mode & IEEE_B) {
6030 band |= IEEE80211_24GHZ_BAND; 6029 band |= IEEE80211_24GHZ_BAND;
6031 modulation |= IEEE80211_CCK_MODULATION; 6030 modulation |= IEEE80211_CCK_MODULATION;
6032 } else 6031 } else
6033 priv->ieee->abg_ture = 0; 6032 priv->ieee->abg_true = 0;
6034 6033
6035 if (mode & IEEE_G) { 6034 if (mode & IEEE_G) {
6036 band |= IEEE80211_24GHZ_BAND; 6035 band |= IEEE80211_24GHZ_BAND;
6037 modulation |= IEEE80211_OFDM_MODULATION; 6036 modulation |= IEEE80211_OFDM_MODULATION;
6038 } else 6037 } else
6039 priv->ieee->abg_ture = 0; 6038 priv->ieee->abg_true = 0;
6040 6039
6041 priv->ieee->mode = mode; 6040 priv->ieee->mode = mode;
6042 priv->ieee->freq_band = band; 6041 priv->ieee->freq_band = band;
@@ -6325,7 +6324,7 @@ we need to heavily modify the ieee80211_skb_to_txb.
6325 6324
6326static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) 6325static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6327{ 6326{
6328 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) 6327 struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)
6329 txb->fragments[0]->data; 6328 txb->fragments[0]->data;
6330 int i = 0; 6329 int i = 0;
6331 struct tfd_frame *tfd; 6330 struct tfd_frame *tfd;
@@ -6448,7 +6447,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb)
6448} 6447}
6449 6448
6450static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb, 6449static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb,
6451 struct net_device *dev) 6450 struct net_device *dev, int pri)
6452{ 6451{
6453 struct ipw_priv *priv = ieee80211_priv(dev); 6452 struct ipw_priv *priv = ieee80211_priv(dev);
6454 unsigned long flags; 6453 unsigned long flags;
@@ -7108,7 +7107,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7108 printk(KERN_INFO DRV_NAME 7107 printk(KERN_INFO DRV_NAME
7109 ": Detected Intel PRO/Wireless 2915ABG Network " 7108 ": Detected Intel PRO/Wireless 2915ABG Network "
7110 "Connection\n"); 7109 "Connection\n");
7111 priv->ieee->abg_ture = 1; 7110 priv->ieee->abg_true = 1;
7112 band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND; 7111 band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND;
7113 modulation = IEEE80211_OFDM_MODULATION | 7112 modulation = IEEE80211_OFDM_MODULATION |
7114 IEEE80211_CCK_MODULATION; 7113 IEEE80211_CCK_MODULATION;
@@ -7124,7 +7123,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7124 ": Detected Intel PRO/Wireless 2200BG Network " 7123 ": Detected Intel PRO/Wireless 2200BG Network "
7125 "Connection\n"); 7124 "Connection\n");
7126 7125
7127 priv->ieee->abg_ture = 0; 7126 priv->ieee->abg_true = 0;
7128 band = IEEE80211_24GHZ_BAND; 7127 band = IEEE80211_24GHZ_BAND;
7129 modulation = IEEE80211_OFDM_MODULATION | 7128 modulation = IEEE80211_OFDM_MODULATION |
7130 IEEE80211_CCK_MODULATION; 7129 IEEE80211_CCK_MODULATION;
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 5b00882133f9..e9cf32bf3e31 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -1654,12 +1654,12 @@ static const long ipw_frequencies[] = {
1654 1654
1655#define IPW_MAX_CONFIG_RETRIES 10 1655#define IPW_MAX_CONFIG_RETRIES 10
1656 1656
1657static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr) 1657static inline u32 frame_hdr_len(struct ieee80211_hdr_4addr *hdr)
1658{ 1658{
1659 u32 retval; 1659 u32 retval;
1660 u16 fc; 1660 u16 fc;
1661 1661
1662 retval = sizeof(struct ieee80211_hdr); 1662 retval = sizeof(struct ieee80211_hdr_3addr);
1663 fc = le16_to_cpu(hdr->frame_ctl); 1663 fc = le16_to_cpu(hdr->frame_ctl);
1664 1664
1665 /* 1665 /*
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index ca6c03c89926..92793b958e32 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -57,9 +57,7 @@
57#include <linux/bitops.h> 57#include <linux/bitops.h>
58#ifdef CONFIG_NET_RADIO 58#ifdef CONFIG_NET_RADIO
59#include <linux/wireless.h> 59#include <linux/wireless.h>
60#if WIRELESS_EXT > 12
61#include <net/iw_handler.h> 60#include <net/iw_handler.h>
62#endif /* WIRELESS_EXT > 12 */
63#endif 61#endif
64 62
65#include <pcmcia/cs_types.h> 63#include <pcmcia/cs_types.h>
@@ -225,10 +223,7 @@ static void update_stats(struct net_device *dev);
225static struct net_device_stats *netwave_get_stats(struct net_device *dev); 223static struct net_device_stats *netwave_get_stats(struct net_device *dev);
226 224
227/* Wireless extensions */ 225/* Wireless extensions */
228#ifdef WIRELESS_EXT
229static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev); 226static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
230#endif
231static int netwave_ioctl(struct net_device *, struct ifreq *, int);
232 227
233static void set_multicast_list(struct net_device *dev); 228static void set_multicast_list(struct net_device *dev);
234 229
@@ -260,26 +255,7 @@ static dev_link_t *dev_list;
260 because they generally can't be allocated dynamically. 255 because they generally can't be allocated dynamically.
261*/ 256*/
262 257
263#if WIRELESS_EXT <= 12
264/* Wireless extensions backward compatibility */
265
266/* Part of iw_handler prototype we need */
267struct iw_request_info
268{
269 __u16 cmd; /* Wireless Extension command */
270 __u16 flags; /* More to come ;-) */
271};
272
273/* Wireless Extension Backward compatibility - Jean II
274 * If the new wireless device private ioctl range is not defined,
275 * default to standard device private ioctl range */
276#ifndef SIOCIWFIRSTPRIV
277#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
278#endif /* SIOCIWFIRSTPRIV */
279
280#else /* WIRELESS_EXT <= 12 */
281static const struct iw_handler_def netwave_handler_def; 258static const struct iw_handler_def netwave_handler_def;
282#endif /* WIRELESS_EXT <= 12 */
283 259
284#define SIOCGIPSNAP SIOCIWFIRSTPRIV + 1 /* Site Survey Snapshot */ 260#define SIOCGIPSNAP SIOCIWFIRSTPRIV + 1 /* Site Survey Snapshot */
285 261
@@ -319,9 +295,7 @@ typedef struct netwave_private {
319 struct timer_list watchdog; /* To avoid blocking state */ 295 struct timer_list watchdog; /* To avoid blocking state */
320 struct site_survey nss; 296 struct site_survey nss;
321 struct net_device_stats stats; 297 struct net_device_stats stats;
322#ifdef WIRELESS_EXT
323 struct iw_statistics iw_stats; /* Wireless stats */ 298 struct iw_statistics iw_stats; /* Wireless stats */
324#endif
325} netwave_private; 299} netwave_private;
326 300
327#ifdef NETWAVE_STATS 301#ifdef NETWAVE_STATS
@@ -353,7 +327,6 @@ static inline void wait_WOC(unsigned int iobase)
353 while ((inb(iobase + NETWAVE_REG_ASR) & 0x8) != 0x8) ; 327 while ((inb(iobase + NETWAVE_REG_ASR) & 0x8) != 0x8) ;
354} 328}
355 329
356#ifdef WIRELESS_EXT
357static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase, 330static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase,
358 kio_addr_t iobase) { 331 kio_addr_t iobase) {
359 u_short resultBuffer; 332 u_short resultBuffer;
@@ -376,9 +349,7 @@ static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase,
376 sizeof(struct site_survey)); 349 sizeof(struct site_survey));
377 } 350 }
378} 351}
379#endif
380 352
381#ifdef WIRELESS_EXT
382/* 353/*
383 * Function netwave_get_wireless_stats (dev) 354 * Function netwave_get_wireless_stats (dev)
384 * 355 *
@@ -411,7 +382,6 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
411 382
412 return &priv->iw_stats; 383 return &priv->iw_stats;
413} 384}
414#endif
415 385
416/* 386/*
417 * Function netwave_attach (void) 387 * Function netwave_attach (void)
@@ -471,13 +441,7 @@ static dev_link_t *netwave_attach(void)
471 dev->get_stats = &netwave_get_stats; 441 dev->get_stats = &netwave_get_stats;
472 dev->set_multicast_list = &set_multicast_list; 442 dev->set_multicast_list = &set_multicast_list;
473 /* wireless extensions */ 443 /* wireless extensions */
474#if WIRELESS_EXT <= 16
475 dev->get_wireless_stats = &netwave_get_wireless_stats;
476#endif /* WIRELESS_EXT <= 16 */
477#if WIRELESS_EXT > 12
478 dev->wireless_handlers = (struct iw_handler_def *)&netwave_handler_def; 444 dev->wireless_handlers = (struct iw_handler_def *)&netwave_handler_def;
479#endif /* WIRELESS_EXT > 12 */
480 dev->do_ioctl = &netwave_ioctl;
481 445
482 dev->tx_timeout = &netwave_watchdog; 446 dev->tx_timeout = &netwave_watchdog;
483 dev->watchdog_timeo = TX_TIMEOUT; 447 dev->watchdog_timeo = TX_TIMEOUT;
@@ -576,13 +540,8 @@ static int netwave_set_nwid(struct net_device *dev,
576 /* Disable interrupts & save flags */ 540 /* Disable interrupts & save flags */
577 spin_lock_irqsave(&priv->spinlock, flags); 541 spin_lock_irqsave(&priv->spinlock, flags);
578 542
579#if WIRELESS_EXT > 8
580 if(!wrqu->nwid.disabled) { 543 if(!wrqu->nwid.disabled) {
581 domain = wrqu->nwid.value; 544 domain = wrqu->nwid.value;
582#else /* WIRELESS_EXT > 8 */
583 if(wrqu->nwid.on) {
584 domain = wrqu->nwid.nwid;
585#endif /* WIRELESS_EXT > 8 */
586 printk( KERN_DEBUG "Setting domain to 0x%x%02x\n", 545 printk( KERN_DEBUG "Setting domain to 0x%x%02x\n",
587 (domain >> 8) & 0x01, domain & 0xff); 546 (domain >> 8) & 0x01, domain & 0xff);
588 wait_WOC(iobase); 547 wait_WOC(iobase);
@@ -606,15 +565,9 @@ static int netwave_get_nwid(struct net_device *dev,
606 union iwreq_data *wrqu, 565 union iwreq_data *wrqu,
607 char *extra) 566 char *extra)
608{ 567{
609#if WIRELESS_EXT > 8
610 wrqu->nwid.value = domain; 568 wrqu->nwid.value = domain;
611 wrqu->nwid.disabled = 0; 569 wrqu->nwid.disabled = 0;
612 wrqu->nwid.fixed = 1; 570 wrqu->nwid.fixed = 1;
613#else /* WIRELESS_EXT > 8 */
614 wrqu->nwid.nwid = domain;
615 wrqu->nwid.on = 1;
616#endif /* WIRELESS_EXT > 8 */
617
618 return 0; 571 return 0;
619} 572}
620 573
@@ -657,17 +610,11 @@ static int netwave_get_scramble(struct net_device *dev,
657{ 610{
658 key[1] = scramble_key & 0xff; 611 key[1] = scramble_key & 0xff;
659 key[0] = (scramble_key>>8) & 0xff; 612 key[0] = (scramble_key>>8) & 0xff;
660#if WIRELESS_EXT > 8
661 wrqu->encoding.flags = IW_ENCODE_ENABLED; 613 wrqu->encoding.flags = IW_ENCODE_ENABLED;
662 wrqu->encoding.length = 2; 614 wrqu->encoding.length = 2;
663#else /* WIRELESS_EXT > 8 */
664 wrqu->encoding.method = 1;
665#endif /* WIRELESS_EXT > 8 */
666
667 return 0; 615 return 0;
668} 616}
669 617
670#if WIRELESS_EXT > 8
671/* 618/*
672 * Wireless Handler : get mode 619 * Wireless Handler : get mode
673 */ 620 */
@@ -683,7 +630,6 @@ static int netwave_get_mode(struct net_device *dev,
683 630
684 return 0; 631 return 0;
685} 632}
686#endif /* WIRELESS_EXT > 8 */
687 633
688/* 634/*
689 * Wireless Handler : get range info 635 * Wireless Handler : get range info
@@ -702,11 +648,9 @@ static int netwave_get_range(struct net_device *dev,
702 /* Set all the info we don't care or don't know about to zero */ 648 /* Set all the info we don't care or don't know about to zero */
703 memset(range, 0, sizeof(struct iw_range)); 649 memset(range, 0, sizeof(struct iw_range));
704 650
705#if WIRELESS_EXT > 10
706 /* Set the Wireless Extension versions */ 651 /* Set the Wireless Extension versions */
707 range->we_version_compiled = WIRELESS_EXT; 652 range->we_version_compiled = WIRELESS_EXT;
708 range->we_version_source = 9; /* Nothing for us in v10 and v11 */ 653 range->we_version_source = 9; /* Nothing for us in v10 and v11 */
709#endif /* WIRELESS_EXT > 10 */
710 654
711 /* Set information in the range struct */ 655 /* Set information in the range struct */
712 range->throughput = 450 * 1000; /* don't argue on this ! */ 656 range->throughput = 450 * 1000; /* don't argue on this ! */
@@ -720,16 +664,12 @@ static int netwave_get_range(struct net_device *dev,
720 range->max_qual.level = 255; 664 range->max_qual.level = 255;
721 range->max_qual.noise = 0; 665 range->max_qual.noise = 0;
722 666
723#if WIRELESS_EXT > 7
724 range->num_bitrates = 1; 667 range->num_bitrates = 1;
725 range->bitrate[0] = 1000000; /* 1 Mb/s */ 668 range->bitrate[0] = 1000000; /* 1 Mb/s */
726#endif /* WIRELESS_EXT > 7 */
727 669
728#if WIRELESS_EXT > 8
729 range->encoding_size[0] = 2; /* 16 bits scrambling */ 670 range->encoding_size[0] = 2; /* 16 bits scrambling */
730 range->num_encoding_sizes = 1; 671 range->num_encoding_sizes = 1;
731 range->max_encoding_tokens = 1; /* Only one key possible */ 672 range->max_encoding_tokens = 1; /* Only one key possible */
732#endif /* WIRELESS_EXT > 8 */
733 673
734 return ret; 674 return ret;
735} 675}
@@ -775,8 +715,6 @@ static const struct iw_priv_args netwave_private_args[] = {
775 "getsitesurvey" }, 715 "getsitesurvey" },
776}; 716};
777 717
778#if WIRELESS_EXT > 12
779
780static const iw_handler netwave_handler[] = 718static const iw_handler netwave_handler[] =
781{ 719{
782 NULL, /* SIOCSIWNAME */ 720 NULL, /* SIOCSIWNAME */
@@ -839,131 +777,8 @@ static const struct iw_handler_def netwave_handler_def =
839 .standard = (iw_handler *) netwave_handler, 777 .standard = (iw_handler *) netwave_handler,
840 .private = (iw_handler *) netwave_private_handler, 778 .private = (iw_handler *) netwave_private_handler,
841 .private_args = (struct iw_priv_args *) netwave_private_args, 779 .private_args = (struct iw_priv_args *) netwave_private_args,
842#if WIRELESS_EXT > 16
843 .get_wireless_stats = netwave_get_wireless_stats, 780 .get_wireless_stats = netwave_get_wireless_stats,
844#endif /* WIRELESS_EXT > 16 */
845}; 781};
846#endif /* WIRELESS_EXT > 12 */
847
848/*
849 * Function netwave_ioctl (dev, rq, cmd)
850 *
851 * Perform ioctl : config & info stuff
852 * This is the stuff that are treated the wireless extensions (iwconfig)
853 *
854 */
855static int netwave_ioctl(struct net_device *dev, /* ioctl device */
856 struct ifreq *rq, /* Data passed */
857 int cmd) /* Ioctl number */
858{
859 int ret = 0;
860#ifdef WIRELESS_EXT
861#if WIRELESS_EXT <= 12
862 struct iwreq *wrq = (struct iwreq *) rq;
863#endif
864#endif
865
866 DEBUG(0, "%s: ->netwave_ioctl(cmd=0x%X)\n", dev->name, cmd);
867
868 /* Look what is the request */
869 switch(cmd) {
870 /* --------------- WIRELESS EXTENSIONS --------------- */
871#ifdef WIRELESS_EXT
872#if WIRELESS_EXT <= 12
873 case SIOCGIWNAME:
874 netwave_get_name(dev, NULL, &(wrq->u), NULL);
875 break;
876 case SIOCSIWNWID:
877 ret = netwave_set_nwid(dev, NULL, &(wrq->u), NULL);
878 break;
879 case SIOCGIWNWID:
880 ret = netwave_get_nwid(dev, NULL, &(wrq->u), NULL);
881 break;
882#if WIRELESS_EXT > 8 /* Note : The API did change... */
883 case SIOCGIWENCODE:
884 /* Get scramble key */
885 if(wrq->u.encoding.pointer != (caddr_t) 0)
886 {
887 char key[2];
888 ret = netwave_get_scramble(dev, NULL, &(wrq->u), key);
889 if(copy_to_user(wrq->u.encoding.pointer, key, 2))
890 ret = -EFAULT;
891 }
892 break;
893 case SIOCSIWENCODE:
894 /* Set scramble key */
895 if(wrq->u.encoding.pointer != (caddr_t) 0)
896 {
897 char key[2];
898 if(copy_from_user(key, wrq->u.encoding.pointer, 2))
899 {
900 ret = -EFAULT;
901 break;
902 }
903 ret = netwave_set_scramble(dev, NULL, &(wrq->u), key);
904 }
905 break;
906 case SIOCGIWMODE:
907 /* Mode of operation */
908 ret = netwave_get_mode(dev, NULL, &(wrq->u), NULL);
909 break;
910#else /* WIRELESS_EXT > 8 */
911 case SIOCGIWENCODE:
912 /* Get scramble key */
913 ret = netwave_get_scramble(dev, NULL, &(wrq->u),
914 (char *) &wrq->u.encoding.code);
915 break;
916 case SIOCSIWENCODE:
917 /* Set scramble key */
918 ret = netwave_set_scramble(dev, NULL, &(wrq->u),
919 (char *) &wrq->u.encoding.code);
920 break;
921#endif /* WIRELESS_EXT > 8 */
922 case SIOCGIWRANGE:
923 /* Basic checking... */
924 if(wrq->u.data.pointer != (caddr_t) 0) {
925 struct iw_range range;
926 ret = netwave_get_range(dev, NULL, &(wrq->u), (char *) &range);
927 if (copy_to_user(wrq->u.data.pointer, &range,
928 sizeof(struct iw_range)))
929 ret = -EFAULT;
930 }
931 break;
932 case SIOCGIWPRIV:
933 /* Basic checking... */
934 if(wrq->u.data.pointer != (caddr_t) 0) {
935 /* Set the number of ioctl available */
936 wrq->u.data.length = sizeof(netwave_private_args) / sizeof(netwave_private_args[0]);
937
938 /* Copy structure to the user buffer */
939 if(copy_to_user(wrq->u.data.pointer,
940 (u_char *) netwave_private_args,
941 sizeof(netwave_private_args)))
942 ret = -EFAULT;
943 }
944 break;
945 case SIOCGIPSNAP:
946 if(wrq->u.data.pointer != (caddr_t) 0) {
947 char buffer[sizeof( struct site_survey)];
948 ret = netwave_get_snap(dev, NULL, &(wrq->u), buffer);
949 /* Copy structure to the user buffer */
950 if(copy_to_user(wrq->u.data.pointer,
951 buffer,
952 sizeof( struct site_survey)))
953 {
954 printk(KERN_DEBUG "Bad buffer!\n");
955 break;
956 }
957 }
958 break;
959#endif /* WIRELESS_EXT <= 12 */
960#endif /* WIRELESS_EXT */
961 default:
962 ret = -EOPNOTSUPP;
963 }
964
965 return ret;
966}
967 782
968/* 783/*
969 * Function netwave_pcmcia_config (link) 784 * Function netwave_pcmcia_config (link)
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 15ceaf615756..d3d4ec9e242e 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -77,30 +77,16 @@
77#define DRIVER_NAME "orinoco" 77#define DRIVER_NAME "orinoco"
78 78
79#include <linux/config.h> 79#include <linux/config.h>
80
81#include <linux/module.h> 80#include <linux/module.h>
82#include <linux/kernel.h> 81#include <linux/kernel.h>
83#include <linux/init.h> 82#include <linux/init.h>
84#include <linux/ptrace.h>
85#include <linux/slab.h>
86#include <linux/string.h>
87#include <linux/timer.h>
88#include <linux/ioport.h>
89#include <linux/netdevice.h> 83#include <linux/netdevice.h>
90#include <linux/if_arp.h>
91#include <linux/etherdevice.h> 84#include <linux/etherdevice.h>
92#include <linux/ethtool.h> 85#include <linux/ethtool.h>
93#include <linux/wireless.h> 86#include <linux/wireless.h>
94#include <net/iw_handler.h> 87#include <net/iw_handler.h>
95#include <net/ieee80211.h> 88#include <net/ieee80211.h>
96 89
97#include <net/ieee80211.h>
98
99#include <asm/uaccess.h>
100#include <asm/io.h>
101#include <asm/system.h>
102
103#include "hermes.h"
104#include "hermes_rid.h" 90#include "hermes_rid.h"
105#include "orinoco.h" 91#include "orinoco.h"
106 92
@@ -137,7 +123,7 @@ MODULE_PARM_DESC(force_monitor, "Allow monitor mode for all firmware versions");
137 123
138/* We do this this way to avoid ifdefs in the actual code */ 124/* We do this this way to avoid ifdefs in the actual code */
139#ifdef WIRELESS_SPY 125#ifdef WIRELESS_SPY
140#define SPY_NUMBER(priv) (priv->spy_number) 126#define SPY_NUMBER(priv) (priv->spy_data.spy_number)
141#else 127#else
142#define SPY_NUMBER(priv) 0 128#define SPY_NUMBER(priv) 0
143#endif /* WIRELESS_SPY */ 129#endif /* WIRELESS_SPY */
@@ -216,31 +202,32 @@ static struct {
216/********************************************************************/ 202/********************************************************************/
217 203
218/* Used in Event handling. 204/* Used in Event handling.
219 * We avoid nested structres as they break on ARM -- Moustafa */ 205 * We avoid nested structures as they break on ARM -- Moustafa */
220struct hermes_tx_descriptor_802_11 { 206struct hermes_tx_descriptor_802_11 {
221 /* hermes_tx_descriptor */ 207 /* hermes_tx_descriptor */
222 u16 status; 208 __le16 status;
223 u16 reserved1; 209 __le16 reserved1;
224 u16 reserved2; 210 __le16 reserved2;
225 u32 sw_support; 211 __le32 sw_support;
226 u8 retry_count; 212 u8 retry_count;
227 u8 tx_rate; 213 u8 tx_rate;
228 u16 tx_control; 214 __le16 tx_control;
229 215
230 /* ieee802_11_hdr */ 216 /* ieee80211_hdr */
231 u16 frame_ctl; 217 __le16 frame_ctl;
232 u16 duration_id; 218 __le16 duration_id;
233 u8 addr1[ETH_ALEN]; 219 u8 addr1[ETH_ALEN];
234 u8 addr2[ETH_ALEN]; 220 u8 addr2[ETH_ALEN];
235 u8 addr3[ETH_ALEN]; 221 u8 addr3[ETH_ALEN];
236 u16 seq_ctl; 222 __le16 seq_ctl;
237 u8 addr4[ETH_ALEN]; 223 u8 addr4[ETH_ALEN];
238 u16 data_len; 224
225 __le16 data_len;
239 226
240 /* ethhdr */ 227 /* ethhdr */
241 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 228 u8 h_dest[ETH_ALEN]; /* destination eth addr */
242 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 229 u8 h_source[ETH_ALEN]; /* source ether addr */
243 unsigned short h_proto; /* packet type ID field */ 230 __be16 h_proto; /* packet type ID field */
244 231
245 /* p8022_hdr */ 232 /* p8022_hdr */
246 u8 dsap; 233 u8 dsap;
@@ -248,31 +235,31 @@ struct hermes_tx_descriptor_802_11 {
248 u8 ctrl; 235 u8 ctrl;
249 u8 oui[3]; 236 u8 oui[3];
250 237
251 u16 ethertype; 238 __be16 ethertype;
252} __attribute__ ((packed)); 239} __attribute__ ((packed));
253 240
254/* Rx frame header except compatibility 802.3 header */ 241/* Rx frame header except compatibility 802.3 header */
255struct hermes_rx_descriptor { 242struct hermes_rx_descriptor {
256 /* Control */ 243 /* Control */
257 u16 status; 244 __le16 status;
258 u32 time; 245 __le32 time;
259 u8 silence; 246 u8 silence;
260 u8 signal; 247 u8 signal;
261 u8 rate; 248 u8 rate;
262 u8 rxflow; 249 u8 rxflow;
263 u32 reserved; 250 __le32 reserved;
264 251
265 /* 802.11 header */ 252 /* 802.11 header */
266 u16 frame_ctl; 253 __le16 frame_ctl;
267 u16 duration_id; 254 __le16 duration_id;
268 u8 addr1[ETH_ALEN]; 255 u8 addr1[ETH_ALEN];
269 u8 addr2[ETH_ALEN]; 256 u8 addr2[ETH_ALEN];
270 u8 addr3[ETH_ALEN]; 257 u8 addr3[ETH_ALEN];
271 u16 seq_ctl; 258 __le16 seq_ctl;
272 u8 addr4[ETH_ALEN]; 259 u8 addr4[ETH_ALEN];
273 260
274 /* Data length */ 261 /* Data length */
275 u16 data_len; 262 __le16 data_len;
276} __attribute__ ((packed)); 263} __attribute__ ((packed));
277 264
278/********************************************************************/ 265/********************************************************************/
@@ -396,14 +383,14 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
396 /* If a spy address is defined, we report stats of the 383 /* If a spy address is defined, we report stats of the
397 * first spy address - Jean II */ 384 * first spy address - Jean II */
398 if (SPY_NUMBER(priv)) { 385 if (SPY_NUMBER(priv)) {
399 wstats->qual.qual = priv->spy_stat[0].qual; 386 wstats->qual.qual = priv->spy_data.spy_stat[0].qual;
400 wstats->qual.level = priv->spy_stat[0].level; 387 wstats->qual.level = priv->spy_data.spy_stat[0].level;
401 wstats->qual.noise = priv->spy_stat[0].noise; 388 wstats->qual.noise = priv->spy_data.spy_stat[0].noise;
402 wstats->qual.updated = priv->spy_stat[0].updated; 389 wstats->qual.updated = priv->spy_data.spy_stat[0].updated;
403 } 390 }
404 } else { 391 } else {
405 struct { 392 struct {
406 u16 qual, signal, noise; 393 __le16 qual, signal, noise;
407 } __attribute__ ((packed)) cq; 394 } __attribute__ ((packed)) cq;
408 395
409 err = HERMES_READ_RECORD(hw, USER_BAP, 396 err = HERMES_READ_RECORD(hw, USER_BAP,
@@ -505,11 +492,9 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
505 492
506 /* Check packet length, pad short packets, round up odd length */ 493 /* Check packet length, pad short packets, round up odd length */
507 len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN); 494 len = max_t(int, ALIGN(skb->len, 2), ETH_ZLEN);
508 if (skb->len < len) { 495 skb = skb_padto(skb, len);
509 skb = skb_padto(skb, len); 496 if (skb == NULL)
510 if (skb == NULL) 497 goto fail;
511 goto fail;
512 }
513 len -= ETH_HLEN; 498 len -= ETH_HLEN;
514 499
515 eh = (struct ethhdr *)skb->data; 500 eh = (struct ethhdr *)skb->data;
@@ -634,16 +619,17 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
634 struct orinoco_private *priv = netdev_priv(dev); 619 struct orinoco_private *priv = netdev_priv(dev);
635 struct net_device_stats *stats = &priv->stats; 620 struct net_device_stats *stats = &priv->stats;
636 u16 fid = hermes_read_regn(hw, TXCOMPLFID); 621 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
622 u16 status;
637 struct hermes_tx_descriptor_802_11 hdr; 623 struct hermes_tx_descriptor_802_11 hdr;
638 int err = 0; 624 int err = 0;
639 625
640 if (fid == DUMMY_FID) 626 if (fid == DUMMY_FID)
641 return; /* Nothing's really happened */ 627 return; /* Nothing's really happened */
642 628
643 /* Read the frame header */ 629 /* Read part of the frame header - we need status and addr1 */
644 err = hermes_bap_pread(hw, IRQ_BAP, &hdr, 630 err = hermes_bap_pread(hw, IRQ_BAP, &hdr,
645 sizeof(struct hermes_tx_descriptor) + 631 offsetof(struct hermes_tx_descriptor_802_11,
646 sizeof(struct ieee80211_hdr), 632 addr2),
647 fid, 0); 633 fid, 0);
648 634
649 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID); 635 hermes_write_regn(hw, TXCOMPLFID, DUMMY_FID);
@@ -663,8 +649,8 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw)
663 * exceeded, because that's the only status that really mean 649 * exceeded, because that's the only status that really mean
664 * that this particular node went away. 650 * that this particular node went away.
665 * Other errors means that *we* screwed up. - Jean II */ 651 * Other errors means that *we* screwed up. - Jean II */
666 hdr.status = le16_to_cpu(hdr.status); 652 status = le16_to_cpu(hdr.status);
667 if (hdr.status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) { 653 if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
668 union iwreq_data wrqu; 654 union iwreq_data wrqu;
669 655
670 /* Copy 802.11 dest address. 656 /* Copy 802.11 dest address.
@@ -723,18 +709,13 @@ static inline int is_ethersnap(void *_hdr)
723static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac, 709static inline void orinoco_spy_gather(struct net_device *dev, u_char *mac,
724 int level, int noise) 710 int level, int noise)
725{ 711{
726 struct orinoco_private *priv = netdev_priv(dev); 712 struct iw_quality wstats;
727 int i; 713 wstats.level = level - 0x95;
728 714 wstats.noise = noise - 0x95;
729 /* Gather wireless spy statistics: for each packet, compare the 715 wstats.qual = (level > noise) ? (level - noise) : 0;
730 * source address with out list, and if match, get the stats... */ 716 wstats.updated = 7;
731 for (i = 0; i < priv->spy_number; i++) 717 /* Update spy records */
732 if (!memcmp(mac, priv->spy_address[i], ETH_ALEN)) { 718 wireless_spy_update(dev, mac, &wstats);
733 priv->spy_stat[i].level = level - 0x95;
734 priv->spy_stat[i].noise = noise - 0x95;
735 priv->spy_stat[i].qual = (level > noise) ? (level - noise) : 0;
736 priv->spy_stat[i].updated = 7;
737 }
738} 719}
739 720
740static void orinoco_stat_gather(struct net_device *dev, 721static void orinoco_stat_gather(struct net_device *dev,
@@ -1055,7 +1036,7 @@ static void orinoco_join_ap(struct net_device *dev)
1055 unsigned long flags; 1036 unsigned long flags;
1056 struct join_req { 1037 struct join_req {
1057 u8 bssid[ETH_ALEN]; 1038 u8 bssid[ETH_ALEN];
1058 u16 channel; 1039 __le16 channel;
1059 } __attribute__ ((packed)) req; 1040 } __attribute__ ((packed)) req;
1060 const int atom_len = offsetof(struct prism2_scan_apinfo, atim); 1041 const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
1061 struct prism2_scan_apinfo *atom = NULL; 1042 struct prism2_scan_apinfo *atom = NULL;
@@ -1070,7 +1051,7 @@ static void orinoco_join_ap(struct net_device *dev)
1070 return; 1051 return;
1071 1052
1072 if (orinoco_lock(priv, &flags) != 0) 1053 if (orinoco_lock(priv, &flags) != 0)
1073 goto out; 1054 goto fail_lock;
1074 1055
1075 /* Sanity checks in case user changed something in the meantime */ 1056 /* Sanity checks in case user changed something in the meantime */
1076 if (! priv->bssid_fixed) 1057 if (! priv->bssid_fixed)
@@ -1115,8 +1096,10 @@ static void orinoco_join_ap(struct net_device *dev)
1115 printk(KERN_ERR "%s: Error issuing join request\n", dev->name); 1096 printk(KERN_ERR "%s: Error issuing join request\n", dev->name);
1116 1097
1117 out: 1098 out:
1118 kfree(buf);
1119 orinoco_unlock(priv, &flags); 1099 orinoco_unlock(priv, &flags);
1100
1101 fail_lock:
1102 kfree(buf);
1120} 1103}
1121 1104
1122/* Send new BSSID to userspace */ 1105/* Send new BSSID to userspace */
@@ -1134,12 +1117,14 @@ static void orinoco_send_wevents(struct net_device *dev)
1134 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENTBSSID, 1117 err = hermes_read_ltv(hw, IRQ_BAP, HERMES_RID_CURRENTBSSID,
1135 ETH_ALEN, NULL, wrqu.ap_addr.sa_data); 1118 ETH_ALEN, NULL, wrqu.ap_addr.sa_data);
1136 if (err != 0) 1119 if (err != 0)
1137 return; 1120 goto out;
1138 1121
1139 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 1122 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1140 1123
1141 /* Send event to user space */ 1124 /* Send event to user space */
1142 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); 1125 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
1126
1127 out:
1143 orinoco_unlock(priv, &flags); 1128 orinoco_unlock(priv, &flags);
1144} 1129}
1145 1130
@@ -1148,8 +1133,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw)
1148 struct orinoco_private *priv = netdev_priv(dev); 1133 struct orinoco_private *priv = netdev_priv(dev);
1149 u16 infofid; 1134 u16 infofid;
1150 struct { 1135 struct {
1151 u16 len; 1136 __le16 len;
1152 u16 type; 1137 __le16 type;
1153 } __attribute__ ((packed)) info; 1138 } __attribute__ ((packed)) info;
1154 int len, type; 1139 int len, type;
1155 int err; 1140 int err;
@@ -2464,6 +2449,10 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2464 dev->get_stats = orinoco_get_stats; 2449 dev->get_stats = orinoco_get_stats;
2465 dev->ethtool_ops = &orinoco_ethtool_ops; 2450 dev->ethtool_ops = &orinoco_ethtool_ops;
2466 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def; 2451 dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def;
2452#ifdef WIRELESS_SPY
2453 priv->wireless_data.spy_data = &priv->spy_data;
2454 dev->wireless_data = &priv->wireless_data;
2455#endif
2467 dev->change_mtu = orinoco_change_mtu; 2456 dev->change_mtu = orinoco_change_mtu;
2468 dev->set_multicast_list = orinoco_set_multicast_list; 2457 dev->set_multicast_list = orinoco_set_multicast_list;
2469 /* we use the default eth_mac_addr for setting the MAC addr */ 2458 /* we use the default eth_mac_addr for setting the MAC addr */
@@ -2835,7 +2824,7 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
2835 } 2824 }
2836 } 2825 }
2837 2826
2838 if ((priv->iw_mode == IW_MODE_ADHOC) && (priv->spy_number == 0)){ 2827 if ((priv->iw_mode == IW_MODE_ADHOC) && (!SPY_NUMBER(priv))){
2839 /* Quality stats meaningless in ad-hoc mode */ 2828 /* Quality stats meaningless in ad-hoc mode */
2840 } else { 2829 } else {
2841 range->max_qual.qual = 0x8b - 0x2f; 2830 range->max_qual.qual = 0x8b - 0x2f;
@@ -2882,6 +2871,14 @@ static int orinoco_ioctl_getiwrange(struct net_device *dev,
2882 range->min_r_time = 0; 2871 range->min_r_time = 0;
2883 range->max_r_time = 65535 * 1000; /* ??? */ 2872 range->max_r_time = 65535 * 1000; /* ??? */
2884 2873
2874 /* Event capability (kernel) */
2875 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
2876 /* Event capability (driver) */
2877 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
2878 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
2879 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
2880 IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
2881
2885 TRACE_EXIT(dev->name); 2882 TRACE_EXIT(dev->name);
2886 2883
2887 return 0; 2884 return 0;
@@ -3841,92 +3838,6 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
3841 return err; 3838 return err;
3842} 3839}
3843 3840
3844/* Spy is used for link quality/strength measurements in Ad-Hoc mode
3845 * Jean II */
3846static int orinoco_ioctl_setspy(struct net_device *dev,
3847 struct iw_request_info *info,
3848 struct iw_point *srq,
3849 char *extra)
3850
3851{
3852 struct orinoco_private *priv = netdev_priv(dev);
3853 struct sockaddr *address = (struct sockaddr *) extra;
3854 int number = srq->length;
3855 int i;
3856 unsigned long flags;
3857
3858 /* Make sure nobody mess with the structure while we do */
3859 if (orinoco_lock(priv, &flags) != 0)
3860 return -EBUSY;
3861
3862 /* orinoco_lock() doesn't disable interrupts, so make sure the
3863 * interrupt rx path don't get confused while we copy */
3864 priv->spy_number = 0;
3865
3866 if (number > 0) {
3867 /* Extract the addresses */
3868 for (i = 0; i < number; i++)
3869 memcpy(priv->spy_address[i], address[i].sa_data,
3870 ETH_ALEN);
3871 /* Reset stats */
3872 memset(priv->spy_stat, 0,
3873 sizeof(struct iw_quality) * IW_MAX_SPY);
3874 /* Set number of addresses */
3875 priv->spy_number = number;
3876 }
3877
3878 /* Now, let the others play */
3879 orinoco_unlock(priv, &flags);
3880
3881 /* Do NOT call commit handler */
3882 return 0;
3883}
3884
3885static int orinoco_ioctl_getspy(struct net_device *dev,
3886 struct iw_request_info *info,
3887 struct iw_point *srq,
3888 char *extra)
3889{
3890 struct orinoco_private *priv = netdev_priv(dev);
3891 struct sockaddr *address = (struct sockaddr *) extra;
3892 int number;
3893 int i;
3894 unsigned long flags;
3895
3896 if (orinoco_lock(priv, &flags) != 0)
3897 return -EBUSY;
3898
3899 number = priv->spy_number;
3900 /* Create address struct */
3901 for (i = 0; i < number; i++) {
3902 memcpy(address[i].sa_data, priv->spy_address[i], ETH_ALEN);
3903 address[i].sa_family = AF_UNIX;
3904 }
3905 if (number > 0) {
3906 /* Create address struct */
3907 for (i = 0; i < number; i++) {
3908 memcpy(address[i].sa_data, priv->spy_address[i],
3909 ETH_ALEN);
3910 address[i].sa_family = AF_UNIX;
3911 }
3912 /* Copy stats */
3913 /* In theory, we should disable irqs while copying the stats
3914 * because the rx path might update it in the middle...
3915 * Bah, who care ? - Jean II */
3916 memcpy(extra + (sizeof(struct sockaddr) * number),
3917 priv->spy_stat, sizeof(struct iw_quality) * number);
3918 }
3919 /* Reset updated flags. */
3920 for (i = 0; i < number; i++)
3921 priv->spy_stat[i].updated = 0;
3922
3923 orinoco_unlock(priv, &flags);
3924
3925 srq->length = number;
3926
3927 return 0;
3928}
3929
3930/* Trigger a scan (look for other cells in the vicinity */ 3841/* Trigger a scan (look for other cells in the vicinity */
3931static int orinoco_ioctl_setscan(struct net_device *dev, 3842static int orinoco_ioctl_setscan(struct net_device *dev,
3932 struct iw_request_info *info, 3843 struct iw_request_info *info,
@@ -3999,7 +3910,7 @@ static int orinoco_ioctl_setscan(struct net_device *dev,
3999 HERMES_HOSTSCAN_SYMBOL_BCAST); 3910 HERMES_HOSTSCAN_SYMBOL_BCAST);
4000 break; 3911 break;
4001 case FIRMWARE_TYPE_INTERSIL: { 3912 case FIRMWARE_TYPE_INTERSIL: {
4002 u16 req[3]; 3913 __le16 req[3];
4003 3914
4004 req[0] = cpu_to_le16(0x3fff); /* All channels */ 3915 req[0] = cpu_to_le16(0x3fff); /* All channels */
4005 req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */ 3916 req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */
@@ -4073,7 +3984,7 @@ static inline int orinoco_translate_scan(struct net_device *dev,
4073 case FIRMWARE_TYPE_INTERSIL: 3984 case FIRMWARE_TYPE_INTERSIL:
4074 offset = 4; 3985 offset = 4;
4075 if (priv->has_hostscan) { 3986 if (priv->has_hostscan) {
4076 atom_len = le16_to_cpup((u16 *)scan); 3987 atom_len = le16_to_cpup((__le16 *)scan);
4077 /* Sanity check for atom_len */ 3988 /* Sanity check for atom_len */
4078 if (atom_len < sizeof(struct prism2_scan_apinfo)) { 3989 if (atom_len < sizeof(struct prism2_scan_apinfo)) {
4079 printk(KERN_ERR "%s: Invalid atom_len in scan data: %d\n", 3990 printk(KERN_ERR "%s: Invalid atom_len in scan data: %d\n",
@@ -4357,8 +4268,10 @@ static const iw_handler orinoco_handler[] = {
4357 [SIOCSIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setsens, 4268 [SIOCSIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setsens,
4358 [SIOCGIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getsens, 4269 [SIOCGIWSENS -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getsens,
4359 [SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getiwrange, 4270 [SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getiwrange,
4360 [SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setspy, 4271 [SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_set_spy,
4361 [SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getspy, 4272 [SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_get_spy,
4273 [SIOCSIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy,
4274 [SIOCGIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy,
4362 [SIOCSIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setwap, 4275 [SIOCSIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setwap,
4363 [SIOCGIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getwap, 4276 [SIOCGIWAP -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_getwap,
4364 [SIOCSIWSCAN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setscan, 4277 [SIOCSIWSCAN -SIOCIWFIRST] = (iw_handler) orinoco_ioctl_setscan,
diff --git a/drivers/net/wireless/orinoco.h b/drivers/net/wireless/orinoco.h
index 2f213a7103fe..7a17bb31fc89 100644
--- a/drivers/net/wireless/orinoco.h
+++ b/drivers/net/wireless/orinoco.h
@@ -7,12 +7,11 @@
7#ifndef _ORINOCO_H 7#ifndef _ORINOCO_H
8#define _ORINOCO_H 8#define _ORINOCO_H
9 9
10#define DRIVER_VERSION "0.15rc2" 10#define DRIVER_VERSION "0.15rc3"
11 11
12#include <linux/types.h>
13#include <linux/spinlock.h>
14#include <linux/netdevice.h> 12#include <linux/netdevice.h>
15#include <linux/wireless.h> 13#include <linux/wireless.h>
14#include <net/iw_handler.h>
16#include <linux/version.h> 15#include <linux/version.h>
17 16
18#include "hermes.h" 17#include "hermes.h"
@@ -28,7 +27,7 @@
28#define ORINOCO_MAX_KEYS 4 27#define ORINOCO_MAX_KEYS 4
29 28
30struct orinoco_key { 29struct orinoco_key {
31 u16 len; /* always stored as little-endian */ 30 __le16 len; /* always stored as little-endian */
32 char data[ORINOCO_MAX_KEY_SIZE]; 31 char data[ORINOCO_MAX_KEY_SIZE];
33} __attribute__ ((packed)); 32} __attribute__ ((packed));
34 33
@@ -36,14 +35,14 @@ struct header_struct {
36 /* 802.3 */ 35 /* 802.3 */
37 u8 dest[ETH_ALEN]; 36 u8 dest[ETH_ALEN];
38 u8 src[ETH_ALEN]; 37 u8 src[ETH_ALEN];
39 u16 len; 38 __be16 len;
40 /* 802.2 */ 39 /* 802.2 */
41 u8 dsap; 40 u8 dsap;
42 u8 ssap; 41 u8 ssap;
43 u8 ctrl; 42 u8 ctrl;
44 /* SNAP */ 43 /* SNAP */
45 u8 oui[3]; 44 u8 oui[3];
46 u16 ethertype; 45 unsigned short ethertype;
47} __attribute__ ((packed)); 46} __attribute__ ((packed));
48 47
49typedef enum { 48typedef enum {
@@ -112,9 +111,8 @@ struct orinoco_private {
112 u16 pm_on, pm_mcast, pm_period, pm_timeout; 111 u16 pm_on, pm_mcast, pm_period, pm_timeout;
113 u16 preamble; 112 u16 preamble;
114#ifdef WIRELESS_SPY 113#ifdef WIRELESS_SPY
115 int spy_number; 114 struct iw_spy_data spy_data; /* iwspy support */
116 u_char spy_address[IW_MAX_SPY][ETH_ALEN]; 115 struct iw_public_data wireless_data;
117 struct iw_quality spy_stat[IW_MAX_SPY];
118#endif 116#endif
119 117
120 /* Configuration dependent variables */ 118 /* Configuration dependent variables */
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index bedd7f9f23e4..dc1128a00971 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -14,33 +14,16 @@
14#define PFX DRIVER_NAME ": " 14#define PFX DRIVER_NAME ": "
15 15
16#include <linux/config.h> 16#include <linux/config.h>
17#ifdef __IN_PCMCIA_PACKAGE__
18#include <pcmcia/k_compat.h>
19#endif /* __IN_PCMCIA_PACKAGE__ */
20
21#include <linux/module.h> 17#include <linux/module.h>
22#include <linux/kernel.h> 18#include <linux/kernel.h>
23#include <linux/init.h> 19#include <linux/init.h>
24#include <linux/sched.h> 20#include <linux/delay.h>
25#include <linux/ptrace.h>
26#include <linux/slab.h>
27#include <linux/string.h>
28#include <linux/ioport.h>
29#include <linux/netdevice.h>
30#include <linux/if_arp.h>
31#include <linux/etherdevice.h>
32#include <linux/wireless.h>
33
34#include <pcmcia/cs_types.h> 21#include <pcmcia/cs_types.h>
35#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
36#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
37#include <pcmcia/cisreg.h> 24#include <pcmcia/cisreg.h>
38#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
39 26
40#include <asm/uaccess.h>
41#include <asm/io.h>
42#include <asm/system.h>
43
44#include "orinoco.h" 27#include "orinoco.h"
45 28
46/********************************************************************/ 29/********************************************************************/
@@ -97,17 +80,8 @@ static dev_link_t *dev_list; /* = NULL */
97/* Function prototypes */ 80/* Function prototypes */
98/********************************************************************/ 81/********************************************************************/
99 82
100/* device methods */ 83static void orinoco_cs_release(dev_link_t *link);
101static int orinoco_cs_hard_reset(struct orinoco_private *priv); 84static void orinoco_cs_detach(dev_link_t *link);
102
103/* PCMCIA gumpf */
104static void orinoco_cs_config(dev_link_t * link);
105static void orinoco_cs_release(dev_link_t * link);
106static int orinoco_cs_event(event_t event, int priority,
107 event_callback_args_t * args);
108
109static dev_link_t *orinoco_cs_attach(void);
110static void orinoco_cs_detach(dev_link_t *);
111 85
112/********************************************************************/ 86/********************************************************************/
113/* Device methods */ 87/* Device methods */
@@ -603,49 +577,85 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
603 "Pavel Roskin <proski@gnu.org>, et al)"; 577 "Pavel Roskin <proski@gnu.org>, et al)";
604 578
605static struct pcmcia_device_id orinoco_cs_ids[] = { 579static struct pcmcia_device_id orinoco_cs_ids[] = {
606 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), 580 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), /* SonicWALL Long Range Wireless Card */
607 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), 581 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), /* Sohoware NCP110, Philips 802.11b */
608 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), 582 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), /* AnyPoint(TM) Wireless II PC Card */
609 PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), 583 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */
610 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), 584 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000), /* PROXIM RangeLAN-DS/LAN PC CARD */
611 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), 585 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), /* Compaq WL100 11 Mbps Wireless Adapter */
612 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), 586 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), /* Lucent Orinoco and old Intersil */
613 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), 587 PCMCIA_DEVICE_MANF_CARD(0x016b, 0x0001), /* Ericsson WLAN Card C11 */
614 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), 588 PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), /* Nortel Networks eMobility 802.11 Wireless Adapter */
615 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), 589 PCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), /* Intermec MobileLAN 11Mbps 802.11b WLAN Card */
616 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), 590 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
617 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), 591 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */
618 PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), 592 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */
619 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), 593 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */
620 PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), 594 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
621 PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), 595 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
622 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), 596 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), /* Compaq HNW-100 11 Mbps Wireless Adapter */
623 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), 597 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), /* Linksys WCF12 Wireless CompactFlash Card */
598 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), /* ASUS SpaceLink WL-100 */
599 PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), /* SpeedStream SS1021 Wireless Adapter */
600 PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), /* PLANEX RoadLannerWave GW-NS11H */
601 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), /* Airvast WN-100 */
602 PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), /* Adaptec Ultra Wireless ANW-8030 */
603 PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), /* CONTEC FLEXSCAN/FX-DDS110-PCC */
604 PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), /* Conceptronic CON11Cpro, EMTAC A2424i */
605 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), /* Safeway 802.11b, ZCOMAX AirRunner/XI-300 */
606 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), /* D-Link DCF660, Sandisk Connect SDWCFB-000 */
607 PCMCIA_DEVICE_PROD_ID12(" ", "IEEE 802.11 Wireless LAN/PC Card", 0x3b6e20c8, 0xefccafe9),
624 PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), 608 PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3),
625 PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
626 PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), 609 PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5),
610 PCMCIA_DEVICE_PROD_ID12("Addtron", "AWP-100 Wireless PCMCIA", 0xe6ec52ce, 0x08649af2),
611 PCMCIA_DEVICE_PROD_ID123("AIRVAST", "IEEE 802.11b Wireless PCMCIA Card", "HFA3863", 0xea569531, 0x4bcb9645, 0x355cb092),
612 PCMCIA_DEVICE_PROD_ID12("Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio", 0x5cd01705, 0x4271660f),
613 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842),
614 PCMCIA_DEVICE_PROD_ID12("ASUS", "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e),
627 PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), 615 PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169),
616 PCMCIA_DEVICE_PROD_ID12("BENQ", "AWL100 PCMCIA ADAPTER", 0x35dadc74, 0x01f7fedb),
628 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), 617 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3),
618 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 0x2decece3, 0x82067c18),
629 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), 619 PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90),
620 PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card", 0x54f7c49c, 0x15a75e5b),
621 PCMCIA_DEVICE_PROD_ID123("corega", "WL PCCL-11", "ISL37300P", 0x0a21501a, 0x59868926, 0xc9049a39),
630 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), 622 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584),
631 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), 623 PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9),
632 PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae), 624 PCMCIA_DEVICE_PROD_ID12("corega_K.K.", "Wireless_LAN_PCCB-11", 0x29e33311, 0xee7a27ae),
633 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), 625 PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac),
634 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), 626 PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab),
627 PCMCIA_DEVICE_PROD_ID12("D-Link Corporation", "D-Link DWL-650H 11Mbps WLAN Adapter", 0xef544d24, 0xcd8ea916),
628 PCMCIA_DEVICE_PROD_ID12("Digital Data Communications", "WPC-0100", 0xfdd73470, 0xe0b6f146),
635 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), 629 PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3),
636 PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), 630 PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c),
631 PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0),
632 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless 2011 LAN PC Card", 0x816cc815, 0x07f58077),
637 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), 633 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18),
634 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "I-GATE 11M PC Card / PC Card plus", 0x74c5e40d, 0x8304ff77),
635 PCMCIA_DEVICE_PROD_ID12("Intersil", "PRISM 2_5 PCMCIA ADAPTER", 0x4b801a17, 0x6345a0bf),
636 PCMCIA_DEVICE_PROD_ID123("Intersil", "PRISM Freedom PCMCIA Adapter", "ISL37100P", 0x4b801a17, 0xf222ec2d, 0x630d52b2),
637 PCMCIA_DEVICE_PROD_ID12("LeArtery", "SYNCBYAIR 11Mbps Wireless LAN PC Card", 0x7e3b326a, 0x49893e92),
638 PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card", 0x0733cc81, 0x0c52f395),
638 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), 639 PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a),
639 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), 640 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410),
640 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), 641 PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3),
641 PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), 642 PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01),
642 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), 643 PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a),
644 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401 Wireless PC", "Card", 0xa37434e9, 0x9762e8f1),
643 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), 645 PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1),
646 PCMCIA_DEVICE_PROD_ID12("Nortel Networks", "emobility 802.11 Wireless LAN PC Card", 0x2d617ea0, 0x88cd5767),
647 PCMCIA_DEVICE_PROD_ID12("OEM", "PRISM2 IEEE 802.11 PC-Card", 0xfea54c90, 0x48f2bdd6),
648 PCMCIA_DEVICE_PROD_ID12("OTC", "Wireless AirEZY 2411-PCC WLAN Card", 0x4ac44287, 0x235a6bed),
649 PCMCIA_DEVICE_PROD_ID123("PCMCIA", "11M WLAN Card v2.5", "ISL37300P", 0x281f1c5d, 0x6e440487, 0xc9049a39),
644 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), 650 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264),
651 PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-NS110", 0x209f40ab, 0x46263178),
645 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), 652 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9),
646 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), 653 PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26),
647 PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), 654 PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b),
648 PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6), 655 PCMCIA_DEVICE_PROD_ID12("SMC", "SMC2632W", 0xc4f8b18b, 0x474a1f2a),
656 PCMCIA_DEVICE_PROD_ID12("Symbol Technologies", "LA4111 Spectrum24 Wireless LAN PC Card", 0x3f02b4d6, 0x3663cb0e),
657 PCMCIA_DEVICE_PROD_ID123("The Linksys Group, Inc.", "Instant Wireless Network PC Card", "ISL37300P", 0xa5f472c2, 0x590eb502, 0xc9049a39),
658 PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High", "Rate wireless Networking", 0x273fe3db, 0x32a1eaee),
649 PCMCIA_DEVICE_NULL, 659 PCMCIA_DEVICE_NULL,
650}; 660};
651MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids); 661MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids);
@@ -656,8 +666,8 @@ static struct pcmcia_driver orinoco_driver = {
656 .name = DRIVER_NAME, 666 .name = DRIVER_NAME,
657 }, 667 },
658 .attach = orinoco_cs_attach, 668 .attach = orinoco_cs_attach,
659 .event = orinoco_cs_event,
660 .detach = orinoco_cs_detach, 669 .detach = orinoco_cs_detach,
670 .event = orinoco_cs_event,
661 .id_table = orinoco_cs_ids, 671 .id_table = orinoco_cs_ids,
662}; 672};
663 673
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index 86fa58e5cfac..d8afd51ff8a5 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -40,29 +40,13 @@
40#define PFX DRIVER_NAME ": " 40#define PFX DRIVER_NAME ": "
41 41
42#include <linux/config.h> 42#include <linux/config.h>
43
44#include <linux/module.h> 43#include <linux/module.h>
45#include <linux/kernel.h> 44#include <linux/kernel.h>
46#include <linux/init.h> 45#include <linux/init.h>
47#include <linux/sched.h> 46#include <linux/delay.h>
48#include <linux/ptrace.h>
49#include <linux/slab.h>
50#include <linux/string.h>
51#include <linux/timer.h>
52#include <linux/ioport.h>
53#include <asm/uaccess.h>
54#include <asm/io.h>
55#include <asm/system.h>
56#include <linux/netdevice.h>
57#include <linux/if_arp.h>
58#include <linux/etherdevice.h>
59#include <linux/list.h>
60#include <linux/pci.h> 47#include <linux/pci.h>
61#include <linux/fcntl.h>
62
63#include <pcmcia/cisreg.h> 48#include <pcmcia/cisreg.h>
64 49
65#include "hermes.h"
66#include "orinoco.h" 50#include "orinoco.h"
67 51
68#define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */ 52#define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
@@ -108,7 +92,7 @@ static int nortel_pci_cor_reset(struct orinoco_private *priv)
108 return 0; 92 return 0;
109} 93}
110 94
111int nortel_pci_hw_init(struct nortel_pci_card *card) 95static int nortel_pci_hw_init(struct nortel_pci_card *card)
112{ 96{
113 int i; 97 int i;
114 u32 reg; 98 u32 reg;
diff --git a/drivers/net/wireless/orinoco_pci.c b/drivers/net/wireless/orinoco_pci.c
index 42e03438291b..5362c214fc8e 100644
--- a/drivers/net/wireless/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco_pci.c
@@ -93,28 +93,12 @@
93#define PFX DRIVER_NAME ": " 93#define PFX DRIVER_NAME ": "
94 94
95#include <linux/config.h> 95#include <linux/config.h>
96
97#include <linux/module.h> 96#include <linux/module.h>
98#include <linux/kernel.h> 97#include <linux/kernel.h>
99#include <linux/init.h> 98#include <linux/init.h>
100#include <linux/sched.h> 99#include <linux/delay.h>
101#include <linux/ptrace.h>
102#include <linux/slab.h>
103#include <linux/string.h>
104#include <linux/timer.h>
105#include <linux/ioport.h>
106#include <linux/netdevice.h>
107#include <linux/if_arp.h>
108#include <linux/etherdevice.h>
109#include <linux/list.h>
110#include <linux/pci.h> 100#include <linux/pci.h>
111#include <linux/fcntl.h>
112
113#include <asm/uaccess.h>
114#include <asm/io.h>
115#include <asm/system.h>
116 101
117#include "hermes.h"
118#include "orinoco.h" 102#include "orinoco.h"
119 103
120/* All the magic there is from wlan-ng */ 104/* All the magic there is from wlan-ng */
diff --git a/drivers/net/wireless/orinoco_plx.c b/drivers/net/wireless/orinoco_plx.c
index 7ab05b89fb3f..210e73776545 100644
--- a/drivers/net/wireless/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco_plx.c
@@ -117,29 +117,13 @@
117#define PFX DRIVER_NAME ": " 117#define PFX DRIVER_NAME ": "
118 118
119#include <linux/config.h> 119#include <linux/config.h>
120
121#include <linux/module.h> 120#include <linux/module.h>
122#include <linux/kernel.h> 121#include <linux/kernel.h>
123#include <linux/init.h> 122#include <linux/init.h>
124#include <linux/sched.h> 123#include <linux/delay.h>
125#include <linux/ptrace.h>
126#include <linux/slab.h>
127#include <linux/string.h>
128#include <linux/timer.h>
129#include <linux/ioport.h>
130#include <asm/uaccess.h>
131#include <asm/io.h>
132#include <asm/system.h>
133#include <linux/netdevice.h>
134#include <linux/if_arp.h>
135#include <linux/etherdevice.h>
136#include <linux/list.h>
137#include <linux/pci.h> 124#include <linux/pci.h>
138#include <linux/fcntl.h>
139
140#include <pcmcia/cisreg.h> 125#include <pcmcia/cisreg.h>
141 126
142#include "hermes.h"
143#include "orinoco.h" 127#include "orinoco.h"
144 128
145#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */ 129#define COR_OFFSET (0x3e0) /* COR attribute offset of Prism2 PC card */
diff --git a/drivers/net/wireless/orinoco_tmd.c b/drivers/net/wireless/orinoco_tmd.c
index 85893f42445b..5e68b7026186 100644
--- a/drivers/net/wireless/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco_tmd.c
@@ -53,29 +53,13 @@
53#define PFX DRIVER_NAME ": " 53#define PFX DRIVER_NAME ": "
54 54
55#include <linux/config.h> 55#include <linux/config.h>
56
57#include <linux/module.h> 56#include <linux/module.h>
58#include <linux/kernel.h> 57#include <linux/kernel.h>
59#include <linux/init.h> 58#include <linux/init.h>
60#include <linux/sched.h> 59#include <linux/delay.h>
61#include <linux/ptrace.h>
62#include <linux/slab.h>
63#include <linux/string.h>
64#include <linux/timer.h>
65#include <linux/ioport.h>
66#include <asm/uaccess.h>
67#include <asm/io.h>
68#include <asm/system.h>
69#include <linux/netdevice.h>
70#include <linux/if_arp.h>
71#include <linux/etherdevice.h>
72#include <linux/list.h>
73#include <linux/pci.h> 60#include <linux/pci.h>
74#include <linux/fcntl.h>
75
76#include <pcmcia/cisreg.h> 61#include <pcmcia/cisreg.h>
77 62
78#include "hermes.h"
79#include "orinoco.h" 63#include "orinoco.h"
80 64
81#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */ 65#define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 9a8790e3580c..5c1a1adf1ff8 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -462,14 +462,12 @@ prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
462 /* txpower is supported in dBm's */ 462 /* txpower is supported in dBm's */
463 range->txpower_capa = IW_TXPOW_DBM; 463 range->txpower_capa = IW_TXPOW_DBM;
464 464
465#if WIRELESS_EXT > 16
466 /* Event capability (kernel + driver) */ 465 /* Event capability (kernel + driver) */
467 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 466 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
468 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) | 467 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
469 IW_EVENT_CAPA_MASK(SIOCGIWAP)); 468 IW_EVENT_CAPA_MASK(SIOCGIWAP));
470 range->event_capa[1] = IW_EVENT_CAPA_K_1; 469 range->event_capa[1] = IW_EVENT_CAPA_K_1;
471 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM); 470 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
472#endif /* WIRELESS_EXT > 16 */
473 471
474 if (islpci_get_state(priv) < PRV_STATE_INIT) 472 if (islpci_get_state(priv) < PRV_STATE_INIT)
475 return 0; 473 return 0;
@@ -693,14 +691,13 @@ prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
693 extra + dwrq->length, 691 extra + dwrq->length,
694 &(bsslist->bsslist[i]), 692 &(bsslist->bsslist[i]),
695 noise); 693 noise);
696#if WIRELESS_EXT > 16 694
697 /* Check if there is space for one more entry */ 695 /* Check if there is space for one more entry */
698 if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) { 696 if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
699 /* Ask user space to try again with a bigger buffer */ 697 /* Ask user space to try again with a bigger buffer */
700 rvalue = -E2BIG; 698 rvalue = -E2BIG;
701 break; 699 break;
702 } 700 }
703#endif /* WIRELESS_EXT > 16 */
704 } 701 }
705 702
706 kfree(bsslist); 703 kfree(bsslist);
@@ -2727,12 +2724,7 @@ const struct iw_handler_def prism54_handler_def = {
2727 .standard = (iw_handler *) prism54_handler, 2724 .standard = (iw_handler *) prism54_handler,
2728 .private = (iw_handler *) prism54_private_handler, 2725 .private = (iw_handler *) prism54_private_handler,
2729 .private_args = (struct iw_priv_args *) prism54_private_args, 2726 .private_args = (struct iw_priv_args *) prism54_private_args,
2730#if WIRELESS_EXT > 16
2731 .get_wireless_stats = prism54_get_wireless_stats, 2727 .get_wireless_stats = prism54_get_wireless_stats,
2732#endif /* WIRELESS_EXT > 16 */
2733#if WIRELESS_EXT == 16
2734 .spy_offset = offsetof(islpci_private, spy_data),
2735#endif /* WIRELESS_EXT == 16 */
2736}; 2728};
2737 2729
2738/* For wpa_supplicant */ 2730/* For wpa_supplicant */
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 6f13d4a8e2d3..6c9584a9f284 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -439,8 +439,7 @@ prism54_bring_down(islpci_private *priv)
439 wmb(); 439 wmb();
440 440
441 /* wait a while for the device to reset */ 441 /* wait a while for the device to reset */
442 set_current_state(TASK_UNINTERRUPTIBLE); 442 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
443 schedule_timeout(50*HZ/1000);
444 443
445 return 0; 444 return 0;
446} 445}
@@ -491,8 +490,7 @@ islpci_reset_if(islpci_private *priv)
491 /* The software reset acknowledge needs about 220 msec here. 490 /* The software reset acknowledge needs about 220 msec here.
492 * Be conservative and wait for up to one second. */ 491 * Be conservative and wait for up to one second. */
493 492
494 set_current_state(TASK_UNINTERRUPTIBLE); 493 remaining = schedule_timeout_uninterruptible(HZ);
495 remaining = schedule_timeout(HZ);
496 494
497 if(remaining > 0) { 495 if(remaining > 0) {
498 result = 0; 496 result = 0;
@@ -839,13 +837,9 @@ islpci_setup(struct pci_dev *pdev)
839 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ? 837 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
840 priv->monitor_type : ARPHRD_ETHER; 838 priv->monitor_type : ARPHRD_ETHER;
841 839
842#if WIRELESS_EXT > 16
843 /* Add pointers to enable iwspy support. */ 840 /* Add pointers to enable iwspy support. */
844 priv->wireless_data.spy_data = &priv->spy_data; 841 priv->wireless_data.spy_data = &priv->spy_data;
845 ndev->wireless_data = &priv->wireless_data; 842 ndev->wireless_data = &priv->wireless_data;
846#else /* WIRELESS_EXT > 16 */
847 ndev->get_wireless_stats = &prism54_get_wireless_stats;
848#endif /* WIRELESS_EXT > 16 */
849 843
850 /* save the start and end address of the PCI memory area */ 844 /* save the start and end address of the PCI memory area */
851 ndev->mem_start = (unsigned long) priv->device_base; 845 ndev->mem_start = (unsigned long) priv->device_base;
diff --git a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h
index 32a1019f1b36..efbed4397951 100644
--- a/drivers/net/wireless/prism54/islpci_dev.h
+++ b/drivers/net/wireless/prism54/islpci_dev.h
@@ -100,9 +100,7 @@ typedef struct {
100 100
101 struct iw_spy_data spy_data; /* iwspy support */ 101 struct iw_spy_data spy_data; /* iwspy support */
102 102
103#if WIRELESS_EXT > 16
104 struct iw_public_data wireless_data; 103 struct iw_public_data wireless_data;
105#endif /* WIRELESS_EXT > 16 */
106 104
107 int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */ 105 int monitor_type; /* ARPHRD_IEEE80211 or ARPHRD_IEEE80211_PRISM */
108 106
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index b6f2e5a223be..4937a5ad4b2c 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -455,7 +455,7 @@ islpci_mgt_transaction(struct net_device *ndev,
455 struct islpci_mgmtframe **recvframe) 455 struct islpci_mgmtframe **recvframe)
456{ 456{
457 islpci_private *priv = netdev_priv(ndev); 457 islpci_private *priv = netdev_priv(ndev);
458 const long wait_cycle_jiffies = (ISL38XX_WAIT_CYCLE * 10 * HZ) / 1000; 458 const long wait_cycle_jiffies = msecs_to_jiffies(ISL38XX_WAIT_CYCLE * 10);
459 long timeout_left = ISL38XX_MAX_WAIT_CYCLES * wait_cycle_jiffies; 459 long timeout_left = ISL38XX_MAX_WAIT_CYCLES * wait_cycle_jiffies;
460 int err; 460 int err;
461 DEFINE_WAIT(wait); 461 DEFINE_WAIT(wait);
@@ -475,8 +475,7 @@ islpci_mgt_transaction(struct net_device *ndev,
475 int timeleft; 475 int timeleft;
476 struct islpci_mgmtframe *frame; 476 struct islpci_mgmtframe *frame;
477 477
478 set_current_state(TASK_UNINTERRUPTIBLE); 478 timeleft = schedule_timeout_uninterruptible(wait_cycle_jiffies);
479 timeleft = schedule_timeout(wait_cycle_jiffies);
480 frame = xchg(&priv->mgmt_received, NULL); 479 frame = xchg(&priv->mgmt_received, NULL);
481 if (frame) { 480 if (frame) {
482 if (frame->header->oid == oid) { 481 if (frame->header->oid == oid) {
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index e9c5ea0f5535..70fd6fd8feb9 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1649,28 +1649,28 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
1649 */ 1649 */
1650 1650
1651static const iw_handler ray_handler[] = { 1651static const iw_handler ray_handler[] = {
1652 [SIOCSIWCOMMIT-SIOCIWFIRST] (iw_handler) ray_commit, 1652 [SIOCSIWCOMMIT-SIOCIWFIRST] = (iw_handler) ray_commit,
1653 [SIOCGIWNAME -SIOCIWFIRST] (iw_handler) ray_get_name, 1653 [SIOCGIWNAME -SIOCIWFIRST] = (iw_handler) ray_get_name,
1654 [SIOCSIWFREQ -SIOCIWFIRST] (iw_handler) ray_set_freq, 1654 [SIOCSIWFREQ -SIOCIWFIRST] = (iw_handler) ray_set_freq,
1655 [SIOCGIWFREQ -SIOCIWFIRST] (iw_handler) ray_get_freq, 1655 [SIOCGIWFREQ -SIOCIWFIRST] = (iw_handler) ray_get_freq,
1656 [SIOCSIWMODE -SIOCIWFIRST] (iw_handler) ray_set_mode, 1656 [SIOCSIWMODE -SIOCIWFIRST] = (iw_handler) ray_set_mode,
1657 [SIOCGIWMODE -SIOCIWFIRST] (iw_handler) ray_get_mode, 1657 [SIOCGIWMODE -SIOCIWFIRST] = (iw_handler) ray_get_mode,
1658 [SIOCGIWRANGE -SIOCIWFIRST] (iw_handler) ray_get_range, 1658 [SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) ray_get_range,
1659#ifdef WIRELESS_SPY 1659#ifdef WIRELESS_SPY
1660 [SIOCSIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_set_spy, 1660 [SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_set_spy,
1661 [SIOCGIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_get_spy, 1661 [SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_get_spy,
1662 [SIOCSIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_set_thrspy, 1662 [SIOCSIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy,
1663 [SIOCGIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_get_thrspy, 1663 [SIOCGIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy,
1664#endif /* WIRELESS_SPY */ 1664#endif /* WIRELESS_SPY */
1665 [SIOCGIWAP -SIOCIWFIRST] (iw_handler) ray_get_wap, 1665 [SIOCGIWAP -SIOCIWFIRST] = (iw_handler) ray_get_wap,
1666 [SIOCSIWESSID -SIOCIWFIRST] (iw_handler) ray_set_essid, 1666 [SIOCSIWESSID -SIOCIWFIRST] = (iw_handler) ray_set_essid,
1667 [SIOCGIWESSID -SIOCIWFIRST] (iw_handler) ray_get_essid, 1667 [SIOCGIWESSID -SIOCIWFIRST] = (iw_handler) ray_get_essid,
1668 [SIOCSIWRATE -SIOCIWFIRST] (iw_handler) ray_set_rate, 1668 [SIOCSIWRATE -SIOCIWFIRST] = (iw_handler) ray_set_rate,
1669 [SIOCGIWRATE -SIOCIWFIRST] (iw_handler) ray_get_rate, 1669 [SIOCGIWRATE -SIOCIWFIRST] = (iw_handler) ray_get_rate,
1670 [SIOCSIWRTS -SIOCIWFIRST] (iw_handler) ray_set_rts, 1670 [SIOCSIWRTS -SIOCIWFIRST] = (iw_handler) ray_set_rts,
1671 [SIOCGIWRTS -SIOCIWFIRST] (iw_handler) ray_get_rts, 1671 [SIOCGIWRTS -SIOCIWFIRST] = (iw_handler) ray_get_rts,
1672 [SIOCSIWFRAG -SIOCIWFIRST] (iw_handler) ray_set_frag, 1672 [SIOCSIWFRAG -SIOCIWFIRST] = (iw_handler) ray_set_frag,
1673 [SIOCGIWFRAG -SIOCIWFIRST] (iw_handler) ray_get_frag, 1673 [SIOCGIWFRAG -SIOCIWFIRST] = (iw_handler) ray_get_frag,
1674}; 1674};
1675 1675
1676#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */ 1676#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
@@ -1678,9 +1678,9 @@ static const iw_handler ray_handler[] = {
1678#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */ 1678#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
1679 1679
1680static const iw_handler ray_private_handler[] = { 1680static const iw_handler ray_private_handler[] = {
1681 [0] (iw_handler) ray_set_framing, 1681 [0] = (iw_handler) ray_set_framing,
1682 [1] (iw_handler) ray_get_framing, 1682 [1] = (iw_handler) ray_get_framing,
1683 [3] (iw_handler) ray_get_country, 1683 [3] = (iw_handler) ray_get_country,
1684}; 1684};
1685 1685
1686static const struct iw_priv_args ray_private_args[] = { 1686static const struct iw_priv_args ray_private_args[] = {
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 39c6cdf7f3f7..b1bbc8e8e91f 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -22,58 +22,23 @@
22#define PFX DRIVER_NAME ": " 22#define PFX DRIVER_NAME ": "
23 23
24#include <linux/config.h> 24#include <linux/config.h>
25#ifdef __IN_PCMCIA_PACKAGE__
26#include <pcmcia/k_compat.h>
27#endif /* __IN_PCMCIA_PACKAGE__ */
28
29#include <linux/module.h> 25#include <linux/module.h>
30#include <linux/kernel.h> 26#include <linux/kernel.h>
31#include <linux/init.h> 27#include <linux/init.h>
32#include <linux/sched.h> 28#include <linux/delay.h>
33#include <linux/ptrace.h> 29#include <linux/firmware.h>
34#include <linux/slab.h>
35#include <linux/string.h>
36#include <linux/ioport.h>
37#include <linux/netdevice.h>
38#include <linux/if_arp.h>
39#include <linux/etherdevice.h>
40#include <linux/wireless.h>
41
42#include <pcmcia/cs_types.h> 30#include <pcmcia/cs_types.h>
43#include <pcmcia/cs.h> 31#include <pcmcia/cs.h>
44#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
45#include <pcmcia/cisreg.h> 33#include <pcmcia/cisreg.h>
46#include <pcmcia/ds.h> 34#include <pcmcia/ds.h>
47 35
48#include <asm/uaccess.h>
49#include <asm/io.h>
50#include <asm/system.h>
51
52#include "orinoco.h" 36#include "orinoco.h"
53 37
54/*
55 * If SPECTRUM_FW_INCLUDED is defined, the firmware is hardcoded into
56 * the driver. Use get_symbol_fw script to generate spectrum_fw.h and
57 * copy it to the same directory as spectrum_cs.c.
58 *
59 * If SPECTRUM_FW_INCLUDED is not defined, the firmware is loaded at the
60 * runtime using hotplug. Use the same get_symbol_fw script to generate
61 * files symbol_sp24t_prim_fw symbol_sp24t_sec_fw, copy them to the
62 * hotplug firmware directory (typically /usr/lib/hotplug/firmware) and
63 * make sure that you have hotplug installed and enabled in the kernel.
64 */
65/* #define SPECTRUM_FW_INCLUDED 1 */
66
67#ifdef SPECTRUM_FW_INCLUDED
68/* Header with the firmware */
69#include "spectrum_fw.h"
70#else /* !SPECTRUM_FW_INCLUDED */
71#include <linux/firmware.h>
72static unsigned char *primsym; 38static unsigned char *primsym;
73static unsigned char *secsym; 39static unsigned char *secsym;
74static const char primary_fw_name[] = "symbol_sp24t_prim_fw"; 40static const char primary_fw_name[] = "symbol_sp24t_prim_fw";
75static const char secondary_fw_name[] = "symbol_sp24t_sec_fw"; 41static const char secondary_fw_name[] = "symbol_sp24t_sec_fw";
76#endif /* !SPECTRUM_FW_INCLUDED */
77 42
78/********************************************************************/ 43/********************************************************************/
79/* Module stuff */ 44/* Module stuff */
@@ -124,17 +89,8 @@ static dev_link_t *dev_list; /* = NULL */
124/* Function prototypes */ 89/* Function prototypes */
125/********************************************************************/ 90/********************************************************************/
126 91
127/* device methods */ 92static void spectrum_cs_release(dev_link_t *link);
128static int spectrum_cs_hard_reset(struct orinoco_private *priv); 93static void spectrum_cs_detach(dev_link_t *link);
129
130/* PCMCIA gumpf */
131static void spectrum_cs_config(dev_link_t * link);
132static void spectrum_cs_release(dev_link_t * link);
133static int spectrum_cs_event(event_t event, int priority,
134 event_callback_args_t * args);
135
136static dev_link_t *spectrum_cs_attach(void);
137static void spectrum_cs_detach(dev_link_t *);
138 94
139/********************************************************************/ 95/********************************************************************/
140/* Firmware downloader */ 96/* Firmware downloader */
@@ -182,8 +138,8 @@ static void spectrum_cs_detach(dev_link_t *);
182 * Each block has the following structure. 138 * Each block has the following structure.
183 */ 139 */
184struct dblock { 140struct dblock {
185 u32 _addr; /* adapter address where to write the block */ 141 __le32 _addr; /* adapter address where to write the block */
186 u16 _len; /* length of the data only, in bytes */ 142 __le16 _len; /* length of the data only, in bytes */
187 char data[0]; /* data to be written */ 143 char data[0]; /* data to be written */
188} __attribute__ ((packed)); 144} __attribute__ ((packed));
189 145
@@ -193,9 +149,9 @@ struct dblock {
193 * items with matching ID should be written. 149 * items with matching ID should be written.
194 */ 150 */
195struct pdr { 151struct pdr {
196 u32 _id; /* record ID */ 152 __le32 _id; /* record ID */
197 u32 _addr; /* adapter address where to write the data */ 153 __le32 _addr; /* adapter address where to write the data */
198 u32 _len; /* expected length of the data, in bytes */ 154 __le32 _len; /* expected length of the data, in bytes */
199 char next[0]; /* next PDR starts here */ 155 char next[0]; /* next PDR starts here */
200} __attribute__ ((packed)); 156} __attribute__ ((packed));
201 157
@@ -206,8 +162,8 @@ struct pdr {
206 * be plugged into the secondary firmware. 162 * be plugged into the secondary firmware.
207 */ 163 */
208struct pdi { 164struct pdi {
209 u16 _len; /* length of ID and data, in words */ 165 __le16 _len; /* length of ID and data, in words */
210 u16 _id; /* record ID */ 166 __le16 _id; /* record ID */
211 char data[0]; /* plug data */ 167 char data[0]; /* plug data */
212} __attribute__ ((packed));; 168} __attribute__ ((packed));;
213 169
@@ -414,7 +370,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
414 370
415/* Read PDA from the adapter */ 371/* Read PDA from the adapter */
416static int 372static int
417spectrum_read_pda(hermes_t *hw, u16 *pda, int pda_len) 373spectrum_read_pda(hermes_t *hw, __le16 *pda, int pda_len)
418{ 374{
419 int ret; 375 int ret;
420 int pda_size; 376 int pda_size;
@@ -445,7 +401,7 @@ spectrum_read_pda(hermes_t *hw, u16 *pda, int pda_len)
445/* Parse PDA and write the records into the adapter */ 401/* Parse PDA and write the records into the adapter */
446static int 402static int
447spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block, 403spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block,
448 u16 *pda) 404 __le16 *pda)
449{ 405{
450 int ret; 406 int ret;
451 struct pdi *pdi; 407 struct pdi *pdi;
@@ -511,7 +467,7 @@ spectrum_dl_image(hermes_t *hw, dev_link_t *link,
511 const struct dblock *first_block; 467 const struct dblock *first_block;
512 468
513 /* Plug Data Area (PDA) */ 469 /* Plug Data Area (PDA) */
514 u16 pda[PDA_WORDS]; 470 __le16 pda[PDA_WORDS];
515 471
516 /* Binary block begins after the 0x1A marker */ 472 /* Binary block begins after the 0x1A marker */
517 ptr = image; 473 ptr = image;
@@ -571,8 +527,6 @@ spectrum_dl_firmware(hermes_t *hw, dev_link_t *link)
571{ 527{
572 int ret; 528 int ret;
573 client_handle_t handle = link->handle; 529 client_handle_t handle = link->handle;
574
575#ifndef SPECTRUM_FW_INCLUDED
576 const struct firmware *fw_entry; 530 const struct firmware *fw_entry;
577 531
578 if (request_firmware(&fw_entry, primary_fw_name, 532 if (request_firmware(&fw_entry, primary_fw_name,
@@ -592,7 +546,6 @@ spectrum_dl_firmware(hermes_t *hw, dev_link_t *link)
592 secondary_fw_name); 546 secondary_fw_name);
593 return -ENOENT; 547 return -ENOENT;
594 } 548 }
595#endif
596 549
597 /* Load primary firmware */ 550 /* Load primary firmware */
598 ret = spectrum_dl_image(hw, link, primsym); 551 ret = spectrum_dl_image(hw, link, primsym);
@@ -1085,7 +1038,7 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
1085static struct pcmcia_device_id spectrum_cs_ids[] = { 1038static struct pcmcia_device_id spectrum_cs_ids[] = {
1086 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */ 1039 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4100 */
1087 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */ 1040 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
1088 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), /* Intel PRO/Wireless 2011B */ 1041 PCMCIA_DEVICE_PROD_ID12("Intel", "PRO/Wireless LAN PC Card", 0x816cc815, 0x6fbf459a), /* 2011B, not 2011 */
1089 PCMCIA_DEVICE_NULL, 1042 PCMCIA_DEVICE_NULL,
1090}; 1043};
1091MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids); 1044MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids);
@@ -1096,8 +1049,8 @@ static struct pcmcia_driver orinoco_driver = {
1096 .name = DRIVER_NAME, 1049 .name = DRIVER_NAME,
1097 }, 1050 },
1098 .attach = spectrum_cs_attach, 1051 .attach = spectrum_cs_attach,
1099 .event = spectrum_cs_event,
1100 .detach = spectrum_cs_detach, 1052 .detach = spectrum_cs_detach,
1053 .event = spectrum_cs_event,
1101 .id_table = spectrum_cs_ids, 1054 .id_table = spectrum_cs_ids,
1102}; 1055};
1103 1056
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index 7a5e20a17890..b0d8b5b03152 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -430,7 +430,6 @@ static void fee_read(unsigned long ioaddr, /* I/O port of the card */
430 } 430 }
431} 431}
432 432
433#ifdef WIRELESS_EXT /* if the wireless extension exists in the kernel */
434 433
435/*------------------------------------------------------------------*/ 434/*------------------------------------------------------------------*/
436/* 435/*
@@ -514,7 +513,6 @@ static void fee_write(unsigned long ioaddr, /* I/O port of the card */
514 fee_wait(ioaddr, 10, 100); 513 fee_wait(ioaddr, 10, 100);
515#endif /* EEPROM_IS_PROTECTED */ 514#endif /* EEPROM_IS_PROTECTED */
516} 515}
517#endif /* WIRELESS_EXT */
518 516
519/************************ I82586 SUBROUTINES *************************/ 517/************************ I82586 SUBROUTINES *************************/
520/* 518/*
@@ -973,11 +971,9 @@ static void wv_mmc_show(struct net_device * dev)
973 mmc_read(ioaddr, 0, (u8 *) & m, sizeof(m)); 971 mmc_read(ioaddr, 0, (u8 *) & m, sizeof(m));
974 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0); 972 mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0);
975 973
976#ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */
977 /* Don't forget to update statistics */ 974 /* Don't forget to update statistics */
978 lp->wstats.discard.nwid += 975 lp->wstats.discard.nwid +=
979 (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l; 976 (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
980#endif /* WIRELESS_EXT */
981 977
982 printk(KERN_DEBUG "##### WaveLAN modem status registers: #####\n"); 978 printk(KERN_DEBUG "##### WaveLAN modem status registers: #####\n");
983#ifdef DEBUG_SHOW_UNUSED 979#ifdef DEBUG_SHOW_UNUSED
@@ -1499,7 +1495,6 @@ static int wavelan_set_mac_address(struct net_device * dev, void *addr)
1499} 1495}
1500#endif /* SET_MAC_ADDRESS */ 1496#endif /* SET_MAC_ADDRESS */
1501 1497
1502#ifdef WIRELESS_EXT /* if wireless extensions exist in the kernel */
1503 1498
1504/*------------------------------------------------------------------*/ 1499/*------------------------------------------------------------------*/
1505/* 1500/*
@@ -2473,7 +2468,6 @@ static iw_stats *wavelan_get_wireless_stats(struct net_device * dev)
2473#endif 2468#endif
2474 return &lp->wstats; 2469 return &lp->wstats;
2475} 2470}
2476#endif /* WIRELESS_EXT */
2477 2471
2478/************************* PACKET RECEPTION *************************/ 2472/************************* PACKET RECEPTION *************************/
2479/* 2473/*
@@ -4194,11 +4188,9 @@ static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr)
4194 dev->set_mac_address = &wavelan_set_mac_address; 4188 dev->set_mac_address = &wavelan_set_mac_address;
4195#endif /* SET_MAC_ADDRESS */ 4189#endif /* SET_MAC_ADDRESS */
4196 4190
4197#ifdef WIRELESS_EXT /* if wireless extension exists in the kernel */
4198 dev->wireless_handlers = &wavelan_handler_def; 4191 dev->wireless_handlers = &wavelan_handler_def;
4199 lp->wireless_data.spy_data = &lp->spy_data; 4192 lp->wireless_data.spy_data = &lp->spy_data;
4200 dev->wireless_data = &lp->wireless_data; 4193 dev->wireless_data = &lp->wireless_data;
4201#endif
4202 4194
4203 dev->mtu = WAVELAN_MTU; 4195 dev->mtu = WAVELAN_MTU;
4204 4196
diff --git a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
index 509ff22a6caa..166e28b9a4f7 100644
--- a/drivers/net/wireless/wavelan.p.h
+++ b/drivers/net/wireless/wavelan.p.h
@@ -409,11 +409,9 @@
409#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ 409#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */
410#undef SET_MAC_ADDRESS /* Experimental */ 410#undef SET_MAC_ADDRESS /* Experimental */
411 411
412#ifdef WIRELESS_EXT /* If wireless extensions exist in the kernel */
413/* Warning: this stuff will slow down the driver. */ 412/* Warning: this stuff will slow down the driver. */
414#define WIRELESS_SPY /* Enable spying addresses. */ 413#define WIRELESS_SPY /* Enable spying addresses. */
415#undef HISTOGRAM /* Enable histogram of signal level. */ 414#undef HISTOGRAM /* Enable histogram of signal level. */
416#endif
417 415
418/****************************** DEBUG ******************************/ 416/****************************** DEBUG ******************************/
419 417
@@ -506,12 +504,10 @@ struct net_local
506 u_short tx_first_free; 504 u_short tx_first_free;
507 u_short tx_first_in_use; 505 u_short tx_first_in_use;
508 506
509#ifdef WIRELESS_EXT
510 iw_stats wstats; /* Wireless-specific statistics */ 507 iw_stats wstats; /* Wireless-specific statistics */
511 508
512 struct iw_spy_data spy_data; 509 struct iw_spy_data spy_data;
513 struct iw_public_data wireless_data; 510 struct iw_public_data wireless_data;
514#endif
515 511
516#ifdef HISTOGRAM 512#ifdef HISTOGRAM
517 int his_number; /* number of intervals */ 513 int his_number; /* number of intervals */
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 183c4732ef65..4b3c98f5c564 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -415,7 +415,6 @@ fee_read(u_long base, /* i/o port of the card */
415 } 415 }
416} 416}
417 417
418#ifdef WIRELESS_EXT /* If wireless extension exist in the kernel */
419 418
420/*------------------------------------------------------------------*/ 419/*------------------------------------------------------------------*/
421/* 420/*
@@ -500,7 +499,6 @@ fee_write(u_long base, /* i/o port of the card */
500 fee_wait(base, 10, 100); 499 fee_wait(base, 10, 100);
501#endif /* EEPROM_IS_PROTECTED */ 500#endif /* EEPROM_IS_PROTECTED */
502} 501}
503#endif /* WIRELESS_EXT */
504 502
505/******************* WaveLAN Roaming routines... ********************/ 503/******************* WaveLAN Roaming routines... ********************/
506 504
@@ -1161,10 +1159,8 @@ wv_mmc_show(struct net_device * dev)
1161 mmc_read(base, 0, (u_char *)&m, sizeof(m)); 1159 mmc_read(base, 0, (u_char *)&m, sizeof(m));
1162 mmc_out(base, mmwoff(0, mmw_freeze), 0); 1160 mmc_out(base, mmwoff(0, mmw_freeze), 0);
1163 1161
1164#ifdef WIRELESS_EXT /* If wireless extension exist in the kernel */
1165 /* Don't forget to update statistics */ 1162 /* Don't forget to update statistics */
1166 lp->wstats.discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l; 1163 lp->wstats.discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
1167#endif /* WIRELESS_EXT */
1168 1164
1169 spin_unlock_irqrestore(&lp->spinlock, flags); 1165 spin_unlock_irqrestore(&lp->spinlock, flags);
1170 1166
@@ -1550,7 +1546,6 @@ wavelan_set_mac_address(struct net_device * dev,
1550} 1546}
1551#endif /* SET_MAC_ADDRESS */ 1547#endif /* SET_MAC_ADDRESS */
1552 1548
1553#ifdef WIRELESS_EXT /* If wireless extension exist in the kernel */
1554 1549
1555/*------------------------------------------------------------------*/ 1550/*------------------------------------------------------------------*/
1556/* 1551/*
@@ -2793,7 +2788,6 @@ wavelan_get_wireless_stats(struct net_device * dev)
2793#endif 2788#endif
2794 return &lp->wstats; 2789 return &lp->wstats;
2795} 2790}
2796#endif /* WIRELESS_EXT */
2797 2791
2798/************************* PACKET RECEPTION *************************/ 2792/************************* PACKET RECEPTION *************************/
2799/* 2793/*
@@ -4679,11 +4673,9 @@ wavelan_attach(void)
4679 dev->watchdog_timeo = WATCHDOG_JIFFIES; 4673 dev->watchdog_timeo = WATCHDOG_JIFFIES;
4680 SET_ETHTOOL_OPS(dev, &ops); 4674 SET_ETHTOOL_OPS(dev, &ops);
4681 4675
4682#ifdef WIRELESS_EXT /* If wireless extension exist in the kernel */
4683 dev->wireless_handlers = &wavelan_handler_def; 4676 dev->wireless_handlers = &wavelan_handler_def;
4684 lp->wireless_data.spy_data = &lp->spy_data; 4677 lp->wireless_data.spy_data = &lp->spy_data;
4685 dev->wireless_data = &lp->wireless_data; 4678 dev->wireless_data = &lp->wireless_data;
4686#endif
4687 4679
4688 /* Other specific data */ 4680 /* Other specific data */
4689 dev->mtu = WAVELAN_MTU; 4681 dev->mtu = WAVELAN_MTU;
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index 01d882be8790..724a715089c9 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -472,11 +472,9 @@
472#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */ 472#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */
473#undef SET_MAC_ADDRESS /* Experimental */ 473#undef SET_MAC_ADDRESS /* Experimental */
474 474
475#ifdef WIRELESS_EXT /* If wireless extension exist in the kernel */
476/* Warning : these stuff will slow down the driver... */ 475/* Warning : these stuff will slow down the driver... */
477#define WIRELESS_SPY /* Enable spying addresses */ 476#define WIRELESS_SPY /* Enable spying addresses */
478#undef HISTOGRAM /* Enable histogram of sig level... */ 477#undef HISTOGRAM /* Enable histogram of sig level... */
479#endif
480 478
481/****************************** DEBUG ******************************/ 479/****************************** DEBUG ******************************/
482 480
@@ -624,12 +622,10 @@ struct net_local
624 int rfp; /* Last DMA machine receive pointer */ 622 int rfp; /* Last DMA machine receive pointer */
625 int overrunning; /* Receiver overrun flag */ 623 int overrunning; /* Receiver overrun flag */
626 624
627#ifdef WIRELESS_EXT
628 iw_stats wstats; /* Wireless specific stats */ 625 iw_stats wstats; /* Wireless specific stats */
629 626
630 struct iw_spy_data spy_data; 627 struct iw_spy_data spy_data;
631 struct iw_public_data wireless_data; 628 struct iw_public_data wireless_data;
632#endif
633 629
634#ifdef HISTOGRAM 630#ifdef HISTOGRAM
635 int his_number; /* Number of intervals */ 631 int his_number; /* Number of intervals */
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
index 7fcbe589c3f2..4303c50c2ab6 100644
--- a/drivers/net/wireless/wl3501.h
+++ b/drivers/net/wireless/wl3501.h
@@ -548,7 +548,7 @@ struct wl3501_80211_tx_plcp_hdr {
548 548
549struct wl3501_80211_tx_hdr { 549struct wl3501_80211_tx_hdr {
550 struct wl3501_80211_tx_plcp_hdr pclp_hdr; 550 struct wl3501_80211_tx_plcp_hdr pclp_hdr;
551 struct ieee80211_hdr mac_hdr; 551 struct ieee80211_hdr_4addr mac_hdr;
552} __attribute__ ((packed)); 552} __attribute__ ((packed));
553 553
554/* 554/*
diff --git a/drivers/parisc/asp.c b/drivers/parisc/asp.c
index 388609967133..558420bc9f88 100644
--- a/drivers/parisc/asp.c
+++ b/drivers/parisc/asp.c
@@ -77,12 +77,12 @@ asp_init_chip(struct parisc_device *dev)
77 struct gsc_irq gsc_irq; 77 struct gsc_irq gsc_irq;
78 int ret; 78 int ret;
79 79
80 asp.version = gsc_readb(dev->hpa + ASP_VER_OFFSET) & 0xf; 80 asp.version = gsc_readb(dev->hpa.start + ASP_VER_OFFSET) & 0xf;
81 asp.name = (asp.version == 1) ? "Asp" : "Cutoff"; 81 asp.name = (asp.version == 1) ? "Asp" : "Cutoff";
82 asp.hpa = ASP_INTERRUPT_ADDR; 82 asp.hpa = ASP_INTERRUPT_ADDR;
83 83
84 printk(KERN_INFO "%s version %d at 0x%lx found.\n", 84 printk(KERN_INFO "%s version %d at 0x%lx found.\n",
85 asp.name, asp.version, dev->hpa); 85 asp.name, asp.version, dev->hpa.start);
86 86
87 /* the IRQ ASP should use */ 87 /* the IRQ ASP should use */
88 ret = -EBUSY; 88 ret = -EBUSY;
@@ -126,7 +126,7 @@ static struct parisc_device_id asp_tbl[] = {
126}; 126};
127 127
128struct parisc_driver asp_driver = { 128struct parisc_driver asp_driver = {
129 .name = "Asp", 129 .name = "asp",
130 .id_table = asp_tbl, 130 .id_table = asp_tbl,
131 .probe = asp_init_chip, 131 .probe = asp_init_chip,
132}; 132};
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 0e98a9d9834c..9e0229f7e25f 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -100,9 +100,9 @@
100#define DBG_RUN_SG(x...) 100#define DBG_RUN_SG(x...)
101#endif 101#endif
102 102
103#define CCIO_INLINE /* inline */ 103#define CCIO_INLINE inline
104#define WRITE_U32(value, addr) gsc_writel(value, (u32 *)(addr)) 104#define WRITE_U32(value, addr) __raw_writel(value, addr)
105#define READ_U32(addr) gsc_readl((u32 *)(addr)) 105#define READ_U32(addr) __raw_readl(addr)
106 106
107#define U2_IOA_RUNWAY 0x580 107#define U2_IOA_RUNWAY 0x580
108#define U2_BC_GSC 0x501 108#define U2_BC_GSC 0x501
@@ -115,28 +115,28 @@
115 115
116struct ioa_registers { 116struct ioa_registers {
117 /* Runway Supervisory Set */ 117 /* Runway Supervisory Set */
118 volatile int32_t unused1[12]; 118 int32_t unused1[12];
119 volatile uint32_t io_command; /* Offset 12 */ 119 uint32_t io_command; /* Offset 12 */
120 volatile uint32_t io_status; /* Offset 13 */ 120 uint32_t io_status; /* Offset 13 */
121 volatile uint32_t io_control; /* Offset 14 */ 121 uint32_t io_control; /* Offset 14 */
122 volatile int32_t unused2[1]; 122 int32_t unused2[1];
123 123
124 /* Runway Auxiliary Register Set */ 124 /* Runway Auxiliary Register Set */
125 volatile uint32_t io_err_resp; /* Offset 0 */ 125 uint32_t io_err_resp; /* Offset 0 */
126 volatile uint32_t io_err_info; /* Offset 1 */ 126 uint32_t io_err_info; /* Offset 1 */
127 volatile uint32_t io_err_req; /* Offset 2 */ 127 uint32_t io_err_req; /* Offset 2 */
128 volatile uint32_t io_err_resp_hi; /* Offset 3 */ 128 uint32_t io_err_resp_hi; /* Offset 3 */
129 volatile uint32_t io_tlb_entry_m; /* Offset 4 */ 129 uint32_t io_tlb_entry_m; /* Offset 4 */
130 volatile uint32_t io_tlb_entry_l; /* Offset 5 */ 130 uint32_t io_tlb_entry_l; /* Offset 5 */
131 volatile uint32_t unused3[1]; 131 uint32_t unused3[1];
132 volatile uint32_t io_pdir_base; /* Offset 7 */ 132 uint32_t io_pdir_base; /* Offset 7 */
133 volatile uint32_t io_io_low_hv; /* Offset 8 */ 133 uint32_t io_io_low_hv; /* Offset 8 */
134 volatile uint32_t io_io_high_hv; /* Offset 9 */ 134 uint32_t io_io_high_hv; /* Offset 9 */
135 volatile uint32_t unused4[1]; 135 uint32_t unused4[1];
136 volatile uint32_t io_chain_id_mask; /* Offset 11 */ 136 uint32_t io_chain_id_mask; /* Offset 11 */
137 volatile uint32_t unused5[2]; 137 uint32_t unused5[2];
138 volatile uint32_t io_io_low; /* Offset 14 */ 138 uint32_t io_io_low; /* Offset 14 */
139 volatile uint32_t io_io_high; /* Offset 15 */ 139 uint32_t io_io_high; /* Offset 15 */
140}; 140};
141 141
142/* 142/*
@@ -226,7 +226,7 @@ struct ioa_registers {
226*/ 226*/
227 227
228struct ioc { 228struct ioc {
229 struct ioa_registers *ioc_hpa; /* I/O MMU base address */ 229 struct ioa_registers __iomem *ioc_regs; /* I/O MMU base address */
230 u8 *res_map; /* resource map, bit == pdir entry */ 230 u8 *res_map; /* resource map, bit == pdir entry */
231 u64 *pdir_base; /* physical base address */ 231 u64 *pdir_base; /* physical base address */
232 u32 pdir_size; /* bytes, function of IOV Space size */ 232 u32 pdir_size; /* bytes, function of IOV Space size */
@@ -595,7 +595,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
595 ** Grab virtual index [0:11] 595 ** Grab virtual index [0:11]
596 ** Deposit virt_idx bits into I/O PDIR word 596 ** Deposit virt_idx bits into I/O PDIR word
597 */ 597 */
598 asm volatile ("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); 598 asm volatile ("lci %%r0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba));
599 asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci)); 599 asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci));
600 asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci)); 600 asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci));
601 601
@@ -613,7 +613,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
613 ** the real mode coherence index generation of U2, the PDIR entry 613 ** the real mode coherence index generation of U2, the PDIR entry
614 ** must be flushed to memory to retain coherence." 614 ** must be flushed to memory to retain coherence."
615 */ 615 */
616 asm volatile("fdc 0(%0)" : : "r" (pdir_ptr)); 616 asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr));
617 asm volatile("sync"); 617 asm volatile("sync");
618} 618}
619 619
@@ -636,7 +636,7 @@ ccio_clear_io_tlb(struct ioc *ioc, dma_addr_t iovp, size_t byte_cnt)
636 byte_cnt += chain_size; 636 byte_cnt += chain_size;
637 637
638 while(byte_cnt > chain_size) { 638 while(byte_cnt > chain_size) {
639 WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_hpa->io_command); 639 WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_regs->io_command);
640 iovp += chain_size; 640 iovp += chain_size;
641 byte_cnt -= chain_size; 641 byte_cnt -= chain_size;
642 } 642 }
@@ -684,7 +684,7 @@ ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt)
684 ** Hopefully someone figures out how to patch (NOP) the 684 ** Hopefully someone figures out how to patch (NOP) the
685 ** FDC/SYNC out at boot time. 685 ** FDC/SYNC out at boot time.
686 */ 686 */
687 asm volatile("fdc 0(%0)" : : "r" (pdir_ptr[7])); 687 asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr[7]));
688 688
689 iovp += IOVP_SIZE; 689 iovp += IOVP_SIZE;
690 byte_cnt -= IOVP_SIZE; 690 byte_cnt -= IOVP_SIZE;
@@ -836,7 +836,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
836 * This function implements the pci_alloc_consistent function. 836 * This function implements the pci_alloc_consistent function.
837 */ 837 */
838static void * 838static void *
839ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, int flag) 839ccio_alloc_consistent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag)
840{ 840{
841 void *ret; 841 void *ret;
842#if 0 842#if 0
@@ -1251,7 +1251,7 @@ static struct parisc_device_id ccio_tbl[] = {
1251static int ccio_probe(struct parisc_device *dev); 1251static int ccio_probe(struct parisc_device *dev);
1252 1252
1253static struct parisc_driver ccio_driver = { 1253static struct parisc_driver ccio_driver = {
1254 .name = "U2:Uturn", 1254 .name = "ccio",
1255 .id_table = ccio_tbl, 1255 .id_table = ccio_tbl,
1256 .probe = ccio_probe, 1256 .probe = ccio_probe,
1257}; 1257};
@@ -1314,14 +1314,13 @@ ccio_ioc_init(struct ioc *ioc)
1314 1314
1315 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); 1315 ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64);
1316 1316
1317 BUG_ON(ioc->pdir_size >= 4 * 1024 * 1024); /* max pdir size < 4MB */ 1317 BUG_ON(ioc->pdir_size > 8 * 1024 * 1024); /* max pdir size <= 8MB */
1318 1318
1319 /* Verify it's a power of two */ 1319 /* Verify it's a power of two */
1320 BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); 1320 BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT));
1321 1321
1322 DBG_INIT("%s() hpa 0x%lx mem %luMB IOV %dMB (%d bits)\n", 1322 DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
1323 __FUNCTION__, 1323 __FUNCTION__, ioc->ioc_regs,
1324 ioc->ioc_hpa,
1325 (unsigned long) num_physpages >> (20 - PAGE_SHIFT), 1324 (unsigned long) num_physpages >> (20 - PAGE_SHIFT),
1326 iova_space_size>>20, 1325 iova_space_size>>20,
1327 iov_order + PAGE_SHIFT); 1326 iov_order + PAGE_SHIFT);
@@ -1329,13 +1328,12 @@ ccio_ioc_init(struct ioc *ioc)
1329 ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, 1328 ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL,
1330 get_order(ioc->pdir_size)); 1329 get_order(ioc->pdir_size));
1331 if(NULL == ioc->pdir_base) { 1330 if(NULL == ioc->pdir_base) {
1332 panic("%s:%s() could not allocate I/O Page Table\n", __FILE__, 1331 panic("%s() could not allocate I/O Page Table\n", __FUNCTION__);
1333 __FUNCTION__);
1334 } 1332 }
1335 memset(ioc->pdir_base, 0, ioc->pdir_size); 1333 memset(ioc->pdir_base, 0, ioc->pdir_size);
1336 1334
1337 BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); 1335 BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base);
1338 DBG_INIT(" base %p", ioc->pdir_base); 1336 DBG_INIT(" base %p\n", ioc->pdir_base);
1339 1337
1340 /* resource map size dictated by pdir_size */ 1338 /* resource map size dictated by pdir_size */
1341 ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; 1339 ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3;
@@ -1344,8 +1342,7 @@ ccio_ioc_init(struct ioc *ioc)
1344 ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, 1342 ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL,
1345 get_order(ioc->res_size)); 1343 get_order(ioc->res_size));
1346 if(NULL == ioc->res_map) { 1344 if(NULL == ioc->res_map) {
1347 panic("%s:%s() could not allocate resource map\n", __FILE__, 1345 panic("%s() could not allocate resource map\n", __FUNCTION__);
1348 __FUNCTION__);
1349 } 1346 }
1350 memset(ioc->res_map, 0, ioc->res_size); 1347 memset(ioc->res_map, 0, ioc->res_size);
1351 1348
@@ -1366,44 +1363,58 @@ ccio_ioc_init(struct ioc *ioc)
1366 ** Initialize IOA hardware 1363 ** Initialize IOA hardware
1367 */ 1364 */
1368 WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, 1365 WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift,
1369 &ioc->ioc_hpa->io_chain_id_mask); 1366 &ioc->ioc_regs->io_chain_id_mask);
1370 1367
1371 WRITE_U32(virt_to_phys(ioc->pdir_base), 1368 WRITE_U32(virt_to_phys(ioc->pdir_base),
1372 &ioc->ioc_hpa->io_pdir_base); 1369 &ioc->ioc_regs->io_pdir_base);
1373 1370
1374 /* 1371 /*
1375 ** Go to "Virtual Mode" 1372 ** Go to "Virtual Mode"
1376 */ 1373 */
1377 WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_hpa->io_control); 1374 WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_regs->io_control);
1378 1375
1379 /* 1376 /*
1380 ** Initialize all I/O TLB entries to 0 (Valid bit off). 1377 ** Initialize all I/O TLB entries to 0 (Valid bit off).
1381 */ 1378 */
1382 WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_m); 1379 WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_m);
1383 WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_l); 1380 WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_l);
1384 1381
1385 for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) { 1382 for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) {
1386 WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), 1383 WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)),
1387 &ioc->ioc_hpa->io_command); 1384 &ioc->ioc_regs->io_command);
1388 } 1385 }
1389} 1386}
1390 1387
1391static void 1388static void
1392ccio_init_resource(struct resource *res, char *name, unsigned long ioaddr) 1389ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
1393{ 1390{
1394 int result; 1391 int result;
1395 1392
1396 res->parent = NULL; 1393 res->parent = NULL;
1397 res->flags = IORESOURCE_MEM; 1394 res->flags = IORESOURCE_MEM;
1398 res->start = (unsigned long)(signed) __raw_readl(ioaddr) << 16; 1395 /*
1399 res->end = (unsigned long)(signed) (__raw_readl(ioaddr + 4) << 16) - 1; 1396 * bracing ((signed) ...) are required for 64bit kernel because
1397 * we only want to sign extend the lower 16 bits of the register.
1398 * The upper 16-bits of range registers are hardcoded to 0xffff.
1399 */
1400 res->start = (unsigned long)((signed) READ_U32(ioaddr) << 16);
1401 res->end = (unsigned long)((signed) (READ_U32(ioaddr + 4) << 16) - 1);
1400 res->name = name; 1402 res->name = name;
1403 /*
1404 * Check if this MMIO range is disable
1405 */
1401 if (res->end + 1 == res->start) 1406 if (res->end + 1 == res->start)
1402 return; 1407 return;
1403 result = request_resource(&iomem_resource, res); 1408
1409 /* On some platforms (e.g. K-Class), we have already registered
1410 * resources for devices reported by firmware. Some are children
1411 * of ccio.
1412 * "insert" ccio ranges in the mmio hierarchy (/proc/iomem).
1413 */
1414 result = insert_resource(&iomem_resource, res);
1404 if (result < 0) { 1415 if (result < 0) {
1405 printk(KERN_ERR "%s: failed to claim CCIO bus address space (%08lx,%08lx)\n", 1416 printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n",
1406 __FILE__, res->start, res->end); 1417 __FUNCTION__, res->start, res->end);
1407 } 1418 }
1408} 1419}
1409 1420
@@ -1414,9 +1425,8 @@ static void __init ccio_init_resources(struct ioc *ioc)
1414 1425
1415 sprintf(name, "GSC Bus [%d/]", ioc->hw_path); 1426 sprintf(name, "GSC Bus [%d/]", ioc->hw_path);
1416 1427
1417 ccio_init_resource(res, name, (unsigned long)&ioc->ioc_hpa->io_io_low); 1428 ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low);
1418 ccio_init_resource(res + 1, name, 1429 ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv);
1419 (unsigned long)&ioc->ioc_hpa->io_io_low_hv);
1420} 1430}
1421 1431
1422static int new_ioc_area(struct resource *res, unsigned long size, 1432static int new_ioc_area(struct resource *res, unsigned long size,
@@ -1427,7 +1437,12 @@ static int new_ioc_area(struct resource *res, unsigned long size,
1427 1437
1428 res->start = (max - size + 1) &~ (align - 1); 1438 res->start = (max - size + 1) &~ (align - 1);
1429 res->end = res->start + size; 1439 res->end = res->start + size;
1430 if (!request_resource(&iomem_resource, res)) 1440
1441 /* We might be trying to expand the MMIO range to include
1442 * a child device that has already registered it's MMIO space.
1443 * Use "insert" instead of request_resource().
1444 */
1445 if (!insert_resource(&iomem_resource, res))
1431 return 0; 1446 return 0;
1432 1447
1433 return new_ioc_area(res, size, min, max - size, align); 1448 return new_ioc_area(res, size, min, max - size, align);
@@ -1486,15 +1501,15 @@ int ccio_allocate_resource(const struct parisc_device *dev,
1486 1501
1487 if (!expand_ioc_area(parent, size, min, max, align)) { 1502 if (!expand_ioc_area(parent, size, min, max, align)) {
1488 __raw_writel(((parent->start)>>16) | 0xffff0000, 1503 __raw_writel(((parent->start)>>16) | 0xffff0000,
1489 (unsigned long)&(ioc->ioc_hpa->io_io_low)); 1504 &ioc->ioc_regs->io_io_low);
1490 __raw_writel(((parent->end)>>16) | 0xffff0000, 1505 __raw_writel(((parent->end)>>16) | 0xffff0000,
1491 (unsigned long)&(ioc->ioc_hpa->io_io_high)); 1506 &ioc->ioc_regs->io_io_high);
1492 } else if (!expand_ioc_area(parent + 1, size, min, max, align)) { 1507 } else if (!expand_ioc_area(parent + 1, size, min, max, align)) {
1493 parent++; 1508 parent++;
1494 __raw_writel(((parent->start)>>16) | 0xffff0000, 1509 __raw_writel(((parent->start)>>16) | 0xffff0000,
1495 (unsigned long)&(ioc->ioc_hpa->io_io_low_hv)); 1510 &ioc->ioc_regs->io_io_low_hv);
1496 __raw_writel(((parent->end)>>16) | 0xffff0000, 1511 __raw_writel(((parent->end)>>16) | 0xffff0000,
1497 (unsigned long)&(ioc->ioc_hpa->io_io_high_hv)); 1512 &ioc->ioc_regs->io_io_high_hv);
1498 } else { 1513 } else {
1499 return -EBUSY; 1514 return -EBUSY;
1500 } 1515 }
@@ -1521,7 +1536,12 @@ int ccio_request_resource(const struct parisc_device *dev,
1521 return -EBUSY; 1536 return -EBUSY;
1522 } 1537 }
1523 1538
1524 return request_resource(parent, res); 1539 /* "transparent" bus bridges need to register MMIO resources
1540 * firmware assigned them. e.g. children of hppb.c (e.g. K-class)
1541 * registered their resources in the PDC "bus walk" (See
1542 * arch/parisc/kernel/inventory.c).
1543 */
1544 return insert_resource(parent, res);
1525} 1545}
1526 1546
1527/** 1547/**
@@ -1546,7 +1566,7 @@ static int ccio_probe(struct parisc_device *dev)
1546 1566
1547 ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn"; 1567 ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
1548 1568
1549 printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa); 1569 printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa.start);
1550 1570
1551 for (i = 0; i < ioc_count; i++) { 1571 for (i = 0; i < ioc_count; i++) {
1552 ioc_p = &(*ioc_p)->next; 1572 ioc_p = &(*ioc_p)->next;
@@ -1554,7 +1574,7 @@ static int ccio_probe(struct parisc_device *dev)
1554 *ioc_p = ioc; 1574 *ioc_p = ioc;
1555 1575
1556 ioc->hw_path = dev->hw_path; 1576 ioc->hw_path = dev->hw_path;
1557 ioc->ioc_hpa = (struct ioa_registers *)dev->hpa; 1577 ioc->ioc_regs = ioremap(dev->hpa.start, 4096);
1558 ccio_ioc_init(ioc); 1578 ccio_ioc_init(ioc);
1559 ccio_init_resources(ioc); 1579 ccio_init_resources(ioc);
1560 hppa_dma_ops = &ccio_ops; 1580 hppa_dma_ops = &ccio_ops;
diff --git a/drivers/parisc/ccio-rm-dma.c b/drivers/parisc/ccio-rm-dma.c
index 57e6385976e2..356b8357bccc 100644
--- a/drivers/parisc/ccio-rm-dma.c
+++ b/drivers/parisc/ccio-rm-dma.c
@@ -167,7 +167,7 @@ ccio_probe(struct parisc_device *dev)
167{ 167{
168 printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME, 168 printk(KERN_INFO "%s found %s at 0x%lx\n", MODULE_NAME,
169 dev->id.hversion == U2_BC_GSC ? "U2" : "UTurn", 169 dev->id.hversion == U2_BC_GSC ? "U2" : "UTurn",
170 dev->hpa); 170 dev->hpa.start);
171 171
172/* 172/*
173** FIXME - should check U2 registers to verify it's really running 173** FIXME - should check U2 registers to verify it's really running
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 2f2dbef2c3b7..5ab75334c579 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -178,6 +178,8 @@ static int dino_cfg_read(struct pci_bus *bus, unsigned int devfn, int where,
178 void __iomem *base_addr = d->hba.base_addr; 178 void __iomem *base_addr = d->hba.base_addr;
179 unsigned long flags; 179 unsigned long flags;
180 180
181 DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where,
182 size);
181 spin_lock_irqsave(&d->dinosaur_pen, flags); 183 spin_lock_irqsave(&d->dinosaur_pen, flags);
182 184
183 /* tell HW which CFG address */ 185 /* tell HW which CFG address */
@@ -211,6 +213,8 @@ static int dino_cfg_write(struct pci_bus *bus, unsigned int devfn, int where,
211 void __iomem *base_addr = d->hba.base_addr; 213 void __iomem *base_addr = d->hba.base_addr;
212 unsigned long flags; 214 unsigned long flags;
213 215
216 DBG("%s: %p, %d, %d, %d\n", __FUNCTION__, base_addr, devfn, where,
217 size);
214 spin_lock_irqsave(&d->dinosaur_pen, flags); 218 spin_lock_irqsave(&d->dinosaur_pen, flags);
215 219
216 /* avoid address stepping feature */ 220 /* avoid address stepping feature */
@@ -295,7 +299,7 @@ static void dino_disable_irq(unsigned int irq)
295 struct dino_device *dino_dev = irq_desc[irq].handler_data; 299 struct dino_device *dino_dev = irq_desc[irq].handler_data;
296 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); 300 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq);
297 301
298 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, irq_dev, irq); 302 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq);
299 303
300 /* Clear the matching bit in the IMR register */ 304 /* Clear the matching bit in the IMR register */
301 dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq)); 305 dino_dev->imr &= ~(DINO_MASK_IRQ(local_irq));
@@ -308,7 +312,7 @@ static void dino_enable_irq(unsigned int irq)
308 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq); 312 int local_irq = gsc_find_local_irq(irq, dino_dev->global_irq, irq);
309 u32 tmp; 313 u32 tmp;
310 314
311 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, irq_dev, irq); 315 DBG(KERN_WARNING "%s(0x%p, %d)\n", __FUNCTION__, dino_dev, irq);
312 316
313 /* 317 /*
314 ** clear pending IRQ bits 318 ** clear pending IRQ bits
@@ -490,7 +494,7 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr)
490 if (res->start == F_EXTEND(0xf0000000UL | (i * _8MB))) 494 if (res->start == F_EXTEND(0xf0000000UL | (i * _8MB)))
491 break; 495 break;
492 } 496 }
493 DBG("DINO GSC WRITE i=%d, start=%lx, dino addr = %lx\n", 497 DBG("DINO GSC WRITE i=%d, start=%lx, dino addr = %p\n",
494 i, res->start, base_addr + DINO_IO_ADDR_EN); 498 i, res->start, base_addr + DINO_IO_ADDR_EN);
495 __raw_writel(1 << i, base_addr + DINO_IO_ADDR_EN); 499 __raw_writel(1 << i, base_addr + DINO_IO_ADDR_EN);
496} 500}
@@ -683,6 +687,14 @@ static void __init
683dino_card_init(struct dino_device *dino_dev) 687dino_card_init(struct dino_device *dino_dev)
684{ 688{
685 u32 brdg_feat = 0x00784e05; 689 u32 brdg_feat = 0x00784e05;
690 unsigned long status;
691
692 status = __raw_readl(dino_dev->hba.base_addr+DINO_IO_STATUS);
693 if (status & 0x0000ff80) {
694 __raw_writel(0x00000005,
695 dino_dev->hba.base_addr+DINO_IO_COMMAND);
696 udelay(1);
697 }
686 698
687 __raw_writel(0x00000000, dino_dev->hba.base_addr+DINO_GMASK); 699 __raw_writel(0x00000000, dino_dev->hba.base_addr+DINO_GMASK);
688 __raw_writel(0x00000001, dino_dev->hba.base_addr+DINO_IO_FBB_EN); 700 __raw_writel(0x00000001, dino_dev->hba.base_addr+DINO_IO_FBB_EN);
@@ -902,15 +914,15 @@ void ccio_cujo20_fixup(struct parisc_device *dev, u32 iovp);
902** If so, initialize the chip appropriately (card-mode vs bridge mode). 914** If so, initialize the chip appropriately (card-mode vs bridge mode).
903** Much of the initialization is common though. 915** Much of the initialization is common though.
904*/ 916*/
905static int __init 917static int __init dino_probe(struct parisc_device *dev)
906dino_driver_callback(struct parisc_device *dev)
907{ 918{
908 struct dino_device *dino_dev; // Dino specific control struct 919 struct dino_device *dino_dev; // Dino specific control struct
909 const char *version = "unknown"; 920 const char *version = "unknown";
910 char *name; 921 char *name;
911 int is_cujo = 0; 922 int is_cujo = 0;
912 struct pci_bus *bus; 923 struct pci_bus *bus;
913 924 unsigned long hpa = dev->hpa.start;
925
914 name = "Dino"; 926 name = "Dino";
915 if (is_card_dino(&dev->id)) { 927 if (is_card_dino(&dev->id)) {
916 version = "3.x (card mode)"; 928 version = "3.x (card mode)";
@@ -928,11 +940,11 @@ dino_driver_callback(struct parisc_device *dev)
928 } 940 }
929 } 941 }
930 942
931 printk("%s version %s found at 0x%lx\n", name, version, dev->hpa); 943 printk("%s version %s found at 0x%lx\n", name, version, hpa);
932 944
933 if (!request_mem_region(dev->hpa, PAGE_SIZE, name)) { 945 if (!request_mem_region(hpa, PAGE_SIZE, name)) {
934 printk(KERN_ERR "DINO: Hey! Someone took my MMIO space (0x%ld)!\n", 946 printk(KERN_ERR "DINO: Hey! Someone took my MMIO space (0x%ld)!\n",
935 dev->hpa); 947 hpa);
936 return 1; 948 return 1;
937 } 949 }
938 950
@@ -940,12 +952,12 @@ dino_driver_callback(struct parisc_device *dev)
940 if (is_cujo && dev->id.hversion_rev == 1) { 952 if (is_cujo && dev->id.hversion_rev == 1) {
941#ifdef CONFIG_IOMMU_CCIO 953#ifdef CONFIG_IOMMU_CCIO
942 printk(KERN_WARNING "Enabling Cujo 2.0 bug workaround\n"); 954 printk(KERN_WARNING "Enabling Cujo 2.0 bug workaround\n");
943 if (dev->hpa == (unsigned long)CUJO_RAVEN_ADDR) { 955 if (hpa == (unsigned long)CUJO_RAVEN_ADDR) {
944 ccio_cujo20_fixup(dev, CUJO_RAVEN_BADPAGE); 956 ccio_cujo20_fixup(dev, CUJO_RAVEN_BADPAGE);
945 } else if (dev->hpa == (unsigned long)CUJO_FIREHAWK_ADDR) { 957 } else if (hpa == (unsigned long)CUJO_FIREHAWK_ADDR) {
946 ccio_cujo20_fixup(dev, CUJO_FIREHAWK_BADPAGE); 958 ccio_cujo20_fixup(dev, CUJO_FIREHAWK_BADPAGE);
947 } else { 959 } else {
948 printk("Don't recognise Cujo at address 0x%lx, not enabling workaround\n", dev->hpa); 960 printk("Don't recognise Cujo at address 0x%lx, not enabling workaround\n", hpa);
949 } 961 }
950#endif 962#endif
951 } else if (!is_cujo && !is_card_dino(&dev->id) && 963 } else if (!is_cujo && !is_card_dino(&dev->id) &&
@@ -970,7 +982,7 @@ dino_driver_callback(struct parisc_device *dev)
970 memset(dino_dev, 0, sizeof(struct dino_device)); 982 memset(dino_dev, 0, sizeof(struct dino_device));
971 983
972 dino_dev->hba.dev = dev; 984 dino_dev->hba.dev = dev;
973 dino_dev->hba.base_addr = ioremap(dev->hpa, 4096); /* faster access */ 985 dino_dev->hba.base_addr = ioremap(hpa, 4096);
974 dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ 986 dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */
975 spin_lock_init(&dino_dev->dinosaur_pen); 987 spin_lock_init(&dino_dev->dinosaur_pen);
976 dino_dev->hba.iommu = ccio_get_iommu(dev); 988 dino_dev->hba.iommu = ccio_get_iommu(dev);
@@ -1027,9 +1039,9 @@ static struct parisc_device_id dino_tbl[] = {
1027}; 1039};
1028 1040
1029static struct parisc_driver dino_driver = { 1041static struct parisc_driver dino_driver = {
1030 .name = "Dino", 1042 .name = "dino",
1031 .id_table = dino_tbl, 1043 .id_table = dino_tbl,
1032 .probe = dino_driver_callback, 1044 .probe = dino_probe,
1033}; 1045};
1034 1046
1035/* 1047/*
diff --git a/drivers/parisc/eisa.c b/drivers/parisc/eisa.c
index 043d47aea75b..6362bf99eff6 100644
--- a/drivers/parisc/eisa.c
+++ b/drivers/parisc/eisa.c
@@ -315,7 +315,7 @@ static int __devinit eisa_probe(struct parisc_device *dev)
315 char *name = is_mongoose(dev) ? "Mongoose" : "Wax"; 315 char *name = is_mongoose(dev) ? "Mongoose" : "Wax";
316 316
317 printk(KERN_INFO "%s EISA Adapter found at 0x%08lx\n", 317 printk(KERN_INFO "%s EISA Adapter found at 0x%08lx\n",
318 name, dev->hpa); 318 name, dev->hpa.start);
319 319
320 eisa_dev.hba.dev = dev; 320 eisa_dev.hba.dev = dev;
321 eisa_dev.hba.iommu = ccio_get_iommu(dev); 321 eisa_dev.hba.iommu = ccio_get_iommu(dev);
@@ -397,7 +397,7 @@ static struct parisc_device_id eisa_tbl[] = {
397MODULE_DEVICE_TABLE(parisc, eisa_tbl); 397MODULE_DEVICE_TABLE(parisc, eisa_tbl);
398 398
399static struct parisc_driver eisa_driver = { 399static struct parisc_driver eisa_driver = {
400 .name = "EISA Bus Adapter", 400 .name = "eisa_ba",
401 .id_table = eisa_tbl, 401 .id_table = eisa_tbl,
402 .probe = eisa_probe, 402 .probe = eisa_probe,
403}; 403};
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index af5e02526a18..16d40f95978d 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -183,12 +183,20 @@ void gsc_asic_assign_irq(struct gsc_asic *asic, int local_irq, int *irqp)
183 *irqp = irq; 183 *irqp = irq;
184} 184}
185 185
186static struct device *next_device(struct klist_iter *i)
187{
188 struct klist_node * n = klist_next(i);
189 return n ? container_of(n, struct device, knode_parent) : NULL;
190}
191
186void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, 192void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl,
187 void (*choose_irq)(struct parisc_device *, void *)) 193 void (*choose_irq)(struct parisc_device *, void *))
188{ 194{
189 struct device *dev; 195 struct device *dev;
196 struct klist_iter i;
190 197
191 list_for_each_entry(dev, &parent->dev.children, node) { 198 klist_iter_init(&parent->dev.klist_children, &i);
199 while ((dev = next_device(&i))) {
192 struct parisc_device *padev = to_parisc_device(dev); 200 struct parisc_device *padev = to_parisc_device(dev);
193 201
194 /* work-around for 715/64 and others which have parent 202 /* work-around for 715/64 and others which have parent
@@ -197,6 +205,7 @@ void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl,
197 return gsc_fixup_irqs(padev, ctrl, choose_irq); 205 return gsc_fixup_irqs(padev, ctrl, choose_irq);
198 choose_irq(padev, ctrl); 206 choose_irq(padev, ctrl);
199 } 207 }
208 klist_iter_exit(&i);
200} 209}
201 210
202int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic) 211int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic)
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index e869c6020370..5edf93f80757 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -68,14 +68,14 @@ static int hppb_probe(struct parisc_device *dev)
68 memset(card->next, '\0', sizeof(struct hppb_card)); 68 memset(card->next, '\0', sizeof(struct hppb_card));
69 card = card->next; 69 card = card->next;
70 } 70 }
71 printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa); 71 printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start);
72 72
73 card->hpa = dev->hpa; 73 card->hpa = dev->hpa.start;
74 card->mmio_region.name = "HP-PB Bus"; 74 card->mmio_region.name = "HP-PB Bus";
75 card->mmio_region.flags = IORESOURCE_MEM; 75 card->mmio_region.flags = IORESOURCE_MEM;
76 76
77 card->mmio_region.start = __raw_readl(dev->hpa + IO_IO_LOW); 77 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW);
78 card->mmio_region.end = __raw_readl(dev->hpa + IO_IO_HIGH) - 1; 78 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1;
79 79
80 status = ccio_request_resource(dev, &card->mmio_region); 80 status = ccio_request_resource(dev, &card->mmio_region);
81 if(status < 0) { 81 if(status < 0) {
@@ -93,7 +93,7 @@ static struct parisc_device_id hppb_tbl[] = {
93}; 93};
94 94
95static struct parisc_driver hppb_driver = { 95static struct parisc_driver hppb_driver = {
96 .name = "Gecko Boa", 96 .name = "gecko_boa",
97 .id_table = hppb_tbl, 97 .id_table = hppb_tbl,
98 .probe = hppb_probe, 98 .probe = hppb_probe,
99}; 99};
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 7a57c1b8373f..a39fbfef789a 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -244,7 +244,7 @@ static struct irt_entry *iosapic_alloc_irt(int num_entries)
244 * 4-byte alignment on 32-bit kernels 244 * 4-byte alignment on 32-bit kernels
245 */ 245 */
246 a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL); 246 a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, GFP_KERNEL);
247 a = (a + 7) & ~7; 247 a = (a + 7UL) & ~7UL;
248 return (struct irt_entry *)a; 248 return (struct irt_entry *)a;
249} 249}
250 250
diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c
index cb84a4e84a2f..a8c20396ffbe 100644
--- a/drivers/parisc/lasi.c
+++ b/drivers/parisc/lasi.c
@@ -175,7 +175,7 @@ lasi_init_chip(struct parisc_device *dev)
175 return -ENOMEM; 175 return -ENOMEM;
176 176
177 lasi->name = "Lasi"; 177 lasi->name = "Lasi";
178 lasi->hpa = dev->hpa; 178 lasi->hpa = dev->hpa.start;
179 179
180 /* Check the 4-bit (yes, only 4) version register */ 180 /* Check the 4-bit (yes, only 4) version register */
181 lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf; 181 lasi->version = gsc_readl(lasi->hpa + LASI_VER) & 0xf;
@@ -233,7 +233,7 @@ static struct parisc_device_id lasi_tbl[] = {
233}; 233};
234 234
235struct parisc_driver lasi_driver = { 235struct parisc_driver lasi_driver = {
236 .name = "Lasi", 236 .name = "lasi",
237 .id_table = lasi_tbl, 237 .id_table = lasi_tbl,
238 .probe = lasi_init_chip, 238 .probe = lasi_init_chip,
239}; 239};
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 7fdd80b7eb47..5e495dcbc58a 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -1288,7 +1288,7 @@ lba_legacy_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
1288 ** Adjust "window" for this rope. 1288 ** Adjust "window" for this rope.
1289 */ 1289 */
1290 rsize /= ROPES_PER_IOC; 1290 rsize /= ROPES_PER_IOC;
1291 r->start += (rsize + 1) * LBA_NUM(pa_dev->hpa); 1291 r->start += (rsize + 1) * LBA_NUM(pa_dev->hpa.start);
1292 r->end = r->start + rsize; 1292 r->end = r->start + rsize;
1293 } else { 1293 } else {
1294 r->end = r->start = 0; /* Not enabled. */ 1294 r->end = r->start = 0; /* Not enabled. */
@@ -1458,7 +1458,7 @@ lba_driver_probe(struct parisc_device *dev)
1458 u32 func_class; 1458 u32 func_class;
1459 void *tmp_obj; 1459 void *tmp_obj;
1460 char *version; 1460 char *version;
1461 void __iomem *addr = ioremap(dev->hpa, 4096); 1461 void __iomem *addr = ioremap(dev->hpa.start, 4096);
1462 1462
1463 /* Read HW Rev First */ 1463 /* Read HW Rev First */
1464 func_class = READ_REG32(addr + LBA_FCLASS); 1464 func_class = READ_REG32(addr + LBA_FCLASS);
@@ -1476,7 +1476,7 @@ lba_driver_probe(struct parisc_device *dev)
1476 } 1476 }
1477 1477
1478 printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", 1478 printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n",
1479 MODULE_NAME, version, func_class & 0xf, dev->hpa); 1479 MODULE_NAME, version, func_class & 0xf, dev->hpa.start);
1480 1480
1481 if (func_class < 2) { 1481 if (func_class < 2) {
1482 printk(KERN_WARNING "Can't support LBA older than " 1482 printk(KERN_WARNING "Can't support LBA older than "
@@ -1503,17 +1503,17 @@ lba_driver_probe(struct parisc_device *dev)
1503 * but for the mask for func_class. 1503 * but for the mask for func_class.
1504 */ 1504 */
1505 printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n", 1505 printk(KERN_INFO "%s version %s (0x%x) found at 0x%lx\n",
1506 MODULE_NAME, version, func_class & 0xff, dev->hpa); 1506 MODULE_NAME, version, func_class & 0xff, dev->hpa.start);
1507 cfg_ops = &mercury_cfg_ops; 1507 cfg_ops = &mercury_cfg_ops;
1508 } else { 1508 } else {
1509 printk(KERN_ERR "Unknown LBA found at 0x%lx\n", dev->hpa); 1509 printk(KERN_ERR "Unknown LBA found at 0x%lx\n", dev->hpa.start);
1510 return -ENODEV; 1510 return -ENODEV;
1511 } 1511 }
1512 1512
1513 /* 1513 /*
1514 ** Tell I/O SAPIC driver we have a IRQ handler/region. 1514 ** Tell I/O SAPIC driver we have a IRQ handler/region.
1515 */ 1515 */
1516 tmp_obj = iosapic_register(dev->hpa + LBA_IOSAPIC_BASE); 1516 tmp_obj = iosapic_register(dev->hpa.start + LBA_IOSAPIC_BASE);
1517 1517
1518 /* NOTE: PCI devices (e.g. 103c:1005 graphics card) which don't 1518 /* NOTE: PCI devices (e.g. 103c:1005 graphics card) which don't
1519 ** have an IRT entry will get NULL back from iosapic code. 1519 ** have an IRT entry will get NULL back from iosapic code.
@@ -1635,7 +1635,7 @@ void __init lba_init(void)
1635*/ 1635*/
1636void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask) 1636void lba_set_iregs(struct parisc_device *lba, u32 ibase, u32 imask)
1637{ 1637{
1638 void __iomem * base_addr = ioremap(lba->hpa, 4096); 1638 void __iomem * base_addr = ioremap(lba->hpa.start, 4096);
1639 1639
1640 imask <<= 2; /* adjust for hints - 2 more bits */ 1640 imask <<= 2; /* adjust for hints - 2 more bits */
1641 1641
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 286902298e33..95bd07b8b61b 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -18,6 +18,9 @@
18 * Changes: 18 * Changes:
19 * - Audit copy_from_user in led_proc_write. 19 * - Audit copy_from_user in led_proc_write.
20 * Daniele Bellucci <bellucda@tiscali.it> 20 * Daniele Bellucci <bellucda@tiscali.it>
21 * - Switch from using a tasklet to a work queue, so the led_LCD_driver
22 * can sleep.
23 * David Pye <dmp@davidmpye.dyndns.org>
21 */ 24 */
22 25
23#include <linux/config.h> 26#include <linux/config.h>
@@ -37,6 +40,7 @@
37#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
38#include <linux/ctype.h> 41#include <linux/ctype.h>
39#include <linux/blkdev.h> 42#include <linux/blkdev.h>
43#include <linux/workqueue.h>
40#include <linux/rcupdate.h> 44#include <linux/rcupdate.h>
41#include <asm/io.h> 45#include <asm/io.h>
42#include <asm/processor.h> 46#include <asm/processor.h>
@@ -47,25 +51,30 @@
47#include <asm/uaccess.h> 51#include <asm/uaccess.h>
48 52
49/* The control of the LEDs and LCDs on PARISC-machines have to be done 53/* The control of the LEDs and LCDs on PARISC-machines have to be done
50 completely in software. The necessary calculations are done in a tasklet 54 completely in software. The necessary calculations are done in a work queue
51 which is scheduled at every timer interrupt and since the calculations 55 task which is scheduled regularly, and since the calculations may consume a
52 may consume relatively much CPU-time some of the calculations can be 56 relatively large amount of CPU time, some of the calculations can be
53 turned off with the following variables (controlled via procfs) */ 57 turned off with the following variables (controlled via procfs) */
54 58
55static int led_type = -1; 59static int led_type = -1;
56static int led_heartbeat = 1; 60static unsigned char lastleds; /* LED state from most recent update */
57static int led_diskio = 1; 61static unsigned int led_heartbeat = 1;
58static int led_lanrxtx = 1; 62static unsigned int led_diskio = 1;
63static unsigned int led_lanrxtx = 1;
59static char lcd_text[32]; 64static char lcd_text[32];
60static char lcd_text_default[32]; 65static char lcd_text_default[32];
61 66
67
68static struct workqueue_struct *led_wq;
69static void led_work_func(void *);
70static DECLARE_WORK(led_task, led_work_func, NULL);
71
62#if 0 72#if 0
63#define DPRINTK(x) printk x 73#define DPRINTK(x) printk x
64#else 74#else
65#define DPRINTK(x) 75#define DPRINTK(x)
66#endif 76#endif
67 77
68
69struct lcd_block { 78struct lcd_block {
70 unsigned char command; /* stores the command byte */ 79 unsigned char command; /* stores the command byte */
71 unsigned char on; /* value for turning LED on */ 80 unsigned char on; /* value for turning LED on */
@@ -116,12 +125,27 @@ lcd_info __attribute__((aligned(8))) =
116#define LCD_DATA_REG lcd_info.lcd_data_reg_addr 125#define LCD_DATA_REG lcd_info.lcd_data_reg_addr
117#define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */ 126#define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */
118 127
128#define LED_HASLCD 1
129#define LED_NOLCD 0
130
131/* The workqueue must be created at init-time */
132static int start_task(void)
133{
134 /* Display the default text now */
135 if (led_type == LED_HASLCD) lcd_print( lcd_text_default );
136
137 /* Create the work queue and queue the LED task */
138 led_wq = create_singlethread_workqueue("led_wq");
139 queue_work(led_wq, &led_task);
140
141 return 0;
142}
143
144device_initcall(start_task);
119 145
120/* ptr to LCD/LED-specific function */ 146/* ptr to LCD/LED-specific function */
121static void (*led_func_ptr) (unsigned char); 147static void (*led_func_ptr) (unsigned char);
122 148
123#define LED_HASLCD 1
124#define LED_NOLCD 0
125#ifdef CONFIG_PROC_FS 149#ifdef CONFIG_PROC_FS
126static int led_proc_read(char *page, char **start, off_t off, int count, 150static int led_proc_read(char *page, char **start, off_t off, int count,
127 int *eof, void *data) 151 int *eof, void *data)
@@ -286,52 +310,35 @@ static void led_LASI_driver(unsigned char leds)
286/* 310/*
287 ** 311 **
288 ** led_LCD_driver() 312 ** led_LCD_driver()
289 **
290 ** The logic of the LCD driver is, that we write at every scheduled call
291 ** only to one of LCD_CMD_REG _or_ LCD_DATA_REG - registers.
292 ** That way we don't need to let this tasklet busywait for min_cmd_delay
293 ** milliseconds.
294 **
295 ** TODO: check the value of "min_cmd_delay" against the value of HZ.
296 ** 313 **
297 */ 314 */
298static void led_LCD_driver(unsigned char leds) 315static void led_LCD_driver(unsigned char leds)
299{ 316{
300 static int last_index; /* 0:heartbeat, 1:disk, 2:lan_in, 3:lan_out */ 317 static int i;
301 static int last_was_cmd;/* 0: CMD was written last, 1: DATA was last */ 318 static unsigned char mask[4] = { LED_HEARTBEAT, LED_DISK_IO,
302 struct lcd_block *block_ptr; 319 LED_LAN_RCV, LED_LAN_TX };
303 int value;
304
305 switch (last_index) {
306 case 0: block_ptr = &lcd_info.heartbeat;
307 value = leds & LED_HEARTBEAT;
308 break;
309 case 1: block_ptr = &lcd_info.disk_io;
310 value = leds & LED_DISK_IO;
311 break;
312 case 2: block_ptr = &lcd_info.lan_rcv;
313 value = leds & LED_LAN_RCV;
314 break;
315 case 3: block_ptr = &lcd_info.lan_tx;
316 value = leds & LED_LAN_TX;
317 break;
318 default: /* should never happen: */
319 return;
320 }
321
322 if (last_was_cmd) {
323 /* write the value to the LCD data port */
324 gsc_writeb( value ? block_ptr->on : block_ptr->off, LCD_DATA_REG );
325 } else {
326 /* write the command-byte to the LCD command register */
327 gsc_writeb( block_ptr->command, LCD_CMD_REG );
328 }
329 320
330 /* now update the vars for the next interrupt iteration */ 321 static struct lcd_block * blockp[4] = {
331 if (++last_was_cmd == 2) { /* switch between cmd & data */ 322 &lcd_info.heartbeat,
332 last_was_cmd = 0; 323 &lcd_info.disk_io,
333 if (++last_index == 4) 324 &lcd_info.lan_rcv,
334 last_index = 0; /* switch back to heartbeat index */ 325 &lcd_info.lan_tx
326 };
327
328 /* Convert min_cmd_delay to milliseconds */
329 unsigned int msec_cmd_delay = 1 + (lcd_info.min_cmd_delay / 1000);
330
331 for (i=0; i<4; ++i)
332 {
333 if ((leds & mask[i]) != (lastleds & mask[i]))
334 {
335 gsc_writeb( blockp[i]->command, LCD_CMD_REG );
336 msleep(msec_cmd_delay);
337
338 gsc_writeb( leds & mask[i] ? blockp[i]->on :
339 blockp[i]->off, LCD_DATA_REG );
340 msleep(msec_cmd_delay);
341 }
335 } 342 }
336} 343}
337 344
@@ -356,7 +363,7 @@ static __inline__ int led_get_net_activity(void)
356 363
357 rx_total = tx_total = 0; 364 rx_total = tx_total = 0;
358 365
359 /* we are running as tasklet, so locking dev_base 366 /* we are running as a workqueue task, so locking dev_base
360 * for reading should be OK */ 367 * for reading should be OK */
361 read_lock(&dev_base_lock); 368 read_lock(&dev_base_lock);
362 rcu_read_lock(); 369 rcu_read_lock();
@@ -405,7 +412,7 @@ static __inline__ int led_get_diskio_activity(void)
405 static unsigned long last_pgpgin, last_pgpgout; 412 static unsigned long last_pgpgin, last_pgpgout;
406 struct page_state pgstat; 413 struct page_state pgstat;
407 int changed; 414 int changed;
408 415
409 get_full_page_state(&pgstat); /* get no of sectors in & out */ 416 get_full_page_state(&pgstat); /* get no of sectors in & out */
410 417
411 /* Just use a very simple calculation here. Do not care about overflow, 418 /* Just use a very simple calculation here. Do not care about overflow,
@@ -413,86 +420,70 @@ static __inline__ int led_get_diskio_activity(void)
413 changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout); 420 changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout);
414 last_pgpgin = pgstat.pgpgin; 421 last_pgpgin = pgstat.pgpgin;
415 last_pgpgout = pgstat.pgpgout; 422 last_pgpgout = pgstat.pgpgout;
416 423
417 return (changed ? LED_DISK_IO : 0); 424 return (changed ? LED_DISK_IO : 0);
418} 425}
419 426
420 427
421 428
422/* 429/*
423 ** led_tasklet_func() 430 ** led_work_func()
424 ** 431 **
425 ** is scheduled at every timer interrupt from time.c and 432 ** manages when and which chassis LCD/LED gets updated
426 ** updates the chassis LCD/LED
427 433
428 TODO: 434 TODO:
429 - display load average (older machines like 715/64 have 4 "free" LED's for that) 435 - display load average (older machines like 715/64 have 4 "free" LED's for that)
430 - optimizations 436 - optimizations
431 */ 437 */
432 438
433#define HEARTBEAT_LEN (HZ*6/100) 439#define HEARTBEAT_LEN (HZ*10/100)
434#define HEARTBEAT_2ND_RANGE_START (HZ*22/100) 440#define HEARTBEAT_2ND_RANGE_START (HZ*28/100)
435#define HEARTBEAT_2ND_RANGE_END (HEARTBEAT_2ND_RANGE_START + HEARTBEAT_LEN) 441#define HEARTBEAT_2ND_RANGE_END (HEARTBEAT_2ND_RANGE_START + HEARTBEAT_LEN)
436 442
437#define NORMALIZED_COUNT(count) (count/(HZ/100)) 443#define LED_UPDATE_INTERVAL (1 + (HZ*19/1000))
438 444
439static void led_tasklet_func(unsigned long unused) 445static void led_work_func (void *unused)
440{ 446{
441 static unsigned char lastleds; 447 static unsigned long last_jiffies;
442 unsigned char currentleds; /* stores current value of the LEDs */
443 static unsigned long count; /* static incremented value, not wrapped */
444 static unsigned long count_HZ; /* counter in range 0..HZ */ 448 static unsigned long count_HZ; /* counter in range 0..HZ */
449 unsigned char currentleds = 0; /* stores current value of the LEDs */
445 450
446 /* exit if not initialized */ 451 /* exit if not initialized */
447 if (!led_func_ptr) 452 if (!led_func_ptr)
448 return; 453 return;
449 454
450 /* increment the local counters */ 455 /* increment the heartbeat timekeeper */
451 ++count; 456 count_HZ += jiffies - last_jiffies;
452 if (++count_HZ == HZ) 457 last_jiffies = jiffies;
458 if (count_HZ >= HZ)
453 count_HZ = 0; 459 count_HZ = 0;
454 460
455 currentleds = lastleds; 461 if (likely(led_heartbeat))
456
457 if (led_heartbeat)
458 {
459 /* flash heartbeat-LED like a real heart (2 x short then a long delay) */
460 if (count_HZ<HEARTBEAT_LEN ||
461 (count_HZ>=HEARTBEAT_2ND_RANGE_START && count_HZ<HEARTBEAT_2ND_RANGE_END))
462 currentleds |= LED_HEARTBEAT;
463 else
464 currentleds &= ~LED_HEARTBEAT;
465 }
466
467 /* look for network activity and flash LEDs respectively */
468 if (led_lanrxtx && ((NORMALIZED_COUNT(count)+(8/2)) & 7) == 0)
469 { 462 {
470 currentleds &= ~(LED_LAN_RCV | LED_LAN_TX); 463 /* flash heartbeat-LED like a real heart
471 currentleds |= led_get_net_activity(); 464 * (2 x short then a long delay)
465 */
466 if (count_HZ < HEARTBEAT_LEN ||
467 (count_HZ >= HEARTBEAT_2ND_RANGE_START &&
468 count_HZ < HEARTBEAT_2ND_RANGE_END))
469 currentleds |= LED_HEARTBEAT;
472 } 470 }
473 471
474 /* avoid to calculate diskio-stats at same irq as netio-stats */ 472 if (likely(led_lanrxtx)) currentleds |= led_get_net_activity();
475 if (led_diskio && (NORMALIZED_COUNT(count) & 7) == 0) 473 if (likely(led_diskio)) currentleds |= led_get_diskio_activity();
476 {
477 currentleds &= ~LED_DISK_IO;
478 currentleds |= led_get_diskio_activity();
479 }
480 474
481 /* blink all LEDs twice a second if we got an Oops (HPMC) */ 475 /* blink all LEDs twice a second if we got an Oops (HPMC) */
482 if (oops_in_progress) { 476 if (unlikely(oops_in_progress))
483 currentleds = (count_HZ<=(HZ/2)) ? 0 : 0xff; 477 currentleds = (count_HZ<=(HZ/2)) ? 0 : 0xff;
484 }
485
486 /* update the LCD/LEDs */
487 if (currentleds != lastleds) {
488 led_func_ptr(currentleds);
489 lastleds = currentleds;
490 }
491}
492 478
493/* main led tasklet struct (scheduled from time.c) */ 479 if (currentleds != lastleds)
494DECLARE_TASKLET_DISABLED(led_tasklet, led_tasklet_func, 0); 480 {
481 led_func_ptr(currentleds); /* Update the LCD/LEDs */
482 lastleds = currentleds;
483 }
495 484
485 queue_delayed_work(led_wq, &led_task, LED_UPDATE_INTERVAL);
486}
496 487
497/* 488/*
498 ** led_halt() 489 ** led_halt()
@@ -522,9 +513,13 @@ static int led_halt(struct notifier_block *nb, unsigned long event, void *buf)
522 default: return NOTIFY_DONE; 513 default: return NOTIFY_DONE;
523 } 514 }
524 515
525 /* completely stop the LED/LCD tasklet */ 516 /* Cancel the work item and delete the queue */
526 tasklet_disable(&led_tasklet); 517 if (led_wq) {
527 518 cancel_rearming_delayed_workqueue(led_wq, &led_task);
519 destroy_workqueue(led_wq);
520 led_wq = NULL;
521 }
522
528 if (lcd_info.model == DISPLAY_MODEL_LCD) 523 if (lcd_info.model == DISPLAY_MODEL_LCD)
529 lcd_print(txt); 524 lcd_print(txt);
530 else 525 else
@@ -559,7 +554,6 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
559 printk(KERN_INFO "LCD display at %lx,%lx registered\n", 554 printk(KERN_INFO "LCD display at %lx,%lx registered\n",
560 LCD_CMD_REG , LCD_DATA_REG); 555 LCD_CMD_REG , LCD_DATA_REG);
561 led_func_ptr = led_LCD_driver; 556 led_func_ptr = led_LCD_driver;
562 lcd_print( lcd_text_default );
563 led_type = LED_HASLCD; 557 led_type = LED_HASLCD;
564 break; 558 break;
565 559
@@ -589,9 +583,11 @@ int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long d
589 initialized++; 583 initialized++;
590 register_reboot_notifier(&led_notifier); 584 register_reboot_notifier(&led_notifier);
591 585
592 /* start the led tasklet for the first time */ 586 /* Ensure the work is queued */
593 tasklet_enable(&led_tasklet); 587 if (led_wq) {
594 588 queue_work(led_wq, &led_task);
589 }
590
595 return 0; 591 return 0;
596} 592}
597 593
@@ -626,8 +622,8 @@ void __init register_led_regions(void)
626 ** lcd_print() 622 ** lcd_print()
627 ** 623 **
628 ** Displays the given string on the LCD-Display of newer machines. 624 ** Displays the given string on the LCD-Display of newer machines.
629 ** lcd_print() disables the timer-based led tasklet during its 625 ** lcd_print() disables/enables the timer-based led work queue to
630 ** execution and enables it afterwards again. 626 ** avoid a race condition while writing the CMD/DATA register pair.
631 ** 627 **
632 */ 628 */
633int lcd_print( char *str ) 629int lcd_print( char *str )
@@ -637,12 +633,13 @@ int lcd_print( char *str )
637 if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD) 633 if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD)
638 return 0; 634 return 0;
639 635
640 /* temporarily disable the led tasklet */ 636 /* temporarily disable the led work task */
641 tasklet_disable(&led_tasklet); 637 if (led_wq)
638 cancel_rearming_delayed_workqueue(led_wq, &led_task);
642 639
643 /* copy display string to buffer for procfs */ 640 /* copy display string to buffer for procfs */
644 strlcpy(lcd_text, str, sizeof(lcd_text)); 641 strlcpy(lcd_text, str, sizeof(lcd_text));
645 642
646 /* Set LCD Cursor to 1st character */ 643 /* Set LCD Cursor to 1st character */
647 gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG); 644 gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG);
648 udelay(lcd_info.min_cmd_delay); 645 udelay(lcd_info.min_cmd_delay);
@@ -656,8 +653,10 @@ int lcd_print( char *str )
656 udelay(lcd_info.min_cmd_delay); 653 udelay(lcd_info.min_cmd_delay);
657 } 654 }
658 655
659 /* re-enable the led tasklet */ 656 /* re-queue the work */
660 tasklet_enable(&led_tasklet); 657 if (led_wq) {
658 queue_work(led_wq, &led_task);
659 }
661 660
662 return lcd_info.lcd_width; 661 return lcd_info.lcd_width;
663} 662}
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 67c8f3b44848..273a74179720 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -536,7 +536,7 @@ pdcs_info_read(struct subsystem *entry, char *buf)
536 536
537 out += sprintf(out, "Memory tested: "); 537 out += sprintf(out, "Memory tested: ");
538 if ((result & 0x0F) < 0x0E) 538 if ((result & 0x0F) < 0x0E)
539 out += sprintf(out, "%.3f MB", 0.256*(1<<(result & 0x0F))); 539 out += sprintf(out, "%d kB", (1<<(result & 0x0F))*256);
540 else 540 else
541 out += sprintf(out, "All"); 541 out += sprintf(out, "All");
542 out += sprintf(out, "\n"); 542 out += sprintf(out, "\n");
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 82ea68b55df4..c85653f315aa 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -91,8 +91,8 @@ extern struct proc_dir_entry * proc_mckinley_root;
91#define DBG_RES(x...) 91#define DBG_RES(x...)
92#endif 92#endif
93 93
94#if defined(__LP64__) && !defined(CONFIG_PDC_NARROW) 94#if defined(CONFIG_64BIT)
95/* "low end" PA8800 machines use ZX1 chipset */ 95/* "low end" PA8800 machines use ZX1 chipset: PAT PDC and only run 64-bit */
96#define ZX1_SUPPORT 96#define ZX1_SUPPORT
97#endif 97#endif
98 98
@@ -231,7 +231,7 @@ struct ioc {
231 spinlock_t res_lock; 231 spinlock_t res_lock;
232 unsigned int res_bitshift; /* from the LEFT! */ 232 unsigned int res_bitshift; /* from the LEFT! */
233 unsigned int res_size; /* size of resource map in bytes */ 233 unsigned int res_size; /* size of resource map in bytes */
234#if SBA_HINT_SUPPORT 234#ifdef SBA_HINT_SUPPORT
235/* FIXME : DMA HINTs not used */ 235/* FIXME : DMA HINTs not used */
236 unsigned long hint_mask_pdir; /* bits used for DMA hints */ 236 unsigned long hint_mask_pdir; /* bits used for DMA hints */
237 unsigned int hint_shift_pdir; 237 unsigned int hint_shift_pdir;
@@ -294,7 +294,7 @@ static unsigned long piranha_bad_128k = 0;
294/* Looks nice and keeps the compiler happy */ 294/* Looks nice and keeps the compiler happy */
295#define SBA_DEV(d) ((struct sba_device *) (d)) 295#define SBA_DEV(d) ((struct sba_device *) (d))
296 296
297#if SBA_AGP_SUPPORT 297#ifdef SBA_AGP_SUPPORT
298static int reserve_sba_gart = 1; 298static int reserve_sba_gart = 1;
299#endif 299#endif
300 300
@@ -314,7 +314,7 @@ static int reserve_sba_gart = 1;
314#define WRITE_REG32(val, addr) __raw_writel(cpu_to_le32(val), addr) 314#define WRITE_REG32(val, addr) __raw_writel(cpu_to_le32(val), addr)
315#define WRITE_REG64(val, addr) __raw_writeq(cpu_to_le64(val), addr) 315#define WRITE_REG64(val, addr) __raw_writeq(cpu_to_le64(val), addr)
316 316
317#ifdef __LP64__ 317#ifdef CONFIG_64BIT
318#define READ_REG(addr) READ_REG64(addr) 318#define READ_REG(addr) READ_REG64(addr)
319#define WRITE_REG(value, addr) WRITE_REG64(value, addr) 319#define WRITE_REG(value, addr) WRITE_REG64(value, addr)
320#else 320#else
@@ -324,7 +324,7 @@ static int reserve_sba_gart = 1;
324 324
325#ifdef DEBUG_SBA_INIT 325#ifdef DEBUG_SBA_INIT
326 326
327/* NOTE: When __LP64__ isn't defined, READ_REG64() is two 32-bit reads */ 327/* NOTE: When CONFIG_64BIT isn't defined, READ_REG64() is two 32-bit reads */
328 328
329/** 329/**
330 * sba_dump_ranges - debugging only - print ranges assigned to this IOA 330 * sba_dump_ranges - debugging only - print ranges assigned to this IOA
@@ -364,7 +364,7 @@ static void sba_dump_tlb(void __iomem *hpa)
364#else 364#else
365#define sba_dump_ranges(x) 365#define sba_dump_ranges(x)
366#define sba_dump_tlb(x) 366#define sba_dump_tlb(x)
367#endif 367#endif /* DEBUG_SBA_INIT */
368 368
369 369
370#ifdef ASSERT_PDIR_SANITY 370#ifdef ASSERT_PDIR_SANITY
@@ -674,7 +674,7 @@ sba_free_range(struct ioc *ioc, dma_addr_t iova, size_t size)
674* 674*
675***************************************************************/ 675***************************************************************/
676 676
677#if SBA_HINT_SUPPORT 677#ifdef SBA_HINT_SUPPORT
678#define SBA_DMA_HINT(ioc, val) ((val) << (ioc)->hint_shift_pdir) 678#define SBA_DMA_HINT(ioc, val) ((val) << (ioc)->hint_shift_pdir)
679#endif 679#endif
680 680
@@ -743,9 +743,8 @@ sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
743 * (bit #61, big endian), we have to flush and sync every time 743 * (bit #61, big endian), we have to flush and sync every time
744 * IO-PDIR is changed in Ike/Astro. 744 * IO-PDIR is changed in Ike/Astro.
745 */ 745 */
746 if (ioc_needs_fdc) { 746 if (ioc_needs_fdc)
747 asm volatile("fdc 0(%%sr1,%0)\n\tsync" : : "r" (pdir_ptr)); 747 asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr));
748 }
749} 748}
750 749
751 750
@@ -769,42 +768,57 @@ static SBA_INLINE void
769sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) 768sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt)
770{ 769{
771 u32 iovp = (u32) SBA_IOVP(ioc,iova); 770 u32 iovp = (u32) SBA_IOVP(ioc,iova);
772 771 u64 *pdir_ptr = &ioc->pdir_base[PDIR_INDEX(iovp)];
773 /* Even though this is a big-endian machine, the entries
774 ** in the iopdir are little endian. That's why we clear the byte
775 ** at +7 instead of at +0.
776 */
777 int off = PDIR_INDEX(iovp)*sizeof(u64)+7;
778 772
779#ifdef ASSERT_PDIR_SANITY 773#ifdef ASSERT_PDIR_SANITY
780 /* Assert first pdir entry is set */ 774 /* Assert first pdir entry is set.
781 if (0x80 != (((u8 *) ioc->pdir_base)[off])) { 775 **
776 ** Even though this is a big-endian machine, the entries
777 ** in the iopdir are little endian. That's why we look at
778 ** the byte at +7 instead of at +0.
779 */
780 if (0x80 != (((u8 *) pdir_ptr)[7])) {
782 sba_dump_pdir_entry(ioc,"sba_mark_invalid()", PDIR_INDEX(iovp)); 781 sba_dump_pdir_entry(ioc,"sba_mark_invalid()", PDIR_INDEX(iovp));
783 } 782 }
784#endif 783#endif
785 784
786 if (byte_cnt <= IOVP_SIZE) 785 if (byte_cnt > IOVP_SIZE)
787 { 786 {
788 iovp |= IOVP_SHIFT; /* set "size" field for PCOM */ 787#if 0
788 unsigned long entries_per_cacheline = ioc_needs_fdc ?
789 L1_CACHE_ALIGN(((unsigned long) pdir_ptr))
790 - (unsigned long) pdir_ptr;
791 : 262144;
792#endif
789 793
790 /* 794 /* set "size" field for PCOM */
791 ** clear I/O PDIR entry "valid" bit 795 iovp |= get_order(byte_cnt) + PAGE_SHIFT;
792 ** Do NOT clear the rest - save it for debugging.
793 ** We should only clear bits that have previously
794 ** been enabled.
795 */
796 ((u8 *)(ioc->pdir_base))[off] = 0;
797 } else {
798 u32 t = get_order(byte_cnt) + PAGE_SHIFT;
799 796
800 iovp |= t;
801 do { 797 do {
802 /* clear I/O Pdir entry "valid" bit first */ 798 /* clear I/O Pdir entry "valid" bit first */
803 ((u8 *)(ioc->pdir_base))[off] = 0; 799 ((u8 *) pdir_ptr)[7] = 0;
804 off += sizeof(u64); 800 if (ioc_needs_fdc) {
801 asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr));
802#if 0
803 entries_per_cacheline = L1_CACHE_SHIFT - 3;
804#endif
805 }
806 pdir_ptr++;
805 byte_cnt -= IOVP_SIZE; 807 byte_cnt -= IOVP_SIZE;
806 } while (byte_cnt > 0); 808 } while (byte_cnt > IOVP_SIZE);
807 } 809 } else
810 iovp |= IOVP_SHIFT; /* set "size" field for PCOM */
811
812 /*
813 ** clear I/O PDIR entry "valid" bit.
814 ** We have to R/M/W the cacheline regardless how much of the
815 ** pdir entry that we clobber.
816 ** The rest of the entry would be useful for debugging if we
817 ** could dump core on HPMC.
818 */
819 ((u8 *) pdir_ptr)[7] = 0;
820 if (ioc_needs_fdc)
821 asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr));
808 822
809 WRITE_REG( SBA_IOVA(ioc, iovp, 0, 0), ioc->ioc_hpa+IOC_PCOM); 823 WRITE_REG( SBA_IOVA(ioc, iovp, 0, 0), ioc->ioc_hpa+IOC_PCOM);
810} 824}
@@ -819,18 +833,29 @@ sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt)
819static int sba_dma_supported( struct device *dev, u64 mask) 833static int sba_dma_supported( struct device *dev, u64 mask)
820{ 834{
821 struct ioc *ioc; 835 struct ioc *ioc;
836
822 if (dev == NULL) { 837 if (dev == NULL) {
823 printk(KERN_ERR MODULE_NAME ": EISA/ISA/et al not supported\n"); 838 printk(KERN_ERR MODULE_NAME ": EISA/ISA/et al not supported\n");
824 BUG(); 839 BUG();
825 return(0); 840 return(0);
826 } 841 }
827 842
828 ioc = GET_IOC(dev); 843 /* Documentation/DMA-mapping.txt tells drivers to try 64-bit first,
844 * then fall back to 32-bit if that fails.
845 * We are just "encouraging" 32-bit DMA masks here since we can
846 * never allow IOMMU bypass unless we add special support for ZX1.
847 */
848 if (mask > ~0U)
849 return 0;
829 850
830 /* check if mask is > than the largest IO Virt Address */ 851 ioc = GET_IOC(dev);
831 852
832 return((int) (mask >= (ioc->ibase + 853 /*
833 (ioc->pdir_size / sizeof(u64) * IOVP_SIZE) ))); 854 * check if mask is >= than the current max IO Virt Address
855 * The max IO Virt address will *always* < 30 bits.
856 */
857 return((int)(mask >= (ioc->ibase - 1 +
858 (ioc->pdir_size / sizeof(u64) * IOVP_SIZE) )));
834} 859}
835 860
836 861
@@ -898,11 +923,17 @@ sba_map_single(struct device *dev, void *addr, size_t size,
898 size -= IOVP_SIZE; 923 size -= IOVP_SIZE;
899 pdir_start++; 924 pdir_start++;
900 } 925 }
901 /* form complete address */ 926
927 /* force FDC ops in io_pdir_entry() to be visible to IOMMU */
928 if (ioc_needs_fdc)
929 asm volatile("sync" : : );
930
902#ifdef ASSERT_PDIR_SANITY 931#ifdef ASSERT_PDIR_SANITY
903 sba_check_pdir(ioc,"Check after sba_map_single()"); 932 sba_check_pdir(ioc,"Check after sba_map_single()");
904#endif 933#endif
905 spin_unlock_irqrestore(&ioc->res_lock, flags); 934 spin_unlock_irqrestore(&ioc->res_lock, flags);
935
936 /* form complete address */
906 return SBA_IOVA(ioc, iovp, offset, DEFAULT_DMA_HINT_REG); 937 return SBA_IOVA(ioc, iovp, offset, DEFAULT_DMA_HINT_REG);
907} 938}
908 939
@@ -958,12 +989,19 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
958 d--; 989 d--;
959 } 990 }
960 ioc->saved_cnt = 0; 991 ioc->saved_cnt = 0;
992
961 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ 993 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */
962 } 994 }
963#else /* DELAYED_RESOURCE_CNT == 0 */ 995#else /* DELAYED_RESOURCE_CNT == 0 */
964 sba_free_range(ioc, iova, size); 996 sba_free_range(ioc, iova, size);
997
998 /* If fdc's were issued, force fdc's to be visible now */
999 if (ioc_needs_fdc)
1000 asm volatile("sync" : : );
1001
965 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */ 1002 READ_REG(ioc->ioc_hpa+IOC_PCOM); /* flush purges */
966#endif /* DELAYED_RESOURCE_CNT == 0 */ 1003#endif /* DELAYED_RESOURCE_CNT == 0 */
1004
967 spin_unlock_irqrestore(&ioc->res_lock, flags); 1005 spin_unlock_irqrestore(&ioc->res_lock, flags);
968 1006
969 /* XXX REVISIT for 2.5 Linux - need syncdma for zero-copy support. 1007 /* XXX REVISIT for 2.5 Linux - need syncdma for zero-copy support.
@@ -986,7 +1024,7 @@ sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
986 * See Documentation/DMA-mapping.txt 1024 * See Documentation/DMA-mapping.txt
987 */ 1025 */
988static void *sba_alloc_consistent(struct device *hwdev, size_t size, 1026static void *sba_alloc_consistent(struct device *hwdev, size_t size,
989 dma_addr_t *dma_handle, int gfp) 1027 dma_addr_t *dma_handle, gfp_t gfp)
990{ 1028{
991 void *ret; 1029 void *ret;
992 1030
@@ -1106,6 +1144,10 @@ sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
1106 */ 1144 */
1107 filled = iommu_fill_pdir(ioc, sglist, nents, 0, sba_io_pdir_entry); 1145 filled = iommu_fill_pdir(ioc, sglist, nents, 0, sba_io_pdir_entry);
1108 1146
1147 /* force FDC ops in io_pdir_entry() to be visible to IOMMU */
1148 if (ioc_needs_fdc)
1149 asm volatile("sync" : : );
1150
1109#ifdef ASSERT_PDIR_SANITY 1151#ifdef ASSERT_PDIR_SANITY
1110 if (sba_check_pdir(ioc,"Check after sba_map_sg()")) 1152 if (sba_check_pdir(ioc,"Check after sba_map_sg()"))
1111 { 1153 {
@@ -1234,8 +1276,10 @@ sba_alloc_pdir(unsigned int pdir_size)
1234 unsigned long pdir_order = get_order(pdir_size); 1276 unsigned long pdir_order = get_order(pdir_size);
1235 1277
1236 pdir_base = __get_free_pages(GFP_KERNEL, pdir_order); 1278 pdir_base = __get_free_pages(GFP_KERNEL, pdir_order);
1237 if (NULL == (void *) pdir_base) 1279 if (NULL == (void *) pdir_base) {
1238 panic("sba_ioc_init() could not allocate I/O Page Table\n"); 1280 panic("%s() could not allocate I/O Page Table\n",
1281 __FUNCTION__);
1282 }
1239 1283
1240 /* If this is not PA8700 (PCX-W2) 1284 /* If this is not PA8700 (PCX-W2)
1241 ** OR newer than ver 2.2 1285 ** OR newer than ver 2.2
@@ -1322,19 +1366,29 @@ sba_alloc_pdir(unsigned int pdir_size)
1322 return (void *) pdir_base; 1366 return (void *) pdir_base;
1323} 1367}
1324 1368
1369static struct device *next_device(struct klist_iter *i)
1370{
1371 struct klist_node * n = klist_next(i);
1372 return n ? container_of(n, struct device, knode_parent) : NULL;
1373}
1374
1325/* setup Mercury or Elroy IBASE/IMASK registers. */ 1375/* setup Mercury or Elroy IBASE/IMASK registers. */
1326static void setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num) 1376static void
1377setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1327{ 1378{
1328 /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ 1379 /* lba_set_iregs() is in drivers/parisc/lba_pci.c */
1329 extern void lba_set_iregs(struct parisc_device *, u32, u32); 1380 extern void lba_set_iregs(struct parisc_device *, u32, u32);
1330 struct device *dev; 1381 struct device *dev;
1382 struct klist_iter i;
1331 1383
1332 list_for_each_entry(dev, &sba->dev.children, node) { 1384 klist_iter_init(&sba->dev.klist_children, &i);
1385 while ((dev = next_device(&i))) {
1333 struct parisc_device *lba = to_parisc_device(dev); 1386 struct parisc_device *lba = to_parisc_device(dev);
1334 int rope_num = (lba->hpa >> 13) & 0xf; 1387 int rope_num = (lba->hpa.start >> 13) & 0xf;
1335 if (rope_num >> 3 == ioc_num) 1388 if (rope_num >> 3 == ioc_num)
1336 lba_set_iregs(lba, ioc->ibase, ioc->imask); 1389 lba_set_iregs(lba, ioc->ibase, ioc->imask);
1337 } 1390 }
1391 klist_iter_exit(&i);
1338} 1392}
1339 1393
1340static void 1394static void
@@ -1343,7 +1397,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1343 u32 iova_space_mask; 1397 u32 iova_space_mask;
1344 u32 iova_space_size; 1398 u32 iova_space_size;
1345 int iov_order, tcnfg; 1399 int iov_order, tcnfg;
1346#if SBA_AGP_SUPPORT 1400#ifdef SBA_AGP_SUPPORT
1347 int agp_found = 0; 1401 int agp_found = 0;
1348#endif 1402#endif
1349 /* 1403 /*
@@ -1380,7 +1434,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1380 DBG_INIT("%s() pdir %p size %x\n", 1434 DBG_INIT("%s() pdir %p size %x\n",
1381 __FUNCTION__, ioc->pdir_base, ioc->pdir_size); 1435 __FUNCTION__, ioc->pdir_base, ioc->pdir_size);
1382 1436
1383#if SBA_HINT_SUPPORT 1437#ifdef SBA_HINT_SUPPORT
1384 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; 1438 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT;
1385 ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); 1439 ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT));
1386 1440
@@ -1404,7 +1458,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1404 1458
1405 WRITE_REG(ioc->imask, ioc->ioc_hpa + IOC_IMASK); 1459 WRITE_REG(ioc->imask, ioc->ioc_hpa + IOC_IMASK);
1406 1460
1407#ifdef __LP64__ 1461#ifdef CONFIG_64BIT
1408 /* 1462 /*
1409 ** Setting the upper bits makes checking for bypass addresses 1463 ** Setting the upper bits makes checking for bypass addresses
1410 ** a little faster later on. 1464 ** a little faster later on.
@@ -1437,7 +1491,7 @@ sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1437 */ 1491 */
1438 WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM); 1492 WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM);
1439 1493
1440#if SBA_AGP_SUPPORT 1494#ifdef SBA_AGP_SUPPORT
1441 /* 1495 /*
1442 ** If an AGP device is present, only use half of the IOV space 1496 ** If an AGP device is present, only use half of the IOV space
1443 ** for PCI DMA. Unfortunately we can't know ahead of time 1497 ** for PCI DMA. Unfortunately we can't know ahead of time
@@ -1489,11 +1543,9 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1489 if (iova_space_size < (1 << (20 - PAGE_SHIFT))) { 1543 if (iova_space_size < (1 << (20 - PAGE_SHIFT))) {
1490 iova_space_size = 1 << (20 - PAGE_SHIFT); 1544 iova_space_size = 1 << (20 - PAGE_SHIFT);
1491 } 1545 }
1492#ifdef __LP64__
1493 else if (iova_space_size > (1 << (30 - PAGE_SHIFT))) { 1546 else if (iova_space_size > (1 << (30 - PAGE_SHIFT))) {
1494 iova_space_size = 1 << (30 - PAGE_SHIFT); 1547 iova_space_size = 1 << (30 - PAGE_SHIFT);
1495 } 1548 }
1496#endif
1497 1549
1498 /* 1550 /*
1499 ** iova space must be log2() in size. 1551 ** iova space must be log2() in size.
@@ -1519,7 +1571,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1519 DBG_INIT("%s() pdir %p size %x\n", 1571 DBG_INIT("%s() pdir %p size %x\n",
1520 __FUNCTION__, ioc->pdir_base, pdir_size); 1572 __FUNCTION__, ioc->pdir_base, pdir_size);
1521 1573
1522#if SBA_HINT_SUPPORT 1574#ifdef SBA_HINT_SUPPORT
1523 /* FIXME : DMA HINTs not used */ 1575 /* FIXME : DMA HINTs not used */
1524 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT; 1576 ioc->hint_shift_pdir = iov_order + PAGE_SHIFT;
1525 ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT)); 1577 ioc->hint_mask_pdir = ~(0x3 << (iov_order + PAGE_SHIFT));
@@ -1590,7 +1642,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
1590 1642
1591static void __iomem *ioc_remap(struct sba_device *sba_dev, int offset) 1643static void __iomem *ioc_remap(struct sba_device *sba_dev, int offset)
1592{ 1644{
1593 return ioremap(sba_dev->dev->hpa + offset, SBA_FUNC_SIZE); 1645 return ioremap(sba_dev->dev->hpa.start + offset, SBA_FUNC_SIZE);
1594} 1646}
1595 1647
1596static void sba_hw_init(struct sba_device *sba_dev) 1648static void sba_hw_init(struct sba_device *sba_dev)
@@ -1968,7 +2020,7 @@ sba_driver_callback(struct parisc_device *dev)
1968 u32 func_class; 2020 u32 func_class;
1969 int i; 2021 int i;
1970 char *version; 2022 char *version;
1971 void __iomem *sba_addr = ioremap(dev->hpa, SBA_FUNC_SIZE); 2023 void __iomem *sba_addr = ioremap(dev->hpa.start, SBA_FUNC_SIZE);
1972 2024
1973 sba_dump_ranges(sba_addr); 2025 sba_dump_ranges(sba_addr);
1974 2026
@@ -2010,7 +2062,7 @@ sba_driver_callback(struct parisc_device *dev)
2010 } 2062 }
2011 2063
2012 printk(KERN_INFO "%s found %s at 0x%lx\n", 2064 printk(KERN_INFO "%s found %s at 0x%lx\n",
2013 MODULE_NAME, version, dev->hpa); 2065 MODULE_NAME, version, dev->hpa.start);
2014 2066
2015 sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL); 2067 sba_dev = kmalloc(sizeof(struct sba_device), GFP_KERNEL);
2016 if (!sba_dev) { 2068 if (!sba_dev) {
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index e0efed796b92..bab3bcabcb6e 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -11,6 +11,7 @@
11 * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca> 11 * (C) Copyright 2000 Alex deVries <alex@onefishtwo.ca>
12 * (C) Copyright 2001 John Marvin <jsm fc hp com> 12 * (C) Copyright 2001 John Marvin <jsm fc hp com>
13 * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org> 13 * (C) Copyright 2003 Grant Grundler <grundler parisc-linux org>
14 * (C) Copyright 2005 Kyle McMartin <kyle@parisc-linux.org>
14 * 15 *
15 * This program is free software; you can redistribute it and/or 16 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as 17 * modify it under the terms of the GNU General Public License as
@@ -405,6 +406,7 @@ static void __devinit superio_serial_init(void)
405 406
406 serial[0].iobase = sio_dev.sp1_base; 407 serial[0].iobase = sio_dev.sp1_base;
407 serial[0].irq = SP1_IRQ; 408 serial[0].irq = SP1_IRQ;
409 spin_lock_init(&serial[0].lock);
408 410
409 retval = early_serial_setup(&serial[0]); 411 retval = early_serial_setup(&serial[0]);
410 if (retval < 0) { 412 if (retval < 0) {
@@ -414,6 +416,7 @@ static void __devinit superio_serial_init(void)
414 416
415 serial[1].iobase = sio_dev.sp2_base; 417 serial[1].iobase = sio_dev.sp2_base;
416 serial[1].irq = SP2_IRQ; 418 serial[1].irq = SP2_IRQ;
419 spin_lock_init(&serial[1].lock);
417 retval = early_serial_setup(&serial[1]); 420 retval = early_serial_setup(&serial[1]);
418 421
419 if (retval < 0) 422 if (retval < 0)
diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c
index e547d7d024d8..17dce2adf7fe 100644
--- a/drivers/parisc/wax.c
+++ b/drivers/parisc/wax.c
@@ -81,7 +81,7 @@ wax_init_chip(struct parisc_device *dev)
81 return -ENOMEM; 81 return -ENOMEM;
82 82
83 wax->name = "wax"; 83 wax->name = "wax";
84 wax->hpa = dev->hpa; 84 wax->hpa = dev->hpa.start;
85 85
86 wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */ 86 wax->version = 0; /* gsc_readb(wax->hpa+WAX_VER); */
87 printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa); 87 printk(KERN_INFO "%s at 0x%lx found.\n", wax->name, wax->hpa);
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
index 02d72acd1c89..fde29a75f888 100644
--- a/drivers/parport/parport_gsc.c
+++ b/drivers/parport/parport_gsc.c
@@ -359,11 +359,12 @@ static int __devinit parport_init_chip(struct parisc_device *dev)
359 unsigned long port; 359 unsigned long port;
360 360
361 if (!dev->irq) { 361 if (!dev->irq) {
362 printk("IRQ not found for parallel device at 0x%lx\n", dev->hpa); 362 printk(KERN_WARNING "IRQ not found for parallel device at 0x%lx\n",
363 dev->hpa.start);
363 return -ENODEV; 364 return -ENODEV;
364 } 365 }
365 366
366 port = dev->hpa + PARPORT_GSC_OFFSET; 367 port = dev->hpa.start + PARPORT_GSC_OFFSET;
367 368
368 /* some older machines with ASP-chip don't support 369 /* some older machines with ASP-chip don't support
369 * the enhanced parport modes. 370 * the enhanced parport modes.
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 24a76de49f41..2a42add7f563 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -60,3 +60,92 @@ EXPORT_SYMBOL(pci_bus_read_config_dword);
60EXPORT_SYMBOL(pci_bus_write_config_byte); 60EXPORT_SYMBOL(pci_bus_write_config_byte);
61EXPORT_SYMBOL(pci_bus_write_config_word); 61EXPORT_SYMBOL(pci_bus_write_config_word);
62EXPORT_SYMBOL(pci_bus_write_config_dword); 62EXPORT_SYMBOL(pci_bus_write_config_dword);
63
64static u32 pci_user_cached_config(struct pci_dev *dev, int pos)
65{
66 u32 data;
67
68 data = dev->saved_config_space[pos/sizeof(dev->saved_config_space[0])];
69 data >>= (pos % sizeof(dev->saved_config_space[0])) * 8;
70 return data;
71}
72
73#define PCI_USER_READ_CONFIG(size,type) \
74int pci_user_read_config_##size \
75 (struct pci_dev *dev, int pos, type *val) \
76{ \
77 unsigned long flags; \
78 int ret = 0; \
79 u32 data = -1; \
80 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
81 spin_lock_irqsave(&pci_lock, flags); \
82 if (likely(!dev->block_ucfg_access)) \
83 ret = dev->bus->ops->read(dev->bus, dev->devfn, \
84 pos, sizeof(type), &data); \
85 else if (pos < sizeof(dev->saved_config_space)) \
86 data = pci_user_cached_config(dev, pos); \
87 spin_unlock_irqrestore(&pci_lock, flags); \
88 *val = (type)data; \
89 return ret; \
90}
91
92#define PCI_USER_WRITE_CONFIG(size,type) \
93int pci_user_write_config_##size \
94 (struct pci_dev *dev, int pos, type val) \
95{ \
96 unsigned long flags; \
97 int ret = -EIO; \
98 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
99 spin_lock_irqsave(&pci_lock, flags); \
100 if (likely(!dev->block_ucfg_access)) \
101 ret = dev->bus->ops->write(dev->bus, dev->devfn, \
102 pos, sizeof(type), val); \
103 spin_unlock_irqrestore(&pci_lock, flags); \
104 return ret; \
105}
106
107PCI_USER_READ_CONFIG(byte, u8)
108PCI_USER_READ_CONFIG(word, u16)
109PCI_USER_READ_CONFIG(dword, u32)
110PCI_USER_WRITE_CONFIG(byte, u8)
111PCI_USER_WRITE_CONFIG(word, u16)
112PCI_USER_WRITE_CONFIG(dword, u32)
113
114/**
115 * pci_block_user_cfg_access - Block userspace PCI config reads/writes
116 * @dev: pci device struct
117 *
118 * This function blocks any userspace PCI config accesses from occurring.
119 * When blocked, any writes will be bit bucketed and reads will return the
120 * data saved using pci_save_state for the first 64 bytes of config
121 * space and return 0xff for all other config reads.
122 **/
123void pci_block_user_cfg_access(struct pci_dev *dev)
124{
125 unsigned long flags;
126
127 pci_save_state(dev);
128
129 /* spinlock to synchronize with anyone reading config space now */
130 spin_lock_irqsave(&pci_lock, flags);
131 dev->block_ucfg_access = 1;
132 spin_unlock_irqrestore(&pci_lock, flags);
133}
134EXPORT_SYMBOL_GPL(pci_block_user_cfg_access);
135
136/**
137 * pci_unblock_user_cfg_access - Unblock userspace PCI config reads/writes
138 * @dev: pci device struct
139 *
140 * This function allows userspace PCI config accesses to resume.
141 **/
142void pci_unblock_user_cfg_access(struct pci_dev *dev)
143{
144 unsigned long flags;
145
146 /* spinlock to synchronize with anyone reading saved config space */
147 spin_lock_irqsave(&pci_lock, flags);
148 dev->block_ucfg_access = 0;
149 spin_unlock_irqrestore(&pci_lock, flags);
150}
151EXPORT_SYMBOL_GPL(pci_unblock_user_cfg_access);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 424e7de181ae..8e21f6ab89a1 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -58,6 +58,9 @@ static LIST_HEAD(bridge_list);
58 58
59static void handle_hotplug_event_bridge (acpi_handle, u32, void *); 59static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
60static void handle_hotplug_event_func (acpi_handle, u32, void *); 60static void handle_hotplug_event_func (acpi_handle, u32, void *);
61static void acpiphp_sanitize_bus(struct pci_bus *bus);
62static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
63
61 64
62/* 65/*
63 * initialization & terminatation routines 66 * initialization & terminatation routines
@@ -796,8 +799,13 @@ static int enable_device(struct acpiphp_slot *slot)
796 } 799 }
797 } 800 }
798 801
802 pci_bus_size_bridges(bus);
799 pci_bus_assign_resources(bus); 803 pci_bus_assign_resources(bus);
804 acpiphp_sanitize_bus(bus);
805 pci_enable_bridges(bus);
800 pci_bus_add_devices(bus); 806 pci_bus_add_devices(bus);
807 acpiphp_set_hpp_values(DEVICE_ACPI_HANDLE(&bus->self->dev), bus);
808 acpiphp_configure_ioapics(DEVICE_ACPI_HANDLE(&bus->self->dev));
801 809
802 /* associate pci_dev to our representation */ 810 /* associate pci_dev to our representation */
803 list_for_each (l, &slot->funcs) { 811 list_for_each (l, &slot->funcs) {
diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
index e9928024be78..790abadd816c 100644
--- a/drivers/pci/hotplug/cpcihp_zt5550.c
+++ b/drivers/pci/hotplug/cpcihp_zt5550.c
@@ -78,11 +78,20 @@ static void __iomem *csr_int_mask;
78 78
79static int zt5550_hc_config(struct pci_dev *pdev) 79static int zt5550_hc_config(struct pci_dev *pdev)
80{ 80{
81 int ret;
82
81 /* Since we know that no boards exist with two HC chips, treat it as an error */ 83 /* Since we know that no boards exist with two HC chips, treat it as an error */
82 if(hc_dev) { 84 if(hc_dev) {
83 err("too many host controller devices?"); 85 err("too many host controller devices?");
84 return -EBUSY; 86 return -EBUSY;
85 } 87 }
88
89 ret = pci_enable_device(pdev);
90 if(ret) {
91 err("cannot enable %s\n", pci_name(pdev));
92 return ret;
93 }
94
86 hc_dev = pdev; 95 hc_dev = pdev;
87 dbg("hc_dev = %p", hc_dev); 96 dbg("hc_dev = %p", hc_dev);
88 dbg("pci resource start %lx", pci_resource_start(hc_dev, 1)); 97 dbg("pci resource start %lx", pci_resource_start(hc_dev, 1));
@@ -91,7 +100,8 @@ static int zt5550_hc_config(struct pci_dev *pdev)
91 if(!request_mem_region(pci_resource_start(hc_dev, 1), 100 if(!request_mem_region(pci_resource_start(hc_dev, 1),
92 pci_resource_len(hc_dev, 1), MY_NAME)) { 101 pci_resource_len(hc_dev, 1), MY_NAME)) {
93 err("cannot reserve MMIO region"); 102 err("cannot reserve MMIO region");
94 return -ENOMEM; 103 ret = -ENOMEM;
104 goto exit_disable_device;
95 } 105 }
96 106
97 hc_registers = 107 hc_registers =
@@ -99,9 +109,8 @@ static int zt5550_hc_config(struct pci_dev *pdev)
99 if(!hc_registers) { 109 if(!hc_registers) {
100 err("cannot remap MMIO region %lx @ %lx", 110 err("cannot remap MMIO region %lx @ %lx",
101 pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1)); 111 pci_resource_len(hc_dev, 1), pci_resource_start(hc_dev, 1));
102 release_mem_region(pci_resource_start(hc_dev, 1), 112 ret = -ENODEV;
103 pci_resource_len(hc_dev, 1)); 113 goto exit_release_region;
104 return -ENODEV;
105 } 114 }
106 115
107 csr_hc_index = hc_registers + CSR_HCINDEX; 116 csr_hc_index = hc_registers + CSR_HCINDEX;
@@ -124,6 +133,13 @@ static int zt5550_hc_config(struct pci_dev *pdev)
124 writeb((u8) ALL_DIRECT_INTS_MASK, csr_int_mask); 133 writeb((u8) ALL_DIRECT_INTS_MASK, csr_int_mask);
125 dbg("disabled timer0, timer1 and ENUM interrupts"); 134 dbg("disabled timer0, timer1 and ENUM interrupts");
126 return 0; 135 return 0;
136
137exit_release_region:
138 release_mem_region(pci_resource_start(hc_dev, 1),
139 pci_resource_len(hc_dev, 1));
140exit_disable_device:
141 pci_disable_device(hc_dev);
142 return ret;
127} 143}
128 144
129static int zt5550_hc_cleanup(void) 145static int zt5550_hc_cleanup(void)
@@ -134,6 +150,7 @@ static int zt5550_hc_cleanup(void)
134 iounmap(hc_registers); 150 iounmap(hc_registers);
135 release_mem_region(pci_resource_start(hc_dev, 1), 151 release_mem_region(pci_resource_start(hc_dev, 1),
136 pci_resource_len(hc_dev, 1)); 152 pci_resource_len(hc_dev, 1));
153 pci_disable_device(hc_dev);
137 return 0; 154 return 0;
138} 155}
139 156
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 8c6d3987d461..9aed8efe6a11 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -794,12 +794,21 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
794 u32 rc; 794 u32 rc;
795 struct controller *ctrl; 795 struct controller *ctrl;
796 struct pci_func *func; 796 struct pci_func *func;
797 int err;
798
799 err = pci_enable_device(pdev);
800 if (err) {
801 printk(KERN_ERR MY_NAME ": cannot enable PCI device %s (%d)\n",
802 pci_name(pdev), err);
803 return err;
804 }
797 805
798 // Need to read VID early b/c it's used to differentiate CPQ and INTC discovery 806 // Need to read VID early b/c it's used to differentiate CPQ and INTC discovery
799 rc = pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor_id); 807 rc = pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor_id);
800 if (rc || ((vendor_id != PCI_VENDOR_ID_COMPAQ) && (vendor_id != PCI_VENDOR_ID_INTEL))) { 808 if (rc || ((vendor_id != PCI_VENDOR_ID_COMPAQ) && (vendor_id != PCI_VENDOR_ID_INTEL))) {
801 err(msg_HPC_non_compaq_or_intel); 809 err(msg_HPC_non_compaq_or_intel);
802 return -ENODEV; 810 rc = -ENODEV;
811 goto err_disable_device;
803 } 812 }
804 dbg("Vendor ID: %x\n", vendor_id); 813 dbg("Vendor ID: %x\n", vendor_id);
805 814
@@ -807,7 +816,8 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
807 dbg("revision: %d\n", rev); 816 dbg("revision: %d\n", rev);
808 if (rc || ((vendor_id == PCI_VENDOR_ID_COMPAQ) && (!rev))) { 817 if (rc || ((vendor_id == PCI_VENDOR_ID_COMPAQ) && (!rev))) {
809 err(msg_HPC_rev_error); 818 err(msg_HPC_rev_error);
810 return -ENODEV; 819 rc = -ENODEV;
820 goto err_disable_device;
811 } 821 }
812 822
813 /* Check for the proper subsytem ID's 823 /* Check for the proper subsytem ID's
@@ -820,18 +830,20 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
820 rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vid); 830 rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vid);
821 if (rc) { 831 if (rc) {
822 err("%s : pci_read_config_word failed\n", __FUNCTION__); 832 err("%s : pci_read_config_word failed\n", __FUNCTION__);
823 return rc; 833 goto err_disable_device;
824 } 834 }
825 dbg("Subsystem Vendor ID: %x\n", subsystem_vid); 835 dbg("Subsystem Vendor ID: %x\n", subsystem_vid);
826 if ((subsystem_vid != PCI_VENDOR_ID_COMPAQ) && (subsystem_vid != PCI_VENDOR_ID_INTEL)) { 836 if ((subsystem_vid != PCI_VENDOR_ID_COMPAQ) && (subsystem_vid != PCI_VENDOR_ID_INTEL)) {
827 err(msg_HPC_non_compaq_or_intel); 837 err(msg_HPC_non_compaq_or_intel);
828 return -ENODEV; 838 rc = -ENODEV;
839 goto err_disable_device;
829 } 840 }
830 841
831 ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); 842 ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
832 if (!ctrl) { 843 if (!ctrl) {
833 err("%s : out of memory\n", __FUNCTION__); 844 err("%s : out of memory\n", __FUNCTION__);
834 return -ENOMEM; 845 rc = -ENOMEM;
846 goto err_disable_device;
835 } 847 }
836 memset(ctrl, 0, sizeof(struct controller)); 848 memset(ctrl, 0, sizeof(struct controller));
837 849
@@ -1264,6 +1276,8 @@ err_free_bus:
1264 kfree(ctrl->pci_bus); 1276 kfree(ctrl->pci_bus);
1265err_free_ctrl: 1277err_free_ctrl:
1266 kfree(ctrl); 1278 kfree(ctrl);
1279err_disable_device:
1280 pci_disable_device(pdev);
1267 return rc; 1281 return rc;
1268} 1282}
1269 1283
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 61d94d1e29cb..71ea5f9bb284 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -92,9 +92,10 @@ extern struct pci_bus *rpaphp_find_pci_bus(struct device_node *dn);
92extern int rpaphp_claim_resource(struct pci_dev *dev, int resource); 92extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
93extern int rpaphp_enable_pci_slot(struct slot *slot); 93extern int rpaphp_enable_pci_slot(struct slot *slot);
94extern int register_pci_slot(struct slot *slot); 94extern int register_pci_slot(struct slot *slot);
95extern int rpaphp_unconfig_pci_adapter(struct slot *slot);
96extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); 95extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
96
97extern int rpaphp_config_pci_adapter(struct pci_bus *bus); 97extern int rpaphp_config_pci_adapter(struct pci_bus *bus);
98extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus);
98 99
99/* rpaphp_core.c */ 100/* rpaphp_core.c */
100extern int rpaphp_add_slot(struct device_node *dn); 101extern int rpaphp_add_slot(struct device_node *dn);
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index c830ff0acdc3..cf075c34b578 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -426,8 +426,11 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
426 426
427 dbg("DISABLING SLOT %s\n", slot->name); 427 dbg("DISABLING SLOT %s\n", slot->name);
428 down(&rpaphp_sem); 428 down(&rpaphp_sem);
429 retval = rpaphp_unconfig_pci_adapter(slot); 429 retval = rpaphp_unconfig_pci_adapter(slot->bus);
430 up(&rpaphp_sem); 430 up(&rpaphp_sem);
431 slot->state = NOT_CONFIGURED;
432 info("%s: devices in slot[%s] unconfigured.\n", __FUNCTION__,
433 slot->name);
431exit: 434exit:
432 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval); 435 dbg("%s - Exit: rc[%d]\n", __FUNCTION__, retval);
433 return retval; 436 return retval;
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 49e4d10a6488..46c157d26a2f 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -319,20 +319,15 @@ static void rpaphp_eeh_remove_bus_device(struct pci_dev *dev)
319 return; 319 return;
320} 320}
321 321
322int rpaphp_unconfig_pci_adapter(struct slot *slot) 322int rpaphp_unconfig_pci_adapter(struct pci_bus *bus)
323{ 323{
324 struct pci_dev *dev, *tmp; 324 struct pci_dev *dev, *tmp;
325 int retval = 0;
326 325
327 list_for_each_entry_safe(dev, tmp, slot->pci_devs, bus_list) { 326 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
328 rpaphp_eeh_remove_bus_device(dev); 327 rpaphp_eeh_remove_bus_device(dev);
329 pci_remove_bus_device(dev); 328 pci_remove_bus_device(dev);
330 } 329 }
331 330 return 0;
332 slot->state = NOT_CONFIGURED;
333 info("%s: devices in slot[%s] unconfigured.\n", __FUNCTION__,
334 slot->name);
335 return retval;
336} 331}
337 332
338static int setup_pci_hotplug_slot_info(struct slot *slot) 333static int setup_pci_hotplug_slot_info(struct slot *slot)
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index b7d1c61d6bbb..abe2cf411e68 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -32,8 +32,6 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <asm/semaphore.h>
36#include <asm/io.h>
37#include "pci_hotplug.h" 35#include "pci_hotplug.h"
38 36
39#if !defined(MODULE) 37#if !defined(MODULE)
@@ -52,42 +50,18 @@ extern int shpchp_debug;
52#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
53#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 51#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
54 52
55struct pci_func {
56 struct pci_func *next;
57 u8 bus;
58 u8 device;
59 u8 function;
60 u8 is_a_board;
61 u16 status;
62 u8 configured;
63 u8 switch_save;
64 u8 presence_save;
65 u8 pwr_save;
66 u32 base_length[0x06];
67 u8 base_type[0x06];
68 u16 reserved2;
69 u32 config_space[0x20];
70 struct pci_resource *mem_head;
71 struct pci_resource *p_mem_head;
72 struct pci_resource *io_head;
73 struct pci_resource *bus_head;
74 struct pci_dev* pci_dev;
75};
76
77#define SLOT_MAGIC 0x67267321 53#define SLOT_MAGIC 0x67267321
78struct slot { 54struct slot {
79 u32 magic; 55 u32 magic;
80 struct slot *next; 56 struct slot *next;
81 u8 bus; 57 u8 bus;
82 u8 device; 58 u8 device;
59 u16 status;
83 u32 number; 60 u32 number;
84 u8 is_a_board; 61 u8 is_a_board;
85 u8 configured;
86 u8 state; 62 u8 state;
87 u8 switch_save;
88 u8 presence_save; 63 u8 presence_save;
89 u32 capabilities; 64 u8 pwr_save;
90 u16 reserved2;
91 struct timer_list task_event; 65 struct timer_list task_event;
92 u8 hp_slot; 66 u8 hp_slot;
93 struct controller *ctrl; 67 struct controller *ctrl;
@@ -96,12 +70,6 @@ struct slot {
96 struct list_head slot_list; 70 struct list_head slot_list;
97}; 71};
98 72
99struct pci_resource {
100 struct pci_resource * next;
101 u32 base;
102 u32 length;
103};
104
105struct event_info { 73struct event_info {
106 u32 event_type; 74 u32 event_type;
107 u8 hp_slot; 75 u8 hp_slot;
@@ -110,13 +78,9 @@ struct event_info {
110struct controller { 78struct controller {
111 struct controller *next; 79 struct controller *next;
112 struct semaphore crit_sect; /* critical section semaphore */ 80 struct semaphore crit_sect; /* critical section semaphore */
113 void * hpc_ctlr_handle; /* HPC controller handle */ 81 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
114 int num_slots; /* Number of slots on ctlr */ 82 int num_slots; /* Number of slots on ctlr */
115 int slot_num_inc; /* 1 or -1 */ 83 int slot_num_inc; /* 1 or -1 */
116 struct pci_resource *mem_head;
117 struct pci_resource *p_mem_head;
118 struct pci_resource *io_head;
119 struct pci_resource *bus_head;
120 struct pci_dev *pci_dev; 84 struct pci_dev *pci_dev;
121 struct pci_bus *pci_bus; 85 struct pci_bus *pci_bus;
122 struct event_info event_queue[10]; 86 struct event_info event_queue[10];
@@ -124,33 +88,21 @@ struct controller {
124 struct hpc_ops *hpc_ops; 88 struct hpc_ops *hpc_ops;
125 wait_queue_head_t queue; /* sleep & wake process */ 89 wait_queue_head_t queue; /* sleep & wake process */
126 u8 next_event; 90 u8 next_event;
127 u8 seg;
128 u8 bus; 91 u8 bus;
129 u8 device; 92 u8 device;
130 u8 function; 93 u8 function;
131 u8 rev;
132 u8 slot_device_offset; 94 u8 slot_device_offset;
133 u8 add_support; 95 u8 add_support;
134 enum pci_bus_speed speed; 96 enum pci_bus_speed speed;
135 u32 first_slot; /* First physical slot number */ 97 u32 first_slot; /* First physical slot number */
136 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 98 u8 slot_bus; /* Bus where the slots handled by this controller sit */
137 u8 push_flag;
138 u16 ctlrcap;
139 u16 vendor_id;
140};
141
142struct irq_mapping {
143 u8 barber_pole;
144 u8 valid_INT;
145 u8 interrupt[4];
146}; 99};
147 100
148struct resource_lists { 101struct hotplug_params {
149 struct pci_resource *mem_head; 102 u8 cache_line_size;
150 struct pci_resource *p_mem_head; 103 u8 latency_timer;
151 struct pci_resource *io_head; 104 u8 enable_serr;
152 struct pci_resource *bus_head; 105 u8 enable_perr;
153 struct irq_mapping *irqs;
154}; 106};
155 107
156/* Define AMD SHPC ID */ 108/* Define AMD SHPC ID */
@@ -194,24 +146,16 @@ struct resource_lists {
194 * error Messages 146 * error Messages
195 */ 147 */
196#define msg_initialization_err "Initialization failure, error=%d\n" 148#define msg_initialization_err "Initialization failure, error=%d\n"
197#define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
198#define msg_HPC_non_shpc "The PCI hot plug controller is not supported by this driver.\n"
199#define msg_HPC_not_supported "This system is not supported by this version of shpcphd mdoule. Upgrade to a newer version of shpchpd\n"
200#define msg_unable_to_save "Unable to store PCI hot plug add resource information. This system must be rebooted before adding any PCI devices.\n"
201#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 149#define msg_button_on "PCI slot #%d - powering on due to button press.\n"
202#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 150#define msg_button_off "PCI slot #%d - powering off due to button press.\n"
203#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 151#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
204#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
205 152
206/* sysfs functions for the hotplug controller info */ 153/* sysfs functions for the hotplug controller info */
207extern void shpchp_create_ctrl_files (struct controller *ctrl); 154extern void shpchp_create_ctrl_files (struct controller *ctrl);
208 155
209/* controller functions */ 156/* controller functions */
210extern int shpchprm_find_available_resources(struct controller *ctrl);
211extern int shpchp_event_start_thread(void); 157extern int shpchp_event_start_thread(void);
212extern void shpchp_event_stop_thread(void); 158extern void shpchp_event_stop_thread(void);
213extern struct pci_func *shpchp_slot_create(unsigned char busnumber);
214extern struct pci_func *shpchp_slot_find(unsigned char bus, unsigned char device, unsigned char index);
215extern int shpchp_enable_slot(struct slot *slot); 159extern int shpchp_enable_slot(struct slot *slot);
216extern int shpchp_disable_slot(struct slot *slot); 160extern int shpchp_disable_slot(struct slot *slot);
217 161
@@ -220,29 +164,20 @@ extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id);
220extern u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id); 164extern u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id);
221extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id); 165extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id);
222 166
223/* resource functions */
224extern int shpchp_resource_sort_and_combine(struct pci_resource **head);
225
226/* pci functions */ 167/* pci functions */
227extern int shpchp_set_irq(u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num);
228/*extern int shpchp_get_bus_dev(struct controller *ctrl, u8 *bus_num, u8 *dev_num, struct slot *slot);*/
229extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); 168extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num);
230extern int shpchp_save_used_resources(struct controller *ctrl, struct pci_func * func, int flag); 169extern int shpchp_configure_device(struct slot *p_slot);
231extern int shpchp_save_slot_config(struct controller *ctrl, struct pci_func * new_slot); 170extern int shpchp_unconfigure_device(struct slot *p_slot);
232extern void shpchp_destroy_board_resources(struct pci_func * func); 171extern void get_hp_hw_control_from_firmware(struct pci_dev *dev);
233extern int shpchp_return_board_resources(struct pci_func * func, struct resource_lists * resources); 172extern void get_hp_params_from_firmware(struct pci_dev *dev,
234extern void shpchp_destroy_resource_list(struct resource_lists * resources); 173 struct hotplug_params *hpp);
235extern int shpchp_configure_device(struct controller* ctrl, struct pci_func* func); 174extern int shpchprm_get_physical_slot_number(struct controller *ctrl,
236extern int shpchp_unconfigure_device(struct pci_func* func); 175 u32 *sun, u8 busnum, u8 devnum);
176extern void shpchp_remove_ctrl_files(struct controller *ctrl);
237 177
238 178
239/* Global variables */ 179/* Global variables */
240extern struct controller *shpchp_ctrl_list; 180extern struct controller *shpchp_ctrl_list;
241extern struct pci_func *shpchp_slot_list[256];
242
243/* These are added to support AMD shpc */
244extern u8 shpchp_nic_irq;
245extern u8 shpchp_disk_irq;
246 181
247struct ctrl_reg { 182struct ctrl_reg {
248 volatile u32 base_offset; 183 volatile u32 base_offset;
@@ -298,7 +233,7 @@ enum ctrl_offsets {
298 SLOT11 = offsetof(struct ctrl_reg, slot11), 233 SLOT11 = offsetof(struct ctrl_reg, slot11),
299 SLOT12 = offsetof(struct ctrl_reg, slot12), 234 SLOT12 = offsetof(struct ctrl_reg, slot12),
300}; 235};
301typedef u8(*php_intr_callback_t) (unsigned int change_id, void *instance_id); 236typedef u8(*php_intr_callback_t) (u8 hp_slot, void *instance_id);
302struct php_ctlr_state_s { 237struct php_ctlr_state_s {
303 struct php_ctlr_state_s *pnext; 238 struct php_ctlr_state_s *pnext;
304 struct pci_dev *pci_dev; 239 struct pci_dev *pci_dev;
@@ -359,12 +294,9 @@ static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
359 294
360 p_slot = ctrl->slot; 295 p_slot = ctrl->slot;
361 296
362 dbg("p_slot = %p\n", p_slot);
363
364 while (p_slot && (p_slot->device != device)) { 297 while (p_slot && (p_slot->device != device)) {
365 tmp_slot = p_slot; 298 tmp_slot = p_slot;
366 p_slot = p_slot->next; 299 p_slot = p_slot->next;
367 dbg("In while loop, p_slot = %p\n", p_slot);
368 } 300 }
369 if (p_slot == NULL) { 301 if (p_slot == NULL) {
370 err("ERROR: shpchp_find_slot device=0x%x\n", device); 302 err("ERROR: shpchp_find_slot device=0x%x\n", device);
@@ -379,8 +311,6 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
379 DECLARE_WAITQUEUE(wait, current); 311 DECLARE_WAITQUEUE(wait, current);
380 int retval = 0; 312 int retval = 0;
381 313
382 dbg("%s : start\n",__FUNCTION__);
383
384 add_wait_queue(&ctrl->queue, &wait); 314 add_wait_queue(&ctrl->queue, &wait);
385 315
386 if (!shpchp_poll_mode) { 316 if (!shpchp_poll_mode) {
@@ -394,19 +324,9 @@ static inline int wait_for_ctrl_irq (struct controller *ctrl)
394 if (signal_pending(current)) 324 if (signal_pending(current))
395 retval = -EINTR; 325 retval = -EINTR;
396 326
397 dbg("%s : end\n", __FUNCTION__);
398 return retval; 327 return retval;
399} 328}
400 329
401/* Puts node back in the resource list pointed to by head */
402static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
403{
404 if (!node || !head)
405 return;
406 node->next = *head;
407 *head = node;
408}
409
410#define SLOT_NAME_SIZE 10 330#define SLOT_NAME_SIZE 10
411 331
412static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 332static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
@@ -420,11 +340,7 @@ enum php_ctlr_type {
420 ACPI 340 ACPI
421}; 341};
422 342
423int shpc_init( struct controller *ctrl, struct pci_dev *pdev, 343int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
424 php_intr_callback_t attention_button_callback,
425 php_intr_callback_t switch_change_callback,
426 php_intr_callback_t presence_change_callback,
427 php_intr_callback_t power_fault_callback);
428 344
429int shpc_get_ctlr_slot_config( struct controller *ctrl, 345int shpc_get_ctlr_slot_config( struct controller *ctrl,
430 int *num_ctlr_slots, 346 int *num_ctlr_slots,
@@ -437,8 +353,6 @@ struct hpc_ops {
437 int (*power_on_slot ) (struct slot *slot); 353 int (*power_on_slot ) (struct slot *slot);
438 int (*slot_enable ) (struct slot *slot); 354 int (*slot_enable ) (struct slot *slot);
439 int (*slot_disable ) (struct slot *slot); 355 int (*slot_disable ) (struct slot *slot);
440 int (*enable_all_slots) (struct slot *slot);
441 int (*pwr_on_all_slots) (struct slot *slot);
442 int (*set_bus_speed_mode) (struct slot *slot, enum pci_bus_speed speed); 356 int (*set_bus_speed_mode) (struct slot *slot, enum pci_bus_speed speed);
443 int (*get_power_status) (struct slot *slot, u8 *status); 357 int (*get_power_status) (struct slot *slot, u8 *status);
444 int (*get_attention_status) (struct slot *slot, u8 *status); 358 int (*get_attention_status) (struct slot *slot, u8 *status);
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 6f7d8a29957a..63628e01dd43 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -27,26 +27,18 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/types.h> 33#include <linux/types.h>
35#include <linux/proc_fs.h>
36#include <linux/slab.h>
37#include <linux/workqueue.h>
38#include <linux/pci.h> 34#include <linux/pci.h>
39#include <linux/init.h>
40#include <asm/uaccess.h>
41#include "shpchp.h" 35#include "shpchp.h"
42#include "shpchprm.h"
43 36
44/* Global variables */ 37/* Global variables */
45int shpchp_debug; 38int shpchp_debug;
46int shpchp_poll_mode; 39int shpchp_poll_mode;
47int shpchp_poll_time; 40int shpchp_poll_time;
48struct controller *shpchp_ctrl_list; /* = NULL */ 41struct controller *shpchp_ctrl_list; /* = NULL */
49struct pci_func *shpchp_slot_list[256];
50 42
51#define DRIVER_VERSION "0.4" 43#define DRIVER_VERSION "0.4"
52#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 44#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -113,8 +105,6 @@ static int init_slots(struct controller *ctrl)
113 u32 slot_number, sun; 105 u32 slot_number, sun;
114 int result = -ENOMEM; 106 int result = -ENOMEM;
115 107
116 dbg("%s\n",__FUNCTION__);
117
118 number_of_slots = ctrl->num_slots; 108 number_of_slots = ctrl->num_slots;
119 slot_device = ctrl->slot_device_offset; 109 slot_device = ctrl->slot_device_offset;
120 slot_number = ctrl->first_slot; 110 slot_number = ctrl->first_slot;
@@ -352,6 +342,17 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
352 return 0; 342 return 0;
353} 343}
354 344
345static int is_shpc_capable(struct pci_dev *dev)
346{
347 if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device ==
348 PCI_DEVICE_ID_AMD_GOLAM_7450))
349 return 1;
350 if (pci_find_capability(dev, PCI_CAP_ID_SHPC))
351 return 1;
352
353 return 0;
354}
355
355static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 356static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
356{ 357{
357 int rc; 358 int rc;
@@ -360,6 +361,9 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
360 int first_device_num; /* first PCI device number supported by this SHPC */ 361 int first_device_num; /* first PCI device number supported by this SHPC */
361 int num_ctlr_slots; /* number of slots supported by this SHPC */ 362 int num_ctlr_slots; /* number of slots supported by this SHPC */
362 363
364 if (!is_shpc_capable(pdev))
365 return -ENODEV;
366
363 ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); 367 ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
364 if (!ctrl) { 368 if (!ctrl) {
365 err("%s : out of memory\n", __FUNCTION__); 369 err("%s : out of memory\n", __FUNCTION__);
@@ -367,19 +371,12 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
367 } 371 }
368 memset(ctrl, 0, sizeof(struct controller)); 372 memset(ctrl, 0, sizeof(struct controller));
369 373
370 dbg("DRV_thread pid = %d\n", current->pid); 374 rc = shpc_init(ctrl, pdev);
371
372 rc = shpc_init(ctrl, pdev,
373 (php_intr_callback_t) shpchp_handle_attention_button,
374 (php_intr_callback_t) shpchp_handle_switch_change,
375 (php_intr_callback_t) shpchp_handle_presence_change,
376 (php_intr_callback_t) shpchp_handle_power_fault);
377 if (rc) { 375 if (rc) {
378 dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME); 376 dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME);
379 goto err_out_free_ctrl; 377 goto err_out_free_ctrl;
380 } 378 }
381 379
382 dbg("%s: controller initialization success\n", __FUNCTION__);
383 ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */ 380 ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
384 381
385 pci_set_drvdata(pdev, ctrl); 382 pci_set_drvdata(pdev, ctrl);
@@ -411,23 +408,8 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
411 first_device_num = ctrl->slot_device_offset; 408 first_device_num = ctrl->slot_device_offset;
412 num_ctlr_slots = ctrl->num_slots; 409 num_ctlr_slots = ctrl->num_slots;
413 410
414 /* Store PCI Config Space for all devices on this bus */ 411 ctrl->add_support = 1;
415 rc = shpchp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
416 if (rc) {
417 err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
418 goto err_out_free_ctrl_bus;
419 }
420
421 /* Get IO, memory, and IRQ resources for new devices */
422 rc = shpchprm_find_available_resources(ctrl);
423 ctrl->add_support = !rc;
424 412
425 if (rc) {
426 dbg("shpchprm_find_available_resources = %#x\n", rc);
427 err("unable to locate PCI configuration resources for hot plug add.\n");
428 goto err_out_free_ctrl_bus;
429 }
430
431 /* Setup the slot information structures */ 413 /* Setup the slot information structures */
432 rc = init_slots(ctrl); 414 rc = init_slots(ctrl);
433 if (rc) { 415 if (rc) {
@@ -477,7 +459,6 @@ err_out_none:
477 459
478static int shpc_start_thread(void) 460static int shpc_start_thread(void)
479{ 461{
480 int loop;
481 int retval = 0; 462 int retval = 0;
482 463
483 dbg("Initialize + Start the notification/polling mechanism \n"); 464 dbg("Initialize + Start the notification/polling mechanism \n");
@@ -488,48 +469,21 @@ static int shpc_start_thread(void)
488 return retval; 469 return retval;
489 } 470 }
490 471
491 dbg("Initialize slot lists\n");
492 /* One slot list for each bus in the system */
493 for (loop = 0; loop < 256; loop++) {
494 shpchp_slot_list[loop] = NULL;
495 }
496
497 return retval; 472 return retval;
498} 473}
499 474
500static inline void __exit
501free_shpchp_res(struct pci_resource *res)
502{
503 struct pci_resource *tres;
504
505 while (res) {
506 tres = res;
507 res = res->next;
508 kfree(tres);
509 }
510}
511
512static void __exit unload_shpchpd(void) 475static void __exit unload_shpchpd(void)
513{ 476{
514 struct pci_func *next;
515 struct pci_func *TempSlot;
516 int loop;
517 struct controller *ctrl; 477 struct controller *ctrl;
518 struct controller *tctrl; 478 struct controller *tctrl;
519 479
520 ctrl = shpchp_ctrl_list; 480 ctrl = shpchp_ctrl_list;
521 481
522 while (ctrl) { 482 while (ctrl) {
483 shpchp_remove_ctrl_files(ctrl);
523 cleanup_slots(ctrl); 484 cleanup_slots(ctrl);
524 485
525 free_shpchp_res(ctrl->io_head);
526 free_shpchp_res(ctrl->mem_head);
527 free_shpchp_res(ctrl->p_mem_head);
528 free_shpchp_res(ctrl->bus_head);
529
530 kfree (ctrl->pci_bus); 486 kfree (ctrl->pci_bus);
531
532 dbg("%s: calling release_ctlr\n", __FUNCTION__);
533 ctrl->hpc_ops->release_ctlr(ctrl); 487 ctrl->hpc_ops->release_ctlr(ctrl);
534 488
535 tctrl = ctrl; 489 tctrl = ctrl;
@@ -538,20 +492,6 @@ static void __exit unload_shpchpd(void)
538 kfree(tctrl); 492 kfree(tctrl);
539 } 493 }
540 494
541 for (loop = 0; loop < 256; loop++) {
542 next = shpchp_slot_list[loop];
543 while (next != NULL) {
544 free_shpchp_res(next->io_head);
545 free_shpchp_res(next->mem_head);
546 free_shpchp_res(next->p_mem_head);
547 free_shpchp_res(next->bus_head);
548
549 TempSlot = next;
550 next = next->next;
551 kfree(TempSlot);
552 }
553 }
554
555 /* Stop the notification mechanism */ 495 /* Stop the notification mechanism */
556 shpchp_event_stop_thread(); 496 shpchp_event_stop_thread();
557 497
@@ -596,20 +536,14 @@ static int __init shpcd_init(void)
596 if (retval) 536 if (retval)
597 goto error_hpc_init; 537 goto error_hpc_init;
598 538
599 retval = shpchprm_init(PCI); 539 retval = pci_register_driver(&shpc_driver);
600 if (!retval) { 540 dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
601 retval = pci_register_driver(&shpc_driver); 541 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
602 dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
603 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
604 }
605 542
606error_hpc_init: 543error_hpc_init:
607 if (retval) { 544 if (retval) {
608 shpchprm_cleanup();
609 shpchp_event_stop_thread(); 545 shpchp_event_stop_thread();
610 } else 546 }
611 shpchprm_print_pirt();
612
613 return retval; 547 return retval;
614} 548}
615 549
@@ -618,9 +552,6 @@ static void __exit shpcd_cleanup(void)
618 dbg("unload_shpchpd()\n"); 552 dbg("unload_shpchpd()\n");
619 unload_shpchpd(); 553 unload_shpchpd();
620 554
621 shpchprm_cleanup();
622
623 dbg("pci_unregister_driver\n");
624 pci_unregister_driver(&shpc_driver); 555 pci_unregister_driver(&shpc_driver);
625 556
626 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 557 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 91c9903e621f..58619359ad08 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -27,24 +27,14 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/workqueue.h>
36#include <linux/interrupt.h>
37#include <linux/delay.h>
38#include <linux/wait.h>
39#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
40#include <linux/pci.h> 34#include <linux/pci.h>
35#include "../pci.h"
41#include "shpchp.h" 36#include "shpchp.h"
42#include "shpchprm.h"
43 37
44static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
45 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
46static int configure_new_function( struct controller *ctrl, struct pci_func *func,
47 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
48static void interrupt_event_handler(struct controller *ctrl); 38static void interrupt_event_handler(struct controller *ctrl);
49 39
50static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 40static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
@@ -52,28 +42,22 @@ static struct semaphore event_exit; /* guard ensure thread has exited before ca
52static int event_finished; 42static int event_finished;
53static unsigned long pushbutton_pending; /* = 0 */ 43static unsigned long pushbutton_pending; /* = 0 */
54 44
55u8 shpchp_disk_irq;
56u8 shpchp_nic_irq;
57
58u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id) 45u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id)
59{ 46{
60 struct controller *ctrl = (struct controller *) inst_id; 47 struct controller *ctrl = (struct controller *) inst_id;
61 struct slot *p_slot; 48 struct slot *p_slot;
62 u8 rc = 0; 49 u8 rc = 0;
63 u8 getstatus; 50 u8 getstatus;
64 struct pci_func *func;
65 struct event_info *taskInfo; 51 struct event_info *taskInfo;
66 52
67 /* Attention Button Change */ 53 /* Attention Button Change */
68 dbg("shpchp: Attention button interrupt received.\n"); 54 dbg("shpchp: Attention button interrupt received.\n");
69 55
70 func = shpchp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
71
72 /* This is the structure that tells the worker thread what to do */ 56 /* This is the structure that tells the worker thread what to do */
73 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 57 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
74 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 58 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
75 59
76 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save)); 60 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
77 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 61 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
78 62
79 ctrl->next_event = (ctrl->next_event + 1) % 10; 63 ctrl->next_event = (ctrl->next_event + 1) % 10;
@@ -118,14 +102,11 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
118 struct slot *p_slot; 102 struct slot *p_slot;
119 u8 rc = 0; 103 u8 rc = 0;
120 u8 getstatus; 104 u8 getstatus;
121 struct pci_func *func;
122 struct event_info *taskInfo; 105 struct event_info *taskInfo;
123 106
124 /* Switch Change */ 107 /* Switch Change */
125 dbg("shpchp: Switch interrupt received.\n"); 108 dbg("shpchp: Switch interrupt received.\n");
126 109
127 func = shpchp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
128
129 /* This is the structure that tells the worker thread 110 /* This is the structure that tells the worker thread
130 * what to do 111 * what to do
131 */ 112 */
@@ -135,19 +116,18 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
135 116
136 rc++; 117 rc++;
137 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 118 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
138 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save)); 119 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
139 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 120 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
140 dbg("%s: Card present %x Power status %x\n", __FUNCTION__, 121 dbg("%s: Card present %x Power status %x\n", __FUNCTION__,
141 func->presence_save, func->pwr_save); 122 p_slot->presence_save, p_slot->pwr_save);
142 123
143 if (getstatus) { 124 if (getstatus) {
144 /* 125 /*
145 * Switch opened 126 * Switch opened
146 */ 127 */
147 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); 128 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
148 func->switch_save = 0;
149 taskInfo->event_type = INT_SWITCH_OPEN; 129 taskInfo->event_type = INT_SWITCH_OPEN;
150 if (func->pwr_save && func->presence_save) { 130 if (p_slot->pwr_save && p_slot->presence_save) {
151 taskInfo->event_type = INT_POWER_FAULT; 131 taskInfo->event_type = INT_POWER_FAULT;
152 err("Surprise Removal of card\n"); 132 err("Surprise Removal of card\n");
153 } 133 }
@@ -156,7 +136,6 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
156 * Switch closed 136 * Switch closed
157 */ 137 */
158 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); 138 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
159 func->switch_save = 0x10;
160 taskInfo->event_type = INT_SWITCH_CLOSE; 139 taskInfo->event_type = INT_SWITCH_CLOSE;
161 } 140 }
162 141
@@ -172,14 +151,11 @@ u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id)
172 struct slot *p_slot; 151 struct slot *p_slot;
173 u8 rc = 0; 152 u8 rc = 0;
174 /*u8 temp_byte;*/ 153 /*u8 temp_byte;*/
175 struct pci_func *func;
176 struct event_info *taskInfo; 154 struct event_info *taskInfo;
177 155
178 /* Presence Change */ 156 /* Presence Change */
179 dbg("shpchp: Presence/Notify input change.\n"); 157 dbg("shpchp: Presence/Notify input change.\n");
180 158
181 func = shpchp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
182
183 /* This is the structure that tells the worker thread 159 /* This is the structure that tells the worker thread
184 * what to do 160 * what to do
185 */ 161 */
@@ -193,8 +169,8 @@ u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id)
193 /* 169 /*
194 * Save the presence state 170 * Save the presence state
195 */ 171 */
196 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save)); 172 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
197 if (func->presence_save) { 173 if (p_slot->presence_save) {
198 /* 174 /*
199 * Card Present 175 * Card Present
200 */ 176 */
@@ -219,14 +195,11 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
219 struct controller *ctrl = (struct controller *) inst_id; 195 struct controller *ctrl = (struct controller *) inst_id;
220 struct slot *p_slot; 196 struct slot *p_slot;
221 u8 rc = 0; 197 u8 rc = 0;
222 struct pci_func *func;
223 struct event_info *taskInfo; 198 struct event_info *taskInfo;
224 199
225 /* Power fault */ 200 /* Power fault */
226 dbg("shpchp: Power fault interrupt received.\n"); 201 dbg("shpchp: Power fault interrupt received.\n");
227 202
228 func = shpchp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
229
230 /* This is the structure that tells the worker thread 203 /* This is the structure that tells the worker thread
231 * what to do 204 * what to do
232 */ 205 */
@@ -242,7 +215,7 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
242 * Power fault Cleared 215 * Power fault Cleared
243 */ 216 */
244 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); 217 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot);
245 func->status = 0x00; 218 p_slot->status = 0x00;
246 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 219 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
247 } else { 220 } else {
248 /* 221 /*
@@ -251,7 +224,7 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
251 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); 224 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot);
252 taskInfo->event_type = INT_POWER_FAULT; 225 taskInfo->event_type = INT_POWER_FAULT;
253 /* set power fault status for this board */ 226 /* set power fault status for this board */
254 func->status = 0xFF; 227 p_slot->status = 0xFF;
255 info("power fault bit %x set\n", hp_slot); 228 info("power fault bit %x set\n", hp_slot);
256 } 229 }
257 if (rc) 230 if (rc)
@@ -260,799 +233,13 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
260 return rc; 233 return rc;
261} 234}
262 235
263
264/*
265 * sort_by_size
266 *
267 * Sorts nodes on the list by their length.
268 * Smallest first.
269 *
270 */
271static int sort_by_size(struct pci_resource **head)
272{
273 struct pci_resource *current_res;
274 struct pci_resource *next_res;
275 int out_of_order = 1;
276
277 if (!(*head))
278 return(1);
279
280 if (!((*head)->next))
281 return(0);
282
283 while (out_of_order) {
284 out_of_order = 0;
285
286 /* Special case for swapping list head */
287 if (((*head)->next) &&
288 ((*head)->length > (*head)->next->length)) {
289 out_of_order++;
290 current_res = *head;
291 *head = (*head)->next;
292 current_res->next = (*head)->next;
293 (*head)->next = current_res;
294 }
295
296 current_res = *head;
297
298 while (current_res->next && current_res->next->next) {
299 if (current_res->next->length > current_res->next->next->length) {
300 out_of_order++;
301 next_res = current_res->next;
302 current_res->next = current_res->next->next;
303 current_res = current_res->next;
304 next_res->next = current_res->next;
305 current_res->next = next_res;
306 } else
307 current_res = current_res->next;
308 }
309 } /* End of out_of_order loop */
310
311 return(0);
312}
313
314
315/*
316 * sort_by_max_size
317 *
318 * Sorts nodes on the list by their length.
319 * Largest first.
320 *
321 */
322static int sort_by_max_size(struct pci_resource **head)
323{
324 struct pci_resource *current_res;
325 struct pci_resource *next_res;
326 int out_of_order = 1;
327
328 if (!(*head))
329 return(1);
330
331 if (!((*head)->next))
332 return(0);
333
334 while (out_of_order) {
335 out_of_order = 0;
336
337 /* Special case for swapping list head */
338 if (((*head)->next) &&
339 ((*head)->length < (*head)->next->length)) {
340 out_of_order++;
341 current_res = *head;
342 *head = (*head)->next;
343 current_res->next = (*head)->next;
344 (*head)->next = current_res;
345 }
346
347 current_res = *head;
348
349 while (current_res->next && current_res->next->next) {
350 if (current_res->next->length < current_res->next->next->length) {
351 out_of_order++;
352 next_res = current_res->next;
353 current_res->next = current_res->next->next;
354 current_res = current_res->next;
355 next_res->next = current_res->next;
356 current_res->next = next_res;
357 } else
358 current_res = current_res->next;
359 }
360 } /* End of out_of_order loop */
361
362 return(0);
363}
364
365
366/*
367 * do_pre_bridge_resource_split
368 *
369 * Returns zero or one node of resources that aren't in use
370 *
371 */
372static struct pci_resource *do_pre_bridge_resource_split (struct pci_resource **head, struct pci_resource **orig_head, u32 alignment)
373{
374 struct pci_resource *prevnode = NULL;
375 struct pci_resource *node;
376 struct pci_resource *split_node;
377 u32 rc;
378 u32 temp_dword;
379 dbg("do_pre_bridge_resource_split\n");
380
381 if (!(*head) || !(*orig_head))
382 return(NULL);
383
384 rc = shpchp_resource_sort_and_combine(head);
385
386 if (rc)
387 return(NULL);
388
389 if ((*head)->base != (*orig_head)->base)
390 return(NULL);
391
392 if ((*head)->length == (*orig_head)->length)
393 return(NULL);
394
395
396 /* If we got here, there the bridge requires some of the resource, but
397 * we may be able to split some off of the front
398 */
399 node = *head;
400
401 if (node->length & (alignment -1)) {
402 /* This one isn't an aligned length, so we'll make a new entry
403 * and split it up.
404 */
405 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
406
407 if (!split_node)
408 return(NULL);
409
410 temp_dword = (node->length | (alignment-1)) + 1 - alignment;
411
412 split_node->base = node->base;
413 split_node->length = temp_dword;
414
415 node->length -= temp_dword;
416 node->base += split_node->length;
417
418 /* Put it in the list */
419 *head = split_node;
420 split_node->next = node;
421 }
422
423 if (node->length < alignment) {
424 return(NULL);
425 }
426
427 /* Now unlink it */
428 if (*head == node) {
429 *head = node->next;
430 node->next = NULL;
431 } else {
432 prevnode = *head;
433 while (prevnode->next != node)
434 prevnode = prevnode->next;
435
436 prevnode->next = node->next;
437 node->next = NULL;
438 }
439
440 return(node);
441}
442
443
444/*
445 * do_bridge_resource_split
446 *
447 * Returns zero or one node of resources that aren't in use
448 *
449 */
450static struct pci_resource *do_bridge_resource_split (struct pci_resource **head, u32 alignment)
451{
452 struct pci_resource *prevnode = NULL;
453 struct pci_resource *node;
454 u32 rc;
455 u32 temp_dword;
456
457 if (!(*head))
458 return(NULL);
459
460 rc = shpchp_resource_sort_and_combine(head);
461
462 if (rc)
463 return(NULL);
464
465 node = *head;
466
467 while (node->next) {
468 prevnode = node;
469 node = node->next;
470 kfree(prevnode);
471 }
472
473 if (node->length < alignment) {
474 kfree(node);
475 return(NULL);
476 }
477
478 if (node->base & (alignment - 1)) {
479 /* Short circuit if adjusted size is too small */
480 temp_dword = (node->base | (alignment-1)) + 1;
481 if ((node->length - (temp_dword - node->base)) < alignment) {
482 kfree(node);
483 return(NULL);
484 }
485
486 node->length -= (temp_dword - node->base);
487 node->base = temp_dword;
488 }
489
490 if (node->length & (alignment - 1)) {
491 /* There's stuff in use after this node */
492 kfree(node);
493 return(NULL);
494 }
495
496 return(node);
497}
498
499
500/*
501 * get_io_resource
502 *
503 * this function sorts the resource list by size and then
504 * returns the first node of "size" length that is not in the
505 * ISA aliasing window. If it finds a node larger than "size"
506 * it will split it up.
507 *
508 * size must be a power of two.
509 */
510static struct pci_resource *get_io_resource (struct pci_resource **head, u32 size)
511{
512 struct pci_resource *prevnode;
513 struct pci_resource *node;
514 struct pci_resource *split_node = NULL;
515 u32 temp_dword;
516
517 if (!(*head))
518 return(NULL);
519
520 if ( shpchp_resource_sort_and_combine(head) )
521 return(NULL);
522
523 if ( sort_by_size(head) )
524 return(NULL);
525
526 for (node = *head; node; node = node->next) {
527 if (node->length < size)
528 continue;
529
530 if (node->base & (size - 1)) {
531 /* This one isn't base aligned properly
532 so we'll make a new entry and split it up */
533 temp_dword = (node->base | (size-1)) + 1;
534
535 /*/ Short circuit if adjusted size is too small */
536 if ((node->length - (temp_dword - node->base)) < size)
537 continue;
538
539 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
540
541 if (!split_node)
542 return(NULL);
543
544 split_node->base = node->base;
545 split_node->length = temp_dword - node->base;
546 node->base = temp_dword;
547 node->length -= split_node->length;
548
549 /* Put it in the list */
550 split_node->next = node->next;
551 node->next = split_node;
552 } /* End of non-aligned base */
553
554 /* Don't need to check if too small since we already did */
555 if (node->length > size) {
556 /* This one is longer than we need
557 so we'll make a new entry and split it up */
558 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
559
560 if (!split_node)
561 return(NULL);
562
563 split_node->base = node->base + size;
564 split_node->length = node->length - size;
565 node->length = size;
566
567 /* Put it in the list */
568 split_node->next = node->next;
569 node->next = split_node;
570 } /* End of too big on top end */
571
572 /* For IO make sure it's not in the ISA aliasing space */
573 if (node->base & 0x300L)
574 continue;
575
576 /* If we got here, then it is the right size
577 Now take it out of the list */
578 if (*head == node) {
579 *head = node->next;
580 } else {
581 prevnode = *head;
582 while (prevnode->next != node)
583 prevnode = prevnode->next;
584
585 prevnode->next = node->next;
586 }
587 node->next = NULL;
588 /* Stop looping */
589 break;
590 }
591
592 return(node);
593}
594
595
596/*
597 * get_max_resource
598 *
599 * Gets the largest node that is at least "size" big from the
600 * list pointed to by head. It aligns the node on top and bottom
601 * to "size" alignment before returning it.
602 * J.I. modified to put max size limits of; 64M->32M->16M->8M->4M->1M
603 * This is needed to avoid allocating entire ACPI _CRS res to one child bridge/slot.
604 */
605static struct pci_resource *get_max_resource (struct pci_resource **head, u32 size)
606{
607 struct pci_resource *max;
608 struct pci_resource *temp;
609 struct pci_resource *split_node;
610 u32 temp_dword;
611 u32 max_size[] = { 0x4000000, 0x2000000, 0x1000000, 0x0800000, 0x0400000, 0x0200000, 0x0100000, 0x00 };
612 int i;
613
614 if (!(*head))
615 return(NULL);
616
617 if (shpchp_resource_sort_and_combine(head))
618 return(NULL);
619
620 if (sort_by_max_size(head))
621 return(NULL);
622
623 for (max = *head;max; max = max->next) {
624
625 /* If not big enough we could probably just bail,
626 instead we'll continue to the next. */
627 if (max->length < size)
628 continue;
629
630 if (max->base & (size - 1)) {
631 /* This one isn't base aligned properly
632 so we'll make a new entry and split it up */
633 temp_dword = (max->base | (size-1)) + 1;
634
635 /* Short circuit if adjusted size is too small */
636 if ((max->length - (temp_dword - max->base)) < size)
637 continue;
638
639 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
640
641 if (!split_node)
642 return(NULL);
643
644 split_node->base = max->base;
645 split_node->length = temp_dword - max->base;
646 max->base = temp_dword;
647 max->length -= split_node->length;
648
649 /* Put it next in the list */
650 split_node->next = max->next;
651 max->next = split_node;
652 }
653
654 if ((max->base + max->length) & (size - 1)) {
655 /* This one isn't end aligned properly at the top
656 so we'll make a new entry and split it up */
657 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
658
659 if (!split_node)
660 return(NULL);
661 temp_dword = ((max->base + max->length) & ~(size - 1));
662 split_node->base = temp_dword;
663 split_node->length = max->length + max->base
664 - split_node->base;
665 max->length -= split_node->length;
666
667 /* Put it in the list */
668 split_node->next = max->next;
669 max->next = split_node;
670 }
671
672 /* Make sure it didn't shrink too much when we aligned it */
673 if (max->length < size)
674 continue;
675
676 for ( i = 0; max_size[i] > size; i++) {
677 if (max->length > max_size[i]) {
678 split_node = kmalloc(sizeof(*split_node),
679 GFP_KERNEL);
680 if (!split_node)
681 break; /* return (NULL); */
682 split_node->base = max->base + max_size[i];
683 split_node->length = max->length - max_size[i];
684 max->length = max_size[i];
685 /* Put it next in the list */
686 split_node->next = max->next;
687 max->next = split_node;
688 break;
689 }
690 }
691
692 /* Now take it out of the list */
693 temp = (struct pci_resource*) *head;
694 if (temp == max) {
695 *head = max->next;
696 } else {
697 while (temp && temp->next != max) {
698 temp = temp->next;
699 }
700
701 temp->next = max->next;
702 }
703
704 max->next = NULL;
705 return(max);
706 }
707
708 /* If we get here, we couldn't find one */
709 return(NULL);
710}
711
712
713/*
714 * get_resource
715 *
716 * this function sorts the resource list by size and then
717 * returns the first node of "size" length. If it finds a node
718 * larger than "size" it will split it up.
719 *
720 * size must be a power of two.
721 */
722static struct pci_resource *get_resource (struct pci_resource **head, u32 size)
723{
724 struct pci_resource *prevnode;
725 struct pci_resource *node;
726 struct pci_resource *split_node;
727 u32 temp_dword;
728
729 if (!(*head))
730 return(NULL);
731
732 if ( shpchp_resource_sort_and_combine(head) )
733 return(NULL);
734
735 if ( sort_by_size(head) )
736 return(NULL);
737
738 for (node = *head; node; node = node->next) {
739 dbg("%s: req_size =0x%x node=%p, base=0x%x, length=0x%x\n",
740 __FUNCTION__, size, node, node->base, node->length);
741 if (node->length < size)
742 continue;
743
744 if (node->base & (size - 1)) {
745 dbg("%s: not aligned\n", __FUNCTION__);
746 /* this one isn't base aligned properly
747 so we'll make a new entry and split it up */
748 temp_dword = (node->base | (size-1)) + 1;
749
750 /* Short circuit if adjusted size is too small */
751 if ((node->length - (temp_dword - node->base)) < size)
752 continue;
753
754 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
755
756 if (!split_node)
757 return(NULL);
758
759 split_node->base = node->base;
760 split_node->length = temp_dword - node->base;
761 node->base = temp_dword;
762 node->length -= split_node->length;
763
764 /* Put it in the list */
765 split_node->next = node->next;
766 node->next = split_node;
767 } /* End of non-aligned base */
768
769 /* Don't need to check if too small since we already did */
770 if (node->length > size) {
771 dbg("%s: too big\n", __FUNCTION__);
772 /* this one is longer than we need
773 so we'll make a new entry and split it up */
774 split_node = kmalloc(sizeof(*split_node), GFP_KERNEL);
775
776 if (!split_node)
777 return(NULL);
778
779 split_node->base = node->base + size;
780 split_node->length = node->length - size;
781 node->length = size;
782
783 /* Put it in the list */
784 split_node->next = node->next;
785 node->next = split_node;
786 } /* End of too big on top end */
787
788 dbg("%s: got one!!!\n", __FUNCTION__);
789 /* If we got here, then it is the right size
790 Now take it out of the list */
791 if (*head == node) {
792 *head = node->next;
793 } else {
794 prevnode = *head;
795 while (prevnode->next != node)
796 prevnode = prevnode->next;
797
798 prevnode->next = node->next;
799 }
800 node->next = NULL;
801 /* Stop looping */
802 break;
803 }
804 return(node);
805}
806
807
808/*
809 * shpchp_resource_sort_and_combine
810 *
811 * Sorts all of the nodes in the list in ascending order by
812 * their base addresses. Also does garbage collection by
813 * combining adjacent nodes.
814 *
815 * returns 0 if success
816 */
817int shpchp_resource_sort_and_combine(struct pci_resource **head)
818{
819 struct pci_resource *node1;
820 struct pci_resource *node2;
821 int out_of_order = 1;
822
823 dbg("%s: head = %p, *head = %p\n", __FUNCTION__, head, *head);
824
825 if (!(*head))
826 return(1);
827
828 dbg("*head->next = %p\n",(*head)->next);
829
830 if (!(*head)->next)
831 return(0); /* only one item on the list, already sorted! */
832
833 dbg("*head->base = 0x%x\n",(*head)->base);
834 dbg("*head->next->base = 0x%x\n",(*head)->next->base);
835 while (out_of_order) {
836 out_of_order = 0;
837
838 /* Special case for swapping list head */
839 if (((*head)->next) &&
840 ((*head)->base > (*head)->next->base)) {
841 node1 = *head;
842 (*head) = (*head)->next;
843 node1->next = (*head)->next;
844 (*head)->next = node1;
845 out_of_order++;
846 }
847
848 node1 = (*head);
849
850 while (node1->next && node1->next->next) {
851 if (node1->next->base > node1->next->next->base) {
852 out_of_order++;
853 node2 = node1->next;
854 node1->next = node1->next->next;
855 node1 = node1->next;
856 node2->next = node1->next;
857 node1->next = node2;
858 } else
859 node1 = node1->next;
860 }
861 } /* End of out_of_order loop */
862
863 node1 = *head;
864
865 while (node1 && node1->next) {
866 if ((node1->base + node1->length) == node1->next->base) {
867 /* Combine */
868 dbg("8..\n");
869 node1->length += node1->next->length;
870 node2 = node1->next;
871 node1->next = node1->next->next;
872 kfree(node2);
873 } else
874 node1 = node1->next;
875 }
876
877 return(0);
878}
879
880
881/**
882 * shpchp_slot_create - Creates a node and adds it to the proper bus.
883 * @busnumber - bus where new node is to be located
884 *
885 * Returns pointer to the new node or NULL if unsuccessful
886 */
887struct pci_func *shpchp_slot_create(u8 busnumber)
888{
889 struct pci_func *new_slot;
890 struct pci_func *next;
891
892 new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL);
893
894 if (new_slot == NULL) {
895 return(new_slot);
896 }
897
898 memset(new_slot, 0, sizeof(struct pci_func));
899
900 new_slot->next = NULL;
901 new_slot->configured = 1;
902
903 if (shpchp_slot_list[busnumber] == NULL) {
904 shpchp_slot_list[busnumber] = new_slot;
905 } else {
906 next = shpchp_slot_list[busnumber];
907 while (next->next != NULL)
908 next = next->next;
909 next->next = new_slot;
910 }
911 return(new_slot);
912}
913
914
915/*
916 * slot_remove - Removes a node from the linked list of slots.
917 * @old_slot: slot to remove
918 *
919 * Returns 0 if successful, !0 otherwise.
920 */
921static int slot_remove(struct pci_func * old_slot)
922{
923 struct pci_func *next;
924
925 if (old_slot == NULL)
926 return(1);
927
928 next = shpchp_slot_list[old_slot->bus];
929
930 if (next == NULL) {
931 return(1);
932 }
933
934 if (next == old_slot) {
935 shpchp_slot_list[old_slot->bus] = old_slot->next;
936 shpchp_destroy_board_resources(old_slot);
937 kfree(old_slot);
938 return(0);
939 }
940
941 while ((next->next != old_slot) && (next->next != NULL)) {
942 next = next->next;
943 }
944
945 if (next->next == old_slot) {
946 next->next = old_slot->next;
947 shpchp_destroy_board_resources(old_slot);
948 kfree(old_slot);
949 return(0);
950 } else
951 return(2);
952}
953
954
955/**
956 * bridge_slot_remove - Removes a node from the linked list of slots.
957 * @bridge: bridge to remove
958 *
959 * Returns 0 if successful, !0 otherwise.
960 */
961static int bridge_slot_remove(struct pci_func *bridge)
962{
963 u8 subordinateBus, secondaryBus;
964 u8 tempBus;
965 struct pci_func *next;
966
967 if (bridge == NULL)
968 return(1);
969
970 secondaryBus = (bridge->config_space[0x06] >> 8) & 0xFF;
971 subordinateBus = (bridge->config_space[0x06] >> 16) & 0xFF;
972
973 for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
974 next = shpchp_slot_list[tempBus];
975
976 while (!slot_remove(next)) {
977 next = shpchp_slot_list[tempBus];
978 }
979 }
980
981 next = shpchp_slot_list[bridge->bus];
982
983 if (next == NULL) {
984 return(1);
985 }
986
987 if (next == bridge) {
988 shpchp_slot_list[bridge->bus] = bridge->next;
989 kfree(bridge);
990 return(0);
991 }
992
993 while ((next->next != bridge) && (next->next != NULL)) {
994 next = next->next;
995 }
996
997 if (next->next == bridge) {
998 next->next = bridge->next;
999 kfree(bridge);
1000 return(0);
1001 } else
1002 return(2);
1003}
1004
1005
1006/**
1007 * shpchp_slot_find - Looks for a node by bus, and device, multiple functions accessed
1008 * @bus: bus to find
1009 * @device: device to find
1010 * @index: is 0 for first function found, 1 for the second...
1011 *
1012 * Returns pointer to the node if successful, %NULL otherwise.
1013 */
1014struct pci_func *shpchp_slot_find(u8 bus, u8 device, u8 index)
1015{
1016 int found = -1;
1017 struct pci_func *func;
1018
1019 func = shpchp_slot_list[bus];
1020
1021 if ((func == NULL) || ((func->device == device) && (index == 0)))
1022 return(func);
1023
1024 if (func->device == device)
1025 found++;
1026
1027 while (func->next != NULL) {
1028 func = func->next;
1029
1030 if (func->device == device)
1031 found++;
1032
1033 if (found == index)
1034 return(func);
1035 }
1036
1037 return(NULL);
1038}
1039
1040static int is_bridge(struct pci_func * func)
1041{
1042 /* Check the header type */
1043 if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
1044 return 1;
1045 else
1046 return 0;
1047}
1048
1049
1050/* The following routines constitute the bulk of the 236/* The following routines constitute the bulk of the
1051 hotplug controller logic 237 hotplug controller logic
1052 */ 238 */
1053static u32 change_bus_speed(struct controller *ctrl, struct slot *p_slot, enum pci_bus_speed speed) 239static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
240 enum pci_bus_speed speed)
1054{ 241{
1055 u32 rc = 0; 242 int rc = 0;
1056 243
1057 dbg("%s: change to speed %d\n", __FUNCTION__, speed); 244 dbg("%s: change to speed %d\n", __FUNCTION__, speed);
1058 down(&ctrl->crit_sect); 245 down(&ctrl->crit_sect);
@@ -1074,10 +261,11 @@ static u32 change_bus_speed(struct controller *ctrl, struct slot *p_slot, enum p
1074 return rc; 261 return rc;
1075} 262}
1076 263
1077static u32 fix_bus_speed(struct controller *ctrl, struct slot *pslot, u8 flag, 264static int fix_bus_speed(struct controller *ctrl, struct slot *pslot,
1078enum pci_bus_speed asp, enum pci_bus_speed bsp, enum pci_bus_speed msp) 265 u8 flag, enum pci_bus_speed asp, enum pci_bus_speed bsp,
266 enum pci_bus_speed msp)
1079{ 267{
1080 u32 rc = 0; 268 int rc = 0;
1081 269
1082 if (flag != 0) { /* Other slots on the same bus are occupied */ 270 if (flag != 0) { /* Other slots on the same bus are occupied */
1083 if ( asp < bsp ) { 271 if ( asp < bsp ) {
@@ -1116,23 +304,20 @@ enum pci_bus_speed asp, enum pci_bus_speed bsp, enum pci_bus_speed msp)
1116 * Configures board 304 * Configures board
1117 * 305 *
1118 */ 306 */
1119static u32 board_added(struct pci_func * func, struct controller * ctrl) 307static int board_added(struct slot *p_slot)
1120{ 308{
1121 u8 hp_slot; 309 u8 hp_slot;
1122 u8 slots_not_empty = 0; 310 u8 slots_not_empty = 0;
1123 int index; 311 int rc = 0;
1124 u32 temp_register = 0xFFFFFFFF;
1125 u32 retval, rc = 0;
1126 struct pci_func *new_func = NULL;
1127 struct slot *p_slot;
1128 struct resource_lists res_lists;
1129 enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed; 312 enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed;
1130 u8 pi, mode; 313 u8 pi, mode;
314 struct controller *ctrl = p_slot->ctrl;
1131 315
1132 p_slot = shpchp_find_slot(ctrl, func->device); 316 hp_slot = p_slot->device - ctrl->slot_device_offset;
1133 hp_slot = func->device - ctrl->slot_device_offset;
1134 317
1135 dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); 318 dbg("%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n",
319 __FUNCTION__, p_slot->device,
320 ctrl->slot_device_offset, hp_slot);
1136 321
1137 /* Wait for exclusive access to hardware */ 322 /* Wait for exclusive access to hardware */
1138 down(&ctrl->crit_sect); 323 down(&ctrl->crit_sect);
@@ -1320,143 +505,68 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
1320 up(&ctrl->crit_sect); 505 up(&ctrl->crit_sect);
1321 506
1322 /* Wait for ~1 second */ 507 /* Wait for ~1 second */
1323 dbg("%s: before long_delay\n", __FUNCTION__);
1324 wait_for_ctrl_irq (ctrl); 508 wait_for_ctrl_irq (ctrl);
1325 dbg("%s: after long_delay\n", __FUNCTION__);
1326 509
1327 dbg("%s: func status = %x\n", __FUNCTION__, func->status); 510 dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status);
1328 /* Check for a power fault */ 511 /* Check for a power fault */
1329 if (func->status == 0xFF) { 512 if (p_slot->status == 0xFF) {
1330 /* power fault occurred, but it was benign */ 513 /* power fault occurred, but it was benign */
1331 temp_register = 0xFFFFFFFF; 514 dbg("%s: power fault\n", __FUNCTION__);
1332 dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register);
1333 rc = POWER_FAILURE; 515 rc = POWER_FAILURE;
1334 func->status = 0; 516 p_slot->status = 0;
1335 } else { 517 goto err_exit;
1336 /* Get vendor/device ID u32 */
1337 rc = pci_bus_read_config_dword (ctrl->pci_dev->subordinate, PCI_DEVFN(func->device, func->function),
1338 PCI_VENDOR_ID, &temp_register);
1339 dbg("%s: pci_bus_read_config_dword returns %d\n", __FUNCTION__, rc);
1340 dbg("%s: temp_register is %x\n", __FUNCTION__, temp_register);
1341
1342 if (rc != 0) {
1343 /* Something's wrong here */
1344 temp_register = 0xFFFFFFFF;
1345 dbg("%s: temp register set to %x by error\n", __FUNCTION__, temp_register);
1346 }
1347 /* Preset return code. It will be changed later if things go okay. */
1348 rc = NO_ADAPTER_PRESENT;
1349 } 518 }
1350 519
1351 /* All F's is an empty slot or an invalid board */ 520 if (shpchp_configure_device(p_slot)) {
1352 if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */ 521 err("Cannot add device at 0x%x:0x%x\n", p_slot->bus,
1353 res_lists.io_head = ctrl->io_head; 522 p_slot->device);
1354 res_lists.mem_head = ctrl->mem_head; 523 goto err_exit;
1355 res_lists.p_mem_head = ctrl->p_mem_head; 524 }
1356 res_lists.bus_head = ctrl->bus_head;
1357 res_lists.irqs = NULL;
1358
1359 rc = configure_new_device(ctrl, func, 0, &res_lists, 0, 0);
1360 dbg("%s: back from configure_new_device\n", __FUNCTION__);
1361
1362 ctrl->io_head = res_lists.io_head;
1363 ctrl->mem_head = res_lists.mem_head;
1364 ctrl->p_mem_head = res_lists.p_mem_head;
1365 ctrl->bus_head = res_lists.bus_head;
1366
1367 shpchp_resource_sort_and_combine(&(ctrl->mem_head));
1368 shpchp_resource_sort_and_combine(&(ctrl->p_mem_head));
1369 shpchp_resource_sort_and_combine(&(ctrl->io_head));
1370 shpchp_resource_sort_and_combine(&(ctrl->bus_head));
1371
1372 if (rc) {
1373 /* Wait for exclusive access to hardware */
1374 down(&ctrl->crit_sect);
1375
1376 /* turn off slot, turn on Amber LED, turn off Green LED */
1377 retval = p_slot->hpc_ops->slot_disable(p_slot);
1378 if (retval) {
1379 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
1380 /* Done with exclusive hardware access */
1381 up(&ctrl->crit_sect);
1382 return retval;
1383 }
1384 /* Wait for the command to complete */
1385 wait_for_ctrl_irq (ctrl);
1386
1387 retval = p_slot->hpc_ops->check_cmd_status(ctrl);
1388 if (retval) {
1389 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, retval);
1390 /* Done with exclusive hardware access */
1391 up(&ctrl->crit_sect);
1392 return retval;
1393 }
1394
1395 /* Done with exclusive hardware access */
1396 up(&ctrl->crit_sect);
1397 525
1398 return(rc); 526 p_slot->status = 0;
1399 } 527 p_slot->is_a_board = 0x01;
1400 shpchp_save_slot_config(ctrl, func); 528 p_slot->pwr_save = 1;
1401 529
1402 func->status = 0; 530 /* Wait for exclusive access to hardware */
1403 func->switch_save = 0x10; 531 down(&ctrl->crit_sect);
1404 func->is_a_board = 0x01;
1405 func->pwr_save = 1;
1406 532
1407 /* Next, we will instantiate the linux pci_dev structures 533 p_slot->hpc_ops->green_led_on(p_slot);
1408 * (with appropriate driver notification, if already present)
1409 */
1410 index = 0;
1411 do {
1412 new_func = shpchp_slot_find(ctrl->slot_bus, func->device, index++);
1413 if (new_func && !new_func->pci_dev) {
1414 dbg("%s:call pci_hp_configure_dev\n", __FUNCTION__);
1415 shpchp_configure_device(ctrl, new_func);
1416 }
1417 } while (new_func);
1418 534
1419 /* Wait for exclusive access to hardware */ 535 /* Wait for the command to complete */
1420 down(&ctrl->crit_sect); 536 wait_for_ctrl_irq (ctrl);
1421 537
1422 p_slot->hpc_ops->green_led_on(p_slot); 538 /* Done with exclusive hardware access */
539 up(&ctrl->crit_sect);
1423 540
1424 /* Wait for the command to complete */ 541 return 0;
1425 wait_for_ctrl_irq (ctrl);
1426 542
543err_exit:
544 /* Wait for exclusive access to hardware */
545 down(&ctrl->crit_sect);
1427 546
547 /* turn off slot, turn on Amber LED, turn off Green LED */
548 rc = p_slot->hpc_ops->slot_disable(p_slot);
549 if (rc) {
550 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
1428 /* Done with exclusive hardware access */ 551 /* Done with exclusive hardware access */
1429 up(&ctrl->crit_sect); 552 up(&ctrl->crit_sect);
553 return rc;
554 }
555 /* Wait for the command to complete */
556 wait_for_ctrl_irq (ctrl);
1430 557
1431 } else { 558 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
1432 /* Wait for exclusive access to hardware */ 559 if (rc) {
1433 down(&ctrl->crit_sect); 560 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
1434
1435 /* turn off slot, turn on Amber LED, turn off Green LED */
1436 rc = p_slot->hpc_ops->slot_disable(p_slot);
1437 if (rc) {
1438 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
1439 /* Done with exclusive hardware access */
1440 up(&ctrl->crit_sect);
1441 return rc;
1442 }
1443 /* Wait for the command to complete */
1444 wait_for_ctrl_irq (ctrl);
1445
1446 rc = p_slot->hpc_ops->check_cmd_status(ctrl);
1447 if (rc) {
1448 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
1449 /* Done with exclusive hardware access */
1450 up(&ctrl->crit_sect);
1451 return rc;
1452 }
1453
1454 /* Done with exclusive hardware access */ 561 /* Done with exclusive hardware access */
1455 up(&ctrl->crit_sect); 562 up(&ctrl->crit_sect);
1456 563 return rc;
1457 return(rc);
1458 } 564 }
1459 return 0; 565
566 /* Done with exclusive hardware access */
567 up(&ctrl->crit_sect);
568
569 return(rc);
1460} 570}
1461 571
1462 572
@@ -1464,55 +574,23 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
1464 * remove_board - Turns off slot and LED's 574 * remove_board - Turns off slot and LED's
1465 * 575 *
1466 */ 576 */
1467static u32 remove_board(struct pci_func *func, struct controller *ctrl) 577static int remove_board(struct slot *p_slot)
1468{ 578{
1469 int index; 579 struct controller *ctrl = p_slot->ctrl;
1470 u8 skip = 0;
1471 u8 device;
1472 u8 hp_slot; 580 u8 hp_slot;
1473 u32 rc; 581 int rc;
1474 struct resource_lists res_lists;
1475 struct pci_func *temp_func;
1476 struct slot *p_slot;
1477
1478 if (func == NULL)
1479 return(1);
1480 582
1481 if (shpchp_unconfigure_device(func)) 583 if (shpchp_unconfigure_device(p_slot))
1482 return(1); 584 return(1);
1483 585
1484 device = func->device; 586 hp_slot = p_slot->device - ctrl->slot_device_offset;
1485
1486 hp_slot = func->device - ctrl->slot_device_offset;
1487 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 587 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1488 588
1489 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 589 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
1490 590
1491 if ((ctrl->add_support) &&
1492 !(func->bus_head || func->mem_head || func->p_mem_head || func->io_head)) {
1493 /* Here we check to see if we've saved any of the board's
1494 * resources already. If so, we'll skip the attempt to
1495 * determine what's being used.
1496 */
1497 index = 0;
1498
1499 temp_func = func;
1500
1501 while ((temp_func = shpchp_slot_find(temp_func->bus, temp_func->device, index++))) {
1502 if (temp_func->bus_head || temp_func->mem_head
1503 || temp_func->p_mem_head || temp_func->io_head) {
1504 skip = 1;
1505 break;
1506 }
1507 }
1508
1509 if (!skip)
1510 rc = shpchp_save_used_resources(ctrl, func, DISABLE_CARD);
1511 }
1512 /* Change status to shutdown */ 591 /* Change status to shutdown */
1513 if (func->is_a_board) 592 if (p_slot->is_a_board)
1514 func->status = 0x01; 593 p_slot->status = 0x01;
1515 func->configured = 0;
1516 594
1517 /* Wait for exclusive access to hardware */ 595 /* Wait for exclusive access to hardware */
1518 down(&ctrl->crit_sect); 596 down(&ctrl->crit_sect);
@@ -1549,55 +627,8 @@ static u32 remove_board(struct pci_func *func, struct controller *ctrl)
1549 /* Done with exclusive hardware access */ 627 /* Done with exclusive hardware access */
1550 up(&ctrl->crit_sect); 628 up(&ctrl->crit_sect);
1551 629
1552 if (ctrl->add_support) { 630 p_slot->pwr_save = 0;
1553 while (func) { 631 p_slot->is_a_board = 0;
1554 res_lists.io_head = ctrl->io_head;
1555 res_lists.mem_head = ctrl->mem_head;
1556 res_lists.p_mem_head = ctrl->p_mem_head;
1557 res_lists.bus_head = ctrl->bus_head;
1558
1559 dbg("Returning resources to ctlr lists for (B/D/F) = (%#x/%#x/%#x)\n", func->bus,
1560 func->device, func->function);
1561
1562 shpchp_return_board_resources(func, &res_lists);
1563
1564 ctrl->io_head = res_lists.io_head;
1565 ctrl->mem_head = res_lists.mem_head;
1566 ctrl->p_mem_head = res_lists.p_mem_head;
1567 ctrl->bus_head = res_lists.bus_head;
1568
1569 shpchp_resource_sort_and_combine(&(ctrl->mem_head));
1570 shpchp_resource_sort_and_combine(&(ctrl->p_mem_head));
1571 shpchp_resource_sort_and_combine(&(ctrl->io_head));
1572 shpchp_resource_sort_and_combine(&(ctrl->bus_head));
1573
1574 if (is_bridge(func)) {
1575 dbg("PCI Bridge Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus,
1576 func->device, func->function);
1577 bridge_slot_remove(func);
1578 } else
1579 dbg("PCI Function Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus,
1580 func->device, func->function);
1581 slot_remove(func);
1582
1583 func = shpchp_slot_find(ctrl->slot_bus, device, 0);
1584 }
1585
1586 /* Setup slot structure with entry for empty slot */
1587 func = shpchp_slot_create(ctrl->slot_bus);
1588
1589 if (func == NULL) {
1590 return(1);
1591 }
1592
1593 func->bus = ctrl->slot_bus;
1594 func->device = device;
1595 func->function = 0;
1596 func->configured = 0;
1597 func->switch_save = 0x10;
1598 func->pwr_save = 0;
1599 func->is_a_board = 0;
1600 }
1601 632
1602 return 0; 633 return 0;
1603} 634}
@@ -1633,13 +664,11 @@ static void shpchp_pushbutton_thread (unsigned long slot)
1633 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 664 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1634 if (getstatus) { 665 if (getstatus) {
1635 p_slot->state = POWEROFF_STATE; 666 p_slot->state = POWEROFF_STATE;
1636 dbg("In power_down_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
1637 667
1638 shpchp_disable_slot(p_slot); 668 shpchp_disable_slot(p_slot);
1639 p_slot->state = STATIC_STATE; 669 p_slot->state = STATIC_STATE;
1640 } else { 670 } else {
1641 p_slot->state = POWERON_STATE; 671 p_slot->state = POWERON_STATE;
1642 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
1643 672
1644 if (shpchp_enable_slot(p_slot)) { 673 if (shpchp_enable_slot(p_slot)) {
1645 /* Wait for exclusive access to hardware */ 674 /* Wait for exclusive access to hardware */
@@ -1701,7 +730,6 @@ int shpchp_event_start_thread (void)
1701 err ("Can't start up our event thread\n"); 730 err ("Can't start up our event thread\n");
1702 return -1; 731 return -1;
1703 } 732 }
1704 dbg("Our event thread pid = %d\n", pid);
1705 return 0; 733 return 0;
1706} 734}
1707 735
@@ -1709,9 +737,7 @@ int shpchp_event_start_thread (void)
1709void shpchp_event_stop_thread (void) 737void shpchp_event_stop_thread (void)
1710{ 738{
1711 event_finished = 1; 739 event_finished = 1;
1712 dbg("event_thread finish command given\n");
1713 up(&event_semaphore); 740 up(&event_semaphore);
1714 dbg("wait for event_thread to exit\n");
1715 down(&event_exit); 741 down(&event_exit);
1716} 742}
1717 743
@@ -1739,12 +765,10 @@ static void interrupt_event_handler(struct controller *ctrl)
1739{ 765{
1740 int loop = 0; 766 int loop = 0;
1741 int change = 1; 767 int change = 1;
1742 struct pci_func *func;
1743 u8 hp_slot; 768 u8 hp_slot;
1744 u8 getstatus; 769 u8 getstatus;
1745 struct slot *p_slot; 770 struct slot *p_slot;
1746 771
1747 dbg("%s:\n", __FUNCTION__);
1748 while (change) { 772 while (change) {
1749 change = 0; 773 change = 0;
1750 774
@@ -1754,12 +778,8 @@ static void interrupt_event_handler(struct controller *ctrl)
1754 ctrl->event_queue[loop].event_type); 778 ctrl->event_queue[loop].event_type);
1755 hp_slot = ctrl->event_queue[loop].hp_slot; 779 hp_slot = ctrl->event_queue[loop].hp_slot;
1756 780
1757 func = shpchp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
1758
1759 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 781 p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1760 782
1761 dbg("%s: hp_slot %d, func %p, p_slot %p\n", __FUNCTION__, hp_slot, func, p_slot);
1762
1763 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { 783 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
1764 dbg("%s: button cancel\n", __FUNCTION__); 784 dbg("%s: button cancel\n", __FUNCTION__);
1765 del_timer(&p_slot->task_event); 785 del_timer(&p_slot->task_event);
@@ -1880,13 +900,6 @@ int shpchp_enable_slot (struct slot *p_slot)
1880{ 900{
1881 u8 getstatus = 0; 901 u8 getstatus = 0;
1882 int rc; 902 int rc;
1883 struct pci_func *func;
1884
1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0);
1886 if (!func) {
1887 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1888 return -ENODEV;
1889 }
1890 903
1891 /* Check to see if (latch closed, card present, power off) */ 904 /* Check to see if (latch closed, card present, power off) */
1892 down(&p_slot->ctrl->crit_sect); 905 down(&p_slot->ctrl->crit_sect);
@@ -1910,72 +923,34 @@ int shpchp_enable_slot (struct slot *p_slot)
1910 } 923 }
1911 up(&p_slot->ctrl->crit_sect); 924 up(&p_slot->ctrl->crit_sect);
1912 925
1913 slot_remove(func); 926 p_slot->is_a_board = 1;
1914
1915 func = shpchp_slot_create(p_slot->bus);
1916 if (func == NULL)
1917 return -ENOMEM;
1918
1919 func->bus = p_slot->bus;
1920 func->device = p_slot->device;
1921 func->function = 0;
1922 func->configured = 0;
1923 func->is_a_board = 1;
1924 927
1925 /* We have to save the presence info for these slots */ 928 /* We have to save the presence info for these slots */
1926 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save)); 929 p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
1927 p_slot->hpc_ops->get_power_status(p_slot, &(func->pwr_save)); 930 p_slot->hpc_ops->get_power_status(p_slot, &(p_slot->pwr_save));
1928 dbg("%s: func->pwr_save %x\n", __FUNCTION__, func->pwr_save); 931 dbg("%s: p_slot->pwr_save %x\n", __FUNCTION__, p_slot->pwr_save);
1929 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 932 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1930 func->switch_save = !getstatus? 0x10:0;
1931 933
1932 rc = board_added(func, p_slot->ctrl); 934 rc = board_added(p_slot);
1933 if (rc) { 935 if (rc) {
1934 if (is_bridge(func)) 936 p_slot->hpc_ops->get_adapter_status(p_slot,
1935 bridge_slot_remove(func); 937 &(p_slot->presence_save));
1936 else
1937 slot_remove(func);
1938
1939 /* Setup slot structure with entry for empty slot */
1940 func = shpchp_slot_create(p_slot->bus);
1941 if (func == NULL)
1942 return -ENOMEM; /* Out of memory */
1943
1944 func->bus = p_slot->bus;
1945 func->device = p_slot->device;
1946 func->function = 0;
1947 func->configured = 0;
1948 func->is_a_board = 1;
1949
1950 /* We have to save the presence info for these slots */
1951 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
1952 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 938 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1953 func->switch_save = !getstatus? 0x10:0;
1954 } 939 }
1955 940
1956 if (p_slot) 941 update_slot_info(p_slot);
1957 update_slot_info(p_slot);
1958
1959 return rc; 942 return rc;
1960} 943}
1961 944
1962 945
1963int shpchp_disable_slot (struct slot *p_slot) 946int shpchp_disable_slot (struct slot *p_slot)
1964{ 947{
1965 u8 class_code, header_type, BCR;
1966 u8 index = 0;
1967 u8 getstatus = 0; 948 u8 getstatus = 0;
1968 u32 rc = 0;
1969 int ret = 0; 949 int ret = 0;
1970 unsigned int devfn;
1971 struct pci_bus *pci_bus;
1972 struct pci_func *func;
1973 950
1974 if (!p_slot->ctrl) 951 if (!p_slot->ctrl)
1975 return -ENODEV; 952 return -ENODEV;
1976 953
1977 pci_bus = p_slot->ctrl->pci_dev->subordinate;
1978
1979 /* Check to see if (latch closed, card present, power on) */ 954 /* Check to see if (latch closed, card present, power on) */
1980 down(&p_slot->ctrl->crit_sect); 955 down(&p_slot->ctrl->crit_sect);
1981 956
@@ -1999,849 +974,8 @@ int shpchp_disable_slot (struct slot *p_slot)
1999 } 974 }
2000 up(&p_slot->ctrl->crit_sect); 975 up(&p_slot->ctrl->crit_sect);
2001 976
2002 func = shpchp_slot_find(p_slot->bus, p_slot->device, index++); 977 ret = remove_board(p_slot);
2003 978 update_slot_info(p_slot);
2004 /* Make sure there are no video controllers here 979 return ret;
2005 * for all func of p_slot
2006 */
2007 while (func && !rc) {
2008 pci_bus->number = func->bus;
2009 devfn = PCI_DEVFN(func->device, func->function);
2010
2011 /* Check the Class Code */
2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2013 if (rc)
2014 return -ENODEV;
2015
2016 if (class_code == PCI_BASE_CLASS_DISPLAY) {
2017 /* Display/Video adapter (not supported) */
2018 rc = REMOVE_NOT_SUPPORTED;
2019 } else {
2020 /* See if it's a bridge */
2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
2022 if (rc)
2023 return -ENODEV;
2024
2025 /* If it's a bridge, check the VGA Enable bit */
2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
2028 if (rc)
2029 return -ENODEV;
2030
2031 /* If the VGA Enable bit is set, remove isn't supported */
2032 if (BCR & PCI_BRIDGE_CTL_VGA) {
2033 rc = REMOVE_NOT_SUPPORTED;
2034 }
2035 }
2036 }
2037
2038 func = shpchp_slot_find(p_slot->bus, p_slot->device, index++);
2039 }
2040
2041 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0);
2042 if ((func != NULL) && !rc) {
2043 rc = remove_board(func, p_slot->ctrl);
2044 } else if (!rc)
2045 rc = -ENODEV;
2046
2047 if (p_slot)
2048 update_slot_info(p_slot);
2049
2050 return rc;
2051}
2052
2053
2054/**
2055 * configure_new_device - Configures the PCI header information of one board.
2056 *
2057 * @ctrl: pointer to controller structure
2058 * @func: pointer to function structure
2059 * @behind_bridge: 1 if this is a recursive call, 0 if not
2060 * @resources: pointer to set of resource lists
2061 *
2062 * Returns 0 if success
2063 *
2064 */
2065static u32 configure_new_device (struct controller * ctrl, struct pci_func * func,
2066 u8 behind_bridge, struct resource_lists * resources, u8 bridge_bus, u8 bridge_dev)
2067{
2068 u8 temp_byte, function, max_functions, stop_it;
2069 int rc;
2070 u32 ID;
2071 struct pci_func *new_slot;
2072 struct pci_bus lpci_bus, *pci_bus;
2073 int index;
2074
2075 new_slot = func;
2076
2077 dbg("%s\n", __FUNCTION__);
2078 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
2079 pci_bus = &lpci_bus;
2080 pci_bus->number = func->bus;
2081
2082 /* Check for Multi-function device */
2083 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
2084 if (rc) {
2085 dbg("%s: rc = %d\n", __FUNCTION__, rc);
2086 return rc;
2087 }
2088
2089 if (temp_byte & 0x80) /* Multi-function device */
2090 max_functions = 8;
2091 else
2092 max_functions = 1;
2093
2094 function = 0;
2095
2096 do {
2097 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources, bridge_bus, bridge_dev);
2098
2099 if (rc) {
2100 dbg("configure_new_function failed %d\n",rc);
2101 index = 0;
2102
2103 while (new_slot) {
2104 new_slot = shpchp_slot_find(new_slot->bus, new_slot->device, index++);
2105
2106 if (new_slot)
2107 shpchp_return_board_resources(new_slot, resources);
2108 }
2109
2110 return(rc);
2111 }
2112
2113 function++;
2114
2115 stop_it = 0;
2116
2117 /* The following loop skips to the next present function
2118 * and creates a board structure
2119 */
2120
2121 while ((function < max_functions) && (!stop_it)) {
2122 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
2123
2124 if (ID == 0xFFFFFFFF) { /* There's nothing there. */
2125 function++;
2126 } else { /* There's something there */
2127 /* Setup slot structure. */
2128 new_slot = shpchp_slot_create(func->bus);
2129
2130 if (new_slot == NULL) {
2131 /* Out of memory */
2132 return(1);
2133 }
2134
2135 new_slot->bus = func->bus;
2136 new_slot->device = func->device;
2137 new_slot->function = function;
2138 new_slot->is_a_board = 1;
2139 new_slot->status = 0;
2140
2141 stop_it++;
2142 }
2143 }
2144
2145 } while (function < max_functions);
2146 dbg("returning from configure_new_device\n");
2147
2148 return 0;
2149}
2150
2151
2152/*
2153 * Configuration logic that involves the hotplug data structures and
2154 * their bookkeeping
2155 */
2156
2157
2158/**
2159 * configure_new_function - Configures the PCI header information of one device
2160 *
2161 * @ctrl: pointer to controller structure
2162 * @func: pointer to function structure
2163 * @behind_bridge: 1 if this is a recursive call, 0 if not
2164 * @resources: pointer to set of resource lists
2165 *
2166 * Calls itself recursively for bridged devices.
2167 * Returns 0 if success
2168 *
2169 */
2170static int configure_new_function (struct controller * ctrl, struct pci_func * func,
2171 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev)
2172{
2173 int cloop;
2174 u8 temp_byte;
2175 u8 device;
2176 u8 class_code;
2177 u16 temp_word;
2178 u32 rc;
2179 u32 temp_register;
2180 u32 base;
2181 u32 ID;
2182 unsigned int devfn;
2183 struct pci_resource *mem_node;
2184 struct pci_resource *p_mem_node;
2185 struct pci_resource *io_node;
2186 struct pci_resource *bus_node;
2187 struct pci_resource *hold_mem_node;
2188 struct pci_resource *hold_p_mem_node;
2189 struct pci_resource *hold_IO_node;
2190 struct pci_resource *hold_bus_node;
2191 struct irq_mapping irqs;
2192 struct pci_func *new_slot;
2193 struct pci_bus lpci_bus, *pci_bus;
2194 struct resource_lists temp_resources;
2195#if defined(CONFIG_X86_64)
2196 u8 IRQ=0;
2197#endif
2198
2199 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
2200 pci_bus = &lpci_bus;
2201 pci_bus->number = func->bus;
2202 devfn = PCI_DEVFN(func->device, func->function);
2203
2204 /* Check for Bridge */
2205 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &temp_byte);
2206 if (rc)
2207 return rc;
2208
2209 if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
2210 /* set Primary bus */
2211 dbg("set Primary bus = 0x%x\n", func->bus);
2212 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
2213 if (rc)
2214 return rc;
2215
2216 /* find range of busses to use */
2217 bus_node = get_max_resource(&resources->bus_head, 1L);
2218
2219 /* If we don't have any busses to allocate, we can't continue */
2220 if (!bus_node) {
2221 err("Got NO bus resource to use\n");
2222 return -ENOMEM;
2223 }
2224 dbg("Got ranges of buses to use: base:len=0x%x:%x\n", bus_node->base, bus_node->length);
2225
2226 /* set Secondary bus */
2227 temp_byte = (u8)bus_node->base;
2228 dbg("set Secondary bus = 0x%x\n", temp_byte);
2229 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, temp_byte);
2230 if (rc)
2231 return rc;
2232
2233 /* set subordinate bus */
2234 temp_byte = (u8)(bus_node->base + bus_node->length - 1);
2235 dbg("set subordinate bus = 0x%x\n", temp_byte);
2236 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2237 if (rc)
2238 return rc;
2239
2240 /* Set HP parameters (Cache Line Size, Latency Timer) */
2241 rc = shpchprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2242 if (rc)
2243 return rc;
2244
2245 /* Setup the IO, memory, and prefetchable windows */
2246
2247 io_node = get_max_resource(&(resources->io_head), 0x1000L);
2248 if (io_node) {
2249 dbg("io_node(base, len, next) (%x, %x, %p)\n", io_node->base, io_node->length, io_node->next);
2250 }
2251
2252 mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2253 if (mem_node) {
2254 dbg("mem_node(base, len, next) (%x, %x, %p)\n", mem_node->base, mem_node->length, mem_node->next);
2255 }
2256
2257 if (resources->p_mem_head)
2258 p_mem_node = get_max_resource(&(resources->p_mem_head), 0x100000L);
2259 else {
2260 /*
2261 * In some platform implementation, MEM and PMEM are not
2262 * distinguished, and hence ACPI _CRS has only MEM entries
2263 * for both MEM and PMEM.
2264 */
2265 dbg("using MEM for PMEM\n");
2266 p_mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2267 }
2268 if (p_mem_node) {
2269 dbg("p_mem_node(base, len, next) (%x, %x, %p)\n", p_mem_node->base, p_mem_node->length, p_mem_node->next);
2270 }
2271
2272 /* set up the IRQ info */
2273 if (!resources->irqs) {
2274 irqs.barber_pole = 0;
2275 irqs.interrupt[0] = 0;
2276 irqs.interrupt[1] = 0;
2277 irqs.interrupt[2] = 0;
2278 irqs.interrupt[3] = 0;
2279 irqs.valid_INT = 0;
2280 } else {
2281 irqs.barber_pole = resources->irqs->barber_pole;
2282 irqs.interrupt[0] = resources->irqs->interrupt[0];
2283 irqs.interrupt[1] = resources->irqs->interrupt[1];
2284 irqs.interrupt[2] = resources->irqs->interrupt[2];
2285 irqs.interrupt[3] = resources->irqs->interrupt[3];
2286 irqs.valid_INT = resources->irqs->valid_INT;
2287 }
2288
2289 /* set up resource lists that are now aligned on top and bottom
2290 * for anything behind the bridge.
2291 */
2292 temp_resources.bus_head = bus_node;
2293 temp_resources.io_head = io_node;
2294 temp_resources.mem_head = mem_node;
2295 temp_resources.p_mem_head = p_mem_node;
2296 temp_resources.irqs = &irqs;
2297
2298 /* Make copies of the nodes we are going to pass down so that
2299 * if there is a problem,we can just use these to free resources
2300 */
2301 hold_bus_node = kmalloc(sizeof(*hold_bus_node), GFP_KERNEL);
2302 hold_IO_node = kmalloc(sizeof(*hold_IO_node), GFP_KERNEL);
2303 hold_mem_node = kmalloc(sizeof(*hold_mem_node), GFP_KERNEL);
2304 hold_p_mem_node = kmalloc(sizeof(*hold_p_mem_node), GFP_KERNEL);
2305
2306 if (!hold_bus_node || !hold_IO_node || !hold_mem_node || !hold_p_mem_node) {
2307 kfree(hold_bus_node);
2308 kfree(hold_IO_node);
2309 kfree(hold_mem_node);
2310 kfree(hold_p_mem_node);
2311
2312 return 1;
2313 }
2314
2315 memcpy(hold_bus_node, bus_node, sizeof(struct pci_resource));
2316
2317 bus_node->base += 1;
2318 bus_node->length -= 1;
2319 bus_node->next = NULL;
2320
2321 /* If we have IO resources copy them and fill in the bridge's
2322 * IO range registers
2323 */
2324 if (io_node) {
2325 memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
2326 io_node->next = NULL;
2327
2328 /* set IO base and Limit registers */
2329 RES_CHECK(io_node->base, 8);
2330 temp_byte = (u8)(io_node->base >> 8);
2331 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_BASE, temp_byte);
2332
2333 RES_CHECK(io_node->base + io_node->length - 1, 8);
2334 temp_byte = (u8)((io_node->base + io_node->length - 1) >> 8);
2335 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2336 } else {
2337 kfree(hold_IO_node);
2338 hold_IO_node = NULL;
2339 }
2340
2341 /* If we have memory resources copy them and fill in the bridge's
2342 * memory range registers. Otherwise, fill in the range
2343 * registers with values that disable them.
2344 */
2345 if (mem_node) {
2346 memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
2347 mem_node->next = NULL;
2348
2349 /* set Mem base and Limit registers */
2350 RES_CHECK(mem_node->base, 16);
2351 temp_word = (u32)(mem_node->base >> 16);
2352 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2353
2354 RES_CHECK(mem_node->base + mem_node->length - 1, 16);
2355 temp_word = (u32)((mem_node->base + mem_node->length - 1) >> 16);
2356 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2357 } else {
2358 temp_word = 0xFFFF;
2359 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2360
2361 temp_word = 0x0000;
2362 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2363
2364 kfree(hold_mem_node);
2365 hold_mem_node = NULL;
2366 }
2367
2368 /* If we have prefetchable memory resources copy them and
2369 * fill in the bridge's memory range registers. Otherwise,
2370 * fill in the range registers with values that disable them.
2371 */
2372 if (p_mem_node) {
2373 memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
2374 p_mem_node->next = NULL;
2375
2376 /* set Pre Mem base and Limit registers */
2377 RES_CHECK(p_mem_node->base, 16);
2378 temp_word = (u32)(p_mem_node->base >> 16);
2379 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2380
2381 RES_CHECK(p_mem_node->base + p_mem_node->length - 1, 16);
2382 temp_word = (u32)((p_mem_node->base + p_mem_node->length - 1) >> 16);
2383 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2384 } else {
2385 temp_word = 0xFFFF;
2386 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2387
2388 temp_word = 0x0000;
2389 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2390
2391 kfree(hold_p_mem_node);
2392 hold_p_mem_node = NULL;
2393 }
2394
2395 /* Adjust this to compensate for extra adjustment in first loop */
2396 irqs.barber_pole--;
2397
2398 rc = 0;
2399
2400 /* Here we actually find the devices and configure them */
2401 for (device = 0; (device <= 0x1F) && !rc; device++) {
2402 irqs.barber_pole = (irqs.barber_pole + 1) & 0x03;
2403
2404 ID = 0xFFFFFFFF;
2405 pci_bus->number = hold_bus_node->base;
2406 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0),
2407 PCI_VENDOR_ID, &ID);
2408 pci_bus->number = func->bus;
2409
2410 if (ID != 0xFFFFFFFF) { /* device Present */
2411 /* Setup slot structure. */
2412 new_slot = shpchp_slot_create(hold_bus_node->base);
2413
2414 if (new_slot == NULL) {
2415 /* Out of memory */
2416 rc = -ENOMEM;
2417 continue;
2418 }
2419
2420 new_slot->bus = hold_bus_node->base;
2421 new_slot->device = device;
2422 new_slot->function = 0;
2423 new_slot->is_a_board = 1;
2424 new_slot->status = 0;
2425
2426 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources, func->bus, func->device);
2427 dbg("configure_new_device rc=0x%x\n",rc);
2428 } /* End of IF (device in slot?) */
2429 } /* End of FOR loop */
2430
2431 if (rc) {
2432 shpchp_destroy_resource_list(&temp_resources);
2433
2434 return_resource(&(resources->bus_head), hold_bus_node);
2435 return_resource(&(resources->io_head), hold_IO_node);
2436 return_resource(&(resources->mem_head), hold_mem_node);
2437 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2438 return(rc);
2439 }
2440
2441 /* save the interrupt routing information */
2442 if (resources->irqs) {
2443 resources->irqs->interrupt[0] = irqs.interrupt[0];
2444 resources->irqs->interrupt[1] = irqs.interrupt[1];
2445 resources->irqs->interrupt[2] = irqs.interrupt[2];
2446 resources->irqs->interrupt[3] = irqs.interrupt[3];
2447 resources->irqs->valid_INT = irqs.valid_INT;
2448 } else if (!behind_bridge) {
2449 /* We need to hook up the interrupts here */
2450 for (cloop = 0; cloop < 4; cloop++) {
2451 if (irqs.valid_INT & (0x01 << cloop)) {
2452 rc = shpchp_set_irq(func->bus, func->device,
2453 0x0A + cloop, irqs.interrupt[cloop]);
2454 if (rc) {
2455 shpchp_destroy_resource_list (&temp_resources);
2456 return_resource(&(resources->bus_head), hold_bus_node);
2457 return_resource(&(resources->io_head), hold_IO_node);
2458 return_resource(&(resources->mem_head), hold_mem_node);
2459 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2460 return rc;
2461 }
2462 }
2463 } /* end of for loop */
2464 }
2465
2466 /* Return unused bus resources
2467 * First use the temporary node to store information for the board
2468 */
2469 if (hold_bus_node && bus_node && temp_resources.bus_head) {
2470 hold_bus_node->length = bus_node->base - hold_bus_node->base;
2471
2472 hold_bus_node->next = func->bus_head;
2473 func->bus_head = hold_bus_node;
2474
2475 temp_byte = (u8)(temp_resources.bus_head->base - 1);
2476
2477 /* set subordinate bus */
2478 dbg("re-set subordinate bus = 0x%x\n", temp_byte);
2479 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2480
2481 if (temp_resources.bus_head->length == 0) {
2482 kfree(temp_resources.bus_head);
2483 temp_resources.bus_head = NULL;
2484 } else {
2485 dbg("return bus res of b:d(0x%x:%x) base:len(0x%x:%x)\n",
2486 func->bus, func->device, temp_resources.bus_head->base, temp_resources.bus_head->length);
2487 return_resource(&(resources->bus_head), temp_resources.bus_head);
2488 }
2489 }
2490
2491 /* If we have IO space available and there is some left,
2492 * return the unused portion
2493 */
2494 if (hold_IO_node && temp_resources.io_head) {
2495 io_node = do_pre_bridge_resource_split(&(temp_resources.io_head),
2496 &hold_IO_node, 0x1000);
2497
2498 /* Check if we were able to split something off */
2499 if (io_node) {
2500 hold_IO_node->base = io_node->base + io_node->length;
2501
2502 RES_CHECK(hold_IO_node->base, 8);
2503 temp_byte = (u8)((hold_IO_node->base) >> 8);
2504 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_BASE, temp_byte);
2505
2506 return_resource(&(resources->io_head), io_node);
2507 }
2508
2509 io_node = do_bridge_resource_split(&(temp_resources.io_head), 0x1000);
2510
2511 /* Check if we were able to split something off */
2512 if (io_node) {
2513 /* First use the temporary node to store information for the board */
2514 hold_IO_node->length = io_node->base - hold_IO_node->base;
2515
2516 /* If we used any, add it to the board's list */
2517 if (hold_IO_node->length) {
2518 hold_IO_node->next = func->io_head;
2519 func->io_head = hold_IO_node;
2520
2521 RES_CHECK(io_node->base - 1, 8);
2522 temp_byte = (u8)((io_node->base - 1) >> 8);
2523 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2524
2525 return_resource(&(resources->io_head), io_node);
2526 } else {
2527 /* it doesn't need any IO */
2528 temp_byte = 0x00;
2529 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2530
2531 return_resource(&(resources->io_head), io_node);
2532 kfree(hold_IO_node);
2533 }
2534 } else {
2535 /* it used most of the range */
2536 hold_IO_node->next = func->io_head;
2537 func->io_head = hold_IO_node;
2538 }
2539 } else if (hold_IO_node) {
2540 /* it used the whole range */
2541 hold_IO_node->next = func->io_head;
2542 func->io_head = hold_IO_node;
2543 }
2544
2545 /* If we have memory space available and there is some left,
2546 * return the unused portion
2547 */
2548 if (hold_mem_node && temp_resources.mem_head) {
2549 mem_node = do_pre_bridge_resource_split(&(temp_resources.mem_head), &hold_mem_node, 0x100000L);
2550
2551 /* Check if we were able to split something off */
2552 if (mem_node) {
2553 hold_mem_node->base = mem_node->base + mem_node->length;
2554
2555 RES_CHECK(hold_mem_node->base, 16);
2556 temp_word = (u32)((hold_mem_node->base) >> 16);
2557 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2558
2559 return_resource(&(resources->mem_head), mem_node);
2560 }
2561
2562 mem_node = do_bridge_resource_split(&(temp_resources.mem_head), 0x100000L);
2563
2564 /* Check if we were able to split something off */
2565 if (mem_node) {
2566 /* First use the temporary node to store information for the board */
2567 hold_mem_node->length = mem_node->base - hold_mem_node->base;
2568
2569 if (hold_mem_node->length) {
2570 hold_mem_node->next = func->mem_head;
2571 func->mem_head = hold_mem_node;
2572
2573 /* configure end address */
2574 RES_CHECK(mem_node->base - 1, 16);
2575 temp_word = (u32)((mem_node->base - 1) >> 16);
2576 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2577
2578 /* Return unused resources to the pool */
2579 return_resource(&(resources->mem_head), mem_node);
2580 } else {
2581 /* it doesn't need any Mem */
2582 temp_word = 0x0000;
2583 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2584
2585 return_resource(&(resources->mem_head), mem_node);
2586 kfree(hold_mem_node);
2587 }
2588 } else {
2589 /* it used most of the range */
2590 hold_mem_node->next = func->mem_head;
2591 func->mem_head = hold_mem_node;
2592 }
2593 } else if (hold_mem_node) {
2594 /* it used the whole range */
2595 hold_mem_node->next = func->mem_head;
2596 func->mem_head = hold_mem_node;
2597 }
2598
2599 /* If we have prefetchable memory space available and there is some
2600 * left at the end, return the unused portion
2601 */
2602 if (hold_p_mem_node && temp_resources.p_mem_head) {
2603 p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
2604 &hold_p_mem_node, 0x100000L);
2605
2606 /* Check if we were able to split something off */
2607 if (p_mem_node) {
2608 hold_p_mem_node->base = p_mem_node->base + p_mem_node->length;
2609
2610 RES_CHECK(hold_p_mem_node->base, 16);
2611 temp_word = (u32)((hold_p_mem_node->base) >> 16);
2612 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2613
2614 return_resource(&(resources->p_mem_head), p_mem_node);
2615 }
2616
2617 p_mem_node = do_bridge_resource_split(&(temp_resources.p_mem_head), 0x100000L);
2618
2619 /* Check if we were able to split something off */
2620 if (p_mem_node) {
2621 /* First use the temporary node to store information for the board */
2622 hold_p_mem_node->length = p_mem_node->base - hold_p_mem_node->base;
2623
2624 /* If we used any, add it to the board's list */
2625 if (hold_p_mem_node->length) {
2626 hold_p_mem_node->next = func->p_mem_head;
2627 func->p_mem_head = hold_p_mem_node;
2628
2629 RES_CHECK(p_mem_node->base - 1, 16);
2630 temp_word = (u32)((p_mem_node->base - 1) >> 16);
2631 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2632
2633 return_resource(&(resources->p_mem_head), p_mem_node);
2634 } else {
2635 /* it doesn't need any PMem */
2636 temp_word = 0x0000;
2637 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2638
2639 return_resource(&(resources->p_mem_head), p_mem_node);
2640 kfree(hold_p_mem_node);
2641 }
2642 } else {
2643 /* it used the most of the range */
2644 hold_p_mem_node->next = func->p_mem_head;
2645 func->p_mem_head = hold_p_mem_node;
2646 }
2647 } else if (hold_p_mem_node) {
2648 /* it used the whole range */
2649 hold_p_mem_node->next = func->p_mem_head;
2650 func->p_mem_head = hold_p_mem_node;
2651 }
2652
2653 /* We should be configuring an IRQ and the bridge's base address
2654 * registers if it needs them. Although we have never seen such
2655 * a device
2656 */
2657
2658 shpchprm_enable_card(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2659
2660 dbg("PCI Bridge Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus, func->device, func->function);
2661 } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
2662 /* Standard device */
2663 u64 base64;
2664 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2665
2666 if (class_code == PCI_BASE_CLASS_DISPLAY)
2667 return (DEVICE_TYPE_NOT_SUPPORTED);
2668
2669 /* Figure out IO and memory needs */
2670 for (cloop = PCI_BASE_ADDRESS_0; cloop <= PCI_BASE_ADDRESS_5; cloop += 4) {
2671 temp_register = 0xFFFFFFFF;
2672
2673 rc = pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
2674 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
2675 dbg("Bar[%x]=0x%x on bus:dev:func(0x%x:%x:%x)\n", cloop, temp_register, func->bus, func->device,
2676 func->function);
2677
2678 if (!temp_register)
2679 continue;
2680
2681 base64 = 0L;
2682 if (temp_register & PCI_BASE_ADDRESS_SPACE_IO) {
2683 /* Map IO */
2684
2685 /* set base = amount of IO space */
2686 base = temp_register & 0xFFFFFFFC;
2687 base = ~base + 1;
2688
2689 dbg("NEED IO length(0x%x)\n", base);
2690 io_node = get_io_resource(&(resources->io_head),(ulong)base);
2691
2692 /* allocate the resource to the board */
2693 if (io_node) {
2694 dbg("Got IO base=0x%x(length=0x%x)\n", io_node->base, io_node->length);
2695 base = (u32)io_node->base;
2696 io_node->next = func->io_head;
2697 func->io_head = io_node;
2698 } else {
2699 err("Got NO IO resource(length=0x%x)\n", base);
2700 return -ENOMEM;
2701 }
2702 } else { /* map MEM */
2703 int prefetchable = 1;
2704 struct pci_resource **res_node = &func->p_mem_head;
2705 char *res_type_str = "PMEM";
2706 u32 temp_register2;
2707
2708 if (!(temp_register & PCI_BASE_ADDRESS_MEM_PREFETCH)) {
2709 prefetchable = 0;
2710 res_node = &func->mem_head;
2711 res_type_str++;
2712 }
2713
2714 base = temp_register & 0xFFFFFFF0;
2715 base = ~base + 1;
2716
2717 switch (temp_register & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
2718 case PCI_BASE_ADDRESS_MEM_TYPE_32:
2719 dbg("NEED 32 %s bar=0x%x(length=0x%x)\n", res_type_str, temp_register, base);
2720
2721 if (prefetchable && resources->p_mem_head)
2722 mem_node=get_resource(&(resources->p_mem_head), (ulong)base);
2723 else {
2724 if (prefetchable)
2725 dbg("using MEM for PMEM\n");
2726 mem_node=get_resource(&(resources->mem_head), (ulong)base);
2727 }
2728
2729 /* allocate the resource to the board */
2730 if (mem_node) {
2731 base = (u32)mem_node->base;
2732 mem_node->next = *res_node;
2733 *res_node = mem_node;
2734 dbg("Got 32 %s base=0x%x(length=0x%x)\n", res_type_str, mem_node->base,
2735 mem_node->length);
2736 } else {
2737 err("Got NO 32 %s resource(length=0x%x)\n", res_type_str, base);
2738 return -ENOMEM;
2739 }
2740 break;
2741 case PCI_BASE_ADDRESS_MEM_TYPE_64:
2742 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop+4, &temp_register2);
2743 dbg("NEED 64 %s bar=0x%x:%x(length=0x%x)\n", res_type_str, temp_register2,
2744 temp_register, base);
2745
2746 if (prefetchable && resources->p_mem_head)
2747 mem_node = get_resource(&(resources->p_mem_head), (ulong)base);
2748 else {
2749 if (prefetchable)
2750 dbg("using MEM for PMEM\n");
2751 mem_node = get_resource(&(resources->mem_head), (ulong)base);
2752 }
2753
2754 /* allocate the resource to the board */
2755 if (mem_node) {
2756 base64 = mem_node->base;
2757 mem_node->next = *res_node;
2758 *res_node = mem_node;
2759 dbg("Got 64 %s base=0x%x:%x(length=%x)\n", res_type_str, (u32)(base64 >> 32),
2760 (u32)base64, mem_node->length);
2761 } else {
2762 err("Got NO 64 %s resource(length=0x%x)\n", res_type_str, base);
2763 return -ENOMEM;
2764 }
2765 break;
2766 default:
2767 dbg("reserved BAR type=0x%x\n", temp_register);
2768 break;
2769 }
2770
2771 }
2772
2773 if (base64) {
2774 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2775 cloop += 4;
2776 base64 >>= 32;
2777
2778 if (base64) {
2779 dbg("%s: high dword of base64(0x%x) set to 0\n", __FUNCTION__, (u32)base64);
2780 base64 = 0x0L;
2781 }
2782
2783 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2784 } else {
2785 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base);
2786 }
2787 } /* End of base register loop */
2788
2789#if defined(CONFIG_X86_64)
2790 /* Figure out which interrupt pin this function uses */
2791 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_INTERRUPT_PIN, &temp_byte);
2792
2793 /* If this function needs an interrupt and we are behind a bridge
2794 and the pin is tied to something that's alread mapped,
2795 set this one the same
2796 */
2797 if (temp_byte && resources->irqs &&
2798 (resources->irqs->valid_INT &
2799 (0x01 << ((temp_byte + resources->irqs->barber_pole - 1) & 0x03)))) {
2800 /* We have to share with something already set up */
2801 IRQ = resources->irqs->interrupt[(temp_byte + resources->irqs->barber_pole - 1) & 0x03];
2802 } else {
2803 /* Program IRQ based on card type */
2804 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2805
2806 if (class_code == PCI_BASE_CLASS_STORAGE) {
2807 IRQ = shpchp_disk_irq;
2808 } else {
2809 IRQ = shpchp_nic_irq;
2810 }
2811 }
2812
2813 /* IRQ Line */
2814 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_INTERRUPT_LINE, IRQ);
2815
2816 if (!behind_bridge) {
2817 rc = shpchp_set_irq(func->bus, func->device, temp_byte + 0x09, IRQ);
2818 if (rc)
2819 return(1);
2820 } else {
2821 /* TBD - this code may also belong in the other clause of this If statement */
2822 resources->irqs->interrupt[(temp_byte + resources->irqs->barber_pole - 1) & 0x03] = IRQ;
2823 resources->irqs->valid_INT |= 0x01 << (temp_byte + resources->irqs->barber_pole - 1) & 0x03;
2824 }
2825#endif
2826 /* Disable ROM base Address */
2827 rc = pci_bus_write_config_dword (pci_bus, devfn, PCI_ROM_ADDRESS, 0x00);
2828
2829 /* Set HP parameters (Cache Line Size, Latency Timer) */
2830 rc = shpchprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2831 if (rc)
2832 return rc;
2833
2834 shpchprm_enable_card(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2835
2836 dbg("PCI function Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus, func->device, func->function);
2837 } /* End of Not-A-Bridge else */
2838 else {
2839 /* It's some strange type of PCI adapter (Cardbus?) */
2840 return(DEVICE_TYPE_NOT_SUPPORTED);
2841 }
2842
2843 func->configured = 1;
2844
2845 return 0;
2846} 980}
2847 981
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 8d98410bf1c0..40905a6c8094 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -27,17 +27,10 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/vmalloc.h>
36#include <linux/interrupt.h>
37#include <linux/spinlock.h>
38#include <linux/delay.h>
39#include <linux/pci.h> 33#include <linux/pci.h>
40#include <asm/system.h>
41#include "shpchp.h" 34#include "shpchp.h"
42 35
43#ifdef DEBUG 36#ifdef DEBUG
@@ -282,7 +275,7 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds)
282 275
283static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd) 276static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
284{ 277{
285 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 278 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
286 u16 cmd_status; 279 u16 cmd_status;
287 int retval = 0; 280 int retval = 0;
288 u16 temp_word; 281 u16 temp_word;
@@ -320,7 +313,6 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
320 * command. 313 * command.
321 */ 314 */
322 writew(temp_word, php_ctlr->creg + CMD); 315 writew(temp_word, php_ctlr->creg + CMD);
323 dbg("%s: temp_word written %x\n", __FUNCTION__, temp_word);
324 316
325 DBG_LEAVE_ROUTINE 317 DBG_LEAVE_ROUTINE
326 return retval; 318 return retval;
@@ -328,7 +320,7 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
328 320
329static int hpc_check_cmd_status(struct controller *ctrl) 321static int hpc_check_cmd_status(struct controller *ctrl)
330{ 322{
331 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) ctrl->hpc_ctlr_handle; 323 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
332 u16 cmd_status; 324 u16 cmd_status;
333 int retval = 0; 325 int retval = 0;
334 326
@@ -368,7 +360,7 @@ static int hpc_check_cmd_status(struct controller *ctrl)
368 360
369static int hpc_get_attention_status(struct slot *slot, u8 *status) 361static int hpc_get_attention_status(struct slot *slot, u8 *status)
370{ 362{
371 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 363 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
372 u32 slot_reg; 364 u32 slot_reg;
373 u16 slot_status; 365 u16 slot_status;
374 u8 atten_led_state; 366 u8 atten_led_state;
@@ -408,7 +400,7 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
408 400
409static int hpc_get_power_status(struct slot * slot, u8 *status) 401static int hpc_get_power_status(struct slot * slot, u8 *status)
410{ 402{
411 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 403 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
412 u32 slot_reg; 404 u32 slot_reg;
413 u16 slot_status; 405 u16 slot_status;
414 u8 slot_state; 406 u8 slot_state;
@@ -450,7 +442,7 @@ static int hpc_get_power_status(struct slot * slot, u8 *status)
450 442
451static int hpc_get_latch_status(struct slot *slot, u8 *status) 443static int hpc_get_latch_status(struct slot *slot, u8 *status)
452{ 444{
453 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 445 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
454 u32 slot_reg; 446 u32 slot_reg;
455 u16 slot_status; 447 u16 slot_status;
456 448
@@ -473,7 +465,7 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
473 465
474static int hpc_get_adapter_status(struct slot *slot, u8 *status) 466static int hpc_get_adapter_status(struct slot *slot, u8 *status)
475{ 467{
476 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 468 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
477 u32 slot_reg; 469 u32 slot_reg;
478 u16 slot_status; 470 u16 slot_status;
479 u8 card_state; 471 u8 card_state;
@@ -496,7 +488,7 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
496 488
497static int hpc_get_prog_int(struct slot *slot, u8 *prog_int) 489static int hpc_get_prog_int(struct slot *slot, u8 *prog_int)
498{ 490{
499 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 491 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
500 492
501 DBG_ENTER_ROUTINE 493 DBG_ENTER_ROUTINE
502 494
@@ -513,7 +505,7 @@ static int hpc_get_prog_int(struct slot *slot, u8 *prog_int)
513 505
514static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value) 506static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
515{ 507{
516 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 508 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
517 u32 slot_reg; 509 u32 slot_reg;
518 u16 slot_status, sec_bus_status; 510 u16 slot_status, sec_bus_status;
519 u8 m66_cap, pcix_cap, pi; 511 u8 m66_cap, pcix_cap, pi;
@@ -594,7 +586,7 @@ static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
594 586
595static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode) 587static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode)
596{ 588{
597 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 589 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
598 u16 sec_bus_status; 590 u16 sec_bus_status;
599 u8 pi; 591 u8 pi;
600 int retval = 0; 592 int retval = 0;
@@ -623,7 +615,7 @@ static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode)
623 615
624static int hpc_query_power_fault(struct slot * slot) 616static int hpc_query_power_fault(struct slot * slot)
625{ 617{
626 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 618 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
627 u32 slot_reg; 619 u32 slot_reg;
628 u16 slot_status; 620 u16 slot_status;
629 u8 pwr_fault_state, status; 621 u8 pwr_fault_state, status;
@@ -647,7 +639,7 @@ static int hpc_query_power_fault(struct slot * slot)
647 639
648static int hpc_set_attention_status(struct slot *slot, u8 value) 640static int hpc_set_attention_status(struct slot *slot, u8 value)
649{ 641{
650 struct php_ctlr_state_s *php_ctlr =(struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 642 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
651 u8 slot_cmd = 0; 643 u8 slot_cmd = 0;
652 int rc = 0; 644 int rc = 0;
653 645
@@ -683,7 +675,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
683 675
684static void hpc_set_green_led_on(struct slot *slot) 676static void hpc_set_green_led_on(struct slot *slot)
685{ 677{
686 struct php_ctlr_state_s *php_ctlr =(struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 678 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
687 u8 slot_cmd; 679 u8 slot_cmd;
688 680
689 if (!slot->ctrl->hpc_ctlr_handle) { 681 if (!slot->ctrl->hpc_ctlr_handle) {
@@ -705,7 +697,7 @@ static void hpc_set_green_led_on(struct slot *slot)
705 697
706static void hpc_set_green_led_off(struct slot *slot) 698static void hpc_set_green_led_off(struct slot *slot)
707{ 699{
708 struct php_ctlr_state_s *php_ctlr =(struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 700 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
709 u8 slot_cmd; 701 u8 slot_cmd;
710 702
711 if (!slot->ctrl->hpc_ctlr_handle) { 703 if (!slot->ctrl->hpc_ctlr_handle) {
@@ -727,7 +719,7 @@ static void hpc_set_green_led_off(struct slot *slot)
727 719
728static void hpc_set_green_led_blink(struct slot *slot) 720static void hpc_set_green_led_blink(struct slot *slot)
729{ 721{
730 struct php_ctlr_state_s *php_ctlr =(struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 722 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
731 u8 slot_cmd; 723 u8 slot_cmd;
732 724
733 if (!slot->ctrl->hpc_ctlr_handle) { 725 if (!slot->ctrl->hpc_ctlr_handle) {
@@ -754,7 +746,7 @@ int shpc_get_ctlr_slot_config(struct controller *ctrl,
754 int *updown, /* physical_slot_num increament: 1 or -1 */ 746 int *updown, /* physical_slot_num increament: 1 or -1 */
755 int *flags) 747 int *flags)
756{ 748{
757 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) ctrl->hpc_ctlr_handle; 749 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
758 750
759 DBG_ENTER_ROUTINE 751 DBG_ENTER_ROUTINE
760 752
@@ -776,7 +768,7 @@ int shpc_get_ctlr_slot_config(struct controller *ctrl,
776 768
777static void hpc_release_ctlr(struct controller *ctrl) 769static void hpc_release_ctlr(struct controller *ctrl)
778{ 770{
779 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) ctrl->hpc_ctlr_handle; 771 struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
780 struct php_ctlr_state_s *p, *p_prev; 772 struct php_ctlr_state_s *p, *p_prev;
781 773
782 DBG_ENTER_ROUTINE 774 DBG_ENTER_ROUTINE
@@ -796,10 +788,8 @@ static void hpc_release_ctlr(struct controller *ctrl)
796 } 788 }
797 } 789 }
798 if (php_ctlr->pci_dev) { 790 if (php_ctlr->pci_dev) {
799 dbg("%s: before calling iounmap & release_mem_region\n", __FUNCTION__);
800 iounmap(php_ctlr->creg); 791 iounmap(php_ctlr->creg);
801 release_mem_region(pci_resource_start(php_ctlr->pci_dev, 0), pci_resource_len(php_ctlr->pci_dev, 0)); 792 release_mem_region(pci_resource_start(php_ctlr->pci_dev, 0), pci_resource_len(php_ctlr->pci_dev, 0));
802 dbg("%s: before calling iounmap & release_mem_region\n", __FUNCTION__);
803 php_ctlr->pci_dev = NULL; 793 php_ctlr->pci_dev = NULL;
804 } 794 }
805 795
@@ -828,7 +818,7 @@ DBG_LEAVE_ROUTINE
828 818
829static int hpc_power_on_slot(struct slot * slot) 819static int hpc_power_on_slot(struct slot * slot)
830{ 820{
831 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 821 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
832 u8 slot_cmd; 822 u8 slot_cmd;
833 int retval = 0; 823 int retval = 0;
834 824
@@ -859,7 +849,7 @@ static int hpc_power_on_slot(struct slot * slot)
859 849
860static int hpc_slot_enable(struct slot * slot) 850static int hpc_slot_enable(struct slot * slot)
861{ 851{
862 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 852 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
863 u8 slot_cmd; 853 u8 slot_cmd;
864 int retval = 0; 854 int retval = 0;
865 855
@@ -890,7 +880,7 @@ static int hpc_slot_enable(struct slot * slot)
890 880
891static int hpc_slot_disable(struct slot * slot) 881static int hpc_slot_disable(struct slot * slot)
892{ 882{
893 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 883 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
894 u8 slot_cmd; 884 u8 slot_cmd;
895 int retval = 0; 885 int retval = 0;
896 886
@@ -920,51 +910,12 @@ static int hpc_slot_disable(struct slot * slot)
920 return retval; 910 return retval;
921} 911}
922 912
923static int hpc_enable_all_slots( struct slot *slot )
924{
925 int retval = 0;
926
927 DBG_ENTER_ROUTINE
928
929 if (!slot->ctrl->hpc_ctlr_handle) {
930 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
931 return -1;
932 }
933
934 retval = shpc_write_cmd(slot, 0, SET_ENABLE_ALL);
935 if (retval) {
936 err("%s: Write command failed!\n", __FUNCTION__);
937 return -1;
938 }
939
940 DBG_LEAVE_ROUTINE
941
942 return retval;
943}
944
945static int hpc_pwr_on_all_slots(struct slot *slot)
946{
947 int retval = 0;
948
949 DBG_ENTER_ROUTINE
950
951 retval = shpc_write_cmd(slot, 0, SET_PWR_ON_ALL);
952
953 if (retval) {
954 err("%s: Write command failed!\n", __FUNCTION__);
955 return -1;
956 }
957
958 DBG_LEAVE_ROUTINE
959 return retval;
960}
961
962static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value) 913static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value)
963{ 914{
964 u8 slot_cmd; 915 u8 slot_cmd;
965 u8 pi; 916 u8 pi;
966 int retval = 0; 917 int retval = 0;
967 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 918 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
968 919
969 DBG_ENTER_ROUTINE 920 DBG_ENTER_ROUTINE
970 921
@@ -1089,18 +1040,13 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1089 1040
1090 if (!intr_loc) 1041 if (!intr_loc)
1091 return IRQ_NONE; 1042 return IRQ_NONE;
1092 dbg("%s: shpc_isr proceeds\n", __FUNCTION__);
1093 dbg("%s: intr_loc = %x\n",__FUNCTION__, intr_loc); 1043 dbg("%s: intr_loc = %x\n",__FUNCTION__, intr_loc);
1094 1044
1095 if(!shpchp_poll_mode) { 1045 if(!shpchp_poll_mode) {
1096 /* Mask Global Interrupt Mask - see implementation note on p. 139 */ 1046 /* Mask Global Interrupt Mask - see implementation note on p. 139 */
1097 /* of SHPC spec rev 1.0*/ 1047 /* of SHPC spec rev 1.0*/
1098 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); 1048 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
1099 dbg("%s: Before masking global interrupt, temp_dword = %x\n",
1100 __FUNCTION__, temp_dword);
1101 temp_dword |= 0x00000001; 1049 temp_dword |= 0x00000001;
1102 dbg("%s: After masking global interrupt, temp_dword = %x\n",
1103 __FUNCTION__, temp_dword);
1104 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); 1050 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
1105 1051
1106 intr_loc2 = readl(php_ctlr->creg + INTR_LOC); 1052 intr_loc2 = readl(php_ctlr->creg + INTR_LOC);
@@ -1114,11 +1060,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1114 * Detect bit in Controller SERR-INT register 1060 * Detect bit in Controller SERR-INT register
1115 */ 1061 */
1116 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); 1062 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
1117 dbg("%s: Before clearing CCIP, temp_dword = %x\n",
1118 __FUNCTION__, temp_dword);
1119 temp_dword &= 0xfffeffff; 1063 temp_dword &= 0xfffeffff;
1120 dbg("%s: After clearing CCIP, temp_dword = %x\n",
1121 __FUNCTION__, temp_dword);
1122 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); 1064 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
1123 wake_up_interruptible(&ctrl->queue); 1065 wake_up_interruptible(&ctrl->queue);
1124 } 1066 }
@@ -1126,11 +1068,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1126 if ((intr_loc = (intr_loc >> 1)) == 0) { 1068 if ((intr_loc = (intr_loc >> 1)) == 0) {
1127 /* Unmask Global Interrupt Mask */ 1069 /* Unmask Global Interrupt Mask */
1128 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); 1070 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
1129 dbg("%s: 1-Before unmasking global interrupt, temp_dword = %x\n",
1130 __FUNCTION__, temp_dword);
1131 temp_dword &= 0xfffffffe; 1071 temp_dword &= 0xfffffffe;
1132 dbg("%s: 1-After unmasking global interrupt, temp_dword = %x\n",
1133 __FUNCTION__, temp_dword);
1134 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); 1072 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
1135 1073
1136 return IRQ_NONE; 1074 return IRQ_NONE;
@@ -1140,11 +1078,9 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1140 /* To find out which slot has interrupt pending */ 1078 /* To find out which slot has interrupt pending */
1141 if ((intr_loc >> hp_slot) & 0x01) { 1079 if ((intr_loc >> hp_slot) & 0x01) {
1142 temp_dword = readl(php_ctlr->creg + SLOT1 + (4*hp_slot)); 1080 temp_dword = readl(php_ctlr->creg + SLOT1 + (4*hp_slot));
1143 dbg("%s: Slot %x with intr, temp_dword = %x\n", 1081 dbg("%s: Slot %x with intr, slot register = %x\n",
1144 __FUNCTION__, hp_slot, temp_dword); 1082 __FUNCTION__, hp_slot, temp_dword);
1145 temp_byte = (temp_dword >> 16) & 0xFF; 1083 temp_byte = (temp_dword >> 16) & 0xFF;
1146 dbg("%s: Slot with intr, temp_byte = %x\n",
1147 __FUNCTION__, temp_byte);
1148 if ((php_ctlr->switch_change_callback) && (temp_byte & 0x08)) 1084 if ((php_ctlr->switch_change_callback) && (temp_byte & 0x08))
1149 schedule_flag += php_ctlr->switch_change_callback( 1085 schedule_flag += php_ctlr->switch_change_callback(
1150 hp_slot, php_ctlr->callback_instance_id); 1086 hp_slot, php_ctlr->callback_instance_id);
@@ -1160,8 +1096,6 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1160 1096
1161 /* Clear all slot events */ 1097 /* Clear all slot events */
1162 temp_dword = 0xe01f3fff; 1098 temp_dword = 0xe01f3fff;
1163 dbg("%s: Clearing slot events, temp_dword = %x\n",
1164 __FUNCTION__, temp_dword);
1165 writel(temp_dword, php_ctlr->creg + SLOT1 + (4*hp_slot)); 1099 writel(temp_dword, php_ctlr->creg + SLOT1 + (4*hp_slot));
1166 1100
1167 intr_loc2 = readl(php_ctlr->creg + INTR_LOC); 1101 intr_loc2 = readl(php_ctlr->creg + INTR_LOC);
@@ -1171,11 +1105,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1171 if (!shpchp_poll_mode) { 1105 if (!shpchp_poll_mode) {
1172 /* Unmask Global Interrupt Mask */ 1106 /* Unmask Global Interrupt Mask */
1173 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE); 1107 temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
1174 dbg("%s: 2-Before unmasking global interrupt, temp_dword = %x\n",
1175 __FUNCTION__, temp_dword);
1176 temp_dword &= 0xfffffffe; 1108 temp_dword &= 0xfffffffe;
1177 dbg("%s: 2-After unmasking global interrupt, temp_dword = %x\n",
1178 __FUNCTION__, temp_dword);
1179 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE); 1109 writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
1180 } 1110 }
1181 1111
@@ -1184,7 +1114,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1184 1114
1185static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value) 1115static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
1186{ 1116{
1187 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 1117 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1188 enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; 1118 enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
1189 int retval = 0; 1119 int retval = 0;
1190 u8 pi; 1120 u8 pi;
@@ -1253,7 +1183,7 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
1253 1183
1254static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value) 1184static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value)
1255{ 1185{
1256 struct php_ctlr_state_s *php_ctlr = (struct php_ctlr_state_s *) slot->ctrl->hpc_ctlr_handle; 1186 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
1257 enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN; 1187 enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
1258 u16 sec_bus_status; 1188 u16 sec_bus_status;
1259 int retval = 0; 1189 int retval = 0;
@@ -1367,8 +1297,6 @@ static struct hpc_ops shpchp_hpc_ops = {
1367 .power_on_slot = hpc_power_on_slot, 1297 .power_on_slot = hpc_power_on_slot,
1368 .slot_enable = hpc_slot_enable, 1298 .slot_enable = hpc_slot_enable,
1369 .slot_disable = hpc_slot_disable, 1299 .slot_disable = hpc_slot_disable,
1370 .enable_all_slots = hpc_enable_all_slots,
1371 .pwr_on_all_slots = hpc_pwr_on_all_slots,
1372 .set_bus_speed_mode = hpc_set_bus_speed_mode, 1300 .set_bus_speed_mode = hpc_set_bus_speed_mode,
1373 .set_attention_status = hpc_set_attention_status, 1301 .set_attention_status = hpc_set_attention_status,
1374 .get_power_status = hpc_get_power_status, 1302 .get_power_status = hpc_get_power_status,
@@ -1391,12 +1319,7 @@ static struct hpc_ops shpchp_hpc_ops = {
1391 .check_cmd_status = hpc_check_cmd_status, 1319 .check_cmd_status = hpc_check_cmd_status,
1392}; 1320};
1393 1321
1394int shpc_init(struct controller * ctrl, 1322int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1395 struct pci_dev * pdev,
1396 php_intr_callback_t attention_button_callback,
1397 php_intr_callback_t switch_change_callback,
1398 php_intr_callback_t presence_change_callback,
1399 php_intr_callback_t power_fault_callback)
1400{ 1323{
1401 struct php_ctlr_state_s *php_ctlr, *p; 1324 struct php_ctlr_state_s *php_ctlr, *p;
1402 void *instance_id = ctrl; 1325 void *instance_id = ctrl;
@@ -1405,7 +1328,6 @@ int shpc_init(struct controller * ctrl,
1405 static int first = 1; 1328 static int first = 1;
1406 u32 shpc_cap_offset, shpc_base_offset; 1329 u32 shpc_cap_offset, shpc_base_offset;
1407 u32 tempdword, slot_reg; 1330 u32 tempdword, slot_reg;
1408 u16 vendor_id, device_id;
1409 u8 i; 1331 u8 i;
1410 1332
1411 DBG_ENTER_ROUTINE 1333 DBG_ENTER_ROUTINE
@@ -1422,21 +1344,8 @@ int shpc_init(struct controller * ctrl,
1422 1344
1423 php_ctlr->pci_dev = pdev; /* save pci_dev in context */ 1345 php_ctlr->pci_dev = pdev; /* save pci_dev in context */
1424 1346
1425 rc = pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor_id); 1347 if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device ==
1426 dbg("%s: Vendor ID: %x\n",__FUNCTION__, vendor_id); 1348 PCI_DEVICE_ID_AMD_GOLAM_7450)) {
1427 if (rc) {
1428 err("%s: unable to read PCI configuration data\n", __FUNCTION__);
1429 goto abort_free_ctlr;
1430 }
1431
1432 rc = pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id);
1433 dbg("%s: Device ID: %x\n",__FUNCTION__, device_id);
1434 if (rc) {
1435 err("%s: unable to read PCI configuration data\n", __FUNCTION__);
1436 goto abort_free_ctlr;
1437 }
1438
1439 if ((vendor_id == PCI_VENDOR_ID_AMD) || (device_id == PCI_DEVICE_ID_AMD_GOLAM_7450)) {
1440 shpc_base_offset = 0; /* amd shpc driver doesn't use this; assume 0 */ 1349 shpc_base_offset = 0; /* amd shpc driver doesn't use this; assume 0 */
1441 } else { 1350 } else {
1442 if ((shpc_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC)) == 0) { 1351 if ((shpc_cap_offset = pci_find_capability(pdev, PCI_CAP_ID_SHPC)) == 0) {
@@ -1469,7 +1378,8 @@ int shpc_init(struct controller * ctrl,
1469 err("%s : pci_read_config_dword failed\n", __FUNCTION__); 1378 err("%s : pci_read_config_dword failed\n", __FUNCTION__);
1470 goto abort_free_ctlr; 1379 goto abort_free_ctlr;
1471 } 1380 }
1472 dbg("%s: offset %d: tempdword %x\n", __FUNCTION__,i, tempdword); 1381 dbg("%s: offset %d: value %x\n", __FUNCTION__,i,
1382 tempdword);
1473 } 1383 }
1474 } 1384 }
1475 1385
@@ -1478,13 +1388,6 @@ int shpc_init(struct controller * ctrl,
1478 first = 0; 1388 first = 0;
1479 } 1389 }
1480 1390
1481 dbg("pdev = %p: b:d:f:irq=0x%x:%x:%x:%x\n", pdev, pdev->bus->number, PCI_SLOT(pdev->devfn),
1482 PCI_FUNC(pdev->devfn), pdev->irq);
1483 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1484 if (pci_resource_len(pdev, rc) > 0)
1485 dbg("pci resource[%d] start=0x%lx(len=0x%lx), shpc_base_offset %x\n", rc,
1486 pci_resource_start(pdev, rc), pci_resource_len(pdev, rc), shpc_base_offset);
1487
1488 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 1391 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor,
1489 pdev->subsystem_device); 1392 pdev->subsystem_device);
1490 1393
@@ -1504,7 +1407,6 @@ int shpc_init(struct controller * ctrl,
1504 goto abort_free_ctlr; 1407 goto abort_free_ctlr;
1505 } 1408 }
1506 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1409 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
1507 dbg("%s: physical addr %p\n", __FUNCTION__, (void*)pci_resource_start(pdev, 0));
1508 1410
1509 init_MUTEX(&ctrl->crit_sect); 1411 init_MUTEX(&ctrl->crit_sect);
1510 /* Setup wait queue */ 1412 /* Setup wait queue */
@@ -1512,13 +1414,10 @@ int shpc_init(struct controller * ctrl,
1512 1414
1513 /* Find the IRQ */ 1415 /* Find the IRQ */
1514 php_ctlr->irq = pdev->irq; 1416 php_ctlr->irq = pdev->irq;
1515 dbg("HPC interrupt = %d\n", php_ctlr->irq); 1417 php_ctlr->attention_button_callback = shpchp_handle_attention_button,
1516 1418 php_ctlr->switch_change_callback = shpchp_handle_switch_change;
1517 /* Save interrupt callback info */ 1419 php_ctlr->presence_change_callback = shpchp_handle_presence_change;
1518 php_ctlr->attention_button_callback = attention_button_callback; 1420 php_ctlr->power_fault_callback = shpchp_handle_power_fault;
1519 php_ctlr->switch_change_callback = switch_change_callback;
1520 php_ctlr->presence_change_callback = presence_change_callback;
1521 php_ctlr->power_fault_callback = power_fault_callback;
1522 php_ctlr->callback_instance_id = instance_id; 1421 php_ctlr->callback_instance_id = instance_id;
1523 1422
1524 /* Return PCI Controller Info */ 1423 /* Return PCI Controller Info */
@@ -1556,7 +1455,6 @@ int shpc_init(struct controller * ctrl,
1556 if (rc) { 1455 if (rc) {
1557 info("Can't get msi for the hotplug controller\n"); 1456 info("Can't get msi for the hotplug controller\n");
1558 info("Use INTx for the hotplug controller\n"); 1457 info("Use INTx for the hotplug controller\n");
1559 dbg("%s: rc = %x\n", __FUNCTION__, rc);
1560 } else 1458 } else
1561 php_ctlr->irq = pdev->irq; 1459 php_ctlr->irq = pdev->irq;
1562 1460
@@ -1566,9 +1464,11 @@ int shpc_init(struct controller * ctrl,
1566 err("Can't get irq %d for the hotplug controller\n", php_ctlr->irq); 1464 err("Can't get irq %d for the hotplug controller\n", php_ctlr->irq);
1567 goto abort_free_ctlr; 1465 goto abort_free_ctlr;
1568 } 1466 }
1569 /* Execute OSHP method here */
1570 } 1467 }
1571 dbg("%s: Before adding HPC to HPC list\n", __FUNCTION__); 1468 dbg("%s: HPC at b:d:f:irq=0x%x:%x:%x:%x\n", __FUNCTION__,
1469 pdev->bus->number, PCI_SLOT(pdev->devfn),
1470 PCI_FUNC(pdev->devfn), pdev->irq);
1471 get_hp_hw_control_from_firmware(pdev);
1572 1472
1573 /* Add this HPC instance into the HPC list */ 1473 /* Add this HPC instance into the HPC list */
1574 spin_lock(&list_lock); 1474 spin_lock(&list_lock);
@@ -1607,7 +1507,6 @@ int shpc_init(struct controller * ctrl,
1607 dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__, tempdword); 1507 dbg("%s: SERR_INTR_ENABLE = %x\n", __FUNCTION__, tempdword);
1608 } 1508 }
1609 1509
1610 dbg("%s: Leaving shpc_init\n", __FUNCTION__);
1611 DBG_LEAVE_ROUTINE 1510 DBG_LEAVE_ROUTINE
1612 return 0; 1511 return 0;
1613 1512
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index d867099114ec..b8e95acea3b6 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -27,784 +27,151 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/workqueue.h>
36#include <linux/proc_fs.h>
37#include <linux/pci.h> 33#include <linux/pci.h>
38#include "../pci.h" 34#include "../pci.h"
39#include "shpchp.h" 35#include "shpchp.h"
40#ifndef CONFIG_IA64
41#include "../../../arch/i386/pci/pci.h" /* horrible hack showing how processor dependant we are... */
42#endif
43 36
44int shpchp_configure_device (struct controller* ctrl, struct pci_func* func) 37void program_fw_provided_values(struct pci_dev *dev)
45{ 38{
46 unsigned char bus; 39 u16 pci_cmd, pci_bctl;
47 struct pci_bus *child; 40 struct pci_dev *cdev;
48 int num; 41 struct hotplug_params hpp = {0x8, 0x40, 0, 0}; /* defaults */
49 42
50 if (func->pci_dev == NULL) 43 /* Program hpp values for this device */
51 func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function)); 44 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
52 45 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
53 /* Still NULL ? Well then scan for it ! */ 46 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
54 if (func->pci_dev == NULL) { 47 return;
55 num = pci_scan_slot(ctrl->pci_dev->subordinate, PCI_DEVFN(func->device, func->function)); 48
56 if (num) { 49 get_hp_params_from_firmware(dev, &hpp);
57 dbg("%s: subordiante %p number %x\n", __FUNCTION__, ctrl->pci_dev->subordinate, 50
58 ctrl->pci_dev->subordinate->number); 51 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size);
59 pci_bus_add_devices(ctrl->pci_dev->subordinate); 52 pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer);
60 } 53 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
61 54 if (hpp.enable_serr)
62 func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function)); 55 pci_cmd |= PCI_COMMAND_SERR;
63 if (func->pci_dev == NULL) { 56 else
64 dbg("ERROR: pci_dev still null\n"); 57 pci_cmd &= ~PCI_COMMAND_SERR;
65 return 0; 58 if (hpp.enable_perr)
59 pci_cmd |= PCI_COMMAND_PARITY;
60 else
61 pci_cmd &= ~PCI_COMMAND_PARITY;
62 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
63
64 /* Program bridge control value and child devices */
65 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
66 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
67 hpp.latency_timer);
68 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
69 if (hpp.enable_serr)
70 pci_bctl |= PCI_BRIDGE_CTL_SERR;
71 else
72 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
73 if (hpp.enable_perr)
74 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
75 else
76 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
77 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
78 if (dev->subordinate) {
79 list_for_each_entry(cdev, &dev->subordinate->devices,
80 bus_list)
81 program_fw_provided_values(cdev);
66 } 82 }
67 } 83 }
68
69 if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
70 pci_read_config_byte(func->pci_dev, PCI_SECONDARY_BUS, &bus);
71 child = pci_add_new_bus(func->pci_dev->bus, (func->pci_dev), bus);
72 pci_do_scan_bus(child);
73
74 }
75
76 return 0;
77} 84}
78 85
79 86int shpchp_configure_device(struct slot *p_slot)
80int shpchp_unconfigure_device(struct pci_func* func)
81{ 87{
82 int rc = 0; 88 struct pci_dev *dev;
83 int j; 89 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
84 90 int num, fn;
85 dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus, 91
86 func->device, func->function); 92 dev = pci_find_slot(p_slot->bus, PCI_DEVFN(p_slot->device, 0));
87 93 if (dev) {
88 for (j=0; j<8 ; j++) { 94 err("Device %s already exists at %x:%x, cannot hot-add\n",
89 struct pci_dev* temp = pci_find_slot(func->bus, 95 pci_name(dev), p_slot->bus, p_slot->device);
90 (func->device << 3) | j); 96 return -EINVAL;
91 if (temp) {
92 pci_remove_bus_device(temp);
93 }
94 } 97 }
95 return rc;
96}
97
98/*
99 * shpchp_set_irq
100 *
101 * @bus_num: bus number of PCI device
102 * @dev_num: device number of PCI device
103 * @slot: pointer to u8 where slot number will be returned
104 */
105int shpchp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
106{
107#if defined(CONFIG_X86) && !defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_64)
108 int rc;
109 u16 temp_word;
110 struct pci_dev fakedev;
111 struct pci_bus fakebus;
112 98
113 fakedev.devfn = dev_num << 3; 99 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
114 fakedev.bus = &fakebus; 100 if (num == 0) {
115 fakebus.number = bus_num; 101 err("No new device found\n");
116 dbg("%s: dev %d, bus %d, pin %d, num %d\n", 102 return -ENODEV;
117 __FUNCTION__, dev_num, bus_num, int_pin, irq_num);
118 rc = pcibios_set_irq_routing(&fakedev, int_pin - 0x0a, irq_num);
119 dbg("%s: rc %d\n", __FUNCTION__, rc);
120 if (!rc)
121 return !rc;
122
123 /* set the Edge Level Control Register (ELCR) */
124 temp_word = inb(0x4d0);
125 temp_word |= inb(0x4d1) << 8;
126
127 temp_word |= 0x01 << irq_num;
128
129 /* This should only be for x86 as it sets the Edge Level Control Register */
130 outb((u8) (temp_word & 0xFF), 0x4d0);
131 outb((u8) ((temp_word & 0xFF00) >> 8), 0x4d1);
132#endif
133 return 0;
134}
135
136/* More PCI configuration routines; this time centered around hotplug controller */
137
138
139/*
140 * shpchp_save_config
141 *
142 * Reads configuration for all slots in a PCI bus and saves info.
143 *
144 * Note: For non-hot plug busses, the slot # saved is the device #
145 *
146 * returns 0 if success
147 */
148int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num)
149{
150 int rc;
151 u8 class_code;
152 u8 header_type;
153 u32 ID;
154 u8 secondary_bus;
155 struct pci_func *new_slot;
156 int sub_bus;
157 int FirstSupported;
158 int LastSupported;
159 int max_functions;
160 int function;
161 u8 DevError;
162 int device = 0;
163 int cloop = 0;
164 int stop_it;
165 int index;
166 int is_hot_plug = num_ctlr_slots || first_device_num;
167 struct pci_bus lpci_bus, *pci_bus;
168
169 dbg("%s: num_ctlr_slots = %d, first_device_num = %d\n", __FUNCTION__,
170 num_ctlr_slots, first_device_num);
171
172 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
173 pci_bus = &lpci_bus;
174
175 dbg("%s: num_ctlr_slots = %d, first_device_num = %d\n", __FUNCTION__,
176 num_ctlr_slots, first_device_num);
177
178 /* Decide which slots are supported */
179 if (is_hot_plug) {
180 /*********************************
181 * is_hot_plug is the slot mask
182 *********************************/
183 FirstSupported = first_device_num;
184 LastSupported = FirstSupported + num_ctlr_slots - 1;
185 } else {
186 FirstSupported = 0;
187 LastSupported = 0x1F;
188 } 103 }
189 104
190 dbg("FirstSupported = %d, LastSupported = %d\n", FirstSupported, 105 for (fn = 0; fn < 8; fn++) {
191 LastSupported); 106 if (!(dev = pci_find_slot(p_slot->bus,
192 107 PCI_DEVFN(p_slot->device, fn))))
193 /* Save PCI configuration space for all devices in supported slots */ 108 continue;
194 pci_bus->number = busnumber; 109 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
195 for (device = FirstSupported; device <= LastSupported; device++) { 110 err("Cannot hot-add display device %s\n",
196 ID = 0xFFFFFFFF; 111 pci_name(dev));
197 rc = pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0), 112 continue;
198 PCI_VENDOR_ID, &ID);
199
200 if (ID != 0xFFFFFFFF) { /* device in slot */
201 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(device, 0),
202 0x0B, &class_code);
203 if (rc)
204 return rc;
205
206 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(device, 0),
207 PCI_HEADER_TYPE, &header_type);
208 if (rc)
209 return rc;
210
211 dbg("class_code = %x, header_type = %x\n", class_code, header_type);
212
213 /* If multi-function device, set max_functions to 8 */
214 if (header_type & 0x80)
215 max_functions = 8;
216 else
217 max_functions = 1;
218
219 function = 0;
220
221 do {
222 DevError = 0;
223
224 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* P-P Bridge */
225 /* Recurse the subordinate bus
226 * get the subordinate bus number
227 */
228 rc = pci_bus_read_config_byte(pci_bus,
229 PCI_DEVFN(device, function),
230 PCI_SECONDARY_BUS, &secondary_bus);
231 if (rc) {
232 return rc;
233 } else {
234 sub_bus = (int) secondary_bus;
235
236 /* Save secondary bus cfg spc with this recursive call. */
237 rc = shpchp_save_config(ctrl, sub_bus, 0, 0);
238 if (rc)
239 return rc;
240 }
241 }
242
243 index = 0;
244 new_slot = shpchp_slot_find(busnumber, device, index++);
245
246 dbg("new_slot = %p\n", new_slot);
247
248 while (new_slot && (new_slot->function != (u8) function)) {
249 new_slot = shpchp_slot_find(busnumber, device, index++);
250 dbg("new_slot = %p\n", new_slot);
251 }
252 if (!new_slot) {
253 /* Setup slot structure. */
254 new_slot = shpchp_slot_create(busnumber);
255 dbg("new_slot = %p\n", new_slot);
256
257 if (new_slot == NULL)
258 return(1);
259 }
260
261 new_slot->bus = (u8) busnumber;
262 new_slot->device = (u8) device;
263 new_slot->function = (u8) function;
264 new_slot->is_a_board = 1;
265 new_slot->switch_save = 0x10;
266 new_slot->pwr_save = 1;
267 /* In case of unsupported board */
268 new_slot->status = DevError;
269 new_slot->pci_dev = pci_find_slot(new_slot->bus,
270 (new_slot->device << 3) | new_slot->function);
271 dbg("new_slot->pci_dev = %p\n", new_slot->pci_dev);
272
273 for (cloop = 0; cloop < 0x20; cloop++) {
274 rc = pci_bus_read_config_dword(pci_bus,
275 PCI_DEVFN(device, function),
276 cloop << 2,
277 (u32 *) &(new_slot->config_space [cloop]));
278 /* dbg("new_slot->config_space[%x] = %x\n",
279 cloop, new_slot->config_space[cloop]); */
280 if (rc)
281 return rc;
282 }
283
284 function++;
285
286 stop_it = 0;
287
288 /* this loop skips to the next present function
289 * reading in Class Code and Header type.
290 */
291
292 while ((function < max_functions)&&(!stop_it)) {
293 rc = pci_bus_read_config_dword(pci_bus,
294 PCI_DEVFN(device, function),
295 PCI_VENDOR_ID, &ID);
296
297 if (ID == 0xFFFFFFFF) { /* nothing there. */
298 function++;
299 dbg("Nothing there\n");
300 } else { /* Something there */
301 rc = pci_bus_read_config_byte(pci_bus,
302 PCI_DEVFN(device, function),
303 0x0B, &class_code);
304 if (rc)
305 return rc;
306
307 rc = pci_bus_read_config_byte(pci_bus,
308 PCI_DEVFN(device, function),
309 PCI_HEADER_TYPE, &header_type);
310 if (rc)
311 return rc;
312
313 dbg("class_code = %x, header_type = %x\n",
314 class_code, header_type);
315 stop_it++;
316 }
317 }
318
319 } while (function < max_functions);
320 /* End of IF (device in slot?) */
321 } else if (is_hot_plug) {
322 /* Setup slot structure with entry for empty slot */
323 new_slot = shpchp_slot_create(busnumber);
324
325 if (new_slot == NULL) {
326 return(1);
327 }
328 dbg("new_slot = %p\n", new_slot);
329
330 new_slot->bus = (u8) busnumber;
331 new_slot->device = (u8) device;
332 new_slot->function = 0;
333 new_slot->is_a_board = 0;
334 new_slot->presence_save = 0;
335 new_slot->switch_save = 0;
336 } 113 }
337 } /* End of FOR loop */ 114 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
338 115 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) {
339 return(0); 116 /* Find an unused bus number for the new bridge */
340} 117 struct pci_bus *child;
341 118 unsigned char busnr, start = parent->secondary;
342 119 unsigned char end = parent->subordinate;
343/* 120 for (busnr = start; busnr <= end; busnr++) {
344 * shpchp_save_slot_config 121 if (!pci_find_bus(pci_domain_nr(parent),
345 * 122 busnr))
346 * Saves configuration info for all PCI devices in a given slot 123 break;
347 * including subordinate busses.
348 *
349 * returns 0 if success
350 */
351int shpchp_save_slot_config(struct controller *ctrl, struct pci_func * new_slot)
352{
353 int rc;
354 u8 class_code;
355 u8 header_type;
356 u32 ID;
357 u8 secondary_bus;
358 int sub_bus;
359 int max_functions;
360 int function;
361 int cloop = 0;
362 int stop_it;
363 struct pci_bus lpci_bus, *pci_bus;
364 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
365 pci_bus = &lpci_bus;
366 pci_bus->number = new_slot->bus;
367
368 ID = 0xFFFFFFFF;
369
370 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(new_slot->device, 0),
371 PCI_VENDOR_ID, &ID);
372
373 if (ID != 0xFFFFFFFF) { /* device in slot */
374 pci_bus_read_config_byte(pci_bus, PCI_DEVFN(new_slot->device, 0),
375 0x0B, &class_code);
376
377 pci_bus_read_config_byte(pci_bus, PCI_DEVFN(new_slot->device, 0),
378 PCI_HEADER_TYPE, &header_type);
379
380 if (header_type & 0x80) /* Multi-function device */
381 max_functions = 8;
382 else
383 max_functions = 1;
384
385 function = 0;
386
387 do {
388 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
389 /* Recurse the subordinate bus */
390 pci_bus_read_config_byte(pci_bus,
391 PCI_DEVFN(new_slot->device, function),
392 PCI_SECONDARY_BUS, &secondary_bus);
393
394 sub_bus = (int) secondary_bus;
395
396 /* Save the config headers for the secondary bus. */
397 rc = shpchp_save_config(ctrl, sub_bus, 0, 0);
398
399 if (rc)
400 return rc;
401
402 } /* End of IF */
403
404 new_slot->status = 0;
405
406 for (cloop = 0; cloop < 0x20; cloop++) {
407 pci_bus_read_config_dword(pci_bus,
408 PCI_DEVFN(new_slot->device, function),
409 cloop << 2,
410 (u32 *) &(new_slot->config_space [cloop]));
411 } 124 }
412 125 if (busnr >= end) {
413 function++; 126 err("No free bus for hot-added bridge\n");
414 127 continue;
415 stop_it = 0;
416
417 /* this loop skips to the next present function
418 * reading in the Class Code and the Header type.
419 */
420
421 while ((function < max_functions) && (!stop_it)) {
422 pci_bus_read_config_dword(pci_bus,
423 PCI_DEVFN(new_slot->device, function),
424 PCI_VENDOR_ID, &ID);
425
426 if (ID == 0xFFFFFFFF) { /* nothing there. */
427 function++;
428 } else { /* Something there */
429 pci_bus_read_config_byte(pci_bus,
430 PCI_DEVFN(new_slot->device, function),
431 0x0B, &class_code);
432
433 pci_bus_read_config_byte(pci_bus,
434 PCI_DEVFN(new_slot->device, function),
435 PCI_HEADER_TYPE, &header_type);
436
437 stop_it++;
438 }
439 } 128 }
440 129 child = pci_add_new_bus(parent, dev, busnr);
441 } while (function < max_functions); 130 if (!child) {
442 } /* End of IF (device in slot?) */ 131 err("Cannot add new bus for %s\n",
443 else { 132 pci_name(dev));
444 return 2; 133 continue;
134 }
135 child->subordinate = pci_do_scan_bus(child);
136 pci_bus_size_bridges(child);
137 }
138 program_fw_provided_values(dev);
445 } 139 }
446 140
141 pci_bus_assign_resources(parent);
142 pci_bus_add_devices(parent);
143 pci_enable_bridges(parent);
447 return 0; 144 return 0;
448} 145}
449 146
450 147int shpchp_unconfigure_device(struct slot *p_slot)
451/*
452 * shpchp_save_used_resources
453 *
454 * Stores used resource information for existing boards. this is
455 * for boards that were in the system when this driver was loaded.
456 * this function is for hot plug ADD
457 *
458 * returns 0 if success
459 * if disable == 1(DISABLE_CARD),
460 * it loops for all functions of the slot and disables them.
461 * else, it just get resources of the function and return.
462 */
463int shpchp_save_used_resources(struct controller *ctrl, struct pci_func *func, int disable)
464{ 148{
465 u8 cloop; 149 int rc = 0;
466 u8 header_type; 150 int j;
467 u8 secondary_bus; 151 u8 bctl = 0;
468 u8 temp_byte; 152
469 u16 command; 153 dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus, p_slot->device);
470 u16 save_command;
471 u16 w_base, w_length;
472 u32 temp_register;
473 u32 save_base;
474 u32 base, length;
475 u64 base64 = 0;
476 int index = 0;
477 unsigned int devfn;
478 struct pci_resource *mem_node = NULL;
479 struct pci_resource *p_mem_node = NULL;
480 struct pci_resource *t_mem_node;
481 struct pci_resource *io_node;
482 struct pci_resource *bus_node;
483 struct pci_bus lpci_bus, *pci_bus;
484 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
485 pci_bus = &lpci_bus;
486
487 if (disable)
488 func = shpchp_slot_find(func->bus, func->device, index++);
489
490 while ((func != NULL) && func->is_a_board) {
491 pci_bus->number = func->bus;
492 devfn = PCI_DEVFN(func->device, func->function);
493
494 /* Save the command register */
495 pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &save_command);
496 154
497 if (disable) { 155 for (j=0; j<8 ; j++) {
498 /* disable card */ 156 struct pci_dev* temp = pci_find_slot(p_slot->bus,
499 command = 0x00; 157 (p_slot->device << 3) | j);
500 pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command); 158 if (!temp)
159 continue;
160 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
161 err("Cannot remove display device %s\n",
162 pci_name(temp));
163 continue;
501 } 164 }
502 165 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
503 /* Check for Bridge */ 166 pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
504 pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 167 if (bctl & PCI_BRIDGE_CTL_VGA) {
505 168 err("Cannot remove display device %s\n",
506 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */ 169 pci_name(temp));
507 dbg("Save_used_res of PCI bridge b:d=0x%x:%x, sc=0x%x\n", 170 continue;
508 func->bus, func->device, save_command);
509 if (disable) {
510 /* Clear Bridge Control Register */
511 command = 0x00;
512 pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
513 } 171 }
514
515 pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
516 pci_bus_read_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, &temp_byte);
517
518 bus_node = kmalloc(sizeof(struct pci_resource),
519 GFP_KERNEL);
520 if (!bus_node)
521 return -ENOMEM;
522
523 bus_node->base = (ulong)secondary_bus;
524 bus_node->length = (ulong)(temp_byte - secondary_bus + 1);
525
526 bus_node->next = func->bus_head;
527 func->bus_head = bus_node;
528
529 /* Save IO base and Limit registers */
530 pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_BASE, &temp_byte);
531 base = temp_byte;
532 pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_LIMIT, &temp_byte);
533 length = temp_byte;
534
535 if ((base <= length) && (!disable || (save_command & PCI_COMMAND_IO))) {
536 io_node = kmalloc(sizeof(struct pci_resource),
537 GFP_KERNEL);
538 if (!io_node)
539 return -ENOMEM;
540
541 io_node->base = (ulong)(base & PCI_IO_RANGE_MASK) << 8;
542 io_node->length = (ulong)(length - base + 0x10) << 8;
543
544 io_node->next = func->io_head;
545 func->io_head = io_node;
546 }
547
548 /* Save memory base and Limit registers */
549 pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_BASE, &w_base);
550 pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length);
551
552 if ((w_base <= w_length) && (!disable || (save_command & PCI_COMMAND_MEMORY))) {
553 mem_node = kmalloc(sizeof(struct pci_resource),
554 GFP_KERNEL);
555 if (!mem_node)
556 return -ENOMEM;
557
558 mem_node->base = (ulong)w_base << 16;
559 mem_node->length = (ulong)(w_length - w_base + 0x10) << 16;
560
561 mem_node->next = func->mem_head;
562 func->mem_head = mem_node;
563 }
564 /* Save prefetchable memory base and Limit registers */
565 pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, &w_base);
566 pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length);
567
568 if ((w_base <= w_length) && (!disable || (save_command & PCI_COMMAND_MEMORY))) {
569 p_mem_node = kmalloc(sizeof(struct pci_resource),
570 GFP_KERNEL);
571 if (!p_mem_node)
572 return -ENOMEM;
573
574 p_mem_node->base = (ulong)w_base << 16;
575 p_mem_node->length = (ulong)(w_length - w_base + 0x10) << 16;
576
577 p_mem_node->next = func->p_mem_head;
578 func->p_mem_head = p_mem_node;
579 }
580 } else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
581 dbg("Save_used_res of PCI adapter b:d=0x%x:%x, sc=0x%x\n",
582 func->bus, func->device, save_command);
583
584 /* Figure out IO and memory base lengths */
585 for (cloop = PCI_BASE_ADDRESS_0; cloop <= PCI_BASE_ADDRESS_5; cloop += 4) {
586 pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
587
588 temp_register = 0xFFFFFFFF;
589 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
590 pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
591
592 if (!disable)
593 pci_bus_write_config_dword(pci_bus, devfn, cloop, save_base);
594
595 if (!temp_register)
596 continue;
597
598 base = temp_register;
599
600 if ((base & PCI_BASE_ADDRESS_SPACE_IO) &&
601 (!disable || (save_command & PCI_COMMAND_IO))) {
602 /* IO base */
603 /* set temp_register = amount of IO space requested */
604 base = base & 0xFFFFFFFCL;
605 base = (~base) + 1;
606
607 io_node = kmalloc(sizeof (struct pci_resource),
608 GFP_KERNEL);
609 if (!io_node)
610 return -ENOMEM;
611
612 io_node->base = (ulong)save_base & PCI_BASE_ADDRESS_IO_MASK;
613 io_node->length = (ulong)base;
614 dbg("sur adapter: IO bar=0x%x(length=0x%x)\n",
615 io_node->base, io_node->length);
616
617 io_node->next = func->io_head;
618 func->io_head = io_node;
619 } else { /* map Memory */
620 int prefetchable = 1;
621 /* struct pci_resources **res_node; */
622 char *res_type_str = "PMEM";
623 u32 temp_register2;
624
625 t_mem_node = kmalloc(sizeof (struct pci_resource),
626 GFP_KERNEL);
627 if (!t_mem_node)
628 return -ENOMEM;
629
630 if (!(base & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
631 (!disable || (save_command & PCI_COMMAND_MEMORY))) {
632 prefetchable = 0;
633 mem_node = t_mem_node;
634 res_type_str++;
635 } else
636 p_mem_node = t_mem_node;
637
638 base = base & 0xFFFFFFF0L;
639 base = (~base) + 1;
640
641 switch (temp_register & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
642 case PCI_BASE_ADDRESS_MEM_TYPE_32:
643 if (prefetchable) {
644 p_mem_node->base = (ulong)save_base & PCI_BASE_ADDRESS_MEM_MASK;
645 p_mem_node->length = (ulong)base;
646 dbg("sur adapter: 32 %s bar=0x%x(length=0x%x)\n",
647 res_type_str,
648 p_mem_node->base,
649 p_mem_node->length);
650
651 p_mem_node->next = func->p_mem_head;
652 func->p_mem_head = p_mem_node;
653 } else {
654 mem_node->base = (ulong)save_base & PCI_BASE_ADDRESS_MEM_MASK;
655 mem_node->length = (ulong)base;
656 dbg("sur adapter: 32 %s bar=0x%x(length=0x%x)\n",
657 res_type_str,
658 mem_node->base,
659 mem_node->length);
660
661 mem_node->next = func->mem_head;
662 func->mem_head = mem_node;
663 }
664 break;
665 case PCI_BASE_ADDRESS_MEM_TYPE_64:
666 pci_bus_read_config_dword(pci_bus, devfn, cloop+4, &temp_register2);
667 base64 = temp_register2;
668 base64 = (base64 << 32) | save_base;
669
670 if (temp_register2) {
671 dbg("sur adapter: 64 %s high dword of base64(0x%x:%x) masked to 0\n",
672 res_type_str, temp_register2, (u32)base64);
673 base64 &= 0x00000000FFFFFFFFL;
674 }
675
676 if (prefetchable) {
677 p_mem_node->base = base64 & PCI_BASE_ADDRESS_MEM_MASK;
678 p_mem_node->length = base;
679 dbg("sur adapter: 64 %s base=0x%x(len=0x%x)\n",
680 res_type_str,
681 p_mem_node->base,
682 p_mem_node->length);
683
684 p_mem_node->next = func->p_mem_head;
685 func->p_mem_head = p_mem_node;
686 } else {
687 mem_node->base = base64 & PCI_BASE_ADDRESS_MEM_MASK;
688 mem_node->length = base;
689 dbg("sur adapter: 64 %s base=0x%x(len=0x%x)\n",
690 res_type_str,
691 mem_node->base,
692 mem_node->length);
693
694 mem_node->next = func->mem_head;
695 func->mem_head = mem_node;
696 }
697 cloop += 4;
698 break;
699 default:
700 dbg("asur: reserved BAR type=0x%x\n",
701 temp_register);
702 break;
703 }
704 }
705 } /* End of base register loop */
706 } else { /* Some other unknown header type */
707 dbg("Save_used_res of PCI unknown type b:d=0x%x:%x. skip.\n",
708 func->bus, func->device);
709 } 172 }
710 173 pci_remove_bus_device(temp);
711 /* find the next device in this slot */
712 if (!disable)
713 break;
714 func = shpchp_slot_find(func->bus, func->device, index++);
715 } 174 }
716
717 return 0;
718}
719
720/**
721 * kfree_resource_list: release memory of all list members
722 * @res: resource list to free
723 */
724static inline void
725return_resource_list(struct pci_resource **func, struct pci_resource **res)
726{
727 struct pci_resource *node;
728 struct pci_resource *t_node;
729
730 node = *func;
731 *func = NULL;
732 while (node) {
733 t_node = node->next;
734 return_resource(res, node);
735 node = t_node;
736 }
737}
738
739/*
740 * shpchp_return_board_resources
741 *
742 * this routine returns all resources allocated to a board to
743 * the available pool.
744 *
745 * returns 0 if success
746 */
747int shpchp_return_board_resources(struct pci_func * func,
748 struct resource_lists * resources)
749{
750 int rc;
751 dbg("%s\n", __FUNCTION__);
752
753 if (!func)
754 return 1;
755
756 return_resource_list(&(func->io_head),&(resources->io_head));
757 return_resource_list(&(func->mem_head),&(resources->mem_head));
758 return_resource_list(&(func->p_mem_head),&(resources->p_mem_head));
759 return_resource_list(&(func->bus_head),&(resources->bus_head));
760
761 rc = shpchp_resource_sort_and_combine(&(resources->mem_head));
762 rc |= shpchp_resource_sort_and_combine(&(resources->p_mem_head));
763 rc |= shpchp_resource_sort_and_combine(&(resources->io_head));
764 rc |= shpchp_resource_sort_and_combine(&(resources->bus_head));
765
766 return rc; 175 return rc;
767} 176}
768 177
769/**
770 * kfree_resource_list: release memory of all list members
771 * @res: resource list to free
772 */
773static inline void
774kfree_resource_list(struct pci_resource **r)
775{
776 struct pci_resource *res, *tres;
777
778 res = *r;
779 *r = NULL;
780
781 while (res) {
782 tres = res;
783 res = res->next;
784 kfree(tres);
785 }
786}
787
788/**
789 * shpchp_destroy_resource_list: put node back in the resource list
790 * @resources: list to put nodes back
791 */
792void shpchp_destroy_resource_list(struct resource_lists *resources)
793{
794 kfree_resource_list(&(resources->io_head));
795 kfree_resource_list(&(resources->mem_head));
796 kfree_resource_list(&(resources->p_mem_head));
797 kfree_resource_list(&(resources->bus_head));
798}
799
800/**
801 * shpchp_destroy_board_resources: put node back in the resource list
802 * @resources: list to put nodes back
803 */
804void shpchp_destroy_board_resources(struct pci_func * func)
805{
806 kfree_resource_list(&(func->io_head));
807 kfree_resource_list(&(func->mem_head));
808 kfree_resource_list(&(func->p_mem_head));
809 kfree_resource_list(&(func->bus_head));
810}
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index c9445ebda5c7..f5cfbf2c047c 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -26,12 +26,9 @@
26 * 26 *
27 */ 27 */
28 28
29#include <linux/config.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/types.h> 31#include <linux/types.h>
33#include <linux/proc_fs.h>
34#include <linux/workqueue.h>
35#include <linux/pci.h> 32#include <linux/pci.h>
36#include "shpchp.h" 33#include "shpchp.h"
37 34
@@ -40,104 +37,60 @@
40 37
41static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf) 38static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
42{ 39{
43 struct pci_dev *pci_dev; 40 struct pci_dev *pdev;
44 struct controller *ctrl;
45 char * out = buf; 41 char * out = buf;
46 int index; 42 int index, busnr;
47 struct pci_resource *res; 43 struct resource *res;
44 struct pci_bus *bus;
48 45
49 pci_dev = container_of (dev, struct pci_dev, dev); 46 pdev = container_of (dev, struct pci_dev, dev);
50 ctrl = pci_get_drvdata(pci_dev); 47 bus = pdev->subordinate;
51 48
52 out += sprintf(buf, "Free resources: memory\n"); 49 out += sprintf(buf, "Free resources: memory\n");
53 index = 11; 50 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
54 res = ctrl->mem_head; 51 res = bus->resource[index];
55 while (res && index--) { 52 if (res && (res->flags & IORESOURCE_MEM) &&
56 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); 53 !(res->flags & IORESOURCE_PREFETCH)) {
57 res = res->next; 54 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
55 res->start, (res->end - res->start));
56 }
58 } 57 }
59 out += sprintf(out, "Free resources: prefetchable memory\n"); 58 out += sprintf(out, "Free resources: prefetchable memory\n");
60 index = 11; 59 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
61 res = ctrl->p_mem_head; 60 res = bus->resource[index];
62 while (res && index--) { 61 if (res && (res->flags & IORESOURCE_MEM) &&
63 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); 62 (res->flags & IORESOURCE_PREFETCH)) {
64 res = res->next; 63 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
64 res->start, (res->end - res->start));
65 }
65 } 66 }
66 out += sprintf(out, "Free resources: IO\n"); 67 out += sprintf(out, "Free resources: IO\n");
67 index = 11; 68 for (index = 0; index < PCI_BUS_NUM_RESOURCES; index++) {
68 res = ctrl->io_head; 69 res = bus->resource[index];
69 while (res && index--) { 70 if (res && (res->flags & IORESOURCE_IO)) {
70 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length); 71 out += sprintf(out, "start = %8.8lx, length = %8.8lx\n",
71 res = res->next; 72 res->start, (res->end - res->start));
73 }
72 } 74 }
73 out += sprintf(out, "Free resources: bus numbers\n"); 75 out += sprintf(out, "Free resources: bus numbers\n");
74 index = 11; 76 for (busnr = bus->secondary; busnr <= bus->subordinate; busnr++) {
75 res = ctrl->bus_head; 77 if (!pci_find_bus(pci_domain_nr(bus), busnr))
76 while (res && index--) { 78 break;
77 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
78 res = res->next;
79 } 79 }
80 if (busnr < bus->subordinate)
81 out += sprintf(out, "start = %8.8x, length = %8.8x\n",
82 busnr, (bus->subordinate - busnr));
80 83
81 return out - buf; 84 return out - buf;
82} 85}
83static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); 86static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
84 87
85static ssize_t show_dev (struct device *dev, struct device_attribute *attr, char *buf) 88void shpchp_create_ctrl_files (struct controller *ctrl)
86{ 89{
87 struct pci_dev *pci_dev; 90 device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl);
88 struct controller *ctrl;
89 char * out = buf;
90 int index;
91 struct pci_resource *res;
92 struct pci_func *new_slot;
93 struct slot *slot;
94
95 pci_dev = container_of (dev, struct pci_dev, dev);
96 ctrl = pci_get_drvdata(pci_dev);
97
98 slot=ctrl->slot;
99
100 while (slot) {
101 new_slot = shpchp_slot_find(slot->bus, slot->device, 0);
102 if (!new_slot)
103 break;
104 out += sprintf(out, "assigned resources: memory\n");
105 index = 11;
106 res = new_slot->mem_head;
107 while (res && index--) {
108 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
109 res = res->next;
110 }
111 out += sprintf(out, "assigned resources: prefetchable memory\n");
112 index = 11;
113 res = new_slot->p_mem_head;
114 while (res && index--) {
115 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
116 res = res->next;
117 }
118 out += sprintf(out, "assigned resources: IO\n");
119 index = 11;
120 res = new_slot->io_head;
121 while (res && index--) {
122 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
123 res = res->next;
124 }
125 out += sprintf(out, "assigned resources: bus numbers\n");
126 index = 11;
127 res = new_slot->bus_head;
128 while (res && index--) {
129 out += sprintf(out, "start = %8.8x, length = %8.8x\n", res->base, res->length);
130 res = res->next;
131 }
132 slot=slot->next;
133 }
134
135 return out - buf;
136} 91}
137static DEVICE_ATTR (dev, S_IRUGO, show_dev, NULL);
138 92
139void shpchp_create_ctrl_files (struct controller *ctrl) 93void shpchp_remove_ctrl_files(struct controller *ctrl)
140{ 94{
141 device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); 95 device_remove_file(&ctrl->pci_dev->dev, &dev_attr_ctrl);
142 device_create_file (&ctrl->pci_dev->dev, &dev_attr_dev);
143} 96}
diff --git a/drivers/pci/hotplug/shpchprm.h b/drivers/pci/hotplug/shpchprm.h
deleted file mode 100644
index 057b192ce589..000000000000
--- a/drivers/pci/hotplug/shpchprm.h
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * SHPCHPRM : SHPCHP Resource Manager for ACPI/non-ACPI platform
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
27 *
28 */
29
30#ifndef _SHPCHPRM_H_
31#define _SHPCHPRM_H_
32
33#ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY
34#include "shpchprm_legacy.h"
35#else
36#include "shpchprm_nonacpi.h"
37#endif
38
39int shpchprm_init(enum php_ctlr_type ct);
40void shpchprm_cleanup(void);
41int shpchprm_print_pirt(void);
42int shpchprm_find_available_resources(struct controller *ctrl);
43int shpchprm_set_hpp(struct controller *ctrl, struct pci_func *func, u8 card_type);
44void shpchprm_enable_card(struct controller *ctrl, struct pci_func *func, u8 card_type);
45int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum);
46
47#ifdef DEBUG
48#define RES_CHECK(this, bits) \
49 { if (((this) & (bits - 1))) \
50 printk("%s:%d ERR: potential res loss!\n", __FUNCTION__, __LINE__); }
51#else
52#define RES_CHECK(this, bits)
53#endif
54
55#endif /* _SHPCHPRM_H_ */
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c
index d37b31658edf..17145e52223a 100644
--- a/drivers/pci/hotplug/shpchprm_acpi.c
+++ b/drivers/pci/hotplug/shpchprm_acpi.c
@@ -24,91 +24,19 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/config.h>
28#include <linux/module.h> 27#include <linux/module.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/types.h> 29#include <linux/types.h>
31#include <linux/pci.h> 30#include <linux/pci.h>
32#include <linux/init.h>
33#include <linux/acpi.h>
34#include <linux/efi.h>
35#include <asm/uaccess.h>
36#include <asm/system.h>
37#ifdef CONFIG_IA64
38#include <asm/iosapic.h>
39#endif
40#include <acpi/acpi.h> 31#include <acpi/acpi.h>
41#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
42#include <acpi/actypes.h> 33#include <acpi/actypes.h>
43#include "shpchp.h" 34#include "shpchp.h"
44#include "shpchprm.h"
45
46#define PCI_MAX_BUS 0x100
47#define ACPI_STA_DEVICE_PRESENT 0x01
48 35
49#define METHOD_NAME__SUN "_SUN" 36#define METHOD_NAME__SUN "_SUN"
50#define METHOD_NAME__HPP "_HPP" 37#define METHOD_NAME__HPP "_HPP"
51#define METHOD_NAME_OSHP "OSHP" 38#define METHOD_NAME_OSHP "OSHP"
52 39
53#define PHP_RES_BUS 0xA0
54#define PHP_RES_IO 0xA1
55#define PHP_RES_MEM 0xA2
56#define PHP_RES_PMEM 0xA3
57
58#define BRIDGE_TYPE_P2P 0x00
59#define BRIDGE_TYPE_HOST 0x01
60
61/* this should go to drivers/acpi/include/ */
62struct acpi__hpp {
63 u8 cache_line_size;
64 u8 latency_timer;
65 u8 enable_serr;
66 u8 enable_perr;
67};
68
69struct acpi_php_slot {
70 struct acpi_php_slot *next;
71 struct acpi_bridge *bridge;
72 acpi_handle handle;
73 int seg;
74 int bus;
75 int dev;
76 int fun;
77 u32 sun;
78 struct pci_resource *mem_head;
79 struct pci_resource *p_mem_head;
80 struct pci_resource *io_head;
81 struct pci_resource *bus_head;
82 void *slot_ops; /* _STA, _EJx, etc */
83 struct slot *slot;
84}; /* per func */
85
86struct acpi_bridge {
87 struct acpi_bridge *parent;
88 struct acpi_bridge *next;
89 struct acpi_bridge *child;
90 acpi_handle handle;
91 int seg;
92 int pbus; /* pdev->bus->number */
93 int pdevice; /* PCI_SLOT(pdev->devfn) */
94 int pfunction; /* PCI_DEVFN(pdev->devfn) */
95 int bus; /* pdev->subordinate->number */
96 struct acpi__hpp *_hpp;
97 struct acpi_php_slot *slots;
98 struct pci_resource *tmem_head; /* total from crs */
99 struct pci_resource *tp_mem_head; /* total from crs */
100 struct pci_resource *tio_head; /* total from crs */
101 struct pci_resource *tbus_head; /* total from crs */
102 struct pci_resource *mem_head; /* available */
103 struct pci_resource *p_mem_head; /* available */
104 struct pci_resource *io_head; /* available */
105 struct pci_resource *bus_head; /* available */
106 int scanned;
107 int type;
108};
109
110static struct acpi_bridge *acpi_bridges_head;
111
112static u8 * acpi_path_name( acpi_handle handle) 40static u8 * acpi_path_name( acpi_handle handle)
113{ 41{
114 acpi_status status; 42 acpi_status status;
@@ -124,82 +52,43 @@ static u8 * acpi_path_name( acpi_handle handle)
124 return path_name; 52 return path_name;
125} 53}
126 54
127static void acpi_get__hpp ( struct acpi_bridge *ab); 55static acpi_status
128static void acpi_run_oshp ( struct acpi_bridge *ab); 56acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
129
130static int acpi_add_slot_to_php_slots(
131 struct acpi_bridge *ab,
132 int bus_num,
133 acpi_handle handle,
134 u32 adr,
135 u32 sun
136 )
137{
138 struct acpi_php_slot *aps;
139 static long samesun = -1;
140
141 aps = (struct acpi_php_slot *) kmalloc (sizeof(struct acpi_php_slot), GFP_KERNEL);
142 if (!aps) {
143 err ("acpi_shpchprm: alloc for aps fail\n");
144 return -1;
145 }
146 memset(aps, 0, sizeof(struct acpi_php_slot));
147
148 aps->handle = handle;
149 aps->bus = bus_num;
150 aps->dev = (adr >> 16) & 0xffff;
151 aps->fun = adr & 0xffff;
152 aps->sun = sun;
153
154 aps->next = ab->slots; /* cling to the bridge */
155 aps->bridge = ab;
156 ab->slots = aps;
157
158 ab->scanned += 1;
159 if (!ab->_hpp)
160 acpi_get__hpp(ab);
161
162 acpi_run_oshp(ab);
163
164 if (sun != samesun) {
165 info("acpi_shpchprm: Slot sun(%x) at s:b:d:f=0x%02x:%02x:%02x:%02x\n", aps->sun, ab->seg,
166 aps->bus, aps->dev, aps->fun);
167 samesun = sun;
168 }
169 return 0;
170}
171
172static void acpi_get__hpp ( struct acpi_bridge *ab)
173{ 57{
174 acpi_status status; 58 acpi_status status;
175 u8 nui[4]; 59 u8 nui[4];
176 struct acpi_buffer ret_buf = { 0, NULL}; 60 struct acpi_buffer ret_buf = { 0, NULL};
177 union acpi_object *ext_obj, *package; 61 union acpi_object *ext_obj, *package;
178 u8 *path_name = acpi_path_name(ab->handle); 62 u8 *path_name = acpi_path_name(handle);
179 int i, len = 0; 63 int i, len = 0;
180 64
181 /* get _hpp */ 65 /* get _hpp */
182 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf); 66 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf);
183 switch (status) { 67 switch (status) {
184 case AE_BUFFER_OVERFLOW: 68 case AE_BUFFER_OVERFLOW:
185 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); 69 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
186 if (!ret_buf.pointer) { 70 if (!ret_buf.pointer) {
187 err ("acpi_shpchprm:%s alloc for _HPP fail\n", path_name); 71 err ("%s:%s alloc for _HPP fail\n", __FUNCTION__,
188 return; 72 path_name);
73 return AE_NO_MEMORY;
189 } 74 }
190 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf); 75 status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
76 NULL, &ret_buf);
191 if (ACPI_SUCCESS(status)) 77 if (ACPI_SUCCESS(status))
192 break; 78 break;
193 default: 79 default:
194 if (ACPI_FAILURE(status)) { 80 if (ACPI_FAILURE(status)) {
195 err("acpi_shpchprm:%s _HPP fail=0x%x\n", path_name, status); 81 dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
196 return; 82 path_name, status);
83 return status;
197 } 84 }
198 } 85 }
199 86
200 ext_obj = (union acpi_object *) ret_buf.pointer; 87 ext_obj = (union acpi_object *) ret_buf.pointer;
201 if (ext_obj->type != ACPI_TYPE_PACKAGE) { 88 if (ext_obj->type != ACPI_TYPE_PACKAGE) {
202 err ("acpi_shpchprm:%s _HPP obj not a package\n", path_name); 89 err ("%s:%s _HPP obj not a package\n", __FUNCTION__,
90 path_name);
91 status = AE_ERROR;
203 goto free_and_return; 92 goto free_and_return;
204 } 93 }
205 94
@@ -212,1353 +101,41 @@ static void acpi_get__hpp ( struct acpi_bridge *ab)
212 nui[i] = (u8)ext_obj->integer.value; 101 nui[i] = (u8)ext_obj->integer.value;
213 break; 102 break;
214 default: 103 default:
215 err ("acpi_shpchprm:%s _HPP obj type incorrect\n", path_name); 104 err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__,
105 path_name);
106 status = AE_ERROR;
216 goto free_and_return; 107 goto free_and_return;
217 } 108 }
218 } 109 }
219 110
220 ab->_hpp = kmalloc (sizeof (struct acpi__hpp), GFP_KERNEL); 111 hpp->cache_line_size = nui[0];
221 if (!ab->_hpp) { 112 hpp->latency_timer = nui[1];
222 err ("acpi_shpchprm:%s alloc for _HPP failed\n", path_name); 113 hpp->enable_serr = nui[2];
223 goto free_and_return; 114 hpp->enable_perr = nui[3];
224 }
225 memset(ab->_hpp, 0, sizeof(struct acpi__hpp));
226 115
227 ab->_hpp->cache_line_size = nui[0]; 116 dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size);
228 ab->_hpp->latency_timer = nui[1]; 117 dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer);
229 ab->_hpp->enable_serr = nui[2]; 118 dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr);
230 ab->_hpp->enable_perr = nui[3]; 119 dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
231
232 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
233 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
234 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
235 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
236 120
237free_and_return: 121free_and_return:
238 kfree(ret_buf.pointer); 122 kfree(ret_buf.pointer);
239}
240
241static void acpi_run_oshp ( struct acpi_bridge *ab)
242{
243 acpi_status status;
244 u8 *path_name = acpi_path_name(ab->handle);
245
246 /* run OSHP */
247 status = acpi_evaluate_object(ab->handle, METHOD_NAME_OSHP, NULL, NULL);
248 if (ACPI_FAILURE(status)) {
249 err("acpi_pciehprm:%s OSHP fails=0x%x\n", path_name, status);
250 } else
251 dbg("acpi_pciehprm:%s OSHP passes =0x%x\n", path_name, status);
252 return;
253}
254
255static acpi_status acpi_evaluate_crs(
256 acpi_handle handle,
257 struct acpi_resource **retbuf
258 )
259{
260 acpi_status status;
261 struct acpi_buffer crsbuf;
262 u8 *path_name = acpi_path_name(handle);
263
264 crsbuf.length = 0;
265 crsbuf.pointer = NULL;
266
267 status = acpi_get_current_resources (handle, &crsbuf);
268
269 switch (status) {
270 case AE_BUFFER_OVERFLOW:
271 break; /* found */
272 case AE_NOT_FOUND:
273 dbg("acpi_shpchprm:%s _CRS not found\n", path_name);
274 return status;
275 default:
276 err ("acpi_shpchprm:%s _CRS fail=0x%x\n", path_name, status);
277 return status;
278 }
279
280 crsbuf.pointer = kmalloc (crsbuf.length, GFP_KERNEL);
281 if (!crsbuf.pointer) {
282 err ("acpi_shpchprm: alloc %ld bytes for %s _CRS fail\n", (ulong)crsbuf.length, path_name);
283 return AE_NO_MEMORY;
284 }
285
286 status = acpi_get_current_resources (handle, &crsbuf);
287 if (ACPI_FAILURE(status)) {
288 err("acpi_shpchprm: %s _CRS fail=0x%x.\n", path_name, status);
289 kfree(crsbuf.pointer);
290 return status;
291 }
292
293 *retbuf = crsbuf.pointer;
294
295 return status;
296}
297
298static void free_pci_resource ( struct pci_resource *aprh)
299{
300 struct pci_resource *res, *next;
301
302 for (res = aprh; res; res = next) {
303 next = res->next;
304 kfree(res);
305 }
306}
307
308static void print_pci_resource ( struct pci_resource *aprh)
309{
310 struct pci_resource *res;
311
312 for (res = aprh; res; res = res->next)
313 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length);
314}
315
316static void print_slot_resources( struct acpi_php_slot *aps)
317{
318 if (aps->bus_head) {
319 dbg(" BUS Resources:\n");
320 print_pci_resource (aps->bus_head);
321 }
322
323 if (aps->io_head) {
324 dbg(" IO Resources:\n");
325 print_pci_resource (aps->io_head);
326 }
327
328 if (aps->mem_head) {
329 dbg(" MEM Resources:\n");
330 print_pci_resource (aps->mem_head);
331 }
332
333 if (aps->p_mem_head) {
334 dbg(" PMEM Resources:\n");
335 print_pci_resource (aps->p_mem_head);
336 }
337}
338
339static void print_pci_resources( struct acpi_bridge *ab)
340{
341 if (ab->tbus_head) {
342 dbg(" Total BUS Resources:\n");
343 print_pci_resource (ab->tbus_head);
344 }
345 if (ab->bus_head) {
346 dbg(" BUS Resources:\n");
347 print_pci_resource (ab->bus_head);
348 }
349
350 if (ab->tio_head) {
351 dbg(" Total IO Resources:\n");
352 print_pci_resource (ab->tio_head);
353 }
354 if (ab->io_head) {
355 dbg(" IO Resources:\n");
356 print_pci_resource (ab->io_head);
357 }
358
359 if (ab->tmem_head) {
360 dbg(" Total MEM Resources:\n");
361 print_pci_resource (ab->tmem_head);
362 }
363 if (ab->mem_head) {
364 dbg(" MEM Resources:\n");
365 print_pci_resource (ab->mem_head);
366 }
367
368 if (ab->tp_mem_head) {
369 dbg(" Total PMEM Resources:\n");
370 print_pci_resource (ab->tp_mem_head);
371 }
372 if (ab->p_mem_head) {
373 dbg(" PMEM Resources:\n");
374 print_pci_resource (ab->p_mem_head);
375 }
376 if (ab->_hpp) {
377 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
378 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
379 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
380 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
381 }
382}
383
384static int shpchprm_delete_resource(
385 struct pci_resource **aprh,
386 ulong base,
387 ulong size)
388{
389 struct pci_resource *res;
390 struct pci_resource *prevnode;
391 struct pci_resource *split_node;
392 ulong tbase;
393
394 shpchp_resource_sort_and_combine(aprh);
395
396 for (res = *aprh; res; res = res->next) {
397 if (res->base > base)
398 continue;
399
400 if ((res->base + res->length) < (base + size))
401 continue;
402
403 if (res->base < base) {
404 tbase = base;
405
406 if ((res->length - (tbase - res->base)) < size)
407 continue;
408
409 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
410 if (!split_node)
411 return -ENOMEM;
412
413 split_node->base = res->base;
414 split_node->length = tbase - res->base;
415 res->base = tbase;
416 res->length -= split_node->length;
417
418 split_node->next = res->next;
419 res->next = split_node;
420 }
421
422 if (res->length >= size) {
423 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
424 if (!split_node)
425 return -ENOMEM;
426
427 split_node->base = res->base + size;
428 split_node->length = res->length - size;
429 res->length = size;
430
431 split_node->next = res->next;
432 res->next = split_node;
433 }
434
435 if (*aprh == res) {
436 *aprh = res->next;
437 } else {
438 prevnode = *aprh;
439 while (prevnode->next != res)
440 prevnode = prevnode->next;
441
442 prevnode->next = res->next;
443 }
444 res->next = NULL;
445 kfree(res);
446 break;
447 }
448
449 return 0;
450}
451
452static int shpchprm_delete_resources(
453 struct pci_resource **aprh,
454 struct pci_resource *this
455 )
456{
457 struct pci_resource *res;
458
459 for (res = this; res; res = res->next)
460 shpchprm_delete_resource(aprh, res->base, res->length);
461
462 return 0;
463}
464
465static int shpchprm_add_resource(
466 struct pci_resource **aprh,
467 ulong base,
468 ulong size)
469{
470 struct pci_resource *res;
471
472 for (res = *aprh; res; res = res->next) {
473 if ((res->base + res->length) == base) {
474 res->length += size;
475 size = 0L;
476 break;
477 }
478 if (res->next == *aprh)
479 break;
480 }
481
482 if (size) {
483 res = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
484 if (!res) {
485 err ("acpi_shpchprm: alloc for res fail\n");
486 return -ENOMEM;
487 }
488 memset(res, 0, sizeof (struct pci_resource));
489
490 res->base = base;
491 res->length = size;
492 res->next = *aprh;
493 *aprh = res;
494 }
495
496 return 0;
497}
498
499static int shpchprm_add_resources(
500 struct pci_resource **aprh,
501 struct pci_resource *this
502 )
503{
504 struct pci_resource *res;
505 int rc = 0;
506
507 for (res = this; res && !rc; res = res->next)
508 rc = shpchprm_add_resource(aprh, res->base, res->length);
509
510 return rc;
511}
512
513static void acpi_parse_io (
514 struct acpi_bridge *ab,
515 union acpi_resource_data *data
516 )
517{
518 struct acpi_resource_io *dataio;
519 dataio = (struct acpi_resource_io *) data;
520
521 dbg("Io Resource\n");
522 dbg(" %d bit decode\n", ACPI_DECODE_16 == dataio->io_decode ? 16:10);
523 dbg(" Range minimum base: %08X\n", dataio->min_base_address);
524 dbg(" Range maximum base: %08X\n", dataio->max_base_address);
525 dbg(" Alignment: %08X\n", dataio->alignment);
526 dbg(" Range Length: %08X\n", dataio->range_length);
527}
528
529static void acpi_parse_fixed_io (
530 struct acpi_bridge *ab,
531 union acpi_resource_data *data
532 )
533{
534 struct acpi_resource_fixed_io *datafio;
535 datafio = (struct acpi_resource_fixed_io *) data;
536
537 dbg("Fixed Io Resource\n");
538 dbg(" Range base address: %08X", datafio->base_address);
539 dbg(" Range length: %08X", datafio->range_length);
540}
541
542static void acpi_parse_address16_32 (
543 struct acpi_bridge *ab,
544 union acpi_resource_data *data,
545 acpi_resource_type id
546 )
547{
548 /*
549 * acpi_resource_address16 == acpi_resource_address32
550 * acpi_resource_address16 *data16 = (acpi_resource_address16 *) data;
551 */
552 struct acpi_resource_address32 *data32 = (struct acpi_resource_address32 *) data;
553 struct pci_resource **aprh, **tprh;
554
555 if (id == ACPI_RSTYPE_ADDRESS16)
556 dbg("acpi_shpchprm:16-Bit Address Space Resource\n");
557 else
558 dbg("acpi_shpchprm:32-Bit Address Space Resource\n");
559
560 switch (data32->resource_type) {
561 case ACPI_MEMORY_RANGE:
562 dbg(" Resource Type: Memory Range\n");
563 aprh = &ab->mem_head;
564 tprh = &ab->tmem_head;
565
566 switch (data32->attribute.memory.cache_attribute) {
567 case ACPI_NON_CACHEABLE_MEMORY:
568 dbg(" Type Specific: Noncacheable memory\n");
569 break;
570 case ACPI_CACHABLE_MEMORY:
571 dbg(" Type Specific: Cacheable memory\n");
572 break;
573 case ACPI_WRITE_COMBINING_MEMORY:
574 dbg(" Type Specific: Write-combining memory\n");
575 break;
576 case ACPI_PREFETCHABLE_MEMORY:
577 aprh = &ab->p_mem_head;
578 dbg(" Type Specific: Prefetchable memory\n");
579 break;
580 default:
581 dbg(" Type Specific: Invalid cache attribute\n");
582 break;
583 }
584
585 dbg(" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == data32->attribute.memory.read_write_attribute ? "/Write":" Only");
586 break;
587
588 case ACPI_IO_RANGE:
589 dbg(" Resource Type: I/O Range\n");
590 aprh = &ab->io_head;
591 tprh = &ab->tio_head;
592
593 switch (data32->attribute.io.range_attribute) {
594 case ACPI_NON_ISA_ONLY_RANGES:
595 dbg(" Type Specific: Non-ISA Io Addresses\n");
596 break;
597 case ACPI_ISA_ONLY_RANGES:
598 dbg(" Type Specific: ISA Io Addresses\n");
599 break;
600 case ACPI_ENTIRE_RANGE:
601 dbg(" Type Specific: ISA and non-ISA Io Addresses\n");
602 break;
603 default:
604 dbg(" Type Specific: Invalid range attribute\n");
605 break;
606 }
607 break;
608
609 case ACPI_BUS_NUMBER_RANGE:
610 dbg(" Resource Type: Bus Number Range(fixed)\n");
611 /* fixup to be compatible with the rest of php driver */
612 data32->min_address_range++;
613 data32->address_length--;
614 aprh = &ab->bus_head;
615 tprh = &ab->tbus_head;
616 break;
617 default:
618 dbg(" Resource Type: Invalid resource type. Exiting.\n");
619 return;
620 }
621
622 dbg(" Resource %s\n", ACPI_CONSUMER == data32->producer_consumer ? "Consumer":"Producer");
623 dbg(" %s decode\n", ACPI_SUB_DECODE == data32->decode ? "Subtractive":"Positive");
624 dbg(" Min address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->min_address_fixed ? "":"not");
625 dbg(" Max address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->max_address_fixed ? "":"not");
626 dbg(" Granularity: %08X\n", data32->granularity);
627 dbg(" Address range min: %08X\n", data32->min_address_range);
628 dbg(" Address range max: %08X\n", data32->max_address_range);
629 dbg(" Address translation offset: %08X\n", data32->address_translation_offset);
630 dbg(" Address Length: %08X\n", data32->address_length);
631
632 if (0xFF != data32->resource_source.index) {
633 dbg(" Resource Source Index: %X\n", data32->resource_source.index);
634 /* dbg(" Resource Source: %s\n", data32->resource_source.string_ptr); */
635 }
636
637 shpchprm_add_resource(aprh, data32->min_address_range, data32->address_length);
638}
639
640static acpi_status acpi_parse_crs(
641 struct acpi_bridge *ab,
642 struct acpi_resource *crsbuf
643 )
644{
645 acpi_status status = AE_OK;
646 struct acpi_resource *resource = crsbuf;
647 u8 count = 0;
648 u8 done = 0;
649
650 while (!done) {
651 dbg("acpi_shpchprm: PCI bus 0x%x Resource structure %x.\n", ab->bus, count++);
652 switch (resource->id) {
653 case ACPI_RSTYPE_IRQ:
654 dbg("Irq -------- Resource\n");
655 break;
656 case ACPI_RSTYPE_DMA:
657 dbg("DMA -------- Resource\n");
658 break;
659 case ACPI_RSTYPE_START_DPF:
660 dbg("Start DPF -------- Resource\n");
661 break;
662 case ACPI_RSTYPE_END_DPF:
663 dbg("End DPF -------- Resource\n");
664 break;
665 case ACPI_RSTYPE_IO:
666 acpi_parse_io (ab, &resource->data);
667 break;
668 case ACPI_RSTYPE_FIXED_IO:
669 acpi_parse_fixed_io (ab, &resource->data);
670 break;
671 case ACPI_RSTYPE_VENDOR:
672 dbg("Vendor -------- Resource\n");
673 break;
674 case ACPI_RSTYPE_END_TAG:
675 dbg("End_tag -------- Resource\n");
676 done = 1;
677 break;
678 case ACPI_RSTYPE_MEM24:
679 dbg("Mem24 -------- Resource\n");
680 break;
681 case ACPI_RSTYPE_MEM32:
682 dbg("Mem32 -------- Resource\n");
683 break;
684 case ACPI_RSTYPE_FIXED_MEM32:
685 dbg("Fixed Mem32 -------- Resource\n");
686 break;
687 case ACPI_RSTYPE_ADDRESS16:
688 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS16);
689 break;
690 case ACPI_RSTYPE_ADDRESS32:
691 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS32);
692 break;
693 case ACPI_RSTYPE_ADDRESS64:
694 info("Address64 -------- Resource unparsed\n");
695 break;
696 case ACPI_RSTYPE_EXT_IRQ:
697 dbg("Ext Irq -------- Resource\n");
698 break;
699 default:
700 dbg("Invalid -------- resource type 0x%x\n", resource->id);
701 break;
702 }
703
704 resource = (struct acpi_resource *) ((char *)resource + resource->length);
705 }
706
707 return status; 123 return status;
708} 124}
709 125
710static acpi_status acpi_get_crs( struct acpi_bridge *ab) 126static void acpi_run_oshp(acpi_handle handle)
711{ 127{
712 acpi_status status; 128 acpi_status status;
713 struct acpi_resource *crsbuf;
714
715 status = acpi_evaluate_crs(ab->handle, &crsbuf);
716 if (ACPI_SUCCESS(status)) {
717 status = acpi_parse_crs(ab, crsbuf);
718 kfree(crsbuf);
719
720 shpchp_resource_sort_and_combine(&ab->bus_head);
721 shpchp_resource_sort_and_combine(&ab->io_head);
722 shpchp_resource_sort_and_combine(&ab->mem_head);
723 shpchp_resource_sort_and_combine(&ab->p_mem_head);
724
725 shpchprm_add_resources (&ab->tbus_head, ab->bus_head);
726 shpchprm_add_resources (&ab->tio_head, ab->io_head);
727 shpchprm_add_resources (&ab->tmem_head, ab->mem_head);
728 shpchprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
729 }
730
731 return status;
732}
733
734/* find acpi_bridge downword from ab. */
735static struct acpi_bridge *
736find_acpi_bridge_by_bus(
737 struct acpi_bridge *ab,
738 int seg,
739 int bus /* pdev->subordinate->number */
740 )
741{
742 struct acpi_bridge *lab = NULL;
743
744 if (!ab)
745 return NULL;
746
747 if ((ab->bus == bus) && (ab->seg == seg))
748 return ab;
749
750 if (ab->child)
751 lab = find_acpi_bridge_by_bus(ab->child, seg, bus);
752
753 if (!lab)
754 if (ab->next)
755 lab = find_acpi_bridge_by_bus(ab->next, seg, bus);
756
757 return lab;
758}
759
760/*
761 * Build a device tree of ACPI PCI Bridges
762 */
763static void shpchprm_acpi_register_a_bridge (
764 struct acpi_bridge **head,
765 struct acpi_bridge *pab, /* parent bridge to which child bridge is added */
766 struct acpi_bridge *cab /* child bridge to add */
767 )
768{
769 struct acpi_bridge *lpab;
770 struct acpi_bridge *lcab;
771
772 lpab = find_acpi_bridge_by_bus(*head, pab->seg, pab->bus);
773 if (!lpab) {
774 if (!(pab->type & BRIDGE_TYPE_HOST))
775 warn("PCI parent bridge s:b(%x:%x) not in list.\n", pab->seg, pab->bus);
776 pab->next = *head;
777 *head = pab;
778 lpab = pab;
779 }
780
781 if ((cab->type & BRIDGE_TYPE_HOST) && (pab == cab))
782 return;
783
784 lcab = find_acpi_bridge_by_bus(*head, cab->seg, cab->bus);
785 if (lcab) {
786 if ((pab->bus != lcab->parent->bus) || (lcab->bus != cab->bus))
787 err("PCI child bridge s:b(%x:%x) in list with diff parent.\n", cab->seg, cab->bus);
788 return;
789 } else
790 lcab = cab;
791
792 lcab->parent = lpab;
793 lcab->next = lpab->child;
794 lpab->child = lcab;
795}
796
797static acpi_status shpchprm_acpi_build_php_slots_callback(
798 acpi_handle handle,
799 u32 Level,
800 void *context,
801 void **retval
802 )
803{
804 ulong bus_num;
805 ulong seg_num;
806 ulong sun, adr;
807 ulong padr = 0;
808 acpi_handle phandle = NULL;
809 struct acpi_bridge *pab = (struct acpi_bridge *)context;
810 struct acpi_bridge *lab;
811 acpi_status status;
812 u8 *path_name = acpi_path_name(handle); 129 u8 *path_name = acpi_path_name(handle);
813 130
814 /* get _SUN */ 131 /* run OSHP */
815 status = acpi_evaluate_integer(handle, METHOD_NAME__SUN, NULL, &sun); 132 status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL);
816 switch(status) {
817 case AE_NOT_FOUND:
818 return AE_OK;
819 default:
820 if (ACPI_FAILURE(status)) {
821 err("acpi_shpchprm:%s _SUN fail=0x%x\n", path_name, status);
822 return status;
823 }
824 }
825
826 /* get _ADR. _ADR must exist if _SUN exists */
827 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
828 if (ACPI_FAILURE(status)) {
829 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
830 return status;
831 }
832
833 dbg("acpi_shpchprm:%s sun=0x%08x adr=0x%08x\n", path_name, (u32)sun, (u32)adr);
834
835 status = acpi_get_parent(handle, &phandle);
836 if (ACPI_FAILURE(status)) { 133 if (ACPI_FAILURE(status)) {
837 err("acpi_shpchprm:%s get_parent fail=0x%x\n", path_name, status); 134 err("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name,
838 return (status); 135 status);
839 }
840
841 bus_num = pab->bus;
842 seg_num = pab->seg;
843
844 if (pab->bus == bus_num) {
845 lab = pab;
846 } else { 136 } else {
847 dbg("WARN: pab is not parent\n"); 137 dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name);
848 lab = find_acpi_bridge_by_bus(pab, seg_num, bus_num);
849 if (!lab) {
850 dbg("acpi_shpchprm: alloc new P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
851 lab = (struct acpi_bridge *)kmalloc(sizeof(struct acpi_bridge), GFP_KERNEL);
852 if (!lab) {
853 err("acpi_shpchprm: alloc for ab fail\n");
854 return AE_NO_MEMORY;
855 }
856 memset(lab, 0, sizeof(struct acpi_bridge));
857
858 lab->handle = phandle;
859 lab->pbus = pab->bus;
860 lab->pdevice = (int)(padr >> 16) & 0xffff;
861 lab->pfunction = (int)(padr & 0xffff);
862 lab->bus = (int)bus_num;
863 lab->scanned = 0;
864 lab->type = BRIDGE_TYPE_P2P;
865
866 shpchprm_acpi_register_a_bridge (&acpi_bridges_head, pab, lab);
867 } else
868 dbg("acpi_shpchprm: found P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
869 } 138 }
870
871 acpi_add_slot_to_php_slots(lab, (int)bus_num, handle, (u32)adr, (u32)sun);
872 return (status);
873}
874
875static int shpchprm_acpi_build_php_slots(
876 struct acpi_bridge *ab,
877 u32 depth
878 )
879{
880 acpi_status status;
881 u8 *path_name = acpi_path_name(ab->handle);
882
883 /* Walk down this pci bridge to get _SUNs if any behind P2P */
884 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
885 ab->handle,
886 depth,
887 shpchprm_acpi_build_php_slots_callback,
888 ab,
889 NULL );
890 if (ACPI_FAILURE(status)) {
891 dbg("acpi_shpchprm:%s walk for _SUN on pci bridge seg:bus(%x:%x) fail=0x%x\n", path_name, ab->seg, ab->bus, status);
892 return -1;
893 }
894
895 return 0;
896}
897
898static void build_a_bridge(
899 struct acpi_bridge *pab,
900 struct acpi_bridge *ab
901 )
902{
903 u8 *path_name = acpi_path_name(ab->handle);
904
905 shpchprm_acpi_register_a_bridge (&acpi_bridges_head, pab, ab);
906
907 switch (ab->type) {
908 case BRIDGE_TYPE_HOST:
909 dbg("acpi_shpchprm: Registered PCI HOST Bridge(%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
910 ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
911 break;
912 case BRIDGE_TYPE_P2P:
913 dbg("acpi_shpchprm: Registered PCI P2P Bridge(%02x-%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
914 ab->pbus, ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
915 break;
916 };
917
918 /* build any immediate PHP slots under this pci bridge */
919 shpchprm_acpi_build_php_slots(ab, 1);
920}
921
922static struct acpi_bridge * add_p2p_bridge(
923 acpi_handle handle,
924 struct acpi_bridge *pab, /* parent */
925 ulong adr
926 )
927{
928 struct acpi_bridge *ab;
929 struct pci_dev *pdev;
930 ulong devnum, funcnum;
931 u8 *path_name = acpi_path_name(handle);
932
933 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
934 if (!ab) {
935 err("acpi_shpchprm: alloc for ab fail\n");
936 return NULL;
937 }
938 memset(ab, 0, sizeof(struct acpi_bridge));
939
940 devnum = (adr >> 16) & 0xffff;
941 funcnum = adr & 0xffff;
942
943 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
944 if (!pdev || !pdev->subordinate) {
945 err("acpi_shpchprm:%s is not a P2P Bridge\n", path_name);
946 kfree(ab);
947 return NULL;
948 }
949
950 ab->handle = handle;
951 ab->seg = pab->seg;
952 ab->pbus = pab->bus; /* or pdev->bus->number */
953 ab->pdevice = devnum; /* or PCI_SLOT(pdev->devfn) */
954 ab->pfunction = funcnum; /* or PCI_FUNC(pdev->devfn) */
955 ab->bus = pdev->subordinate->number;
956 ab->scanned = 0;
957 ab->type = BRIDGE_TYPE_P2P;
958
959 dbg("acpi_shpchprm: P2P(%x-%x) on pci=b:d:f(%x:%x:%x) acpi=b:d:f(%x:%x:%x) [%s]\n",
960 pab->bus, ab->bus, pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
961 pab->bus, (u32)devnum, (u32)funcnum, path_name);
962
963 build_a_bridge(pab, ab);
964
965 return ab;
966}
967
968static acpi_status scan_p2p_bridge(
969 acpi_handle handle,
970 u32 Level,
971 void *context,
972 void **retval
973 )
974{
975 struct acpi_bridge *pab = (struct acpi_bridge *)context;
976 struct acpi_bridge *ab;
977 acpi_status status;
978 ulong adr = 0;
979 u8 *path_name = acpi_path_name(handle);
980 ulong devnum, funcnum;
981 struct pci_dev *pdev;
982
983 /* get device, function */
984 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
985 if (ACPI_FAILURE(status)) {
986 if (status != AE_NOT_FOUND)
987 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
988 return AE_OK;
989 }
990
991 devnum = (adr >> 16) & 0xffff;
992 funcnum = adr & 0xffff;
993
994 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
995 if (!pdev)
996 return AE_OK;
997 if (!pdev->subordinate)
998 return AE_OK;
999
1000 ab = add_p2p_bridge(handle, pab, adr);
1001 if (ab) {
1002 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1003 handle,
1004 (u32)1,
1005 scan_p2p_bridge,
1006 ab,
1007 NULL);
1008 if (ACPI_FAILURE(status))
1009 dbg("acpi_shpchprm:%s find_p2p fail=0x%x\n", path_name, status);
1010 }
1011
1012 return AE_OK;
1013}
1014
1015static struct acpi_bridge * add_host_bridge(
1016 acpi_handle handle,
1017 ulong segnum,
1018 ulong busnum
1019 )
1020{
1021 ulong adr = 0;
1022 acpi_status status;
1023 struct acpi_bridge *ab;
1024 u8 *path_name = acpi_path_name(handle);
1025
1026 /* get device, function: host br adr is always 0000 though. */
1027 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
1028 if (ACPI_FAILURE(status)) {
1029 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
1030 return NULL;
1031 }
1032 dbg("acpi_shpchprm: ROOT PCI seg(0x%x)bus(0x%x)dev(0x%x)func(0x%x) [%s]\n", (u32)segnum, (u32)busnum,
1033 (u32)(adr >> 16) & 0xffff, (u32)adr & 0xffff, path_name);
1034
1035 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
1036 if (!ab) {
1037 err("acpi_shpchprm: alloc for ab fail\n");
1038 return NULL;
1039 }
1040 memset(ab, 0, sizeof(struct acpi_bridge));
1041
1042 ab->handle = handle;
1043 ab->seg = (int)segnum;
1044 ab->bus = ab->pbus = (int)busnum;
1045 ab->pdevice = (int)(adr >> 16) & 0xffff;
1046 ab->pfunction = (int)(adr & 0xffff);
1047 ab->scanned = 0;
1048 ab->type = BRIDGE_TYPE_HOST;
1049
1050 /* get root pci bridge's current resources */
1051 status = acpi_get_crs(ab);
1052 if (ACPI_FAILURE(status)) {
1053 err("acpi_shpchprm:%s evaluate _CRS fail=0x%x\n", path_name, status);
1054 kfree(ab);
1055 return NULL;
1056 }
1057 build_a_bridge(ab, ab);
1058
1059 return ab;
1060}
1061
1062static acpi_status acpi_scan_from_root_pci_callback (
1063 acpi_handle handle,
1064 u32 Level,
1065 void *context,
1066 void **retval
1067 )
1068{
1069 ulong segnum = 0;
1070 ulong busnum = 0;
1071 acpi_status status;
1072 struct acpi_bridge *ab;
1073 u8 *path_name = acpi_path_name(handle);
1074
1075 /* get bus number of this pci root bridge */
1076 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &segnum);
1077 if (ACPI_FAILURE(status)) {
1078 if (status != AE_NOT_FOUND) {
1079 err("acpi_shpchprm:%s evaluate _SEG fail=0x%x\n", path_name, status);
1080 return status;
1081 }
1082 segnum = 0;
1083 }
1084
1085 /* get bus number of this pci root bridge */
1086 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, &busnum);
1087 if (ACPI_FAILURE(status)) {
1088 err("acpi_shpchprm:%s evaluate _BBN fail=0x%x\n", path_name, status);
1089 return (status);
1090 }
1091
1092 ab = add_host_bridge(handle, segnum, busnum);
1093 if (ab) {
1094 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1095 handle,
1096 1,
1097 scan_p2p_bridge,
1098 ab,
1099 NULL);
1100 if (ACPI_FAILURE(status))
1101 dbg("acpi_shpchprm:%s find_p2p fail=0x%x\n", path_name, status);
1102 }
1103
1104 return AE_OK;
1105}
1106
1107static int shpchprm_acpi_scan_pci (void)
1108{
1109 acpi_status status;
1110
1111 /*
1112 * TBD: traverse LDM device tree with the help of
1113 * unified ACPI augmented for php device population.
1114 */
1115 status = acpi_get_devices ( PCI_ROOT_HID_STRING,
1116 acpi_scan_from_root_pci_callback,
1117 NULL,
1118 NULL );
1119 if (ACPI_FAILURE(status)) {
1120 err("acpi_shpchprm:get_device PCI ROOT HID fail=0x%x\n", status);
1121 return -1;
1122 }
1123
1124 return 0;
1125}
1126
1127int shpchprm_init(enum php_ctlr_type ctlr_type)
1128{
1129 int rc;
1130
1131 if (ctlr_type != PCI)
1132 return -ENODEV;
1133
1134 dbg("shpchprm ACPI init <enter>\n");
1135 acpi_bridges_head = NULL;
1136
1137 /* construct PCI bus:device tree of acpi_handles */
1138 rc = shpchprm_acpi_scan_pci();
1139 if (rc)
1140 return rc;
1141
1142 dbg("shpchprm ACPI init %s\n", (rc)?"fail":"success");
1143 return rc;
1144}
1145
1146static void free_a_slot(struct acpi_php_slot *aps)
1147{
1148 dbg(" free a php func of slot(0x%02x) on PCI b:d:f=0x%02x:%02x:%02x\n", aps->sun, aps->bus, aps->dev, aps->fun);
1149
1150 free_pci_resource (aps->io_head);
1151 free_pci_resource (aps->bus_head);
1152 free_pci_resource (aps->mem_head);
1153 free_pci_resource (aps->p_mem_head);
1154
1155 kfree(aps);
1156}
1157
1158static void free_a_bridge( struct acpi_bridge *ab)
1159{
1160 struct acpi_php_slot *aps, *next;
1161
1162 switch (ab->type) {
1163 case BRIDGE_TYPE_HOST:
1164 dbg("Free ACPI PCI HOST Bridge(%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1165 ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1166 break;
1167 case BRIDGE_TYPE_P2P:
1168 dbg("Free ACPI PCI P2P Bridge(%x-%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1169 ab->pbus, ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1170 break;
1171 };
1172
1173 /* free slots first */
1174 for (aps = ab->slots; aps; aps = next) {
1175 next = aps->next;
1176 free_a_slot(aps);
1177 }
1178
1179 free_pci_resource (ab->io_head);
1180 free_pci_resource (ab->tio_head);
1181 free_pci_resource (ab->bus_head);
1182 free_pci_resource (ab->tbus_head);
1183 free_pci_resource (ab->mem_head);
1184 free_pci_resource (ab->tmem_head);
1185 free_pci_resource (ab->p_mem_head);
1186 free_pci_resource (ab->tp_mem_head);
1187
1188 kfree(ab);
1189}
1190
1191static void shpchprm_free_bridges ( struct acpi_bridge *ab)
1192{
1193 if (!ab)
1194 return;
1195
1196 if (ab->child)
1197 shpchprm_free_bridges (ab->child);
1198
1199 if (ab->next)
1200 shpchprm_free_bridges (ab->next);
1201
1202 free_a_bridge(ab);
1203}
1204
1205void shpchprm_cleanup(void)
1206{
1207 shpchprm_free_bridges (acpi_bridges_head);
1208}
1209
1210static int get_number_of_slots (
1211 struct acpi_bridge *ab,
1212 int selfonly
1213 )
1214{
1215 struct acpi_php_slot *aps;
1216 int prev_slot = -1;
1217 int slot_num = 0;
1218
1219 for ( aps = ab->slots; aps; aps = aps->next)
1220 if (aps->dev != prev_slot) {
1221 prev_slot = aps->dev;
1222 slot_num++;
1223 }
1224
1225 if (ab->child)
1226 slot_num += get_number_of_slots (ab->child, 0);
1227
1228 if (selfonly)
1229 return slot_num;
1230
1231 if (ab->next)
1232 slot_num += get_number_of_slots (ab->next, 0);
1233
1234 return slot_num;
1235}
1236
1237static int print_acpi_resources (struct acpi_bridge *ab)
1238{
1239 struct acpi_php_slot *aps;
1240 int i;
1241
1242 switch (ab->type) {
1243 case BRIDGE_TYPE_HOST:
1244 dbg("PCI HOST Bridge (%x) [%s]\n", ab->bus, acpi_path_name(ab->handle));
1245 break;
1246 case BRIDGE_TYPE_P2P:
1247 dbg("PCI P2P Bridge (%x-%x) [%s]\n", ab->pbus, ab->bus, acpi_path_name(ab->handle));
1248 break;
1249 };
1250
1251 print_pci_resources (ab);
1252
1253 for ( i = -1, aps = ab->slots; aps; aps = aps->next) {
1254 if (aps->dev == i)
1255 continue;
1256 dbg(" Slot sun(%x) s:b:d:f(%02x:%02x:%02x:%02x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1257 print_slot_resources(aps);
1258 i = aps->dev;
1259 }
1260
1261 if (ab->child)
1262 print_acpi_resources (ab->child);
1263
1264 if (ab->next)
1265 print_acpi_resources (ab->next);
1266
1267 return 0;
1268}
1269
1270int shpchprm_print_pirt(void)
1271{
1272 dbg("SHPCHPRM ACPI Slots\n");
1273 if (acpi_bridges_head)
1274 print_acpi_resources (acpi_bridges_head);
1275 return 0;
1276}
1277
1278static struct acpi_php_slot * get_acpi_slot (
1279 struct acpi_bridge *ab,
1280 u32 sun
1281 )
1282{
1283 struct acpi_php_slot *aps = NULL;
1284
1285 for ( aps = ab->slots; aps; aps = aps->next)
1286 if (aps->sun == sun)
1287 return aps;
1288
1289 if (!aps && ab->child) {
1290 aps = (struct acpi_php_slot *)get_acpi_slot (ab->child, sun);
1291 if (aps)
1292 return aps;
1293 }
1294
1295 if (!aps && ab->next) {
1296 aps = (struct acpi_php_slot *)get_acpi_slot (ab->next, sun);
1297 if (aps)
1298 return aps;
1299 }
1300
1301 return aps;
1302
1303}
1304
1305#if 0
1306static void * shpchprm_get_slot(struct slot *slot)
1307{
1308 struct acpi_bridge *ab = acpi_bridges_head;
1309 struct acpi_php_slot *aps = get_acpi_slot (ab, slot->number);
1310
1311 aps->slot = slot;
1312
1313 dbg("Got acpi slot sun(%x): s:b:d:f(%x:%x:%x:%x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1314
1315 return (void *)aps;
1316}
1317#endif
1318
1319static void shpchprm_dump_func_res( struct pci_func *fun)
1320{
1321 struct pci_func *func = fun;
1322
1323 if (func->bus_head) {
1324 dbg(": BUS Resources:\n");
1325 print_pci_resource (func->bus_head);
1326 }
1327 if (func->io_head) {
1328 dbg(": IO Resources:\n");
1329 print_pci_resource (func->io_head);
1330 }
1331 if (func->mem_head) {
1332 dbg(": MEM Resources:\n");
1333 print_pci_resource (func->mem_head);
1334 }
1335 if (func->p_mem_head) {
1336 dbg(": PMEM Resources:\n");
1337 print_pci_resource (func->p_mem_head);
1338 }
1339}
1340
1341static void shpchprm_dump_ctrl_res( struct controller *ctlr)
1342{
1343 struct controller *ctrl = ctlr;
1344
1345 if (ctrl->bus_head) {
1346 dbg(": BUS Resources:\n");
1347 print_pci_resource (ctrl->bus_head);
1348 }
1349 if (ctrl->io_head) {
1350 dbg(": IO Resources:\n");
1351 print_pci_resource (ctrl->io_head);
1352 }
1353 if (ctrl->mem_head) {
1354 dbg(": MEM Resources:\n");
1355 print_pci_resource (ctrl->mem_head);
1356 }
1357 if (ctrl->p_mem_head) {
1358 dbg(": PMEM Resources:\n");
1359 print_pci_resource (ctrl->p_mem_head);
1360 }
1361}
1362
1363static int shpchprm_get_used_resources (
1364 struct controller *ctrl,
1365 struct pci_func *func
1366 )
1367{
1368 return shpchp_save_used_resources (ctrl, func, !DISABLE_CARD);
1369}
1370
1371static int configure_existing_function(
1372 struct controller *ctrl,
1373 struct pci_func *func
1374 )
1375{
1376 int rc;
1377
1378 /* see how much resources the func has used. */
1379 rc = shpchprm_get_used_resources (ctrl, func);
1380
1381 if (!rc) {
1382 /* subtract the resources used by the func from ctrl resources */
1383 rc = shpchprm_delete_resources (&ctrl->bus_head, func->bus_head);
1384 rc |= shpchprm_delete_resources (&ctrl->io_head, func->io_head);
1385 rc |= shpchprm_delete_resources (&ctrl->mem_head, func->mem_head);
1386 rc |= shpchprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
1387 if (rc)
1388 warn("aCEF: cannot del used resources\n");
1389 } else
1390 err("aCEF: cannot get used resources\n");
1391
1392 return rc;
1393}
1394
1395static int bind_pci_resources_to_slots ( struct controller *ctrl)
1396{
1397 struct pci_func *func, new_func;
1398 int busn = ctrl->slot_bus;
1399 int devn, funn;
1400 u32 vid;
1401
1402 for (devn = 0; devn < 32; devn++) {
1403 for (funn = 0; funn < 8; funn++) {
1404 /*
1405 if (devn == ctrl->device && funn == ctrl->function)
1406 continue;
1407 */
1408 /* find out if this entry is for an occupied slot */
1409 vid = 0xFFFFFFFF;
1410 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
1411
1412 if (vid != 0xFFFFFFFF) {
1413 func = shpchp_slot_find(busn, devn, funn);
1414 if (!func) {
1415 memset(&new_func, 0, sizeof(struct pci_func));
1416 new_func.bus = busn;
1417 new_func.device = devn;
1418 new_func.function = funn;
1419 new_func.is_a_board = 1;
1420 configure_existing_function(ctrl, &new_func);
1421 shpchprm_dump_func_res(&new_func);
1422 } else {
1423 configure_existing_function(ctrl, func);
1424 shpchprm_dump_func_res(func);
1425 }
1426 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
1427 }
1428 }
1429 }
1430
1431 return 0;
1432}
1433
1434static int bind_pci_resources(
1435 struct controller *ctrl,
1436 struct acpi_bridge *ab
1437 )
1438{
1439 int status = 0;
1440
1441 if (ab->bus_head) {
1442 dbg("bapr: BUS Resources add on PCI 0x%x\n", ab->bus);
1443 status = shpchprm_add_resources (&ctrl->bus_head, ab->bus_head);
1444 if (shpchprm_delete_resources (&ab->bus_head, ctrl->bus_head))
1445 warn("bapr: cannot sub BUS Resource on PCI 0x%x\n", ab->bus);
1446 if (status) {
1447 err("bapr: BUS Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1448 return status;
1449 }
1450 } else
1451 info("bapr: No BUS Resource on PCI 0x%x.\n", ab->bus);
1452
1453 if (ab->io_head) {
1454 dbg("bapr: IO Resources add on PCI 0x%x\n", ab->bus);
1455 status = shpchprm_add_resources (&ctrl->io_head, ab->io_head);
1456 if (shpchprm_delete_resources (&ab->io_head, ctrl->io_head))
1457 warn("bapr: cannot sub IO Resource on PCI 0x%x\n", ab->bus);
1458 if (status) {
1459 err("bapr: IO Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1460 return status;
1461 }
1462 } else
1463 info("bapr: No IO Resource on PCI 0x%x.\n", ab->bus);
1464
1465 if (ab->mem_head) {
1466 dbg("bapr: MEM Resources add on PCI 0x%x\n", ab->bus);
1467 status = shpchprm_add_resources (&ctrl->mem_head, ab->mem_head);
1468 if (shpchprm_delete_resources (&ab->mem_head, ctrl->mem_head))
1469 warn("bapr: cannot sub MEM Resource on PCI 0x%x\n", ab->bus);
1470 if (status) {
1471 err("bapr: MEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1472 return status;
1473 }
1474 } else
1475 info("bapr: No MEM Resource on PCI 0x%x.\n", ab->bus);
1476
1477 if (ab->p_mem_head) {
1478 dbg("bapr: PMEM Resources add on PCI 0x%x\n", ab->bus);
1479 status = shpchprm_add_resources (&ctrl->p_mem_head, ab->p_mem_head);
1480 if (shpchprm_delete_resources (&ab->p_mem_head, ctrl->p_mem_head))
1481 warn("bapr: cannot sub PMEM Resource on PCI 0x%x\n", ab->bus);
1482 if (status) {
1483 err("bapr: PMEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1484 return status;
1485 }
1486 } else
1487 info("bapr: No PMEM Resource on PCI 0x%x.\n", ab->bus);
1488
1489 return status;
1490}
1491
1492static int no_pci_resources( struct acpi_bridge *ab)
1493{
1494 return !(ab->p_mem_head || ab->mem_head || ab->io_head || ab->bus_head);
1495}
1496
1497static int find_pci_bridge_resources (
1498 struct controller *ctrl,
1499 struct acpi_bridge *ab
1500 )
1501{
1502 int rc = 0;
1503 struct pci_func func;
1504
1505 memset(&func, 0, sizeof(struct pci_func));
1506
1507 func.bus = ab->pbus;
1508 func.device = ab->pdevice;
1509 func.function = ab->pfunction;
1510 func.is_a_board = 1;
1511
1512 /* Get used resources for this PCI bridge */
1513 rc = shpchp_save_used_resources (ctrl, &func, !DISABLE_CARD);
1514
1515 ab->io_head = func.io_head;
1516 ab->mem_head = func.mem_head;
1517 ab->p_mem_head = func.p_mem_head;
1518 ab->bus_head = func.bus_head;
1519 if (ab->bus_head)
1520 shpchprm_delete_resource(&ab->bus_head, ctrl->bus, 1);
1521
1522 return rc;
1523}
1524
1525static int get_pci_resources_from_bridge(
1526 struct controller *ctrl,
1527 struct acpi_bridge *ab
1528 )
1529{
1530 int rc = 0;
1531
1532 dbg("grfb: Get Resources for PCI 0x%x from actual PCI bridge 0x%x.\n", ctrl->bus, ab->bus);
1533
1534 rc = find_pci_bridge_resources (ctrl, ab);
1535
1536 shpchp_resource_sort_and_combine(&ab->bus_head);
1537 shpchp_resource_sort_and_combine(&ab->io_head);
1538 shpchp_resource_sort_and_combine(&ab->mem_head);
1539 shpchp_resource_sort_and_combine(&ab->p_mem_head);
1540
1541 shpchprm_add_resources (&ab->tbus_head, ab->bus_head);
1542 shpchprm_add_resources (&ab->tio_head, ab->io_head);
1543 shpchprm_add_resources (&ab->tmem_head, ab->mem_head);
1544 shpchprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
1545
1546 return rc;
1547}
1548
1549static int get_pci_resources(
1550 struct controller *ctrl,
1551 struct acpi_bridge *ab
1552 )
1553{
1554 int rc = 0;
1555
1556 if (no_pci_resources(ab)) {
1557 dbg("spbr:PCI 0x%x has no resources. Get parent resources.\n", ab->bus);
1558 rc = get_pci_resources_from_bridge(ctrl, ab);
1559 }
1560
1561 return rc;
1562} 139}
1563 140
1564int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) 141int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
@@ -1570,144 +147,40 @@ int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busn
1570 return 0; 147 return 0;
1571} 148}
1572 149
1573/* 150void get_hp_hw_control_from_firmware(struct pci_dev *dev)
1574 * Get resources for this ctrl.
1575 * 1. get total resources from ACPI _CRS or bridge (this ctrl)
1576 * 2. find used resources of existing adapters
1577 * 3. subtract used resources from total resources
1578 */
1579int shpchprm_find_available_resources( struct controller *ctrl)
1580{ 151{
1581 int rc = 0; 152 /*
1582 struct acpi_bridge *ab; 153 * OSHP is an optional ACPI firmware control method. If present,
1583 154 * we need to run it to inform BIOS that we will control SHPC
1584 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->pci_dev->subordinate->number); 155 * hardware from now on.
1585 if (!ab) { 156 */
1586 err("pfar:cannot locate acpi bridge of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number); 157 acpi_handle handle = DEVICE_ACPI_HANDLE(&(dev->dev));
1587 return -1; 158 if (!handle)
1588 } 159 return;
1589 if (no_pci_resources(ab)) { 160 acpi_run_oshp(handle);
1590 rc = get_pci_resources(ctrl, ab);
1591 if (rc) {
1592 err("pfar:cannot get pci resources of PCI 0x%x.\n",ctrl->pci_dev->subordinate->number);
1593 return -1;
1594 }
1595 }
1596
1597 rc = bind_pci_resources(ctrl, ab);
1598 dbg("pfar:pre-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1599 shpchprm_dump_ctrl_res(ctrl);
1600
1601 bind_pci_resources_to_slots (ctrl);
1602
1603 dbg("pfar:post-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1604 shpchprm_dump_ctrl_res(ctrl);
1605
1606 return rc;
1607}
1608
1609int shpchprm_set_hpp(
1610 struct controller *ctrl,
1611 struct pci_func *func,
1612 u8 card_type
1613 )
1614{
1615 struct acpi_bridge *ab;
1616 struct pci_bus lpci_bus, *pci_bus;
1617 int rc = 0;
1618 unsigned int devfn;
1619 u8 cls= 0x08; /* default cache line size */
1620 u8 lt = 0x40; /* default latency timer */
1621 u8 ep = 0;
1622 u8 es = 0;
1623
1624 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1625 pci_bus = &lpci_bus;
1626 pci_bus->number = func->bus;
1627 devfn = PCI_DEVFN(func->device, func->function);
1628
1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus);
1630
1631 if (ab) {
1632 if (ab->_hpp) {
1633 lt = (u8)ab->_hpp->latency_timer;
1634 cls = (u8)ab->_hpp->cache_line_size;
1635 ep = (u8)ab->_hpp->enable_perr;
1636 es = (u8)ab->_hpp->enable_serr;
1637 } else
1638 dbg("_hpp: no _hpp for B/D/F=%#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1639 } else
1640 dbg("_hpp: no acpi bridge for B/D/F = %#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1641
1642
1643 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1644 /* set subordinate Latency Timer */
1645 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, lt);
1646 }
1647
1648 /* set base Latency Timer */
1649 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, lt);
1650 dbg(" set latency timer =0x%02x: %x\n", lt, rc);
1651
1652 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, cls);
1653 dbg(" set cache_line_size=0x%02x: %x\n", cls, rc);
1654
1655 return rc;
1656} 161}
1657 162
1658void shpchprm_enable_card( 163void get_hp_params_from_firmware(struct pci_dev *dev,
1659 struct controller *ctrl, 164 struct hotplug_params *hpp)
1660 struct pci_func *func,
1661 u8 card_type)
1662{ 165{
1663 u16 command, cmd, bcommand, bcmd; 166 acpi_status status = AE_NOT_FOUND;
1664 struct pci_bus lpci_bus, *pci_bus; 167 struct pci_dev *pdev = dev;
1665 struct acpi_bridge *ab;
1666 unsigned int devfn;
1667 int rc;
1668
1669 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1670 pci_bus = &lpci_bus;
1671 pci_bus->number = func->bus;
1672 devfn = PCI_DEVFN(func->device, func->function);
1673
1674 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
1675
1676 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1677 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
1678 }
1679 168
1680 cmd = command = command | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE 169 /*
1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; 170 * _HPP settings apply to all child buses, until another _HPP is
1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; 171 * encountered. If we don't find an _HPP for the input pci dev,
1683 172 * look for it in the parent device scope since that would apply to
1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus); 173 * this pci dev. If we don't find any _HPP, use hardcoded defaults
1685 if (ab) { 174 */
1686 if (ab->_hpp) { 175 while (pdev && (ACPI_FAILURE(status))) {
1687 if (ab->_hpp->enable_perr) { 176 acpi_handle handle = DEVICE_ACPI_HANDLE(&(pdev->dev));
1688 command |= PCI_COMMAND_PARITY; 177 if (!handle)
1689 bcommand |= PCI_BRIDGE_CTL_PARITY; 178 break;
1690 } else { 179 status = acpi_run_hpp(handle, hpp);
1691 command &= ~PCI_COMMAND_PARITY; 180 if (!(pdev->bus->parent))
1692 bcommand &= ~PCI_BRIDGE_CTL_PARITY; 181 break;
1693 } 182 /* Check if a parent object supports _HPP */
1694 if (ab->_hpp->enable_serr) { 183 pdev = pdev->bus->parent->self;
1695 command |= PCI_COMMAND_SERR;
1696 bcommand |= PCI_BRIDGE_CTL_SERR;
1697 } else {
1698 command &= ~PCI_COMMAND_SERR;
1699 bcommand &= ~PCI_BRIDGE_CTL_SERR;
1700 }
1701 } else
1702 dbg("no _hpp for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1703 } else
1704 dbg("no acpi bridge for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1705
1706 if (command != cmd) {
1707 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
1708 }
1709 if ((card_type == PCI_HEADER_TYPE_BRIDGE) && (bcommand != bcmd)) {
1710 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);
1711 } 184 }
1712} 185}
1713 186
diff --git a/drivers/pci/hotplug/shpchprm_legacy.c b/drivers/pci/hotplug/shpchprm_legacy.c
index ba6c549c9b9d..ed6c1254bf6f 100644
--- a/drivers/pci/hotplug/shpchprm_legacy.c
+++ b/drivers/pci/hotplug/shpchprm_legacy.c
@@ -27,33 +27,11 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/pci.h> 33#include <linux/pci.h>
35#include <linux/init.h>
36#include <asm/uaccess.h>
37#ifdef CONFIG_IA64
38#include <asm/iosapic.h>
39#endif
40#include "shpchp.h" 34#include "shpchp.h"
41#include "shpchprm.h"
42#include "shpchprm_legacy.h"
43
44static void __iomem *shpchp_rom_start;
45static u16 unused_IRQ;
46
47void shpchprm_cleanup(void)
48{
49 if (shpchp_rom_start)
50 iounmap(shpchp_rom_start);
51}
52
53int shpchprm_print_pirt(void)
54{
55 return 0;
56}
57 35
58int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) 36int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
59{ 37{
@@ -63,377 +41,14 @@ int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busn
63 return 0; 41 return 0;
64} 42}
65 43
66/* Find the Hot Plug Resource Table in the specified region of memory */ 44void get_hp_params_from_firmware(struct pci_dev *dev,
67static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iomem *end) 45 struct hotplug_params *hpp)
68{ 46{
69 void __iomem *fp; 47 return;
70 void __iomem *endp;
71 u8 temp1, temp2, temp3, temp4;
72 int status = 0;
73
74 endp = (end - sizeof(struct hrt) + 1);
75
76 for (fp = begin; fp <= endp; fp += 16) {
77 temp1 = readb(fp + SIG0);
78 temp2 = readb(fp + SIG1);
79 temp3 = readb(fp + SIG2);
80 temp4 = readb(fp + SIG3);
81 if (temp1 == '$' && temp2 == 'H' && temp3 == 'R' && temp4 == 'T') {
82 status = 1;
83 break;
84 }
85 }
86
87 if (!status)
88 fp = NULL;
89
90 dbg("Discovered Hotplug Resource Table at %p\n", fp);
91 return fp;
92} 48}
93 49
94/* 50void get_hp_hw_control_from_firmware(struct pci_dev *dev)
95 * shpchprm_find_available_resources
96 *
97 * Finds available memory, IO, and IRQ resources for programming
98 * devices which may be added to the system
99 * this function is for hot plug ADD!
100 *
101 * returns 0 if success
102 */
103int shpchprm_find_available_resources(struct controller *ctrl)
104{ 51{
105 u8 populated_slot; 52 return;
106 u8 bridged_slot;
107 void __iomem *one_slot;
108 struct pci_func *func = NULL;
109 int i = 10, index = 0;
110 u32 temp_dword, rc;
111 ulong temp_ulong;
112 struct pci_resource *mem_node;
113 struct pci_resource *p_mem_node;
114 struct pci_resource *io_node;
115 struct pci_resource *bus_node;
116 void __iomem *rom_resource_table;
117 struct pci_bus lpci_bus, *pci_bus;
118 u8 cfgspc_irq, temp;
119
120 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
121 pci_bus = &lpci_bus;
122 rom_resource_table = detect_HRT_floating_pointer(shpchp_rom_start, shpchp_rom_start + 0xffff);
123 dbg("rom_resource_table = %p\n", rom_resource_table);
124 if (rom_resource_table == NULL)
125 return -ENODEV;
126
127 /* Sum all resources and setup resource maps */
128 unused_IRQ = readl(rom_resource_table + UNUSED_IRQ);
129 dbg("unused_IRQ = %x\n", unused_IRQ);
130
131 temp = 0;
132 while (unused_IRQ) {
133 if (unused_IRQ & 1) {
134 shpchp_disk_irq = temp;
135 break;
136 }
137 unused_IRQ = unused_IRQ >> 1;
138 temp++;
139 }
140
141 dbg("shpchp_disk_irq= %d\n", shpchp_disk_irq);
142 unused_IRQ = unused_IRQ >> 1;
143 temp++;
144
145 while (unused_IRQ) {
146 if (unused_IRQ & 1) {
147 shpchp_nic_irq = temp;
148 break;
149 }
150 unused_IRQ = unused_IRQ >> 1;
151 temp++;
152 }
153
154 dbg("shpchp_nic_irq= %d\n", shpchp_nic_irq);
155 unused_IRQ = readl(rom_resource_table + PCIIRQ);
156
157 temp = 0;
158
159 pci_read_config_byte(ctrl->pci_dev, PCI_INTERRUPT_LINE, &cfgspc_irq);
160
161 if (!shpchp_nic_irq) {
162 shpchp_nic_irq = cfgspc_irq;
163 }
164
165 if (!shpchp_disk_irq) {
166 shpchp_disk_irq = cfgspc_irq;
167 }
168
169 dbg("shpchp_disk_irq, shpchp_nic_irq= %d, %d\n", shpchp_disk_irq, shpchp_nic_irq);
170
171 one_slot = rom_resource_table + sizeof(struct hrt);
172
173 i = readb(rom_resource_table + NUMBER_OF_ENTRIES);
174 dbg("number_of_entries = %d\n", i);
175
176 if (!readb(one_slot + SECONDARY_BUS))
177 return (1);
178
179 dbg("dev|IO base|length|MEMbase|length|PM base|length|PB SB MB\n");
180
181 while (i && readb(one_slot + SECONDARY_BUS)) {
182 u8 dev_func = readb(one_slot + DEV_FUNC);
183 u8 primary_bus = readb(one_slot + PRIMARY_BUS);
184 u8 secondary_bus = readb(one_slot + SECONDARY_BUS);
185 u8 max_bus = readb(one_slot + MAX_BUS);
186 u16 io_base = readw(one_slot + IO_BASE);
187 u16 io_length = readw(one_slot + IO_LENGTH);
188 u16 mem_base = readw(one_slot + MEM_BASE);
189 u16 mem_length = readw(one_slot + MEM_LENGTH);
190 u16 pre_mem_base = readw(one_slot + PRE_MEM_BASE);
191 u16 pre_mem_length = readw(one_slot + PRE_MEM_LENGTH);
192
193 dbg("%2.2x | %4.4x | %4.4x | %4.4x | %4.4x | %4.4x | %4.4x |%2.2x %2.2x %2.2x\n",
194 dev_func, io_base, io_length, mem_base, mem_length, pre_mem_base, pre_mem_length,
195 primary_bus, secondary_bus, max_bus);
196
197 /* If this entry isn't for our controller's bus, ignore it */
198 if (primary_bus != ctrl->slot_bus) {
199 i--;
200 one_slot += sizeof(struct slot_rt);
201 continue;
202 }
203 /* find out if this entry is for an occupied slot */
204 temp_dword = 0xFFFFFFFF;
205 pci_bus->number = primary_bus;
206 pci_bus_read_config_dword(pci_bus, dev_func, PCI_VENDOR_ID, &temp_dword);
207
208 dbg("temp_D_word = %x\n", temp_dword);
209
210 if (temp_dword != 0xFFFFFFFF) {
211 index = 0;
212 func = shpchp_slot_find(primary_bus, dev_func >> 3, 0);
213
214 while (func && (func->function != (dev_func & 0x07))) {
215 dbg("func = %p b:d:f(%x:%x:%x)\n", func, primary_bus, dev_func >> 3, index);
216 func = shpchp_slot_find(primary_bus, dev_func >> 3, index++);
217 }
218
219 /* If we can't find a match, skip this table entry */
220 if (!func) {
221 i--;
222 one_slot += sizeof(struct slot_rt);
223 continue;
224 }
225 /* this may not work and shouldn't be used */
226 if (secondary_bus != primary_bus)
227 bridged_slot = 1;
228 else
229 bridged_slot = 0;
230
231 populated_slot = 1;
232 } else {
233 populated_slot = 0;
234 bridged_slot = 0;
235 }
236 dbg("slot populated =%s \n", populated_slot?"yes":"no");
237
238 /* If we've got a valid IO base, use it */
239
240 temp_ulong = io_base + io_length;
241
242 if ((io_base) && (temp_ulong <= 0x10000)) {
243 io_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
244 if (!io_node)
245 return -ENOMEM;
246
247 io_node->base = (ulong)io_base;
248 io_node->length = (ulong)io_length;
249 dbg("found io_node(base, length) = %x, %x\n", io_node->base, io_node->length);
250
251 if (!populated_slot) {
252 io_node->next = ctrl->io_head;
253 ctrl->io_head = io_node;
254 } else {
255 io_node->next = func->io_head;
256 func->io_head = io_node;
257 }
258 }
259
260 /* If we've got a valid memory base, use it */
261 temp_ulong = mem_base + mem_length;
262 if ((mem_base) && (temp_ulong <= 0x10000)) {
263 mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
264 if (!mem_node)
265 return -ENOMEM;
266
267 mem_node->base = (ulong)mem_base << 16;
268 mem_node->length = (ulong)(mem_length << 16);
269 dbg("found mem_node(base, length) = %x, %x\n", mem_node->base, mem_node->length);
270
271 if (!populated_slot) {
272 mem_node->next = ctrl->mem_head;
273 ctrl->mem_head = mem_node;
274 } else {
275 mem_node->next = func->mem_head;
276 func->mem_head = mem_node;
277 }
278 }
279
280 /*
281 * If we've got a valid prefetchable memory base, and
282 * the base + length isn't greater than 0xFFFF
283 */
284 temp_ulong = pre_mem_base + pre_mem_length;
285 if ((pre_mem_base) && (temp_ulong <= 0x10000)) {
286 p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
287 if (!p_mem_node)
288 return -ENOMEM;
289
290 p_mem_node->base = (ulong)pre_mem_base << 16;
291 p_mem_node->length = (ulong)pre_mem_length << 16;
292 dbg("found p_mem_node(base, length) = %x, %x\n", p_mem_node->base, p_mem_node->length);
293
294 if (!populated_slot) {
295 p_mem_node->next = ctrl->p_mem_head;
296 ctrl->p_mem_head = p_mem_node;
297 } else {
298 p_mem_node->next = func->p_mem_head;
299 func->p_mem_head = p_mem_node;
300 }
301 }
302
303 /*
304 * If we've got a valid bus number, use it
305 * The second condition is to ignore bus numbers on
306 * populated slots that don't have PCI-PCI bridges
307 */
308 if (secondary_bus && (secondary_bus != primary_bus)) {
309 bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
310 if (!bus_node)
311 return -ENOMEM;
312
313 bus_node->base = (ulong)secondary_bus;
314 bus_node->length = (ulong)(max_bus - secondary_bus + 1);
315 dbg("found bus_node(base, length) = %x, %x\n", bus_node->base, bus_node->length);
316
317 if (!populated_slot) {
318 bus_node->next = ctrl->bus_head;
319 ctrl->bus_head = bus_node;
320 } else {
321 bus_node->next = func->bus_head;
322 func->bus_head = bus_node;
323 }
324 }
325
326 i--;
327 one_slot += sizeof(struct slot_rt);
328 }
329
330 /* If all of the following fail, we don't have any resources for hot plug add */
331 rc = 1;
332 rc &= shpchp_resource_sort_and_combine(&(ctrl->mem_head));
333 rc &= shpchp_resource_sort_and_combine(&(ctrl->p_mem_head));
334 rc &= shpchp_resource_sort_and_combine(&(ctrl->io_head));
335 rc &= shpchp_resource_sort_and_combine(&(ctrl->bus_head));
336
337 return (rc);
338} 53}
339 54
340int shpchprm_set_hpp(
341 struct controller *ctrl,
342 struct pci_func *func,
343 u8 card_type)
344{
345 u32 rc;
346 u8 temp_byte;
347 struct pci_bus lpci_bus, *pci_bus;
348 unsigned int devfn;
349 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
350 pci_bus = &lpci_bus;
351 pci_bus->number = func->bus;
352 devfn = PCI_DEVFN(func->device, func->function);
353
354 temp_byte = 0x40; /* hard coded value for LT */
355 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
356 /* set subordinate Latency Timer */
357 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, temp_byte);
358 if (rc) {
359 dbg("%s: set secondary LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus,
360 func->device, func->function);
361 return rc;
362 }
363 }
364
365 /* set base Latency Timer */
366 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, temp_byte);
367 if (rc) {
368 dbg("%s: set LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
369 return rc;
370 }
371
372 /* set Cache Line size */
373 temp_byte = 0x08; /* hard coded value for CLS */
374 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, temp_byte);
375 if (rc) {
376 dbg("%s: set CLS error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
377 }
378
379 /* set enable_perr */
380 /* set enable_serr */
381
382 return rc;
383}
384
385void shpchprm_enable_card(
386 struct controller *ctrl,
387 struct pci_func *func,
388 u8 card_type)
389{
390 u16 command, bcommand;
391 struct pci_bus lpci_bus, *pci_bus;
392 unsigned int devfn;
393 int rc;
394
395 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
396 pci_bus = &lpci_bus;
397 pci_bus->number = func->bus;
398 devfn = PCI_DEVFN(func->device, func->function);
399
400 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
401 command |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR
402 | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
403 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
404 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
405
406 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
407 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
408 bcommand |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR
409 | PCI_BRIDGE_CTL_NO_ISA;
410 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);
411 }
412}
413
414static int legacy_shpchprm_init_pci(void)
415{
416 shpchp_rom_start = ioremap(ROM_PHY_ADDR, ROM_PHY_LEN);
417 if (!shpchp_rom_start) {
418 err("Could not ioremap memory region for ROM\n");
419 return -EIO;
420 }
421
422 return 0;
423}
424
425int shpchprm_init(enum php_ctlr_type ctrl_type)
426{
427 int retval;
428
429 switch (ctrl_type) {
430 case PCI:
431 retval = legacy_shpchprm_init_pci();
432 break;
433 default:
434 retval = -ENODEV;
435 break;
436 }
437
438 return retval;
439}
diff --git a/drivers/pci/hotplug/shpchprm_legacy.h b/drivers/pci/hotplug/shpchprm_legacy.h
deleted file mode 100644
index 21bda74ddfa5..000000000000
--- a/drivers/pci/hotplug/shpchprm_legacy.h
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 * SHPCHPRM Legacy: PHP Resource Manager for Non-ACPI/Legacy platform using HRT
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
27 *
28 */
29
30#ifndef _SHPCHPRM_LEGACY_H_
31#define _SHPCHPRM_LEGACY_H_
32
33#define ROM_PHY_ADDR 0x0F0000
34#define ROM_PHY_LEN 0x00FFFF
35
36struct slot_rt {
37 u8 dev_func;
38 u8 primary_bus;
39 u8 secondary_bus;
40 u8 max_bus;
41 u16 io_base;
42 u16 io_length;
43 u16 mem_base;
44 u16 mem_length;
45 u16 pre_mem_base;
46 u16 pre_mem_length;
47} __attribute__ ((packed));
48
49/* offsets to the hotplug slot resource table registers based on the above structure layout */
50enum slot_rt_offsets {
51 DEV_FUNC = offsetof(struct slot_rt, dev_func),
52 PRIMARY_BUS = offsetof(struct slot_rt, primary_bus),
53 SECONDARY_BUS = offsetof(struct slot_rt, secondary_bus),
54 MAX_BUS = offsetof(struct slot_rt, max_bus),
55 IO_BASE = offsetof(struct slot_rt, io_base),
56 IO_LENGTH = offsetof(struct slot_rt, io_length),
57 MEM_BASE = offsetof(struct slot_rt, mem_base),
58 MEM_LENGTH = offsetof(struct slot_rt, mem_length),
59 PRE_MEM_BASE = offsetof(struct slot_rt, pre_mem_base),
60 PRE_MEM_LENGTH = offsetof(struct slot_rt, pre_mem_length),
61};
62
63struct hrt {
64 char sig0;
65 char sig1;
66 char sig2;
67 char sig3;
68 u16 unused_IRQ;
69 u16 PCIIRQ;
70 u8 number_of_entries;
71 u8 revision;
72 u16 reserved1;
73 u32 reserved2;
74} __attribute__ ((packed));
75
76/* offsets to the hotplug resource table registers based on the above structure layout */
77enum hrt_offsets {
78 SIG0 = offsetof(struct hrt, sig0),
79 SIG1 = offsetof(struct hrt, sig1),
80 SIG2 = offsetof(struct hrt, sig2),
81 SIG3 = offsetof(struct hrt, sig3),
82 UNUSED_IRQ = offsetof(struct hrt, unused_IRQ),
83 PCIIRQ = offsetof(struct hrt, PCIIRQ),
84 NUMBER_OF_ENTRIES = offsetof(struct hrt, number_of_entries),
85 REVISION = offsetof(struct hrt, revision),
86 HRT_RESERVED1 = offsetof(struct hrt, reserved1),
87 HRT_RESERVED2 = offsetof(struct hrt, reserved2),
88};
89
90struct irq_info {
91 u8 bus, devfn; /* bus, device and function */
92 struct {
93 u8 link; /* IRQ line ID, chipset dependent, 0=not routed */
94 u16 bitmap; /* Available IRQs */
95 } __attribute__ ((packed)) irq[4];
96 u8 slot; /* slot number, 0=onboard */
97 u8 rfu;
98} __attribute__ ((packed));
99
100struct irq_routing_table {
101 u32 signature; /* PIRQ_SIGNATURE should be here */
102 u16 version; /* PIRQ_VERSION */
103 u16 size; /* Table size in bytes */
104 u8 rtr_bus, rtr_devfn; /* Where the interrupt router lies */
105 u16 exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
106 u16 rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
107 u32 miniport_data; /* Crap */
108 u8 rfu[11];
109 u8 checksum; /* Modulo 256 checksum must give zero */
110 struct irq_info slots[0];
111} __attribute__ ((packed));
112
113#endif /* _SHPCHPRM_LEGACY_H_ */
diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.c b/drivers/pci/hotplug/shpchprm_nonacpi.c
index 5f75ef7f3df2..d70fe5408417 100644
--- a/drivers/pci/hotplug/shpchprm_nonacpi.c
+++ b/drivers/pci/hotplug/shpchprm_nonacpi.c
@@ -32,24 +32,7 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/init.h>
36#include <asm/uaccess.h>
37#ifdef CONFIG_IA64
38#include <asm/iosapic.h>
39#endif
40#include "shpchp.h" 35#include "shpchp.h"
41#include "shpchprm.h"
42#include "shpchprm_nonacpi.h"
43
44void shpchprm_cleanup(void)
45{
46 return;
47}
48
49int shpchprm_print_pirt(void)
50{
51 return 0;
52}
53 36
54int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum) 37int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
55{ 38{
@@ -60,375 +43,13 @@ int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busn
60 return 0; 43 return 0;
61} 44}
62 45
63static void print_pci_resource ( struct pci_resource *aprh) 46void get_hp_params_from_firmware(struct pci_dev *dev,
64{ 47 struct hotplug_params *hpp)
65 struct pci_resource *res;
66
67 for (res = aprh; res; res = res->next)
68 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length);
69}
70
71
72static void phprm_dump_func_res( struct pci_func *fun)
73{
74 struct pci_func *func = fun;
75
76 if (func->bus_head) {
77 dbg(": BUS Resources:\n");
78 print_pci_resource (func->bus_head);
79 }
80 if (func->io_head) {
81 dbg(": IO Resources:\n");
82 print_pci_resource (func->io_head);
83 }
84 if (func->mem_head) {
85 dbg(": MEM Resources:\n");
86 print_pci_resource (func->mem_head);
87 }
88 if (func->p_mem_head) {
89 dbg(": PMEM Resources:\n");
90 print_pci_resource (func->p_mem_head);
91 }
92}
93
94static int phprm_get_used_resources (
95 struct controller *ctrl,
96 struct pci_func *func
97 )
98{
99 return shpchp_save_used_resources (ctrl, func, !DISABLE_CARD);
100}
101
102static int phprm_delete_resource(
103 struct pci_resource **aprh,
104 ulong base,
105 ulong size)
106{
107 struct pci_resource *res;
108 struct pci_resource *prevnode;
109 struct pci_resource *split_node;
110 ulong tbase;
111
112 shpchp_resource_sort_and_combine(aprh);
113
114 for (res = *aprh; res; res = res->next) {
115 if (res->base > base)
116 continue;
117
118 if ((res->base + res->length) < (base + size))
119 continue;
120
121 if (res->base < base) {
122 tbase = base;
123
124 if ((res->length - (tbase - res->base)) < size)
125 continue;
126
127 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
128 if (!split_node)
129 return -ENOMEM;
130
131 split_node->base = res->base;
132 split_node->length = tbase - res->base;
133 res->base = tbase;
134 res->length -= split_node->length;
135
136 split_node->next = res->next;
137 res->next = split_node;
138 }
139
140 if (res->length >= size) {
141 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
142 if (!split_node)
143 return -ENOMEM;
144
145 split_node->base = res->base + size;
146 split_node->length = res->length - size;
147 res->length = size;
148
149 split_node->next = res->next;
150 res->next = split_node;
151 }
152
153 if (*aprh == res) {
154 *aprh = res->next;
155 } else {
156 prevnode = *aprh;
157 while (prevnode->next != res)
158 prevnode = prevnode->next;
159
160 prevnode->next = res->next;
161 }
162 res->next = NULL;
163 kfree(res);
164 break;
165 }
166
167 return 0;
168}
169
170
171static int phprm_delete_resources(
172 struct pci_resource **aprh,
173 struct pci_resource *this
174 )
175{
176 struct pci_resource *res;
177
178 for (res = this; res; res = res->next)
179 phprm_delete_resource(aprh, res->base, res->length);
180
181 return 0;
182}
183
184
185static int configure_existing_function(
186 struct controller *ctrl,
187 struct pci_func *func
188 )
189{
190 int rc;
191
192 /* see how much resources the func has used. */
193 rc = phprm_get_used_resources (ctrl, func);
194
195 if (!rc) {
196 /* subtract the resources used by the func from ctrl resources */
197 rc = phprm_delete_resources (&ctrl->bus_head, func->bus_head);
198 rc |= phprm_delete_resources (&ctrl->io_head, func->io_head);
199 rc |= phprm_delete_resources (&ctrl->mem_head, func->mem_head);
200 rc |= phprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
201 if (rc)
202 warn("aCEF: cannot del used resources\n");
203 } else
204 err("aCEF: cannot get used resources\n");
205
206 return rc;
207}
208
209static int bind_pci_resources_to_slots ( struct controller *ctrl)
210{ 48{
211 struct pci_func *func, new_func; 49 return;
212 int busn = ctrl->slot_bus;
213 int devn, funn;
214 u32 vid;
215
216 for (devn = 0; devn < 32; devn++) {
217 for (funn = 0; funn < 8; funn++) {
218 /*
219 if (devn == ctrl->device && funn == ctrl->function)
220 continue;
221 */
222 /* find out if this entry is for an occupied slot */
223 vid = 0xFFFFFFFF;
224
225 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
226
227 if (vid != 0xFFFFFFFF) {
228 func = shpchp_slot_find(busn, devn, funn);
229 if (!func) {
230 memset(&new_func, 0, sizeof(struct pci_func));
231 new_func.bus = busn;
232 new_func.device = devn;
233 new_func.function = funn;
234 new_func.is_a_board = 1;
235 configure_existing_function(ctrl, &new_func);
236 phprm_dump_func_res(&new_func);
237 } else {
238 configure_existing_function(ctrl, func);
239 phprm_dump_func_res(func);
240 }
241 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
242 }
243 }
244 }
245
246 return 0;
247}
248
249static void phprm_dump_ctrl_res( struct controller *ctlr)
250{
251 struct controller *ctrl = ctlr;
252
253 if (ctrl->bus_head) {
254 dbg(": BUS Resources:\n");
255 print_pci_resource (ctrl->bus_head);
256 }
257 if (ctrl->io_head) {
258 dbg(": IO Resources:\n");
259 print_pci_resource (ctrl->io_head);
260 }
261 if (ctrl->mem_head) {
262 dbg(": MEM Resources:\n");
263 print_pci_resource (ctrl->mem_head);
264 }
265 if (ctrl->p_mem_head) {
266 dbg(": PMEM Resources:\n");
267 print_pci_resource (ctrl->p_mem_head);
268 }
269}
270
271/*
272 * phprm_find_available_resources
273 *
274 * Finds available memory, IO, and IRQ resources for programming
275 * devices which may be added to the system
276 * this function is for hot plug ADD!
277 *
278 * returns 0 if success
279 */
280int shpchprm_find_available_resources(struct controller *ctrl)
281{
282 struct pci_func func;
283 u32 rc;
284
285 memset(&func, 0, sizeof(struct pci_func));
286
287 func.bus = ctrl->bus;
288 func.device = ctrl->device;
289 func.function = ctrl->function;
290 func.is_a_board = 1;
291
292 /* Get resources for this PCI bridge */
293 rc = shpchp_save_used_resources (ctrl, &func, !DISABLE_CARD);
294 dbg("%s: shpchp_save_used_resources rc = %d\n", __FUNCTION__, rc);
295
296 if (func.mem_head)
297 func.mem_head->next = ctrl->mem_head;
298 ctrl->mem_head = func.mem_head;
299
300 if (func.p_mem_head)
301 func.p_mem_head->next = ctrl->p_mem_head;
302 ctrl->p_mem_head = func.p_mem_head;
303
304 if (func.io_head)
305 func.io_head->next = ctrl->io_head;
306 ctrl->io_head = func.io_head;
307
308 if(func.bus_head)
309 func.bus_head->next = ctrl->bus_head;
310 ctrl->bus_head = func.bus_head;
311 if (ctrl->bus_head)
312 phprm_delete_resource(&ctrl->bus_head, ctrl->pci_dev->subordinate->number, 1);
313
314 dbg("%s:pre-Bind PCI 0x%x Ctrl Resource Dump\n", __FUNCTION__, ctrl->bus);
315 phprm_dump_ctrl_res(ctrl);
316 bind_pci_resources_to_slots (ctrl);
317
318 dbg("%s:post-Bind PCI 0x%x Ctrl Resource Dump\n", __FUNCTION__, ctrl->bus);
319 phprm_dump_ctrl_res(ctrl);
320
321
322 /* If all of the following fail, we don't have any resources for hot plug add */
323 rc = 1;
324 rc &= shpchp_resource_sort_and_combine(&(ctrl->mem_head));
325 rc &= shpchp_resource_sort_and_combine(&(ctrl->p_mem_head));
326 rc &= shpchp_resource_sort_and_combine(&(ctrl->io_head));
327 rc &= shpchp_resource_sort_and_combine(&(ctrl->bus_head));
328
329 return (rc);
330}
331
332int shpchprm_set_hpp(
333 struct controller *ctrl,
334 struct pci_func *func,
335 u8 card_type)
336{
337 u32 rc;
338 u8 temp_byte;
339 struct pci_bus lpci_bus, *pci_bus;
340 unsigned int devfn;
341 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
342 pci_bus = &lpci_bus;
343 pci_bus->number = func->bus;
344 devfn = PCI_DEVFN(func->device, func->function);
345
346 temp_byte = 0x40; /* hard coded value for LT */
347 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
348 /* set subordinate Latency Timer */
349 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, temp_byte);
350
351 if (rc) {
352 dbg("%s: set secondary LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus,
353 func->device, func->function);
354 return rc;
355 }
356 }
357
358 /* set base Latency Timer */
359 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, temp_byte);
360
361 if (rc) {
362 dbg("%s: set LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
363 return rc;
364 }
365
366 /* set Cache Line size */
367 temp_byte = 0x08; /* hard coded value for CLS */
368
369 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, temp_byte);
370
371 if (rc) {
372 dbg("%s: set CLS error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
373 }
374
375 /* set enable_perr */
376 /* set enable_serr */
377
378 return rc;
379}
380
381void shpchprm_enable_card(
382 struct controller *ctrl,
383 struct pci_func *func,
384 u8 card_type)
385{
386 u16 command, bcommand;
387 struct pci_bus lpci_bus, *pci_bus;
388 unsigned int devfn;
389 int rc;
390
391 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
392 pci_bus = &lpci_bus;
393 pci_bus->number = func->bus;
394 devfn = PCI_DEVFN(func->device, func->function);
395
396 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
397
398 command |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR
399 | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
400 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
401
402 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
403
404 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
405
406 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
407
408 bcommand |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR
409 | PCI_BRIDGE_CTL_NO_ISA;
410
411 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);
412 }
413}
414
415static int legacy_shpchprm_init_pci(void)
416{
417 return 0;
418} 50}
419 51
420int shpchprm_init(enum php_ctlr_type ctrl_type) 52void get_hp_hw_control_from_firmware(struct pci_dev *dev)
421{ 53{
422 int retval; 54 return;
423
424 switch (ctrl_type) {
425 case PCI:
426 retval = legacy_shpchprm_init_pci();
427 break;
428 default:
429 retval = -ENODEV;
430 break;
431 }
432
433 return retval;
434} 55}
diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.h b/drivers/pci/hotplug/shpchprm_nonacpi.h
deleted file mode 100644
index cddaaa5ee1b3..000000000000
--- a/drivers/pci/hotplug/shpchprm_nonacpi.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * SHPCHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
27 *
28 */
29
30#ifndef _SHPCHPRM_NONACPI_H_
31#define _SHPCHPRM_NONACPI_H_
32
33struct irq_info {
34 u8 bus, devfn; /* bus, device and function */
35 struct {
36 u8 link; /* IRQ line ID, chipset dependent, 0=not routed */
37 u16 bitmap; /* Available IRQs */
38 } __attribute__ ((packed)) irq[4];
39 u8 slot; /* slot number, 0=onboard */
40 u8 rfu;
41} __attribute__ ((packed));
42
43struct irq_routing_table {
44 u32 signature; /* PIRQ_SIGNATURE should be here */
45 u16 version; /* PIRQ_VERSION */
46 u16 size; /* Table size in bytes */
47 u8 rtr_bus, rtr_devfn; /* Where the interrupt router lies */
48 u16 exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
49 u16 rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
50 u32 miniport_data; /* Crap */
51 u8 rfu[11];
52 u8 checksum; /* Modulo 256 checksum must give zero */
53 struct irq_info slots[0];
54} __attribute__ ((packed));
55
56#endif /* _SHPCHPRM_NONACPI_H_ */
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index ee8677bda950..a2033552423c 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -575,6 +575,8 @@ static int msi_capability_init(struct pci_dev *dev)
575/** 575/**
576 * msix_capability_init - configure device's MSI-X capability 576 * msix_capability_init - configure device's MSI-X capability
577 * @dev: pointer to the pci_dev data structure of MSI-X device function 577 * @dev: pointer to the pci_dev data structure of MSI-X device function
578 * @entries: pointer to an array of struct msix_entry entries
579 * @nvec: number of @entries
578 * 580 *
579 * Setup the MSI-X capability structure of device function with a 581 * Setup the MSI-X capability structure of device function with a
580 * single MSI-X vector. A return of zero indicates the successful setup of 582 * single MSI-X vector. A return of zero indicates the successful setup of
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 0d0d533894e0..8972e6a3aac0 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -26,7 +26,10 @@ struct pci_dynid {
26#ifdef CONFIG_HOTPLUG 26#ifdef CONFIG_HOTPLUG
27 27
28/** 28/**
29 * store_new_id 29 * store_new_id - add a new PCI device ID to this driver and re-probe devices
30 * @driver: target device driver
31 * @buf: buffer for scanning device ID data
32 * @count: input size
30 * 33 *
31 * Adds a new dynamic pci device ID to this driver, 34 * Adds a new dynamic pci device ID to this driver,
32 * and causes the driver to probe for all devices again. 35 * and causes the driver to probe for all devices again.
@@ -194,8 +197,10 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
194 197
195/** 198/**
196 * __pci_device_probe() 199 * __pci_device_probe()
200 * @drv: driver to call to check if it wants the PCI device
201 * @pci_dev: PCI device being probed
197 * 202 *
198 * returns 0 on success, else error. 203 * returns 0 on success, else error.
199 * side-effect: pci_dev->driver is set to drv when drv claims pci_dev. 204 * side-effect: pci_dev->driver is set to drv when drv claims pci_dev.
200 */ 205 */
201static int 206static int
@@ -377,6 +382,10 @@ int pci_register_driver(struct pci_driver *drv)
377 * the pci shutdown function, this test can go away. */ 382 * the pci shutdown function, this test can go away. */
378 if (!drv->driver.shutdown) 383 if (!drv->driver.shutdown)
379 drv->driver.shutdown = pci_device_shutdown; 384 drv->driver.shutdown = pci_device_shutdown;
385 else
386 printk(KERN_WARNING "Warning: PCI driver %s has a struct "
387 "device_driver shutdown method, please update!\n",
388 drv->name);
380 drv->driver.owner = drv->owner; 389 drv->driver.owner = drv->owner;
381 drv->driver.kobj.ktype = &pci_driver_kobj_type; 390 drv->driver.kobj.ktype = &pci_driver_kobj_type;
382 391
@@ -436,11 +445,11 @@ pci_dev_driver(const struct pci_dev *dev)
436 445
437/** 446/**
438 * pci_bus_match - Tell if a PCI device structure has a matching PCI device id structure 447 * pci_bus_match - Tell if a PCI device structure has a matching PCI device id structure
439 * @ids: array of PCI device id structures to search in
440 * @dev: the PCI device structure to match against 448 * @dev: the PCI device structure to match against
449 * @drv: the device driver to search for matching PCI device id structures
441 * 450 *
442 * Used by a driver to check whether a PCI device present in the 451 * Used by a driver to check whether a PCI device present in the
443 * system is in its list of supported devices.Returns the matching 452 * system is in its list of supported devices. Returns the matching
444 * pci_device_id structure or %NULL if there is no match. 453 * pci_device_id structure or %NULL if there is no match.
445 */ 454 */
446static int pci_bus_match(struct device *dev, struct device_driver *drv) 455static int pci_bus_match(struct device *dev, struct device_driver *drv)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 2898830c496f..965a5934623a 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -130,7 +130,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
130 130
131 if ((off & 1) && size) { 131 if ((off & 1) && size) {
132 u8 val; 132 u8 val;
133 pci_read_config_byte(dev, off, &val); 133 pci_user_read_config_byte(dev, off, &val);
134 data[off - init_off] = val; 134 data[off - init_off] = val;
135 off++; 135 off++;
136 size--; 136 size--;
@@ -138,7 +138,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
138 138
139 if ((off & 3) && size > 2) { 139 if ((off & 3) && size > 2) {
140 u16 val; 140 u16 val;
141 pci_read_config_word(dev, off, &val); 141 pci_user_read_config_word(dev, off, &val);
142 data[off - init_off] = val & 0xff; 142 data[off - init_off] = val & 0xff;
143 data[off - init_off + 1] = (val >> 8) & 0xff; 143 data[off - init_off + 1] = (val >> 8) & 0xff;
144 off += 2; 144 off += 2;
@@ -147,7 +147,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
147 147
148 while (size > 3) { 148 while (size > 3) {
149 u32 val; 149 u32 val;
150 pci_read_config_dword(dev, off, &val); 150 pci_user_read_config_dword(dev, off, &val);
151 data[off - init_off] = val & 0xff; 151 data[off - init_off] = val & 0xff;
152 data[off - init_off + 1] = (val >> 8) & 0xff; 152 data[off - init_off + 1] = (val >> 8) & 0xff;
153 data[off - init_off + 2] = (val >> 16) & 0xff; 153 data[off - init_off + 2] = (val >> 16) & 0xff;
@@ -158,7 +158,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
158 158
159 if (size >= 2) { 159 if (size >= 2) {
160 u16 val; 160 u16 val;
161 pci_read_config_word(dev, off, &val); 161 pci_user_read_config_word(dev, off, &val);
162 data[off - init_off] = val & 0xff; 162 data[off - init_off] = val & 0xff;
163 data[off - init_off + 1] = (val >> 8) & 0xff; 163 data[off - init_off + 1] = (val >> 8) & 0xff;
164 off += 2; 164 off += 2;
@@ -167,7 +167,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
167 167
168 if (size > 0) { 168 if (size > 0) {
169 u8 val; 169 u8 val;
170 pci_read_config_byte(dev, off, &val); 170 pci_user_read_config_byte(dev, off, &val);
171 data[off - init_off] = val; 171 data[off - init_off] = val;
172 off++; 172 off++;
173 --size; 173 --size;
@@ -192,7 +192,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
192 } 192 }
193 193
194 if ((off & 1) && size) { 194 if ((off & 1) && size) {
195 pci_write_config_byte(dev, off, data[off - init_off]); 195 pci_user_write_config_byte(dev, off, data[off - init_off]);
196 off++; 196 off++;
197 size--; 197 size--;
198 } 198 }
@@ -200,7 +200,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
200 if ((off & 3) && size > 2) { 200 if ((off & 3) && size > 2) {
201 u16 val = data[off - init_off]; 201 u16 val = data[off - init_off];
202 val |= (u16) data[off - init_off + 1] << 8; 202 val |= (u16) data[off - init_off + 1] << 8;
203 pci_write_config_word(dev, off, val); 203 pci_user_write_config_word(dev, off, val);
204 off += 2; 204 off += 2;
205 size -= 2; 205 size -= 2;
206 } 206 }
@@ -210,7 +210,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
210 val |= (u32) data[off - init_off + 1] << 8; 210 val |= (u32) data[off - init_off + 1] << 8;
211 val |= (u32) data[off - init_off + 2] << 16; 211 val |= (u32) data[off - init_off + 2] << 16;
212 val |= (u32) data[off - init_off + 3] << 24; 212 val |= (u32) data[off - init_off + 3] << 24;
213 pci_write_config_dword(dev, off, val); 213 pci_user_write_config_dword(dev, off, val);
214 off += 4; 214 off += 4;
215 size -= 4; 215 size -= 4;
216 } 216 }
@@ -218,13 +218,13 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
218 if (size >= 2) { 218 if (size >= 2) {
219 u16 val = data[off - init_off]; 219 u16 val = data[off - init_off];
220 val |= (u16) data[off - init_off + 1] << 8; 220 val |= (u16) data[off - init_off + 1] << 8;
221 pci_write_config_word(dev, off, val); 221 pci_user_write_config_word(dev, off, val);
222 off += 2; 222 off += 2;
223 size -= 2; 223 size -= 2;
224 } 224 }
225 225
226 if (size) { 226 if (size) {
227 pci_write_config_byte(dev, off, data[off - init_off]); 227 pci_user_write_config_byte(dev, off, data[off - init_off]);
228 off++; 228 off++;
229 --size; 229 --size;
230 } 230 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 259d247b7551..61b855c99e39 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -252,6 +252,8 @@ pci_restore_bars(struct pci_dev *dev)
252 pci_update_resource(dev, &dev->resource[i], i); 252 pci_update_resource(dev, &dev->resource[i], i);
253} 253}
254 254
255int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t);
256
255/** 257/**
256 * pci_set_power_state - Set the power state of a PCI device 258 * pci_set_power_state - Set the power state of a PCI device
257 * @dev: PCI device to be suspended 259 * @dev: PCI device to be suspended
@@ -266,7 +268,6 @@ pci_restore_bars(struct pci_dev *dev)
266 * -EIO if device does not support PCI PM. 268 * -EIO if device does not support PCI PM.
267 * 0 if we can successfully change the power state. 269 * 0 if we can successfully change the power state.
268 */ 270 */
269int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t);
270int 271int
271pci_set_power_state(struct pci_dev *dev, pci_power_t state) 272pci_set_power_state(struct pci_dev *dev, pci_power_t state)
272{ 273{
@@ -314,19 +315,19 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
314 * sets PowerState to 0. 315 * sets PowerState to 0.
315 */ 316 */
316 switch (dev->current_state) { 317 switch (dev->current_state) {
318 case PCI_D0:
319 case PCI_D1:
320 case PCI_D2:
321 pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
322 pmcsr |= state;
323 break;
317 case PCI_UNKNOWN: /* Boot-up */ 324 case PCI_UNKNOWN: /* Boot-up */
318 if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot 325 if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot
319 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) 326 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
320 need_restore = 1; 327 need_restore = 1;
321 /* Fall-through: force to D0 */ 328 /* Fall-through: force to D0 */
322 case PCI_D3hot:
323 case PCI_D3cold:
324 case PCI_POWER_ERROR:
325 pmcsr = 0;
326 break;
327 default: 329 default:
328 pmcsr &= ~PCI_PM_CTRL_STATE_MASK; 330 pmcsr = 0;
329 pmcsr |= state;
330 break; 331 break;
331 } 332 }
332 333
@@ -808,8 +809,8 @@ pci_clear_mwi(struct pci_dev *dev)
808 809
809/** 810/**
810 * pci_intx - enables/disables PCI INTx for device dev 811 * pci_intx - enables/disables PCI INTx for device dev
811 * @dev: the PCI device to operate on 812 * @pdev: the PCI device to operate on
812 * @enable: boolean 813 * @enable: boolean: whether to enable or disable PCI INTx
813 * 814 *
814 * Enables/disables PCI INTx for device dev 815 * Enables/disables PCI INTx for device dev
815 */ 816 */
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index d3f3dd42240d..6527b36c9a61 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -15,6 +15,13 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state); 16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
17 17
18extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
19extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
20extern int pci_user_read_config_dword(struct pci_dev *dev, int where, u32 *val);
21extern int pci_user_write_config_byte(struct pci_dev *dev, int where, u8 val);
22extern int pci_user_write_config_word(struct pci_dev *dev, int where, u16 val);
23extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val);
24
18/* PCI /proc functions */ 25/* PCI /proc functions */
19#ifdef CONFIG_PROC_FS 26#ifdef CONFIG_PROC_FS
20extern int pci_proc_attach_device(struct pci_dev *dev); 27extern int pci_proc_attach_device(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 393e0cee91a9..14f05d22bb70 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -61,7 +61,7 @@ static int pcie_port_remove_service(struct device *dev)
61 61
62static void pcie_port_shutdown_service(struct device *dev) {} 62static void pcie_port_shutdown_service(struct device *dev) {}
63 63
64static int pcie_port_suspend_service(struct device *dev, pm_message_t state, u32 level) 64static int pcie_port_suspend_service(struct device *dev, pm_message_t state)
65{ 65{
66 struct pcie_device *pciedev; 66 struct pcie_device *pciedev;
67 struct pcie_port_service_driver *driver; 67 struct pcie_port_service_driver *driver;
@@ -76,7 +76,7 @@ static int pcie_port_suspend_service(struct device *dev, pm_message_t state, u32
76 return 0; 76 return 0;
77} 77}
78 78
79static int pcie_port_resume_service(struct device *dev, u32 level) 79static int pcie_port_resume_service(struct device *dev)
80{ 80{
81 struct pcie_device *pciedev; 81 struct pcie_device *pciedev;
82 struct pcie_port_service_driver *driver; 82 struct pcie_port_service_driver *driver;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 005786416bb5..fce2cb2112d8 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -669,6 +669,7 @@ static void pci_release_dev(struct device *dev)
669 669
670/** 670/**
671 * pci_cfg_space_size - get the configuration space size of the PCI device. 671 * pci_cfg_space_size - get the configuration space size of the PCI device.
672 * @dev: PCI device
672 * 673 *
673 * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices 674 * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices
674 * have 4096 bytes. Even if the device is capable, that doesn't mean we can 675 * have 4096 bytes. Even if the device is capable, that doesn't mean we can
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 9613f666c110..9eb465727fce 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -80,7 +80,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
80 80
81 if ((pos & 1) && cnt) { 81 if ((pos & 1) && cnt) {
82 unsigned char val; 82 unsigned char val;
83 pci_read_config_byte(dev, pos, &val); 83 pci_user_read_config_byte(dev, pos, &val);
84 __put_user(val, buf); 84 __put_user(val, buf);
85 buf++; 85 buf++;
86 pos++; 86 pos++;
@@ -89,7 +89,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
89 89
90 if ((pos & 3) && cnt > 2) { 90 if ((pos & 3) && cnt > 2) {
91 unsigned short val; 91 unsigned short val;
92 pci_read_config_word(dev, pos, &val); 92 pci_user_read_config_word(dev, pos, &val);
93 __put_user(cpu_to_le16(val), (unsigned short __user *) buf); 93 __put_user(cpu_to_le16(val), (unsigned short __user *) buf);
94 buf += 2; 94 buf += 2;
95 pos += 2; 95 pos += 2;
@@ -98,7 +98,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
98 98
99 while (cnt >= 4) { 99 while (cnt >= 4) {
100 unsigned int val; 100 unsigned int val;
101 pci_read_config_dword(dev, pos, &val); 101 pci_user_read_config_dword(dev, pos, &val);
102 __put_user(cpu_to_le32(val), (unsigned int __user *) buf); 102 __put_user(cpu_to_le32(val), (unsigned int __user *) buf);
103 buf += 4; 103 buf += 4;
104 pos += 4; 104 pos += 4;
@@ -107,7 +107,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
107 107
108 if (cnt >= 2) { 108 if (cnt >= 2) {
109 unsigned short val; 109 unsigned short val;
110 pci_read_config_word(dev, pos, &val); 110 pci_user_read_config_word(dev, pos, &val);
111 __put_user(cpu_to_le16(val), (unsigned short __user *) buf); 111 __put_user(cpu_to_le16(val), (unsigned short __user *) buf);
112 buf += 2; 112 buf += 2;
113 pos += 2; 113 pos += 2;
@@ -116,7 +116,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
116 116
117 if (cnt) { 117 if (cnt) {
118 unsigned char val; 118 unsigned char val;
119 pci_read_config_byte(dev, pos, &val); 119 pci_user_read_config_byte(dev, pos, &val);
120 __put_user(val, buf); 120 __put_user(val, buf);
121 buf++; 121 buf++;
122 pos++; 122 pos++;
@@ -151,7 +151,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
151 if ((pos & 1) && cnt) { 151 if ((pos & 1) && cnt) {
152 unsigned char val; 152 unsigned char val;
153 __get_user(val, buf); 153 __get_user(val, buf);
154 pci_write_config_byte(dev, pos, val); 154 pci_user_write_config_byte(dev, pos, val);
155 buf++; 155 buf++;
156 pos++; 156 pos++;
157 cnt--; 157 cnt--;
@@ -160,7 +160,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
160 if ((pos & 3) && cnt > 2) { 160 if ((pos & 3) && cnt > 2) {
161 unsigned short val; 161 unsigned short val;
162 __get_user(val, (unsigned short __user *) buf); 162 __get_user(val, (unsigned short __user *) buf);
163 pci_write_config_word(dev, pos, le16_to_cpu(val)); 163 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
164 buf += 2; 164 buf += 2;
165 pos += 2; 165 pos += 2;
166 cnt -= 2; 166 cnt -= 2;
@@ -169,7 +169,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
169 while (cnt >= 4) { 169 while (cnt >= 4) {
170 unsigned int val; 170 unsigned int val;
171 __get_user(val, (unsigned int __user *) buf); 171 __get_user(val, (unsigned int __user *) buf);
172 pci_write_config_dword(dev, pos, le32_to_cpu(val)); 172 pci_user_write_config_dword(dev, pos, le32_to_cpu(val));
173 buf += 4; 173 buf += 4;
174 pos += 4; 174 pos += 4;
175 cnt -= 4; 175 cnt -= 4;
@@ -178,7 +178,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
178 if (cnt >= 2) { 178 if (cnt >= 2) {
179 unsigned short val; 179 unsigned short val;
180 __get_user(val, (unsigned short __user *) buf); 180 __get_user(val, (unsigned short __user *) buf);
181 pci_write_config_word(dev, pos, le16_to_cpu(val)); 181 pci_user_write_config_word(dev, pos, le16_to_cpu(val));
182 buf += 2; 182 buf += 2;
183 pos += 2; 183 pos += 2;
184 cnt -= 2; 184 cnt -= 2;
@@ -187,7 +187,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
187 if (cnt) { 187 if (cnt) {
188 unsigned char val; 188 unsigned char val;
189 __get_user(val, buf); 189 __get_user(val, buf);
190 pci_write_config_byte(dev, pos, val); 190 pci_user_write_config_byte(dev, pos, val);
191 buf++; 191 buf++;
192 pos++; 192 pos++;
193 cnt--; 193 cnt--;
@@ -484,10 +484,10 @@ static int show_dev_config(struct seq_file *m, void *v)
484 484
485 drv = pci_dev_driver(dev); 485 drv = pci_dev_driver(dev);
486 486
487 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 487 pci_user_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
488 pci_read_config_byte (dev, PCI_LATENCY_TIMER, &latency); 488 pci_user_read_config_byte (dev, PCI_LATENCY_TIMER, &latency);
489 pci_read_config_byte (dev, PCI_MIN_GNT, &min_gnt); 489 pci_user_read_config_byte (dev, PCI_MIN_GNT, &min_gnt);
490 pci_read_config_byte (dev, PCI_MAX_LAT, &max_lat); 490 pci_user_read_config_byte (dev, PCI_MAX_LAT, &max_lat);
491 seq_printf(m, " Bus %2d, device %3d, function %2d:\n", 491 seq_printf(m, " Bus %2d, device %3d, function %2d:\n",
492 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 492 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
493 seq_printf(m, " Class %04x", class_rev >> 16); 493 seq_printf(m, " Class %04x", class_rev >> 16);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 7992bc8cc6a4..bbd9c2323d8c 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -7,6 +7,9 @@
7 * 7 *
8 * Copyright (c) 1999 Martin Mares <mj@ucw.cz> 8 * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
9 * 9 *
10 * Init/reset quirks for USB host controllers should be in the
11 * USB quirks file, where their drivers can access reuse it.
12 *
10 * The bridge optimization stuff has been removed. If you really 13 * The bridge optimization stuff has been removed. If you really
11 * have a silly BIOS which is unable to set your host bridge right, 14 * have a silly BIOS which is unable to set your host bridge right,
12 * use the PowerTweak utility (see http://powertweak.sourceforge.net). 15 * use the PowerTweak utility (see http://powertweak.sourceforge.net).
@@ -414,6 +417,18 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
414DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi ); 417DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi );
415DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi ); 418DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi );
416 419
420static void __devinit quirk_ich6_lpc_acpi(struct pci_dev *dev)
421{
422 u32 region;
423
424 pci_read_config_dword(dev, 0x40, &region);
425 quirk_io_region(dev, region, 128, PCI_BRIDGE_RESOURCES, "ICH6 ACPI/GPIO/TCO");
426
427 pci_read_config_dword(dev, 0x48, &region);
428 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES+1, "ICH6 GPIO");
429}
430DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi );
431
417/* 432/*
418 * VIA ACPI: One IO region pointed to by longword at 433 * VIA ACPI: One IO region pointed to by longword at
419 * 0x48 or 0x20 (256 bytes of ACPI registers) 434 * 0x48 or 0x20 (256 bytes of ACPI registers)
@@ -633,28 +648,6 @@ static void quirk_via_irq(struct pci_dev *dev)
633DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq); 648DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq);
634 649
635/* 650/*
636 * PIIX3 USB: We have to disable USB interrupts that are
637 * hardwired to PIRQD# and may be shared with an
638 * external device.
639 *
640 * Legacy Support Register (LEGSUP):
641 * bit13: USB PIRQ Enable (USBPIRQDEN),
642 * bit4: Trap/SMI On IRQ Enable (USBSMIEN).
643 *
644 * We mask out all r/wc bits, too.
645 */
646static void __devinit quirk_piix3_usb(struct pci_dev *dev)
647{
648 u16 legsup;
649
650 pci_read_config_word(dev, 0xc0, &legsup);
651 legsup &= 0x50ef;
652 pci_write_config_word(dev, 0xc0, legsup);
653}
654DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_2, quirk_piix3_usb );
655DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_2, quirk_piix3_usb );
656
657/*
658 * VIA VT82C598 has its device ID settable and many BIOSes 651 * VIA VT82C598 has its device ID settable and many BIOSes
659 * set it to the ID of VT82C597 for backward compatibility. 652 * set it to the ID of VT82C597 for backward compatibility.
660 * We need to switch it off to be able to recognize the real 653 * We need to switch it off to be able to recognize the real
@@ -922,6 +915,12 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
922 case 0x186a: /* M6Ne notebook */ 915 case 0x186a: /* M6Ne notebook */
923 asus_hides_smbus = 1; 916 asus_hides_smbus = 1;
924 } 917 }
918 if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) {
919 switch (dev->subsystem_device) {
920 case 0x1882: /* M6V notebook */
921 asus_hides_smbus = 1;
922 }
923 }
925 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) { 924 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) {
926 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 925 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
927 switch(dev->subsystem_device) { 926 switch(dev->subsystem_device) {
@@ -932,6 +931,7 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
932 if (dev->device == PCI_DEVICE_ID_INTEL_82865_HB) 931 if (dev->device == PCI_DEVICE_ID_INTEL_82865_HB)
933 switch (dev->subsystem_device) { 932 switch (dev->subsystem_device) {
934 case 0x12bc: /* HP D330L */ 933 case 0x12bc: /* HP D330L */
934 case 0x12bd: /* HP D530 */
935 asus_hides_smbus = 1; 935 asus_hides_smbus = 1;
936 } 936 }
937 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) { 937 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) {
@@ -966,6 +966,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82865_HB, asus
966DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_7205_0, asus_hides_smbus_hostbridge ); 966DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_7205_0, asus_hides_smbus_hostbridge );
967DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855PM_HB, asus_hides_smbus_hostbridge ); 967DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855PM_HB, asus_hides_smbus_hostbridge );
968DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855GM_HB, asus_hides_smbus_hostbridge ); 968DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855GM_HB, asus_hides_smbus_hostbridge );
969DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82915GM_HB, asus_hides_smbus_hostbridge );
969 970
970static void __init asus_hides_smbus_lpc(struct pci_dev *dev) 971static void __init asus_hides_smbus_lpc(struct pci_dev *dev)
971{ 972{
@@ -990,6 +991,23 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, as
990DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc ); 991DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc );
991DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc ); 992DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc );
992 993
994static void __init asus_hides_smbus_lpc_ich6(struct pci_dev *dev)
995{
996 u32 val, rcba;
997 void __iomem *base;
998
999 if (likely(!asus_hides_smbus))
1000 return;
1001 pci_read_config_dword(dev, 0xF0, &rcba);
1002 base = ioremap_nocache(rcba & 0xFFFFC000, 0x4000); /* use bits 31:14, 16 kB aligned */
1003 if (base == NULL) return;
1004 val=readl(base + 0x3418); /* read the Function Disable register, dword mode only */
1005 writel(val & 0xFFFFFFF7, base + 0x3418); /* enable the SMBus device */
1006 iounmap(base);
1007 printk(KERN_INFO "PCI: Enabled ICH6/i801 SMBus device\n");
1008}
1009DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6 );
1010
993/* 1011/*
994 * SiS 96x south bridge: BIOS typically hides SMBus device... 1012 * SiS 96x south bridge: BIOS typically hides SMBus device...
995 */ 1013 */
@@ -1002,234 +1020,6 @@ static void __init quirk_sis_96x_smbus(struct pci_dev *dev)
1002 pci_read_config_byte(dev, 0x77, &val); 1020 pci_read_config_byte(dev, 0x77, &val);
1003} 1021}
1004 1022
1005
1006#define UHCI_USBLEGSUP 0xc0 /* legacy support */
1007#define UHCI_USBCMD 0 /* command register */
1008#define UHCI_USBSTS 2 /* status register */
1009#define UHCI_USBINTR 4 /* interrupt register */
1010#define UHCI_USBLEGSUP_DEFAULT 0x2000 /* only PIRQ enable set */
1011#define UHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
1012#define UHCI_USBCMD_GRESET (1 << 2) /* Global reset */
1013#define UHCI_USBCMD_CONFIGURE (1 << 6) /* config semaphore */
1014#define UHCI_USBSTS_HALTED (1 << 5) /* HCHalted bit */
1015
1016#define OHCI_CONTROL 0x04
1017#define OHCI_CMDSTATUS 0x08
1018#define OHCI_INTRSTATUS 0x0c
1019#define OHCI_INTRENABLE 0x10
1020#define OHCI_INTRDISABLE 0x14
1021#define OHCI_OCR (1 << 3) /* ownership change request */
1022#define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
1023#define OHCI_INTR_OC (1 << 30) /* ownership change */
1024
1025#define EHCI_HCC_PARAMS 0x08 /* extended capabilities */
1026#define EHCI_USBCMD 0 /* command register */
1027#define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
1028#define EHCI_USBSTS 4 /* status register */
1029#define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
1030#define EHCI_USBINTR 8 /* interrupt register */
1031#define EHCI_USBLEGSUP 0 /* legacy support register */
1032#define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
1033#define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
1034#define EHCI_USBLEGCTLSTS 4 /* legacy control/status */
1035#define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */
1036
1037int usb_early_handoff __devinitdata = 0;
1038static int __init usb_handoff_early(char *str)
1039{
1040 usb_early_handoff = 1;
1041 return 0;
1042}
1043__setup("usb-handoff", usb_handoff_early);
1044
1045static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev)
1046{
1047 unsigned long base = 0;
1048 int wait_time, delta;
1049 u16 val, sts;
1050 int i;
1051
1052 for (i = 0; i < PCI_ROM_RESOURCE; i++)
1053 if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
1054 base = pci_resource_start(pdev, i);
1055 break;
1056 }
1057
1058 if (!base)
1059 return;
1060
1061 /*
1062 * stop controller
1063 */
1064 sts = inw(base + UHCI_USBSTS);
1065 val = inw(base + UHCI_USBCMD);
1066 val &= ~(u16)(UHCI_USBCMD_RUN | UHCI_USBCMD_CONFIGURE);
1067 outw(val, base + UHCI_USBCMD);
1068
1069 /*
1070 * wait while it stops if it was running
1071 */
1072 if ((sts & UHCI_USBSTS_HALTED) == 0)
1073 {
1074 wait_time = 1000;
1075 delta = 100;
1076
1077 do {
1078 outw(0x1f, base + UHCI_USBSTS);
1079 udelay(delta);
1080 wait_time -= delta;
1081 val = inw(base + UHCI_USBSTS);
1082 if (val & UHCI_USBSTS_HALTED)
1083 break;
1084 } while (wait_time > 0);
1085 }
1086
1087 /*
1088 * disable interrupts & legacy support
1089 */
1090 outw(0, base + UHCI_USBINTR);
1091 outw(0x1f, base + UHCI_USBSTS);
1092 pci_read_config_word(pdev, UHCI_USBLEGSUP, &val);
1093 if (val & 0xbf)
1094 pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_DEFAULT);
1095
1096}
1097
1098static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
1099{
1100 void __iomem *base;
1101 int wait_time;
1102
1103 base = ioremap_nocache(pci_resource_start(pdev, 0),
1104 pci_resource_len(pdev, 0));
1105 if (base == NULL) return;
1106
1107 if (readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
1108 wait_time = 500; /* 0.5 seconds */
1109 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
1110 writel(OHCI_OCR, base + OHCI_CMDSTATUS);
1111 while (wait_time > 0 &&
1112 readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
1113 wait_time -= 10;
1114 msleep(10);
1115 }
1116 }
1117
1118 /*
1119 * disable interrupts
1120 */
1121 writel(~(u32)0, base + OHCI_INTRDISABLE);
1122 writel(~(u32)0, base + OHCI_INTRSTATUS);
1123
1124 iounmap(base);
1125}
1126
1127static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
1128{
1129 int wait_time, delta;
1130 void __iomem *base, *op_reg_base;
1131 u32 hcc_params, val, temp;
1132 u8 cap_length;
1133
1134 base = ioremap_nocache(pci_resource_start(pdev, 0),
1135 pci_resource_len(pdev, 0));
1136 if (base == NULL) return;
1137
1138 cap_length = readb(base);
1139 op_reg_base = base + cap_length;
1140 hcc_params = readl(base + EHCI_HCC_PARAMS);
1141 hcc_params = (hcc_params >> 8) & 0xff;
1142 if (hcc_params) {
1143 pci_read_config_dword(pdev,
1144 hcc_params + EHCI_USBLEGSUP,
1145 &val);
1146 if (((val & 0xff) == 1) && (val & EHCI_USBLEGSUP_BIOS)) {
1147 /*
1148 * Ok, BIOS is in smm mode, try to hand off...
1149 */
1150 pci_read_config_dword(pdev,
1151 hcc_params + EHCI_USBLEGCTLSTS,
1152 &temp);
1153 pci_write_config_dword(pdev,
1154 hcc_params + EHCI_USBLEGCTLSTS,
1155 temp | EHCI_USBLEGCTLSTS_SOOE);
1156 val |= EHCI_USBLEGSUP_OS;
1157 pci_write_config_dword(pdev,
1158 hcc_params + EHCI_USBLEGSUP,
1159 val);
1160
1161 wait_time = 500;
1162 do {
1163 msleep(10);
1164 wait_time -= 10;
1165 pci_read_config_dword(pdev,
1166 hcc_params + EHCI_USBLEGSUP,
1167 &val);
1168 } while (wait_time && (val & EHCI_USBLEGSUP_BIOS));
1169 if (!wait_time) {
1170 /*
1171 * well, possibly buggy BIOS...
1172 */
1173 printk(KERN_WARNING "EHCI early BIOS handoff "
1174 "failed (BIOS bug ?)\n");
1175 pci_write_config_dword(pdev,
1176 hcc_params + EHCI_USBLEGSUP,
1177 EHCI_USBLEGSUP_OS);
1178 pci_write_config_dword(pdev,
1179 hcc_params + EHCI_USBLEGCTLSTS,
1180 0);
1181 }
1182 }
1183 }
1184
1185 /*
1186 * halt EHCI & disable its interrupts in any case
1187 */
1188 val = readl(op_reg_base + EHCI_USBSTS);
1189 if ((val & EHCI_USBSTS_HALTED) == 0) {
1190 val = readl(op_reg_base + EHCI_USBCMD);
1191 val &= ~EHCI_USBCMD_RUN;
1192 writel(val, op_reg_base + EHCI_USBCMD);
1193
1194 wait_time = 2000;
1195 delta = 100;
1196 do {
1197 writel(0x3f, op_reg_base + EHCI_USBSTS);
1198 udelay(delta);
1199 wait_time -= delta;
1200 val = readl(op_reg_base + EHCI_USBSTS);
1201 if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) {
1202 break;
1203 }
1204 } while (wait_time > 0);
1205 }
1206 writel(0, op_reg_base + EHCI_USBINTR);
1207 writel(0x3f, op_reg_base + EHCI_USBSTS);
1208
1209 iounmap(base);
1210
1211 return;
1212}
1213
1214
1215
1216static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
1217{
1218 if (!usb_early_handoff)
1219 return;
1220
1221 if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x00)) { /* UHCI */
1222 quirk_usb_handoff_uhci(pdev);
1223 } else if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x10)) { /* OHCI */
1224 quirk_usb_handoff_ohci(pdev);
1225 } else if (pdev->class == ((PCI_CLASS_SERIAL_USB << 8) | 0x20)) { /* EHCI */
1226 quirk_usb_disable_ehci(pdev);
1227 }
1228
1229 return;
1230}
1231DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
1232
1233/* 1023/*
1234 * ... This is further complicated by the fact that some SiS96x south 1024 * ... This is further complicated by the fact that some SiS96x south
1235 * bridges pretend to be 85C503/5513 instead. In that case see if we 1025 * bridges pretend to be 85C503/5513 instead. In that case see if we
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index c071790cc983..87fafc08cb9d 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -13,7 +13,7 @@
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/syscalls.h> 14#include <linux/syscalls.h>
15#include <asm/uaccess.h> 15#include <asm/uaccess.h>
16 16#include "pci.h"
17 17
18asmlinkage long 18asmlinkage long
19sys_pciconfig_read(unsigned long bus, unsigned long dfn, 19sys_pciconfig_read(unsigned long bus, unsigned long dfn,
@@ -38,13 +38,13 @@ sys_pciconfig_read(unsigned long bus, unsigned long dfn,
38 lock_kernel(); 38 lock_kernel();
39 switch (len) { 39 switch (len) {
40 case 1: 40 case 1:
41 cfg_ret = pci_read_config_byte(dev, off, &byte); 41 cfg_ret = pci_user_read_config_byte(dev, off, &byte);
42 break; 42 break;
43 case 2: 43 case 2:
44 cfg_ret = pci_read_config_word(dev, off, &word); 44 cfg_ret = pci_user_read_config_word(dev, off, &word);
45 break; 45 break;
46 case 4: 46 case 4:
47 cfg_ret = pci_read_config_dword(dev, off, &dword); 47 cfg_ret = pci_user_read_config_dword(dev, off, &dword);
48 break; 48 break;
49 default: 49 default:
50 err = -EINVAL; 50 err = -EINVAL;
@@ -112,7 +112,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
112 err = get_user(byte, (u8 __user *)buf); 112 err = get_user(byte, (u8 __user *)buf);
113 if (err) 113 if (err)
114 break; 114 break;
115 err = pci_write_config_byte(dev, off, byte); 115 err = pci_user_write_config_byte(dev, off, byte);
116 if (err != PCIBIOS_SUCCESSFUL) 116 if (err != PCIBIOS_SUCCESSFUL)
117 err = -EIO; 117 err = -EIO;
118 break; 118 break;
@@ -121,7 +121,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
121 err = get_user(word, (u16 __user *)buf); 121 err = get_user(word, (u16 __user *)buf);
122 if (err) 122 if (err)
123 break; 123 break;
124 err = pci_write_config_word(dev, off, word); 124 err = pci_user_write_config_word(dev, off, word);
125 if (err != PCIBIOS_SUCCESSFUL) 125 if (err != PCIBIOS_SUCCESSFUL)
126 err = -EIO; 126 err = -EIO;
127 break; 127 break;
@@ -130,7 +130,7 @@ sys_pciconfig_write(unsigned long bus, unsigned long dfn,
130 err = get_user(dword, (u32 __user *)buf); 130 err = get_user(dword, (u32 __user *)buf);
131 if (err) 131 if (err)
132 break; 132 break;
133 err = pci_write_config_dword(dev, off, dword); 133 err = pci_user_write_config_dword(dev, off, dword);
134 if (err != PCIBIOS_SUCCESSFUL) 134 if (err != PCIBIOS_SUCCESSFUL)
135 err = -EIO; 135 err = -EIO;
136 break; 136 break;
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 470ef756252e..d90a634cebf5 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -519,30 +519,13 @@ static int au1x00_drv_pcmcia_probe(struct device *dev)
519} 519}
520 520
521 521
522static int au1x00_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level)
523{
524 int ret = 0;
525 if (level == SUSPEND_SAVE_STATE)
526 ret = pcmcia_socket_dev_suspend(dev, state);
527 return ret;
528}
529
530static int au1x00_drv_pcmcia_resume(struct device *dev, u32 level)
531{
532 int ret = 0;
533 if (level == RESUME_RESTORE_STATE)
534 ret = pcmcia_socket_dev_resume(dev);
535 return ret;
536}
537
538
539static struct device_driver au1x00_pcmcia_driver = { 522static struct device_driver au1x00_pcmcia_driver = {
540 .probe = au1x00_drv_pcmcia_probe, 523 .probe = au1x00_drv_pcmcia_probe,
541 .remove = au1x00_drv_pcmcia_remove, 524 .remove = au1x00_drv_pcmcia_remove,
542 .name = "au1x00-pcmcia", 525 .name = "au1x00-pcmcia",
543 .bus = &platform_bus_type, 526 .bus = &platform_bus_type,
544 .suspend = au1x00_drv_pcmcia_suspend, 527 .suspend = pcmcia_socket_dev_suspend,
545 .resume = au1x00_drv_pcmcia_resume 528 .resume = pcmcia_socket_dev_resume,
546}; 529};
547 530
548static struct platform_device au1x00_device = { 531static struct platform_device au1x00_device = {
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 080608c7381a..39d096b52926 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1157,7 +1157,8 @@ static struct pcmcia_callback pcmcia_bus_callback = {
1157 .requery = pcmcia_bus_rescan, 1157 .requery = pcmcia_bus_rescan,
1158}; 1158};
1159 1159
1160static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) 1160static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1161 struct class_interface *class_intf)
1161{ 1162{
1162 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1163 struct pcmcia_socket *socket = class_get_devdata(class_dev);
1163 int ret; 1164 int ret;
@@ -1192,7 +1193,8 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
1192 return 0; 1193 return 0;
1193} 1194}
1194 1195
1195static void pcmcia_bus_remove_socket(struct class_device *class_dev) 1196static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1197 struct class_interface *class_intf)
1196{ 1198{
1197 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1199 struct pcmcia_socket *socket = class_get_devdata(class_dev);
1198 1200
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index 316f8bcc878b..b57a0b98b4d6 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -844,27 +844,11 @@ static void hs_exit_socket(hs_socket_t *sp)
844 local_irq_restore(flags); 844 local_irq_restore(flags);
845} 845}
846 846
847static int hd64465_suspend(struct device *dev, pm_message_t state, u32 level)
848{
849 int ret = 0;
850 if (level == SUSPEND_SAVE_STATE)
851 ret = pcmcia_socket_dev_suspend(dev, state);
852 return ret;
853}
854
855static int hd64465_resume(struct device *dev, u32 level)
856{
857 int ret = 0;
858 if (level == RESUME_RESTORE_STATE)
859 ret = pcmcia_socket_dev_resume(dev);
860 return ret;
861}
862
863static struct device_driver hd64465_driver = { 847static struct device_driver hd64465_driver = {
864 .name = "hd64465-pcmcia", 848 .name = "hd64465-pcmcia",
865 .bus = &platform_bus_type, 849 .bus = &platform_bus_type,
866 .suspend = hd64465_suspend, 850 .suspend = pcmcia_socket_dev_suspend,
867 .resume = hd64465_resume, 851 .resume = pcmcia_socket_dev_resume,
868}; 852};
869 853
870static struct platform_device hd64465_device = { 854static struct platform_device hd64465_device = {
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index a713015e8228..4a41f67d185d 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1332,27 +1332,11 @@ static struct pccard_operations pcic_operations = {
1332 1332
1333/*====================================================================*/ 1333/*====================================================================*/
1334 1334
1335static int i82365_suspend(struct device *dev, pm_message_t state, u32 level)
1336{
1337 int ret = 0;
1338 if (level == SUSPEND_SAVE_STATE)
1339 ret = pcmcia_socket_dev_suspend(dev, state);
1340 return ret;
1341}
1342
1343static int i82365_resume(struct device *dev, u32 level)
1344{
1345 int ret = 0;
1346 if (level == RESUME_RESTORE_STATE)
1347 ret = pcmcia_socket_dev_resume(dev);
1348 return ret;
1349}
1350
1351static struct device_driver i82365_driver = { 1335static struct device_driver i82365_driver = {
1352 .name = "i82365", 1336 .name = "i82365",
1353 .bus = &platform_bus_type, 1337 .bus = &platform_bus_type,
1354 .suspend = i82365_suspend, 1338 .suspend = pcmcia_socket_dev_suspend,
1355 .resume = i82365_resume, 1339 .resume = pcmcia_socket_dev_resume,
1356}; 1340};
1357 1341
1358static struct platform_device i82365_device = { 1342static struct platform_device i82365_device = {
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 65f3ee3d4d3c..c6ed70ea4812 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -731,28 +731,11 @@ static struct pccard_operations pcc_operations = {
731 731
732/*====================================================================*/ 732/*====================================================================*/
733 733
734static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level)
735{
736 int ret = 0;
737 if (level == SUSPEND_SAVE_STATE)
738 ret = pcmcia_socket_dev_suspend(dev, state);
739 return ret;
740}
741
742static int m32r_pcc_resume(struct device *dev, u32 level)
743{
744 int ret = 0;
745 if (level == RESUME_RESTORE_STATE)
746 ret = pcmcia_socket_dev_resume(dev);
747 return ret;
748}
749
750
751static struct device_driver pcc_driver = { 734static struct device_driver pcc_driver = {
752 .name = "cfc", 735 .name = "cfc",
753 .bus = &platform_bus_type, 736 .bus = &platform_bus_type,
754 .suspend = m32r_pcc_suspend, 737 .suspend = pcmcia_socket_dev_suspend,
755 .resume = m32r_pcc_resume, 738 .resume = pcmcia_socket_dev_resume,
756}; 739};
757 740
758static struct platform_device pcc_device = { 741static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 7b14d7efd68c..3397ff28de6a 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -695,28 +695,11 @@ static struct pccard_operations pcc_operations = {
695 695
696/*====================================================================*/ 696/*====================================================================*/
697 697
698static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level)
699{
700 int ret = 0;
701 if (level == SUSPEND_SAVE_STATE)
702 ret = pcmcia_socket_dev_suspend(dev, state);
703 return ret;
704}
705
706static int m32r_pcc_resume(struct device *dev, u32 level)
707{
708 int ret = 0;
709 if (level == RESUME_RESTORE_STATE)
710 ret = pcmcia_socket_dev_resume(dev);
711 return ret;
712}
713
714
715static struct device_driver pcc_driver = { 698static struct device_driver pcc_driver = {
716 .name = "pcc", 699 .name = "pcc",
717 .bus = &platform_bus_type, 700 .bus = &platform_bus_type,
718 .suspend = m32r_pcc_suspend, 701 .suspend = pcmcia_socket_dev_suspend,
719 .resume = m32r_pcc_resume, 702 .resume = pcmcia_socket_dev_resume,
720}; 703};
721 704
722static struct platform_device pcc_device = { 705static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 94be9e51654e..2558c3cc91ec 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -329,27 +329,13 @@ static int __devexit omap_cf_remove(struct device *dev)
329 return 0; 329 return 0;
330} 330}
331 331
332static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level)
333{
334 if (level != SUSPEND_SAVE_STATE)
335 return 0;
336 return pcmcia_socket_dev_suspend(dev, mesg);
337}
338
339static int omap_cf_resume(struct device *dev, u32 level)
340{
341 if (level != RESUME_RESTORE_STATE)
342 return 0;
343 return pcmcia_socket_dev_resume(dev);
344}
345
346static struct device_driver omap_cf_driver = { 332static struct device_driver omap_cf_driver = {
347 .name = (char *) driver_name, 333 .name = (char *) driver_name,
348 .bus = &platform_bus_type, 334 .bus = &platform_bus_type,
349 .probe = omap_cf_probe, 335 .probe = omap_cf_probe,
350 .remove = __devexit_p(omap_cf_remove), 336 .remove = __devexit_p(omap_cf_remove),
351 .suspend = omap_cf_suspend, 337 .suspend = pcmcia_socket_dev_suspend,
352 .resume = omap_cf_resume, 338 .resume = pcmcia_socket_dev_resume,
353}; 339};
354 340
355static int __init omap_cf_init(void) 341static int __init omap_cf_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 325c992f7d8f..c2a12d53f6c7 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -205,32 +205,20 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev)
205} 205}
206EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); 206EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe);
207 207
208static int pxa2xx_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level) 208static int pxa2xx_drv_pcmcia_resume(struct device *dev)
209{ 209{
210 int ret = 0; 210 struct pcmcia_low_level *ops = dev->platform_data;
211 if (level == SUSPEND_SAVE_STATE) 211 int nr = ops ? ops->nr : 0;
212 ret = pcmcia_socket_dev_suspend(dev, state);
213 return ret;
214}
215 212
216static int pxa2xx_drv_pcmcia_resume(struct device *dev, u32 level) 213 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
217{ 214
218 int ret = 0; 215 return pcmcia_socket_dev_resume(dev);
219 if (level == RESUME_RESTORE_STATE)
220 {
221 struct pcmcia_low_level *ops = dev->platform_data;
222 int nr = ops ? ops->nr : 0;
223
224 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
225 ret = pcmcia_socket_dev_resume(dev);
226 }
227 return ret;
228} 216}
229 217
230static struct device_driver pxa2xx_pcmcia_driver = { 218static struct device_driver pxa2xx_pcmcia_driver = {
231 .probe = pxa2xx_drv_pcmcia_probe, 219 .probe = pxa2xx_drv_pcmcia_probe,
232 .remove = soc_common_drv_pcmcia_remove, 220 .remove = soc_common_drv_pcmcia_remove,
233 .suspend = pxa2xx_drv_pcmcia_suspend, 221 .suspend = pcmcia_socket_dev_suspend,
234 .resume = pxa2xx_drv_pcmcia_resume, 222 .resume = pxa2xx_drv_pcmcia_resume,
235 .name = "pxa2xx-pcmcia", 223 .name = "pxa2xx-pcmcia",
236 .bus = &platform_bus_type, 224 .bus = &platform_bus_type,
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index f9a5c70284b5..fc87e7e2b6b8 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -994,7 +994,8 @@ static struct class_device_attribute *pccard_rsrc_attributes[] = {
994 NULL, 994 NULL,
995}; 995};
996 996
997static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) 997static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev,
998 struct class_interface *class_intf)
998{ 999{
999 struct pcmcia_socket *s = class_get_devdata(class_dev); 1000 struct pcmcia_socket *s = class_get_devdata(class_dev);
1000 struct class_device_attribute **attr; 1001 struct class_device_attribute **attr;
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
1011 return ret; 1012 return ret;
1012} 1013}
1013 1014
1014static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev) 1015static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev,
1016 struct class_interface *class_intf)
1015{ 1017{
1016 struct pcmcia_socket *s = class_get_devdata(class_dev); 1018 struct pcmcia_socket *s = class_get_devdata(class_dev);
1017 struct class_device_attribute **attr; 1019 struct class_device_attribute **attr;
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index d4ed508b38be..b768fa81f043 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -74,29 +74,13 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
74 return ret; 74 return ret;
75} 75}
76 76
77static int sa11x0_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level)
78{
79 int ret = 0;
80 if (level == SUSPEND_SAVE_STATE)
81 ret = pcmcia_socket_dev_suspend(dev, state);
82 return ret;
83}
84
85static int sa11x0_drv_pcmcia_resume(struct device *dev, u32 level)
86{
87 int ret = 0;
88 if (level == RESUME_RESTORE_STATE)
89 ret = pcmcia_socket_dev_resume(dev);
90 return ret;
91}
92
93static struct device_driver sa11x0_pcmcia_driver = { 77static struct device_driver sa11x0_pcmcia_driver = {
94 .probe = sa11x0_drv_pcmcia_probe, 78 .probe = sa11x0_drv_pcmcia_probe,
95 .remove = soc_common_drv_pcmcia_remove, 79 .remove = soc_common_drv_pcmcia_remove,
96 .name = "sa11x0-pcmcia", 80 .name = "sa11x0-pcmcia",
97 .bus = &platform_bus_type, 81 .bus = &platform_bus_type,
98 .suspend = sa11x0_drv_pcmcia_suspend, 82 .suspend = pcmcia_socket_dev_suspend,
99 .resume = sa11x0_drv_pcmcia_resume, 83 .resume = pcmcia_socket_dev_resume,
100}; 84};
101 85
102/* sa11x0_pcmcia_init() 86/* sa11x0_pcmcia_init()
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index bb90a1448a53..81ded52c8959 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -122,7 +122,7 @@ void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
122 122
123static int pcmcia_probe(struct sa1111_dev *dev) 123static int pcmcia_probe(struct sa1111_dev *dev)
124{ 124{
125 char *base; 125 void __iomem *base;
126 126
127 if (!request_mem_region(dev->res.start, 512, 127 if (!request_mem_region(dev->res.start, 512,
128 SA1111_DRIVER_NAME(dev))) 128 SA1111_DRIVER_NAME(dev)))
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 1040a6c1a8a4..4a3150a7854c 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_attr = {
341 .write = pccard_store_cis, 341 .write = pccard_store_cis,
342}; 342};
343 343
344static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) 344static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev,
345 struct class_interface *class_intf)
345{ 346{
346 struct class_device_attribute **attr; 347 struct class_device_attribute **attr;
347 int ret = 0; 348 int ret = 0;
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev)
357 return ret; 358 return ret;
358} 359}
359 360
360static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev) 361static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev,
362 struct class_interface *class_intf)
361{ 363{
362 struct class_device_attribute **attr; 364 struct class_device_attribute **attr;
363 365
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index d5a61eae6119..f158b67f6610 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -372,27 +372,11 @@ static int __init get_tcic_id(void)
372 372
373/*====================================================================*/ 373/*====================================================================*/
374 374
375static int tcic_drv_suspend(struct device *dev, pm_message_t state, u32 level)
376{
377 int ret = 0;
378 if (level == SUSPEND_SAVE_STATE)
379 ret = pcmcia_socket_dev_suspend(dev, state);
380 return ret;
381}
382
383static int tcic_drv_resume(struct device *dev, u32 level)
384{
385 int ret = 0;
386 if (level == RESUME_RESTORE_STATE)
387 ret = pcmcia_socket_dev_resume(dev);
388 return ret;
389}
390
391static struct device_driver tcic_driver = { 375static struct device_driver tcic_driver = {
392 .name = "tcic-pcmcia", 376 .name = "tcic-pcmcia",
393 .bus = &platform_bus_type, 377 .bus = &platform_bus_type,
394 .suspend = tcic_drv_suspend, 378 .suspend = pcmcia_socket_dev_suspend,
395 .resume = tcic_drv_resume, 379 .resume = pcmcia_socket_dev_resume,
396}; 380};
397 381
398static struct platform_device tcic_device = { 382static struct platform_device tcic_device = {
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index 17bb2da6752b..3d2dca675e02 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -774,31 +774,11 @@ static int __devinit vrc4171_card_setup(char *options)
774 774
775__setup("vrc4171_card=", vrc4171_card_setup); 775__setup("vrc4171_card=", vrc4171_card_setup);
776 776
777static int vrc4171_card_suspend(struct device *dev, pm_message_t state, u32 level)
778{
779 int retval = 0;
780
781 if (level == SUSPEND_SAVE_STATE)
782 retval = pcmcia_socket_dev_suspend(dev, state);
783
784 return retval;
785}
786
787static int vrc4171_card_resume(struct device *dev, u32 level)
788{
789 int retval = 0;
790
791 if (level == RESUME_RESTORE_STATE)
792 retval = pcmcia_socket_dev_resume(dev);
793
794 return retval;
795}
796
797static struct device_driver vrc4171_card_driver = { 777static struct device_driver vrc4171_card_driver = {
798 .name = vrc4171_card_name, 778 .name = vrc4171_card_name,
799 .bus = &platform_bus_type, 779 .bus = &platform_bus_type,
800 .suspend = vrc4171_card_suspend, 780 .suspend = pcmcia_socket_dev_suspend,
801 .resume = vrc4171_card_resume, 781 .resume = pcmcia_socket_dev_resume,
802}; 782};
803 783
804static int __devinit vrc4171_card_init(void) 784static int __devinit vrc4171_card_init(void)
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index db9f952f9e3c..ec6ab65f0872 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -151,6 +151,40 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
151 readb(socket->base + 0x800 + reg + 1); 151 readb(socket->base + 0x800 + reg + 1);
152} 152}
153 153
154static ssize_t show_yenta_registers(struct device *yentadev, struct device_attribute *attr, char *buf)
155{
156 struct pci_dev *dev = to_pci_dev(yentadev);
157 struct yenta_socket *socket = pci_get_drvdata(dev);
158 int offset = 0, i;
159
160 offset = snprintf(buf, PAGE_SIZE, "CB registers:");
161 for (i = 0; i < 0x24; i += 4) {
162 unsigned val;
163 if (!(i & 15))
164 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
165 val = cb_readl(socket, i);
166 offset += snprintf(buf + offset, PAGE_SIZE - offset, " %08x", val);
167 }
168
169 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n\nExCA registers:");
170 for (i = 0; i < 0x45; i++) {
171 unsigned char val;
172 if (!(i & 7)) {
173 if (i & 8) {
174 memcpy(buf + offset, " -", 2);
175 offset += 2;
176 } else
177 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
178 }
179 val = exca_readb(socket, i);
180 offset += snprintf(buf + offset, PAGE_SIZE - offset, " %02x", val);
181 }
182 buf[offset++] = '\n';
183 return offset;
184}
185
186static DEVICE_ATTR(yenta_registers, S_IRUSR, show_yenta_registers, NULL);
187
154/* 188/*
155 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend 189 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend
156 * on what kind of card is inserted.. 190 * on what kind of card is inserted..
@@ -765,6 +799,9 @@ static void yenta_close(struct pci_dev *dev)
765{ 799{
766 struct yenta_socket *sock = pci_get_drvdata(dev); 800 struct yenta_socket *sock = pci_get_drvdata(dev);
767 801
802 /* Remove the register attributes */
803 device_remove_file(&dev->dev, &dev_attr_yenta_registers);
804
768 /* we don't want a dying socket registered */ 805 /* we don't want a dying socket registered */
769 pcmcia_unregister_socket(&sock->socket); 806 pcmcia_unregister_socket(&sock->socket);
770 807
@@ -1138,8 +1175,11 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1138 1175
1139 /* Register it with the pcmcia layer.. */ 1176 /* Register it with the pcmcia layer.. */
1140 ret = pcmcia_register_socket(&socket->socket); 1177 ret = pcmcia_register_socket(&socket->socket);
1141 if (ret == 0) 1178 if (ret == 0) {
1179 /* Add the yenta register attributes */
1180 device_create_file(&dev->dev, &dev_attr_yenta_registers);
1142 goto out; 1181 goto out;
1182 }
1143 1183
1144 unmap: 1184 unmap:
1145 iounmap(socket->base); 1185 iounmap(socket->base);
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index ed0cb1f15b4c..fcaee447d6fe 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -72,6 +72,7 @@ struct tape_class_device *register_tape_dev(
72 72
73 tcd->class_device = class_device_create( 73 tcd->class_device = class_device_create(
74 tape_class, 74 tape_class,
75 NULL,
75 tcd->char_device->dev, 76 tcd->char_device->dev,
76 device, 77 device,
77 "%s", tcd->device_name 78 "%s", tcd->device_name
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 491f00c032e8..a107fec4457a 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -787,6 +787,7 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
787 return ret; 787 return ret;
788 } 788 }
789 priv->class_device = class_device_create( 789 priv->class_device = class_device_create(
790 NULL,
790 vmlogrdr_class, 791 vmlogrdr_class,
791 MKDEV(vmlogrdr_major, priv->minor_num), 792 MKDEV(vmlogrdr_major, priv->minor_num),
792 dev, 793 dev,
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index fa09440d82e5..38f50b7129a2 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -16,7 +16,7 @@ MODULE_LICENSE("GPL");
16 16
17fsm_instance * 17fsm_instance *
18init_fsm(char *name, const char **state_names, const char **event_names, int nr_states, 18init_fsm(char *name, const char **state_names, const char **event_names, int nr_states,
19 int nr_events, const fsm_node *tmpl, int tmpl_len, int order) 19 int nr_events, const fsm_node *tmpl, int tmpl_len, gfp_t order)
20{ 20{
21 int i; 21 int i;
22 fsm_instance *this; 22 fsm_instance *this;
diff --git a/drivers/s390/net/fsm.h b/drivers/s390/net/fsm.h
index f9a011001eb6..1b8a7e7c34f3 100644
--- a/drivers/s390/net/fsm.h
+++ b/drivers/s390/net/fsm.h
@@ -110,7 +110,7 @@ extern fsm_instance *
110init_fsm(char *name, const char **state_names, 110init_fsm(char *name, const char **state_names,
111 const char **event_names, 111 const char **event_names,
112 int nr_states, int nr_events, const fsm_node *tmpl, 112 int nr_states, int nr_events, const fsm_node *tmpl,
113 int tmpl_len, int order); 113 int tmpl_len, gfp_t order);
114 114
115/** 115/**
116 * Releases an FSM 116 * Releases an FSM
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 9963479ba89f..38a2441564d7 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -275,6 +275,10 @@ qeth_is_ipa_enabled(struct qeth_ipa_info *ipa, enum qeth_ipa_funcs func)
275 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \ 275 QETH_IDX_FUNC_LEVEL_IQD_ENA_IPAT, \
276 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \ 276 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT, \
277 QETH_MAX_QUEUES,0x103}, \ 277 QETH_MAX_QUEUES,0x103}, \
278 {0x1731,0x06,0x1732,0x06,QETH_CARD_TYPE_OSN,0, \
279 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT, \
280 QETH_IDX_FUNC_LEVEL_OSAE_DIS_IPAT, \
281 QETH_MAX_QUEUES,0}, \
278 {0,0,0,0,0,0,0,0,0}} 282 {0,0,0,0,0,0,0,0,0}}
279 283
280#define QETH_REAL_CARD 1 284#define QETH_REAL_CARD 1
@@ -363,10 +367,22 @@ struct qeth_hdr_layer2 {
363 __u8 reserved2[16]; 367 __u8 reserved2[16];
364} __attribute__ ((packed)); 368} __attribute__ ((packed));
365 369
370struct qeth_hdr_osn {
371 __u8 id;
372 __u8 reserved;
373 __u16 seq_no;
374 __u16 reserved2;
375 __u16 control_flags;
376 __u16 pdu_length;
377 __u8 reserved3[18];
378 __u32 ccid;
379} __attribute__ ((packed));
380
366struct qeth_hdr { 381struct qeth_hdr {
367 union { 382 union {
368 struct qeth_hdr_layer2 l2; 383 struct qeth_hdr_layer2 l2;
369 struct qeth_hdr_layer3 l3; 384 struct qeth_hdr_layer3 l3;
385 struct qeth_hdr_osn osn;
370 } hdr; 386 } hdr;
371} __attribute__ ((packed)); 387} __attribute__ ((packed));
372 388
@@ -413,6 +429,7 @@ enum qeth_header_ids {
413 QETH_HEADER_TYPE_LAYER3 = 0x01, 429 QETH_HEADER_TYPE_LAYER3 = 0x01,
414 QETH_HEADER_TYPE_LAYER2 = 0x02, 430 QETH_HEADER_TYPE_LAYER2 = 0x02,
415 QETH_HEADER_TYPE_TSO = 0x03, 431 QETH_HEADER_TYPE_TSO = 0x03,
432 QETH_HEADER_TYPE_OSN = 0x04,
416}; 433};
417/* flags for qeth_hdr.ext_flags */ 434/* flags for qeth_hdr.ext_flags */
418#define QETH_HDR_EXT_VLAN_FRAME 0x01 435#define QETH_HDR_EXT_VLAN_FRAME 0x01
@@ -582,7 +599,6 @@ enum qeth_card_states {
582 * Protocol versions 599 * Protocol versions
583 */ 600 */
584enum qeth_prot_versions { 601enum qeth_prot_versions {
585 QETH_PROT_SNA = 0x0001,
586 QETH_PROT_IPV4 = 0x0004, 602 QETH_PROT_IPV4 = 0x0004,
587 QETH_PROT_IPV6 = 0x0006, 603 QETH_PROT_IPV6 = 0x0006,
588}; 604};
@@ -761,6 +777,11 @@ enum qeth_threads {
761 QETH_RECOVER_THREAD = 2, 777 QETH_RECOVER_THREAD = 2,
762}; 778};
763 779
780struct qeth_osn_info {
781 int (*assist_cb)(struct net_device *dev, void *data);
782 int (*data_cb)(struct sk_buff *skb);
783};
784
764struct qeth_card { 785struct qeth_card {
765 struct list_head list; 786 struct list_head list;
766 enum qeth_card_states state; 787 enum qeth_card_states state;
@@ -803,6 +824,7 @@ struct qeth_card {
803 int use_hard_stop; 824 int use_hard_stop;
804 int (*orig_hard_header)(struct sk_buff *,struct net_device *, 825 int (*orig_hard_header)(struct sk_buff *,struct net_device *,
805 unsigned short,void *,void *,unsigned); 826 unsigned short,void *,void *,unsigned);
827 struct qeth_osn_info osn_info;
806}; 828};
807 829
808struct qeth_card_list_struct { 830struct qeth_card_list_struct {
@@ -916,10 +938,12 @@ qeth_get_hlen(__u8 link_type)
916static inline unsigned short 938static inline unsigned short
917qeth_get_netdev_flags(struct qeth_card *card) 939qeth_get_netdev_flags(struct qeth_card *card)
918{ 940{
919 if (card->options.layer2) 941 if (card->options.layer2 &&
942 (card->info.type == QETH_CARD_TYPE_OSAE))
920 return 0; 943 return 0;
921 switch (card->info.type) { 944 switch (card->info.type) {
922 case QETH_CARD_TYPE_IQD: 945 case QETH_CARD_TYPE_IQD:
946 case QETH_CARD_TYPE_OSN:
923 return IFF_NOARP; 947 return IFF_NOARP;
924#ifdef CONFIG_QETH_IPV6 948#ifdef CONFIG_QETH_IPV6
925 default: 949 default:
@@ -956,9 +980,10 @@ static inline int
956qeth_get_max_mtu_for_card(int cardtype) 980qeth_get_max_mtu_for_card(int cardtype)
957{ 981{
958 switch (cardtype) { 982 switch (cardtype) {
983
959 case QETH_CARD_TYPE_UNKNOWN: 984 case QETH_CARD_TYPE_UNKNOWN:
960 return 61440;
961 case QETH_CARD_TYPE_OSAE: 985 case QETH_CARD_TYPE_OSAE:
986 case QETH_CARD_TYPE_OSN:
962 return 61440; 987 return 61440;
963 case QETH_CARD_TYPE_IQD: 988 case QETH_CARD_TYPE_IQD:
964 return 57344; 989 return 57344;
@@ -1004,6 +1029,7 @@ qeth_mtu_is_valid(struct qeth_card * card, int mtu)
1004 case QETH_CARD_TYPE_IQD: 1029 case QETH_CARD_TYPE_IQD:
1005 return ((mtu >= 576) && 1030 return ((mtu >= 576) &&
1006 (mtu <= card->info.max_mtu + 4096 - 32)); 1031 (mtu <= card->info.max_mtu + 4096 - 32));
1032 case QETH_CARD_TYPE_OSN:
1007 case QETH_CARD_TYPE_UNKNOWN: 1033 case QETH_CARD_TYPE_UNKNOWN:
1008 default: 1034 default:
1009 return 1; 1035 return 1;
@@ -1015,6 +1041,7 @@ qeth_get_arphdr_type(int cardtype, int linktype)
1015{ 1041{
1016 switch (cardtype) { 1042 switch (cardtype) {
1017 case QETH_CARD_TYPE_OSAE: 1043 case QETH_CARD_TYPE_OSAE:
1044 case QETH_CARD_TYPE_OSN:
1018 switch (linktype) { 1045 switch (linktype) {
1019 case QETH_LINK_TYPE_LANE_TR: 1046 case QETH_LINK_TYPE_LANE_TR:
1020 case QETH_LINK_TYPE_HSTR: 1047 case QETH_LINK_TYPE_HSTR:
@@ -1182,4 +1209,16 @@ qeth_fill_header(struct qeth_card *, struct qeth_hdr *,
1182extern void 1209extern void
1183qeth_flush_buffers(struct qeth_qdio_out_q *, int, int, int); 1210qeth_flush_buffers(struct qeth_qdio_out_q *, int, int, int);
1184 1211
1212extern int
1213qeth_osn_assist(struct net_device *, void *, int);
1214
1215extern int
1216qeth_osn_register(unsigned char *read_dev_no,
1217 struct net_device **,
1218 int (*assist_cb)(struct net_device *, void *),
1219 int (*data_cb)(struct sk_buff *));
1220
1221extern void
1222qeth_osn_deregister(struct net_device *);
1223
1185#endif /* __QETH_H__ */ 1224#endif /* __QETH_H__ */
diff --git a/drivers/s390/net/qeth_fs.h b/drivers/s390/net/qeth_fs.h
index 5c9a51ce91b6..c0b4c8d82c45 100644
--- a/drivers/s390/net/qeth_fs.h
+++ b/drivers/s390/net/qeth_fs.h
@@ -12,7 +12,7 @@
12#ifndef __QETH_FS_H__ 12#ifndef __QETH_FS_H__
13#define __QETH_FS_H__ 13#define __QETH_FS_H__
14 14
15#define VERSION_QETH_FS_H "$Revision: 1.9 $" 15#define VERSION_QETH_FS_H "$Revision: 1.10 $"
16 16
17extern const char *VERSION_QETH_PROC_C; 17extern const char *VERSION_QETH_PROC_C;
18extern const char *VERSION_QETH_SYS_C; 18extern const char *VERSION_QETH_SYS_C;
@@ -43,6 +43,12 @@ extern void
43qeth_remove_device_attributes(struct device *dev); 43qeth_remove_device_attributes(struct device *dev);
44 44
45extern int 45extern int
46qeth_create_device_attributes_osn(struct device *dev);
47
48extern void
49qeth_remove_device_attributes_osn(struct device *dev);
50
51extern int
46qeth_create_driver_attributes(void); 52qeth_create_driver_attributes(void);
47 53
48extern void 54extern void
@@ -108,6 +114,8 @@ qeth_get_cardname(struct qeth_card *card)
108 return " OSD Express"; 114 return " OSD Express";
109 case QETH_CARD_TYPE_IQD: 115 case QETH_CARD_TYPE_IQD:
110 return " HiperSockets"; 116 return " HiperSockets";
117 case QETH_CARD_TYPE_OSN:
118 return " OSN QDIO";
111 default: 119 default:
112 return " unknown"; 120 return " unknown";
113 } 121 }
@@ -153,6 +161,8 @@ qeth_get_cardname_short(struct qeth_card *card)
153 } 161 }
154 case QETH_CARD_TYPE_IQD: 162 case QETH_CARD_TYPE_IQD:
155 return "HiperSockets"; 163 return "HiperSockets";
164 case QETH_CARD_TYPE_OSN:
165 return "OSN";
156 default: 166 default:
157 return "unknown"; 167 return "unknown";
158 } 168 }
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index bd28e2438d7f..692003c9f896 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -196,7 +196,6 @@ qeth_notifier_register(struct task_struct *p, int signum)
196{ 196{
197 struct qeth_notify_list_struct *n_entry; 197 struct qeth_notify_list_struct *n_entry;
198 198
199
200 /*check first if entry already exists*/ 199 /*check first if entry already exists*/
201 spin_lock(&qeth_notify_lock); 200 spin_lock(&qeth_notify_lock);
202 list_for_each_entry(n_entry, &qeth_notify_list, list) { 201 list_for_each_entry(n_entry, &qeth_notify_list, list) {
@@ -1024,7 +1023,10 @@ qeth_set_intial_options(struct qeth_card *card)
1024 card->options.fake_broadcast = 0; 1023 card->options.fake_broadcast = 0;
1025 card->options.add_hhlen = DEFAULT_ADD_HHLEN; 1024 card->options.add_hhlen = DEFAULT_ADD_HHLEN;
1026 card->options.fake_ll = 0; 1025 card->options.fake_ll = 0;
1027 card->options.layer2 = 0; 1026 if (card->info.type == QETH_CARD_TYPE_OSN)
1027 card->options.layer2 = 1;
1028 else
1029 card->options.layer2 = 0;
1028} 1030}
1029 1031
1030/** 1032/**
@@ -1113,19 +1115,20 @@ qeth_determine_card_type(struct qeth_card *card)
1113 1115
1114 QETH_DBF_TEXT(setup, 2, "detcdtyp"); 1116 QETH_DBF_TEXT(setup, 2, "detcdtyp");
1115 1117
1118 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT;
1119 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
1116 while (known_devices[i][4]) { 1120 while (known_devices[i][4]) {
1117 if ((CARD_RDEV(card)->id.dev_type == known_devices[i][2]) && 1121 if ((CARD_RDEV(card)->id.dev_type == known_devices[i][2]) &&
1118 (CARD_RDEV(card)->id.dev_model == known_devices[i][3])) { 1122 (CARD_RDEV(card)->id.dev_model == known_devices[i][3])) {
1119 card->info.type = known_devices[i][4]; 1123 card->info.type = known_devices[i][4];
1124 card->qdio.no_out_queues = known_devices[i][8];
1125 card->info.is_multicast_different = known_devices[i][9];
1120 if (is_1920_device(card)) { 1126 if (is_1920_device(card)) {
1121 PRINT_INFO("Priority Queueing not able " 1127 PRINT_INFO("Priority Queueing not able "
1122 "due to hardware limitations!\n"); 1128 "due to hardware limitations!\n");
1123 card->qdio.no_out_queues = 1; 1129 card->qdio.no_out_queues = 1;
1124 card->qdio.default_out_queue = 0; 1130 card->qdio.default_out_queue = 0;
1125 } else { 1131 }
1126 card->qdio.no_out_queues = known_devices[i][8];
1127 }
1128 card->info.is_multicast_different = known_devices[i][9];
1129 return 0; 1132 return 0;
1130 } 1133 }
1131 i++; 1134 i++;
@@ -1149,6 +1152,8 @@ qeth_probe_device(struct ccwgroup_device *gdev)
1149 if (!get_device(dev)) 1152 if (!get_device(dev))
1150 return -ENODEV; 1153 return -ENODEV;
1151 1154
1155 QETH_DBF_TEXT_(setup, 2, "%s", gdev->dev.bus_id);
1156
1152 card = qeth_alloc_card(); 1157 card = qeth_alloc_card();
1153 if (!card) { 1158 if (!card) {
1154 put_device(dev); 1159 put_device(dev);
@@ -1158,28 +1163,27 @@ qeth_probe_device(struct ccwgroup_device *gdev)
1158 card->read.ccwdev = gdev->cdev[0]; 1163 card->read.ccwdev = gdev->cdev[0];
1159 card->write.ccwdev = gdev->cdev[1]; 1164 card->write.ccwdev = gdev->cdev[1];
1160 card->data.ccwdev = gdev->cdev[2]; 1165 card->data.ccwdev = gdev->cdev[2];
1161
1162 if ((rc = qeth_setup_card(card))){
1163 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
1164 put_device(dev);
1165 qeth_free_card(card);
1166 return rc;
1167 }
1168 gdev->dev.driver_data = card; 1166 gdev->dev.driver_data = card;
1169 card->gdev = gdev; 1167 card->gdev = gdev;
1170 gdev->cdev[0]->handler = qeth_irq; 1168 gdev->cdev[0]->handler = qeth_irq;
1171 gdev->cdev[1]->handler = qeth_irq; 1169 gdev->cdev[1]->handler = qeth_irq;
1172 gdev->cdev[2]->handler = qeth_irq; 1170 gdev->cdev[2]->handler = qeth_irq;
1173 1171
1174 rc = qeth_create_device_attributes(dev); 1172 if ((rc = qeth_determine_card_type(card))){
1175 if (rc) { 1173 PRINT_WARN("%s: not a valid card type\n", __func__);
1174 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
1175 put_device(dev);
1176 qeth_free_card(card);
1177 return rc;
1178 }
1179 if ((rc = qeth_setup_card(card))){
1180 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
1176 put_device(dev); 1181 put_device(dev);
1177 qeth_free_card(card); 1182 qeth_free_card(card);
1178 return rc; 1183 return rc;
1179 } 1184 }
1180 if ((rc = qeth_determine_card_type(card))){ 1185 rc = qeth_create_device_attributes(dev);
1181 PRINT_WARN("%s: not a valid card type\n", __func__); 1186 if (rc) {
1182 QETH_DBF_TEXT_(setup, 2, "3err%d", rc);
1183 put_device(dev); 1187 put_device(dev);
1184 qeth_free_card(card); 1188 qeth_free_card(card);
1185 return rc; 1189 return rc;
@@ -1660,6 +1664,8 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1660 netif_carrier_on(card->dev); 1664 netif_carrier_on(card->dev);
1661 qeth_schedule_recovery(card); 1665 qeth_schedule_recovery(card);
1662 return NULL; 1666 return NULL;
1667 case IPA_CMD_MODCCID:
1668 return cmd;
1663 case IPA_CMD_REGISTER_LOCAL_ADDR: 1669 case IPA_CMD_REGISTER_LOCAL_ADDR:
1664 QETH_DBF_TEXT(trace,3, "irla"); 1670 QETH_DBF_TEXT(trace,3, "irla");
1665 break; 1671 break;
@@ -1721,6 +1727,14 @@ qeth_send_control_data_cb(struct qeth_channel *channel,
1721 cmd = qeth_check_ipa_data(card, iob); 1727 cmd = qeth_check_ipa_data(card, iob);
1722 if ((cmd == NULL) && (card->state != CARD_STATE_DOWN)) 1728 if ((cmd == NULL) && (card->state != CARD_STATE_DOWN))
1723 goto out; 1729 goto out;
1730 /*in case of OSN : check if cmd is set */
1731 if (card->info.type == QETH_CARD_TYPE_OSN &&
1732 cmd &&
1733 cmd->hdr.command != IPA_CMD_STARTLAN &&
1734 card->osn_info.assist_cb != NULL) {
1735 card->osn_info.assist_cb(card->dev, cmd);
1736 goto out;
1737 }
1724 1738
1725 spin_lock_irqsave(&card->lock, flags); 1739 spin_lock_irqsave(&card->lock, flags);
1726 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { 1740 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) {
@@ -1737,8 +1751,7 @@ qeth_send_control_data_cb(struct qeth_channel *channel,
1737 keep_reply = reply->callback(card, 1751 keep_reply = reply->callback(card,
1738 reply, 1752 reply,
1739 (unsigned long)cmd); 1753 (unsigned long)cmd);
1740 } 1754 } else
1741 else
1742 keep_reply = reply->callback(card, 1755 keep_reply = reply->callback(card,
1743 reply, 1756 reply,
1744 (unsigned long)iob); 1757 (unsigned long)iob);
@@ -1768,6 +1781,24 @@ out:
1768 qeth_release_buffer(channel,iob); 1781 qeth_release_buffer(channel,iob);
1769} 1782}
1770 1783
1784static inline void
1785qeth_prepare_control_data(struct qeth_card *card, int len,
1786struct qeth_cmd_buffer *iob)
1787{
1788 qeth_setup_ccw(&card->write,iob->data,len);
1789 iob->callback = qeth_release_buffer;
1790
1791 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data),
1792 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH);
1793 card->seqno.trans_hdr++;
1794 memcpy(QETH_PDU_HEADER_SEQ_NO(iob->data),
1795 &card->seqno.pdu_hdr, QETH_SEQ_NO_LENGTH);
1796 card->seqno.pdu_hdr++;
1797 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob->data),
1798 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH);
1799 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1800}
1801
1771static int 1802static int
1772qeth_send_control_data(struct qeth_card *card, int len, 1803qeth_send_control_data(struct qeth_card *card, int len,
1773 struct qeth_cmd_buffer *iob, 1804 struct qeth_cmd_buffer *iob,
@@ -1778,24 +1809,11 @@ qeth_send_control_data(struct qeth_card *card, int len,
1778{ 1809{
1779 int rc; 1810 int rc;
1780 unsigned long flags; 1811 unsigned long flags;
1781 struct qeth_reply *reply; 1812 struct qeth_reply *reply = NULL;
1782 struct timer_list timer; 1813 struct timer_list timer;
1783 1814
1784 QETH_DBF_TEXT(trace, 2, "sendctl"); 1815 QETH_DBF_TEXT(trace, 2, "sendctl");
1785 1816
1786 qeth_setup_ccw(&card->write,iob->data,len);
1787
1788 memcpy(QETH_TRANSPORT_HEADER_SEQ_NO(iob->data),
1789 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH);
1790 card->seqno.trans_hdr++;
1791
1792 memcpy(QETH_PDU_HEADER_SEQ_NO(iob->data),
1793 &card->seqno.pdu_hdr, QETH_SEQ_NO_LENGTH);
1794 card->seqno.pdu_hdr++;
1795 memcpy(QETH_PDU_HEADER_ACK_SEQ_NO(iob->data),
1796 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH);
1797 iob->callback = qeth_release_buffer;
1798
1799 reply = qeth_alloc_reply(card); 1817 reply = qeth_alloc_reply(card);
1800 if (!reply) { 1818 if (!reply) {
1801 PRINT_WARN("Could no alloc qeth_reply!\n"); 1819 PRINT_WARN("Could no alloc qeth_reply!\n");
@@ -1810,10 +1828,6 @@ qeth_send_control_data(struct qeth_card *card, int len,
1810 init_timer(&timer); 1828 init_timer(&timer);
1811 timer.function = qeth_cmd_timeout; 1829 timer.function = qeth_cmd_timeout;
1812 timer.data = (unsigned long) reply; 1830 timer.data = (unsigned long) reply;
1813 if (IS_IPA(iob->data))
1814 timer.expires = jiffies + QETH_IPA_TIMEOUT;
1815 else
1816 timer.expires = jiffies + QETH_TIMEOUT;
1817 init_waitqueue_head(&reply->wait_q); 1831 init_waitqueue_head(&reply->wait_q);
1818 spin_lock_irqsave(&card->lock, flags); 1832 spin_lock_irqsave(&card->lock, flags);
1819 list_add_tail(&reply->list, &card->cmd_waiter_list); 1833 list_add_tail(&reply->list, &card->cmd_waiter_list);
@@ -1821,6 +1835,11 @@ qeth_send_control_data(struct qeth_card *card, int len,
1821 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); 1835 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1822 wait_event(card->wait_q, 1836 wait_event(card->wait_q,
1823 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0); 1837 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0);
1838 qeth_prepare_control_data(card, len, iob);
1839 if (IS_IPA(iob->data))
1840 timer.expires = jiffies + QETH_IPA_TIMEOUT;
1841 else
1842 timer.expires = jiffies + QETH_TIMEOUT;
1824 QETH_DBF_TEXT(trace, 6, "noirqpnd"); 1843 QETH_DBF_TEXT(trace, 6, "noirqpnd");
1825 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); 1844 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
1826 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, 1845 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
@@ -1848,6 +1867,62 @@ qeth_send_control_data(struct qeth_card *card, int len,
1848} 1867}
1849 1868
1850static int 1869static int
1870qeth_osn_send_control_data(struct qeth_card *card, int len,
1871 struct qeth_cmd_buffer *iob)
1872{
1873 unsigned long flags;
1874 int rc = 0;
1875
1876 QETH_DBF_TEXT(trace, 5, "osndctrd");
1877
1878 wait_event(card->wait_q,
1879 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0);
1880 qeth_prepare_control_data(card, len, iob);
1881 QETH_DBF_TEXT(trace, 6, "osnoirqp");
1882 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
1883 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw,
1884 (addr_t) iob, 0, 0);
1885 spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags);
1886 if (rc){
1887 PRINT_WARN("qeth_osn_send_control_data: "
1888 "ccw_device_start rc = %i\n", rc);
1889 QETH_DBF_TEXT_(trace, 2, " err%d", rc);
1890 qeth_release_buffer(iob->channel, iob);
1891 atomic_set(&card->write.irq_pending, 0);
1892 wake_up(&card->wait_q);
1893 }
1894 return rc;
1895}
1896
1897static inline void
1898qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1899 char prot_type)
1900{
1901 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
1902 memcpy(QETH_IPA_CMD_PROT_TYPE(iob->data),&prot_type,1);
1903 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
1904 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
1905}
1906
1907static int
1908qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1909 int data_len)
1910{
1911 u16 s1, s2;
1912
1913QETH_DBF_TEXT(trace,4,"osndipa");
1914
1915 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
1916 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
1917 s2 = (u16)data_len;
1918 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2);
1919 memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2);
1920 memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2);
1921 memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2);
1922 return qeth_osn_send_control_data(card, s1, iob);
1923}
1924
1925static int
1851qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, 1926qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1852 int (*reply_cb) 1927 int (*reply_cb)
1853 (struct qeth_card *,struct qeth_reply*, unsigned long), 1928 (struct qeth_card *,struct qeth_reply*, unsigned long),
@@ -1858,17 +1933,14 @@ qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1858 1933
1859 QETH_DBF_TEXT(trace,4,"sendipa"); 1934 QETH_DBF_TEXT(trace,4,"sendipa");
1860 1935
1861 memcpy(iob->data, IPA_PDU_HEADER, IPA_PDU_HEADER_SIZE);
1862
1863 if (card->options.layer2) 1936 if (card->options.layer2)
1864 prot_type = QETH_PROT_LAYER2; 1937 if (card->info.type == QETH_CARD_TYPE_OSN)
1938 prot_type = QETH_PROT_OSN2;
1939 else
1940 prot_type = QETH_PROT_LAYER2;
1865 else 1941 else
1866 prot_type = QETH_PROT_TCPIP; 1942 prot_type = QETH_PROT_TCPIP;
1867 1943 qeth_prepare_ipa_cmd(card,iob,prot_type);
1868 memcpy(QETH_IPA_CMD_PROT_TYPE(iob->data),&prot_type,1);
1869 memcpy(QETH_IPA_CMD_DEST_ADDR(iob->data),
1870 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH);
1871
1872 rc = qeth_send_control_data(card, IPA_CMD_LENGTH, iob, 1944 rc = qeth_send_control_data(card, IPA_CMD_LENGTH, iob,
1873 reply_cb, reply_param); 1945 reply_cb, reply_param);
1874 return rc; 1946 return rc;
@@ -2010,7 +2082,10 @@ qeth_ulp_enable(struct qeth_card *card)
2010 *(QETH_ULP_ENABLE_LINKNUM(iob->data)) = 2082 *(QETH_ULP_ENABLE_LINKNUM(iob->data)) =
2011 (__u8) card->info.portno; 2083 (__u8) card->info.portno;
2012 if (card->options.layer2) 2084 if (card->options.layer2)
2013 prot_type = QETH_PROT_LAYER2; 2085 if (card->info.type == QETH_CARD_TYPE_OSN)
2086 prot_type = QETH_PROT_OSN2;
2087 else
2088 prot_type = QETH_PROT_LAYER2;
2014 else 2089 else
2015 prot_type = QETH_PROT_TCPIP; 2090 prot_type = QETH_PROT_TCPIP;
2016 2091
@@ -2100,15 +2175,21 @@ qeth_check_for_inbound_error(struct qeth_qdio_buffer *buf,
2100} 2175}
2101 2176
2102static inline struct sk_buff * 2177static inline struct sk_buff *
2103qeth_get_skb(unsigned int length) 2178qeth_get_skb(unsigned int length, struct qeth_hdr *hdr)
2104{ 2179{
2105 struct sk_buff* skb; 2180 struct sk_buff* skb;
2181 int add_len;
2182
2183 add_len = 0;
2184 if (hdr->hdr.osn.id == QETH_HEADER_TYPE_OSN)
2185 add_len = sizeof(struct qeth_hdr);
2106#ifdef CONFIG_QETH_VLAN 2186#ifdef CONFIG_QETH_VLAN
2107 if ((skb = dev_alloc_skb(length + VLAN_HLEN))) 2187 else
2108 skb_reserve(skb, VLAN_HLEN); 2188 add_len = VLAN_HLEN;
2109#else
2110 skb = dev_alloc_skb(length);
2111#endif 2189#endif
2190 skb = dev_alloc_skb(length + add_len);
2191 if (skb && add_len)
2192 skb_reserve(skb, add_len);
2112 return skb; 2193 return skb;
2113} 2194}
2114 2195
@@ -2138,7 +2219,10 @@ qeth_get_next_skb(struct qeth_card *card, struct qdio_buffer *buffer,
2138 2219
2139 offset += sizeof(struct qeth_hdr); 2220 offset += sizeof(struct qeth_hdr);
2140 if (card->options.layer2) 2221 if (card->options.layer2)
2141 skb_len = (*hdr)->hdr.l2.pkt_length; 2222 if (card->info.type == QETH_CARD_TYPE_OSN)
2223 skb_len = (*hdr)->hdr.osn.pdu_length;
2224 else
2225 skb_len = (*hdr)->hdr.l2.pkt_length;
2142 else 2226 else
2143 skb_len = (*hdr)->hdr.l3.length; 2227 skb_len = (*hdr)->hdr.l3.length;
2144 2228
@@ -2146,15 +2230,15 @@ qeth_get_next_skb(struct qeth_card *card, struct qdio_buffer *buffer,
2146 return NULL; 2230 return NULL;
2147 if (card->options.fake_ll){ 2231 if (card->options.fake_ll){
2148 if(card->dev->type == ARPHRD_IEEE802_TR){ 2232 if(card->dev->type == ARPHRD_IEEE802_TR){
2149 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_TR))) 2233 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_TR, *hdr)))
2150 goto no_mem; 2234 goto no_mem;
2151 skb_reserve(skb,QETH_FAKE_LL_LEN_TR); 2235 skb_reserve(skb,QETH_FAKE_LL_LEN_TR);
2152 } else { 2236 } else {
2153 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_ETH))) 2237 if (!(skb = qeth_get_skb(skb_len+QETH_FAKE_LL_LEN_ETH, *hdr)))
2154 goto no_mem; 2238 goto no_mem;
2155 skb_reserve(skb,QETH_FAKE_LL_LEN_ETH); 2239 skb_reserve(skb,QETH_FAKE_LL_LEN_ETH);
2156 } 2240 }
2157 } else if (!(skb = qeth_get_skb(skb_len))) 2241 } else if (!(skb = qeth_get_skb(skb_len, *hdr)))
2158 goto no_mem; 2242 goto no_mem;
2159 data_ptr = element->addr + offset; 2243 data_ptr = element->addr + offset;
2160 while (skb_len) { 2244 while (skb_len) {
@@ -2453,8 +2537,12 @@ qeth_process_inbound_buffer(struct qeth_card *card,
2453 skb->dev = card->dev; 2537 skb->dev = card->dev;
2454 if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2) 2538 if (hdr->hdr.l2.id == QETH_HEADER_TYPE_LAYER2)
2455 vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr); 2539 vlan_tag = qeth_layer2_rebuild_skb(card, skb, hdr);
2456 else 2540 else if (hdr->hdr.l3.id == QETH_HEADER_TYPE_LAYER3)
2457 qeth_rebuild_skb(card, skb, hdr); 2541 qeth_rebuild_skb(card, skb, hdr);
2542 else { /*in case of OSN*/
2543 skb_push(skb, sizeof(struct qeth_hdr));
2544 memcpy(skb->data, hdr, sizeof(struct qeth_hdr));
2545 }
2458 /* is device UP ? */ 2546 /* is device UP ? */
2459 if (!(card->dev->flags & IFF_UP)){ 2547 if (!(card->dev->flags & IFF_UP)){
2460 dev_kfree_skb_any(skb); 2548 dev_kfree_skb_any(skb);
@@ -2465,7 +2553,10 @@ qeth_process_inbound_buffer(struct qeth_card *card,
2465 vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag); 2553 vlan_hwaccel_rx(skb, card->vlangrp, vlan_tag);
2466 else 2554 else
2467#endif 2555#endif
2468 rxrc = netif_rx(skb); 2556 if (card->info.type == QETH_CARD_TYPE_OSN)
2557 rxrc = card->osn_info.data_cb(skb);
2558 else
2559 rxrc = netif_rx(skb);
2469 card->dev->last_rx = jiffies; 2560 card->dev->last_rx = jiffies;
2470 card->stats.rx_packets++; 2561 card->stats.rx_packets++;
2471 card->stats.rx_bytes += skb->len; 2562 card->stats.rx_bytes += skb->len;
@@ -3150,8 +3241,6 @@ qeth_init_qdio_info(struct qeth_card *card)
3150 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list); 3241 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list);
3151 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list); 3242 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list);
3152 /* outbound */ 3243 /* outbound */
3153 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT;
3154 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
3155} 3244}
3156 3245
3157static int 3246static int
@@ -3466,7 +3555,7 @@ qeth_mpc_initialize(struct qeth_card *card)
3466 3555
3467 return 0; 3556 return 0;
3468out_qdio: 3557out_qdio:
3469 qeth_qdio_clear_card(card, card->info.type==QETH_CARD_TYPE_OSAE); 3558 qeth_qdio_clear_card(card, card->info.type!=QETH_CARD_TYPE_IQD);
3470 return rc; 3559 return rc;
3471} 3560}
3472 3561
@@ -3491,6 +3580,9 @@ qeth_get_netdevice(enum qeth_card_types type, enum qeth_link_types linktype)
3491 case QETH_CARD_TYPE_IQD: 3580 case QETH_CARD_TYPE_IQD:
3492 dev = alloc_netdev(0, "hsi%d", ether_setup); 3581 dev = alloc_netdev(0, "hsi%d", ether_setup);
3493 break; 3582 break;
3583 case QETH_CARD_TYPE_OSN:
3584 dev = alloc_netdev(0, "osn%d", ether_setup);
3585 break;
3494 default: 3586 default:
3495 dev = alloc_etherdev(0); 3587 dev = alloc_etherdev(0);
3496 } 3588 }
@@ -3655,7 +3747,8 @@ qeth_open(struct net_device *dev)
3655 if (card->state != CARD_STATE_SOFTSETUP) 3747 if (card->state != CARD_STATE_SOFTSETUP)
3656 return -ENODEV; 3748 return -ENODEV;
3657 3749
3658 if ( (card->options.layer2) && 3750 if ( (card->info.type != QETH_CARD_TYPE_OSN) &&
3751 (card->options.layer2) &&
3659 (!card->info.layer2_mac_registered)) { 3752 (!card->info.layer2_mac_registered)) {
3660 QETH_DBF_TEXT(trace,4,"nomacadr"); 3753 QETH_DBF_TEXT(trace,4,"nomacadr");
3661 return -EPERM; 3754 return -EPERM;
@@ -3693,6 +3786,9 @@ qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
3693{ 3786{
3694 int cast_type = RTN_UNSPEC; 3787 int cast_type = RTN_UNSPEC;
3695 3788
3789 if (card->info.type == QETH_CARD_TYPE_OSN)
3790 return cast_type;
3791
3696 if (skb->dst && skb->dst->neighbour){ 3792 if (skb->dst && skb->dst->neighbour){
3697 cast_type = skb->dst->neighbour->type; 3793 cast_type = skb->dst->neighbour->type;
3698 if ((cast_type == RTN_BROADCAST) || 3794 if ((cast_type == RTN_BROADCAST) ||
@@ -3782,13 +3878,16 @@ static inline int
3782qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb, 3878qeth_prepare_skb(struct qeth_card *card, struct sk_buff **skb,
3783 struct qeth_hdr **hdr, int ipv) 3879 struct qeth_hdr **hdr, int ipv)
3784{ 3880{
3785 int rc; 3881 int rc = 0;
3786#ifdef CONFIG_QETH_VLAN 3882#ifdef CONFIG_QETH_VLAN
3787 u16 *tag; 3883 u16 *tag;
3788#endif 3884#endif
3789 3885
3790 QETH_DBF_TEXT(trace, 6, "prepskb"); 3886 QETH_DBF_TEXT(trace, 6, "prepskb");
3791 3887 if (card->info.type == QETH_CARD_TYPE_OSN) {
3888 *hdr = (struct qeth_hdr *)(*skb)->data;
3889 return rc;
3890 }
3792 rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr)); 3891 rc = qeth_realloc_headroom(card, skb, sizeof(struct qeth_hdr));
3793 if (rc) 3892 if (rc)
3794 return rc; 3893 return rc;
@@ -4291,8 +4390,14 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4291 } 4390 }
4292 } 4391 }
4293 } 4392 }
4393 if ((card->info.type == QETH_CARD_TYPE_OSN) &&
4394 (skb->protocol == htons(ETH_P_IPV6))) {
4395 dev_kfree_skb_any(skb);
4396 return 0;
4397 }
4294 cast_type = qeth_get_cast_type(card, skb); 4398 cast_type = qeth_get_cast_type(card, skb);
4295 if ((cast_type == RTN_BROADCAST) && (card->info.broadcast_capable == 0)){ 4399 if ((cast_type == RTN_BROADCAST) &&
4400 (card->info.broadcast_capable == 0)){
4296 card->stats.tx_dropped++; 4401 card->stats.tx_dropped++;
4297 card->stats.tx_errors++; 4402 card->stats.tx_errors++;
4298 dev_kfree_skb_any(skb); 4403 dev_kfree_skb_any(skb);
@@ -4320,7 +4425,8 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
4320 QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc); 4425 QETH_DBF_TEXT_(trace, 4, "pskbe%d", rc);
4321 return rc; 4426 return rc;
4322 } 4427 }
4323 qeth_fill_header(card, hdr, skb, ipv, cast_type); 4428 if (card->info.type != QETH_CARD_TYPE_OSN)
4429 qeth_fill_header(card, hdr, skb, ipv, cast_type);
4324 } 4430 }
4325 4431
4326 if (large_send == QETH_LARGE_SEND_EDDP) { 4432 if (large_send == QETH_LARGE_SEND_EDDP) {
@@ -4381,6 +4487,7 @@ qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
4381 case MII_BMCR: /* Basic mode control register */ 4487 case MII_BMCR: /* Basic mode control register */
4382 rc = BMCR_FULLDPLX; 4488 rc = BMCR_FULLDPLX;
4383 if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH)&& 4489 if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH)&&
4490 (card->info.link_type != QETH_LINK_TYPE_OSN) &&
4384 (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH)) 4491 (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH))
4385 rc |= BMCR_SPEED100; 4492 rc |= BMCR_SPEED100;
4386 break; 4493 break;
@@ -5004,6 +5111,9 @@ qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5004 (card->state != CARD_STATE_SOFTSETUP)) 5111 (card->state != CARD_STATE_SOFTSETUP))
5005 return -ENODEV; 5112 return -ENODEV;
5006 5113
5114 if (card->info.type == QETH_CARD_TYPE_OSN)
5115 return -EPERM;
5116
5007 switch (cmd){ 5117 switch (cmd){
5008 case SIOC_QETH_ARP_SET_NO_ENTRIES: 5118 case SIOC_QETH_ARP_SET_NO_ENTRIES:
5009 if ( !capable(CAP_NET_ADMIN) || 5119 if ( !capable(CAP_NET_ADMIN) ||
@@ -5329,6 +5439,9 @@ qeth_set_multicast_list(struct net_device *dev)
5329{ 5439{
5330 struct qeth_card *card = (struct qeth_card *) dev->priv; 5440 struct qeth_card *card = (struct qeth_card *) dev->priv;
5331 5441
5442 if (card->info.type == QETH_CARD_TYPE_OSN)
5443 return ;
5444
5332 QETH_DBF_TEXT(trace,3,"setmulti"); 5445 QETH_DBF_TEXT(trace,3,"setmulti");
5333 qeth_delete_mc_addresses(card); 5446 qeth_delete_mc_addresses(card);
5334 qeth_add_multicast_ipv4(card); 5447 qeth_add_multicast_ipv4(card);
@@ -5370,6 +5483,94 @@ qeth_get_addr_buffer(enum qeth_prot_versions prot)
5370 return addr; 5483 return addr;
5371} 5484}
5372 5485
5486int
5487qeth_osn_assist(struct net_device *dev,
5488 void *data,
5489 int data_len)
5490{
5491 struct qeth_cmd_buffer *iob;
5492 struct qeth_card *card;
5493 int rc;
5494
5495 QETH_DBF_TEXT(trace, 2, "osnsdmc");
5496 if (!dev)
5497 return -ENODEV;
5498 card = (struct qeth_card *)dev->priv;
5499 if (!card)
5500 return -ENODEV;
5501 if ((card->state != CARD_STATE_UP) &&
5502 (card->state != CARD_STATE_SOFTSETUP))
5503 return -ENODEV;
5504 iob = qeth_wait_for_buffer(&card->write);
5505 memcpy(iob->data+IPA_PDU_HEADER_SIZE, data, data_len);
5506 rc = qeth_osn_send_ipa_cmd(card, iob, data_len);
5507 return rc;
5508}
5509
5510static struct net_device *
5511qeth_netdev_by_devno(unsigned char *read_dev_no)
5512{
5513 struct qeth_card *card;
5514 struct net_device *ndev;
5515 unsigned char *readno;
5516 __u16 temp_dev_no, card_dev_no;
5517 char *endp;
5518 unsigned long flags;
5519
5520 ndev = NULL;
5521 memcpy(&temp_dev_no, read_dev_no, 2);
5522 read_lock_irqsave(&qeth_card_list.rwlock, flags);
5523 list_for_each_entry(card, &qeth_card_list.list, list) {
5524 readno = CARD_RDEV_ID(card);
5525 readno += (strlen(readno) - 4);
5526 card_dev_no = simple_strtoul(readno, &endp, 16);
5527 if (card_dev_no == temp_dev_no) {
5528 ndev = card->dev;
5529 break;
5530 }
5531 }
5532 read_unlock_irqrestore(&qeth_card_list.rwlock, flags);
5533 return ndev;
5534}
5535
5536int
5537qeth_osn_register(unsigned char *read_dev_no,
5538 struct net_device **dev,
5539 int (*assist_cb)(struct net_device *, void *),
5540 int (*data_cb)(struct sk_buff *))
5541{
5542 struct qeth_card * card;
5543
5544 QETH_DBF_TEXT(trace, 2, "osnreg");
5545 *dev = qeth_netdev_by_devno(read_dev_no);
5546 if (*dev == NULL)
5547 return -ENODEV;
5548 card = (struct qeth_card *)(*dev)->priv;
5549 if (!card)
5550 return -ENODEV;
5551 if ((assist_cb == NULL) || (data_cb == NULL))
5552 return -EINVAL;
5553 card->osn_info.assist_cb = assist_cb;
5554 card->osn_info.data_cb = data_cb;
5555 return 0;
5556}
5557
5558void
5559qeth_osn_deregister(struct net_device * dev)
5560{
5561 struct qeth_card *card;
5562
5563 QETH_DBF_TEXT(trace, 2, "osndereg");
5564 if (!dev)
5565 return;
5566 card = (struct qeth_card *)dev->priv;
5567 if (!card)
5568 return;
5569 card->osn_info.assist_cb = NULL;
5570 card->osn_info.data_cb = NULL;
5571 return;
5572}
5573
5373static void 5574static void
5374qeth_delete_mc_addresses(struct qeth_card *card) 5575qeth_delete_mc_addresses(struct qeth_card *card)
5375{ 5576{
@@ -5700,6 +5901,12 @@ qeth_layer2_set_mac_address(struct net_device *dev, void *p)
5700 QETH_DBF_TEXT(trace, 3, "setmcLY3"); 5901 QETH_DBF_TEXT(trace, 3, "setmcLY3");
5701 return -EOPNOTSUPP; 5902 return -EOPNOTSUPP;
5702 } 5903 }
5904 if (card->info.type == QETH_CARD_TYPE_OSN) {
5905 PRINT_WARN("Setting MAC address on %s is not supported.\n",
5906 dev->name);
5907 QETH_DBF_TEXT(trace, 3, "setmcOSN");
5908 return -EOPNOTSUPP;
5909 }
5703 QETH_DBF_TEXT_(trace, 3, "%s", CARD_BUS_ID(card)); 5910 QETH_DBF_TEXT_(trace, 3, "%s", CARD_BUS_ID(card));
5704 QETH_DBF_HEX(trace, 3, addr->sa_data, OSA_ADDR_LEN); 5911 QETH_DBF_HEX(trace, 3, addr->sa_data, OSA_ADDR_LEN);
5705 rc = qeth_layer2_send_delmac(card, &card->dev->dev_addr[0]); 5912 rc = qeth_layer2_send_delmac(card, &card->dev->dev_addr[0]);
@@ -6076,9 +6283,8 @@ qeth_netdev_init(struct net_device *dev)
6076 qeth_get_hlen(card->info.link_type) + card->options.add_hhlen; 6283 qeth_get_hlen(card->info.link_type) + card->options.add_hhlen;
6077 dev->addr_len = OSA_ADDR_LEN; 6284 dev->addr_len = OSA_ADDR_LEN;
6078 dev->mtu = card->info.initial_mtu; 6285 dev->mtu = card->info.initial_mtu;
6079 6286 if (card->info.type != QETH_CARD_TYPE_OSN)
6080 SET_ETHTOOL_OPS(dev, &qeth_ethtool_ops); 6287 SET_ETHTOOL_OPS(dev, &qeth_ethtool_ops);
6081
6082 SET_MODULE_OWNER(dev); 6288 SET_MODULE_OWNER(dev);
6083 return 0; 6289 return 0;
6084} 6290}
@@ -6095,6 +6301,7 @@ qeth_init_func_level(struct qeth_card *card)
6095 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT; 6301 QETH_IDX_FUNC_LEVEL_OSAE_ENA_IPAT;
6096 } else { 6302 } else {
6097 if (card->info.type == QETH_CARD_TYPE_IQD) 6303 if (card->info.type == QETH_CARD_TYPE_IQD)
6304 /*FIXME:why do we have same values for dis and ena for osae??? */
6098 card->info.func_level = 6305 card->info.func_level =
6099 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT; 6306 QETH_IDX_FUNC_LEVEL_IQD_DIS_IPAT;
6100 else 6307 else
@@ -6124,7 +6331,7 @@ retry:
6124 ccw_device_set_online(CARD_WDEV(card)); 6331 ccw_device_set_online(CARD_WDEV(card));
6125 ccw_device_set_online(CARD_DDEV(card)); 6332 ccw_device_set_online(CARD_DDEV(card));
6126 } 6333 }
6127 rc = qeth_qdio_clear_card(card,card->info.type==QETH_CARD_TYPE_OSAE); 6334 rc = qeth_qdio_clear_card(card,card->info.type!=QETH_CARD_TYPE_IQD);
6128 if (rc == -ERESTARTSYS) { 6335 if (rc == -ERESTARTSYS) {
6129 QETH_DBF_TEXT(setup, 2, "break1"); 6336 QETH_DBF_TEXT(setup, 2, "break1");
6130 return rc; 6337 return rc;
@@ -6176,8 +6383,8 @@ retry:
6176 card->dev = qeth_get_netdevice(card->info.type, 6383 card->dev = qeth_get_netdevice(card->info.type,
6177 card->info.link_type); 6384 card->info.link_type);
6178 if (!card->dev){ 6385 if (!card->dev){
6179 qeth_qdio_clear_card(card, card->info.type == 6386 qeth_qdio_clear_card(card, card->info.type !=
6180 QETH_CARD_TYPE_OSAE); 6387 QETH_CARD_TYPE_IQD);
6181 rc = -ENODEV; 6388 rc = -ENODEV;
6182 QETH_DBF_TEXT_(setup, 2, "6err%d", rc); 6389 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
6183 goto out; 6390 goto out;
@@ -7084,6 +7291,8 @@ qeth_softsetup_card(struct qeth_card *card)
7084 return rc; 7291 return rc;
7085 } else 7292 } else
7086 card->lan_online = 1; 7293 card->lan_online = 1;
7294 if (card->info.type==QETH_CARD_TYPE_OSN)
7295 goto out;
7087 if (card->options.layer2) { 7296 if (card->options.layer2) {
7088 card->dev->features |= 7297 card->dev->features |=
7089 NETIF_F_HW_VLAN_FILTER | 7298 NETIF_F_HW_VLAN_FILTER |
@@ -7255,7 +7464,8 @@ qeth_stop_card(struct qeth_card *card, int recovery_mode)
7255 if (card->read.state == CH_STATE_UP && 7464 if (card->read.state == CH_STATE_UP &&
7256 card->write.state == CH_STATE_UP && 7465 card->write.state == CH_STATE_UP &&
7257 (card->state == CARD_STATE_UP)) { 7466 (card->state == CARD_STATE_UP)) {
7258 if(recovery_mode) { 7467 if (recovery_mode &&
7468 card->info.type != QETH_CARD_TYPE_OSN) {
7259 qeth_stop(card->dev); 7469 qeth_stop(card->dev);
7260 } else { 7470 } else {
7261 rtnl_lock(); 7471 rtnl_lock();
@@ -7437,7 +7647,8 @@ qeth_start_again(struct qeth_card *card, int recovery_mode)
7437{ 7647{
7438 QETH_DBF_TEXT(setup ,2, "startag"); 7648 QETH_DBF_TEXT(setup ,2, "startag");
7439 7649
7440 if(recovery_mode) { 7650 if (recovery_mode &&
7651 card->info.type != QETH_CARD_TYPE_OSN) {
7441 qeth_open(card->dev); 7652 qeth_open(card->dev);
7442 } else { 7653 } else {
7443 rtnl_lock(); 7654 rtnl_lock();
@@ -7469,33 +7680,36 @@ qeth_start_again(struct qeth_card *card, int recovery_mode)
7469static void qeth_make_parameters_consistent(struct qeth_card *card) 7680static void qeth_make_parameters_consistent(struct qeth_card *card)
7470{ 7681{
7471 7682
7472 if (card->options.layer2) { 7683 if (card->options.layer2 == 0)
7473 if (card->info.type == QETH_CARD_TYPE_IQD) { 7684 return;
7474 PRINT_ERR("Device %s does not support " \ 7685 if (card->info.type == QETH_CARD_TYPE_OSN)
7475 "layer 2 functionality. " \ 7686 return;
7476 "Ignoring layer2 option.\n",CARD_BUS_ID(card)); 7687 if (card->info.type == QETH_CARD_TYPE_IQD) {
7477 } 7688 PRINT_ERR("Device %s does not support layer 2 functionality." \
7478 IGNORE_PARAM_NEQ(route4.type, NO_ROUTER, NO_ROUTER, 7689 " Ignoring layer2 option.\n",CARD_BUS_ID(card));
7479 "Routing options are"); 7690 card->options.layer2 = 0;
7691 return;
7692 }
7693 IGNORE_PARAM_NEQ(route4.type, NO_ROUTER, NO_ROUTER,
7694 "Routing options are");
7480#ifdef CONFIG_QETH_IPV6 7695#ifdef CONFIG_QETH_IPV6
7481 IGNORE_PARAM_NEQ(route6.type, NO_ROUTER, NO_ROUTER, 7696 IGNORE_PARAM_NEQ(route6.type, NO_ROUTER, NO_ROUTER,
7482 "Routing options are"); 7697 "Routing options are");
7483#endif 7698#endif
7484 IGNORE_PARAM_EQ(checksum_type, HW_CHECKSUMMING, 7699 IGNORE_PARAM_EQ(checksum_type, HW_CHECKSUMMING,
7485 QETH_CHECKSUM_DEFAULT, 7700 QETH_CHECKSUM_DEFAULT,
7486 "Checksumming options are"); 7701 "Checksumming options are");
7487 IGNORE_PARAM_NEQ(broadcast_mode, QETH_TR_BROADCAST_ALLRINGS, 7702 IGNORE_PARAM_NEQ(broadcast_mode, QETH_TR_BROADCAST_ALLRINGS,
7488 QETH_TR_BROADCAST_ALLRINGS, 7703 QETH_TR_BROADCAST_ALLRINGS,
7489 "Broadcast mode options are"); 7704 "Broadcast mode options are");
7490 IGNORE_PARAM_NEQ(macaddr_mode, QETH_TR_MACADDR_NONCANONICAL, 7705 IGNORE_PARAM_NEQ(macaddr_mode, QETH_TR_MACADDR_NONCANONICAL,
7491 QETH_TR_MACADDR_NONCANONICAL, 7706 QETH_TR_MACADDR_NONCANONICAL,
7492 "Canonical MAC addr options are"); 7707 "Canonical MAC addr options are");
7493 IGNORE_PARAM_NEQ(fake_broadcast, 0, 0, 7708 IGNORE_PARAM_NEQ(fake_broadcast, 0, 0,
7494 "Broadcast faking options are"); 7709 "Broadcast faking options are");
7495 IGNORE_PARAM_NEQ(add_hhlen, DEFAULT_ADD_HHLEN, 7710 IGNORE_PARAM_NEQ(add_hhlen, DEFAULT_ADD_HHLEN,
7496 DEFAULT_ADD_HHLEN,"Option add_hhlen is"); 7711 DEFAULT_ADD_HHLEN,"Option add_hhlen is");
7497 IGNORE_PARAM_NEQ(fake_ll, 0, 0,"Option fake_ll is"); 7712 IGNORE_PARAM_NEQ(fake_ll, 0, 0,"Option fake_ll is");
7498 }
7499} 7713}
7500 7714
7501 7715
@@ -7525,8 +7739,7 @@ __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
7525 return -EIO; 7739 return -EIO;
7526 } 7740 }
7527 7741
7528 if (card->options.layer2) 7742 qeth_make_parameters_consistent(card);
7529 qeth_make_parameters_consistent(card);
7530 7743
7531 if ((rc = qeth_hardsetup_card(card))){ 7744 if ((rc = qeth_hardsetup_card(card))){
7532 QETH_DBF_TEXT_(setup, 2, "2err%d", rc); 7745 QETH_DBF_TEXT_(setup, 2, "2err%d", rc);
@@ -7585,6 +7798,7 @@ qeth_set_online(struct ccwgroup_device *gdev)
7585static struct ccw_device_id qeth_ids[] = { 7798static struct ccw_device_id qeth_ids[] = {
7586 {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE}, 7799 {CCW_DEVICE(0x1731, 0x01), driver_info:QETH_CARD_TYPE_OSAE},
7587 {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD}, 7800 {CCW_DEVICE(0x1731, 0x05), driver_info:QETH_CARD_TYPE_IQD},
7801 {CCW_DEVICE(0x1731, 0x06), driver_info:QETH_CARD_TYPE_OSN},
7588 {}, 7802 {},
7589}; 7803};
7590MODULE_DEVICE_TABLE(ccw, qeth_ids); 7804MODULE_DEVICE_TABLE(ccw, qeth_ids);
@@ -8329,6 +8543,9 @@ again:
8329 printk("qeth: removed\n"); 8543 printk("qeth: removed\n");
8330} 8544}
8331 8545
8546EXPORT_SYMBOL(qeth_osn_register);
8547EXPORT_SYMBOL(qeth_osn_deregister);
8548EXPORT_SYMBOL(qeth_osn_assist);
8332module_init(qeth_init); 8549module_init(qeth_init);
8333module_exit(qeth_exit); 8550module_exit(qeth_exit);
8334MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>"); 8551MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>");
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c
index f685ecc7da99..30e053d3cac2 100644
--- a/drivers/s390/net/qeth_mpc.c
+++ b/drivers/s390/net/qeth_mpc.c
@@ -11,7 +11,7 @@
11#include <asm/cio.h> 11#include <asm/cio.h>
12#include "qeth_mpc.h" 12#include "qeth_mpc.h"
13 13
14const char *VERSION_QETH_MPC_C = "$Revision: 1.11 $"; 14const char *VERSION_QETH_MPC_C = "$Revision: 1.12 $";
15 15
16unsigned char IDX_ACTIVATE_READ[]={ 16unsigned char IDX_ACTIVATE_READ[]={
17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, 17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00,
@@ -138,7 +138,9 @@ unsigned char IPA_PDU_HEADER[]={
138 sizeof(struct qeth_ipa_cmd)%256, 138 sizeof(struct qeth_ipa_cmd)%256,
139 0x00, 139 0x00,
140 sizeof(struct qeth_ipa_cmd)/256, 140 sizeof(struct qeth_ipa_cmd)/256,
141 sizeof(struct qeth_ipa_cmd),0x05, 0x77,0x77,0x77,0x77, 141 sizeof(struct qeth_ipa_cmd)%256,
142 0x05,
143 0x77,0x77,0x77,0x77,
142 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 144 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
143 0x01,0x00, 145 0x01,0x00,
144 sizeof(struct qeth_ipa_cmd)/256, 146 sizeof(struct qeth_ipa_cmd)/256,
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 3d916b5c5d09..7edc5f1fc0d2 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -46,13 +46,16 @@ extern unsigned char IPA_PDU_HEADER[];
46/* IP Assist related definitions */ 46/* IP Assist related definitions */
47/*****************************************************************************/ 47/*****************************************************************************/
48#define IPA_CMD_INITIATOR_HOST 0x00 48#define IPA_CMD_INITIATOR_HOST 0x00
49#define IPA_CMD_INITIATOR_HYDRA 0x01 49#define IPA_CMD_INITIATOR_OSA 0x01
50#define IPA_CMD_INITIATOR_HOST_REPLY 0x80
51#define IPA_CMD_INITIATOR_OSA_REPLY 0x81
50#define IPA_CMD_PRIM_VERSION_NO 0x01 52#define IPA_CMD_PRIM_VERSION_NO 0x01
51 53
52enum qeth_card_types { 54enum qeth_card_types {
53 QETH_CARD_TYPE_UNKNOWN = 0, 55 QETH_CARD_TYPE_UNKNOWN = 0,
54 QETH_CARD_TYPE_OSAE = 10, 56 QETH_CARD_TYPE_OSAE = 10,
55 QETH_CARD_TYPE_IQD = 1234, 57 QETH_CARD_TYPE_IQD = 1234,
58 QETH_CARD_TYPE_OSN = 11,
56}; 59};
57 60
58#define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18 61#define QETH_MPC_DIFINFO_LEN_INDICATES_LINK_TYPE 0x18
@@ -61,6 +64,7 @@ enum qeth_link_types {
61 QETH_LINK_TYPE_FAST_ETH = 0x01, 64 QETH_LINK_TYPE_FAST_ETH = 0x01,
62 QETH_LINK_TYPE_HSTR = 0x02, 65 QETH_LINK_TYPE_HSTR = 0x02,
63 QETH_LINK_TYPE_GBIT_ETH = 0x03, 66 QETH_LINK_TYPE_GBIT_ETH = 0x03,
67 QETH_LINK_TYPE_OSN = 0x04,
64 QETH_LINK_TYPE_10GBIT_ETH = 0x10, 68 QETH_LINK_TYPE_10GBIT_ETH = 0x10,
65 QETH_LINK_TYPE_LANE_ETH100 = 0x81, 69 QETH_LINK_TYPE_LANE_ETH100 = 0x81,
66 QETH_LINK_TYPE_LANE_TR = 0x82, 70 QETH_LINK_TYPE_LANE_TR = 0x82,
@@ -111,6 +115,9 @@ enum qeth_ipa_cmds {
111 IPA_CMD_DELGMAC = 0x24, 115 IPA_CMD_DELGMAC = 0x24,
112 IPA_CMD_SETVLAN = 0x25, 116 IPA_CMD_SETVLAN = 0x25,
113 IPA_CMD_DELVLAN = 0x26, 117 IPA_CMD_DELVLAN = 0x26,
118 IPA_CMD_SETCCID = 0x41,
119 IPA_CMD_DELCCID = 0x42,
120 IPA_CMD_MODCCID = 0x43,
114 IPA_CMD_SETIP = 0xb1, 121 IPA_CMD_SETIP = 0xb1,
115 IPA_CMD_DELIP = 0xb7, 122 IPA_CMD_DELIP = 0xb7,
116 IPA_CMD_QIPASSIST = 0xb2, 123 IPA_CMD_QIPASSIST = 0xb2,
@@ -437,8 +444,9 @@ enum qeth_ipa_arp_return_codes {
437#define QETH_ARP_DATA_SIZE 3968 444#define QETH_ARP_DATA_SIZE 3968
438#define QETH_ARP_CMD_LEN (QETH_ARP_DATA_SIZE + 8) 445#define QETH_ARP_CMD_LEN (QETH_ARP_DATA_SIZE + 8)
439/* Helper functions */ 446/* Helper functions */
440#define IS_IPA_REPLY(cmd) (cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) 447#define IS_IPA_REPLY(cmd) ((cmd->hdr.initiator == IPA_CMD_INITIATOR_HOST) || \
441 448 (cmd->hdr.initiator == IPA_CMD_INITIATOR_OSA_REPLY))
449
442/*****************************************************************************/ 450/*****************************************************************************/
443/* END OF IP Assist related definitions */ 451/* END OF IP Assist related definitions */
444/*****************************************************************************/ 452/*****************************************************************************/
@@ -483,6 +491,7 @@ extern unsigned char ULP_ENABLE[];
483/* Layer 2 defintions */ 491/* Layer 2 defintions */
484#define QETH_PROT_LAYER2 0x08 492#define QETH_PROT_LAYER2 0x08
485#define QETH_PROT_TCPIP 0x03 493#define QETH_PROT_TCPIP 0x03
494#define QETH_PROT_OSN2 0x0a
486#define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50) 495#define QETH_ULP_ENABLE_PROT_TYPE(buffer) (buffer+0x50)
487#define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19) 496#define QETH_IPA_CMD_PROT_TYPE(buffer) (buffer+0x19)
488 497
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index dda105b73063..f91a02db5743 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.54 $) 3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.55 $)
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to sysfs. 6 * This file contains code related to sysfs.
@@ -20,7 +20,7 @@
20#include "qeth_mpc.h" 20#include "qeth_mpc.h"
21#include "qeth_fs.h" 21#include "qeth_fs.h"
22 22
23const char *VERSION_QETH_SYS_C = "$Revision: 1.54 $"; 23const char *VERSION_QETH_SYS_C = "$Revision: 1.55 $";
24 24
25/*****************************************************************************/ 25/*****************************************************************************/
26/* */ 26/* */
@@ -937,6 +937,19 @@ static struct attribute_group qeth_device_attr_group = {
937 .attrs = (struct attribute **)qeth_device_attrs, 937 .attrs = (struct attribute **)qeth_device_attrs,
938}; 938};
939 939
940static struct device_attribute * qeth_osn_device_attrs[] = {
941 &dev_attr_state,
942 &dev_attr_chpid,
943 &dev_attr_if_name,
944 &dev_attr_card_type,
945 &dev_attr_buffer_count,
946 &dev_attr_recover,
947 NULL,
948};
949
950static struct attribute_group qeth_osn_device_attr_group = {
951 .attrs = (struct attribute **)qeth_osn_device_attrs,
952};
940 953
941#define QETH_DEVICE_ATTR(_id,_name,_mode,_show,_store) \ 954#define QETH_DEVICE_ATTR(_id,_name,_mode,_show,_store) \
942struct device_attribute dev_attr_##_id = { \ 955struct device_attribute dev_attr_##_id = { \
@@ -1667,7 +1680,12 @@ int
1667qeth_create_device_attributes(struct device *dev) 1680qeth_create_device_attributes(struct device *dev)
1668{ 1681{
1669 int ret; 1682 int ret;
1683 struct qeth_card *card = dev->driver_data;
1670 1684
1685 if (card->info.type == QETH_CARD_TYPE_OSN)
1686 return sysfs_create_group(&dev->kobj,
1687 &qeth_osn_device_attr_group);
1688
1671 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group))) 1689 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_attr_group)))
1672 return ret; 1690 return ret;
1673 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group))){ 1691 if ((ret = sysfs_create_group(&dev->kobj, &qeth_device_ipato_group))){
@@ -1693,6 +1711,12 @@ qeth_create_device_attributes(struct device *dev)
1693void 1711void
1694qeth_remove_device_attributes(struct device *dev) 1712qeth_remove_device_attributes(struct device *dev)
1695{ 1713{
1714 struct qeth_card *card = dev->driver_data;
1715
1716 if (card->info.type == QETH_CARD_TYPE_OSN)
1717 return sysfs_remove_group(&dev->kobj,
1718 &qeth_osn_device_attr_group);
1719
1696 sysfs_remove_group(&dev->kobj, &qeth_device_attr_group); 1720 sysfs_remove_group(&dev->kobj, &qeth_device_attr_group);
1697 sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group); 1721 sysfs_remove_group(&dev->kobj, &qeth_device_ipato_group);
1698 sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group); 1722 sysfs_remove_group(&dev->kobj, &qeth_device_vipa_group);
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 3ee9b8b33be0..9c9f162bd6ed 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -489,11 +489,11 @@ config SCSI_SATA_NV
489 489
490 If unsure, say N. 490 If unsure, say N.
491 491
492config SCSI_SATA_PROMISE 492config SCSI_PDC_ADMA
493 tristate "Promise SATA TX2/TX4 support" 493 tristate "Pacific Digital ADMA support"
494 depends on SCSI_SATA && PCI 494 depends on SCSI_SATA && PCI
495 help 495 help
496 This option enables support for Promise Serial ATA TX2/TX4. 496 This option enables support for Pacific Digital ADMA controllers
497 497
498 If unsure, say N. 498 If unsure, say N.
499 499
@@ -505,6 +505,14 @@ config SCSI_SATA_QSTOR
505 505
506 If unsure, say N. 506 If unsure, say N.
507 507
508config SCSI_SATA_PROMISE
509 tristate "Promise SATA TX2/TX4 support"
510 depends on SCSI_SATA && PCI
511 help
512 This option enables support for Promise Serial ATA TX2/TX4.
513
514 If unsure, say N.
515
508config SCSI_SATA_SX4 516config SCSI_SATA_SX4
509 tristate "Promise SATA SX4 support" 517 tristate "Promise SATA SX4 support"
510 depends on SCSI_SATA && PCI && EXPERIMENTAL 518 depends on SCSI_SATA && PCI && EXPERIMENTAL
@@ -521,6 +529,14 @@ config SCSI_SATA_SIL
521 529
522 If unsure, say N. 530 If unsure, say N.
523 531
532config SCSI_SATA_SIL24
533 tristate "Silicon Image 3124/3132 SATA support"
534 depends on SCSI_SATA && PCI && EXPERIMENTAL
535 help
536 This option enables support for Silicon Image 3124/3132 Serial ATA.
537
538 If unsure, say N.
539
524config SCSI_SATA_SIS 540config SCSI_SATA_SIS
525 tristate "SiS 964/180 SATA support" 541 tristate "SiS 964/180 SATA support"
526 depends on SCSI_SATA && PCI && EXPERIMENTAL 542 depends on SCSI_SATA && PCI && EXPERIMENTAL
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 48529d180ca8..2d4439826c08 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -130,6 +130,7 @@ obj-$(CONFIG_SCSI_ATA_PIIX) += libata.o ata_piix.o
130obj-$(CONFIG_SCSI_SATA_PROMISE) += libata.o sata_promise.o 130obj-$(CONFIG_SCSI_SATA_PROMISE) += libata.o sata_promise.o
131obj-$(CONFIG_SCSI_SATA_QSTOR) += libata.o sata_qstor.o 131obj-$(CONFIG_SCSI_SATA_QSTOR) += libata.o sata_qstor.o
132obj-$(CONFIG_SCSI_SATA_SIL) += libata.o sata_sil.o 132obj-$(CONFIG_SCSI_SATA_SIL) += libata.o sata_sil.o
133obj-$(CONFIG_SCSI_SATA_SIL24) += libata.o sata_sil24.o
133obj-$(CONFIG_SCSI_SATA_VIA) += libata.o sata_via.o 134obj-$(CONFIG_SCSI_SATA_VIA) += libata.o sata_via.o
134obj-$(CONFIG_SCSI_SATA_VITESSE) += libata.o sata_vsc.o 135obj-$(CONFIG_SCSI_SATA_VITESSE) += libata.o sata_vsc.o
135obj-$(CONFIG_SCSI_SATA_SIS) += libata.o sata_sis.o 136obj-$(CONFIG_SCSI_SATA_SIS) += libata.o sata_sis.o
@@ -137,6 +138,7 @@ obj-$(CONFIG_SCSI_SATA_SX4) += libata.o sata_sx4.o
137obj-$(CONFIG_SCSI_SATA_NV) += libata.o sata_nv.o 138obj-$(CONFIG_SCSI_SATA_NV) += libata.o sata_nv.o
138obj-$(CONFIG_SCSI_SATA_ULI) += libata.o sata_uli.o 139obj-$(CONFIG_SCSI_SATA_ULI) += libata.o sata_uli.o
139obj-$(CONFIG_SCSI_SATA_MV) += libata.o sata_mv.o 140obj-$(CONFIG_SCSI_SATA_MV) += libata.o sata_mv.o
141obj-$(CONFIG_SCSI_PDC_ADMA) += libata.o pdc_adma.o
140 142
141obj-$(CONFIG_ARM) += arm/ 143obj-$(CONFIG_ARM) += arm/
142 144
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index c2c8fa828e24..fe8187d6f58b 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -216,7 +216,7 @@ static Scsi_Host_Template ahci_sht = {
216 .ordered_flush = 1, 216 .ordered_flush = 1,
217}; 217};
218 218
219static struct ata_port_operations ahci_ops = { 219static const struct ata_port_operations ahci_ops = {
220 .port_disable = ata_port_disable, 220 .port_disable = ata_port_disable,
221 221
222 .check_status = ahci_check_status, 222 .check_status = ahci_check_status,
@@ -407,7 +407,7 @@ static u32 ahci_scr_read (struct ata_port *ap, unsigned int sc_reg_in)
407 return 0xffffffffU; 407 return 0xffffffffU;
408 } 408 }
409 409
410 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 410 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
411} 411}
412 412
413 413
@@ -425,7 +425,7 @@ static void ahci_scr_write (struct ata_port *ap, unsigned int sc_reg_in,
425 return; 425 return;
426 } 426 }
427 427
428 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 428 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
429} 429}
430 430
431static void ahci_phy_reset(struct ata_port *ap) 431static void ahci_phy_reset(struct ata_port *ap)
@@ -453,14 +453,14 @@ static void ahci_phy_reset(struct ata_port *ap)
453 453
454static u8 ahci_check_status(struct ata_port *ap) 454static u8 ahci_check_status(struct ata_port *ap)
455{ 455{
456 void *mmio = (void *) ap->ioaddr.cmd_addr; 456 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
457 457
458 return readl(mmio + PORT_TFDATA) & 0xFF; 458 return readl(mmio + PORT_TFDATA) & 0xFF;
459} 459}
460 460
461static u8 ahci_check_err(struct ata_port *ap) 461static u8 ahci_check_err(struct ata_port *ap)
462{ 462{
463 void *mmio = (void *) ap->ioaddr.cmd_addr; 463 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
464 464
465 return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF; 465 return (readl(mmio + PORT_TFDATA) >> 8) & 0xFF;
466} 466}
@@ -672,17 +672,36 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
672 672
673 for (i = 0; i < host_set->n_ports; i++) { 673 for (i = 0; i < host_set->n_ports; i++) {
674 struct ata_port *ap; 674 struct ata_port *ap;
675 u32 tmp;
676 675
677 VPRINTK("port %u\n", i); 676 if (!(irq_stat & (1 << i)))
677 continue;
678
678 ap = host_set->ports[i]; 679 ap = host_set->ports[i];
679 tmp = irq_stat & (1 << i); 680 if (ap) {
680 if (tmp && ap) {
681 struct ata_queued_cmd *qc; 681 struct ata_queued_cmd *qc;
682 qc = ata_qc_from_tag(ap, ap->active_tag); 682 qc = ata_qc_from_tag(ap, ap->active_tag);
683 if (ahci_host_intr(ap, qc)) 683 if (!ahci_host_intr(ap, qc))
684 irq_ack |= (1 << i); 684 if (ata_ratelimit()) {
685 struct pci_dev *pdev =
686 to_pci_dev(ap->host_set->dev);
687 printk(KERN_WARNING
688 "ahci(%s): unhandled interrupt on port %u\n",
689 pci_name(pdev), i);
690 }
691
692 VPRINTK("port %u\n", i);
693 } else {
694 VPRINTK("port %u (no irq)\n", i);
695 if (ata_ratelimit()) {
696 struct pci_dev *pdev =
697 to_pci_dev(ap->host_set->dev);
698 printk(KERN_WARNING
699 "ahci(%s): interrupt on disabled port %u\n",
700 pci_name(pdev), i);
701 }
685 } 702 }
703
704 irq_ack |= (1 << i);
686 } 705 }
687 706
688 if (irq_ack) { 707 if (irq_ack) {
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index d71cef767cec..be021478f416 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -147,7 +147,7 @@ static Scsi_Host_Template piix_sht = {
147 .ordered_flush = 1, 147 .ordered_flush = 1,
148}; 148};
149 149
150static struct ata_port_operations piix_pata_ops = { 150static const struct ata_port_operations piix_pata_ops = {
151 .port_disable = ata_port_disable, 151 .port_disable = ata_port_disable,
152 .set_piomode = piix_set_piomode, 152 .set_piomode = piix_set_piomode,
153 .set_dmamode = piix_set_dmamode, 153 .set_dmamode = piix_set_dmamode,
@@ -177,7 +177,7 @@ static struct ata_port_operations piix_pata_ops = {
177 .host_stop = ata_host_stop, 177 .host_stop = ata_host_stop,
178}; 178};
179 179
180static struct ata_port_operations piix_sata_ops = { 180static const struct ata_port_operations piix_sata_ops = {
181 .port_disable = ata_port_disable, 181 .port_disable = ata_port_disable,
182 182
183 .tf_load = ata_tf_load, 183 .tf_load = ata_tf_load,
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index da6e51c7fe69..540147cb51ce 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -936,7 +936,7 @@ static int ch_probe(struct device *dev)
936 if (init) 936 if (init)
937 ch_init_elem(ch); 937 ch_init_elem(ch);
938 938
939 class_device_create(ch_sysfs_class, 939 class_device_create(ch_sysfs_class, NULL,
940 MKDEV(SCSI_CHANGER_MAJOR,ch->minor), 940 MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
941 dev, "s%s", ch->name); 941 dev, "s%s", ch->name);
942 942
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index c10e45b94b62..3d13fdee4fc2 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -1357,7 +1357,7 @@ static int port_detect(unsigned long port_base, unsigned int j,
1357 1357
1358 for (i = 0; i < shost->can_queue; i++) { 1358 for (i = 0; i < shost->can_queue; i++) {
1359 size_t sz = shost->sg_tablesize *sizeof(struct sg_list); 1359 size_t sz = shost->sg_tablesize *sizeof(struct sg_list);
1360 unsigned int gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC; 1360 gfp_t gfp_mask = (shost->unchecked_isa_dma ? GFP_DMA : 0) | GFP_ATOMIC;
1361 ha->cp[i].sglist = kmalloc(sz, gfp_mask); 1361 ha->cp[i].sglist = kmalloc(sz, gfp_mask);
1362 if (!ha->cp[i].sglist) { 1362 if (!ha->cp[i].sglist) {
1363 printk 1363 printk
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 02fe371b0ab8..f24d84538fd5 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -287,7 +287,8 @@ static void scsi_host_dev_release(struct device *dev)
287struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) 287struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
288{ 288{
289 struct Scsi_Host *shost; 289 struct Scsi_Host *shost;
290 int gfp_mask = GFP_KERNEL, rval; 290 gfp_t gfp_mask = GFP_KERNEL;
291 int rval;
291 292
292 if (sht->unchecked_isa_dma && privsize) 293 if (sht->unchecked_isa_dma && privsize)
293 gfp_mask |= __GFP_DMA; 294 gfp_mask |= __GFP_DMA;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index babd48363402..e0039dfae8e5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4944,6 +4944,7 @@ static int ipr_reset_restore_cfg_space(struct ipr_cmnd *ipr_cmd)
4944 int rc; 4944 int rc;
4945 4945
4946 ENTER; 4946 ENTER;
4947 pci_unblock_user_cfg_access(ioa_cfg->pdev);
4947 rc = pci_restore_state(ioa_cfg->pdev); 4948 rc = pci_restore_state(ioa_cfg->pdev);
4948 4949
4949 if (rc != PCIBIOS_SUCCESSFUL) { 4950 if (rc != PCIBIOS_SUCCESSFUL) {
@@ -4998,6 +4999,7 @@ static int ipr_reset_start_bist(struct ipr_cmnd *ipr_cmd)
4998 int rc; 4999 int rc;
4999 5000
5000 ENTER; 5001 ENTER;
5002 pci_block_user_cfg_access(ioa_cfg->pdev);
5001 rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START); 5003 rc = pci_write_config_byte(ioa_cfg->pdev, PCI_BIST, PCI_BIST_START);
5002 5004
5003 if (rc != PCIBIOS_SUCCESSFUL) { 5005 if (rc != PCIBIOS_SUCCESSFUL) {
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
index 4cbb6187cc44..459a4daebece 100644
--- a/drivers/scsi/lasi700.c
+++ b/drivers/scsi/lasi700.c
@@ -98,7 +98,7 @@ MODULE_DEVICE_TABLE(parisc, lasi700_ids);
98static int __init 98static int __init
99lasi700_probe(struct parisc_device *dev) 99lasi700_probe(struct parisc_device *dev)
100{ 100{
101 unsigned long base = dev->hpa + LASI_SCSI_CORE_OFFSET; 101 unsigned long base = dev->hpa.start + LASI_SCSI_CORE_OFFSET;
102 struct NCR_700_Host_Parameters *hostdata; 102 struct NCR_700_Host_Parameters *hostdata;
103 struct Scsi_Host *host; 103 struct Scsi_Host *host;
104 104
@@ -125,8 +125,6 @@ lasi700_probe(struct parisc_device *dev)
125 hostdata->dmode_extra = DMODE_FC2; 125 hostdata->dmode_extra = DMODE_FC2;
126 } 126 }
127 127
128 NCR_700_set_mem_mapped(hostdata);
129
130 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev); 128 host = NCR_700_detect(&lasi700_template, hostdata, &dev->dev);
131 if (!host) 129 if (!host)
132 goto out_kfree; 130 goto out_kfree;
@@ -168,7 +166,7 @@ lasi700_driver_remove(struct parisc_device *dev)
168} 166}
169 167
170static struct parisc_driver lasi700_driver = { 168static struct parisc_driver lasi700_driver = {
171 .name = "Lasi SCSI", 169 .name = "lasi_scsi",
172 .id_table = lasi700_ids, 170 .id_table = lasi700_ids,
173 .probe = lasi700_probe, 171 .probe = lasi700_probe,
174 .remove = __devexit_p(lasi700_driver_remove), 172 .remove = __devexit_p(lasi700_driver_remove),
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index e5b01997117a..f53d7b8ac33f 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -48,6 +48,7 @@
48#include <linux/completion.h> 48#include <linux/completion.h>
49#include <linux/suspend.h> 49#include <linux/suspend.h>
50#include <linux/workqueue.h> 50#include <linux/workqueue.h>
51#include <linux/jiffies.h>
51#include <scsi/scsi.h> 52#include <scsi/scsi.h>
52#include "scsi.h" 53#include "scsi.h"
53#include "scsi_priv.h" 54#include "scsi_priv.h"
@@ -62,14 +63,15 @@
62static unsigned int ata_busy_sleep (struct ata_port *ap, 63static unsigned int ata_busy_sleep (struct ata_port *ap,
63 unsigned long tmout_pat, 64 unsigned long tmout_pat,
64 unsigned long tmout); 65 unsigned long tmout);
66static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev);
67static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev);
65static void ata_set_mode(struct ata_port *ap); 68static void ata_set_mode(struct ata_port *ap);
66static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 69static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
67static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift); 70static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift);
68static int fgb(u32 bitmap); 71static int fgb(u32 bitmap);
69static int ata_choose_xfer_mode(struct ata_port *ap, 72static int ata_choose_xfer_mode(const struct ata_port *ap,
70 u8 *xfer_mode_out, 73 u8 *xfer_mode_out,
71 unsigned int *xfer_shift_out); 74 unsigned int *xfer_shift_out);
72static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
73static void __ata_qc_complete(struct ata_queued_cmd *qc); 75static void __ata_qc_complete(struct ata_queued_cmd *qc);
74 76
75static unsigned int ata_unique_id = 1; 77static unsigned int ata_unique_id = 1;
@@ -85,7 +87,7 @@ MODULE_LICENSE("GPL");
85MODULE_VERSION(DRV_VERSION); 87MODULE_VERSION(DRV_VERSION);
86 88
87/** 89/**
88 * ata_tf_load - send taskfile registers to host controller 90 * ata_tf_load_pio - send taskfile registers to host controller
89 * @ap: Port to which output is sent 91 * @ap: Port to which output is sent
90 * @tf: ATA taskfile register set 92 * @tf: ATA taskfile register set
91 * 93 *
@@ -95,7 +97,7 @@ MODULE_VERSION(DRV_VERSION);
95 * Inherited from caller. 97 * Inherited from caller.
96 */ 98 */
97 99
98static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf) 100static void ata_tf_load_pio(struct ata_port *ap, const struct ata_taskfile *tf)
99{ 101{
100 struct ata_ioports *ioaddr = &ap->ioaddr; 102 struct ata_ioports *ioaddr = &ap->ioaddr;
101 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 103 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -153,7 +155,7 @@ static void ata_tf_load_pio(struct ata_port *ap, struct ata_taskfile *tf)
153 * Inherited from caller. 155 * Inherited from caller.
154 */ 156 */
155 157
156static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 158static void ata_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
157{ 159{
158 struct ata_ioports *ioaddr = &ap->ioaddr; 160 struct ata_ioports *ioaddr = &ap->ioaddr;
159 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 161 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -222,7 +224,7 @@ static void ata_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
222 * LOCKING: 224 * LOCKING:
223 * Inherited from caller. 225 * Inherited from caller.
224 */ 226 */
225void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 227void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
226{ 228{
227 if (ap->flags & ATA_FLAG_MMIO) 229 if (ap->flags & ATA_FLAG_MMIO)
228 ata_tf_load_mmio(ap, tf); 230 ata_tf_load_mmio(ap, tf);
@@ -242,7 +244,7 @@ void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf)
242 * spin_lock_irqsave(host_set lock) 244 * spin_lock_irqsave(host_set lock)
243 */ 245 */
244 246
245static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf) 247static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile *tf)
246{ 248{
247 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 249 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
248 250
@@ -263,7 +265,7 @@ static void ata_exec_command_pio(struct ata_port *ap, struct ata_taskfile *tf)
263 * spin_lock_irqsave(host_set lock) 265 * spin_lock_irqsave(host_set lock)
264 */ 266 */
265 267
266static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 268static void ata_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
267{ 269{
268 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command); 270 DPRINTK("ata%u: cmd 0x%X\n", ap->id, tf->command);
269 271
@@ -283,7 +285,7 @@ static void ata_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf)
283 * LOCKING: 285 * LOCKING:
284 * spin_lock_irqsave(host_set lock) 286 * spin_lock_irqsave(host_set lock)
285 */ 287 */
286void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf) 288void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
287{ 289{
288 if (ap->flags & ATA_FLAG_MMIO) 290 if (ap->flags & ATA_FLAG_MMIO)
289 ata_exec_command_mmio(ap, tf); 291 ata_exec_command_mmio(ap, tf);
@@ -303,7 +305,7 @@ void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf)
303 * Obtains host_set lock. 305 * Obtains host_set lock.
304 */ 306 */
305 307
306static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf) 308static inline void ata_exec(struct ata_port *ap, const struct ata_taskfile *tf)
307{ 309{
308 unsigned long flags; 310 unsigned long flags;
309 311
@@ -326,7 +328,7 @@ static inline void ata_exec(struct ata_port *ap, struct ata_taskfile *tf)
326 * Obtains host_set lock. 328 * Obtains host_set lock.
327 */ 329 */
328 330
329static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf) 331static void ata_tf_to_host(struct ata_port *ap, const struct ata_taskfile *tf)
330{ 332{
331 ap->ops->tf_load(ap, tf); 333 ap->ops->tf_load(ap, tf);
332 334
@@ -346,7 +348,7 @@ static void ata_tf_to_host(struct ata_port *ap, struct ata_taskfile *tf)
346 * spin_lock_irqsave(host_set lock) 348 * spin_lock_irqsave(host_set lock)
347 */ 349 */
348 350
349void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf) 351void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf)
350{ 352{
351 ap->ops->tf_load(ap, tf); 353 ap->ops->tf_load(ap, tf);
352 ap->ops->exec_command(ap, tf); 354 ap->ops->exec_command(ap, tf);
@@ -556,7 +558,7 @@ u8 ata_chk_err(struct ata_port *ap)
556 * Inherited from caller. 558 * Inherited from caller.
557 */ 559 */
558 560
559void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp) 561void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
560{ 562{
561 fis[0] = 0x27; /* Register - Host to Device FIS */ 563 fis[0] = 0x27; /* Register - Host to Device FIS */
562 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number, 564 fis[1] = (pmp & 0xf) | (1 << 7); /* Port multiplier number,
@@ -597,7 +599,7 @@ void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp)
597 * Inherited from caller. 599 * Inherited from caller.
598 */ 600 */
599 601
600void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf) 602void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf)
601{ 603{
602 tf->command = fis[2]; /* status */ 604 tf->command = fis[2]; /* status */
603 tf->feature = fis[3]; /* error */ 605 tf->feature = fis[3]; /* error */
@@ -615,79 +617,53 @@ void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf)
615 tf->hob_nsect = fis[13]; 617 tf->hob_nsect = fis[13];
616} 618}
617 619
618/** 620static const u8 ata_rw_cmds[] = {
619 * ata_prot_to_cmd - determine which read/write opcodes to use 621 /* pio multi */
620 * @protocol: ATA_PROT_xxx taskfile protocol 622 ATA_CMD_READ_MULTI,
621 * @lba48: true is lba48 is present 623 ATA_CMD_WRITE_MULTI,
622 * 624 ATA_CMD_READ_MULTI_EXT,
623 * Given necessary input, determine which read/write commands 625 ATA_CMD_WRITE_MULTI_EXT,
624 * to use to transfer data. 626 /* pio */
625 * 627 ATA_CMD_PIO_READ,
626 * LOCKING: 628 ATA_CMD_PIO_WRITE,
627 * None. 629 ATA_CMD_PIO_READ_EXT,
628 */ 630 ATA_CMD_PIO_WRITE_EXT,
629static int ata_prot_to_cmd(int protocol, int lba48) 631 /* dma */
630{ 632 ATA_CMD_READ,
631 int rcmd = 0, wcmd = 0; 633 ATA_CMD_WRITE,
632 634 ATA_CMD_READ_EXT,
633 switch (protocol) { 635 ATA_CMD_WRITE_EXT
634 case ATA_PROT_PIO: 636};
635 if (lba48) {
636 rcmd = ATA_CMD_PIO_READ_EXT;
637 wcmd = ATA_CMD_PIO_WRITE_EXT;
638 } else {
639 rcmd = ATA_CMD_PIO_READ;
640 wcmd = ATA_CMD_PIO_WRITE;
641 }
642 break;
643
644 case ATA_PROT_DMA:
645 if (lba48) {
646 rcmd = ATA_CMD_READ_EXT;
647 wcmd = ATA_CMD_WRITE_EXT;
648 } else {
649 rcmd = ATA_CMD_READ;
650 wcmd = ATA_CMD_WRITE;
651 }
652 break;
653
654 default:
655 return -1;
656 }
657
658 return rcmd | (wcmd << 8);
659}
660 637
661/** 638/**
662 * ata_dev_set_protocol - set taskfile protocol and r/w commands 639 * ata_rwcmd_protocol - set taskfile r/w commands and protocol
663 * @dev: device to examine and configure 640 * @qc: command to examine and configure
664 * 641 *
665 * Examine the device configuration, after we have 642 * Examine the device configuration and tf->flags to calculate
666 * read the identify-device page and configured the 643 * the proper read/write commands and protocol to use.
667 * data transfer mode. Set internal state related to
668 * the ATA taskfile protocol (pio, pio mult, dma, etc.)
669 * and calculate the proper read/write commands to use.
670 * 644 *
671 * LOCKING: 645 * LOCKING:
672 * caller. 646 * caller.
673 */ 647 */
674static void ata_dev_set_protocol(struct ata_device *dev) 648void ata_rwcmd_protocol(struct ata_queued_cmd *qc)
675{ 649{
676 int pio = (dev->flags & ATA_DFLAG_PIO); 650 struct ata_taskfile *tf = &qc->tf;
677 int lba48 = (dev->flags & ATA_DFLAG_LBA48); 651 struct ata_device *dev = qc->dev;
678 int proto, cmd;
679 652
680 if (pio) 653 int index, lba48, write;
681 proto = dev->xfer_protocol = ATA_PROT_PIO; 654
682 else 655 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0;
683 proto = dev->xfer_protocol = ATA_PROT_DMA; 656 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0;
684 657
685 cmd = ata_prot_to_cmd(proto, lba48); 658 if (dev->flags & ATA_DFLAG_PIO) {
686 if (cmd < 0) 659 tf->protocol = ATA_PROT_PIO;
687 BUG(); 660 index = dev->multi_count ? 0 : 4;
661 } else {
662 tf->protocol = ATA_PROT_DMA;
663 index = 8;
664 }
688 665
689 dev->read_cmd = cmd & 0xff; 666 tf->command = ata_rw_cmds[index + lba48 + write];
690 dev->write_cmd = (cmd >> 8) & 0xff;
691} 667}
692 668
693static const char * xfer_mode_str[] = { 669static const char * xfer_mode_str[] = {
@@ -869,7 +845,7 @@ static unsigned int ata_devchk(struct ata_port *ap,
869 * the event of failure. 845 * the event of failure.
870 */ 846 */
871 847
872unsigned int ata_dev_classify(struct ata_taskfile *tf) 848unsigned int ata_dev_classify(const struct ata_taskfile *tf)
873{ 849{
874 /* Apple's open source Darwin code hints that some devices only 850 /* Apple's open source Darwin code hints that some devices only
875 * put a proper signature into the LBA mid/high registers, 851 * put a proper signature into the LBA mid/high registers,
@@ -961,7 +937,7 @@ static u8 ata_dev_try_classify(struct ata_port *ap, unsigned int device)
961 * caller. 937 * caller.
962 */ 938 */
963 939
964void ata_dev_id_string(u16 *id, unsigned char *s, 940void ata_dev_id_string(const u16 *id, unsigned char *s,
965 unsigned int ofs, unsigned int len) 941 unsigned int ofs, unsigned int len)
966{ 942{
967 unsigned int c; 943 unsigned int c;
@@ -1078,7 +1054,7 @@ void ata_dev_select(struct ata_port *ap, unsigned int device,
1078 * caller. 1054 * caller.
1079 */ 1055 */
1080 1056
1081static inline void ata_dump_id(struct ata_device *dev) 1057static inline void ata_dump_id(const struct ata_device *dev)
1082{ 1058{
1083 DPRINTK("49==0x%04x " 1059 DPRINTK("49==0x%04x "
1084 "53==0x%04x " 1060 "53==0x%04x "
@@ -1106,6 +1082,31 @@ static inline void ata_dump_id(struct ata_device *dev)
1106 dev->id[93]); 1082 dev->id[93]);
1107} 1083}
1108 1084
1085/*
1086 * Compute the PIO modes available for this device. This is not as
1087 * trivial as it seems if we must consider early devices correctly.
1088 *
1089 * FIXME: pre IDE drive timing (do we care ?).
1090 */
1091
1092static unsigned int ata_pio_modes(const struct ata_device *adev)
1093{
1094 u16 modes;
1095
1096 /* Usual case. Word 53 indicates word 88 is valid */
1097 if (adev->id[ATA_ID_FIELD_VALID] & (1 << 2)) {
1098 modes = adev->id[ATA_ID_PIO_MODES] & 0x03;
1099 modes <<= 3;
1100 modes |= 0x7;
1101 return modes;
1102 }
1103
1104 /* If word 88 isn't valid then Word 51 holds the PIO timing number
1105 for the maximum. Turn it into a mask and return it */
1106 modes = (2 << (adev->id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ;
1107 return modes;
1108}
1109
1109/** 1110/**
1110 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1111 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1111 * @ap: port on which device we wish to probe resides 1112 * @ap: port on which device we wish to probe resides
@@ -1131,7 +1132,7 @@ static inline void ata_dump_id(struct ata_device *dev)
1131static void ata_dev_identify(struct ata_port *ap, unsigned int device) 1132static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1132{ 1133{
1133 struct ata_device *dev = &ap->device[device]; 1134 struct ata_device *dev = &ap->device[device];
1134 unsigned int i; 1135 unsigned int major_version;
1135 u16 tmp; 1136 u16 tmp;
1136 unsigned long xfer_modes; 1137 unsigned long xfer_modes;
1137 u8 status; 1138 u8 status;
@@ -1229,9 +1230,9 @@ retry:
1229 * common ATA, ATAPI feature tests 1230 * common ATA, ATAPI feature tests
1230 */ 1231 */
1231 1232
1232 /* we require LBA and DMA support (bits 8 & 9 of word 49) */ 1233 /* we require DMA support (bits 8 of word 49) */
1233 if (!ata_id_has_dma(dev->id) || !ata_id_has_lba(dev->id)) { 1234 if (!ata_id_has_dma(dev->id)) {
1234 printk(KERN_DEBUG "ata%u: no dma/lba\n", ap->id); 1235 printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
1235 goto err_out_nosup; 1236 goto err_out_nosup;
1236 } 1237 }
1237 1238
@@ -1239,10 +1240,8 @@ retry:
1239 xfer_modes = dev->id[ATA_ID_UDMA_MODES]; 1240 xfer_modes = dev->id[ATA_ID_UDMA_MODES];
1240 if (!xfer_modes) 1241 if (!xfer_modes)
1241 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA; 1242 xfer_modes = (dev->id[ATA_ID_MWDMA_MODES]) << ATA_SHIFT_MWDMA;
1242 if (!xfer_modes) { 1243 if (!xfer_modes)
1243 xfer_modes = (dev->id[ATA_ID_PIO_MODES]) << (ATA_SHIFT_PIO + 3); 1244 xfer_modes = ata_pio_modes(dev);
1244 xfer_modes |= (0x7 << ATA_SHIFT_PIO);
1245 }
1246 1245
1247 ata_dump_id(dev); 1246 ata_dump_id(dev);
1248 1247
@@ -1251,32 +1250,75 @@ retry:
1251 if (!ata_id_is_ata(dev->id)) /* sanity check */ 1250 if (!ata_id_is_ata(dev->id)) /* sanity check */
1252 goto err_out_nosup; 1251 goto err_out_nosup;
1253 1252
1253 /* get major version */
1254 tmp = dev->id[ATA_ID_MAJOR_VER]; 1254 tmp = dev->id[ATA_ID_MAJOR_VER];
1255 for (i = 14; i >= 1; i--) 1255 for (major_version = 14; major_version >= 1; major_version--)
1256 if (tmp & (1 << i)) 1256 if (tmp & (1 << major_version))
1257 break; 1257 break;
1258 1258
1259 /* we require at least ATA-3 */ 1259 /*
1260 if (i < 3) { 1260 * The exact sequence expected by certain pre-ATA4 drives is:
1261 printk(KERN_DEBUG "ata%u: no ATA-3\n", ap->id); 1261 * SRST RESET
1262 goto err_out_nosup; 1262 * IDENTIFY
1263 * INITIALIZE DEVICE PARAMETERS
1264 * anything else..
1265 * Some drives were very specific about that exact sequence.
1266 */
1267 if (major_version < 4 || (!ata_id_has_lba(dev->id))) {
1268 ata_dev_init_params(ap, dev);
1269
1270 /* current CHS translation info (id[53-58]) might be
1271 * changed. reread the identify device info.
1272 */
1273 ata_dev_reread_id(ap, dev);
1263 } 1274 }
1264 1275
1265 if (ata_id_has_lba48(dev->id)) { 1276 if (ata_id_has_lba(dev->id)) {
1266 dev->flags |= ATA_DFLAG_LBA48; 1277 dev->flags |= ATA_DFLAG_LBA;
1267 dev->n_sectors = ata_id_u64(dev->id, 100); 1278
1268 } else { 1279 if (ata_id_has_lba48(dev->id)) {
1269 dev->n_sectors = ata_id_u32(dev->id, 60); 1280 dev->flags |= ATA_DFLAG_LBA48;
1281 dev->n_sectors = ata_id_u64(dev->id, 100);
1282 } else {
1283 dev->n_sectors = ata_id_u32(dev->id, 60);
1284 }
1285
1286 /* print device info to dmesg */
1287 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",
1288 ap->id, device,
1289 major_version,
1290 ata_mode_string(xfer_modes),
1291 (unsigned long long)dev->n_sectors,
1292 dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA");
1293 } else {
1294 /* CHS */
1295
1296 /* Default translation */
1297 dev->cylinders = dev->id[1];
1298 dev->heads = dev->id[3];
1299 dev->sectors = dev->id[6];
1300 dev->n_sectors = dev->cylinders * dev->heads * dev->sectors;
1301
1302 if (ata_id_current_chs_valid(dev->id)) {
1303 /* Current CHS translation is valid. */
1304 dev->cylinders = dev->id[54];
1305 dev->heads = dev->id[55];
1306 dev->sectors = dev->id[56];
1307
1308 dev->n_sectors = ata_id_u32(dev->id, 57);
1309 }
1310
1311 /* print device info to dmesg */
1312 printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n",
1313 ap->id, device,
1314 major_version,
1315 ata_mode_string(xfer_modes),
1316 (unsigned long long)dev->n_sectors,
1317 (int)dev->cylinders, (int)dev->heads, (int)dev->sectors);
1318
1270 } 1319 }
1271 1320
1272 ap->host->max_cmd_len = 16; 1321 ap->host->max_cmd_len = 16;
1273
1274 /* print device info to dmesg */
1275 printk(KERN_INFO "ata%u: dev %u ATA, max %s, %Lu sectors:%s\n",
1276 ap->id, device,
1277 ata_mode_string(xfer_modes),
1278 (unsigned long long)dev->n_sectors,
1279 dev->flags & ATA_DFLAG_LBA48 ? " lba48" : "");
1280 } 1322 }
1281 1323
1282 /* ATAPI-specific feature tests */ 1324 /* ATAPI-specific feature tests */
@@ -1310,7 +1352,7 @@ err_out:
1310} 1352}
1311 1353
1312 1354
1313static inline u8 ata_dev_knobble(struct ata_port *ap) 1355static inline u8 ata_dev_knobble(const struct ata_port *ap)
1314{ 1356{
1315 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id))); 1357 return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ap->device->id)));
1316} 1358}
@@ -1496,7 +1538,153 @@ void ata_port_disable(struct ata_port *ap)
1496 ap->flags |= ATA_FLAG_PORT_DISABLED; 1538 ap->flags |= ATA_FLAG_PORT_DISABLED;
1497} 1539}
1498 1540
1499static struct { 1541/*
1542 * This mode timing computation functionality is ported over from
1543 * drivers/ide/ide-timing.h and was originally written by Vojtech Pavlik
1544 */
1545/*
1546 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
1547 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
1548 * for PIO 5, which is a nonstandard extension and UDMA6, which
1549 * is currently supported only by Maxtor drives.
1550 */
1551
1552static const struct ata_timing ata_timing[] = {
1553
1554 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 },
1555 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 },
1556 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 },
1557 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 },
1558
1559 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 },
1560 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
1561 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
1562
1563/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
1564
1565 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
1566 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
1567 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
1568
1569 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
1570 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
1571 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
1572
1573/* { XFER_PIO_5, 20, 50, 30, 100, 50, 30, 100, 0 }, */
1574 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 },
1575 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 },
1576
1577 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 },
1578 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 },
1579 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 },
1580
1581/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */
1582
1583 { 0xFF }
1584};
1585
1586#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
1587#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
1588
1589static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
1590{
1591 q->setup = EZ(t->setup * 1000, T);
1592 q->act8b = EZ(t->act8b * 1000, T);
1593 q->rec8b = EZ(t->rec8b * 1000, T);
1594 q->cyc8b = EZ(t->cyc8b * 1000, T);
1595 q->active = EZ(t->active * 1000, T);
1596 q->recover = EZ(t->recover * 1000, T);
1597 q->cycle = EZ(t->cycle * 1000, T);
1598 q->udma = EZ(t->udma * 1000, UT);
1599}
1600
1601void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
1602 struct ata_timing *m, unsigned int what)
1603{
1604 if (what & ATA_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
1605 if (what & ATA_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
1606 if (what & ATA_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
1607 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
1608 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
1609 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
1610 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
1611 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
1612}
1613
1614static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
1615{
1616 const struct ata_timing *t;
1617
1618 for (t = ata_timing; t->mode != speed; t++)
1619 if (t->mode == 0xFF)
1620 return NULL;
1621 return t;
1622}
1623
1624int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1625 struct ata_timing *t, int T, int UT)
1626{
1627 const struct ata_timing *s;
1628 struct ata_timing p;
1629
1630 /*
1631 * Find the mode.
1632 */
1633
1634 if (!(s = ata_timing_find_mode(speed)))
1635 return -EINVAL;
1636
1637 /*
1638 * If the drive is an EIDE drive, it can tell us it needs extended
1639 * PIO/MW_DMA cycle timing.
1640 */
1641
1642 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */
1643 memset(&p, 0, sizeof(p));
1644 if(speed >= XFER_PIO_0 && speed <= XFER_SW_DMA_0) {
1645 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO];
1646 else p.cycle = p.cyc8b = adev->id[ATA_ID_EIDE_PIO_IORDY];
1647 } else if(speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) {
1648 p.cycle = adev->id[ATA_ID_EIDE_DMA_MIN];
1649 }
1650 ata_timing_merge(&p, t, t, ATA_TIMING_CYCLE | ATA_TIMING_CYC8B);
1651 }
1652
1653 /*
1654 * Convert the timing to bus clock counts.
1655 */
1656
1657 ata_timing_quantize(s, t, T, UT);
1658
1659 /*
1660 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
1661 * and some other commands. We have to ensure that the DMA cycle timing is
1662 * slower/equal than the fastest PIO timing.
1663 */
1664
1665 if (speed > XFER_PIO_4) {
1666 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
1667 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
1668 }
1669
1670 /*
1671 * Lenghten active & recovery time so that cycle time is correct.
1672 */
1673
1674 if (t->act8b + t->rec8b < t->cyc8b) {
1675 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
1676 t->rec8b = t->cyc8b - t->act8b;
1677 }
1678
1679 if (t->active + t->recover < t->cycle) {
1680 t->active += (t->cycle - (t->active + t->recover)) / 2;
1681 t->recover = t->cycle - t->active;
1682 }
1683
1684 return 0;
1685}
1686
1687static const struct {
1500 unsigned int shift; 1688 unsigned int shift;
1501 u8 base; 1689 u8 base;
1502} xfer_mode_classes[] = { 1690} xfer_mode_classes[] = {
@@ -1603,7 +1791,7 @@ static void ata_host_set_dma(struct ata_port *ap, u8 xfer_mode,
1603 */ 1791 */
1604static void ata_set_mode(struct ata_port *ap) 1792static void ata_set_mode(struct ata_port *ap)
1605{ 1793{
1606 unsigned int i, xfer_shift; 1794 unsigned int xfer_shift;
1607 u8 xfer_mode; 1795 u8 xfer_mode;
1608 int rc; 1796 int rc;
1609 1797
@@ -1632,11 +1820,6 @@ static void ata_set_mode(struct ata_port *ap)
1632 if (ap->ops->post_set_mode) 1820 if (ap->ops->post_set_mode)
1633 ap->ops->post_set_mode(ap); 1821 ap->ops->post_set_mode(ap);
1634 1822
1635 for (i = 0; i < 2; i++) {
1636 struct ata_device *dev = &ap->device[i];
1637 ata_dev_set_protocol(dev);
1638 }
1639
1640 return; 1823 return;
1641 1824
1642err_out: 1825err_out:
@@ -1910,7 +2093,8 @@ err_out:
1910 DPRINTK("EXIT\n"); 2093 DPRINTK("EXIT\n");
1911} 2094}
1912 2095
1913static void ata_pr_blacklisted(struct ata_port *ap, struct ata_device *dev) 2096static void ata_pr_blacklisted(const struct ata_port *ap,
2097 const struct ata_device *dev)
1914{ 2098{
1915 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n", 2099 printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, disabling DMA\n",
1916 ap->id, dev->devno); 2100 ap->id, dev->devno);
@@ -1948,7 +2132,7 @@ static const char * ata_dma_blacklist [] = {
1948 "_NEC DV5800A", 2132 "_NEC DV5800A",
1949}; 2133};
1950 2134
1951static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev) 2135static int ata_dma_blacklisted(const struct ata_device *dev)
1952{ 2136{
1953 unsigned char model_num[40]; 2137 unsigned char model_num[40];
1954 char *s; 2138 char *s;
@@ -1973,9 +2157,9 @@ static int ata_dma_blacklisted(struct ata_port *ap, struct ata_device *dev)
1973 return 0; 2157 return 0;
1974} 2158}
1975 2159
1976static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift) 2160static unsigned int ata_get_mode_mask(const struct ata_port *ap, int shift)
1977{ 2161{
1978 struct ata_device *master, *slave; 2162 const struct ata_device *master, *slave;
1979 unsigned int mask; 2163 unsigned int mask;
1980 2164
1981 master = &ap->device[0]; 2165 master = &ap->device[0];
@@ -1987,14 +2171,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
1987 mask = ap->udma_mask; 2171 mask = ap->udma_mask;
1988 if (ata_dev_present(master)) { 2172 if (ata_dev_present(master)) {
1989 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff); 2173 mask &= (master->id[ATA_ID_UDMA_MODES] & 0xff);
1990 if (ata_dma_blacklisted(ap, master)) { 2174 if (ata_dma_blacklisted(master)) {
1991 mask = 0; 2175 mask = 0;
1992 ata_pr_blacklisted(ap, master); 2176 ata_pr_blacklisted(ap, master);
1993 } 2177 }
1994 } 2178 }
1995 if (ata_dev_present(slave)) { 2179 if (ata_dev_present(slave)) {
1996 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff); 2180 mask &= (slave->id[ATA_ID_UDMA_MODES] & 0xff);
1997 if (ata_dma_blacklisted(ap, slave)) { 2181 if (ata_dma_blacklisted(slave)) {
1998 mask = 0; 2182 mask = 0;
1999 ata_pr_blacklisted(ap, slave); 2183 ata_pr_blacklisted(ap, slave);
2000 } 2184 }
@@ -2004,14 +2188,14 @@ static unsigned int ata_get_mode_mask(struct ata_port *ap, int shift)
2004 mask = ap->mwdma_mask; 2188 mask = ap->mwdma_mask;
2005 if (ata_dev_present(master)) { 2189 if (ata_dev_present(master)) {
2006 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07); 2190 mask &= (master->id[ATA_ID_MWDMA_MODES] & 0x07);
2007 if (ata_dma_blacklisted(ap, master)) { 2191 if (ata_dma_blacklisted(master)) {
2008 mask = 0; 2192 mask = 0;
2009 ata_pr_blacklisted(ap, master); 2193 ata_pr_blacklisted(ap, master);
2010 } 2194 }
2011 } 2195 }
2012 if (ata_dev_present(slave)) { 2196 if (ata_dev_present(slave)) {
2013 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07); 2197 mask &= (slave->id[ATA_ID_MWDMA_MODES] & 0x07);
2014 if (ata_dma_blacklisted(ap, slave)) { 2198 if (ata_dma_blacklisted(slave)) {
2015 mask = 0; 2199 mask = 0;
2016 ata_pr_blacklisted(ap, slave); 2200 ata_pr_blacklisted(ap, slave);
2017 } 2201 }
@@ -2075,7 +2259,7 @@ static int fgb(u32 bitmap)
2075 * Zero on success, negative on error. 2259 * Zero on success, negative on error.
2076 */ 2260 */
2077 2261
2078static int ata_choose_xfer_mode(struct ata_port *ap, 2262static int ata_choose_xfer_mode(const struct ata_port *ap,
2079 u8 *xfer_mode_out, 2263 u8 *xfer_mode_out,
2080 unsigned int *xfer_shift_out) 2264 unsigned int *xfer_shift_out)
2081{ 2265{
@@ -2144,6 +2328,110 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2144} 2328}
2145 2329
2146/** 2330/**
2331 * ata_dev_reread_id - Reread the device identify device info
2332 * @ap: port where the device is
2333 * @dev: device to reread the identify device info
2334 *
2335 * LOCKING:
2336 */
2337
2338static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2339{
2340 DECLARE_COMPLETION(wait);
2341 struct ata_queued_cmd *qc;
2342 unsigned long flags;
2343 int rc;
2344
2345 qc = ata_qc_new_init(ap, dev);
2346 BUG_ON(qc == NULL);
2347
2348 ata_sg_init_one(qc, dev->id, sizeof(dev->id));
2349 qc->dma_dir = DMA_FROM_DEVICE;
2350
2351 if (dev->class == ATA_DEV_ATA) {
2352 qc->tf.command = ATA_CMD_ID_ATA;
2353 DPRINTK("do ATA identify\n");
2354 } else {
2355 qc->tf.command = ATA_CMD_ID_ATAPI;
2356 DPRINTK("do ATAPI identify\n");
2357 }
2358
2359 qc->tf.flags |= ATA_TFLAG_DEVICE;
2360 qc->tf.protocol = ATA_PROT_PIO;
2361 qc->nsect = 1;
2362
2363 qc->waiting = &wait;
2364 qc->complete_fn = ata_qc_complete_noop;
2365
2366 spin_lock_irqsave(&ap->host_set->lock, flags);
2367 rc = ata_qc_issue(qc);
2368 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2369
2370 if (rc)
2371 goto err_out;
2372
2373 wait_for_completion(&wait);
2374
2375 swap_buf_le16(dev->id, ATA_ID_WORDS);
2376
2377 ata_dump_id(dev);
2378
2379 DPRINTK("EXIT\n");
2380
2381 return;
2382err_out:
2383 ata_port_disable(ap);
2384}
2385
2386/**
2387 * ata_dev_init_params - Issue INIT DEV PARAMS command
2388 * @ap: Port associated with device @dev
2389 * @dev: Device to which command will be sent
2390 *
2391 * LOCKING:
2392 */
2393
2394static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2395{
2396 DECLARE_COMPLETION(wait);
2397 struct ata_queued_cmd *qc;
2398 int rc;
2399 unsigned long flags;
2400 u16 sectors = dev->id[6];
2401 u16 heads = dev->id[3];
2402
2403 /* Number of sectors per track 1-255. Number of heads 1-16 */
2404 if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16)
2405 return;
2406
2407 /* set up init dev params taskfile */
2408 DPRINTK("init dev params \n");
2409
2410 qc = ata_qc_new_init(ap, dev);
2411 BUG_ON(qc == NULL);
2412
2413 qc->tf.command = ATA_CMD_INIT_DEV_PARAMS;
2414 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2415 qc->tf.protocol = ATA_PROT_NODATA;
2416 qc->tf.nsect = sectors;
2417 qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
2418
2419 qc->waiting = &wait;
2420 qc->complete_fn = ata_qc_complete_noop;
2421
2422 spin_lock_irqsave(&ap->host_set->lock, flags);
2423 rc = ata_qc_issue(qc);
2424 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2425
2426 if (rc)
2427 ata_port_disable(ap);
2428 else
2429 wait_for_completion(&wait);
2430
2431 DPRINTK("EXIT\n");
2432}
2433
2434/**
2147 * ata_sg_clean - Unmap DMA memory associated with command 2435 * ata_sg_clean - Unmap DMA memory associated with command
2148 * @qc: Command containing DMA memory to be released 2436 * @qc: Command containing DMA memory to be released
2149 * 2437 *
@@ -2413,32 +2701,32 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2413 2701
2414/** 2702/**
2415 * ata_pio_poll - 2703 * ata_pio_poll -
2416 * @ap: 2704 * @ap: the target ata_port
2417 * 2705 *
2418 * LOCKING: 2706 * LOCKING:
2419 * None. (executing in kernel thread context) 2707 * None. (executing in kernel thread context)
2420 * 2708 *
2421 * RETURNS: 2709 * RETURNS:
2422 * 2710 * timeout value to use
2423 */ 2711 */
2424 2712
2425static unsigned long ata_pio_poll(struct ata_port *ap) 2713static unsigned long ata_pio_poll(struct ata_port *ap)
2426{ 2714{
2427 u8 status; 2715 u8 status;
2428 unsigned int poll_state = PIO_ST_UNKNOWN; 2716 unsigned int poll_state = HSM_ST_UNKNOWN;
2429 unsigned int reg_state = PIO_ST_UNKNOWN; 2717 unsigned int reg_state = HSM_ST_UNKNOWN;
2430 const unsigned int tmout_state = PIO_ST_TMOUT; 2718 const unsigned int tmout_state = HSM_ST_TMOUT;
2431 2719
2432 switch (ap->pio_task_state) { 2720 switch (ap->hsm_task_state) {
2433 case PIO_ST: 2721 case HSM_ST:
2434 case PIO_ST_POLL: 2722 case HSM_ST_POLL:
2435 poll_state = PIO_ST_POLL; 2723 poll_state = HSM_ST_POLL;
2436 reg_state = PIO_ST; 2724 reg_state = HSM_ST;
2437 break; 2725 break;
2438 case PIO_ST_LAST: 2726 case HSM_ST_LAST:
2439 case PIO_ST_LAST_POLL: 2727 case HSM_ST_LAST_POLL:
2440 poll_state = PIO_ST_LAST_POLL; 2728 poll_state = HSM_ST_LAST_POLL;
2441 reg_state = PIO_ST_LAST; 2729 reg_state = HSM_ST_LAST;
2442 break; 2730 break;
2443 default: 2731 default:
2444 BUG(); 2732 BUG();
@@ -2448,20 +2736,20 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2448 status = ata_chk_status(ap); 2736 status = ata_chk_status(ap);
2449 if (status & ATA_BUSY) { 2737 if (status & ATA_BUSY) {
2450 if (time_after(jiffies, ap->pio_task_timeout)) { 2738 if (time_after(jiffies, ap->pio_task_timeout)) {
2451 ap->pio_task_state = tmout_state; 2739 ap->hsm_task_state = tmout_state;
2452 return 0; 2740 return 0;
2453 } 2741 }
2454 ap->pio_task_state = poll_state; 2742 ap->hsm_task_state = poll_state;
2455 return ATA_SHORT_PAUSE; 2743 return ATA_SHORT_PAUSE;
2456 } 2744 }
2457 2745
2458 ap->pio_task_state = reg_state; 2746 ap->hsm_task_state = reg_state;
2459 return 0; 2747 return 0;
2460} 2748}
2461 2749
2462/** 2750/**
2463 * ata_pio_complete - 2751 * ata_pio_complete - check if drive is busy or idle
2464 * @ap: 2752 * @ap: the target ata_port
2465 * 2753 *
2466 * LOCKING: 2754 * LOCKING:
2467 * None. (executing in kernel thread context) 2755 * None. (executing in kernel thread context)
@@ -2480,14 +2768,14 @@ static int ata_pio_complete (struct ata_port *ap)
2480 * we enter, BSY will be cleared in a chk-status or two. If not, 2768 * we enter, BSY will be cleared in a chk-status or two. If not,
2481 * the drive is probably seeking or something. Snooze for a couple 2769 * the drive is probably seeking or something. Snooze for a couple
2482 * msecs, then chk-status again. If still busy, fall back to 2770 * msecs, then chk-status again. If still busy, fall back to
2483 * PIO_ST_POLL state. 2771 * HSM_ST_POLL state.
2484 */ 2772 */
2485 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); 2773 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
2486 if (drv_stat & (ATA_BUSY | ATA_DRQ)) { 2774 if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
2487 msleep(2); 2775 msleep(2);
2488 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); 2776 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10);
2489 if (drv_stat & (ATA_BUSY | ATA_DRQ)) { 2777 if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
2490 ap->pio_task_state = PIO_ST_LAST_POLL; 2778 ap->hsm_task_state = HSM_ST_LAST_POLL;
2491 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; 2779 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
2492 return 0; 2780 return 0;
2493 } 2781 }
@@ -2495,14 +2783,14 @@ static int ata_pio_complete (struct ata_port *ap)
2495 2783
2496 drv_stat = ata_wait_idle(ap); 2784 drv_stat = ata_wait_idle(ap);
2497 if (!ata_ok(drv_stat)) { 2785 if (!ata_ok(drv_stat)) {
2498 ap->pio_task_state = PIO_ST_ERR; 2786 ap->hsm_task_state = HSM_ST_ERR;
2499 return 0; 2787 return 0;
2500 } 2788 }
2501 2789
2502 qc = ata_qc_from_tag(ap, ap->active_tag); 2790 qc = ata_qc_from_tag(ap, ap->active_tag);
2503 assert(qc != NULL); 2791 assert(qc != NULL);
2504 2792
2505 ap->pio_task_state = PIO_ST_IDLE; 2793 ap->hsm_task_state = HSM_ST_IDLE;
2506 2794
2507 ata_poll_qc_complete(qc, drv_stat); 2795 ata_poll_qc_complete(qc, drv_stat);
2508 2796
@@ -2513,7 +2801,7 @@ static int ata_pio_complete (struct ata_port *ap)
2513 2801
2514 2802
2515/** 2803/**
2516 * swap_buf_le16 - 2804 * swap_buf_le16 - swap halves of 16-words in place
2517 * @buf: Buffer to swap 2805 * @buf: Buffer to swap
2518 * @buf_words: Number of 16-bit words in buffer. 2806 * @buf_words: Number of 16-bit words in buffer.
2519 * 2807 *
@@ -2522,6 +2810,7 @@ static int ata_pio_complete (struct ata_port *ap)
2522 * vice-versa. 2810 * vice-versa.
2523 * 2811 *
2524 * LOCKING: 2812 * LOCKING:
2813 * Inherited from caller.
2525 */ 2814 */
2526void swap_buf_le16(u16 *buf, unsigned int buf_words) 2815void swap_buf_le16(u16 *buf, unsigned int buf_words)
2527{ 2816{
@@ -2544,7 +2833,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
2544 * 2833 *
2545 * LOCKING: 2834 * LOCKING:
2546 * Inherited from caller. 2835 * Inherited from caller.
2547 *
2548 */ 2836 */
2549 2837
2550static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf, 2838static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2590,7 +2878,6 @@ static void ata_mmio_data_xfer(struct ata_port *ap, unsigned char *buf,
2590 * 2878 *
2591 * LOCKING: 2879 * LOCKING:
2592 * Inherited from caller. 2880 * Inherited from caller.
2593 *
2594 */ 2881 */
2595 2882
2596static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf, 2883static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2630,7 +2917,6 @@ static void ata_pio_data_xfer(struct ata_port *ap, unsigned char *buf,
2630 * 2917 *
2631 * LOCKING: 2918 * LOCKING:
2632 * Inherited from caller. 2919 * Inherited from caller.
2633 *
2634 */ 2920 */
2635 2921
2636static void ata_data_xfer(struct ata_port *ap, unsigned char *buf, 2922static void ata_data_xfer(struct ata_port *ap, unsigned char *buf,
@@ -2662,7 +2948,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
2662 unsigned char *buf; 2948 unsigned char *buf;
2663 2949
2664 if (qc->cursect == (qc->nsect - 1)) 2950 if (qc->cursect == (qc->nsect - 1))
2665 ap->pio_task_state = PIO_ST_LAST; 2951 ap->hsm_task_state = HSM_ST_LAST;
2666 2952
2667 page = sg[qc->cursg].page; 2953 page = sg[qc->cursg].page;
2668 offset = sg[qc->cursg].offset + qc->cursg_ofs * ATA_SECT_SIZE; 2954 offset = sg[qc->cursg].offset + qc->cursg_ofs * ATA_SECT_SIZE;
@@ -2712,7 +2998,7 @@ static void __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes)
2712 unsigned int offset, count; 2998 unsigned int offset, count;
2713 2999
2714 if (qc->curbytes + bytes >= qc->nbytes) 3000 if (qc->curbytes + bytes >= qc->nbytes)
2715 ap->pio_task_state = PIO_ST_LAST; 3001 ap->hsm_task_state = HSM_ST_LAST;
2716 3002
2717next_sg: 3003next_sg:
2718 if (unlikely(qc->cursg >= qc->n_elem)) { 3004 if (unlikely(qc->cursg >= qc->n_elem)) {
@@ -2734,7 +3020,7 @@ next_sg:
2734 for (i = 0; i < words; i++) 3020 for (i = 0; i < words; i++)
2735 ata_data_xfer(ap, (unsigned char*)pad_buf, 2, do_write); 3021 ata_data_xfer(ap, (unsigned char*)pad_buf, 2, do_write);
2736 3022
2737 ap->pio_task_state = PIO_ST_LAST; 3023 ap->hsm_task_state = HSM_ST_LAST;
2738 return; 3024 return;
2739 } 3025 }
2740 3026
@@ -2783,7 +3069,6 @@ next_sg:
2783 * 3069 *
2784 * LOCKING: 3070 * LOCKING:
2785 * Inherited from caller. 3071 * Inherited from caller.
2786 *
2787 */ 3072 */
2788 3073
2789static void atapi_pio_bytes(struct ata_queued_cmd *qc) 3074static void atapi_pio_bytes(struct ata_queued_cmd *qc)
@@ -2815,12 +3100,12 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
2815err_out: 3100err_out:
2816 printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", 3101 printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n",
2817 ap->id, dev->devno); 3102 ap->id, dev->devno);
2818 ap->pio_task_state = PIO_ST_ERR; 3103 ap->hsm_task_state = HSM_ST_ERR;
2819} 3104}
2820 3105
2821/** 3106/**
2822 * ata_pio_sector - 3107 * ata_pio_block - start PIO on a block
2823 * @ap: 3108 * @ap: the target ata_port
2824 * 3109 *
2825 * LOCKING: 3110 * LOCKING:
2826 * None. (executing in kernel thread context) 3111 * None. (executing in kernel thread context)
@@ -2832,19 +3117,19 @@ static void ata_pio_block(struct ata_port *ap)
2832 u8 status; 3117 u8 status;
2833 3118
2834 /* 3119 /*
2835 * This is purely hueristic. This is a fast path. 3120 * This is purely heuristic. This is a fast path.
2836 * Sometimes when we enter, BSY will be cleared in 3121 * Sometimes when we enter, BSY will be cleared in
2837 * a chk-status or two. If not, the drive is probably seeking 3122 * a chk-status or two. If not, the drive is probably seeking
2838 * or something. Snooze for a couple msecs, then 3123 * or something. Snooze for a couple msecs, then
2839 * chk-status again. If still busy, fall back to 3124 * chk-status again. If still busy, fall back to
2840 * PIO_ST_POLL state. 3125 * HSM_ST_POLL state.
2841 */ 3126 */
2842 status = ata_busy_wait(ap, ATA_BUSY, 5); 3127 status = ata_busy_wait(ap, ATA_BUSY, 5);
2843 if (status & ATA_BUSY) { 3128 if (status & ATA_BUSY) {
2844 msleep(2); 3129 msleep(2);
2845 status = ata_busy_wait(ap, ATA_BUSY, 10); 3130 status = ata_busy_wait(ap, ATA_BUSY, 10);
2846 if (status & ATA_BUSY) { 3131 if (status & ATA_BUSY) {
2847 ap->pio_task_state = PIO_ST_POLL; 3132 ap->hsm_task_state = HSM_ST_POLL;
2848 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; 3133 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
2849 return; 3134 return;
2850 } 3135 }
@@ -2856,7 +3141,7 @@ static void ata_pio_block(struct ata_port *ap)
2856 if (is_atapi_taskfile(&qc->tf)) { 3141 if (is_atapi_taskfile(&qc->tf)) {
2857 /* no more data to transfer or unsupported ATAPI command */ 3142 /* no more data to transfer or unsupported ATAPI command */
2858 if ((status & ATA_DRQ) == 0) { 3143 if ((status & ATA_DRQ) == 0) {
2859 ap->pio_task_state = PIO_ST_LAST; 3144 ap->hsm_task_state = HSM_ST_LAST;
2860 return; 3145 return;
2861 } 3146 }
2862 3147
@@ -2864,7 +3149,7 @@ static void ata_pio_block(struct ata_port *ap)
2864 } else { 3149 } else {
2865 /* handle BSY=0, DRQ=0 as error */ 3150 /* handle BSY=0, DRQ=0 as error */
2866 if ((status & ATA_DRQ) == 0) { 3151 if ((status & ATA_DRQ) == 0) {
2867 ap->pio_task_state = PIO_ST_ERR; 3152 ap->hsm_task_state = HSM_ST_ERR;
2868 return; 3153 return;
2869 } 3154 }
2870 3155
@@ -2884,7 +3169,7 @@ static void ata_pio_error(struct ata_port *ap)
2884 printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n", 3169 printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n",
2885 ap->id, drv_stat); 3170 ap->id, drv_stat);
2886 3171
2887 ap->pio_task_state = PIO_ST_IDLE; 3172 ap->hsm_task_state = HSM_ST_IDLE;
2888 3173
2889 ata_poll_qc_complete(qc, drv_stat | ATA_ERR); 3174 ata_poll_qc_complete(qc, drv_stat | ATA_ERR);
2890} 3175}
@@ -2899,25 +3184,25 @@ fsm_start:
2899 timeout = 0; 3184 timeout = 0;
2900 qc_completed = 0; 3185 qc_completed = 0;
2901 3186
2902 switch (ap->pio_task_state) { 3187 switch (ap->hsm_task_state) {
2903 case PIO_ST_IDLE: 3188 case HSM_ST_IDLE:
2904 return; 3189 return;
2905 3190
2906 case PIO_ST: 3191 case HSM_ST:
2907 ata_pio_block(ap); 3192 ata_pio_block(ap);
2908 break; 3193 break;
2909 3194
2910 case PIO_ST_LAST: 3195 case HSM_ST_LAST:
2911 qc_completed = ata_pio_complete(ap); 3196 qc_completed = ata_pio_complete(ap);
2912 break; 3197 break;
2913 3198
2914 case PIO_ST_POLL: 3199 case HSM_ST_POLL:
2915 case PIO_ST_LAST_POLL: 3200 case HSM_ST_LAST_POLL:
2916 timeout = ata_pio_poll(ap); 3201 timeout = ata_pio_poll(ap);
2917 break; 3202 break;
2918 3203
2919 case PIO_ST_TMOUT: 3204 case HSM_ST_TMOUT:
2920 case PIO_ST_ERR: 3205 case HSM_ST_ERR:
2921 ata_pio_error(ap); 3206 ata_pio_error(ap);
2922 return; 3207 return;
2923 } 3208 }
@@ -2928,52 +3213,6 @@ fsm_start:
2928 goto fsm_start; 3213 goto fsm_start;
2929} 3214}
2930 3215
2931static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
2932 struct scsi_cmnd *cmd)
2933{
2934 DECLARE_COMPLETION(wait);
2935 struct ata_queued_cmd *qc;
2936 unsigned long flags;
2937 int rc;
2938
2939 DPRINTK("ATAPI request sense\n");
2940
2941 qc = ata_qc_new_init(ap, dev);
2942 BUG_ON(qc == NULL);
2943
2944 /* FIXME: is this needed? */
2945 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
2946
2947 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
2948 qc->dma_dir = DMA_FROM_DEVICE;
2949
2950 memset(&qc->cdb, 0, ap->cdb_len);
2951 qc->cdb[0] = REQUEST_SENSE;
2952 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
2953
2954 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2955 qc->tf.command = ATA_CMD_PACKET;
2956
2957 qc->tf.protocol = ATA_PROT_ATAPI;
2958 qc->tf.lbam = (8 * 1024) & 0xff;
2959 qc->tf.lbah = (8 * 1024) >> 8;
2960 qc->nbytes = SCSI_SENSE_BUFFERSIZE;
2961
2962 qc->waiting = &wait;
2963 qc->complete_fn = ata_qc_complete_noop;
2964
2965 spin_lock_irqsave(&ap->host_set->lock, flags);
2966 rc = ata_qc_issue(qc);
2967 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2968
2969 if (rc)
2970 ata_port_disable(ap);
2971 else
2972 wait_for_completion(&wait);
2973
2974 DPRINTK("EXIT\n");
2975}
2976
2977/** 3216/**
2978 * ata_qc_timeout - Handle timeout of queued command 3217 * ata_qc_timeout - Handle timeout of queued command
2979 * @qc: Command that timed out 3218 * @qc: Command that timed out
@@ -3091,14 +3330,14 @@ void ata_eng_timeout(struct ata_port *ap)
3091 DPRINTK("ENTER\n"); 3330 DPRINTK("ENTER\n");
3092 3331
3093 qc = ata_qc_from_tag(ap, ap->active_tag); 3332 qc = ata_qc_from_tag(ap, ap->active_tag);
3094 if (!qc) { 3333 if (qc)
3334 ata_qc_timeout(qc);
3335 else {
3095 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 3336 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
3096 ap->id); 3337 ap->id);
3097 goto out; 3338 goto out;
3098 } 3339 }
3099 3340
3100 ata_qc_timeout(qc);
3101
3102out: 3341out:
3103 DPRINTK("EXIT\n"); 3342 DPRINTK("EXIT\n");
3104} 3343}
@@ -3155,15 +3394,12 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3155 qc->nbytes = qc->curbytes = 0; 3394 qc->nbytes = qc->curbytes = 0;
3156 3395
3157 ata_tf_init(ap, &qc->tf, dev->devno); 3396 ata_tf_init(ap, &qc->tf, dev->devno);
3158
3159 if (dev->flags & ATA_DFLAG_LBA48)
3160 qc->tf.flags |= ATA_TFLAG_LBA48;
3161 } 3397 }
3162 3398
3163 return qc; 3399 return qc;
3164} 3400}
3165 3401
3166static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) 3402int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat)
3167{ 3403{
3168 return 0; 3404 return 0;
3169} 3405}
@@ -3201,7 +3437,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3201 * 3437 *
3202 * LOCKING: 3438 * LOCKING:
3203 * spin_lock_irqsave(host_set lock) 3439 * spin_lock_irqsave(host_set lock)
3204 *
3205 */ 3440 */
3206void ata_qc_free(struct ata_queued_cmd *qc) 3441void ata_qc_free(struct ata_queued_cmd *qc)
3207{ 3442{
@@ -3221,7 +3456,6 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3221 * 3456 *
3222 * LOCKING: 3457 * LOCKING:
3223 * spin_lock_irqsave(host_set lock) 3458 * spin_lock_irqsave(host_set lock)
3224 *
3225 */ 3459 */
3226 3460
3227void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3461void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
@@ -3360,7 +3594,7 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3360 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ 3594 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */
3361 ata_qc_set_polling(qc); 3595 ata_qc_set_polling(qc);
3362 ata_tf_to_host_nolock(ap, &qc->tf); 3596 ata_tf_to_host_nolock(ap, &qc->tf);
3363 ap->pio_task_state = PIO_ST; 3597 ap->hsm_task_state = HSM_ST;
3364 queue_work(ata_wq, &ap->pio_task); 3598 queue_work(ata_wq, &ap->pio_task);
3365 break; 3599 break;
3366 3600
@@ -3586,7 +3820,7 @@ u8 ata_bmdma_status(struct ata_port *ap)
3586 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr; 3820 void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
3587 host_stat = readb(mmio + ATA_DMA_STATUS); 3821 host_stat = readb(mmio + ATA_DMA_STATUS);
3588 } else 3822 } else
3589 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 3823 host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
3590 return host_stat; 3824 return host_stat;
3591} 3825}
3592 3826
@@ -3715,7 +3949,6 @@ idle_irq:
3715 * 3949 *
3716 * RETURNS: 3950 * RETURNS:
3717 * IRQ_NONE or IRQ_HANDLED. 3951 * IRQ_NONE or IRQ_HANDLED.
3718 *
3719 */ 3952 */
3720 3953
3721irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) 3954irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
@@ -3806,7 +4039,7 @@ static void atapi_packet_task(void *_data)
3806 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1); 4039 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
3807 4040
3808 /* PIO commands are handled by polling */ 4041 /* PIO commands are handled by polling */
3809 ap->pio_task_state = PIO_ST; 4042 ap->hsm_task_state = HSM_ST;
3810 queue_work(ata_wq, &ap->pio_task); 4043 queue_work(ata_wq, &ap->pio_task);
3811 } 4044 }
3812 4045
@@ -3827,6 +4060,7 @@ err_out:
3827 * May be used as the port_start() entry in ata_port_operations. 4060 * May be used as the port_start() entry in ata_port_operations.
3828 * 4061 *
3829 * LOCKING: 4062 * LOCKING:
4063 * Inherited from caller.
3830 */ 4064 */
3831 4065
3832int ata_port_start (struct ata_port *ap) 4066int ata_port_start (struct ata_port *ap)
@@ -3852,6 +4086,7 @@ int ata_port_start (struct ata_port *ap)
3852 * May be used as the port_stop() entry in ata_port_operations. 4086 * May be used as the port_stop() entry in ata_port_operations.
3853 * 4087 *
3854 * LOCKING: 4088 * LOCKING:
4089 * Inherited from caller.
3855 */ 4090 */
3856 4091
3857void ata_port_stop (struct ata_port *ap) 4092void ata_port_stop (struct ata_port *ap)
@@ -3874,6 +4109,7 @@ void ata_host_stop (struct ata_host_set *host_set)
3874 * @do_unregister: 1 if we fully unregister, 0 to just stop the port 4109 * @do_unregister: 1 if we fully unregister, 0 to just stop the port
3875 * 4110 *
3876 * LOCKING: 4111 * LOCKING:
4112 * Inherited from caller.
3877 */ 4113 */
3878 4114
3879static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister) 4115static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
@@ -3901,12 +4137,11 @@ static void ata_host_remove(struct ata_port *ap, unsigned int do_unregister)
3901 * 4137 *
3902 * LOCKING: 4138 * LOCKING:
3903 * Inherited from caller. 4139 * Inherited from caller.
3904 *
3905 */ 4140 */
3906 4141
3907static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host, 4142static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
3908 struct ata_host_set *host_set, 4143 struct ata_host_set *host_set,
3909 struct ata_probe_ent *ent, unsigned int port_no) 4144 const struct ata_probe_ent *ent, unsigned int port_no)
3910{ 4145{
3911 unsigned int i; 4146 unsigned int i;
3912 4147
@@ -3962,10 +4197,9 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
3962 * 4197 *
3963 * RETURNS: 4198 * RETURNS:
3964 * New ata_port on success, for NULL on error. 4199 * New ata_port on success, for NULL on error.
3965 *
3966 */ 4200 */
3967 4201
3968static struct ata_port * ata_host_add(struct ata_probe_ent *ent, 4202static struct ata_port * ata_host_add(const struct ata_probe_ent *ent,
3969 struct ata_host_set *host_set, 4203 struct ata_host_set *host_set,
3970 unsigned int port_no) 4204 unsigned int port_no)
3971{ 4205{
@@ -4010,10 +4244,9 @@ err_out:
4010 * 4244 *
4011 * RETURNS: 4245 * RETURNS:
4012 * Number of ports registered. Zero on error (no ports registered). 4246 * Number of ports registered. Zero on error (no ports registered).
4013 *
4014 */ 4247 */
4015 4248
4016int ata_device_add(struct ata_probe_ent *ent) 4249int ata_device_add(const struct ata_probe_ent *ent)
4017{ 4250{
4018 unsigned int count = 0, i; 4251 unsigned int count = 0, i;
4019 struct device *dev = ent->dev; 4252 struct device *dev = ent->dev;
@@ -4113,7 +4346,7 @@ int ata_device_add(struct ata_probe_ent *ent)
4113 for (i = 0; i < count; i++) { 4346 for (i = 0; i < count; i++) {
4114 struct ata_port *ap = host_set->ports[i]; 4347 struct ata_port *ap = host_set->ports[i];
4115 4348
4116 scsi_scan_host(ap->host); 4349 ata_scsi_scan_host(ap);
4117 } 4350 }
4118 4351
4119 dev_set_drvdata(dev, host_set); 4352 dev_set_drvdata(dev, host_set);
@@ -4142,7 +4375,6 @@ err_out:
4142 * Inherited from calling layer (may sleep). 4375 * Inherited from calling layer (may sleep).
4143 */ 4376 */
4144 4377
4145
4146void ata_host_set_remove(struct ata_host_set *host_set) 4378void ata_host_set_remove(struct ata_host_set *host_set)
4147{ 4379{
4148 struct ata_port *ap; 4380 struct ata_port *ap;
@@ -4232,7 +4464,7 @@ void ata_std_ports(struct ata_ioports *ioaddr)
4232} 4464}
4233 4465
4234static struct ata_probe_ent * 4466static struct ata_probe_ent *
4235ata_probe_ent_alloc(struct device *dev, struct ata_port_info *port) 4467ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
4236{ 4468{
4237 struct ata_probe_ent *probe_ent; 4469 struct ata_probe_ent *probe_ent;
4238 4470
@@ -4273,85 +4505,86 @@ void ata_pci_host_stop (struct ata_host_set *host_set)
4273 * ata_pci_init_native_mode - Initialize native-mode driver 4505 * ata_pci_init_native_mode - Initialize native-mode driver
4274 * @pdev: pci device to be initialized 4506 * @pdev: pci device to be initialized
4275 * @port: array[2] of pointers to port info structures. 4507 * @port: array[2] of pointers to port info structures.
4508 * @ports: bitmap of ports present
4276 * 4509 *
4277 * Utility function which allocates and initializes an 4510 * Utility function which allocates and initializes an
4278 * ata_probe_ent structure for a standard dual-port 4511 * ata_probe_ent structure for a standard dual-port
4279 * PIO-based IDE controller. The returned ata_probe_ent 4512 * PIO-based IDE controller. The returned ata_probe_ent
4280 * structure can be passed to ata_device_add(). The returned 4513 * structure can be passed to ata_device_add(). The returned
4281 * ata_probe_ent structure should then be freed with kfree(). 4514 * ata_probe_ent structure should then be freed with kfree().
4515 *
4516 * The caller need only pass the address of the primary port, the
4517 * secondary will be deduced automatically. If the device has non
4518 * standard secondary port mappings this function can be called twice,
4519 * once for each interface.
4282 */ 4520 */
4283 4521
4284struct ata_probe_ent * 4522struct ata_probe_ent *
4285ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port) 4523ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int ports)
4286{ 4524{
4287 struct ata_probe_ent *probe_ent = 4525 struct ata_probe_ent *probe_ent =
4288 ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 4526 ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
4527 int p = 0;
4528
4289 if (!probe_ent) 4529 if (!probe_ent)
4290 return NULL; 4530 return NULL;
4291 4531
4292 probe_ent->n_ports = 2;
4293 probe_ent->irq = pdev->irq; 4532 probe_ent->irq = pdev->irq;
4294 probe_ent->irq_flags = SA_SHIRQ; 4533 probe_ent->irq_flags = SA_SHIRQ;
4295 4534
4296 probe_ent->port[0].cmd_addr = pci_resource_start(pdev, 0); 4535 if (ports & ATA_PORT_PRIMARY) {
4297 probe_ent->port[0].altstatus_addr = 4536 probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0);
4298 probe_ent->port[0].ctl_addr = 4537 probe_ent->port[p].altstatus_addr =
4299 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS; 4538 probe_ent->port[p].ctl_addr =
4300 probe_ent->port[0].bmdma_addr = pci_resource_start(pdev, 4); 4539 pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS;
4301 4540 probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4);
4302 probe_ent->port[1].cmd_addr = pci_resource_start(pdev, 2); 4541 ata_std_ports(&probe_ent->port[p]);
4303 probe_ent->port[1].altstatus_addr = 4542 p++;
4304 probe_ent->port[1].ctl_addr = 4543 }
4305 pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
4306 probe_ent->port[1].bmdma_addr = pci_resource_start(pdev, 4) + 8;
4307 4544
4308 ata_std_ports(&probe_ent->port[0]); 4545 if (ports & ATA_PORT_SECONDARY) {
4309 ata_std_ports(&probe_ent->port[1]); 4546 probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 2);
4547 probe_ent->port[p].altstatus_addr =
4548 probe_ent->port[p].ctl_addr =
4549 pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS;
4550 probe_ent->port[p].bmdma_addr = pci_resource_start(pdev, 4) + 8;
4551 ata_std_ports(&probe_ent->port[p]);
4552 p++;
4553 }
4310 4554
4555 probe_ent->n_ports = p;
4311 return probe_ent; 4556 return probe_ent;
4312} 4557}
4313 4558
4314static struct ata_probe_ent * 4559static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num)
4315ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port,
4316 struct ata_probe_ent **ppe2)
4317{ 4560{
4318 struct ata_probe_ent *probe_ent, *probe_ent2; 4561 struct ata_probe_ent *probe_ent;
4319 4562
4320 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 4563 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]);
4321 if (!probe_ent) 4564 if (!probe_ent)
4322 return NULL; 4565 return NULL;
4323 probe_ent2 = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[1]);
4324 if (!probe_ent2) {
4325 kfree(probe_ent);
4326 return NULL;
4327 }
4328
4329 probe_ent->n_ports = 1;
4330 probe_ent->irq = 14;
4331 4566
4332 probe_ent->hard_port_no = 0;
4333 probe_ent->legacy_mode = 1; 4567 probe_ent->legacy_mode = 1;
4334 4568 probe_ent->n_ports = 1;
4335 probe_ent2->n_ports = 1; 4569 probe_ent->hard_port_no = port_num;
4336 probe_ent2->irq = 15; 4570
4337 4571 switch(port_num)
4338 probe_ent2->hard_port_no = 1; 4572 {
4339 probe_ent2->legacy_mode = 1; 4573 case 0:
4340 4574 probe_ent->irq = 14;
4341 probe_ent->port[0].cmd_addr = 0x1f0; 4575 probe_ent->port[0].cmd_addr = 0x1f0;
4342 probe_ent->port[0].altstatus_addr = 4576 probe_ent->port[0].altstatus_addr =
4343 probe_ent->port[0].ctl_addr = 0x3f6; 4577 probe_ent->port[0].ctl_addr = 0x3f6;
4344 probe_ent->port[0].bmdma_addr = pci_resource_start(pdev, 4); 4578 break;
4345 4579 case 1:
4346 probe_ent2->port[0].cmd_addr = 0x170; 4580 probe_ent->irq = 15;
4347 probe_ent2->port[0].altstatus_addr = 4581 probe_ent->port[0].cmd_addr = 0x170;
4348 probe_ent2->port[0].ctl_addr = 0x376; 4582 probe_ent->port[0].altstatus_addr =
4349 probe_ent2->port[0].bmdma_addr = pci_resource_start(pdev, 4)+8; 4583 probe_ent->port[0].ctl_addr = 0x376;
4350 4584 break;
4585 }
4586 probe_ent->port[0].bmdma_addr = pci_resource_start(pdev, 4) + 8 * port_num;
4351 ata_std_ports(&probe_ent->port[0]); 4587 ata_std_ports(&probe_ent->port[0]);
4352 ata_std_ports(&probe_ent2->port[0]);
4353
4354 *ppe2 = probe_ent2;
4355 return probe_ent; 4588 return probe_ent;
4356} 4589}
4357 4590
@@ -4374,13 +4607,12 @@ ata_pci_init_legacy_mode(struct pci_dev *pdev, struct ata_port_info **port,
4374 * 4607 *
4375 * RETURNS: 4608 * RETURNS:
4376 * Zero on success, negative on errno-based value on error. 4609 * Zero on success, negative on errno-based value on error.
4377 *
4378 */ 4610 */
4379 4611
4380int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 4612int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4381 unsigned int n_ports) 4613 unsigned int n_ports)
4382{ 4614{
4383 struct ata_probe_ent *probe_ent, *probe_ent2 = NULL; 4615 struct ata_probe_ent *probe_ent = NULL, *probe_ent2 = NULL;
4384 struct ata_port_info *port[2]; 4616 struct ata_port_info *port[2];
4385 u8 tmp8, mask; 4617 u8 tmp8, mask;
4386 unsigned int legacy_mode = 0; 4618 unsigned int legacy_mode = 0;
@@ -4397,7 +4629,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4397 4629
4398 if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0 4630 if ((port[0]->host_flags & ATA_FLAG_NO_LEGACY) == 0
4399 && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { 4631 && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
4400 /* TODO: support transitioning to native mode? */ 4632 /* TODO: What if one channel is in native mode ... */
4401 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); 4633 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
4402 mask = (1 << 2) | (1 << 0); 4634 mask = (1 << 2) | (1 << 0);
4403 if ((tmp8 & mask) != mask) 4635 if ((tmp8 & mask) != mask)
@@ -4405,11 +4637,20 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4405 } 4637 }
4406 4638
4407 /* FIXME... */ 4639 /* FIXME... */
4408 if ((!legacy_mode) && (n_ports > 1)) { 4640 if ((!legacy_mode) && (n_ports > 2)) {
4409 printk(KERN_ERR "ata: BUG: native mode, n_ports > 1\n"); 4641 printk(KERN_ERR "ata: BUG: native mode, n_ports > 2\n");
4410 return -EINVAL; 4642 n_ports = 2;
4643 /* For now */
4411 } 4644 }
4412 4645
4646 /* FIXME: Really for ATA it isn't safe because the device may be
4647 multi-purpose and we want to leave it alone if it was already
4648 enabled. Secondly for shared use as Arjan says we want refcounting
4649
4650 Checking dev->is_enabled is insufficient as this is not set at
4651 boot for the primary video which is BIOS enabled
4652 */
4653
4413 rc = pci_enable_device(pdev); 4654 rc = pci_enable_device(pdev);
4414 if (rc) 4655 if (rc)
4415 return rc; 4656 return rc;
@@ -4420,6 +4661,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4420 goto err_out; 4661 goto err_out;
4421 } 4662 }
4422 4663
4664 /* FIXME: Should use platform specific mappers for legacy port ranges */
4423 if (legacy_mode) { 4665 if (legacy_mode) {
4424 if (!request_region(0x1f0, 8, "libata")) { 4666 if (!request_region(0x1f0, 8, "libata")) {
4425 struct resource *conflict, res; 4667 struct resource *conflict, res;
@@ -4464,10 +4706,17 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4464 goto err_out_regions; 4706 goto err_out_regions;
4465 4707
4466 if (legacy_mode) { 4708 if (legacy_mode) {
4467 probe_ent = ata_pci_init_legacy_mode(pdev, port, &probe_ent2); 4709 if (legacy_mode & (1 << 0))
4468 } else 4710 probe_ent = ata_pci_init_legacy_port(pdev, port, 0);
4469 probe_ent = ata_pci_init_native_mode(pdev, port); 4711 if (legacy_mode & (1 << 1))
4470 if (!probe_ent) { 4712 probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1);
4713 } else {
4714 if (n_ports == 2)
4715 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
4716 else
4717 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY);
4718 }
4719 if (!probe_ent && !probe_ent2) {
4471 rc = -ENOMEM; 4720 rc = -ENOMEM;
4472 goto err_out_regions; 4721 goto err_out_regions;
4473 } 4722 }
@@ -4505,7 +4754,7 @@ err_out:
4505 * @pdev: PCI device that was removed 4754 * @pdev: PCI device that was removed
4506 * 4755 *
4507 * PCI layer indicates to libata via this hook that 4756 * PCI layer indicates to libata via this hook that
4508 * hot-unplug or module unload event has occured. 4757 * hot-unplug or module unload event has occurred.
4509 * Handle this by unregistering all objects associated 4758 * Handle this by unregistering all objects associated
4510 * with this PCI device. Free those objects. Then finally 4759 * with this PCI device. Free those objects. Then finally
4511 * release PCI resources and disable device. 4760 * release PCI resources and disable device.
@@ -4526,7 +4775,7 @@ void ata_pci_remove_one (struct pci_dev *pdev)
4526} 4775}
4527 4776
4528/* move to PCI subsystem */ 4777/* move to PCI subsystem */
4529int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits) 4778int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
4530{ 4779{
4531 unsigned long tmp = 0; 4780 unsigned long tmp = 0;
4532 4781
@@ -4579,6 +4828,27 @@ static void __exit ata_exit(void)
4579module_init(ata_init); 4828module_init(ata_init);
4580module_exit(ata_exit); 4829module_exit(ata_exit);
4581 4830
4831static unsigned long ratelimit_time;
4832static spinlock_t ata_ratelimit_lock = SPIN_LOCK_UNLOCKED;
4833
4834int ata_ratelimit(void)
4835{
4836 int rc;
4837 unsigned long flags;
4838
4839 spin_lock_irqsave(&ata_ratelimit_lock, flags);
4840
4841 if (time_after(jiffies, ratelimit_time)) {
4842 rc = 1;
4843 ratelimit_time = jiffies + (HZ/5);
4844 } else
4845 rc = 0;
4846
4847 spin_unlock_irqrestore(&ata_ratelimit_lock, flags);
4848
4849 return rc;
4850}
4851
4582/* 4852/*
4583 * libata is essentially a library of internal helper functions for 4853 * libata is essentially a library of internal helper functions for
4584 * low-level ATA host controller drivers. As such, the API/ABI is 4854 * low-level ATA host controller drivers. As such, the API/ABI is
@@ -4620,6 +4890,7 @@ EXPORT_SYMBOL_GPL(sata_phy_reset);
4620EXPORT_SYMBOL_GPL(__sata_phy_reset); 4890EXPORT_SYMBOL_GPL(__sata_phy_reset);
4621EXPORT_SYMBOL_GPL(ata_bus_reset); 4891EXPORT_SYMBOL_GPL(ata_bus_reset);
4622EXPORT_SYMBOL_GPL(ata_port_disable); 4892EXPORT_SYMBOL_GPL(ata_port_disable);
4893EXPORT_SYMBOL_GPL(ata_ratelimit);
4623EXPORT_SYMBOL_GPL(ata_scsi_ioctl); 4894EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
4624EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 4895EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
4625EXPORT_SYMBOL_GPL(ata_scsi_error); 4896EXPORT_SYMBOL_GPL(ata_scsi_error);
@@ -4631,6 +4902,9 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
4631EXPORT_SYMBOL_GPL(ata_dev_config); 4902EXPORT_SYMBOL_GPL(ata_dev_config);
4632EXPORT_SYMBOL_GPL(ata_scsi_simulate); 4903EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4633 4904
4905EXPORT_SYMBOL_GPL(ata_timing_compute);
4906EXPORT_SYMBOL_GPL(ata_timing_merge);
4907
4634#ifdef CONFIG_PCI 4908#ifdef CONFIG_PCI
4635EXPORT_SYMBOL_GPL(pci_test_config_bits); 4909EXPORT_SYMBOL_GPL(pci_test_config_bits);
4636EXPORT_SYMBOL_GPL(ata_pci_host_stop); 4910EXPORT_SYMBOL_GPL(ata_pci_host_stop);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 104fd9a63e73..58858886d751 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -44,11 +44,19 @@
44 44
45#include "libata.h" 45#include "libata.h"
46 46
47typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, u8 *scsicmd); 47typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc, const u8 *scsicmd);
48static struct ata_device * 48static struct ata_device *
49ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev); 49ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev);
50 50
51 51
52static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
53 void (*done)(struct scsi_cmnd *))
54{
55 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x24, 0x0);
56 /* "Invalid field in cbd" */
57 done(cmd);
58}
59
52/** 60/**
53 * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd. 61 * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
54 * @sdev: SCSI device for which BIOS geometry is to be determined 62 * @sdev: SCSI device for which BIOS geometry is to be determined
@@ -182,7 +190,6 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat)
182{ 190{
183 struct scsi_cmnd *cmd = qc->scsicmd; 191 struct scsi_cmnd *cmd = qc->scsicmd;
184 u8 err = 0; 192 u8 err = 0;
185 unsigned char *sb = cmd->sense_buffer;
186 /* Based on the 3ware driver translation table */ 193 /* Based on the 3ware driver translation table */
187 static unsigned char sense_table[][4] = { 194 static unsigned char sense_table[][4] = {
188 /* BBD|ECC|ID|MAR */ 195 /* BBD|ECC|ID|MAR */
@@ -225,8 +232,6 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat)
225 }; 232 };
226 int i = 0; 233 int i = 0;
227 234
228 cmd->result = SAM_STAT_CHECK_CONDITION;
229
230 /* 235 /*
231 * Is this an error we can process/parse 236 * Is this an error we can process/parse
232 */ 237 */
@@ -281,11 +286,9 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat)
281 /* Look for best matches first */ 286 /* Look for best matches first */
282 if((sense_table[i][0] & err) == sense_table[i][0]) 287 if((sense_table[i][0] & err) == sense_table[i][0])
283 { 288 {
284 sb[0] = 0x70; 289 ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */,
285 sb[2] = sense_table[i][1]; 290 sense_table[i][2] /* asc */,
286 sb[7] = 0x0a; 291 sense_table[i][3] /* ascq */ );
287 sb[12] = sense_table[i][2];
288 sb[13] = sense_table[i][3];
289 return; 292 return;
290 } 293 }
291 i++; 294 i++;
@@ -300,11 +303,9 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat)
300 { 303 {
301 if(stat_table[i][0] & drv_stat) 304 if(stat_table[i][0] & drv_stat)
302 { 305 {
303 sb[0] = 0x70; 306 ata_scsi_set_sense(cmd, sense_table[i][1] /* sk */,
304 sb[2] = stat_table[i][1]; 307 sense_table[i][2] /* asc */,
305 sb[7] = 0x0a; 308 sense_table[i][3] /* ascq */ );
306 sb[12] = stat_table[i][2];
307 sb[13] = stat_table[i][3];
308 return; 309 return;
309 } 310 }
310 i++; 311 i++;
@@ -313,15 +314,12 @@ void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat)
313 printk(KERN_ERR "ata%u: called with no error (%02X)!\n", qc->ap->id, drv_stat); 314 printk(KERN_ERR "ata%u: called with no error (%02X)!\n", qc->ap->id, drv_stat);
314 /* additional-sense-code[-qualifier] */ 315 /* additional-sense-code[-qualifier] */
315 316
316 sb[0] = 0x70;
317 sb[2] = MEDIUM_ERROR;
318 sb[7] = 0x0A;
319 if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 317 if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
320 sb[12] = 0x11; /* "unrecovered read error" */ 318 ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0x11, 0x4);
321 sb[13] = 0x04; 319 /* "unrecovered read error" */
322 } else { 320 } else {
323 sb[12] = 0x0C; /* "write error - */ 321 ata_scsi_set_sense(cmd, MEDIUM_ERROR, 0xc, 0x2);
324 sb[13] = 0x02; /* auto-reallocation failed" */ 322 /* "write error - auto-reallocation failed" */
325 } 323 }
326} 324}
327 325
@@ -420,7 +418,7 @@ int ata_scsi_error(struct Scsi_Host *host)
420 */ 418 */
421 419
422static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc, 420static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
423 u8 *scsicmd) 421 const u8 *scsicmd)
424{ 422{
425 struct ata_taskfile *tf = &qc->tf; 423 struct ata_taskfile *tf = &qc->tf;
426 424
@@ -430,15 +428,26 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
430 ; /* ignore IMMED bit, violates sat-r05 */ 428 ; /* ignore IMMED bit, violates sat-r05 */
431 } 429 }
432 if (scsicmd[4] & 0x2) 430 if (scsicmd[4] & 0x2)
433 return 1; /* LOEJ bit set not supported */ 431 goto invalid_fld; /* LOEJ bit set not supported */
434 if (((scsicmd[4] >> 4) & 0xf) != 0) 432 if (((scsicmd[4] >> 4) & 0xf) != 0)
435 return 1; /* power conditions not supported */ 433 goto invalid_fld; /* power conditions not supported */
436 if (scsicmd[4] & 0x1) { 434 if (scsicmd[4] & 0x1) {
437 tf->nsect = 1; /* 1 sector, lba=0 */ 435 tf->nsect = 1; /* 1 sector, lba=0 */
438 tf->lbah = 0x0; 436
439 tf->lbam = 0x0; 437 if (qc->dev->flags & ATA_DFLAG_LBA) {
440 tf->lbal = 0x0; 438 qc->tf.flags |= ATA_TFLAG_LBA;
441 tf->device |= ATA_LBA; 439
440 tf->lbah = 0x0;
441 tf->lbam = 0x0;
442 tf->lbal = 0x0;
443 tf->device |= ATA_LBA;
444 } else {
445 /* CHS */
446 tf->lbal = 0x1; /* sect */
447 tf->lbam = 0x0; /* cyl low */
448 tf->lbah = 0x0; /* cyl high */
449 }
450
442 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ 451 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
443 } else { 452 } else {
444 tf->nsect = 0; /* time period value (0 implies now) */ 453 tf->nsect = 0; /* time period value (0 implies now) */
@@ -453,6 +462,11 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
453 */ 462 */
454 463
455 return 0; 464 return 0;
465
466invalid_fld:
467 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0);
468 /* "Invalid field in cbd" */
469 return 1;
456} 470}
457 471
458 472
@@ -471,14 +485,14 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc,
471 * Zero on success, non-zero on error. 485 * Zero on success, non-zero on error.
472 */ 486 */
473 487
474static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 488static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
475{ 489{
476 struct ata_taskfile *tf = &qc->tf; 490 struct ata_taskfile *tf = &qc->tf;
477 491
478 tf->flags |= ATA_TFLAG_DEVICE; 492 tf->flags |= ATA_TFLAG_DEVICE;
479 tf->protocol = ATA_PROT_NODATA; 493 tf->protocol = ATA_PROT_NODATA;
480 494
481 if ((tf->flags & ATA_TFLAG_LBA48) && 495 if ((qc->dev->flags & ATA_DFLAG_LBA48) &&
482 (ata_id_has_flush_ext(qc->dev->id))) 496 (ata_id_has_flush_ext(qc->dev->id)))
483 tf->command = ATA_CMD_FLUSH_EXT; 497 tf->command = ATA_CMD_FLUSH_EXT;
484 else 498 else
@@ -488,6 +502,99 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
488} 502}
489 503
490/** 504/**
505 * scsi_6_lba_len - Get LBA and transfer length
506 * @scsicmd: SCSI command to translate
507 *
508 * Calculate LBA and transfer length for 6-byte commands.
509 *
510 * RETURNS:
511 * @plba: the LBA
512 * @plen: the transfer length
513 */
514
515static void scsi_6_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
516{
517 u64 lba = 0;
518 u32 len = 0;
519
520 VPRINTK("six-byte command\n");
521
522 lba |= ((u64)scsicmd[2]) << 8;
523 lba |= ((u64)scsicmd[3]);
524
525 len |= ((u32)scsicmd[4]);
526
527 *plba = lba;
528 *plen = len;
529}
530
531/**
532 * scsi_10_lba_len - Get LBA and transfer length
533 * @scsicmd: SCSI command to translate
534 *
535 * Calculate LBA and transfer length for 10-byte commands.
536 *
537 * RETURNS:
538 * @plba: the LBA
539 * @plen: the transfer length
540 */
541
542static void scsi_10_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
543{
544 u64 lba = 0;
545 u32 len = 0;
546
547 VPRINTK("ten-byte command\n");
548
549 lba |= ((u64)scsicmd[2]) << 24;
550 lba |= ((u64)scsicmd[3]) << 16;
551 lba |= ((u64)scsicmd[4]) << 8;
552 lba |= ((u64)scsicmd[5]);
553
554 len |= ((u32)scsicmd[7]) << 8;
555 len |= ((u32)scsicmd[8]);
556
557 *plba = lba;
558 *plen = len;
559}
560
561/**
562 * scsi_16_lba_len - Get LBA and transfer length
563 * @scsicmd: SCSI command to translate
564 *
565 * Calculate LBA and transfer length for 16-byte commands.
566 *
567 * RETURNS:
568 * @plba: the LBA
569 * @plen: the transfer length
570 */
571
572static void scsi_16_lba_len(const u8 *scsicmd, u64 *plba, u32 *plen)
573{
574 u64 lba = 0;
575 u32 len = 0;
576
577 VPRINTK("sixteen-byte command\n");
578
579 lba |= ((u64)scsicmd[2]) << 56;
580 lba |= ((u64)scsicmd[3]) << 48;
581 lba |= ((u64)scsicmd[4]) << 40;
582 lba |= ((u64)scsicmd[5]) << 32;
583 lba |= ((u64)scsicmd[6]) << 24;
584 lba |= ((u64)scsicmd[7]) << 16;
585 lba |= ((u64)scsicmd[8]) << 8;
586 lba |= ((u64)scsicmd[9]);
587
588 len |= ((u32)scsicmd[10]) << 24;
589 len |= ((u32)scsicmd[11]) << 16;
590 len |= ((u32)scsicmd[12]) << 8;
591 len |= ((u32)scsicmd[13]);
592
593 *plba = lba;
594 *plen = len;
595}
596
597/**
491 * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one 598 * ata_scsi_verify_xlat - Translate SCSI VERIFY command into an ATA one
492 * @qc: Storage for translated ATA taskfile 599 * @qc: Storage for translated ATA taskfile
493 * @scsicmd: SCSI command to translate 600 * @scsicmd: SCSI command to translate
@@ -501,82 +608,110 @@ static unsigned int ata_scsi_flush_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
501 * Zero on success, non-zero on error. 608 * Zero on success, non-zero on error.
502 */ 609 */
503 610
504static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 611static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
505{ 612{
506 struct ata_taskfile *tf = &qc->tf; 613 struct ata_taskfile *tf = &qc->tf;
507 unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48; 614 struct ata_device *dev = qc->dev;
508 u64 dev_sectors = qc->dev->n_sectors; 615 u64 dev_sectors = qc->dev->n_sectors;
509 u64 sect = 0; 616 u64 block;
510 u32 n_sect = 0; 617 u32 n_block;
511 618
512 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 619 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
513 tf->protocol = ATA_PROT_NODATA; 620 tf->protocol = ATA_PROT_NODATA;
514 tf->device |= ATA_LBA;
515 621
516 if (scsicmd[0] == VERIFY) { 622 if (scsicmd[0] == VERIFY)
517 sect |= ((u64)scsicmd[2]) << 24; 623 scsi_10_lba_len(scsicmd, &block, &n_block);
518 sect |= ((u64)scsicmd[3]) << 16; 624 else if (scsicmd[0] == VERIFY_16)
519 sect |= ((u64)scsicmd[4]) << 8; 625 scsi_16_lba_len(scsicmd, &block, &n_block);
520 sect |= ((u64)scsicmd[5]); 626 else
627 goto invalid_fld;
521 628
522 n_sect |= ((u32)scsicmd[7]) << 8; 629 if (!n_block)
523 n_sect |= ((u32)scsicmd[8]); 630 goto nothing_to_do;
524 } 631 if (block >= dev_sectors)
632 goto out_of_range;
633 if ((block + n_block) > dev_sectors)
634 goto out_of_range;
525 635
526 else if (scsicmd[0] == VERIFY_16) { 636 if (dev->flags & ATA_DFLAG_LBA) {
527 sect |= ((u64)scsicmd[2]) << 56; 637 tf->flags |= ATA_TFLAG_LBA;
528 sect |= ((u64)scsicmd[3]) << 48;
529 sect |= ((u64)scsicmd[4]) << 40;
530 sect |= ((u64)scsicmd[5]) << 32;
531 sect |= ((u64)scsicmd[6]) << 24;
532 sect |= ((u64)scsicmd[7]) << 16;
533 sect |= ((u64)scsicmd[8]) << 8;
534 sect |= ((u64)scsicmd[9]);
535
536 n_sect |= ((u32)scsicmd[10]) << 24;
537 n_sect |= ((u32)scsicmd[11]) << 16;
538 n_sect |= ((u32)scsicmd[12]) << 8;
539 n_sect |= ((u32)scsicmd[13]);
540 }
541 638
542 else 639 if (dev->flags & ATA_DFLAG_LBA48) {
543 return 1; 640 if (n_block > (64 * 1024))
641 goto invalid_fld;
544 642
545 if (!n_sect) 643 /* use LBA48 */
546 return 1; 644 tf->flags |= ATA_TFLAG_LBA48;
547 if (sect >= dev_sectors) 645 tf->command = ATA_CMD_VERIFY_EXT;
548 return 1;
549 if ((sect + n_sect) > dev_sectors)
550 return 1;
551 if (lba48) {
552 if (n_sect > (64 * 1024))
553 return 1;
554 } else {
555 if (n_sect > 256)
556 return 1;
557 }
558 646
559 if (lba48) { 647 tf->hob_nsect = (n_block >> 8) & 0xff;
560 tf->command = ATA_CMD_VERIFY_EXT;
561 648
562 tf->hob_nsect = (n_sect >> 8) & 0xff; 649 tf->hob_lbah = (block >> 40) & 0xff;
650 tf->hob_lbam = (block >> 32) & 0xff;
651 tf->hob_lbal = (block >> 24) & 0xff;
652 } else {
653 if (n_block > 256)
654 goto invalid_fld;
563 655
564 tf->hob_lbah = (sect >> 40) & 0xff; 656 /* use LBA28 */
565 tf->hob_lbam = (sect >> 32) & 0xff; 657 tf->command = ATA_CMD_VERIFY;
566 tf->hob_lbal = (sect >> 24) & 0xff; 658
659 tf->device |= (block >> 24) & 0xf;
660 }
661
662 tf->nsect = n_block & 0xff;
663
664 tf->lbah = (block >> 16) & 0xff;
665 tf->lbam = (block >> 8) & 0xff;
666 tf->lbal = block & 0xff;
667
668 tf->device |= ATA_LBA;
567 } else { 669 } else {
670 /* CHS */
671 u32 sect, head, cyl, track;
672
673 if (n_block > 256)
674 goto invalid_fld;
675
676 /* Convert LBA to CHS */
677 track = (u32)block / dev->sectors;
678 cyl = track / dev->heads;
679 head = track % dev->heads;
680 sect = (u32)block % dev->sectors + 1;
681
682 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
683 (u32)block, track, cyl, head, sect);
684
685 /* Check whether the converted CHS can fit.
686 Cylinder: 0-65535
687 Head: 0-15
688 Sector: 1-255*/
689 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
690 goto out_of_range;
691
568 tf->command = ATA_CMD_VERIFY; 692 tf->command = ATA_CMD_VERIFY;
569 693 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
570 tf->device |= (sect >> 24) & 0xf; 694 tf->lbal = sect;
695 tf->lbam = cyl;
696 tf->lbah = cyl >> 8;
697 tf->device |= head;
571 } 698 }
572 699
573 tf->nsect = n_sect & 0xff; 700 return 0;
701
702invalid_fld:
703 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0);
704 /* "Invalid field in cbd" */
705 return 1;
574 706
575 tf->lbah = (sect >> 16) & 0xff; 707out_of_range:
576 tf->lbam = (sect >> 8) & 0xff; 708 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0);
577 tf->lbal = sect & 0xff; 709 /* "Logical Block Address out of range" */
710 return 1;
578 711
579 return 0; 712nothing_to_do:
713 qc->scsicmd->result = SAM_STAT_GOOD;
714 return 1;
580} 715}
581 716
582/** 717/**
@@ -599,106 +734,137 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
599 * Zero on success, non-zero on error. 734 * Zero on success, non-zero on error.
600 */ 735 */
601 736
602static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 737static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
603{ 738{
604 struct ata_taskfile *tf = &qc->tf; 739 struct ata_taskfile *tf = &qc->tf;
605 unsigned int lba48 = tf->flags & ATA_TFLAG_LBA48; 740 struct ata_device *dev = qc->dev;
741 u64 block;
742 u32 n_block;
606 743
607 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 744 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
608 tf->protocol = qc->dev->xfer_protocol;
609 tf->device |= ATA_LBA;
610 745
611 if (scsicmd[0] == READ_10 || scsicmd[0] == READ_6 || 746 if (scsicmd[0] == WRITE_10 || scsicmd[0] == WRITE_6 ||
612 scsicmd[0] == READ_16) { 747 scsicmd[0] == WRITE_16)
613 tf->command = qc->dev->read_cmd;
614 } else {
615 tf->command = qc->dev->write_cmd;
616 tf->flags |= ATA_TFLAG_WRITE; 748 tf->flags |= ATA_TFLAG_WRITE;
617 }
618 749
619 if (scsicmd[0] == READ_10 || scsicmd[0] == WRITE_10) { 750 /* Calculate the SCSI LBA and transfer length. */
620 if (lba48) { 751 switch (scsicmd[0]) {
621 tf->hob_nsect = scsicmd[7]; 752 case READ_10:
622 tf->hob_lbal = scsicmd[2]; 753 case WRITE_10:
754 scsi_10_lba_len(scsicmd, &block, &n_block);
755 break;
756 case READ_6:
757 case WRITE_6:
758 scsi_6_lba_len(scsicmd, &block, &n_block);
623 759
624 qc->nsect = ((unsigned int)scsicmd[7] << 8) | 760 /* for 6-byte r/w commands, transfer length 0
625 scsicmd[8]; 761 * means 256 blocks of data, not 0 block.
626 } else { 762 */
627 /* if we don't support LBA48 addressing, the request 763 if (!n_block)
628 * -may- be too large. */ 764 n_block = 256;
629 if ((scsicmd[2] & 0xf0) || scsicmd[7]) 765 break;
630 return 1; 766 case READ_16:
767 case WRITE_16:
768 scsi_16_lba_len(scsicmd, &block, &n_block);
769 break;
770 default:
771 DPRINTK("no-byte command\n");
772 goto invalid_fld;
773 }
631 774
632 /* stores LBA27:24 in lower 4 bits of device reg */ 775 /* Check and compose ATA command */
633 tf->device |= scsicmd[2]; 776 if (!n_block)
777 /* For 10-byte and 16-byte SCSI R/W commands, transfer
778 * length 0 means transfer 0 block of data.
779 * However, for ATA R/W commands, sector count 0 means
780 * 256 or 65536 sectors, not 0 sectors as in SCSI.
781 */
782 goto nothing_to_do;
634 783
635 qc->nsect = scsicmd[8]; 784 if (dev->flags & ATA_DFLAG_LBA) {
636 } 785 tf->flags |= ATA_TFLAG_LBA;
637 786
638 tf->nsect = scsicmd[8]; 787 if (dev->flags & ATA_DFLAG_LBA48) {
639 tf->lbal = scsicmd[5]; 788 /* The request -may- be too large for LBA48. */
640 tf->lbam = scsicmd[4]; 789 if ((block >> 48) || (n_block > 65536))
641 tf->lbah = scsicmd[3]; 790 goto out_of_range;
642 791
643 VPRINTK("ten-byte command\n"); 792 /* use LBA48 */
644 if (qc->nsect == 0) /* we don't support length==0 cmds */ 793 tf->flags |= ATA_TFLAG_LBA48;
645 return 1;
646 return 0;
647 }
648 794
649 if (scsicmd[0] == READ_6 || scsicmd[0] == WRITE_6) { 795 tf->hob_nsect = (n_block >> 8) & 0xff;
650 qc->nsect = tf->nsect = scsicmd[4];
651 if (!qc->nsect) {
652 qc->nsect = 256;
653 if (lba48)
654 tf->hob_nsect = 1;
655 }
656 796
657 tf->lbal = scsicmd[3]; 797 tf->hob_lbah = (block >> 40) & 0xff;
658 tf->lbam = scsicmd[2]; 798 tf->hob_lbam = (block >> 32) & 0xff;
659 tf->lbah = scsicmd[1] & 0x1f; /* mask out reserved bits */ 799 tf->hob_lbal = (block >> 24) & 0xff;
800 } else {
801 /* use LBA28 */
660 802
661 VPRINTK("six-byte command\n"); 803 /* The request -may- be too large for LBA28. */
662 return 0; 804 if ((block >> 28) || (n_block > 256))
663 } 805 goto out_of_range;
664 806
665 if (scsicmd[0] == READ_16 || scsicmd[0] == WRITE_16) { 807 tf->device |= (block >> 24) & 0xf;
666 /* rule out impossible LBAs and sector counts */ 808 }
667 if (scsicmd[2] || scsicmd[3] || scsicmd[10] || scsicmd[11])
668 return 1;
669 809
670 if (lba48) { 810 ata_rwcmd_protocol(qc);
671 tf->hob_nsect = scsicmd[12];
672 tf->hob_lbal = scsicmd[6];
673 tf->hob_lbam = scsicmd[5];
674 tf->hob_lbah = scsicmd[4];
675 811
676 qc->nsect = ((unsigned int)scsicmd[12] << 8) | 812 qc->nsect = n_block;
677 scsicmd[13]; 813 tf->nsect = n_block & 0xff;
678 } else {
679 /* once again, filter out impossible non-zero values */
680 if (scsicmd[4] || scsicmd[5] || scsicmd[12] ||
681 (scsicmd[6] & 0xf0))
682 return 1;
683 814
684 /* stores LBA27:24 in lower 4 bits of device reg */ 815 tf->lbah = (block >> 16) & 0xff;
685 tf->device |= scsicmd[6]; 816 tf->lbam = (block >> 8) & 0xff;
817 tf->lbal = block & 0xff;
686 818
687 qc->nsect = scsicmd[13]; 819 tf->device |= ATA_LBA;
688 } 820 } else {
821 /* CHS */
822 u32 sect, head, cyl, track;
823
824 /* The request -may- be too large for CHS addressing. */
825 if ((block >> 28) || (n_block > 256))
826 goto out_of_range;
827
828 ata_rwcmd_protocol(qc);
829
830 /* Convert LBA to CHS */
831 track = (u32)block / dev->sectors;
832 cyl = track / dev->heads;
833 head = track % dev->heads;
834 sect = (u32)block % dev->sectors + 1;
835
836 DPRINTK("block %u track %u cyl %u head %u sect %u\n",
837 (u32)block, track, cyl, head, sect);
838
839 /* Check whether the converted CHS can fit.
840 Cylinder: 0-65535
841 Head: 0-15
842 Sector: 1-255*/
843 if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
844 goto out_of_range;
845
846 qc->nsect = n_block;
847 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
848 tf->lbal = sect;
849 tf->lbam = cyl;
850 tf->lbah = cyl >> 8;
851 tf->device |= head;
852 }
689 853
690 tf->nsect = scsicmd[13]; 854 return 0;
691 tf->lbal = scsicmd[9];
692 tf->lbam = scsicmd[8];
693 tf->lbah = scsicmd[7];
694 855
695 VPRINTK("sixteen-byte command\n"); 856invalid_fld:
696 if (qc->nsect == 0) /* we don't support length==0 cmds */ 857 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x0);
697 return 1; 858 /* "Invalid field in cbd" */
698 return 0; 859 return 1;
699 } 860
861out_of_range:
862 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x21, 0x0);
863 /* "Logical Block Address out of range" */
864 return 1;
700 865
701 DPRINTK("no-byte command\n"); 866nothing_to_do:
867 qc->scsicmd->result = SAM_STAT_GOOD;
702 return 1; 868 return 1;
703} 869}
704 870
@@ -731,6 +897,12 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
731 * This function sets up an ata_queued_cmd structure for the 897 * This function sets up an ata_queued_cmd structure for the
732 * SCSI command, and sends that ata_queued_cmd to the hardware. 898 * SCSI command, and sends that ata_queued_cmd to the hardware.
733 * 899 *
900 * The xlat_func argument (actor) returns 0 if ready to execute
901 * ATA command, else 1 to finish translation. If 1 is returned
902 * then cmd->result (and possibly cmd->sense_buffer) are assumed
903 * to be set reflecting an error condition or clean (early)
904 * termination.
905 *
734 * LOCKING: 906 * LOCKING:
735 * spin_lock_irqsave(host_set lock) 907 * spin_lock_irqsave(host_set lock)
736 */ 908 */
@@ -747,7 +919,7 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
747 919
748 qc = ata_scsi_qc_new(ap, dev, cmd, done); 920 qc = ata_scsi_qc_new(ap, dev, cmd, done);
749 if (!qc) 921 if (!qc)
750 return; 922 goto err_mem;
751 923
752 /* data is present; dma-map it */ 924 /* data is present; dma-map it */
753 if (cmd->sc_data_direction == DMA_FROM_DEVICE || 925 if (cmd->sc_data_direction == DMA_FROM_DEVICE ||
@@ -755,7 +927,7 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
755 if (unlikely(cmd->request_bufflen < 1)) { 927 if (unlikely(cmd->request_bufflen < 1)) {
756 printk(KERN_WARNING "ata%u(%u): WARNING: zero len r/w req\n", 928 printk(KERN_WARNING "ata%u(%u): WARNING: zero len r/w req\n",
757 ap->id, dev->devno); 929 ap->id, dev->devno);
758 goto err_out; 930 goto err_did;
759 } 931 }
760 932
761 if (cmd->use_sg) 933 if (cmd->use_sg)
@@ -770,19 +942,28 @@ static void ata_scsi_translate(struct ata_port *ap, struct ata_device *dev,
770 qc->complete_fn = ata_scsi_qc_complete; 942 qc->complete_fn = ata_scsi_qc_complete;
771 943
772 if (xlat_func(qc, scsicmd)) 944 if (xlat_func(qc, scsicmd))
773 goto err_out; 945 goto early_finish;
774 946
775 /* select device, send command to hardware */ 947 /* select device, send command to hardware */
776 if (ata_qc_issue(qc)) 948 if (ata_qc_issue(qc))
777 goto err_out; 949 goto err_did;
778 950
779 VPRINTK("EXIT\n"); 951 VPRINTK("EXIT\n");
780 return; 952 return;
781 953
782err_out: 954early_finish:
955 ata_qc_free(qc);
956 done(cmd);
957 DPRINTK("EXIT - early finish (good or error)\n");
958 return;
959
960err_did:
783 ata_qc_free(qc); 961 ata_qc_free(qc);
784 ata_bad_cdb(cmd, done); 962err_mem:
785 DPRINTK("EXIT - badcmd\n"); 963 cmd->result = (DID_ERROR << 16);
964 done(cmd);
965 DPRINTK("EXIT - internal\n");
966 return;
786} 967}
787 968
788/** 969/**
@@ -849,7 +1030,8 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf)
849 * Mapping the response buffer, calling the command's handler, 1030 * Mapping the response buffer, calling the command's handler,
850 * and handling the handler's return value. This return value 1031 * and handling the handler's return value. This return value
851 * indicates whether the handler wishes the SCSI command to be 1032 * indicates whether the handler wishes the SCSI command to be
852 * completed successfully, or not. 1033 * completed successfully (0), or not (in which case cmd->result
1034 * and sense buffer are assumed to be set).
853 * 1035 *
854 * LOCKING: 1036 * LOCKING:
855 * spin_lock_irqsave(host_set lock) 1037 * spin_lock_irqsave(host_set lock)
@@ -868,12 +1050,9 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
868 rc = actor(args, rbuf, buflen); 1050 rc = actor(args, rbuf, buflen);
869 ata_scsi_rbuf_put(cmd, rbuf); 1051 ata_scsi_rbuf_put(cmd, rbuf);
870 1052
871 if (rc) 1053 if (rc == 0)
872 ata_bad_cdb(cmd, args->done);
873 else {
874 cmd->result = SAM_STAT_GOOD; 1054 cmd->result = SAM_STAT_GOOD;
875 args->done(cmd); 1055 args->done(cmd);
876 }
877} 1056}
878 1057
879/** 1058/**
@@ -1179,8 +1358,16 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1179 * in the same manner) 1358 * in the same manner)
1180 */ 1359 */
1181 page_control = scsicmd[2] >> 6; 1360 page_control = scsicmd[2] >> 6;
1182 if ((page_control != 0) && (page_control != 3)) 1361 switch (page_control) {
1183 return 1; 1362 case 0: /* current */
1363 break; /* supported */
1364 case 3: /* saved */
1365 goto saving_not_supp;
1366 case 1: /* changeable */
1367 case 2: /* defaults */
1368 default:
1369 goto invalid_fld;
1370 }
1184 1371
1185 if (six_byte) 1372 if (six_byte)
1186 output_len = 4; 1373 output_len = 4;
@@ -1211,7 +1398,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1211 break; 1398 break;
1212 1399
1213 default: /* invalid page code */ 1400 default: /* invalid page code */
1214 return 1; 1401 goto invalid_fld;
1215 } 1402 }
1216 1403
1217 if (six_byte) { 1404 if (six_byte) {
@@ -1224,6 +1411,16 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1224 } 1411 }
1225 1412
1226 return 0; 1413 return 0;
1414
1415invalid_fld:
1416 ata_scsi_set_sense(args->cmd, ILLEGAL_REQUEST, 0x24, 0x0);
1417 /* "Invalid field in cbd" */
1418 return 1;
1419
1420saving_not_supp:
1421 ata_scsi_set_sense(args->cmd, ILLEGAL_REQUEST, 0x39, 0x0);
1422 /* "Saving parameters not supported" */
1423 return 1;
1227} 1424}
1228 1425
1229/** 1426/**
@@ -1246,10 +1443,20 @@ unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf,
1246 1443
1247 VPRINTK("ENTER\n"); 1444 VPRINTK("ENTER\n");
1248 1445
1249 if (ata_id_has_lba48(args->id)) 1446 if (ata_id_has_lba(args->id)) {
1250 n_sectors = ata_id_u64(args->id, 100); 1447 if (ata_id_has_lba48(args->id))
1251 else 1448 n_sectors = ata_id_u64(args->id, 100);
1252 n_sectors = ata_id_u32(args->id, 60); 1449 else
1450 n_sectors = ata_id_u32(args->id, 60);
1451 } else {
1452 /* CHS default translation */
1453 n_sectors = args->id[1] * args->id[3] * args->id[6];
1454
1455 if (ata_id_current_chs_valid(args->id))
1456 /* CHS current translation */
1457 n_sectors = ata_id_u32(args->id, 57);
1458 }
1459
1253 n_sectors--; /* ATA TotalUserSectors - 1 */ 1460 n_sectors--; /* ATA TotalUserSectors - 1 */
1254 1461
1255 if (args->cmd->cmnd[0] == READ_CAPACITY) { 1462 if (args->cmd->cmnd[0] == READ_CAPACITY) {
@@ -1313,6 +1520,34 @@ unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
1313} 1520}
1314 1521
1315/** 1522/**
1523 * ata_scsi_set_sense - Set SCSI sense data and status
1524 * @cmd: SCSI request to be handled
1525 * @sk: SCSI-defined sense key
1526 * @asc: SCSI-defined additional sense code
1527 * @ascq: SCSI-defined additional sense code qualifier
1528 *
1529 * Helper function that builds a valid fixed format, current
1530 * response code and the given sense key (sk), additional sense
1531 * code (asc) and additional sense code qualifier (ascq) with
1532 * a SCSI command status of %SAM_STAT_CHECK_CONDITION and
1533 * DRIVER_SENSE set in the upper bits of scsi_cmnd::result .
1534 *
1535 * LOCKING:
1536 * Not required
1537 */
1538
1539void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
1540{
1541 cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
1542
1543 cmd->sense_buffer[0] = 0x70; /* fixed format, current */
1544 cmd->sense_buffer[2] = sk;
1545 cmd->sense_buffer[7] = 18 - 8; /* additional sense length */
1546 cmd->sense_buffer[12] = asc;
1547 cmd->sense_buffer[13] = ascq;
1548}
1549
1550/**
1316 * ata_scsi_badcmd - End a SCSI request with an error 1551 * ata_scsi_badcmd - End a SCSI request with an error
1317 * @cmd: SCSI request to be handled 1552 * @cmd: SCSI request to be handled
1318 * @done: SCSI command completion function 1553 * @done: SCSI command completion function
@@ -1330,30 +1565,84 @@ unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
1330void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq) 1565void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq)
1331{ 1566{
1332 DPRINTK("ENTER\n"); 1567 DPRINTK("ENTER\n");
1333 cmd->result = SAM_STAT_CHECK_CONDITION; 1568 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, asc, ascq);
1334
1335 cmd->sense_buffer[0] = 0x70;
1336 cmd->sense_buffer[2] = ILLEGAL_REQUEST;
1337 cmd->sense_buffer[7] = 14 - 8; /* addnl. sense len. FIXME: correct? */
1338 cmd->sense_buffer[12] = asc;
1339 cmd->sense_buffer[13] = ascq;
1340 1569
1341 done(cmd); 1570 done(cmd);
1342} 1571}
1343 1572
1573void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
1574 struct scsi_cmnd *cmd)
1575{
1576 DECLARE_COMPLETION(wait);
1577 struct ata_queued_cmd *qc;
1578 unsigned long flags;
1579 int rc;
1580
1581 DPRINTK("ATAPI request sense\n");
1582
1583 qc = ata_qc_new_init(ap, dev);
1584 BUG_ON(qc == NULL);
1585
1586 /* FIXME: is this needed? */
1587 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
1588
1589 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
1590 qc->dma_dir = DMA_FROM_DEVICE;
1591
1592 memset(&qc->cdb, 0, ap->cdb_len);
1593 qc->cdb[0] = REQUEST_SENSE;
1594 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
1595
1596 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1597 qc->tf.command = ATA_CMD_PACKET;
1598
1599 qc->tf.protocol = ATA_PROT_ATAPI;
1600 qc->tf.lbam = (8 * 1024) & 0xff;
1601 qc->tf.lbah = (8 * 1024) >> 8;
1602 qc->nbytes = SCSI_SENSE_BUFFERSIZE;
1603
1604 qc->waiting = &wait;
1605 qc->complete_fn = ata_qc_complete_noop;
1606
1607 spin_lock_irqsave(&ap->host_set->lock, flags);
1608 rc = ata_qc_issue(qc);
1609 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1610
1611 if (rc)
1612 ata_port_disable(ap);
1613 else
1614 wait_for_completion(&wait);
1615
1616 DPRINTK("EXIT\n");
1617}
1618
1344static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 1619static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1345{ 1620{
1346 struct scsi_cmnd *cmd = qc->scsicmd; 1621 struct scsi_cmnd *cmd = qc->scsicmd;
1347 1622
1348 if (unlikely(drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ))) { 1623 VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat);
1624
1625 if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ)))
1626 ata_to_sense_error(qc, drv_stat);
1627
1628 else if (unlikely(drv_stat & ATA_ERR)) {
1349 DPRINTK("request check condition\n"); 1629 DPRINTK("request check condition\n");
1350 1630
1631 /* FIXME: command completion with check condition
1632 * but no sense causes the error handler to run,
1633 * which then issues REQUEST SENSE, fills in the sense
1634 * buffer, and completes the command (for the second
1635 * time). We need to issue REQUEST SENSE some other
1636 * way, to avoid completing the command twice.
1637 */
1351 cmd->result = SAM_STAT_CHECK_CONDITION; 1638 cmd->result = SAM_STAT_CHECK_CONDITION;
1352 1639
1353 qc->scsidone(cmd); 1640 qc->scsidone(cmd);
1354 1641
1355 return 1; 1642 return 1;
1356 } else { 1643 }
1644
1645 else {
1357 u8 *scsicmd = cmd->cmnd; 1646 u8 *scsicmd = cmd->cmnd;
1358 1647
1359 if (scsicmd[0] == INQUIRY) { 1648 if (scsicmd[0] == INQUIRY) {
@@ -1361,15 +1650,30 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1361 unsigned int buflen; 1650 unsigned int buflen;
1362 1651
1363 buflen = ata_scsi_rbuf_get(cmd, &buf); 1652 buflen = ata_scsi_rbuf_get(cmd, &buf);
1364 buf[2] = 0x5; 1653
1365 buf[3] = (buf[3] & 0xf0) | 2; 1654 /* ATAPI devices typically report zero for their SCSI version,
1655 * and sometimes deviate from the spec WRT response data
1656 * format. If SCSI version is reported as zero like normal,
1657 * then we make the following fixups: 1) Fake MMC-5 version,
1658 * to indicate to the Linux scsi midlayer this is a modern
1659 * device. 2) Ensure response data format / ATAPI information
1660 * are always correct.
1661 */
1662 /* FIXME: do we ever override EVPD pages and the like, with
1663 * this code?
1664 */
1665 if (buf[2] == 0) {
1666 buf[2] = 0x5;
1667 buf[3] = 0x32;
1668 }
1669
1366 ata_scsi_rbuf_put(cmd, buf); 1670 ata_scsi_rbuf_put(cmd, buf);
1367 } 1671 }
1672
1368 cmd->result = SAM_STAT_GOOD; 1673 cmd->result = SAM_STAT_GOOD;
1369 } 1674 }
1370 1675
1371 qc->scsidone(cmd); 1676 qc->scsidone(cmd);
1372
1373 return 0; 1677 return 0;
1374} 1678}
1375/** 1679/**
@@ -1384,7 +1688,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1384 * Zero on success, non-zero on failure. 1688 * Zero on success, non-zero on failure.
1385 */ 1689 */
1386 1690
1387static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd) 1691static unsigned int atapi_xlat(struct ata_queued_cmd *qc, const u8 *scsicmd)
1388{ 1692{
1389 struct scsi_cmnd *cmd = qc->scsicmd; 1693 struct scsi_cmnd *cmd = qc->scsicmd;
1390 struct ata_device *dev = qc->dev; 1694 struct ata_device *dev = qc->dev;
@@ -1453,7 +1757,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc, u8 *scsicmd)
1453 */ 1757 */
1454 1758
1455static struct ata_device * 1759static struct ata_device *
1456ata_scsi_find_dev(struct ata_port *ap, struct scsi_device *scsidev) 1760ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
1457{ 1761{
1458 struct ata_device *dev; 1762 struct ata_device *dev;
1459 1763
@@ -1610,7 +1914,7 @@ void ata_scsi_simulate(u16 *id,
1610 void (*done)(struct scsi_cmnd *)) 1914 void (*done)(struct scsi_cmnd *))
1611{ 1915{
1612 struct ata_scsi_args args; 1916 struct ata_scsi_args args;
1613 u8 *scsicmd = cmd->cmnd; 1917 const u8 *scsicmd = cmd->cmnd;
1614 1918
1615 args.id = id; 1919 args.id = id;
1616 args.cmd = cmd; 1920 args.cmd = cmd;
@@ -1630,7 +1934,7 @@ void ata_scsi_simulate(u16 *id,
1630 1934
1631 case INQUIRY: 1935 case INQUIRY:
1632 if (scsicmd[1] & 2) /* is CmdDt set? */ 1936 if (scsicmd[1] & 2) /* is CmdDt set? */
1633 ata_bad_cdb(cmd, done); 1937 ata_scsi_invalid_field(cmd, done);
1634 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */ 1938 else if ((scsicmd[1] & 1) == 0) /* is EVPD clear? */
1635 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std); 1939 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_std);
1636 else if (scsicmd[2] == 0x00) 1940 else if (scsicmd[2] == 0x00)
@@ -1640,7 +1944,7 @@ void ata_scsi_simulate(u16 *id,
1640 else if (scsicmd[2] == 0x83) 1944 else if (scsicmd[2] == 0x83)
1641 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83); 1945 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_83);
1642 else 1946 else
1643 ata_bad_cdb(cmd, done); 1947 ata_scsi_invalid_field(cmd, done);
1644 break; 1948 break;
1645 1949
1646 case MODE_SENSE: 1950 case MODE_SENSE:
@@ -1650,7 +1954,7 @@ void ata_scsi_simulate(u16 *id,
1650 1954
1651 case MODE_SELECT: /* unconditionally return */ 1955 case MODE_SELECT: /* unconditionally return */
1652 case MODE_SELECT_10: /* bad-field-in-cdb */ 1956 case MODE_SELECT_10: /* bad-field-in-cdb */
1653 ata_bad_cdb(cmd, done); 1957 ata_scsi_invalid_field(cmd, done);
1654 break; 1958 break;
1655 1959
1656 case READ_CAPACITY: 1960 case READ_CAPACITY:
@@ -1661,7 +1965,7 @@ void ata_scsi_simulate(u16 *id,
1661 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16) 1965 if ((scsicmd[1] & 0x1f) == SAI_READ_CAPACITY_16)
1662 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap); 1966 ata_scsi_rbuf_fill(&args, ata_scsiop_read_cap);
1663 else 1967 else
1664 ata_bad_cdb(cmd, done); 1968 ata_scsi_invalid_field(cmd, done);
1665 break; 1969 break;
1666 1970
1667 case REPORT_LUNS: 1971 case REPORT_LUNS:
@@ -1673,8 +1977,26 @@ void ata_scsi_simulate(u16 *id,
1673 1977
1674 /* all other commands */ 1978 /* all other commands */
1675 default: 1979 default:
1676 ata_bad_scsiop(cmd, done); 1980 ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, 0x20, 0x0);
1981 /* "Invalid command operation code" */
1982 done(cmd);
1677 break; 1983 break;
1678 } 1984 }
1679} 1985}
1680 1986
1987void ata_scsi_scan_host(struct ata_port *ap)
1988{
1989 struct ata_device *dev;
1990 unsigned int i;
1991
1992 if (ap->flags & ATA_FLAG_PORT_DISABLED)
1993 return;
1994
1995 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1996 dev = &ap->device[i];
1997
1998 if (ata_dev_present(dev))
1999 scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
2000 }
2001}
2002
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index d608b3a0f6fe..3d60190584ba 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -39,18 +39,23 @@ struct ata_scsi_args {
39 39
40/* libata-core.c */ 40/* libata-core.c */
41extern int atapi_enabled; 41extern int atapi_enabled;
42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
42extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
43 struct ata_device *dev); 44 struct ata_device *dev);
45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
44extern void ata_qc_free(struct ata_queued_cmd *qc); 46extern void ata_qc_free(struct ata_queued_cmd *qc);
45extern int ata_qc_issue(struct ata_queued_cmd *qc); 47extern int ata_qc_issue(struct ata_queued_cmd *qc);
46extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
47extern void ata_dev_select(struct ata_port *ap, unsigned int device, 49extern void ata_dev_select(struct ata_port *ap, unsigned int device,
48 unsigned int wait, unsigned int can_sleep); 50 unsigned int wait, unsigned int can_sleep);
49extern void ata_tf_to_host_nolock(struct ata_port *ap, struct ata_taskfile *tf); 51extern void ata_tf_to_host_nolock(struct ata_port *ap, const struct ata_taskfile *tf);
50extern void swap_buf_le16(u16 *buf, unsigned int buf_words); 52extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
51 53
52 54
53/* libata-scsi.c */ 55/* libata-scsi.c */
56extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
57 struct scsi_cmnd *cmd);
58extern void ata_scsi_scan_host(struct ata_port *ap);
54extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat); 59extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat);
55extern int ata_scsi_error(struct Scsi_Host *host); 60extern int ata_scsi_error(struct Scsi_Host *host);
56extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 61extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
@@ -76,18 +81,10 @@ extern unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf,
76extern void ata_scsi_badcmd(struct scsi_cmnd *cmd, 81extern void ata_scsi_badcmd(struct scsi_cmnd *cmd,
77 void (*done)(struct scsi_cmnd *), 82 void (*done)(struct scsi_cmnd *),
78 u8 asc, u8 ascq); 83 u8 asc, u8 ascq);
84extern void ata_scsi_set_sense(struct scsi_cmnd *cmd,
85 u8 sk, u8 asc, u8 ascq);
79extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, 86extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
80 unsigned int (*actor) (struct ata_scsi_args *args, 87 unsigned int (*actor) (struct ata_scsi_args *args,
81 u8 *rbuf, unsigned int buflen)); 88 u8 *rbuf, unsigned int buflen));
82 89
83static inline void ata_bad_scsiop(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
84{
85 ata_scsi_badcmd(cmd, done, 0x20, 0x00);
86}
87
88static inline void ata_bad_cdb(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
89{
90 ata_scsi_badcmd(cmd, done, 0x24, 0x00);
91}
92
93#endif /* __LIBATA_H__ */ 90#endif /* __LIBATA_H__ */
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index 0aba13ceaacf..352df47bcaca 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -39,7 +39,7 @@
39#define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */ 39#define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */
40 40
41static void * 41static void *
42lpfc_pool_kmalloc(unsigned int gfp_flags, void *data) 42lpfc_pool_kmalloc(gfp_t gfp_flags, void *data)
43{ 43{
44 return kmalloc((unsigned long)data, gfp_flags); 44 return kmalloc((unsigned long)data, gfp_flags);
45} 45}
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index d47be8e0ea3a..c9e743ba09ec 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -76,7 +76,7 @@ static void megaraid_exit(void);
76 76
77static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *); 77static int megaraid_probe_one(struct pci_dev*, const struct pci_device_id *);
78static void megaraid_detach_one(struct pci_dev *); 78static void megaraid_detach_one(struct pci_dev *);
79static void megaraid_mbox_shutdown(struct device *); 79static void megaraid_mbox_shutdown(struct pci_dev *);
80 80
81static int megaraid_io_attach(adapter_t *); 81static int megaraid_io_attach(adapter_t *);
82static void megaraid_io_detach(adapter_t *); 82static void megaraid_io_detach(adapter_t *);
@@ -369,9 +369,7 @@ static struct pci_driver megaraid_pci_driver_g = {
369 .id_table = pci_id_table_g, 369 .id_table = pci_id_table_g,
370 .probe = megaraid_probe_one, 370 .probe = megaraid_probe_one,
371 .remove = __devexit_p(megaraid_detach_one), 371 .remove = __devexit_p(megaraid_detach_one),
372 .driver = { 372 .shutdown = megaraid_mbox_shutdown,
373 .shutdown = megaraid_mbox_shutdown,
374 }
375}; 373};
376 374
377 375
@@ -673,9 +671,9 @@ megaraid_detach_one(struct pci_dev *pdev)
673 * Shutdown notification, perform flush cache 671 * Shutdown notification, perform flush cache
674 */ 672 */
675static void 673static void
676megaraid_mbox_shutdown(struct device *device) 674megaraid_mbox_shutdown(struct pci_dev *pdev)
677{ 675{
678 adapter_t *adapter = pci_get_drvdata(to_pci_dev(device)); 676 adapter_t *adapter = pci_get_drvdata(pdev);
679 static int counter; 677 static int counter;
680 678
681 if (!adapter) { 679 if (!adapter) {
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 3f2f2464fa63..172839fce0eb 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5146,7 +5146,8 @@ static long osst_compat_ioctl(struct file * file, unsigned int cmd_in, unsigned
5146/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */ 5146/* Try to allocate a new tape buffer skeleton. Caller must not hold os_scsi_tapes_lock */
5147static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg ) 5147static struct osst_buffer * new_tape_buffer( int from_initialization, int need_dma, int max_sg )
5148{ 5148{
5149 int i, priority; 5149 int i;
5150 gfp_t priority;
5150 struct osst_buffer *tb; 5151 struct osst_buffer *tb;
5151 5152
5152 if (from_initialization) 5153 if (from_initialization)
@@ -5178,7 +5179,8 @@ static struct osst_buffer * new_tape_buffer( int from_initialization, int need_d
5178/* Try to allocate a temporary (while a user has the device open) enlarged tape buffer */ 5179/* Try to allocate a temporary (while a user has the device open) enlarged tape buffer */
5179static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) 5180static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5180{ 5181{
5181 int segs, nbr, max_segs, b_size, priority, order, got; 5182 int segs, nbr, max_segs, b_size, order, got;
5183 gfp_t priority;
5182 5184
5183 if (STbuffer->buffer_size >= OS_FRAME_SIZE) 5185 if (STbuffer->buffer_size >= OS_FRAME_SIZE)
5184 return 1; 5186 return 1;
@@ -5627,7 +5629,7 @@ static void osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape *
5627 5629
5628 if (!osst_sysfs_valid) return; 5630 if (!osst_sysfs_valid) return;
5629 5631
5630 osst_class_member = class_device_create(osst_sysfs_class, dev, device, "%s", name); 5632 osst_class_member = class_device_create(osst_sysfs_class, NULL, dev, device, "%s", name);
5631 if (IS_ERR(osst_class_member)) { 5633 if (IS_ERR(osst_class_member)) {
5632 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5634 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
5633 return; 5635 return;
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
new file mode 100644
index 000000000000..9820f272f889
--- /dev/null
+++ b/drivers/scsi/pdc_adma.c
@@ -0,0 +1,739 @@
1/*
2 * pdc_adma.c - Pacific Digital Corporation ADMA
3 *
4 * Maintained by: Mark Lord <mlord@pobox.com>
5 *
6 * Copyright 2005 Mark Lord
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 *
23 * libata documentation is available via 'make {ps|pdf}docs',
24 * as Documentation/DocBook/libata.*
25 *
26 *
27 * Supports ATA disks in single-packet ADMA mode.
28 * Uses PIO for everything else.
29 *
30 * TODO: Use ADMA transfers for ATAPI devices, when possible.
31 * This requires careful attention to a number of quirks of the chip.
32 *
33 */
34
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/pci.h>
38#include <linux/init.h>
39#include <linux/blkdev.h>
40#include <linux/delay.h>
41#include <linux/interrupt.h>
42#include <linux/sched.h>
43#include "scsi.h"
44#include <scsi/scsi_host.h>
45#include <asm/io.h>
46#include <linux/libata.h>
47
48#define DRV_NAME "pdc_adma"
49#define DRV_VERSION "0.01"
50
51/* macro to calculate base address for ATA regs */
52#define ADMA_ATA_REGS(base,port_no) ((base) + ((port_no) * 0x40))
53
54/* macro to calculate base address for ADMA regs */
55#define ADMA_REGS(base,port_no) ((base) + 0x80 + ((port_no) * 0x20))
56
57enum {
58 ADMA_PORTS = 2,
59 ADMA_CPB_BYTES = 40,
60 ADMA_PRD_BYTES = LIBATA_MAX_PRD * 16,
61 ADMA_PKT_BYTES = ADMA_CPB_BYTES + ADMA_PRD_BYTES,
62
63 ADMA_DMA_BOUNDARY = 0xffffffff,
64
65 /* global register offsets */
66 ADMA_MODE_LOCK = 0x00c7,
67
68 /* per-channel register offsets */
69 ADMA_CONTROL = 0x0000, /* ADMA control */
70 ADMA_STATUS = 0x0002, /* ADMA status */
71 ADMA_CPB_COUNT = 0x0004, /* CPB count */
72 ADMA_CPB_CURRENT = 0x000c, /* current CPB address */
73 ADMA_CPB_NEXT = 0x000c, /* next CPB address */
74 ADMA_CPB_LOOKUP = 0x0010, /* CPB lookup table */
75 ADMA_FIFO_IN = 0x0014, /* input FIFO threshold */
76 ADMA_FIFO_OUT = 0x0016, /* output FIFO threshold */
77
78 /* ADMA_CONTROL register bits */
79 aNIEN = (1 << 8), /* irq mask: 1==masked */
80 aGO = (1 << 7), /* packet trigger ("Go!") */
81 aRSTADM = (1 << 5), /* ADMA logic reset */
82 aRSTA = (1 << 2), /* ATA hard reset */
83 aPIOMD4 = 0x0003, /* PIO mode 4 */
84
85 /* ADMA_STATUS register bits */
86 aPSD = (1 << 6),
87 aUIRQ = (1 << 4),
88 aPERR = (1 << 0),
89
90 /* CPB bits */
91 cDONE = (1 << 0),
92 cVLD = (1 << 0),
93 cDAT = (1 << 2),
94 cIEN = (1 << 3),
95
96 /* PRD bits */
97 pORD = (1 << 4),
98 pDIRO = (1 << 5),
99 pEND = (1 << 7),
100
101 /* ATA register flags */
102 rIGN = (1 << 5),
103 rEND = (1 << 7),
104
105 /* ATA register addresses */
106 ADMA_REGS_CONTROL = 0x0e,
107 ADMA_REGS_SECTOR_COUNT = 0x12,
108 ADMA_REGS_LBA_LOW = 0x13,
109 ADMA_REGS_LBA_MID = 0x14,
110 ADMA_REGS_LBA_HIGH = 0x15,
111 ADMA_REGS_DEVICE = 0x16,
112 ADMA_REGS_COMMAND = 0x17,
113
114 /* PCI device IDs */
115 board_1841_idx = 0, /* ADMA 2-port controller */
116};
117
118typedef enum { adma_state_idle, adma_state_pkt, adma_state_mmio } adma_state_t;
119
120struct adma_port_priv {
121 u8 *pkt;
122 dma_addr_t pkt_dma;
123 adma_state_t state;
124};
125
126static int adma_ata_init_one (struct pci_dev *pdev,
127 const struct pci_device_id *ent);
128static irqreturn_t adma_intr (int irq, void *dev_instance,
129 struct pt_regs *regs);
130static int adma_port_start(struct ata_port *ap);
131static void adma_host_stop(struct ata_host_set *host_set);
132static void adma_port_stop(struct ata_port *ap);
133static void adma_phy_reset(struct ata_port *ap);
134static void adma_qc_prep(struct ata_queued_cmd *qc);
135static int adma_qc_issue(struct ata_queued_cmd *qc);
136static int adma_check_atapi_dma(struct ata_queued_cmd *qc);
137static void adma_bmdma_stop(struct ata_queued_cmd *qc);
138static u8 adma_bmdma_status(struct ata_port *ap);
139static void adma_irq_clear(struct ata_port *ap);
140static void adma_eng_timeout(struct ata_port *ap);
141
142static Scsi_Host_Template adma_ata_sht = {
143 .module = THIS_MODULE,
144 .name = DRV_NAME,
145 .ioctl = ata_scsi_ioctl,
146 .queuecommand = ata_scsi_queuecmd,
147 .eh_strategy_handler = ata_scsi_error,
148 .can_queue = ATA_DEF_QUEUE,
149 .this_id = ATA_SHT_THIS_ID,
150 .sg_tablesize = LIBATA_MAX_PRD,
151 .max_sectors = ATA_MAX_SECTORS,
152 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
153 .emulated = ATA_SHT_EMULATED,
154 .use_clustering = ENABLE_CLUSTERING,
155 .proc_name = DRV_NAME,
156 .dma_boundary = ADMA_DMA_BOUNDARY,
157 .slave_configure = ata_scsi_slave_config,
158 .bios_param = ata_std_bios_param,
159};
160
161static const struct ata_port_operations adma_ata_ops = {
162 .port_disable = ata_port_disable,
163 .tf_load = ata_tf_load,
164 .tf_read = ata_tf_read,
165 .check_status = ata_check_status,
166 .check_atapi_dma = adma_check_atapi_dma,
167 .exec_command = ata_exec_command,
168 .dev_select = ata_std_dev_select,
169 .phy_reset = adma_phy_reset,
170 .qc_prep = adma_qc_prep,
171 .qc_issue = adma_qc_issue,
172 .eng_timeout = adma_eng_timeout,
173 .irq_handler = adma_intr,
174 .irq_clear = adma_irq_clear,
175 .port_start = adma_port_start,
176 .port_stop = adma_port_stop,
177 .host_stop = adma_host_stop,
178 .bmdma_stop = adma_bmdma_stop,
179 .bmdma_status = adma_bmdma_status,
180};
181
182static struct ata_port_info adma_port_info[] = {
183 /* board_1841_idx */
184 {
185 .sht = &adma_ata_sht,
186 .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST |
187 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO,
188 .pio_mask = 0x10, /* pio4 */
189 .udma_mask = 0x1f, /* udma0-4 */
190 .port_ops = &adma_ata_ops,
191 },
192};
193
194static struct pci_device_id adma_ata_pci_tbl[] = {
195 { PCI_VENDOR_ID_PDC, 0x1841, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
196 board_1841_idx },
197
198 { } /* terminate list */
199};
200
201static struct pci_driver adma_ata_pci_driver = {
202 .name = DRV_NAME,
203 .id_table = adma_ata_pci_tbl,
204 .probe = adma_ata_init_one,
205 .remove = ata_pci_remove_one,
206};
207
208static int adma_check_atapi_dma(struct ata_queued_cmd *qc)
209{
210 return 1; /* ATAPI DMA not yet supported */
211}
212
213static void adma_bmdma_stop(struct ata_queued_cmd *qc)
214{
215 /* nothing */
216}
217
218static u8 adma_bmdma_status(struct ata_port *ap)
219{
220 return 0;
221}
222
223static void adma_irq_clear(struct ata_port *ap)
224{
225 /* nothing */
226}
227
228static void adma_reset_engine(void __iomem *chan)
229{
230 /* reset ADMA to idle state */
231 writew(aPIOMD4 | aNIEN | aRSTADM, chan + ADMA_CONTROL);
232 udelay(2);
233 writew(aPIOMD4, chan + ADMA_CONTROL);
234 udelay(2);
235}
236
237static void adma_reinit_engine(struct ata_port *ap)
238{
239 struct adma_port_priv *pp = ap->private_data;
240 void __iomem *mmio_base = ap->host_set->mmio_base;
241 void __iomem *chan = ADMA_REGS(mmio_base, ap->port_no);
242
243 /* mask/clear ATA interrupts */
244 writeb(ATA_NIEN, (void __iomem *)ap->ioaddr.ctl_addr);
245 ata_check_status(ap);
246
247 /* reset the ADMA engine */
248 adma_reset_engine(chan);
249
250 /* set in-FIFO threshold to 0x100 */
251 writew(0x100, chan + ADMA_FIFO_IN);
252
253 /* set CPB pointer */
254 writel((u32)pp->pkt_dma, chan + ADMA_CPB_NEXT);
255
256 /* set out-FIFO threshold to 0x100 */
257 writew(0x100, chan + ADMA_FIFO_OUT);
258
259 /* set CPB count */
260 writew(1, chan + ADMA_CPB_COUNT);
261
262 /* read/discard ADMA status */
263 readb(chan + ADMA_STATUS);
264}
265
266static inline void adma_enter_reg_mode(struct ata_port *ap)
267{
268 void __iomem *chan = ADMA_REGS(ap->host_set->mmio_base, ap->port_no);
269
270 writew(aPIOMD4, chan + ADMA_CONTROL);
271 readb(chan + ADMA_STATUS); /* flush */
272}
273
274static void adma_phy_reset(struct ata_port *ap)
275{
276 struct adma_port_priv *pp = ap->private_data;
277
278 pp->state = adma_state_idle;
279 adma_reinit_engine(ap);
280 ata_port_probe(ap);
281 ata_bus_reset(ap);
282}
283
284static void adma_eng_timeout(struct ata_port *ap)
285{
286 struct adma_port_priv *pp = ap->private_data;
287
288 if (pp->state != adma_state_idle) /* healthy paranoia */
289 pp->state = adma_state_mmio;
290 adma_reinit_engine(ap);
291 ata_eng_timeout(ap);
292}
293
294static int adma_fill_sg(struct ata_queued_cmd *qc)
295{
296 struct scatterlist *sg = qc->sg;
297 struct ata_port *ap = qc->ap;
298 struct adma_port_priv *pp = ap->private_data;
299 u8 *buf = pp->pkt;
300 int nelem, i = (2 + buf[3]) * 8;
301 u8 pFLAGS = pORD | ((qc->tf.flags & ATA_TFLAG_WRITE) ? pDIRO : 0);
302
303 for (nelem = 0; nelem < qc->n_elem; nelem++,sg++) {
304 u32 addr;
305 u32 len;
306
307 addr = (u32)sg_dma_address(sg);
308 *(__le32 *)(buf + i) = cpu_to_le32(addr);
309 i += 4;
310
311 len = sg_dma_len(sg) >> 3;
312 *(__le32 *)(buf + i) = cpu_to_le32(len);
313 i += 4;
314
315 if ((nelem + 1) == qc->n_elem)
316 pFLAGS |= pEND;
317 buf[i++] = pFLAGS;
318 buf[i++] = qc->dev->dma_mode & 0xf;
319 buf[i++] = 0; /* pPKLW */
320 buf[i++] = 0; /* reserved */
321
322 *(__le32 *)(buf + i)
323 = (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
324 i += 4;
325
326 VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", nelem,
327 (unsigned long)addr, len);
328 }
329 return i;
330}
331
332static void adma_qc_prep(struct ata_queued_cmd *qc)
333{
334 struct adma_port_priv *pp = qc->ap->private_data;
335 u8 *buf = pp->pkt;
336 u32 pkt_dma = (u32)pp->pkt_dma;
337 int i = 0;
338
339 VPRINTK("ENTER\n");
340
341 adma_enter_reg_mode(qc->ap);
342 if (qc->tf.protocol != ATA_PROT_DMA) {
343 ata_qc_prep(qc);
344 return;
345 }
346
347 buf[i++] = 0; /* Response flags */
348 buf[i++] = 0; /* reserved */
349 buf[i++] = cVLD | cDAT | cIEN;
350 i++; /* cLEN, gets filled in below */
351
352 *(__le32 *)(buf+i) = cpu_to_le32(pkt_dma); /* cNCPB */
353 i += 4; /* cNCPB */
354 i += 4; /* cPRD, gets filled in below */
355
356 buf[i++] = 0; /* reserved */
357 buf[i++] = 0; /* reserved */
358 buf[i++] = 0; /* reserved */
359 buf[i++] = 0; /* reserved */
360
361 /* ATA registers; must be a multiple of 4 */
362 buf[i++] = qc->tf.device;
363 buf[i++] = ADMA_REGS_DEVICE;
364 if ((qc->tf.flags & ATA_TFLAG_LBA48)) {
365 buf[i++] = qc->tf.hob_nsect;
366 buf[i++] = ADMA_REGS_SECTOR_COUNT;
367 buf[i++] = qc->tf.hob_lbal;
368 buf[i++] = ADMA_REGS_LBA_LOW;
369 buf[i++] = qc->tf.hob_lbam;
370 buf[i++] = ADMA_REGS_LBA_MID;
371 buf[i++] = qc->tf.hob_lbah;
372 buf[i++] = ADMA_REGS_LBA_HIGH;
373 }
374 buf[i++] = qc->tf.nsect;
375 buf[i++] = ADMA_REGS_SECTOR_COUNT;
376 buf[i++] = qc->tf.lbal;
377 buf[i++] = ADMA_REGS_LBA_LOW;
378 buf[i++] = qc->tf.lbam;
379 buf[i++] = ADMA_REGS_LBA_MID;
380 buf[i++] = qc->tf.lbah;
381 buf[i++] = ADMA_REGS_LBA_HIGH;
382 buf[i++] = 0;
383 buf[i++] = ADMA_REGS_CONTROL;
384 buf[i++] = rIGN;
385 buf[i++] = 0;
386 buf[i++] = qc->tf.command;
387 buf[i++] = ADMA_REGS_COMMAND | rEND;
388
389 buf[3] = (i >> 3) - 2; /* cLEN */
390 *(__le32 *)(buf+8) = cpu_to_le32(pkt_dma + i); /* cPRD */
391
392 i = adma_fill_sg(qc);
393 wmb(); /* flush PRDs and pkt to memory */
394#if 0
395 /* dump out CPB + PRDs for debug */
396 {
397 int j, len = 0;
398 static char obuf[2048];
399 for (j = 0; j < i; ++j) {
400 len += sprintf(obuf+len, "%02x ", buf[j]);
401 if ((j & 7) == 7) {
402 printk("%s\n", obuf);
403 len = 0;
404 }
405 }
406 if (len)
407 printk("%s\n", obuf);
408 }
409#endif
410}
411
412static inline void adma_packet_start(struct ata_queued_cmd *qc)
413{
414 struct ata_port *ap = qc->ap;
415 void __iomem *chan = ADMA_REGS(ap->host_set->mmio_base, ap->port_no);
416
417 VPRINTK("ENTER, ap %p\n", ap);
418
419 /* fire up the ADMA engine */
420 writew(aPIOMD4 | aGO, chan + ADMA_CONTROL);
421}
422
423static int adma_qc_issue(struct ata_queued_cmd *qc)
424{
425 struct adma_port_priv *pp = qc->ap->private_data;
426
427 switch (qc->tf.protocol) {
428 case ATA_PROT_DMA:
429 pp->state = adma_state_pkt;
430 adma_packet_start(qc);
431 return 0;
432
433 case ATA_PROT_ATAPI_DMA:
434 BUG();
435 break;
436
437 default:
438 break;
439 }
440
441 pp->state = adma_state_mmio;
442 return ata_qc_issue_prot(qc);
443}
444
445static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
446{
447 unsigned int handled = 0, port_no;
448 u8 __iomem *mmio_base = host_set->mmio_base;
449
450 for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
451 struct ata_port *ap = host_set->ports[port_no];
452 struct adma_port_priv *pp;
453 struct ata_queued_cmd *qc;
454 void __iomem *chan = ADMA_REGS(mmio_base, port_no);
455 u8 drv_stat, status = readb(chan + ADMA_STATUS);
456
457 if (status == 0)
458 continue;
459 handled = 1;
460 adma_enter_reg_mode(ap);
461 if ((ap->flags & ATA_FLAG_PORT_DISABLED))
462 continue;
463 pp = ap->private_data;
464 if (!pp || pp->state != adma_state_pkt)
465 continue;
466 qc = ata_qc_from_tag(ap, ap->active_tag);
467 drv_stat = 0;
468 if ((status & (aPERR | aPSD | aUIRQ)))
469 drv_stat = ATA_ERR;
470 else if (pp->pkt[0] != cDONE)
471 drv_stat = ATA_ERR;
472 ata_qc_complete(qc, drv_stat);
473 }
474 return handled;
475}
476
477static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
478{
479 unsigned int handled = 0, port_no;
480
481 for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
482 struct ata_port *ap;
483 ap = host_set->ports[port_no];
484 if (ap && (!(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))) {
485 struct ata_queued_cmd *qc;
486 struct adma_port_priv *pp = ap->private_data;
487 if (!pp || pp->state != adma_state_mmio)
488 continue;
489 qc = ata_qc_from_tag(ap, ap->active_tag);
490 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
491
492 /* check main status, clearing INTRQ */
493 u8 status = ata_chk_status(ap);
494 if ((status & ATA_BUSY))
495 continue;
496 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
497 ap->id, qc->tf.protocol, status);
498
499 /* complete taskfile transaction */
500 pp->state = adma_state_idle;
501 ata_qc_complete(qc, status);
502 handled = 1;
503 }
504 }
505 }
506 return handled;
507}
508
509static irqreturn_t adma_intr(int irq, void *dev_instance, struct pt_regs *regs)
510{
511 struct ata_host_set *host_set = dev_instance;
512 unsigned int handled = 0;
513
514 VPRINTK("ENTER\n");
515
516 spin_lock(&host_set->lock);
517 handled = adma_intr_pkt(host_set) | adma_intr_mmio(host_set);
518 spin_unlock(&host_set->lock);
519
520 VPRINTK("EXIT\n");
521
522 return IRQ_RETVAL(handled);
523}
524
525static void adma_ata_setup_port(struct ata_ioports *port, unsigned long base)
526{
527 port->cmd_addr =
528 port->data_addr = base + 0x000;
529 port->error_addr =
530 port->feature_addr = base + 0x004;
531 port->nsect_addr = base + 0x008;
532 port->lbal_addr = base + 0x00c;
533 port->lbam_addr = base + 0x010;
534 port->lbah_addr = base + 0x014;
535 port->device_addr = base + 0x018;
536 port->status_addr =
537 port->command_addr = base + 0x01c;
538 port->altstatus_addr =
539 port->ctl_addr = base + 0x038;
540}
541
542static int adma_port_start(struct ata_port *ap)
543{
544 struct device *dev = ap->host_set->dev;
545 struct adma_port_priv *pp;
546 int rc;
547
548 rc = ata_port_start(ap);
549 if (rc)
550 return rc;
551 adma_enter_reg_mode(ap);
552 rc = -ENOMEM;
553 pp = kcalloc(1, sizeof(*pp), GFP_KERNEL);
554 if (!pp)
555 goto err_out;
556 pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma,
557 GFP_KERNEL);
558 if (!pp->pkt)
559 goto err_out_kfree;
560 /* paranoia? */
561 if ((pp->pkt_dma & 7) != 0) {
562 printk("bad alignment for pp->pkt_dma: %08x\n",
563 (u32)pp->pkt_dma);
564 goto err_out_kfree2;
565 }
566 memset(pp->pkt, 0, ADMA_PKT_BYTES);
567 ap->private_data = pp;
568 adma_reinit_engine(ap);
569 return 0;
570
571err_out_kfree2:
572 kfree(pp);
573err_out_kfree:
574 kfree(pp);
575err_out:
576 ata_port_stop(ap);
577 return rc;
578}
579
580static void adma_port_stop(struct ata_port *ap)
581{
582 struct device *dev = ap->host_set->dev;
583 struct adma_port_priv *pp = ap->private_data;
584
585 adma_reset_engine(ADMA_REGS(ap->host_set->mmio_base, ap->port_no));
586 if (pp != NULL) {
587 ap->private_data = NULL;
588 if (pp->pkt != NULL)
589 dma_free_coherent(dev, ADMA_PKT_BYTES,
590 pp->pkt, pp->pkt_dma);
591 kfree(pp);
592 }
593 ata_port_stop(ap);
594}
595
596static void adma_host_stop(struct ata_host_set *host_set)
597{
598 unsigned int port_no;
599
600 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
601 adma_reset_engine(ADMA_REGS(host_set->mmio_base, port_no));
602
603 ata_pci_host_stop(host_set);
604}
605
606static void adma_host_init(unsigned int chip_id,
607 struct ata_probe_ent *probe_ent)
608{
609 unsigned int port_no;
610 void __iomem *mmio_base = probe_ent->mmio_base;
611
612 /* enable/lock aGO operation */
613 writeb(7, mmio_base + ADMA_MODE_LOCK);
614
615 /* reset the ADMA logic */
616 for (port_no = 0; port_no < ADMA_PORTS; ++port_no)
617 adma_reset_engine(ADMA_REGS(mmio_base, port_no));
618}
619
620static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
621{
622 int rc;
623
624 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
625 if (rc) {
626 printk(KERN_ERR DRV_NAME
627 "(%s): 32-bit DMA enable failed\n",
628 pci_name(pdev));
629 return rc;
630 }
631 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
632 if (rc) {
633 printk(KERN_ERR DRV_NAME
634 "(%s): 32-bit consistent DMA enable failed\n",
635 pci_name(pdev));
636 return rc;
637 }
638 return 0;
639}
640
641static int adma_ata_init_one(struct pci_dev *pdev,
642 const struct pci_device_id *ent)
643{
644 static int printed_version;
645 struct ata_probe_ent *probe_ent = NULL;
646 void __iomem *mmio_base;
647 unsigned int board_idx = (unsigned int) ent->driver_data;
648 int rc, port_no;
649
650 if (!printed_version++)
651 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
652
653 rc = pci_enable_device(pdev);
654 if (rc)
655 return rc;
656
657 rc = pci_request_regions(pdev, DRV_NAME);
658 if (rc)
659 goto err_out;
660
661 if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) {
662 rc = -ENODEV;
663 goto err_out_regions;
664 }
665
666 mmio_base = pci_iomap(pdev, 4, 0);
667 if (mmio_base == NULL) {
668 rc = -ENOMEM;
669 goto err_out_regions;
670 }
671
672 rc = adma_set_dma_masks(pdev, mmio_base);
673 if (rc)
674 goto err_out_iounmap;
675
676 probe_ent = kcalloc(1, sizeof(*probe_ent), GFP_KERNEL);
677 if (probe_ent == NULL) {
678 rc = -ENOMEM;
679 goto err_out_iounmap;
680 }
681
682 probe_ent->dev = pci_dev_to_dev(pdev);
683 INIT_LIST_HEAD(&probe_ent->node);
684
685 probe_ent->sht = adma_port_info[board_idx].sht;
686 probe_ent->host_flags = adma_port_info[board_idx].host_flags;
687 probe_ent->pio_mask = adma_port_info[board_idx].pio_mask;
688 probe_ent->mwdma_mask = adma_port_info[board_idx].mwdma_mask;
689 probe_ent->udma_mask = adma_port_info[board_idx].udma_mask;
690 probe_ent->port_ops = adma_port_info[board_idx].port_ops;
691
692 probe_ent->irq = pdev->irq;
693 probe_ent->irq_flags = SA_SHIRQ;
694 probe_ent->mmio_base = mmio_base;
695 probe_ent->n_ports = ADMA_PORTS;
696
697 for (port_no = 0; port_no < probe_ent->n_ports; ++port_no) {
698 adma_ata_setup_port(&probe_ent->port[port_no],
699 ADMA_ATA_REGS((unsigned long)mmio_base, port_no));
700 }
701
702 pci_set_master(pdev);
703
704 /* initialize adapter */
705 adma_host_init(board_idx, probe_ent);
706
707 rc = ata_device_add(probe_ent);
708 kfree(probe_ent);
709 if (rc != ADMA_PORTS)
710 goto err_out_iounmap;
711 return 0;
712
713err_out_iounmap:
714 pci_iounmap(pdev, mmio_base);
715err_out_regions:
716 pci_release_regions(pdev);
717err_out:
718 pci_disable_device(pdev);
719 return rc;
720}
721
722static int __init adma_ata_init(void)
723{
724 return pci_module_init(&adma_ata_pci_driver);
725}
726
727static void __exit adma_ata_exit(void)
728{
729 pci_unregister_driver(&adma_ata_pci_driver);
730}
731
732MODULE_AUTHOR("Mark Lord");
733MODULE_DESCRIPTION("Pacific Digital Corporation ADMA low-level driver");
734MODULE_LICENSE("GPL");
735MODULE_DEVICE_TABLE(pci, adma_ata_pci_tbl);
736MODULE_VERSION(DRV_VERSION);
737
738module_init(adma_ata_init);
739module_exit(adma_ata_exit);
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 1ed32e7b5472..e451941ad81d 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -52,7 +52,7 @@ extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
52extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *); 52extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *);
53extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *); 53extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *);
54 54
55extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, int); 55extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t);
56 56
57extern int qla2x00_loop_resync(scsi_qla_host_t *); 57extern int qla2x00_loop_resync(scsi_qla_host_t *);
58 58
@@ -277,7 +277,7 @@ extern int qla2x00_fdmi_register(scsi_qla_host_t *);
277/* 277/*
278 * Global Function Prototypes in qla_rscn.c source file. 278 * Global Function Prototypes in qla_rscn.c source file.
279 */ 279 */
280extern fc_port_t *qla2x00_alloc_rscn_fcport(scsi_qla_host_t *, int); 280extern fc_port_t *qla2x00_alloc_rscn_fcport(scsi_qla_host_t *, gfp_t);
281extern int qla2x00_handle_port_rscn(scsi_qla_host_t *, uint32_t, fc_port_t *, 281extern int qla2x00_handle_port_rscn(scsi_qla_host_t *, uint32_t, fc_port_t *,
282 int); 282 int);
283extern void qla2x00_process_iodesc(scsi_qla_host_t *, struct mbx_entry *); 283extern void qla2x00_process_iodesc(scsi_qla_host_t *, struct mbx_entry *);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 23d095d3817b..fbb6feee40cf 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1685,7 +1685,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1685 * Returns a pointer to the allocated fcport, or NULL, if none available. 1685 * Returns a pointer to the allocated fcport, or NULL, if none available.
1686 */ 1686 */
1687fc_port_t * 1687fc_port_t *
1688qla2x00_alloc_fcport(scsi_qla_host_t *ha, int flags) 1688qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
1689{ 1689{
1690 fc_port_t *fcport; 1690 fc_port_t *fcport;
1691 1691
diff --git a/drivers/scsi/qla2xxx/qla_rscn.c b/drivers/scsi/qla2xxx/qla_rscn.c
index 1eba98828636..7534efcc8918 100644
--- a/drivers/scsi/qla2xxx/qla_rscn.c
+++ b/drivers/scsi/qla2xxx/qla_rscn.c
@@ -1066,7 +1066,7 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
1066 * Returns a pointer to the allocated RSCN fcport, or NULL, if none available. 1066 * Returns a pointer to the allocated RSCN fcport, or NULL, if none available.
1067 */ 1067 */
1068fc_port_t * 1068fc_port_t *
1069qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, int flags) 1069qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, gfp_t flags)
1070{ 1070{
1071 fc_port_t *fcport; 1071 fc_port_t *fcport;
1072 1072
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index ea76fe44585e..422e0b6f603a 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -35,7 +35,7 @@
35#include <asm/io.h> 35#include <asm/io.h>
36 36
37#define DRV_NAME "sata_mv" 37#define DRV_NAME "sata_mv"
38#define DRV_VERSION "0.12" 38#define DRV_VERSION "0.25"
39 39
40enum { 40enum {
41 /* BAR's are enumerated in terms of pci_resource_start() terms */ 41 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -55,31 +55,61 @@ enum {
55 MV_SATAHC_ARBTR_REG_SZ = MV_MINOR_REG_AREA_SZ, /* arbiter */ 55 MV_SATAHC_ARBTR_REG_SZ = MV_MINOR_REG_AREA_SZ, /* arbiter */
56 MV_PORT_REG_SZ = MV_MINOR_REG_AREA_SZ, 56 MV_PORT_REG_SZ = MV_MINOR_REG_AREA_SZ,
57 57
58 MV_Q_CT = 32, 58 MV_USE_Q_DEPTH = ATA_DEF_QUEUE,
59 MV_CRQB_SZ = 32,
60 MV_CRPB_SZ = 8,
61 59
62 MV_DMA_BOUNDARY = 0xffffffffU, 60 MV_MAX_Q_DEPTH = 32,
63 SATAHC_MASK = (~(MV_SATAHC_REG_SZ - 1)), 61 MV_MAX_Q_DEPTH_MASK = MV_MAX_Q_DEPTH - 1,
62
63 /* CRQB needs alignment on a 1KB boundary. Size == 1KB
64 * CRPB needs alignment on a 256B boundary. Size == 256B
65 * SG count of 176 leads to MV_PORT_PRIV_DMA_SZ == 4KB
66 * ePRD (SG) entries need alignment on a 16B boundary. Size == 16B
67 */
68 MV_CRQB_Q_SZ = (32 * MV_MAX_Q_DEPTH),
69 MV_CRPB_Q_SZ = (8 * MV_MAX_Q_DEPTH),
70 MV_MAX_SG_CT = 176,
71 MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT),
72 MV_PORT_PRIV_DMA_SZ = (MV_CRQB_Q_SZ + MV_CRPB_Q_SZ + MV_SG_TBL_SZ),
73
74 /* Our DMA boundary is determined by an ePRD being unable to handle
75 * anything larger than 64KB
76 */
77 MV_DMA_BOUNDARY = 0xffffU,
64 78
65 MV_PORTS_PER_HC = 4, 79 MV_PORTS_PER_HC = 4,
66 /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */ 80 /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */
67 MV_PORT_HC_SHIFT = 2, 81 MV_PORT_HC_SHIFT = 2,
68 /* == (port % MV_PORTS_PER_HC) to determine port from 0-7 port */ 82 /* == (port % MV_PORTS_PER_HC) to determine hard port from 0-7 port */
69 MV_PORT_MASK = 3, 83 MV_PORT_MASK = 3,
70 84
71 /* Host Flags */ 85 /* Host Flags */
72 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 86 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
73 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
74 MV_FLAG_BDMA = (1 << 28), /* Basic DMA */ 88 MV_FLAG_GLBL_SFT_RST = (1 << 28), /* Global Soft Reset support */
89 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
90 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO),
91 MV_6XXX_FLAGS = (MV_FLAG_IRQ_COALESCE |
92 MV_FLAG_GLBL_SFT_RST),
75 93
76 chip_504x = 0, 94 chip_504x = 0,
77 chip_508x = 1, 95 chip_508x = 1,
78 chip_604x = 2, 96 chip_604x = 2,
79 chip_608x = 3, 97 chip_608x = 3,
80 98
99 CRQB_FLAG_READ = (1 << 0),
100 CRQB_TAG_SHIFT = 1,
101 CRQB_CMD_ADDR_SHIFT = 8,
102 CRQB_CMD_CS = (0x2 << 11),
103 CRQB_CMD_LAST = (1 << 15),
104
105 CRPB_FLAG_STATUS_SHIFT = 8,
106
107 EPRD_FLAG_END_OF_TBL = (1 << 31),
108
81 /* PCI interface registers */ 109 /* PCI interface registers */
82 110
111 PCI_COMMAND_OFS = 0xc00,
112
83 PCI_MAIN_CMD_STS_OFS = 0xd30, 113 PCI_MAIN_CMD_STS_OFS = 0xd30,
84 STOP_PCI_MASTER = (1 << 2), 114 STOP_PCI_MASTER = (1 << 2),
85 PCI_MASTER_EMPTY = (1 << 3), 115 PCI_MASTER_EMPTY = (1 << 3),
@@ -111,20 +141,13 @@ enum {
111 HC_CFG_OFS = 0, 141 HC_CFG_OFS = 0,
112 142
113 HC_IRQ_CAUSE_OFS = 0x14, 143 HC_IRQ_CAUSE_OFS = 0x14,
114 CRBP_DMA_DONE = (1 << 0), /* shift by port # */ 144 CRPB_DMA_DONE = (1 << 0), /* shift by port # */
115 HC_IRQ_COAL = (1 << 4), /* IRQ coalescing */ 145 HC_IRQ_COAL = (1 << 4), /* IRQ coalescing */
116 DEV_IRQ = (1 << 8), /* shift by port # */ 146 DEV_IRQ = (1 << 8), /* shift by port # */
117 147
118 /* Shadow block registers */ 148 /* Shadow block registers */
119 SHD_PIO_DATA_OFS = 0x100, 149 SHD_BLK_OFS = 0x100,
120 SHD_FEA_ERR_OFS = 0x104, 150 SHD_CTL_AST_OFS = 0x20, /* ofs from SHD_BLK_OFS */
121 SHD_SECT_CNT_OFS = 0x108,
122 SHD_LBA_L_OFS = 0x10C,
123 SHD_LBA_M_OFS = 0x110,
124 SHD_LBA_H_OFS = 0x114,
125 SHD_DEV_HD_OFS = 0x118,
126 SHD_CMD_STA_OFS = 0x11C,
127 SHD_CTL_AST_OFS = 0x120,
128 151
129 /* SATA registers */ 152 /* SATA registers */
130 SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */ 153 SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */
@@ -132,6 +155,11 @@ enum {
132 155
133 /* Port registers */ 156 /* Port registers */
134 EDMA_CFG_OFS = 0, 157 EDMA_CFG_OFS = 0,
158 EDMA_CFG_Q_DEPTH = 0, /* queueing disabled */
159 EDMA_CFG_NCQ = (1 << 5),
160 EDMA_CFG_NCQ_GO_ON_ERR = (1 << 14), /* continue on error */
161 EDMA_CFG_RD_BRST_EXT = (1 << 11), /* read burst 512B */
162 EDMA_CFG_WR_BUFF_LEN = (1 << 13), /* write buffer 512B */
135 163
136 EDMA_ERR_IRQ_CAUSE_OFS = 0x8, 164 EDMA_ERR_IRQ_CAUSE_OFS = 0x8,
137 EDMA_ERR_IRQ_MASK_OFS = 0xc, 165 EDMA_ERR_IRQ_MASK_OFS = 0xc,
@@ -161,33 +189,85 @@ enum {
161 EDMA_ERR_LNK_DATA_TX | 189 EDMA_ERR_LNK_DATA_TX |
162 EDMA_ERR_TRANS_PROTO), 190 EDMA_ERR_TRANS_PROTO),
163 191
192 EDMA_REQ_Q_BASE_HI_OFS = 0x10,
193 EDMA_REQ_Q_IN_PTR_OFS = 0x14, /* also contains BASE_LO */
194 EDMA_REQ_Q_BASE_LO_MASK = 0xfffffc00U,
195
196 EDMA_REQ_Q_OUT_PTR_OFS = 0x18,
197 EDMA_REQ_Q_PTR_SHIFT = 5,
198
199 EDMA_RSP_Q_BASE_HI_OFS = 0x1c,
200 EDMA_RSP_Q_IN_PTR_OFS = 0x20,
201 EDMA_RSP_Q_OUT_PTR_OFS = 0x24, /* also contains BASE_LO */
202 EDMA_RSP_Q_BASE_LO_MASK = 0xffffff00U,
203 EDMA_RSP_Q_PTR_SHIFT = 3,
204
164 EDMA_CMD_OFS = 0x28, 205 EDMA_CMD_OFS = 0x28,
165 EDMA_EN = (1 << 0), 206 EDMA_EN = (1 << 0),
166 EDMA_DS = (1 << 1), 207 EDMA_DS = (1 << 1),
167 ATA_RST = (1 << 2), 208 ATA_RST = (1 << 2),
168 209
169 /* BDMA is 6xxx part only */ 210 /* Host private flags (hp_flags) */
170 BDMA_CMD_OFS = 0x224, 211 MV_HP_FLAG_MSI = (1 << 0),
171 BDMA_START = (1 << 0),
172 212
173 MV_UNDEF = 0, 213 /* Port private flags (pp_flags) */
214 MV_PP_FLAG_EDMA_EN = (1 << 0),
215 MV_PP_FLAG_EDMA_DS_ACT = (1 << 1),
174}; 216};
175 217
176struct mv_port_priv { 218/* Command ReQuest Block: 32B */
219struct mv_crqb {
220 u32 sg_addr;
221 u32 sg_addr_hi;
222 u16 ctrl_flags;
223 u16 ata_cmd[11];
224};
177 225
226/* Command ResPonse Block: 8B */
227struct mv_crpb {
228 u16 id;
229 u16 flags;
230 u32 tmstmp;
178}; 231};
179 232
180struct mv_host_priv { 233/* EDMA Physical Region Descriptor (ePRD); A.K.A. SG */
234struct mv_sg {
235 u32 addr;
236 u32 flags_size;
237 u32 addr_hi;
238 u32 reserved;
239};
181 240
241struct mv_port_priv {
242 struct mv_crqb *crqb;
243 dma_addr_t crqb_dma;
244 struct mv_crpb *crpb;
245 dma_addr_t crpb_dma;
246 struct mv_sg *sg_tbl;
247 dma_addr_t sg_tbl_dma;
248
249 unsigned req_producer; /* cp of req_in_ptr */
250 unsigned rsp_consumer; /* cp of rsp_out_ptr */
251 u32 pp_flags;
252};
253
254struct mv_host_priv {
255 u32 hp_flags;
182}; 256};
183 257
184static void mv_irq_clear(struct ata_port *ap); 258static void mv_irq_clear(struct ata_port *ap);
185static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); 259static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
186static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 260static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
261static u8 mv_check_err(struct ata_port *ap);
187static void mv_phy_reset(struct ata_port *ap); 262static void mv_phy_reset(struct ata_port *ap);
188static int mv_master_reset(void __iomem *mmio_base); 263static void mv_host_stop(struct ata_host_set *host_set);
264static int mv_port_start(struct ata_port *ap);
265static void mv_port_stop(struct ata_port *ap);
266static void mv_qc_prep(struct ata_queued_cmd *qc);
267static int mv_qc_issue(struct ata_queued_cmd *qc);
189static irqreturn_t mv_interrupt(int irq, void *dev_instance, 268static irqreturn_t mv_interrupt(int irq, void *dev_instance,
190 struct pt_regs *regs); 269 struct pt_regs *regs);
270static void mv_eng_timeout(struct ata_port *ap);
191static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 271static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
192 272
193static Scsi_Host_Template mv_sht = { 273static Scsi_Host_Template mv_sht = {
@@ -196,13 +276,13 @@ static Scsi_Host_Template mv_sht = {
196 .ioctl = ata_scsi_ioctl, 276 .ioctl = ata_scsi_ioctl,
197 .queuecommand = ata_scsi_queuecmd, 277 .queuecommand = ata_scsi_queuecmd,
198 .eh_strategy_handler = ata_scsi_error, 278 .eh_strategy_handler = ata_scsi_error,
199 .can_queue = ATA_DEF_QUEUE, 279 .can_queue = MV_USE_Q_DEPTH,
200 .this_id = ATA_SHT_THIS_ID, 280 .this_id = ATA_SHT_THIS_ID,
201 .sg_tablesize = MV_UNDEF, 281 .sg_tablesize = MV_MAX_SG_CT,
202 .max_sectors = ATA_MAX_SECTORS, 282 .max_sectors = ATA_MAX_SECTORS,
203 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 283 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
204 .emulated = ATA_SHT_EMULATED, 284 .emulated = ATA_SHT_EMULATED,
205 .use_clustering = MV_UNDEF, 285 .use_clustering = ATA_SHT_USE_CLUSTERING,
206 .proc_name = DRV_NAME, 286 .proc_name = DRV_NAME,
207 .dma_boundary = MV_DMA_BOUNDARY, 287 .dma_boundary = MV_DMA_BOUNDARY,
208 .slave_configure = ata_scsi_slave_config, 288 .slave_configure = ata_scsi_slave_config,
@@ -210,21 +290,22 @@ static Scsi_Host_Template mv_sht = {
210 .ordered_flush = 1, 290 .ordered_flush = 1,
211}; 291};
212 292
213static struct ata_port_operations mv_ops = { 293static const struct ata_port_operations mv_ops = {
214 .port_disable = ata_port_disable, 294 .port_disable = ata_port_disable,
215 295
216 .tf_load = ata_tf_load, 296 .tf_load = ata_tf_load,
217 .tf_read = ata_tf_read, 297 .tf_read = ata_tf_read,
218 .check_status = ata_check_status, 298 .check_status = ata_check_status,
299 .check_err = mv_check_err,
219 .exec_command = ata_exec_command, 300 .exec_command = ata_exec_command,
220 .dev_select = ata_std_dev_select, 301 .dev_select = ata_std_dev_select,
221 302
222 .phy_reset = mv_phy_reset, 303 .phy_reset = mv_phy_reset,
223 304
224 .qc_prep = ata_qc_prep, 305 .qc_prep = mv_qc_prep,
225 .qc_issue = ata_qc_issue_prot, 306 .qc_issue = mv_qc_issue,
226 307
227 .eng_timeout = ata_eng_timeout, 308 .eng_timeout = mv_eng_timeout,
228 309
229 .irq_handler = mv_interrupt, 310 .irq_handler = mv_interrupt,
230 .irq_clear = mv_irq_clear, 311 .irq_clear = mv_irq_clear,
@@ -232,46 +313,39 @@ static struct ata_port_operations mv_ops = {
232 .scr_read = mv_scr_read, 313 .scr_read = mv_scr_read,
233 .scr_write = mv_scr_write, 314 .scr_write = mv_scr_write,
234 315
235 .port_start = ata_port_start, 316 .port_start = mv_port_start,
236 .port_stop = ata_port_stop, 317 .port_stop = mv_port_stop,
237 .host_stop = ata_host_stop, 318 .host_stop = mv_host_stop,
238}; 319};
239 320
240static struct ata_port_info mv_port_info[] = { 321static struct ata_port_info mv_port_info[] = {
241 { /* chip_504x */ 322 { /* chip_504x */
242 .sht = &mv_sht, 323 .sht = &mv_sht,
243 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 324 .host_flags = MV_COMMON_FLAGS,
244 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO), 325 .pio_mask = 0x1f, /* pio0-4 */
245 .pio_mask = 0x1f, /* pio4-0 */ 326 .udma_mask = 0, /* 0x7f (udma0-6 disabled for now) */
246 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
247 .port_ops = &mv_ops, 327 .port_ops = &mv_ops,
248 }, 328 },
249 { /* chip_508x */ 329 { /* chip_508x */
250 .sht = &mv_sht, 330 .sht = &mv_sht,
251 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 331 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
252 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 332 .pio_mask = 0x1f, /* pio0-4 */
253 MV_FLAG_DUAL_HC), 333 .udma_mask = 0, /* 0x7f (udma0-6 disabled for now) */
254 .pio_mask = 0x1f, /* pio4-0 */
255 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
256 .port_ops = &mv_ops, 334 .port_ops = &mv_ops,
257 }, 335 },
258 { /* chip_604x */ 336 { /* chip_604x */
259 .sht = &mv_sht, 337 .sht = &mv_sht,
260 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 338 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
261 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 339 .pio_mask = 0x1f, /* pio0-4 */
262 MV_FLAG_IRQ_COALESCE | MV_FLAG_BDMA), 340 .udma_mask = 0x7f, /* udma0-6 */
263 .pio_mask = 0x1f, /* pio4-0 */
264 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
265 .port_ops = &mv_ops, 341 .port_ops = &mv_ops,
266 }, 342 },
267 { /* chip_608x */ 343 { /* chip_608x */
268 .sht = &mv_sht, 344 .sht = &mv_sht,
269 .host_flags = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 345 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS |
270 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 346 MV_FLAG_DUAL_HC),
271 MV_FLAG_IRQ_COALESCE | MV_FLAG_DUAL_HC | 347 .pio_mask = 0x1f, /* pio0-4 */
272 MV_FLAG_BDMA), 348 .udma_mask = 0x7f, /* udma0-6 */
273 .pio_mask = 0x1f, /* pio4-0 */
274 .udma_mask = 0, /* 0x7f (udma6-0 disabled for now) */
275 .port_ops = &mv_ops, 349 .port_ops = &mv_ops,
276 }, 350 },
277}; 351};
@@ -306,12 +380,6 @@ static inline void writelfl(unsigned long data, void __iomem *addr)
306 (void) readl(addr); /* flush to avoid PCI posted write */ 380 (void) readl(addr); /* flush to avoid PCI posted write */
307} 381}
308 382
309static inline void __iomem *mv_port_addr_to_hc_base(void __iomem *port_mmio)
310{
311 return ((void __iomem *)((unsigned long)port_mmio &
312 (unsigned long)SATAHC_MASK));
313}
314
315static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc) 383static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc)
316{ 384{
317 return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); 385 return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ));
@@ -329,24 +397,150 @@ static inline void __iomem *mv_ap_base(struct ata_port *ap)
329 return mv_port_base(ap->host_set->mmio_base, ap->port_no); 397 return mv_port_base(ap->host_set->mmio_base, ap->port_no);
330} 398}
331 399
332static inline int mv_get_hc_count(unsigned long flags) 400static inline int mv_get_hc_count(unsigned long hp_flags)
333{ 401{
334 return ((flags & MV_FLAG_DUAL_HC) ? 2 : 1); 402 return ((hp_flags & MV_FLAG_DUAL_HC) ? 2 : 1);
335} 403}
336 404
337static inline int mv_is_edma_active(struct ata_port *ap) 405static void mv_irq_clear(struct ata_port *ap)
406{
407}
408
409/**
410 * mv_start_dma - Enable eDMA engine
411 * @base: port base address
412 * @pp: port private data
413 *
414 * Verify the local cache of the eDMA state is accurate with an
415 * assert.
416 *
417 * LOCKING:
418 * Inherited from caller.
419 */
420static void mv_start_dma(void __iomem *base, struct mv_port_priv *pp)
421{
422 if (!(MV_PP_FLAG_EDMA_EN & pp->pp_flags)) {
423 writelfl(EDMA_EN, base + EDMA_CMD_OFS);
424 pp->pp_flags |= MV_PP_FLAG_EDMA_EN;
425 }
426 assert(EDMA_EN & readl(base + EDMA_CMD_OFS));
427}
428
429/**
430 * mv_stop_dma - Disable eDMA engine
431 * @ap: ATA channel to manipulate
432 *
433 * Verify the local cache of the eDMA state is accurate with an
434 * assert.
435 *
436 * LOCKING:
437 * Inherited from caller.
438 */
439static void mv_stop_dma(struct ata_port *ap)
338{ 440{
339 void __iomem *port_mmio = mv_ap_base(ap); 441 void __iomem *port_mmio = mv_ap_base(ap);
340 return (EDMA_EN & readl(port_mmio + EDMA_CMD_OFS)); 442 struct mv_port_priv *pp = ap->private_data;
443 u32 reg;
444 int i;
445
446 if (MV_PP_FLAG_EDMA_EN & pp->pp_flags) {
447 /* Disable EDMA if active. The disable bit auto clears.
448 */
449 writelfl(EDMA_DS, port_mmio + EDMA_CMD_OFS);
450 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
451 } else {
452 assert(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS)));
453 }
454
455 /* now properly wait for the eDMA to stop */
456 for (i = 1000; i > 0; i--) {
457 reg = readl(port_mmio + EDMA_CMD_OFS);
458 if (!(EDMA_EN & reg)) {
459 break;
460 }
461 udelay(100);
462 }
463
464 if (EDMA_EN & reg) {
465 printk(KERN_ERR "ata%u: Unable to stop eDMA\n", ap->id);
466 /* FIXME: Consider doing a reset here to recover */
467 }
341} 468}
342 469
343static inline int mv_port_bdma_capable(struct ata_port *ap) 470#ifdef ATA_DEBUG
471static void mv_dump_mem(void __iomem *start, unsigned bytes)
344{ 472{
345 return (ap->flags & MV_FLAG_BDMA); 473 int b, w;
474 for (b = 0; b < bytes; ) {
475 DPRINTK("%p: ", start + b);
476 for (w = 0; b < bytes && w < 4; w++) {
477 printk("%08x ",readl(start + b));
478 b += sizeof(u32);
479 }
480 printk("\n");
481 }
346} 482}
483#endif
347 484
348static void mv_irq_clear(struct ata_port *ap) 485static void mv_dump_pci_cfg(struct pci_dev *pdev, unsigned bytes)
486{
487#ifdef ATA_DEBUG
488 int b, w;
489 u32 dw;
490 for (b = 0; b < bytes; ) {
491 DPRINTK("%02x: ", b);
492 for (w = 0; b < bytes && w < 4; w++) {
493 (void) pci_read_config_dword(pdev,b,&dw);
494 printk("%08x ",dw);
495 b += sizeof(u32);
496 }
497 printk("\n");
498 }
499#endif
500}
501static void mv_dump_all_regs(void __iomem *mmio_base, int port,
502 struct pci_dev *pdev)
349{ 503{
504#ifdef ATA_DEBUG
505 void __iomem *hc_base = mv_hc_base(mmio_base,
506 port >> MV_PORT_HC_SHIFT);
507 void __iomem *port_base;
508 int start_port, num_ports, p, start_hc, num_hcs, hc;
509
510 if (0 > port) {
511 start_hc = start_port = 0;
512 num_ports = 8; /* shld be benign for 4 port devs */
513 num_hcs = 2;
514 } else {
515 start_hc = port >> MV_PORT_HC_SHIFT;
516 start_port = port;
517 num_ports = num_hcs = 1;
518 }
519 DPRINTK("All registers for port(s) %u-%u:\n", start_port,
520 num_ports > 1 ? num_ports - 1 : start_port);
521
522 if (NULL != pdev) {
523 DPRINTK("PCI config space regs:\n");
524 mv_dump_pci_cfg(pdev, 0x68);
525 }
526 DPRINTK("PCI regs:\n");
527 mv_dump_mem(mmio_base+0xc00, 0x3c);
528 mv_dump_mem(mmio_base+0xd00, 0x34);
529 mv_dump_mem(mmio_base+0xf00, 0x4);
530 mv_dump_mem(mmio_base+0x1d00, 0x6c);
531 for (hc = start_hc; hc < start_hc + num_hcs; hc++) {
532 hc_base = mv_hc_base(mmio_base, port >> MV_PORT_HC_SHIFT);
533 DPRINTK("HC regs (HC %i):\n", hc);
534 mv_dump_mem(hc_base, 0x1c);
535 }
536 for (p = start_port; p < start_port + num_ports; p++) {
537 port_base = mv_port_base(mmio_base, p);
538 DPRINTK("EDMA regs (port %i):\n",p);
539 mv_dump_mem(port_base, 0x54);
540 DPRINTK("SATA regs (port %i):\n",p);
541 mv_dump_mem(port_base+0x300, 0x60);
542 }
543#endif
350} 544}
351 545
352static unsigned int mv_scr_offset(unsigned int sc_reg_in) 546static unsigned int mv_scr_offset(unsigned int sc_reg_in)
@@ -389,30 +583,37 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
389 } 583 }
390} 584}
391 585
392static int mv_master_reset(void __iomem *mmio_base) 586/**
587 * mv_global_soft_reset - Perform the 6xxx global soft reset
588 * @mmio_base: base address of the HBA
589 *
590 * This routine only applies to 6xxx parts.
591 *
592 * LOCKING:
593 * Inherited from caller.
594 */
595static int mv_global_soft_reset(void __iomem *mmio_base)
393{ 596{
394 void __iomem *reg = mmio_base + PCI_MAIN_CMD_STS_OFS; 597 void __iomem *reg = mmio_base + PCI_MAIN_CMD_STS_OFS;
395 int i, rc = 0; 598 int i, rc = 0;
396 u32 t; 599 u32 t;
397 600
398 VPRINTK("ENTER\n");
399
400 /* Following procedure defined in PCI "main command and status 601 /* Following procedure defined in PCI "main command and status
401 * register" table. 602 * register" table.
402 */ 603 */
403 t = readl(reg); 604 t = readl(reg);
404 writel(t | STOP_PCI_MASTER, reg); 605 writel(t | STOP_PCI_MASTER, reg);
405 606
406 for (i = 0; i < 100; i++) { 607 for (i = 0; i < 1000; i++) {
407 msleep(10); 608 udelay(1);
408 t = readl(reg); 609 t = readl(reg);
409 if (PCI_MASTER_EMPTY & t) { 610 if (PCI_MASTER_EMPTY & t) {
410 break; 611 break;
411 } 612 }
412 } 613 }
413 if (!(PCI_MASTER_EMPTY & t)) { 614 if (!(PCI_MASTER_EMPTY & t)) {
414 printk(KERN_ERR DRV_NAME "PCI master won't flush\n"); 615 printk(KERN_ERR DRV_NAME ": PCI master won't flush\n");
415 rc = 1; /* broken HW? */ 616 rc = 1;
416 goto done; 617 goto done;
417 } 618 }
418 619
@@ -425,39 +626,399 @@ static int mv_master_reset(void __iomem *mmio_base)
425 } while (!(GLOB_SFT_RST & t) && (i-- > 0)); 626 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
426 627
427 if (!(GLOB_SFT_RST & t)) { 628 if (!(GLOB_SFT_RST & t)) {
428 printk(KERN_ERR DRV_NAME "can't set global reset\n"); 629 printk(KERN_ERR DRV_NAME ": can't set global reset\n");
429 rc = 1; /* broken HW? */ 630 rc = 1;
430 goto done; 631 goto done;
431 } 632 }
432 633
433 /* clear reset */ 634 /* clear reset and *reenable the PCI master* (not mentioned in spec) */
434 i = 5; 635 i = 5;
435 do { 636 do {
436 writel(t & ~GLOB_SFT_RST, reg); 637 writel(t & ~(GLOB_SFT_RST | STOP_PCI_MASTER), reg);
437 t = readl(reg); 638 t = readl(reg);
438 udelay(1); 639 udelay(1);
439 } while ((GLOB_SFT_RST & t) && (i-- > 0)); 640 } while ((GLOB_SFT_RST & t) && (i-- > 0));
440 641
441 if (GLOB_SFT_RST & t) { 642 if (GLOB_SFT_RST & t) {
442 printk(KERN_ERR DRV_NAME "can't clear global reset\n"); 643 printk(KERN_ERR DRV_NAME ": can't clear global reset\n");
443 rc = 1; /* broken HW? */ 644 rc = 1;
444 } 645 }
445 646done:
446 done:
447 VPRINTK("EXIT, rc = %i\n", rc);
448 return rc; 647 return rc;
449} 648}
450 649
451static void mv_err_intr(struct ata_port *ap) 650/**
651 * mv_host_stop - Host specific cleanup/stop routine.
652 * @host_set: host data structure
653 *
654 * Disable ints, cleanup host memory, call general purpose
655 * host_stop.
656 *
657 * LOCKING:
658 * Inherited from caller.
659 */
660static void mv_host_stop(struct ata_host_set *host_set)
452{ 661{
453 void __iomem *port_mmio; 662 struct mv_host_priv *hpriv = host_set->private_data;
454 u32 edma_err_cause, serr = 0; 663 struct pci_dev *pdev = to_pci_dev(host_set->dev);
664
665 if (hpriv->hp_flags & MV_HP_FLAG_MSI) {
666 pci_disable_msi(pdev);
667 } else {
668 pci_intx(pdev, 0);
669 }
670 kfree(hpriv);
671 ata_host_stop(host_set);
672}
673
674/**
675 * mv_port_start - Port specific init/start routine.
676 * @ap: ATA channel to manipulate
677 *
678 * Allocate and point to DMA memory, init port private memory,
679 * zero indices.
680 *
681 * LOCKING:
682 * Inherited from caller.
683 */
684static int mv_port_start(struct ata_port *ap)
685{
686 struct device *dev = ap->host_set->dev;
687 struct mv_port_priv *pp;
688 void __iomem *port_mmio = mv_ap_base(ap);
689 void *mem;
690 dma_addr_t mem_dma;
691
692 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
693 if (!pp) {
694 return -ENOMEM;
695 }
696 memset(pp, 0, sizeof(*pp));
697
698 mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma,
699 GFP_KERNEL);
700 if (!mem) {
701 kfree(pp);
702 return -ENOMEM;
703 }
704 memset(mem, 0, MV_PORT_PRIV_DMA_SZ);
705
706 /* First item in chunk of DMA memory:
707 * 32-slot command request table (CRQB), 32 bytes each in size
708 */
709 pp->crqb = mem;
710 pp->crqb_dma = mem_dma;
711 mem += MV_CRQB_Q_SZ;
712 mem_dma += MV_CRQB_Q_SZ;
713
714 /* Second item:
715 * 32-slot command response table (CRPB), 8 bytes each in size
716 */
717 pp->crpb = mem;
718 pp->crpb_dma = mem_dma;
719 mem += MV_CRPB_Q_SZ;
720 mem_dma += MV_CRPB_Q_SZ;
721
722 /* Third item:
723 * Table of scatter-gather descriptors (ePRD), 16 bytes each
724 */
725 pp->sg_tbl = mem;
726 pp->sg_tbl_dma = mem_dma;
727
728 writelfl(EDMA_CFG_Q_DEPTH | EDMA_CFG_RD_BRST_EXT |
729 EDMA_CFG_WR_BUFF_LEN, port_mmio + EDMA_CFG_OFS);
730
731 writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS);
732 writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK,
733 port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
734
735 writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS);
736 writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS);
737
738 writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS);
739 writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK,
740 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
741
742 pp->req_producer = pp->rsp_consumer = 0;
743
744 /* Don't turn on EDMA here...do it before DMA commands only. Else
745 * we'll be unable to send non-data, PIO, etc due to restricted access
746 * to shadow regs.
747 */
748 ap->private_data = pp;
749 return 0;
750}
751
752/**
753 * mv_port_stop - Port specific cleanup/stop routine.
754 * @ap: ATA channel to manipulate
755 *
756 * Stop DMA, cleanup port memory.
757 *
758 * LOCKING:
759 * This routine uses the host_set lock to protect the DMA stop.
760 */
761static void mv_port_stop(struct ata_port *ap)
762{
763 struct device *dev = ap->host_set->dev;
764 struct mv_port_priv *pp = ap->private_data;
765 unsigned long flags;
766
767 spin_lock_irqsave(&ap->host_set->lock, flags);
768 mv_stop_dma(ap);
769 spin_unlock_irqrestore(&ap->host_set->lock, flags);
770
771 ap->private_data = NULL;
772 dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma);
773 kfree(pp);
774}
775
776/**
777 * mv_fill_sg - Fill out the Marvell ePRD (scatter gather) entries
778 * @qc: queued command whose SG list to source from
779 *
780 * Populate the SG list and mark the last entry.
781 *
782 * LOCKING:
783 * Inherited from caller.
784 */
785static void mv_fill_sg(struct ata_queued_cmd *qc)
786{
787 struct mv_port_priv *pp = qc->ap->private_data;
788 unsigned int i;
789
790 for (i = 0; i < qc->n_elem; i++) {
791 u32 sg_len;
792 dma_addr_t addr;
793
794 addr = sg_dma_address(&qc->sg[i]);
795 sg_len = sg_dma_len(&qc->sg[i]);
796
797 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff);
798 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
799 assert(0 == (sg_len & ~MV_DMA_BOUNDARY));
800 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len);
801 }
802 if (0 < qc->n_elem) {
803 pp->sg_tbl[qc->n_elem - 1].flags_size |=
804 cpu_to_le32(EPRD_FLAG_END_OF_TBL);
805 }
806}
807
808static inline unsigned mv_inc_q_index(unsigned *index)
809{
810 *index = (*index + 1) & MV_MAX_Q_DEPTH_MASK;
811 return *index;
812}
813
814static inline void mv_crqb_pack_cmd(u16 *cmdw, u8 data, u8 addr, unsigned last)
815{
816 *cmdw = data | (addr << CRQB_CMD_ADDR_SHIFT) | CRQB_CMD_CS |
817 (last ? CRQB_CMD_LAST : 0);
818}
455 819
456 /* bug here b/c we got an err int on a port we don't know about, 820/**
457 * so there's no way to clear it 821 * mv_qc_prep - Host specific command preparation.
822 * @qc: queued command to prepare
823 *
824 * This routine simply redirects to the general purpose routine
825 * if command is not DMA. Else, it handles prep of the CRQB
826 * (command request block), does some sanity checking, and calls
827 * the SG load routine.
828 *
829 * LOCKING:
830 * Inherited from caller.
831 */
832static void mv_qc_prep(struct ata_queued_cmd *qc)
833{
834 struct ata_port *ap = qc->ap;
835 struct mv_port_priv *pp = ap->private_data;
836 u16 *cw;
837 struct ata_taskfile *tf;
838 u16 flags = 0;
839
840 if (ATA_PROT_DMA != qc->tf.protocol) {
841 return;
842 }
843
844 /* the req producer index should be the same as we remember it */
845 assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >>
846 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
847 pp->req_producer);
848
849 /* Fill in command request block
458 */ 850 */
459 BUG_ON(NULL == ap); 851 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) {
460 port_mmio = mv_ap_base(ap); 852 flags |= CRQB_FLAG_READ;
853 }
854 assert(MV_MAX_Q_DEPTH > qc->tag);
855 flags |= qc->tag << CRQB_TAG_SHIFT;
856
857 pp->crqb[pp->req_producer].sg_addr =
858 cpu_to_le32(pp->sg_tbl_dma & 0xffffffff);
859 pp->crqb[pp->req_producer].sg_addr_hi =
860 cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16);
861 pp->crqb[pp->req_producer].ctrl_flags = cpu_to_le16(flags);
862
863 cw = &pp->crqb[pp->req_producer].ata_cmd[0];
864 tf = &qc->tf;
865
866 /* Sadly, the CRQB cannot accomodate all registers--there are
867 * only 11 bytes...so we must pick and choose required
868 * registers based on the command. So, we drop feature and
869 * hob_feature for [RW] DMA commands, but they are needed for
870 * NCQ. NCQ will drop hob_nsect.
871 */
872 switch (tf->command) {
873 case ATA_CMD_READ:
874 case ATA_CMD_READ_EXT:
875 case ATA_CMD_WRITE:
876 case ATA_CMD_WRITE_EXT:
877 mv_crqb_pack_cmd(cw++, tf->hob_nsect, ATA_REG_NSECT, 0);
878 break;
879#ifdef LIBATA_NCQ /* FIXME: remove this line when NCQ added */
880 case ATA_CMD_FPDMA_READ:
881 case ATA_CMD_FPDMA_WRITE:
882 mv_crqb_pack_cmd(cw++, tf->hob_feature, ATA_REG_FEATURE, 0);
883 mv_crqb_pack_cmd(cw++, tf->feature, ATA_REG_FEATURE, 0);
884 break;
885#endif /* FIXME: remove this line when NCQ added */
886 default:
887 /* The only other commands EDMA supports in non-queued and
888 * non-NCQ mode are: [RW] STREAM DMA and W DMA FUA EXT, none
889 * of which are defined/used by Linux. If we get here, this
890 * driver needs work.
891 *
892 * FIXME: modify libata to give qc_prep a return value and
893 * return error here.
894 */
895 BUG_ON(tf->command);
896 break;
897 }
898 mv_crqb_pack_cmd(cw++, tf->nsect, ATA_REG_NSECT, 0);
899 mv_crqb_pack_cmd(cw++, tf->hob_lbal, ATA_REG_LBAL, 0);
900 mv_crqb_pack_cmd(cw++, tf->lbal, ATA_REG_LBAL, 0);
901 mv_crqb_pack_cmd(cw++, tf->hob_lbam, ATA_REG_LBAM, 0);
902 mv_crqb_pack_cmd(cw++, tf->lbam, ATA_REG_LBAM, 0);
903 mv_crqb_pack_cmd(cw++, tf->hob_lbah, ATA_REG_LBAH, 0);
904 mv_crqb_pack_cmd(cw++, tf->lbah, ATA_REG_LBAH, 0);
905 mv_crqb_pack_cmd(cw++, tf->device, ATA_REG_DEVICE, 0);
906 mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */
907
908 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) {
909 return;
910 }
911 mv_fill_sg(qc);
912}
913
914/**
915 * mv_qc_issue - Initiate a command to the host
916 * @qc: queued command to start
917 *
918 * This routine simply redirects to the general purpose routine
919 * if command is not DMA. Else, it sanity checks our local
920 * caches of the request producer/consumer indices then enables
921 * DMA and bumps the request producer index.
922 *
923 * LOCKING:
924 * Inherited from caller.
925 */
926static int mv_qc_issue(struct ata_queued_cmd *qc)
927{
928 void __iomem *port_mmio = mv_ap_base(qc->ap);
929 struct mv_port_priv *pp = qc->ap->private_data;
930 u32 in_ptr;
931
932 if (ATA_PROT_DMA != qc->tf.protocol) {
933 /* We're about to send a non-EDMA capable command to the
934 * port. Turn off EDMA so there won't be problems accessing
935 * shadow block, etc registers.
936 */
937 mv_stop_dma(qc->ap);
938 return ata_qc_issue_prot(qc);
939 }
940
941 in_ptr = readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
942
943 /* the req producer index should be the same as we remember it */
944 assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
945 pp->req_producer);
946 /* until we do queuing, the queue should be empty at this point */
947 assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
948 ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >>
949 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK));
950
951 mv_inc_q_index(&pp->req_producer); /* now incr producer index */
952
953 mv_start_dma(port_mmio, pp);
954
955 /* and write the request in pointer to kick the EDMA to life */
956 in_ptr &= EDMA_REQ_Q_BASE_LO_MASK;
957 in_ptr |= pp->req_producer << EDMA_REQ_Q_PTR_SHIFT;
958 writelfl(in_ptr, port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
959
960 return 0;
961}
962
963/**
964 * mv_get_crpb_status - get status from most recently completed cmd
965 * @ap: ATA channel to manipulate
966 *
967 * This routine is for use when the port is in DMA mode, when it
968 * will be using the CRPB (command response block) method of
969 * returning command completion information. We assert indices
970 * are good, grab status, and bump the response consumer index to
971 * prove that we're up to date.
972 *
973 * LOCKING:
974 * Inherited from caller.
975 */
976static u8 mv_get_crpb_status(struct ata_port *ap)
977{
978 void __iomem *port_mmio = mv_ap_base(ap);
979 struct mv_port_priv *pp = ap->private_data;
980 u32 out_ptr;
981
982 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
983
984 /* the response consumer index should be the same as we remember it */
985 assert(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
986 pp->rsp_consumer);
987
988 /* increment our consumer index... */
989 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
990
991 /* and, until we do NCQ, there should only be 1 CRPB waiting */
992 assert(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >>
993 EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
994 pp->rsp_consumer);
995
996 /* write out our inc'd consumer index so EDMA knows we're caught up */
997 out_ptr &= EDMA_RSP_Q_BASE_LO_MASK;
998 out_ptr |= pp->rsp_consumer << EDMA_RSP_Q_PTR_SHIFT;
999 writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1000
1001 /* Return ATA status register for completed CRPB */
1002 return (pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT);
1003}
1004
1005/**
1006 * mv_err_intr - Handle error interrupts on the port
1007 * @ap: ATA channel to manipulate
1008 *
1009 * In most cases, just clear the interrupt and move on. However,
1010 * some cases require an eDMA reset, which is done right before
1011 * the COMRESET in mv_phy_reset(). The SERR case requires a
1012 * clear of pending errors in the SATA SERROR register. Finally,
1013 * if the port disabled DMA, update our cached copy to match.
1014 *
1015 * LOCKING:
1016 * Inherited from caller.
1017 */
1018static void mv_err_intr(struct ata_port *ap)
1019{
1020 void __iomem *port_mmio = mv_ap_base(ap);
1021 u32 edma_err_cause, serr = 0;
461 1022
462 edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1023 edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
463 1024
@@ -465,8 +1026,12 @@ static void mv_err_intr(struct ata_port *ap)
465 serr = scr_read(ap, SCR_ERROR); 1026 serr = scr_read(ap, SCR_ERROR);
466 scr_write_flush(ap, SCR_ERROR, serr); 1027 scr_write_flush(ap, SCR_ERROR, serr);
467 } 1028 }
468 DPRINTK("port %u error; EDMA err cause: 0x%08x SERR: 0x%08x\n", 1029 if (EDMA_ERR_SELF_DIS & edma_err_cause) {
469 ap->port_no, edma_err_cause, serr); 1030 struct mv_port_priv *pp = ap->private_data;
1031 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
1032 }
1033 DPRINTK(KERN_ERR "ata%u: port error; EDMA err cause: 0x%08x "
1034 "SERR: 0x%08x\n", ap->id, edma_err_cause, serr);
470 1035
471 /* Clear EDMA now that SERR cleanup done */ 1036 /* Clear EDMA now that SERR cleanup done */
472 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1037 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
@@ -477,7 +1042,21 @@ static void mv_err_intr(struct ata_port *ap)
477 } 1042 }
478} 1043}
479 1044
480/* Handle any outstanding interrupts in a single SATAHC 1045/**
1046 * mv_host_intr - Handle all interrupts on the given host controller
1047 * @host_set: host specific structure
1048 * @relevant: port error bits relevant to this host controller
1049 * @hc: which host controller we're to look at
1050 *
1051 * Read then write clear the HC interrupt status then walk each
1052 * port connected to the HC and see if it needs servicing. Port
1053 * success ints are reported in the HC interrupt status reg, the
1054 * port error ints are reported in the higher level main
1055 * interrupt status register and thus are passed in via the
1056 * 'relevant' argument.
1057 *
1058 * LOCKING:
1059 * Inherited from caller.
481 */ 1060 */
482static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, 1061static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
483 unsigned int hc) 1062 unsigned int hc)
@@ -487,8 +1066,8 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
487 struct ata_port *ap; 1066 struct ata_port *ap;
488 struct ata_queued_cmd *qc; 1067 struct ata_queued_cmd *qc;
489 u32 hc_irq_cause; 1068 u32 hc_irq_cause;
490 int shift, port, port0, hard_port; 1069 int shift, port, port0, hard_port, handled;
491 u8 ata_status; 1070 u8 ata_status = 0;
492 1071
493 if (hc == 0) { 1072 if (hc == 0) {
494 port0 = 0; 1073 port0 = 0;
@@ -499,7 +1078,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
499 /* we'll need the HC success int register in most cases */ 1078 /* we'll need the HC success int register in most cases */
500 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); 1079 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS);
501 if (hc_irq_cause) { 1080 if (hc_irq_cause) {
502 writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS); 1081 writelfl(~hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
503 } 1082 }
504 1083
505 VPRINTK("ENTER, hc%u relevant=0x%08x HC IRQ cause=0x%08x\n", 1084 VPRINTK("ENTER, hc%u relevant=0x%08x HC IRQ cause=0x%08x\n",
@@ -508,35 +1087,38 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
508 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { 1087 for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) {
509 ap = host_set->ports[port]; 1088 ap = host_set->ports[port];
510 hard_port = port & MV_PORT_MASK; /* range 0-3 */ 1089 hard_port = port & MV_PORT_MASK; /* range 0-3 */
511 ata_status = 0xffU; 1090 handled = 0; /* ensure ata_status is set if handled++ */
512 1091
513 if (((CRBP_DMA_DONE | DEV_IRQ) << hard_port) & hc_irq_cause) { 1092 if ((CRPB_DMA_DONE << hard_port) & hc_irq_cause) {
514 BUG_ON(NULL == ap); 1093 /* new CRPB on the queue; just one at a time until NCQ
515 /* rcv'd new resp, basic DMA complete, or ATA IRQ */ 1094 */
516 /* This is needed to clear the ATA INTRQ. 1095 ata_status = mv_get_crpb_status(ap);
517 * FIXME: don't read the status reg in EDMA mode! 1096 handled++;
1097 } else if ((DEV_IRQ << hard_port) & hc_irq_cause) {
1098 /* received ATA IRQ; read the status reg to clear INTRQ
518 */ 1099 */
519 ata_status = readb((void __iomem *) 1100 ata_status = readb((void __iomem *)
520 ap->ioaddr.status_addr); 1101 ap->ioaddr.status_addr);
1102 handled++;
521 } 1103 }
522 1104
523 shift = port * 2; 1105 shift = port << 1; /* (port * 2) */
524 if (port >= MV_PORTS_PER_HC) { 1106 if (port >= MV_PORTS_PER_HC) {
525 shift++; /* skip bit 8 in the HC Main IRQ reg */ 1107 shift++; /* skip bit 8 in the HC Main IRQ reg */
526 } 1108 }
527 if ((PORT0_ERR << shift) & relevant) { 1109 if ((PORT0_ERR << shift) & relevant) {
528 mv_err_intr(ap); 1110 mv_err_intr(ap);
529 /* FIXME: smart to OR in ATA_ERR? */ 1111 /* OR in ATA_ERR to ensure libata knows we took one */
530 ata_status = readb((void __iomem *) 1112 ata_status = readb((void __iomem *)
531 ap->ioaddr.status_addr) | ATA_ERR; 1113 ap->ioaddr.status_addr) | ATA_ERR;
1114 handled++;
532 } 1115 }
533 1116
534 if (ap) { 1117 if (handled && ap) {
535 qc = ata_qc_from_tag(ap, ap->active_tag); 1118 qc = ata_qc_from_tag(ap, ap->active_tag);
536 if (NULL != qc) { 1119 if (NULL != qc) {
537 VPRINTK("port %u IRQ found for qc, " 1120 VPRINTK("port %u IRQ found for qc, "
538 "ata_status 0x%x\n", port,ata_status); 1121 "ata_status 0x%x\n", port,ata_status);
539 BUG_ON(0xffU == ata_status);
540 /* mark qc status appropriately */ 1122 /* mark qc status appropriately */
541 ata_qc_complete(qc, ata_status); 1123 ata_qc_complete(qc, ata_status);
542 } 1124 }
@@ -545,17 +1127,30 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
545 VPRINTK("EXIT\n"); 1127 VPRINTK("EXIT\n");
546} 1128}
547 1129
1130/**
1131 * mv_interrupt -
1132 * @irq: unused
1133 * @dev_instance: private data; in this case the host structure
1134 * @regs: unused
1135 *
1136 * Read the read only register to determine if any host
1137 * controllers have pending interrupts. If so, call lower level
1138 * routine to handle. Also check for PCI errors which are only
1139 * reported here.
1140 *
1141 * LOCKING:
1142 * This routine holds the host_set lock while processing pending
1143 * interrupts.
1144 */
548static irqreturn_t mv_interrupt(int irq, void *dev_instance, 1145static irqreturn_t mv_interrupt(int irq, void *dev_instance,
549 struct pt_regs *regs) 1146 struct pt_regs *regs)
550{ 1147{
551 struct ata_host_set *host_set = dev_instance; 1148 struct ata_host_set *host_set = dev_instance;
552 unsigned int hc, handled = 0, n_hcs; 1149 unsigned int hc, handled = 0, n_hcs;
553 void __iomem *mmio; 1150 void __iomem *mmio = host_set->mmio_base;
554 u32 irq_stat; 1151 u32 irq_stat;
555 1152
556 mmio = host_set->mmio_base;
557 irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS); 1153 irq_stat = readl(mmio + HC_MAIN_IRQ_CAUSE_OFS);
558 n_hcs = mv_get_hc_count(host_set->ports[0]->flags);
559 1154
560 /* check the cases where we either have nothing pending or have read 1155 /* check the cases where we either have nothing pending or have read
561 * a bogus register value which can indicate HW removal or PCI fault 1156 * a bogus register value which can indicate HW removal or PCI fault
@@ -564,64 +1159,105 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
564 return IRQ_NONE; 1159 return IRQ_NONE;
565 } 1160 }
566 1161
1162 n_hcs = mv_get_hc_count(host_set->ports[0]->flags);
567 spin_lock(&host_set->lock); 1163 spin_lock(&host_set->lock);
568 1164
569 for (hc = 0; hc < n_hcs; hc++) { 1165 for (hc = 0; hc < n_hcs; hc++) {
570 u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT)); 1166 u32 relevant = irq_stat & (HC0_IRQ_PEND << (hc * HC_SHIFT));
571 if (relevant) { 1167 if (relevant) {
572 mv_host_intr(host_set, relevant, hc); 1168 mv_host_intr(host_set, relevant, hc);
573 handled = 1; 1169 handled++;
574 } 1170 }
575 } 1171 }
576 if (PCI_ERR & irq_stat) { 1172 if (PCI_ERR & irq_stat) {
577 /* FIXME: these are all masked by default, but still need 1173 printk(KERN_ERR DRV_NAME ": PCI ERROR; PCI IRQ cause=0x%08x\n",
578 * to recover from them properly. 1174 readl(mmio + PCI_IRQ_CAUSE_OFS));
579 */
580 }
581 1175
1176 DPRINTK("All regs @ PCI error\n");
1177 mv_dump_all_regs(mmio, -1, to_pci_dev(host_set->dev));
1178
1179 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS);
1180 handled++;
1181 }
582 spin_unlock(&host_set->lock); 1182 spin_unlock(&host_set->lock);
583 1183
584 return IRQ_RETVAL(handled); 1184 return IRQ_RETVAL(handled);
585} 1185}
586 1186
1187/**
1188 * mv_check_err - Return the error shadow register to caller.
1189 * @ap: ATA channel to manipulate
1190 *
1191 * Marvell requires DMA to be stopped before accessing shadow
1192 * registers. So we do that, then return the needed register.
1193 *
1194 * LOCKING:
1195 * Inherited from caller. FIXME: protect mv_stop_dma with lock?
1196 */
1197static u8 mv_check_err(struct ata_port *ap)
1198{
1199 mv_stop_dma(ap); /* can't read shadow regs if DMA on */
1200 return readb((void __iomem *) ap->ioaddr.error_addr);
1201}
1202
1203/**
1204 * mv_phy_reset - Perform eDMA reset followed by COMRESET
1205 * @ap: ATA channel to manipulate
1206 *
1207 * Part of this is taken from __sata_phy_reset and modified to
1208 * not sleep since this routine gets called from interrupt level.
1209 *
1210 * LOCKING:
1211 * Inherited from caller. This is coded to safe to call at
1212 * interrupt level, i.e. it does not sleep.
1213 */
587static void mv_phy_reset(struct ata_port *ap) 1214static void mv_phy_reset(struct ata_port *ap)
588{ 1215{
589 void __iomem *port_mmio = mv_ap_base(ap); 1216 void __iomem *port_mmio = mv_ap_base(ap);
590 struct ata_taskfile tf; 1217 struct ata_taskfile tf;
591 struct ata_device *dev = &ap->device[0]; 1218 struct ata_device *dev = &ap->device[0];
592 u32 edma = 0, bdma; 1219 unsigned long timeout;
593 1220
594 VPRINTK("ENTER, port %u, mmio 0x%p\n", ap->port_no, port_mmio); 1221 VPRINTK("ENTER, port %u, mmio 0x%p\n", ap->port_no, port_mmio);
595 1222
596 edma = readl(port_mmio + EDMA_CMD_OFS); 1223 mv_stop_dma(ap);
597 if (EDMA_EN & edma) {
598 /* disable EDMA if active */
599 edma &= ~EDMA_EN;
600 writelfl(edma | EDMA_DS, port_mmio + EDMA_CMD_OFS);
601 udelay(1);
602 } else if (mv_port_bdma_capable(ap) &&
603 (bdma = readl(port_mmio + BDMA_CMD_OFS)) & BDMA_START) {
604 /* disable BDMA if active */
605 writelfl(bdma & ~BDMA_START, port_mmio + BDMA_CMD_OFS);
606 }
607 1224
608 writelfl(edma | ATA_RST, port_mmio + EDMA_CMD_OFS); 1225 writelfl(ATA_RST, port_mmio + EDMA_CMD_OFS);
609 udelay(25); /* allow reset propagation */ 1226 udelay(25); /* allow reset propagation */
610 1227
611 /* Spec never mentions clearing the bit. Marvell's driver does 1228 /* Spec never mentions clearing the bit. Marvell's driver does
612 * clear the bit, however. 1229 * clear the bit, however.
613 */ 1230 */
614 writelfl(edma & ~ATA_RST, port_mmio + EDMA_CMD_OFS); 1231 writelfl(0, port_mmio + EDMA_CMD_OFS);
615 1232
616 VPRINTK("Done. Now calling __sata_phy_reset()\n"); 1233 VPRINTK("S-regs after ATA_RST: SStat 0x%08x SErr 0x%08x "
1234 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS),
1235 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL));
617 1236
618 /* proceed to init communications via the scr_control reg */ 1237 /* proceed to init communications via the scr_control reg */
619 __sata_phy_reset(ap); 1238 scr_write_flush(ap, SCR_CONTROL, 0x301);
1239 mdelay(1);
1240 scr_write_flush(ap, SCR_CONTROL, 0x300);
1241 timeout = jiffies + (HZ * 1);
1242 do {
1243 mdelay(10);
1244 if ((scr_read(ap, SCR_STATUS) & 0xf) != 1)
1245 break;
1246 } while (time_before(jiffies, timeout));
620 1247
621 if (ap->flags & ATA_FLAG_PORT_DISABLED) { 1248 VPRINTK("S-regs after PHY wake: SStat 0x%08x SErr 0x%08x "
622 VPRINTK("Port disabled pre-sig. Exiting.\n"); 1249 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS),
1250 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL));
1251
1252 if (sata_dev_present(ap)) {
1253 ata_port_probe(ap);
1254 } else {
1255 printk(KERN_INFO "ata%u: no device found (phy stat %08x)\n",
1256 ap->id, scr_read(ap, SCR_STATUS));
1257 ata_port_disable(ap);
623 return; 1258 return;
624 } 1259 }
1260 ap->cbl = ATA_CBL_SATA;
625 1261
626 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr); 1262 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr);
627 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr); 1263 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr);
@@ -636,37 +1272,118 @@ static void mv_phy_reset(struct ata_port *ap)
636 VPRINTK("EXIT\n"); 1272 VPRINTK("EXIT\n");
637} 1273}
638 1274
639static void mv_port_init(struct ata_ioports *port, unsigned long base) 1275/**
1276 * mv_eng_timeout - Routine called by libata when SCSI times out I/O
1277 * @ap: ATA channel to manipulate
1278 *
1279 * Intent is to clear all pending error conditions, reset the
1280 * chip/bus, fail the command, and move on.
1281 *
1282 * LOCKING:
1283 * This routine holds the host_set lock while failing the command.
1284 */
1285static void mv_eng_timeout(struct ata_port *ap)
1286{
1287 struct ata_queued_cmd *qc;
1288 unsigned long flags;
1289
1290 printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id);
1291 DPRINTK("All regs @ start of eng_timeout\n");
1292 mv_dump_all_regs(ap->host_set->mmio_base, ap->port_no,
1293 to_pci_dev(ap->host_set->dev));
1294
1295 qc = ata_qc_from_tag(ap, ap->active_tag);
1296 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
1297 ap->host_set->mmio_base, ap, qc, qc->scsicmd,
1298 &qc->scsicmd->cmnd);
1299
1300 mv_err_intr(ap);
1301 mv_phy_reset(ap);
1302
1303 if (!qc) {
1304 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
1305 ap->id);
1306 } else {
1307 /* hack alert! We cannot use the supplied completion
1308 * function from inside the ->eh_strategy_handler() thread.
1309 * libata is the only user of ->eh_strategy_handler() in
1310 * any kernel, so the default scsi_done() assumes it is
1311 * not being called from the SCSI EH.
1312 */
1313 spin_lock_irqsave(&ap->host_set->lock, flags);
1314 qc->scsidone = scsi_finish_command;
1315 ata_qc_complete(qc, ATA_ERR);
1316 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1317 }
1318}
1319
1320/**
1321 * mv_port_init - Perform some early initialization on a single port.
1322 * @port: libata data structure storing shadow register addresses
1323 * @port_mmio: base address of the port
1324 *
1325 * Initialize shadow register mmio addresses, clear outstanding
1326 * interrupts on the port, and unmask interrupts for the future
1327 * start of the port.
1328 *
1329 * LOCKING:
1330 * Inherited from caller.
1331 */
1332static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
640{ 1333{
641 /* PIO related setup */ 1334 unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS;
642 port->data_addr = base + SHD_PIO_DATA_OFS; 1335 unsigned serr_ofs;
643 port->error_addr = port->feature_addr = base + SHD_FEA_ERR_OFS; 1336
644 port->nsect_addr = base + SHD_SECT_CNT_OFS; 1337 /* PIO related setup
645 port->lbal_addr = base + SHD_LBA_L_OFS; 1338 */
646 port->lbam_addr = base + SHD_LBA_M_OFS; 1339 port->data_addr = shd_base + (sizeof(u32) * ATA_REG_DATA);
647 port->lbah_addr = base + SHD_LBA_H_OFS; 1340 port->error_addr =
648 port->device_addr = base + SHD_DEV_HD_OFS; 1341 port->feature_addr = shd_base + (sizeof(u32) * ATA_REG_ERR);
649 port->status_addr = port->command_addr = base + SHD_CMD_STA_OFS; 1342 port->nsect_addr = shd_base + (sizeof(u32) * ATA_REG_NSECT);
650 port->altstatus_addr = port->ctl_addr = base + SHD_CTL_AST_OFS; 1343 port->lbal_addr = shd_base + (sizeof(u32) * ATA_REG_LBAL);
651 /* unused */ 1344 port->lbam_addr = shd_base + (sizeof(u32) * ATA_REG_LBAM);
1345 port->lbah_addr = shd_base + (sizeof(u32) * ATA_REG_LBAH);
1346 port->device_addr = shd_base + (sizeof(u32) * ATA_REG_DEVICE);
1347 port->status_addr =
1348 port->command_addr = shd_base + (sizeof(u32) * ATA_REG_STATUS);
1349 /* special case: control/altstatus doesn't have ATA_REG_ address */
1350 port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS;
1351
1352 /* unused: */
652 port->cmd_addr = port->bmdma_addr = port->scr_addr = 0; 1353 port->cmd_addr = port->bmdma_addr = port->scr_addr = 0;
653 1354
1355 /* Clear any currently outstanding port interrupt conditions */
1356 serr_ofs = mv_scr_offset(SCR_ERROR);
1357 writelfl(readl(port_mmio + serr_ofs), port_mmio + serr_ofs);
1358 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1359
654 /* unmask all EDMA error interrupts */ 1360 /* unmask all EDMA error interrupts */
655 writel(~0, (void __iomem *)base + EDMA_ERR_IRQ_MASK_OFS); 1361 writelfl(~0, port_mmio + EDMA_ERR_IRQ_MASK_OFS);
656 1362
657 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n", 1363 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n",
658 readl((void __iomem *)base + EDMA_CFG_OFS), 1364 readl(port_mmio + EDMA_CFG_OFS),
659 readl((void __iomem *)base + EDMA_ERR_IRQ_CAUSE_OFS), 1365 readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS),
660 readl((void __iomem *)base + EDMA_ERR_IRQ_MASK_OFS)); 1366 readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS));
661} 1367}
662 1368
1369/**
1370 * mv_host_init - Perform some early initialization of the host.
1371 * @probe_ent: early data struct representing the host
1372 *
1373 * If possible, do an early global reset of the host. Then do
1374 * our port init and clear/unmask all/relevant host interrupts.
1375 *
1376 * LOCKING:
1377 * Inherited from caller.
1378 */
663static int mv_host_init(struct ata_probe_ent *probe_ent) 1379static int mv_host_init(struct ata_probe_ent *probe_ent)
664{ 1380{
665 int rc = 0, n_hc, port, hc; 1381 int rc = 0, n_hc, port, hc;
666 void __iomem *mmio = probe_ent->mmio_base; 1382 void __iomem *mmio = probe_ent->mmio_base;
667 void __iomem *port_mmio; 1383 void __iomem *port_mmio;
668 1384
669 if (mv_master_reset(probe_ent->mmio_base)) { 1385 if ((MV_FLAG_GLBL_SFT_RST & probe_ent->host_flags) &&
1386 mv_global_soft_reset(probe_ent->mmio_base)) {
670 rc = 1; 1387 rc = 1;
671 goto done; 1388 goto done;
672 } 1389 }
@@ -676,17 +1393,27 @@ static int mv_host_init(struct ata_probe_ent *probe_ent)
676 1393
677 for (port = 0; port < probe_ent->n_ports; port++) { 1394 for (port = 0; port < probe_ent->n_ports; port++) {
678 port_mmio = mv_port_base(mmio, port); 1395 port_mmio = mv_port_base(mmio, port);
679 mv_port_init(&probe_ent->port[port], (unsigned long)port_mmio); 1396 mv_port_init(&probe_ent->port[port], port_mmio);
680 } 1397 }
681 1398
682 for (hc = 0; hc < n_hc; hc++) { 1399 for (hc = 0; hc < n_hc; hc++) {
683 VPRINTK("HC%i: HC config=0x%08x HC IRQ cause=0x%08x\n", hc, 1400 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
684 readl(mv_hc_base(mmio, hc) + HC_CFG_OFS), 1401
685 readl(mv_hc_base(mmio, hc) + HC_IRQ_CAUSE_OFS)); 1402 VPRINTK("HC%i: HC config=0x%08x HC IRQ cause "
1403 "(before clear)=0x%08x\n", hc,
1404 readl(hc_mmio + HC_CFG_OFS),
1405 readl(hc_mmio + HC_IRQ_CAUSE_OFS));
1406
1407 /* Clear any currently outstanding hc interrupt conditions */
1408 writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS);
686 } 1409 }
687 1410
688 writel(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS); 1411 /* Clear any currently outstanding host interrupt conditions */
689 writel(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS); 1412 writelfl(0, mmio + PCI_IRQ_CAUSE_OFS);
1413
1414 /* and unmask interrupt generation for host regs */
1415 writelfl(PCI_UNMASK_ALL_IRQS, mmio + PCI_IRQ_MASK_OFS);
1416 writelfl(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS);
690 1417
691 VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x " 1418 VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x "
692 "PCI int cause/mask=0x%08x/0x%08x\n", 1419 "PCI int cause/mask=0x%08x/0x%08x\n",
@@ -694,11 +1421,53 @@ static int mv_host_init(struct ata_probe_ent *probe_ent)
694 readl(mmio + HC_MAIN_IRQ_MASK_OFS), 1421 readl(mmio + HC_MAIN_IRQ_MASK_OFS),
695 readl(mmio + PCI_IRQ_CAUSE_OFS), 1422 readl(mmio + PCI_IRQ_CAUSE_OFS),
696 readl(mmio + PCI_IRQ_MASK_OFS)); 1423 readl(mmio + PCI_IRQ_MASK_OFS));
697 1424done:
698 done:
699 return rc; 1425 return rc;
700} 1426}
701 1427
1428/**
1429 * mv_print_info - Dump key info to kernel log for perusal.
1430 * @probe_ent: early data struct representing the host
1431 *
1432 * FIXME: complete this.
1433 *
1434 * LOCKING:
1435 * Inherited from caller.
1436 */
1437static void mv_print_info(struct ata_probe_ent *probe_ent)
1438{
1439 struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
1440 struct mv_host_priv *hpriv = probe_ent->private_data;
1441 u8 rev_id, scc;
1442 const char *scc_s;
1443
1444 /* Use this to determine the HW stepping of the chip so we know
1445 * what errata to workaround
1446 */
1447 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
1448
1449 pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &scc);
1450 if (scc == 0)
1451 scc_s = "SCSI";
1452 else if (scc == 0x01)
1453 scc_s = "RAID";
1454 else
1455 scc_s = "unknown";
1456
1457 printk(KERN_INFO DRV_NAME
1458 "(%s) %u slots %u ports %s mode IRQ via %s\n",
1459 pci_name(pdev), (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports,
1460 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
1461}
1462
1463/**
1464 * mv_init_one - handle a positive probe of a Marvell host
1465 * @pdev: PCI device found
1466 * @ent: PCI device ID entry for the matched host
1467 *
1468 * LOCKING:
1469 * Inherited from caller.
1470 */
702static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1471static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
703{ 1472{
704 static int printed_version = 0; 1473 static int printed_version = 0;
@@ -706,16 +1475,12 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
706 struct mv_host_priv *hpriv; 1475 struct mv_host_priv *hpriv;
707 unsigned int board_idx = (unsigned int)ent->driver_data; 1476 unsigned int board_idx = (unsigned int)ent->driver_data;
708 void __iomem *mmio_base; 1477 void __iomem *mmio_base;
709 int pci_dev_busy = 0; 1478 int pci_dev_busy = 0, rc;
710 int rc;
711 1479
712 if (!printed_version++) { 1480 if (!printed_version++) {
713 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 1481 printk(KERN_INFO DRV_NAME " version " DRV_VERSION "\n");
714 } 1482 }
715 1483
716 VPRINTK("ENTER for PCI Bus:Slot.Func=%u:%u.%u\n", pdev->bus->number,
717 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
718
719 rc = pci_enable_device(pdev); 1484 rc = pci_enable_device(pdev);
720 if (rc) { 1485 if (rc) {
721 return rc; 1486 return rc;
@@ -727,8 +1492,6 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
727 goto err_out; 1492 goto err_out;
728 } 1493 }
729 1494
730 pci_intx(pdev, 1);
731
732 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); 1495 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
733 if (probe_ent == NULL) { 1496 if (probe_ent == NULL) {
734 rc = -ENOMEM; 1497 rc = -ENOMEM;
@@ -739,8 +1502,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
739 probe_ent->dev = pci_dev_to_dev(pdev); 1502 probe_ent->dev = pci_dev_to_dev(pdev);
740 INIT_LIST_HEAD(&probe_ent->node); 1503 INIT_LIST_HEAD(&probe_ent->node);
741 1504
742 mmio_base = ioremap_nocache(pci_resource_start(pdev, MV_PRIMARY_BAR), 1505 mmio_base = pci_iomap(pdev, MV_PRIMARY_BAR, 0);
743 pci_resource_len(pdev, MV_PRIMARY_BAR));
744 if (mmio_base == NULL) { 1506 if (mmio_base == NULL) {
745 rc = -ENOMEM; 1507 rc = -ENOMEM;
746 goto err_out_free_ent; 1508 goto err_out_free_ent;
@@ -769,37 +1531,40 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
769 if (rc) { 1531 if (rc) {
770 goto err_out_hpriv; 1532 goto err_out_hpriv;
771 } 1533 }
772/* mv_print_info(probe_ent); */
773 1534
774 { 1535 /* Enable interrupts */
775 int b, w; 1536 if (pci_enable_msi(pdev) == 0) {
776 u32 dw[4]; /* hold a line of 16b */ 1537 hpriv->hp_flags |= MV_HP_FLAG_MSI;
777 VPRINTK("PCI config space:\n"); 1538 } else {
778 for (b = 0; b < 0x40; ) { 1539 pci_intx(pdev, 1);
779 for (w = 0; w < 4; w++) {
780 (void) pci_read_config_dword(pdev,b,&dw[w]);
781 b += sizeof(*dw);
782 }
783 VPRINTK("%08x %08x %08x %08x\n",
784 dw[0],dw[1],dw[2],dw[3]);
785 }
786 } 1540 }
787 1541
788 /* FIXME: check ata_device_add return value */ 1542 mv_dump_pci_cfg(pdev, 0x68);
789 ata_device_add(probe_ent); 1543 mv_print_info(probe_ent);
790 kfree(probe_ent); 1544
1545 if (ata_device_add(probe_ent) == 0) {
1546 rc = -ENODEV; /* No devices discovered */
1547 goto err_out_dev_add;
1548 }
791 1549
1550 kfree(probe_ent);
792 return 0; 1551 return 0;
793 1552
794 err_out_hpriv: 1553err_out_dev_add:
1554 if (MV_HP_FLAG_MSI & hpriv->hp_flags) {
1555 pci_disable_msi(pdev);
1556 } else {
1557 pci_intx(pdev, 0);
1558 }
1559err_out_hpriv:
795 kfree(hpriv); 1560 kfree(hpriv);
796 err_out_iounmap: 1561err_out_iounmap:
797 iounmap(mmio_base); 1562 pci_iounmap(pdev, mmio_base);
798 err_out_free_ent: 1563err_out_free_ent:
799 kfree(probe_ent); 1564 kfree(probe_ent);
800 err_out_regions: 1565err_out_regions:
801 pci_release_regions(pdev); 1566 pci_release_regions(pdev);
802 err_out: 1567err_out:
803 if (!pci_dev_busy) { 1568 if (!pci_dev_busy) {
804 pci_disable_device(pdev); 1569 pci_disable_device(pdev);
805 } 1570 }
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index cb832b03ec5e..1a56d6c79ddd 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -238,7 +238,7 @@ static Scsi_Host_Template nv_sht = {
238 .ordered_flush = 1, 238 .ordered_flush = 1,
239}; 239};
240 240
241static struct ata_port_operations nv_ops = { 241static const struct ata_port_operations nv_ops = {
242 .port_disable = ata_port_disable, 242 .port_disable = ata_port_disable,
243 .tf_load = ata_tf_load, 243 .tf_load = ata_tf_load,
244 .tf_read = ata_tf_read, 244 .tf_read = ata_tf_read,
@@ -331,7 +331,7 @@ static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
331 return 0xffffffffU; 331 return 0xffffffffU;
332 332
333 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 333 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
334 return readl((void*)ap->ioaddr.scr_addr + (sc_reg * 4)); 334 return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
335 else 335 else
336 return inl(ap->ioaddr.scr_addr + (sc_reg * 4)); 336 return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
337} 337}
@@ -345,7 +345,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
345 return; 345 return;
346 346
347 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) 347 if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
348 writel(val, (void*)ap->ioaddr.scr_addr + (sc_reg * 4)); 348 writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
349 else 349 else
350 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)); 350 outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
351} 351}
@@ -405,7 +405,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
405 rc = -ENOMEM; 405 rc = -ENOMEM;
406 406
407 ppi = &nv_port_info; 407 ppi = &nv_port_info;
408 probe_ent = ata_pci_init_native_mode(pdev, &ppi); 408 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
409 if (!probe_ent) 409 if (!probe_ent)
410 goto err_out_regions; 410 goto err_out_regions;
411 411
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 538ad727bd2e..eee93b0016df 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -87,8 +87,8 @@ static void pdc_port_stop(struct ata_port *ap);
87static void pdc_pata_phy_reset(struct ata_port *ap); 87static void pdc_pata_phy_reset(struct ata_port *ap);
88static void pdc_sata_phy_reset(struct ata_port *ap); 88static void pdc_sata_phy_reset(struct ata_port *ap);
89static void pdc_qc_prep(struct ata_queued_cmd *qc); 89static void pdc_qc_prep(struct ata_queued_cmd *qc);
90static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); 90static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
91static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); 91static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
92static void pdc_irq_clear(struct ata_port *ap); 92static void pdc_irq_clear(struct ata_port *ap);
93static int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 93static int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
94 94
@@ -113,7 +113,7 @@ static Scsi_Host_Template pdc_ata_sht = {
113 .ordered_flush = 1, 113 .ordered_flush = 1,
114}; 114};
115 115
116static struct ata_port_operations pdc_sata_ops = { 116static const struct ata_port_operations pdc_sata_ops = {
117 .port_disable = ata_port_disable, 117 .port_disable = ata_port_disable,
118 .tf_load = pdc_tf_load_mmio, 118 .tf_load = pdc_tf_load_mmio,
119 .tf_read = ata_tf_read, 119 .tf_read = ata_tf_read,
@@ -136,7 +136,7 @@ static struct ata_port_operations pdc_sata_ops = {
136 .host_stop = ata_pci_host_stop, 136 .host_stop = ata_pci_host_stop,
137}; 137};
138 138
139static struct ata_port_operations pdc_pata_ops = { 139static const struct ata_port_operations pdc_pata_ops = {
140 .port_disable = ata_port_disable, 140 .port_disable = ata_port_disable,
141 .tf_load = pdc_tf_load_mmio, 141 .tf_load = pdc_tf_load_mmio,
142 .tf_read = ata_tf_read, 142 .tf_read = ata_tf_read,
@@ -324,7 +324,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
324{ 324{
325 if (sc_reg > SCR_CONTROL) 325 if (sc_reg > SCR_CONTROL)
326 return 0xffffffffU; 326 return 0xffffffffU;
327 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 327 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
328} 328}
329 329
330 330
@@ -333,7 +333,7 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
333{ 333{
334 if (sc_reg > SCR_CONTROL) 334 if (sc_reg > SCR_CONTROL)
335 return; 335 return;
336 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 336 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
337} 337}
338 338
339static void pdc_qc_prep(struct ata_queued_cmd *qc) 339static void pdc_qc_prep(struct ata_queued_cmd *qc)
@@ -438,11 +438,11 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap,
438 break; 438 break;
439 439
440 default: 440 default:
441 ap->stats.idle_irq++; 441 ap->stats.idle_irq++;
442 break; 442 break;
443 } 443 }
444 444
445 return handled; 445 return handled;
446} 446}
447 447
448static void pdc_irq_clear(struct ata_port *ap) 448static void pdc_irq_clear(struct ata_port *ap)
@@ -523,8 +523,8 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
523 523
524 pp->pkt[2] = seq; 524 pp->pkt[2] = seq;
525 wmb(); /* flush PRD, pkt writes */ 525 wmb(); /* flush PRD, pkt writes */
526 writel(pp->pkt_dma, (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 526 writel(pp->pkt_dma, (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
527 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ 527 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */
528} 528}
529 529
530static int pdc_qc_issue_prot(struct ata_queued_cmd *qc) 530static int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
@@ -546,7 +546,7 @@ static int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
546 return ata_qc_issue_prot(qc); 546 return ata_qc_issue_prot(qc);
547} 547}
548 548
549static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 549static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
550{ 550{
551 WARN_ON (tf->protocol == ATA_PROT_DMA || 551 WARN_ON (tf->protocol == ATA_PROT_DMA ||
552 tf->protocol == ATA_PROT_NODATA); 552 tf->protocol == ATA_PROT_NODATA);
@@ -554,7 +554,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
554} 554}
555 555
556 556
557static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 557static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
558{ 558{
559 WARN_ON (tf->protocol == ATA_PROT_DMA || 559 WARN_ON (tf->protocol == ATA_PROT_DMA ||
560 tf->protocol == ATA_PROT_NODATA); 560 tf->protocol == ATA_PROT_NODATA);
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index ffcdeb68641c..250dafa6bc36 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -51,8 +51,6 @@ enum {
51 QS_PRD_BYTES = QS_MAX_PRD * 16, 51 QS_PRD_BYTES = QS_MAX_PRD * 16,
52 QS_PKT_BYTES = QS_CPB_BYTES + QS_PRD_BYTES, 52 QS_PKT_BYTES = QS_CPB_BYTES + QS_PRD_BYTES,
53 53
54 QS_DMA_BOUNDARY = ~0UL,
55
56 /* global register offsets */ 54 /* global register offsets */
57 QS_HCF_CNFG3 = 0x0003, /* host configuration offset */ 55 QS_HCF_CNFG3 = 0x0003, /* host configuration offset */
58 QS_HID_HPHY = 0x0004, /* host physical interface info */ 56 QS_HID_HPHY = 0x0004, /* host physical interface info */
@@ -101,6 +99,10 @@ enum {
101 board_2068_idx = 0, /* QStor 4-port SATA/RAID */ 99 board_2068_idx = 0, /* QStor 4-port SATA/RAID */
102}; 100};
103 101
102enum {
103 QS_DMA_BOUNDARY = ~0UL
104};
105
104typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t; 106typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t;
105 107
106struct qs_port_priv { 108struct qs_port_priv {
@@ -145,7 +147,7 @@ static Scsi_Host_Template qs_ata_sht = {
145 .bios_param = ata_std_bios_param, 147 .bios_param = ata_std_bios_param,
146}; 148};
147 149
148static struct ata_port_operations qs_ata_ops = { 150static const struct ata_port_operations qs_ata_ops = {
149 .port_disable = ata_port_disable, 151 .port_disable = ata_port_disable,
150 .tf_load = ata_tf_load, 152 .tf_load = ata_tf_load,
151 .tf_read = ata_tf_read, 153 .tf_read = ata_tf_read,
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index ba98a175ee3a..3a056173fb95 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -150,7 +150,7 @@ static Scsi_Host_Template sil_sht = {
150 .ordered_flush = 1, 150 .ordered_flush = 1,
151}; 151};
152 152
153static struct ata_port_operations sil_ops = { 153static const struct ata_port_operations sil_ops = {
154 .port_disable = ata_port_disable, 154 .port_disable = ata_port_disable,
155 .dev_config = sil_dev_config, 155 .dev_config = sil_dev_config,
156 .tf_load = ata_tf_load, 156 .tf_load = ata_tf_load,
@@ -289,7 +289,7 @@ static inline unsigned long sil_scr_addr(struct ata_port *ap, unsigned int sc_re
289 289
290static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg) 290static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
291{ 291{
292 void *mmio = (void *) sil_scr_addr(ap, sc_reg); 292 void __iomem *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
293 if (mmio) 293 if (mmio)
294 return readl(mmio); 294 return readl(mmio);
295 return 0xffffffffU; 295 return 0xffffffffU;
@@ -297,7 +297,7 @@ static u32 sil_scr_read (struct ata_port *ap, unsigned int sc_reg)
297 297
298static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val) 298static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
299{ 299{
300 void *mmio = (void *) sil_scr_addr(ap, sc_reg); 300 void *mmio = (void __iomem *) sil_scr_addr(ap, sc_reg);
301 if (mmio) 301 if (mmio)
302 writel(val, mmio); 302 writel(val, mmio);
303} 303}
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
new file mode 100644
index 000000000000..32d730bd5bb6
--- /dev/null
+++ b/drivers/scsi/sata_sil24.c
@@ -0,0 +1,875 @@
1/*
2 * sata_sil24.c - Driver for Silicon Image 3124/3132 SATA-2 controllers
3 *
4 * Copyright 2005 Tejun Heo
5 *
6 * Based on preview driver from Silicon Image.
7 *
8 * NOTE: No NCQ/ATAPI support yet. The preview driver didn't support
9 * NCQ nor ATAPI, and, unfortunately, I couldn't find out how to make
10 * those work. Enabling those shouldn't be difficult. Basic
11 * structure is all there (in libata-dev tree). If you have any
12 * information about this hardware, please contact me or linux-ide.
13 * Info is needed on...
14 *
15 * - How to issue tagged commands and turn on sactive on issue accordingly.
16 * - Where to put an ATAPI command and how to tell the device to send it.
17 * - How to enable/use 64bit.
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2, or (at your option) any
22 * later version.
23 *
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.
28 *
29 */
30
31#include <linux/kernel.h>
32#include <linux/module.h>
33#include <linux/pci.h>
34#include <linux/blkdev.h>
35#include <linux/delay.h>
36#include <linux/interrupt.h>
37#include <linux/dma-mapping.h>
38#include <scsi/scsi_host.h>
39#include "scsi.h"
40#include <linux/libata.h>
41#include <asm/io.h>
42
43#define DRV_NAME "sata_sil24"
44#define DRV_VERSION "0.22" /* Silicon Image's preview driver was 0.10 */
45
46/*
47 * Port request block (PRB) 32 bytes
48 */
49struct sil24_prb {
50 u16 ctrl;
51 u16 prot;
52 u32 rx_cnt;
53 u8 fis[6 * 4];
54};
55
56/*
57 * Scatter gather entry (SGE) 16 bytes
58 */
59struct sil24_sge {
60 u64 addr;
61 u32 cnt;
62 u32 flags;
63};
64
65/*
66 * Port multiplier
67 */
68struct sil24_port_multiplier {
69 u32 diag;
70 u32 sactive;
71};
72
73enum {
74 /*
75 * Global controller registers (128 bytes @ BAR0)
76 */
77 /* 32 bit regs */
78 HOST_SLOT_STAT = 0x00, /* 32 bit slot stat * 4 */
79 HOST_CTRL = 0x40,
80 HOST_IRQ_STAT = 0x44,
81 HOST_PHY_CFG = 0x48,
82 HOST_BIST_CTRL = 0x50,
83 HOST_BIST_PTRN = 0x54,
84 HOST_BIST_STAT = 0x58,
85 HOST_MEM_BIST_STAT = 0x5c,
86 HOST_FLASH_CMD = 0x70,
87 /* 8 bit regs */
88 HOST_FLASH_DATA = 0x74,
89 HOST_TRANSITION_DETECT = 0x75,
90 HOST_GPIO_CTRL = 0x76,
91 HOST_I2C_ADDR = 0x78, /* 32 bit */
92 HOST_I2C_DATA = 0x7c,
93 HOST_I2C_XFER_CNT = 0x7e,
94 HOST_I2C_CTRL = 0x7f,
95
96 /* HOST_SLOT_STAT bits */
97 HOST_SSTAT_ATTN = (1 << 31),
98
99 /*
100 * Port registers
101 * (8192 bytes @ +0x0000, +0x2000, +0x4000 and +0x6000 @ BAR2)
102 */
103 PORT_REGS_SIZE = 0x2000,
104 PORT_PRB = 0x0000, /* (32 bytes PRB + 16 bytes SGEs * 6) * 31 (3968 bytes) */
105
106 PORT_PM = 0x0f80, /* 8 bytes PM * 16 (128 bytes) */
107 /* 32 bit regs */
108 PORT_CTRL_STAT = 0x1000, /* write: ctrl-set, read: stat */
109 PORT_CTRL_CLR = 0x1004, /* write: ctrl-clear */
110 PORT_IRQ_STAT = 0x1008, /* high: status, low: interrupt */
111 PORT_IRQ_ENABLE_SET = 0x1010, /* write: enable-set */
112 PORT_IRQ_ENABLE_CLR = 0x1014, /* write: enable-clear */
113 PORT_ACTIVATE_UPPER_ADDR= 0x101c,
114 PORT_EXEC_FIFO = 0x1020, /* command execution fifo */
115 PORT_CMD_ERR = 0x1024, /* command error number */
116 PORT_FIS_CFG = 0x1028,
117 PORT_FIFO_THRES = 0x102c,
118 /* 16 bit regs */
119 PORT_DECODE_ERR_CNT = 0x1040,
120 PORT_DECODE_ERR_THRESH = 0x1042,
121 PORT_CRC_ERR_CNT = 0x1044,
122 PORT_CRC_ERR_THRESH = 0x1046,
123 PORT_HSHK_ERR_CNT = 0x1048,
124 PORT_HSHK_ERR_THRESH = 0x104a,
125 /* 32 bit regs */
126 PORT_PHY_CFG = 0x1050,
127 PORT_SLOT_STAT = 0x1800,
128 PORT_CMD_ACTIVATE = 0x1c00, /* 64 bit cmd activate * 31 (248 bytes) */
129 PORT_EXEC_DIAG = 0x1e00, /* 32bit exec diag * 16 (64 bytes, 0-10 used on 3124) */
130 PORT_PSD_DIAG = 0x1e40, /* 32bit psd diag * 16 (64 bytes, 0-8 used on 3124) */
131 PORT_SCONTROL = 0x1f00,
132 PORT_SSTATUS = 0x1f04,
133 PORT_SERROR = 0x1f08,
134 PORT_SACTIVE = 0x1f0c,
135
136 /* PORT_CTRL_STAT bits */
137 PORT_CS_PORT_RST = (1 << 0), /* port reset */
138 PORT_CS_DEV_RST = (1 << 1), /* device reset */
139 PORT_CS_INIT = (1 << 2), /* port initialize */
140 PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */
141 PORT_CS_RESUME = (1 << 6), /* port resume */
142 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */
143 PORT_CS_PM_EN = (1 << 13), /* port multiplier enable */
144 PORT_CS_RDY = (1 << 31), /* port ready to accept commands */
145
146 /* PORT_IRQ_STAT/ENABLE_SET/CLR */
147 /* bits[11:0] are masked */
148 PORT_IRQ_COMPLETE = (1 << 0), /* command(s) completed */
149 PORT_IRQ_ERROR = (1 << 1), /* command execution error */
150 PORT_IRQ_PORTRDY_CHG = (1 << 2), /* port ready change */
151 PORT_IRQ_PWR_CHG = (1 << 3), /* power management change */
152 PORT_IRQ_PHYRDY_CHG = (1 << 4), /* PHY ready change */
153 PORT_IRQ_COMWAKE = (1 << 5), /* COMWAKE received */
154 PORT_IRQ_UNK_FIS = (1 << 6), /* Unknown FIS received */
155 PORT_IRQ_SDB_FIS = (1 << 11), /* SDB FIS received */
156
157 /* bits[27:16] are unmasked (raw) */
158 PORT_IRQ_RAW_SHIFT = 16,
159 PORT_IRQ_MASKED_MASK = 0x7ff,
160 PORT_IRQ_RAW_MASK = (0x7ff << PORT_IRQ_RAW_SHIFT),
161
162 /* ENABLE_SET/CLR specific, intr steering - 2 bit field */
163 PORT_IRQ_STEER_SHIFT = 30,
164 PORT_IRQ_STEER_MASK = (3 << PORT_IRQ_STEER_SHIFT),
165
166 /* PORT_CMD_ERR constants */
167 PORT_CERR_DEV = 1, /* Error bit in D2H Register FIS */
168 PORT_CERR_SDB = 2, /* Error bit in SDB FIS */
169 PORT_CERR_DATA = 3, /* Error in data FIS not detected by dev */
170 PORT_CERR_SEND = 4, /* Initial cmd FIS transmission failure */
171 PORT_CERR_INCONSISTENT = 5, /* Protocol mismatch */
172 PORT_CERR_DIRECTION = 6, /* Data direction mismatch */
173 PORT_CERR_UNDERRUN = 7, /* Ran out of SGEs while writing */
174 PORT_CERR_OVERRUN = 8, /* Ran out of SGEs while reading */
175 PORT_CERR_PKT_PROT = 11, /* DIR invalid in 1st PIO setup of ATAPI */
176 PORT_CERR_SGT_BOUNDARY = 16, /* PLD ecode 00 - SGT not on qword boundary */
177 PORT_CERR_SGT_TGTABRT = 17, /* PLD ecode 01 - target abort */
178 PORT_CERR_SGT_MSTABRT = 18, /* PLD ecode 10 - master abort */
179 PORT_CERR_SGT_PCIPERR = 19, /* PLD ecode 11 - PCI parity err while fetching SGT */
180 PORT_CERR_CMD_BOUNDARY = 24, /* ctrl[15:13] 001 - PRB not on qword boundary */
181 PORT_CERR_CMD_TGTABRT = 25, /* ctrl[15:13] 010 - target abort */
182 PORT_CERR_CMD_MSTABRT = 26, /* ctrl[15:13] 100 - master abort */
183 PORT_CERR_CMD_PCIPERR = 27, /* ctrl[15:13] 110 - PCI parity err while fetching PRB */
184 PORT_CERR_XFR_UNDEF = 32, /* PSD ecode 00 - undefined */
185 PORT_CERR_XFR_TGTABRT = 33, /* PSD ecode 01 - target abort */
186 PORT_CERR_XFR_MSGABRT = 34, /* PSD ecode 10 - master abort */
187 PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */
188 PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */
189
190 /*
191 * Other constants
192 */
193 SGE_TRM = (1 << 31), /* Last SGE in chain */
194 PRB_SOFT_RST = (1 << 7), /* Soft reset request (ign BSY?) */
195
196 /* board id */
197 BID_SIL3124 = 0,
198 BID_SIL3132 = 1,
199 BID_SIL3131 = 2,
200
201 IRQ_STAT_4PORTS = 0xf,
202};
203
204struct sil24_cmd_block {
205 struct sil24_prb prb;
206 struct sil24_sge sge[LIBATA_MAX_PRD];
207};
208
209/*
210 * ap->private_data
211 *
212 * The preview driver always returned 0 for status. We emulate it
213 * here from the previous interrupt.
214 */
215struct sil24_port_priv {
216 struct sil24_cmd_block *cmd_block; /* 32 cmd blocks */
217 dma_addr_t cmd_block_dma; /* DMA base addr for them */
218 struct ata_taskfile tf; /* Cached taskfile registers */
219};
220
221/* ap->host_set->private_data */
222struct sil24_host_priv {
223 void *host_base; /* global controller control (128 bytes @BAR0) */
224 void *port_base; /* port registers (4 * 8192 bytes @BAR2) */
225};
226
227static u8 sil24_check_status(struct ata_port *ap);
228static u8 sil24_check_err(struct ata_port *ap);
229static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
230static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val);
231static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
232static void sil24_phy_reset(struct ata_port *ap);
233static void sil24_qc_prep(struct ata_queued_cmd *qc);
234static int sil24_qc_issue(struct ata_queued_cmd *qc);
235static void sil24_irq_clear(struct ata_port *ap);
236static void sil24_eng_timeout(struct ata_port *ap);
237static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
238static int sil24_port_start(struct ata_port *ap);
239static void sil24_port_stop(struct ata_port *ap);
240static void sil24_host_stop(struct ata_host_set *host_set);
241static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
242
243static struct pci_device_id sil24_pci_tbl[] = {
244 { 0x1095, 0x3124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3124 },
245 { 0x1095, 0x3132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3132 },
246 { 0x1095, 0x3131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3131 },
247 { 0x1095, 0x3531, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3131 },
248 { } /* terminate list */
249};
250
251static struct pci_driver sil24_pci_driver = {
252 .name = DRV_NAME,
253 .id_table = sil24_pci_tbl,
254 .probe = sil24_init_one,
255 .remove = ata_pci_remove_one, /* safe? */
256};
257
258static Scsi_Host_Template sil24_sht = {
259 .module = THIS_MODULE,
260 .name = DRV_NAME,
261 .ioctl = ata_scsi_ioctl,
262 .queuecommand = ata_scsi_queuecmd,
263 .eh_strategy_handler = ata_scsi_error,
264 .can_queue = ATA_DEF_QUEUE,
265 .this_id = ATA_SHT_THIS_ID,
266 .sg_tablesize = LIBATA_MAX_PRD,
267 .max_sectors = ATA_MAX_SECTORS,
268 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
269 .emulated = ATA_SHT_EMULATED,
270 .use_clustering = ATA_SHT_USE_CLUSTERING,
271 .proc_name = DRV_NAME,
272 .dma_boundary = ATA_DMA_BOUNDARY,
273 .slave_configure = ata_scsi_slave_config,
274 .bios_param = ata_std_bios_param,
275 .ordered_flush = 1, /* NCQ not supported yet */
276};
277
278static const struct ata_port_operations sil24_ops = {
279 .port_disable = ata_port_disable,
280
281 .check_status = sil24_check_status,
282 .check_altstatus = sil24_check_status,
283 .check_err = sil24_check_err,
284 .dev_select = ata_noop_dev_select,
285
286 .tf_read = sil24_tf_read,
287
288 .phy_reset = sil24_phy_reset,
289
290 .qc_prep = sil24_qc_prep,
291 .qc_issue = sil24_qc_issue,
292
293 .eng_timeout = sil24_eng_timeout,
294
295 .irq_handler = sil24_interrupt,
296 .irq_clear = sil24_irq_clear,
297
298 .scr_read = sil24_scr_read,
299 .scr_write = sil24_scr_write,
300
301 .port_start = sil24_port_start,
302 .port_stop = sil24_port_stop,
303 .host_stop = sil24_host_stop,
304};
305
306/*
307 * Use bits 30-31 of host_flags to encode available port numbers.
308 * Current maxium is 4.
309 */
310#define SIL24_NPORTS2FLAG(nports) ((((unsigned)(nports) - 1) & 0x3) << 30)
311#define SIL24_FLAG2NPORTS(flag) ((((flag) >> 30) & 0x3) + 1)
312
313static struct ata_port_info sil24_port_info[] = {
314 /* sil_3124 */
315 {
316 .sht = &sil24_sht,
317 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
318 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
319 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(4),
320 .pio_mask = 0x1f, /* pio0-4 */
321 .mwdma_mask = 0x07, /* mwdma0-2 */
322 .udma_mask = 0x3f, /* udma0-5 */
323 .port_ops = &sil24_ops,
324 },
325 /* sil_3132 */
326 {
327 .sht = &sil24_sht,
328 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
329 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
330 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(2),
331 .pio_mask = 0x1f, /* pio0-4 */
332 .mwdma_mask = 0x07, /* mwdma0-2 */
333 .udma_mask = 0x3f, /* udma0-5 */
334 .port_ops = &sil24_ops,
335 },
336 /* sil_3131/sil_3531 */
337 {
338 .sht = &sil24_sht,
339 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
340 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
341 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(1),
342 .pio_mask = 0x1f, /* pio0-4 */
343 .mwdma_mask = 0x07, /* mwdma0-2 */
344 .udma_mask = 0x3f, /* udma0-5 */
345 .port_ops = &sil24_ops,
346 },
347};
348
349static inline void sil24_update_tf(struct ata_port *ap)
350{
351 struct sil24_port_priv *pp = ap->private_data;
352 void *port = (void *)ap->ioaddr.cmd_addr;
353 struct sil24_prb *prb = port;
354
355 ata_tf_from_fis(prb->fis, &pp->tf);
356}
357
358static u8 sil24_check_status(struct ata_port *ap)
359{
360 struct sil24_port_priv *pp = ap->private_data;
361 return pp->tf.command;
362}
363
364static u8 sil24_check_err(struct ata_port *ap)
365{
366 struct sil24_port_priv *pp = ap->private_data;
367 return pp->tf.feature;
368}
369
370static int sil24_scr_map[] = {
371 [SCR_CONTROL] = 0,
372 [SCR_STATUS] = 1,
373 [SCR_ERROR] = 2,
374 [SCR_ACTIVE] = 3,
375};
376
377static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
378{
379 void *scr_addr = (void *)ap->ioaddr.scr_addr;
380 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
381 void *addr;
382 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
383 return readl(scr_addr + sil24_scr_map[sc_reg] * 4);
384 }
385 return 0xffffffffU;
386}
387
388static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
389{
390 void *scr_addr = (void *)ap->ioaddr.scr_addr;
391 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
392 void *addr;
393 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
394 writel(val, scr_addr + sil24_scr_map[sc_reg] * 4);
395 }
396}
397
398static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
399{
400 struct sil24_port_priv *pp = ap->private_data;
401 *tf = pp->tf;
402}
403
404static void sil24_phy_reset(struct ata_port *ap)
405{
406 __sata_phy_reset(ap);
407 /*
408 * No ATAPI yet. Just unconditionally indicate ATA device.
409 * If ATAPI device is attached, it will fail ATA_CMD_ID_ATA
410 * and libata core will ignore the device.
411 */
412 if (!(ap->flags & ATA_FLAG_PORT_DISABLED))
413 ap->device[0].class = ATA_DEV_ATA;
414}
415
416static inline void sil24_fill_sg(struct ata_queued_cmd *qc,
417 struct sil24_cmd_block *cb)
418{
419 struct scatterlist *sg = qc->sg;
420 struct sil24_sge *sge = cb->sge;
421 unsigned i;
422
423 for (i = 0; i < qc->n_elem; i++, sg++, sge++) {
424 sge->addr = cpu_to_le64(sg_dma_address(sg));
425 sge->cnt = cpu_to_le32(sg_dma_len(sg));
426 sge->flags = 0;
427 sge->flags = i < qc->n_elem - 1 ? 0 : cpu_to_le32(SGE_TRM);
428 }
429}
430
431static void sil24_qc_prep(struct ata_queued_cmd *qc)
432{
433 struct ata_port *ap = qc->ap;
434 struct sil24_port_priv *pp = ap->private_data;
435 struct sil24_cmd_block *cb = pp->cmd_block + qc->tag;
436 struct sil24_prb *prb = &cb->prb;
437
438 switch (qc->tf.protocol) {
439 case ATA_PROT_PIO:
440 case ATA_PROT_DMA:
441 case ATA_PROT_NODATA:
442 break;
443 default:
444 /* ATAPI isn't supported yet */
445 BUG();
446 }
447
448 ata_tf_to_fis(&qc->tf, prb->fis, 0);
449
450 if (qc->flags & ATA_QCFLAG_DMAMAP)
451 sil24_fill_sg(qc, cb);
452}
453
454static int sil24_qc_issue(struct ata_queued_cmd *qc)
455{
456 struct ata_port *ap = qc->ap;
457 void *port = (void *)ap->ioaddr.cmd_addr;
458 struct sil24_port_priv *pp = ap->private_data;
459 dma_addr_t paddr = pp->cmd_block_dma + qc->tag * sizeof(*pp->cmd_block);
460
461 writel((u32)paddr, port + PORT_CMD_ACTIVATE);
462 return 0;
463}
464
465static void sil24_irq_clear(struct ata_port *ap)
466{
467 /* unused */
468}
469
470static int __sil24_reset_controller(void *port)
471{
472 int cnt;
473 u32 tmp;
474
475 /* Reset controller state. Is this correct? */
476 writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT);
477 readl(port + PORT_CTRL_STAT); /* sync */
478
479 /* Max ~100ms */
480 for (cnt = 0; cnt < 1000; cnt++) {
481 udelay(100);
482 tmp = readl(port + PORT_CTRL_STAT);
483 if (!(tmp & PORT_CS_DEV_RST))
484 break;
485 }
486
487 if (tmp & PORT_CS_DEV_RST)
488 return -1;
489 return 0;
490}
491
492static void sil24_reset_controller(struct ata_port *ap)
493{
494 printk(KERN_NOTICE DRV_NAME
495 " ata%u: resetting controller...\n", ap->id);
496 if (__sil24_reset_controller((void *)ap->ioaddr.cmd_addr))
497 printk(KERN_ERR DRV_NAME
498 " ata%u: failed to reset controller\n", ap->id);
499}
500
501static void sil24_eng_timeout(struct ata_port *ap)
502{
503 struct ata_queued_cmd *qc;
504
505 qc = ata_qc_from_tag(ap, ap->active_tag);
506 if (!qc) {
507 printk(KERN_ERR "ata%u: BUG: tiemout without command\n",
508 ap->id);
509 return;
510 }
511
512 /*
513 * hack alert! We cannot use the supplied completion
514 * function from inside the ->eh_strategy_handler() thread.
515 * libata is the only user of ->eh_strategy_handler() in
516 * any kernel, so the default scsi_done() assumes it is
517 * not being called from the SCSI EH.
518 */
519 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
520 qc->scsidone = scsi_finish_command;
521 ata_qc_complete(qc, ATA_ERR);
522
523 sil24_reset_controller(ap);
524}
525
526static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
527{
528 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
529 struct sil24_port_priv *pp = ap->private_data;
530 void *port = (void *)ap->ioaddr.cmd_addr;
531 u32 irq_stat, cmd_err, sstatus, serror;
532
533 irq_stat = readl(port + PORT_IRQ_STAT);
534 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */
535
536 if (!(irq_stat & PORT_IRQ_ERROR)) {
537 /* ignore non-completion, non-error irqs for now */
538 printk(KERN_WARNING DRV_NAME
539 "ata%u: non-error exception irq (irq_stat %x)\n",
540 ap->id, irq_stat);
541 return;
542 }
543
544 cmd_err = readl(port + PORT_CMD_ERR);
545 sstatus = readl(port + PORT_SSTATUS);
546 serror = readl(port + PORT_SERROR);
547 if (serror)
548 writel(serror, port + PORT_SERROR);
549
550 printk(KERN_ERR DRV_NAME " ata%u: error interrupt on port%d\n"
551 " stat=0x%x irq=0x%x cmd_err=%d sstatus=0x%x serror=0x%x\n",
552 ap->id, ap->port_no, slot_stat, irq_stat, cmd_err, sstatus, serror);
553
554 if (cmd_err == PORT_CERR_DEV || cmd_err == PORT_CERR_SDB) {
555 /*
556 * Device is reporting error, tf registers are valid.
557 */
558 sil24_update_tf(ap);
559 } else {
560 /*
561 * Other errors. libata currently doesn't have any
562 * mechanism to report these errors. Just turn on
563 * ATA_ERR.
564 */
565 pp->tf.command = ATA_ERR;
566 }
567
568 if (qc)
569 ata_qc_complete(qc, pp->tf.command);
570
571 sil24_reset_controller(ap);
572}
573
574static inline void sil24_host_intr(struct ata_port *ap)
575{
576 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->active_tag);
577 void *port = (void *)ap->ioaddr.cmd_addr;
578 u32 slot_stat;
579
580 slot_stat = readl(port + PORT_SLOT_STAT);
581 if (!(slot_stat & HOST_SSTAT_ATTN)) {
582 struct sil24_port_priv *pp = ap->private_data;
583 /*
584 * !HOST_SSAT_ATTN guarantees successful completion,
585 * so reading back tf registers is unnecessary for
586 * most commands. TODO: read tf registers for
587 * commands which require these values on successful
588 * completion (EXECUTE DEVICE DIAGNOSTIC, CHECK POWER,
589 * DEVICE RESET and READ PORT MULTIPLIER (any more?).
590 */
591 sil24_update_tf(ap);
592
593 if (qc)
594 ata_qc_complete(qc, pp->tf.command);
595 } else
596 sil24_error_intr(ap, slot_stat);
597}
598
599static irqreturn_t sil24_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
600{
601 struct ata_host_set *host_set = dev_instance;
602 struct sil24_host_priv *hpriv = host_set->private_data;
603 unsigned handled = 0;
604 u32 status;
605 int i;
606
607 status = readl(hpriv->host_base + HOST_IRQ_STAT);
608
609 if (status == 0xffffffff) {
610 printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, "
611 "PCI fault or device removal?\n");
612 goto out;
613 }
614
615 if (!(status & IRQ_STAT_4PORTS))
616 goto out;
617
618 spin_lock(&host_set->lock);
619
620 for (i = 0; i < host_set->n_ports; i++)
621 if (status & (1 << i)) {
622 struct ata_port *ap = host_set->ports[i];
623 if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
624 sil24_host_intr(host_set->ports[i]);
625 handled++;
626 } else
627 printk(KERN_ERR DRV_NAME
628 ": interrupt from disabled port %d\n", i);
629 }
630
631 spin_unlock(&host_set->lock);
632 out:
633 return IRQ_RETVAL(handled);
634}
635
636static int sil24_port_start(struct ata_port *ap)
637{
638 struct device *dev = ap->host_set->dev;
639 struct sil24_port_priv *pp;
640 struct sil24_cmd_block *cb;
641 size_t cb_size = sizeof(*cb);
642 dma_addr_t cb_dma;
643
644 pp = kmalloc(sizeof(*pp), GFP_KERNEL);
645 if (!pp)
646 return -ENOMEM;
647 memset(pp, 0, sizeof(*pp));
648
649 pp->tf.command = ATA_DRDY;
650
651 cb = dma_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL);
652 if (!cb) {
653 kfree(pp);
654 return -ENOMEM;
655 }
656 memset(cb, 0, cb_size);
657
658 pp->cmd_block = cb;
659 pp->cmd_block_dma = cb_dma;
660
661 ap->private_data = pp;
662
663 return 0;
664}
665
666static void sil24_port_stop(struct ata_port *ap)
667{
668 struct device *dev = ap->host_set->dev;
669 struct sil24_port_priv *pp = ap->private_data;
670 size_t cb_size = sizeof(*pp->cmd_block);
671
672 dma_free_coherent(dev, cb_size, pp->cmd_block, pp->cmd_block_dma);
673 kfree(pp);
674}
675
676static void sil24_host_stop(struct ata_host_set *host_set)
677{
678 struct sil24_host_priv *hpriv = host_set->private_data;
679
680 iounmap(hpriv->host_base);
681 iounmap(hpriv->port_base);
682 kfree(hpriv);
683}
684
685static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
686{
687 static int printed_version = 0;
688 unsigned int board_id = (unsigned int)ent->driver_data;
689 struct ata_port_info *pinfo = &sil24_port_info[board_id];
690 struct ata_probe_ent *probe_ent = NULL;
691 struct sil24_host_priv *hpriv = NULL;
692 void *host_base = NULL, *port_base = NULL;
693 int i, rc;
694
695 if (!printed_version++)
696 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
697
698 rc = pci_enable_device(pdev);
699 if (rc)
700 return rc;
701
702 rc = pci_request_regions(pdev, DRV_NAME);
703 if (rc)
704 goto out_disable;
705
706 rc = -ENOMEM;
707 /* ioremap mmio registers */
708 host_base = ioremap(pci_resource_start(pdev, 0),
709 pci_resource_len(pdev, 0));
710 if (!host_base)
711 goto out_free;
712 port_base = ioremap(pci_resource_start(pdev, 2),
713 pci_resource_len(pdev, 2));
714 if (!port_base)
715 goto out_free;
716
717 /* allocate & init probe_ent and hpriv */
718 probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
719 if (!probe_ent)
720 goto out_free;
721
722 hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
723 if (!hpriv)
724 goto out_free;
725
726 memset(probe_ent, 0, sizeof(*probe_ent));
727 probe_ent->dev = pci_dev_to_dev(pdev);
728 INIT_LIST_HEAD(&probe_ent->node);
729
730 probe_ent->sht = pinfo->sht;
731 probe_ent->host_flags = pinfo->host_flags;
732 probe_ent->pio_mask = pinfo->pio_mask;
733 probe_ent->udma_mask = pinfo->udma_mask;
734 probe_ent->port_ops = pinfo->port_ops;
735 probe_ent->n_ports = SIL24_FLAG2NPORTS(pinfo->host_flags);
736
737 probe_ent->irq = pdev->irq;
738 probe_ent->irq_flags = SA_SHIRQ;
739 probe_ent->mmio_base = port_base;
740 probe_ent->private_data = hpriv;
741
742 memset(hpriv, 0, sizeof(*hpriv));
743 hpriv->host_base = host_base;
744 hpriv->port_base = port_base;
745
746 /*
747 * Configure the device
748 */
749 /*
750 * FIXME: This device is certainly 64-bit capable. We just
751 * don't know how to use it. After fixing 32bit activation in
752 * this function, enable 64bit masks here.
753 */
754 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
755 if (rc) {
756 printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n",
757 pci_name(pdev));
758 goto out_free;
759 }
760 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
761 if (rc) {
762 printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n",
763 pci_name(pdev));
764 goto out_free;
765 }
766
767 /* GPIO off */
768 writel(0, host_base + HOST_FLASH_CMD);
769
770 /* Mask interrupts during initialization */
771 writel(0, host_base + HOST_CTRL);
772
773 for (i = 0; i < probe_ent->n_ports; i++) {
774 void *port = port_base + i * PORT_REGS_SIZE;
775 unsigned long portu = (unsigned long)port;
776 u32 tmp;
777 int cnt;
778
779 probe_ent->port[i].cmd_addr = portu + PORT_PRB;
780 probe_ent->port[i].scr_addr = portu + PORT_SCONTROL;
781
782 ata_std_ports(&probe_ent->port[i]);
783
784 /* Initial PHY setting */
785 writel(0x20c, port + PORT_PHY_CFG);
786
787 /* Clear port RST */
788 tmp = readl(port + PORT_CTRL_STAT);
789 if (tmp & PORT_CS_PORT_RST) {
790 writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR);
791 readl(port + PORT_CTRL_STAT); /* sync */
792 for (cnt = 0; cnt < 10; cnt++) {
793 msleep(10);
794 tmp = readl(port + PORT_CTRL_STAT);
795 if (!(tmp & PORT_CS_PORT_RST))
796 break;
797 }
798 if (tmp & PORT_CS_PORT_RST)
799 printk(KERN_ERR DRV_NAME
800 "(%s): failed to clear port RST\n",
801 pci_name(pdev));
802 }
803
804 /* Zero error counters. */
805 writel(0x8000, port + PORT_DECODE_ERR_THRESH);
806 writel(0x8000, port + PORT_CRC_ERR_THRESH);
807 writel(0x8000, port + PORT_HSHK_ERR_THRESH);
808 writel(0x0000, port + PORT_DECODE_ERR_CNT);
809 writel(0x0000, port + PORT_CRC_ERR_CNT);
810 writel(0x0000, port + PORT_HSHK_ERR_CNT);
811
812 /* FIXME: 32bit activation? */
813 writel(0, port + PORT_ACTIVATE_UPPER_ADDR);
814 writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_STAT);
815
816 /* Configure interrupts */
817 writel(0xffff, port + PORT_IRQ_ENABLE_CLR);
818 writel(PORT_IRQ_COMPLETE | PORT_IRQ_ERROR | PORT_IRQ_SDB_FIS,
819 port + PORT_IRQ_ENABLE_SET);
820
821 /* Clear interrupts */
822 writel(0x0fff0fff, port + PORT_IRQ_STAT);
823 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR);
824
825 /* Clear port multiplier enable and resume bits */
826 writel(PORT_CS_PM_EN | PORT_CS_RESUME, port + PORT_CTRL_CLR);
827
828 /* Reset itself */
829 if (__sil24_reset_controller(port))
830 printk(KERN_ERR DRV_NAME
831 "(%s): failed to reset controller\n",
832 pci_name(pdev));
833 }
834
835 /* Turn on interrupts */
836 writel(IRQ_STAT_4PORTS, host_base + HOST_CTRL);
837
838 pci_set_master(pdev);
839
840 /* FIXME: check ata_device_add return value */
841 ata_device_add(probe_ent);
842
843 kfree(probe_ent);
844 return 0;
845
846 out_free:
847 if (host_base)
848 iounmap(host_base);
849 if (port_base)
850 iounmap(port_base);
851 kfree(probe_ent);
852 kfree(hpriv);
853 pci_release_regions(pdev);
854 out_disable:
855 pci_disable_device(pdev);
856 return rc;
857}
858
859static int __init sil24_init(void)
860{
861 return pci_module_init(&sil24_pci_driver);
862}
863
864static void __exit sil24_exit(void)
865{
866 pci_unregister_driver(&sil24_pci_driver);
867}
868
869MODULE_AUTHOR("Tejun Heo");
870MODULE_DESCRIPTION("Silicon Image 3124/3132 SATA low-level driver");
871MODULE_LICENSE("GPL");
872MODULE_DEVICE_TABLE(pci, sil24_pci_tbl);
873
874module_init(sil24_init);
875module_exit(sil24_exit);
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index b227e51d12f4..057f7b98b6c4 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -102,7 +102,7 @@ static Scsi_Host_Template sis_sht = {
102 .ordered_flush = 1, 102 .ordered_flush = 1,
103}; 103};
104 104
105static struct ata_port_operations sis_ops = { 105static const struct ata_port_operations sis_ops = {
106 .port_disable = ata_port_disable, 106 .port_disable = ata_port_disable,
107 .tf_load = ata_tf_load, 107 .tf_load = ata_tf_load,
108 .tf_read = ata_tf_read, 108 .tf_read = ata_tf_read,
@@ -263,7 +263,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
263 goto err_out_regions; 263 goto err_out_regions;
264 264
265 ppi = &sis_port_info; 265 ppi = &sis_port_info;
266 probe_ent = ata_pci_init_native_mode(pdev, &ppi); 266 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
267 if (!probe_ent) { 267 if (!probe_ent) {
268 rc = -ENOMEM; 268 rc = -ENOMEM;
269 goto err_out_regions; 269 goto err_out_regions;
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index d89d968bedac..e0f9570bc6dd 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -102,7 +102,7 @@ static void k2_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
102} 102}
103 103
104 104
105static void k2_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 105static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
106{ 106{
107 struct ata_ioports *ioaddr = &ap->ioaddr; 107 struct ata_ioports *ioaddr = &ap->ioaddr;
108 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 108 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -297,7 +297,7 @@ static Scsi_Host_Template k2_sata_sht = {
297}; 297};
298 298
299 299
300static struct ata_port_operations k2_sata_ops = { 300static const struct ata_port_operations k2_sata_ops = {
301 .port_disable = ata_port_disable, 301 .port_disable = ata_port_disable,
302 .tf_load = k2_sata_tf_load, 302 .tf_load = k2_sata_tf_load,
303 .tf_read = k2_sata_tf_read, 303 .tf_read = k2_sata_tf_read,
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index 540a85191172..af08f4f650c1 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -137,7 +137,7 @@ struct pdc_port_priv {
137}; 137};
138 138
139struct pdc_host_priv { 139struct pdc_host_priv {
140 void *dimm_mmio; 140 void __iomem *dimm_mmio;
141 141
142 unsigned int doing_hdma; 142 unsigned int doing_hdma;
143 unsigned int hdma_prod; 143 unsigned int hdma_prod;
@@ -157,8 +157,8 @@ static void pdc_20621_phy_reset (struct ata_port *ap);
157static int pdc_port_start(struct ata_port *ap); 157static int pdc_port_start(struct ata_port *ap);
158static void pdc_port_stop(struct ata_port *ap); 158static void pdc_port_stop(struct ata_port *ap);
159static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 159static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
160static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf); 160static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
161static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf); 161static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
162static void pdc20621_host_stop(struct ata_host_set *host_set); 162static void pdc20621_host_stop(struct ata_host_set *host_set);
163static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); 163static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
164static int pdc20621_detect_dimm(struct ata_probe_ent *pe); 164static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
@@ -196,7 +196,7 @@ static Scsi_Host_Template pdc_sata_sht = {
196 .ordered_flush = 1, 196 .ordered_flush = 1,
197}; 197};
198 198
199static struct ata_port_operations pdc_20621_ops = { 199static const struct ata_port_operations pdc_20621_ops = {
200 .port_disable = ata_port_disable, 200 .port_disable = ata_port_disable,
201 .tf_load = pdc_tf_load_mmio, 201 .tf_load = pdc_tf_load_mmio,
202 .tf_read = ata_tf_read, 202 .tf_read = ata_tf_read,
@@ -247,7 +247,7 @@ static void pdc20621_host_stop(struct ata_host_set *host_set)
247{ 247{
248 struct pci_dev *pdev = to_pci_dev(host_set->dev); 248 struct pci_dev *pdev = to_pci_dev(host_set->dev);
249 struct pdc_host_priv *hpriv = host_set->private_data; 249 struct pdc_host_priv *hpriv = host_set->private_data;
250 void *dimm_mmio = hpriv->dimm_mmio; 250 void __iomem *dimm_mmio = hpriv->dimm_mmio;
251 251
252 pci_iounmap(pdev, dimm_mmio); 252 pci_iounmap(pdev, dimm_mmio);
253 kfree(hpriv); 253 kfree(hpriv);
@@ -669,8 +669,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
669 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */ 669 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); /* flush */
670 670
671 writel(port_ofs + PDC_DIMM_ATA_PKT, 671 writel(port_ofs + PDC_DIMM_ATA_PKT,
672 (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 672 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
673 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 673 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
674 VPRINTK("submitted ofs 0x%x (%u), seq %u\n", 674 VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
675 port_ofs + PDC_DIMM_ATA_PKT, 675 port_ofs + PDC_DIMM_ATA_PKT,
676 port_ofs + PDC_DIMM_ATA_PKT, 676 port_ofs + PDC_DIMM_ATA_PKT,
@@ -747,8 +747,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
747 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4)); 747 writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
748 readl(mmio + PDC_20621_SEQCTL + (seq * 4)); 748 readl(mmio + PDC_20621_SEQCTL + (seq * 4));
749 writel(port_ofs + PDC_DIMM_ATA_PKT, 749 writel(port_ofs + PDC_DIMM_ATA_PKT,
750 (void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 750 (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
751 readl((void *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); 751 readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
752 } 752 }
753 753
754 /* step two - execute ATA command */ 754 /* step two - execute ATA command */
@@ -899,7 +899,7 @@ out:
899 DPRINTK("EXIT\n"); 899 DPRINTK("EXIT\n");
900} 900}
901 901
902static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf) 902static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
903{ 903{
904 WARN_ON (tf->protocol == ATA_PROT_DMA || 904 WARN_ON (tf->protocol == ATA_PROT_DMA ||
905 tf->protocol == ATA_PROT_NODATA); 905 tf->protocol == ATA_PROT_NODATA);
@@ -907,7 +907,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, struct ata_taskfile *tf)
907} 907}
908 908
909 909
910static void pdc_exec_command_mmio(struct ata_port *ap, struct ata_taskfile *tf) 910static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
911{ 911{
912 WARN_ON (tf->protocol == ATA_PROT_DMA || 912 WARN_ON (tf->protocol == ATA_PROT_DMA ||
913 tf->protocol == ATA_PROT_NODATA); 913 tf->protocol == ATA_PROT_NODATA);
@@ -1014,7 +1014,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1014 idx++; 1014 idx++;
1015 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size : 1015 dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size :
1016 (long) (window_size - offset); 1016 (long) (window_size - offset);
1017 memcpy_toio((char *) (dimm_mmio + offset / 4), (char *) psource, dist); 1017 memcpy_toio(dimm_mmio + offset / 4, psource, dist);
1018 writel(0x01, mmio + PDC_GENERAL_CTLR); 1018 writel(0x01, mmio + PDC_GENERAL_CTLR);
1019 readl(mmio + PDC_GENERAL_CTLR); 1019 readl(mmio + PDC_GENERAL_CTLR);
1020 1020
@@ -1023,8 +1023,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1023 for (; (long) size >= (long) window_size ;) { 1023 for (; (long) size >= (long) window_size ;) {
1024 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1024 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1025 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1025 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1026 memcpy_toio((char *) (dimm_mmio), (char *) psource, 1026 memcpy_toio(dimm_mmio, psource, window_size / 4);
1027 window_size / 4);
1028 writel(0x01, mmio + PDC_GENERAL_CTLR); 1027 writel(0x01, mmio + PDC_GENERAL_CTLR);
1029 readl(mmio + PDC_GENERAL_CTLR); 1028 readl(mmio + PDC_GENERAL_CTLR);
1030 psource += window_size; 1029 psource += window_size;
@@ -1035,7 +1034,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
1035 if (size) { 1034 if (size) {
1036 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR); 1035 writel(((idx) << page_mask), mmio + PDC_DIMM_WINDOW_CTLR);
1037 readl(mmio + PDC_DIMM_WINDOW_CTLR); 1036 readl(mmio + PDC_DIMM_WINDOW_CTLR);
1038 memcpy_toio((char *) (dimm_mmio), (char *) psource, size / 4); 1037 memcpy_toio(dimm_mmio, psource, size / 4);
1039 writel(0x01, mmio + PDC_GENERAL_CTLR); 1038 writel(0x01, mmio + PDC_GENERAL_CTLR);
1040 readl(mmio + PDC_GENERAL_CTLR); 1039 readl(mmio + PDC_GENERAL_CTLR);
1041 } 1040 }
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 4c9fb8b71be1..d68dc7d3422c 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -90,7 +90,7 @@ static Scsi_Host_Template uli_sht = {
90 .ordered_flush = 1, 90 .ordered_flush = 1,
91}; 91};
92 92
93static struct ata_port_operations uli_ops = { 93static const struct ata_port_operations uli_ops = {
94 .port_disable = ata_port_disable, 94 .port_disable = ata_port_disable,
95 95
96 .tf_load = ata_tf_load, 96 .tf_load = ata_tf_load,
@@ -202,7 +202,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
202 goto err_out_regions; 202 goto err_out_regions;
203 203
204 ppi = &uli_port_info; 204 ppi = &uli_port_info;
205 probe_ent = ata_pci_init_native_mode(pdev, &ppi); 205 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
206 if (!probe_ent) { 206 if (!probe_ent) {
207 rc = -ENOMEM; 207 rc = -ENOMEM;
208 goto err_out_regions; 208 goto err_out_regions;
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 128b996b07b7..80e291a909a9 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -109,7 +109,7 @@ static Scsi_Host_Template svia_sht = {
109 .ordered_flush = 1, 109 .ordered_flush = 1,
110}; 110};
111 111
112static struct ata_port_operations svia_sata_ops = { 112static const struct ata_port_operations svia_sata_ops = {
113 .port_disable = ata_port_disable, 113 .port_disable = ata_port_disable,
114 114
115 .tf_load = ata_tf_load, 115 .tf_load = ata_tf_load,
@@ -212,7 +212,7 @@ static struct ata_probe_ent *vt6420_init_probe_ent(struct pci_dev *pdev)
212 struct ata_probe_ent *probe_ent; 212 struct ata_probe_ent *probe_ent;
213 struct ata_port_info *ppi = &svia_port_info; 213 struct ata_port_info *ppi = &svia_port_info;
214 214
215 probe_ent = ata_pci_init_native_mode(pdev, &ppi); 215 probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
216 if (!probe_ent) 216 if (!probe_ent)
217 return NULL; 217 return NULL;
218 218
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index cf94e0158a8d..5af05fdf8544 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -86,7 +86,7 @@ static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
86{ 86{
87 if (sc_reg > SCR_CONTROL) 87 if (sc_reg > SCR_CONTROL)
88 return 0xffffffffU; 88 return 0xffffffffU;
89 return readl((void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 89 return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
90} 90}
91 91
92 92
@@ -95,16 +95,16 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg,
95{ 95{
96 if (sc_reg > SCR_CONTROL) 96 if (sc_reg > SCR_CONTROL)
97 return; 97 return;
98 writel(val, (void *) ap->ioaddr.scr_addr + (sc_reg * 4)); 98 writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4));
99} 99}
100 100
101 101
102static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) 102static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
103{ 103{
104 unsigned long mask_addr; 104 void __iomem *mask_addr;
105 u8 mask; 105 u8 mask;
106 106
107 mask_addr = (unsigned long) ap->host_set->mmio_base + 107 mask_addr = ap->host_set->mmio_base +
108 VSC_SATA_INT_MASK_OFFSET + ap->port_no; 108 VSC_SATA_INT_MASK_OFFSET + ap->port_no;
109 mask = readb(mask_addr); 109 mask = readb(mask_addr);
110 if (ctl & ATA_NIEN) 110 if (ctl & ATA_NIEN)
@@ -115,7 +115,7 @@ static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl)
115} 115}
116 116
117 117
118static void vsc_sata_tf_load(struct ata_port *ap, struct ata_taskfile *tf) 118static void vsc_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
119{ 119{
120 struct ata_ioports *ioaddr = &ap->ioaddr; 120 struct ata_ioports *ioaddr = &ap->ioaddr;
121 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 121 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
@@ -231,7 +231,7 @@ static Scsi_Host_Template vsc_sata_sht = {
231}; 231};
232 232
233 233
234static struct ata_port_operations vsc_sata_ops = { 234static const struct ata_port_operations vsc_sata_ops = {
235 .port_disable = ata_port_disable, 235 .port_disable = ata_port_disable,
236 .tf_load = vsc_sata_tf_load, 236 .tf_load = vsc_sata_tf_load,
237 .tf_read = vsc_sata_tf_read, 237 .tf_read = vsc_sata_tf_read,
@@ -283,7 +283,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
283 struct ata_probe_ent *probe_ent = NULL; 283 struct ata_probe_ent *probe_ent = NULL;
284 unsigned long base; 284 unsigned long base;
285 int pci_dev_busy = 0; 285 int pci_dev_busy = 0;
286 void *mmio_base; 286 void __iomem *mmio_base;
287 int rc; 287 int rc;
288 288
289 if (!printed_version++) 289 if (!printed_version++)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1f0ebabf6d47..a5711d545d71 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -130,7 +130,7 @@ EXPORT_SYMBOL(scsi_device_types);
130 * Returns: Pointer to request block. 130 * Returns: Pointer to request block.
131 */ 131 */
132struct scsi_request *scsi_allocate_request(struct scsi_device *sdev, 132struct scsi_request *scsi_allocate_request(struct scsi_device *sdev,
133 int gfp_mask) 133 gfp_t gfp_mask)
134{ 134{
135 const int offset = ALIGN(sizeof(struct scsi_request), 4); 135 const int offset = ALIGN(sizeof(struct scsi_request), 4);
136 const int size = offset + sizeof(struct request); 136 const int size = offset + sizeof(struct request);
@@ -196,7 +196,7 @@ struct scsi_host_cmd_pool {
196 unsigned int users; 196 unsigned int users;
197 char *name; 197 char *name;
198 unsigned int slab_flags; 198 unsigned int slab_flags;
199 unsigned int gfp_mask; 199 gfp_t gfp_mask;
200}; 200};
201 201
202static struct scsi_host_cmd_pool scsi_cmd_pool = { 202static struct scsi_host_cmd_pool scsi_cmd_pool = {
@@ -213,7 +213,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
213static DECLARE_MUTEX(host_cmd_pool_mutex); 213static DECLARE_MUTEX(host_cmd_pool_mutex);
214 214
215static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 215static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
216 int gfp_mask) 216 gfp_t gfp_mask)
217{ 217{
218 struct scsi_cmnd *cmd; 218 struct scsi_cmnd *cmd;
219 219
@@ -245,7 +245,7 @@ static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
245 * 245 *
246 * Returns: The allocated scsi command structure. 246 * Returns: The allocated scsi command structure.
247 */ 247 */
248struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, int gfp_mask) 248struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
249{ 249{
250 struct scsi_cmnd *cmd; 250 struct scsi_cmnd *cmd;
251 251
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index de7f98cc38fe..6a3f6aae8a97 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -205,7 +205,8 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
205 unsigned int inlen, outlen, cmdlen; 205 unsigned int inlen, outlen, cmdlen;
206 unsigned int needed, buf_needed; 206 unsigned int needed, buf_needed;
207 int timeout, retries, result; 207 int timeout, retries, result;
208 int data_direction, gfp_mask = GFP_KERNEL; 208 int data_direction;
209 gfp_t gfp_mask = GFP_KERNEL;
209 210
210 if (!sic) 211 if (!sic)
211 return -EINVAL; 212 return -EINVAL;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0074f28c37b2..3ff538809786 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -677,7 +677,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
677 return NULL; 677 return NULL;
678} 678}
679 679
680static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, int gfp_mask) 680static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
681{ 681{
682 struct scsi_host_sg_pool *sgp; 682 struct scsi_host_sg_pool *sgp;
683 struct scatterlist *sgl; 683 struct scatterlist *sgl;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ad94367df430..861e51375d70 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -104,8 +104,8 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF;
104 104
105#define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */ 105#define SG_DEV_ARR_LUMP 32 /* amount to over allocate sg_dev_arr by */
106 106
107static int sg_add(struct class_device *); 107static int sg_add(struct class_device *, struct class_interface *);
108static void sg_remove(struct class_device *); 108static void sg_remove(struct class_device *, struct class_interface *);
109 109
110static Scsi_Request *dummy_cmdp; /* only used for sizeof */ 110static Scsi_Request *dummy_cmdp; /* only used for sizeof */
111 111
@@ -1506,7 +1506,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1506} 1506}
1507 1507
1508static int 1508static int
1509sg_add(struct class_device *cl_dev) 1509sg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1510{ 1510{
1511 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1511 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
1512 struct gendisk *disk; 1512 struct gendisk *disk;
@@ -1550,7 +1550,7 @@ sg_add(struct class_device *cl_dev)
1550 if (sg_sysfs_valid) { 1550 if (sg_sysfs_valid) {
1551 struct class_device * sg_class_member; 1551 struct class_device * sg_class_member;
1552 1552
1553 sg_class_member = class_device_create(sg_sysfs_class, 1553 sg_class_member = class_device_create(sg_sysfs_class, NULL,
1554 MKDEV(SCSI_GENERIC_MAJOR, k), 1554 MKDEV(SCSI_GENERIC_MAJOR, k),
1555 cl_dev->dev, "%s", 1555 cl_dev->dev, "%s",
1556 disk->disk_name); 1556 disk->disk_name);
@@ -1582,7 +1582,7 @@ out:
1582} 1582}
1583 1583
1584static void 1584static void
1585sg_remove(struct class_device *cl_dev) 1585sg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1586{ 1586{
1587 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev); 1587 struct scsi_device *scsidp = to_scsi_device(cl_dev->dev);
1588 Sg_device *sdp = NULL; 1588 Sg_device *sdp = NULL;
@@ -2644,7 +2644,7 @@ static char *
2644sg_page_malloc(int rqSz, int lowDma, int *retSzp) 2644sg_page_malloc(int rqSz, int lowDma, int *retSzp)
2645{ 2645{
2646 char *resp = NULL; 2646 char *resp = NULL;
2647 int page_mask; 2647 gfp_t page_mask;
2648 int order, a_size; 2648 int order, a_size;
2649 int resSz = rqSz; 2649 int resSz = rqSz;
2650 2650
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index d001c046551b..5eb54d8019b4 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3577,7 +3577,8 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
3577static struct st_buffer * 3577static struct st_buffer *
3578 new_tape_buffer(int from_initialization, int need_dma, int max_sg) 3578 new_tape_buffer(int from_initialization, int need_dma, int max_sg)
3579{ 3579{
3580 int i, priority, got = 0, segs = 0; 3580 int i, got = 0, segs = 0;
3581 gfp_t priority;
3581 struct st_buffer *tb; 3582 struct st_buffer *tb;
3582 3583
3583 if (from_initialization) 3584 if (from_initialization)
@@ -3610,7 +3611,8 @@ static struct st_buffer *
3610/* Try to allocate enough space in the tape buffer */ 3611/* Try to allocate enough space in the tape buffer */
3611static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) 3612static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
3612{ 3613{
3613 int segs, nbr, max_segs, b_size, priority, order, got; 3614 int segs, nbr, max_segs, b_size, order, got;
3615 gfp_t priority;
3614 3616
3615 if (new_size <= STbuffer->buffer_size) 3617 if (new_size <= STbuffer->buffer_size)
3616 return 1; 3618 return 1;
@@ -4375,7 +4377,7 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4375 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4377 snprintf(name, 10, "%s%s%s", rew ? "n" : "",
4376 STp->disk->disk_name, st_formats[i]); 4378 STp->disk->disk_name, st_formats[i]);
4377 st_class_member = 4379 st_class_member =
4378 class_device_create(st_sysfs_class, 4380 class_device_create(st_sysfs_class, NULL,
4379 MKDEV(SCSI_TAPE_MAJOR, 4381 MKDEV(SCSI_TAPE_MAJOR,
4380 TAPE_MINOR(dev_num, mode, rew)), 4382 TAPE_MINOR(dev_num, mode, rew)),
4381 &STp->device->sdev_gendev, "%s", name); 4383 &STp->device->sdev_gendev, "%s", name);
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
index 5a51051e31f0..b131432c677d 100644
--- a/drivers/scsi/zalon.c
+++ b/drivers/scsi/zalon.c
@@ -88,7 +88,7 @@ zalon_probe(struct parisc_device *dev)
88 struct gsc_irq gsc_irq; 88 struct gsc_irq gsc_irq;
89 u32 zalon_vers; 89 u32 zalon_vers;
90 int error = -ENODEV; 90 int error = -ENODEV;
91 void __iomem *zalon = ioremap(dev->hpa, 4096); 91 void __iomem *zalon = ioremap(dev->hpa.start, 4096);
92 void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET; 92 void __iomem *io_port = zalon + GSC_SCSI_ZALON_OFFSET;
93 static int unit = 0; 93 static int unit = 0;
94 struct Scsi_Host *host; 94 struct Scsi_Host *host;
@@ -127,7 +127,7 @@ zalon_probe(struct parisc_device *dev)
127 device.chip = zalon720_chip; 127 device.chip = zalon720_chip;
128 device.host_id = 7; 128 device.host_id = 7;
129 device.dev = &dev->dev; 129 device.dev = &dev->dev;
130 device.slot.base = dev->hpa + GSC_SCSI_ZALON_OFFSET; 130 device.slot.base = dev->hpa.start + GSC_SCSI_ZALON_OFFSET;
131 device.slot.base_v = io_port; 131 device.slot.base_v = io_port;
132 device.slot.irq = dev->irq; 132 device.slot.irq = dev->irq;
133 device.differential = 2; 133 device.differential = 2;
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 4d75cdfa0a0a..afb7ddf200e0 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2358,13 +2358,10 @@ static int __devexit serial8250_remove(struct device *dev)
2358 return 0; 2358 return 0;
2359} 2359}
2360 2360
2361static int serial8250_suspend(struct device *dev, pm_message_t state, u32 level) 2361static int serial8250_suspend(struct device *dev, pm_message_t state)
2362{ 2362{
2363 int i; 2363 int i;
2364 2364
2365 if (level != SUSPEND_DISABLE)
2366 return 0;
2367
2368 for (i = 0; i < UART_NR; i++) { 2365 for (i = 0; i < UART_NR; i++) {
2369 struct uart_8250_port *up = &serial8250_ports[i]; 2366 struct uart_8250_port *up = &serial8250_ports[i];
2370 2367
@@ -2375,13 +2372,10 @@ static int serial8250_suspend(struct device *dev, pm_message_t state, u32 level)
2375 return 0; 2372 return 0;
2376} 2373}
2377 2374
2378static int serial8250_resume(struct device *dev, u32 level) 2375static int serial8250_resume(struct device *dev)
2379{ 2376{
2380 int i; 2377 int i;
2381 2378
2382 if (level != RESUME_ENABLE)
2383 return 0;
2384
2385 for (i = 0; i < UART_NR; i++) { 2379 for (i = 0; i < UART_NR; i++) {
2386 struct uart_8250_port *up = &serial8250_ports[i]; 2380 struct uart_8250_port *up = &serial8250_ports[i];
2387 2381
diff --git a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c
index 431aa5761a7a..8b4947933d9b 100644
--- a/drivers/serial/8250_gsc.c
+++ b/drivers/serial/8250_gsc.c
@@ -29,7 +29,6 @@
29static int __init 29static int __init
30serial_init_chip(struct parisc_device *dev) 30serial_init_chip(struct parisc_device *dev)
31{ 31{
32 static int serial_line_nr;
33 struct uart_port port; 32 struct uart_port port;
34 unsigned long address; 33 unsigned long address;
35 int err; 34 int err;
@@ -42,12 +41,13 @@ serial_init_chip(struct parisc_device *dev)
42 */ 41 */
43 if (parisc_parent(dev)->id.hw_type != HPHW_IOA) { 42 if (parisc_parent(dev)->id.hw_type != HPHW_IOA) {
44 printk(KERN_INFO "Serial: device 0x%lx not configured.\n" 43 printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
45 "Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa); 44 "Enable support for Wax, Lasi, Asp or Dino.\n",
45 dev->hpa.start);
46 } 46 }
47 return -ENODEV; 47 return -ENODEV;
48 } 48 }
49 49
50 address = dev->hpa; 50 address = dev->hpa.start;
51 if (dev->id.sversion != 0x8d) { 51 if (dev->id.sversion != 0x8d) {
52 address += 0x800; 52 address += 0x800;
53 } 53 }
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 679e678c7e6a..ddd0307fece2 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -50,6 +50,7 @@
50 50
51#include <asm/io.h> 51#include <asm/io.h>
52#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/hardware.h>
53#include <asm/hardware/amba.h> 54#include <asm/hardware/amba.h>
54#include <asm/hardware/amba_serial.h> 55#include <asm/hardware/amba_serial.h>
55 56
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 1ff629c74750..938d185841c9 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -50,6 +50,7 @@
50 50
51#include <asm/io.h> 51#include <asm/io.h>
52#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/sizes.h>
53#include <asm/hardware/amba.h> 54#include <asm/hardware/amba.h>
54#include <asm/hardware/clock.h> 55#include <asm/hardware/clock.h>
55#include <asm/hardware/amba_serial.h> 56#include <asm/hardware/amba_serial.h>
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 87ef368384fb..6a67e8f585b3 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -408,7 +408,11 @@ static struct uart_port clps711x_ports[UART_NR] = {
408 { 408 {
409 .iobase = SYSCON1, 409 .iobase = SYSCON1,
410 .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */ 410 .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */
411#ifdef CONFIG_MP1000_90MHZ
412 .uartclk = 4515840,
413#else
411 .uartclk = 3686400, 414 .uartclk = 3686400,
415#endif
412 .fifosize = 16, 416 .fifosize = 16,
413 .ops = &clps711x_pops, 417 .ops = &clps711x_pops,
414 .line = 0, 418 .line = 0,
@@ -417,7 +421,11 @@ static struct uart_port clps711x_ports[UART_NR] = {
417 { 421 {
418 .iobase = SYSCON2, 422 .iobase = SYSCON2,
419 .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */ 423 .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */
424#ifdef CONFIG_MP1000_90MHZ
425 .uartclk = 4515840,
426#else
420 .uartclk = 3686400, 427 .uartclk = 3686400,
428#endif
421 .fifosize = 16, 429 .fifosize = 16,
422 .ops = &clps711x_pops, 430 .ops = &clps711x_pops,
423 .line = 1, 431 .line = 1,
@@ -551,6 +559,7 @@ console_initcall(clps711xuart_console_init);
551static struct uart_driver clps711x_reg = { 559static struct uart_driver clps711x_reg = {
552 .driver_name = "ttyCL", 560 .driver_name = "ttyCL",
553 .dev_name = "ttyCL", 561 .dev_name = "ttyCL",
562 .devfs_name = "ttyCL",
554 .major = SERIAL_CLPS711X_MAJOR, 563 .major = SERIAL_CLPS711X_MAJOR,
555 .minor = SERIAL_CLPS711X_MINOR, 564 .minor = SERIAL_CLPS711X_MINOR,
556 .nr = UART_NR, 565 .nr = UART_NR,
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index bdb4e454b8b0..5b3933b0c997 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -921,21 +921,21 @@ static struct uart_driver imx_reg = {
921 .cons = IMX_CONSOLE, 921 .cons = IMX_CONSOLE,
922}; 922};
923 923
924static int serial_imx_suspend(struct device *_dev, pm_message_t state, u32 level) 924static int serial_imx_suspend(struct device *_dev, pm_message_t state)
925{ 925{
926 struct imx_port *sport = dev_get_drvdata(_dev); 926 struct imx_port *sport = dev_get_drvdata(_dev);
927 927
928 if (sport && level == SUSPEND_DISABLE) 928 if (sport)
929 uart_suspend_port(&imx_reg, &sport->port); 929 uart_suspend_port(&imx_reg, &sport->port);
930 930
931 return 0; 931 return 0;
932} 932}
933 933
934static int serial_imx_resume(struct device *_dev, u32 level) 934static int serial_imx_resume(struct device *_dev)
935{ 935{
936 struct imx_port *sport = dev_get_drvdata(_dev); 936 struct imx_port *sport = dev_get_drvdata(_dev);
937 937
938 if (sport && level == RESUME_ENABLE) 938 if (sport)
939 uart_resume_port(&imx_reg, &sport->port); 939 uart_resume_port(&imx_reg, &sport->port);
940 940
941 return 0; 941 return 0;
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 0585ab27ffde..8a79968f8ce1 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -781,22 +781,22 @@ mpc52xx_uart_remove(struct device *dev)
781 781
782#ifdef CONFIG_PM 782#ifdef CONFIG_PM
783static int 783static int
784mpc52xx_uart_suspend(struct device *dev, pm_message_t state, u32 level) 784mpc52xx_uart_suspend(struct device *dev, pm_message_t state)
785{ 785{
786 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 786 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
787 787
788 if (sport && level == SUSPEND_DISABLE) 788 if (sport)
789 uart_suspend_port(&mpc52xx_uart_driver, port); 789 uart_suspend_port(&mpc52xx_uart_driver, port);
790 790
791 return 0; 791 return 0;
792} 792}
793 793
794static int 794static int
795mpc52xx_uart_resume(struct device *dev, u32 level) 795mpc52xx_uart_resume(struct device *dev)
796{ 796{
797 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 797 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev);
798 798
799 if (port && level == RESUME_ENABLE) 799 if (port)
800 uart_resume_port(&mpc52xx_uart_driver, port); 800 uart_resume_port(&mpc52xx_uart_driver, port);
801 801
802 return 0; 802 return 0;
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c
index 189064607709..660bae5ba179 100644
--- a/drivers/serial/mux.c
+++ b/drivers/serial/mux.c
@@ -27,6 +27,7 @@
27#include <linux/delay.h> /* for udelay */ 27#include <linux/delay.h> /* for udelay */
28#include <linux/device.h> 28#include <linux/device.h>
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/irq.h>
30#include <asm/parisc-device.h> 31#include <asm/parisc-device.h>
31 32
32#ifdef CONFIG_MAGIC_SYSRQ 33#ifdef CONFIG_MAGIC_SYSRQ
@@ -444,7 +445,7 @@ static int __init mux_probe(struct parisc_device *dev)
444 unsigned long bytecnt; 445 unsigned long bytecnt;
445 struct uart_port *port; 446 struct uart_port *port;
446 447
447 status = pdc_iodc_read(&bytecnt, dev->hpa, 0, iodc_data, 32); 448 status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32);
448 if(status != PDC_OK) { 449 if(status != PDC_OK) {
449 printk(KERN_ERR "Serial mux: Unable to read IODC.\n"); 450 printk(KERN_ERR "Serial mux: Unable to read IODC.\n");
450 return 1; 451 return 1;
@@ -469,16 +470,18 @@ static int __init mux_probe(struct parisc_device *dev)
469 for(i = 0; i < ports; ++i, ++port_cnt) { 470 for(i = 0; i < ports; ++i, ++port_cnt) {
470 port = &mux_ports[port_cnt]; 471 port = &mux_ports[port_cnt];
471 port->iobase = 0; 472 port->iobase = 0;
472 port->mapbase = dev->hpa + MUX_OFFSET + (i * MUX_LINE_OFFSET); 473 port->mapbase = dev->hpa.start + MUX_OFFSET +
474 (i * MUX_LINE_OFFSET);
473 port->membase = ioremap(port->mapbase, MUX_LINE_OFFSET); 475 port->membase = ioremap(port->mapbase, MUX_LINE_OFFSET);
474 port->iotype = SERIAL_IO_MEM; 476 port->iotype = SERIAL_IO_MEM;
475 port->type = PORT_MUX; 477 port->type = PORT_MUX;
476 port->irq = SERIAL_IRQ_NONE; 478 port->irq = NO_IRQ;
477 port->uartclk = 0; 479 port->uartclk = 0;
478 port->fifosize = MUX_FIFO_SIZE; 480 port->fifosize = MUX_FIFO_SIZE;
479 port->ops = &mux_pops; 481 port->ops = &mux_pops;
480 port->flags = UPF_BOOT_AUTOCONF; 482 port->flags = UPF_BOOT_AUTOCONF;
481 port->line = port_cnt; 483 port->line = port_cnt;
484 spin_lock_init(&port->lock);
482 status = uart_add_one_port(&mux_driver, port); 485 status = uart_add_one_port(&mux_driver, port);
483 BUG_ON(status); 486 BUG_ON(status);
484 } 487 }
@@ -497,7 +500,7 @@ static struct parisc_device_id mux_tbl[] = {
497MODULE_DEVICE_TABLE(parisc, mux_tbl); 500MODULE_DEVICE_TABLE(parisc, mux_tbl);
498 501
499static struct parisc_driver serial_mux_driver = { 502static struct parisc_driver serial_mux_driver = {
500 .name = "Serial MUX", 503 .name = "serial_mux",
501 .id_table = mux_tbl, 504 .id_table = mux_tbl,
502 .probe = mux_probe, 505 .probe = mux_probe,
503}; 506};
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 90c2a86c421b..8cc4cedadd99 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -358,6 +358,9 @@ static int serial_pxa_startup(struct uart_port *port)
358 unsigned long flags; 358 unsigned long flags;
359 int retval; 359 int retval;
360 360
361 if (port->line == 3) /* HWUART */
362 up->mcr |= UART_MCR_AFE;
363 else
361 up->mcr = 0; 364 up->mcr = 0;
362 365
363 /* 366 /*
@@ -481,8 +484,10 @@ serial_pxa_set_termios(struct uart_port *port, struct termios *termios,
481 484
482 if ((up->port.uartclk / quot) < (2400 * 16)) 485 if ((up->port.uartclk / quot) < (2400 * 16))
483 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR1; 486 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR1;
484 else 487 else if ((up->port.uartclk / quot) < (230400 * 16))
485 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR8; 488 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR8;
489 else
490 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_PXAR32;
486 491
487 /* 492 /*
488 * Ok, we're now changing the port state. Do it with 493 * Ok, we're now changing the port state. Do it with
@@ -772,6 +777,20 @@ static struct uart_pxa_port serial_pxa_ports[] = {
772 .ops = &serial_pxa_pops, 777 .ops = &serial_pxa_pops,
773 .line = 2, 778 .line = 2,
774 }, 779 },
780 }, { /* HWUART */
781 .name = "HWUART",
782 .cken = CKEN4_HWUART,
783 .port = {
784 .type = PORT_PXA,
785 .iotype = UPIO_MEM,
786 .membase = (void *)&HWUART,
787 .mapbase = __PREG(HWUART),
788 .irq = IRQ_HWUART,
789 .uartclk = 921600 * 16,
790 .fifosize = 64,
791 .ops = &serial_pxa_pops,
792 .line = 3,
793 },
775 } 794 }
776}; 795};
777 796
@@ -786,21 +805,21 @@ static struct uart_driver serial_pxa_reg = {
786 .cons = PXA_CONSOLE, 805 .cons = PXA_CONSOLE,
787}; 806};
788 807
789static int serial_pxa_suspend(struct device *_dev, pm_message_t state, u32 level) 808static int serial_pxa_suspend(struct device *_dev, pm_message_t state)
790{ 809{
791 struct uart_pxa_port *sport = dev_get_drvdata(_dev); 810 struct uart_pxa_port *sport = dev_get_drvdata(_dev);
792 811
793 if (sport && level == SUSPEND_DISABLE) 812 if (sport)
794 uart_suspend_port(&serial_pxa_reg, &sport->port); 813 uart_suspend_port(&serial_pxa_reg, &sport->port);
795 814
796 return 0; 815 return 0;
797} 816}
798 817
799static int serial_pxa_resume(struct device *_dev, u32 level) 818static int serial_pxa_resume(struct device *_dev)
800{ 819{
801 struct uart_pxa_port *sport = dev_get_drvdata(_dev); 820 struct uart_pxa_port *sport = dev_get_drvdata(_dev);
802 821
803 if (sport && level == RESUME_ENABLE) 822 if (sport)
804 uart_resume_port(&serial_pxa_reg, &sport->port); 823 uart_resume_port(&serial_pxa_reg, &sport->port);
805 824
806 return 0; 825 return 0;
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 52692aa345ec..06a17dff1a73 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1134,23 +1134,22 @@ static int s3c24xx_serial_remove(struct device *_dev)
1134 1134
1135#ifdef CONFIG_PM 1135#ifdef CONFIG_PM
1136 1136
1137static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state, 1137static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state)
1138 u32 level)
1139{ 1138{
1140 struct uart_port *port = s3c24xx_dev_to_port(dev); 1139 struct uart_port *port = s3c24xx_dev_to_port(dev);
1141 1140
1142 if (port && level == SUSPEND_DISABLE) 1141 if (port)
1143 uart_suspend_port(&s3c24xx_uart_drv, port); 1142 uart_suspend_port(&s3c24xx_uart_drv, port);
1144 1143
1145 return 0; 1144 return 0;
1146} 1145}
1147 1146
1148static int s3c24xx_serial_resume(struct device *dev, u32 level) 1147static int s3c24xx_serial_resume(struct device *dev)
1149{ 1148{
1150 struct uart_port *port = s3c24xx_dev_to_port(dev); 1149 struct uart_port *port = s3c24xx_dev_to_port(dev);
1151 struct s3c24xx_uart_port *ourport = to_ourport(port); 1150 struct s3c24xx_uart_port *ourport = to_ourport(port);
1152 1151
1153 if (port && level == RESUME_ENABLE) { 1152 if (port) {
1154 clk_enable(ourport->clk); 1153 clk_enable(ourport->clk);
1155 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); 1154 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port));
1156 clk_disable(ourport->clk); 1155 clk_disable(ourport->clk);
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index dd8aed242357..c4a789e6af44 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -834,21 +834,21 @@ static struct uart_driver sa1100_reg = {
834 .cons = SA1100_CONSOLE, 834 .cons = SA1100_CONSOLE,
835}; 835};
836 836
837static int sa1100_serial_suspend(struct device *_dev, pm_message_t state, u32 level) 837static int sa1100_serial_suspend(struct device *_dev, pm_message_t state)
838{ 838{
839 struct sa1100_port *sport = dev_get_drvdata(_dev); 839 struct sa1100_port *sport = dev_get_drvdata(_dev);
840 840
841 if (sport && level == SUSPEND_DISABLE) 841 if (sport)
842 uart_suspend_port(&sa1100_reg, &sport->port); 842 uart_suspend_port(&sa1100_reg, &sport->port);
843 843
844 return 0; 844 return 0;
845} 845}
846 846
847static int sa1100_serial_resume(struct device *_dev, u32 level) 847static int sa1100_serial_resume(struct device *_dev)
848{ 848{
849 struct sa1100_port *sport = dev_get_drvdata(_dev); 849 struct sa1100_port *sport = dev_get_drvdata(_dev);
850 850
851 if (sport && level == RESUME_ENABLE) 851 if (sport)
852 uart_resume_port(&sa1100_reg, &sport->port); 852 uart_resume_port(&sa1100_reg, &sport->port);
853 853
854 return 0; 854 return 0;
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 0c5d65a08f6e..2b623ab0e36e 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -976,14 +976,11 @@ static int siu_remove(struct device *dev)
976 return 0; 976 return 0;
977} 977}
978 978
979static int siu_suspend(struct device *dev, pm_message_t state, u32 level) 979static int siu_suspend(struct device *dev, pm_message_t state)
980{ 980{
981 struct uart_port *port; 981 struct uart_port *port;
982 int i; 982 int i;
983 983
984 if (level != SUSPEND_DISABLE)
985 return 0;
986
987 for (i = 0; i < siu_uart_driver.nr; i++) { 984 for (i = 0; i < siu_uart_driver.nr; i++) {
988 port = &siu_uart_ports[i]; 985 port = &siu_uart_ports[i];
989 if ((port->type == PORT_VR41XX_SIU || 986 if ((port->type == PORT_VR41XX_SIU ||
@@ -995,14 +992,11 @@ static int siu_suspend(struct device *dev, pm_message_t state, u32 level)
995 return 0; 992 return 0;
996} 993}
997 994
998static int siu_resume(struct device *dev, u32 level) 995static int siu_resume(struct device *dev)
999{ 996{
1000 struct uart_port *port; 997 struct uart_port *port;
1001 int i; 998 int i;
1002 999
1003 if (level != RESUME_ENABLE)
1004 return 0;
1005
1006 for (i = 0; i < siu_uart_driver.nr; i++) { 1000 for (i = 0; i < siu_uart_driver.nr; i++) {
1007 port = &siu_uart_ports[i]; 1001 port = &siu_uart_ports[i];
1008 if ((port->type == PORT_VR41XX_SIU || 1002 if ((port->type == PORT_VR41XX_SIU ||
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index df014c2a7c54..a50c2bc506f2 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_USB) += core/
8 8
9obj-$(CONFIG_USB_MON) += mon/ 9obj-$(CONFIG_USB_MON) += mon/
10 10
11obj-$(CONFIG_PCI) += host/
11obj-$(CONFIG_USB_EHCI_HCD) += host/ 12obj-$(CONFIG_USB_EHCI_HCD) += host/
12obj-$(CONFIG_USB_ISP116X_HCD) += host/ 13obj-$(CONFIG_USB_ISP116X_HCD) += host/
13obj-$(CONFIG_USB_OHCI_HCD) += host/ 14obj-$(CONFIG_USB_OHCI_HCD) += host/
@@ -17,7 +18,6 @@ obj-$(CONFIG_ETRAX_USB_HOST) += host/
17 18
18obj-$(CONFIG_USB_ACM) += class/ 19obj-$(CONFIG_USB_ACM) += class/
19obj-$(CONFIG_USB_AUDIO) += class/ 20obj-$(CONFIG_USB_AUDIO) += class/
20obj-$(CONFIG_USB_BLUETOOTH_TTY) += class/
21obj-$(CONFIG_USB_MIDI) += class/ 21obj-$(CONFIG_USB_MIDI) += class/
22obj-$(CONFIG_USB_PRINTER) += class/ 22obj-$(CONFIG_USB_PRINTER) += class/
23 23
diff --git a/drivers/usb/class/Kconfig b/drivers/usb/class/Kconfig
index 333e39bb105f..ef105a92a7bd 100644
--- a/drivers/usb/class/Kconfig
+++ b/drivers/usb/class/Kconfig
@@ -28,29 +28,6 @@ config USB_AUDIO
28 To compile this driver as a module, choose M here: the 28 To compile this driver as a module, choose M here: the
29 module will be called audio. 29 module will be called audio.
30 30
31comment "USB Bluetooth TTY can only be used with disabled Bluetooth subsystem"
32 depends on USB && BT
33
34config USB_BLUETOOTH_TTY
35 tristate "USB Bluetooth TTY support"
36 depends on USB && BT=n
37 ---help---
38 This driver implements a nonstandard tty interface to a Bluetooth
39 device that can be used only by specialized Bluetooth HCI software.
40
41 Say Y here if you want to use OpenBT Bluetooth stack (available
42 at <http://developer.axis.com/software>), or other TTY based
43 Bluetooth stacks, and want to connect a USB Bluetooth device
44 to your computer's USB port.
45
46 Do *not* enable this driver if you want to use generic Linux
47 Bluetooth support.
48
49 If in doubt, say N here.
50
51 To compile this driver as a module, choose M here: the
52 module will be called bluetty.
53
54config USB_MIDI 31config USB_MIDI
55 tristate "USB MIDI support" 32 tristate "USB MIDI support"
56 depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER 33 depends on USB && SOUND && OBSOLETE_OSS_USB_DRIVER
diff --git a/drivers/usb/class/Makefile b/drivers/usb/class/Makefile
index 971e5497a3fd..229471247751 100644
--- a/drivers/usb/class/Makefile
+++ b/drivers/usb/class/Makefile
@@ -5,6 +5,5 @@
5 5
6obj-$(CONFIG_USB_ACM) += cdc-acm.o 6obj-$(CONFIG_USB_ACM) += cdc-acm.o
7obj-$(CONFIG_USB_AUDIO) += audio.o 7obj-$(CONFIG_USB_AUDIO) += audio.o
8obj-$(CONFIG_USB_BLUETOOTH_TTY) += bluetty.o
9obj-$(CONFIG_USB_MIDI) += usb-midi.o 8obj-$(CONFIG_USB_MIDI) += usb-midi.o
10obj-$(CONFIG_USB_PRINTER) += usblp.o 9obj-$(CONFIG_USB_PRINTER) += usblp.o
diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c
deleted file mode 100644
index 524023327c49..000000000000
--- a/drivers/usb/class/bluetty.c
+++ /dev/null
@@ -1,1279 +0,0 @@
1/*
2 * bluetty.c Version 0.13
3 *
4 * Copyright (C) 2000, 2001 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2000 Mark Douglas Corner <mcorner@umich.edu>
6 *
7 * USB Bluetooth TTY driver, based on the Bluetooth Spec version 1.0B
8 *
9 * (2001/11/30) Version 0.13 gkh
10 * - added locking patch from Masoodur Rahman <rmasoodu@in.ibm.com>
11 * - removed active variable, as open_count will do.
12 *
13 * (2001/07/09) Version 0.12 gkh
14 * - removed in_interrupt() call, as it doesn't make sense to do
15 * that anymore.
16 *
17 * (2001/06/05) Version 0.11 gkh
18 * - Fixed problem with read urb status saying that we have shutdown,
19 * and that we shouldn't resubmit the urb. Patch from unknown.
20 *
21 * (2001/05/28) Version 0.10 gkh
22 * - Fixed problem with using data from userspace in the bluetooth_write
23 * function as found by the CHECKER project.
24 * - Added a buffer to the write_urb_pool which reduces the number of
25 * buffers being created and destroyed for ever write. Also cleans
26 * up the logic a bit.
27 * - Added a buffer to the control_urb_pool which fixes a memory leak
28 * when the device is removed from the system.
29 *
30 * (2001/05/28) Version 0.9 gkh
31 * Fixed problem with bluetooth==NULL for bluetooth_read_bulk_callback
32 * which was found by both the CHECKER project and Mikko Rahkonen.
33 *
34 * (08/04/2001) gb
35 * Identify version on module load.
36 *
37 * (2001/03/10) Version 0.8 gkh
38 * Fixed problem with not unlinking interrupt urb on device close
39 * and resubmitting the read urb on error with bluetooth struct.
40 * Thanks to Narayan Mohanram <narayan@RovingNetworks.com> for the
41 * fixes.
42 *
43 * (11/29/2000) Version 0.7 gkh
44 * Fixed problem with overrunning the tty flip buffer.
45 * Removed unneeded NULL pointer initialization.
46 *
47 * (10/05/2000) Version 0.6 gkh
48 * Fixed bug with urb->dev not being set properly, now that the usb
49 * core needs it.
50 * Got a real major id number and name.
51 *
52 * (08/06/2000) Version 0.5 gkh
53 * Fixed problem of not resubmitting the bulk read urb if there is
54 * an error in the callback. Ericsson devices seem to need this.
55 *
56 * (07/11/2000) Version 0.4 gkh
57 * Fixed bug in disconnect for when we call tty_hangup
58 * Fixed bug in bluetooth_ctrl_msg where the bluetooth struct was not
59 * getting attached to the control urb properly.
60 * Fixed bug in bluetooth_write where we pay attention to the result
61 * of bluetooth_ctrl_msg.
62 *
63 * (08/03/2000) Version 0.3 gkh mdc
64 * Merged in Mark's changes to make the driver play nice with the Axis
65 * stack.
66 * Made the write bulk use an urb pool to enable larger transfers with
67 * fewer calls to the driver.
68 * Fixed off by one bug in acl pkt receive
69 * Made packet counters specific to each bluetooth device
70 * Added checks for zero length callbacks
71 * Added buffers for int and bulk packets. Had to do this otherwise
72 * packet types could intermingle.
73 * Made a control urb pool for the control messages.
74 *
75 * (07/11/2000) Version 0.2 gkh
76 * Fixed a small bug found by Nils Faerber in the usb_bluetooth_probe
77 * function.
78 *
79 * (07/09/2000) Version 0.1 gkh
80 * Initial release. Has support for sending ACL data (which is really just
81 * a HCI frame.) Raw HCI commands and HCI events are not supported.
82 * A ioctl will probably be needed for the HCI commands and events in the
83 * future. All isoch endpoints are ignored at this time also.
84 * This driver should work for all currently shipping USB Bluetooth
85 * devices at this time :)
86 *
87 */
88
89/*
90 * This program is free software; you can redistribute it and/or modify
91 * it under the terms of the GNU General Public License as published by
92 * the Free Software Foundation; either version 2 of the License, or
93 * (at your option) any later version.
94 *
95 * This program is distributed in the hope that it will be useful,
96 * but WITHOUT ANY WARRANTY; without even the implied warranty of
97 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98 * GNU General Public License for more details.
99 *
100 * You should have received a copy of the GNU General Public License
101 * along with this program; if not, write to the Free Software
102 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
103 */
104
105
106#include <linux/kernel.h>
107#include <linux/errno.h>
108#include <linux/init.h>
109#include <linux/slab.h>
110#include <linux/tty.h>
111#include <linux/tty_driver.h>
112#include <linux/tty_flip.h>
113#include <linux/module.h>
114#include <asm/uaccess.h>
115
116#define DEBUG
117#include <linux/usb.h>
118
119/*
120 * Version Information
121 */
122#define DRIVER_VERSION "v0.13"
123#define DRIVER_AUTHOR "Greg Kroah-Hartman, Mark Douglas Corner"
124#define DRIVER_DESC "USB Bluetooth tty driver"
125
126/* define this if you have hardware that is not good */
127/*#define BTBUGGYHARDWARE */
128
129/* Class, SubClass, and Protocol codes that describe a Bluetooth device */
130#define WIRELESS_CLASS_CODE 0xe0
131#define RF_SUBCLASS_CODE 0x01
132#define BLUETOOTH_PROGRAMMING_PROTOCOL_CODE 0x01
133
134
135#define BLUETOOTH_TTY_MAJOR 216 /* real device node major id */
136#define BLUETOOTH_TTY_MINORS 256 /* whole lotta bluetooth devices */
137
138#define USB_BLUETOOTH_MAGIC 0x6d02 /* magic number for bluetooth struct */
139
140#define BLUETOOTH_CONTROL_REQUEST_TYPE 0x20
141
142/* Bluetooth packet types */
143#define CMD_PKT 0x01
144#define ACL_PKT 0x02
145#define SCO_PKT 0x03
146#define EVENT_PKT 0x04
147#define ERROR_PKT 0x05
148#define NEG_PKT 0x06
149
150/* Message sizes */
151#define MAX_EVENT_SIZE 0xFF
152#define EVENT_HDR_SIZE 3 /* 2 for the header + 1 for the type indicator */
153#define EVENT_BUFFER_SIZE (MAX_EVENT_SIZE + EVENT_HDR_SIZE)
154
155#define MAX_ACL_SIZE 0xFFFF
156#define ACL_HDR_SIZE 5 /* 4 for the header + 1 for the type indicator */
157#define ACL_BUFFER_SIZE (MAX_ACL_SIZE + ACL_HDR_SIZE)
158
159/* parity check flag */
160#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
161
162#define CHAR2INT16(c1,c0) (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
163
164#define NUM_BULK_URBS 24
165#define NUM_CONTROL_URBS 16
166
167struct usb_bluetooth {
168 int magic;
169 struct usb_device * dev;
170 struct tty_driver * tty_driver; /* the tty_driver for this device */
171 struct tty_struct * tty; /* the corresponding tty for this port */
172
173 unsigned char minor; /* the starting minor number for this device */
174 int throttle; /* throttled by tty layer */
175 int open_count;
176
177 __u8 control_out_bInterfaceNum;
178 struct urb * control_urb_pool[NUM_CONTROL_URBS];
179 struct usb_ctrlrequest dr[NUM_CONTROL_URBS];
180
181 unsigned char * interrupt_in_buffer;
182 struct urb * interrupt_in_urb;
183 __u8 interrupt_in_endpointAddress;
184 __u8 interrupt_in_interval;
185 int interrupt_in_buffer_size;
186
187 unsigned char * bulk_in_buffer;
188 struct urb * read_urb;
189 __u8 bulk_in_endpointAddress;
190 int bulk_in_buffer_size;
191
192 int bulk_out_buffer_size;
193 __u8 bulk_out_endpointAddress;
194
195 wait_queue_head_t write_wait;
196
197 struct work_struct work; /* work queue entry for line discipline waking up */
198
199 unsigned int int_packet_pos;
200 unsigned char int_buffer[EVENT_BUFFER_SIZE];
201 unsigned int bulk_packet_pos;
202 unsigned char bulk_buffer[ACL_BUFFER_SIZE]; /* 64k preallocated, fix? */
203 struct semaphore lock;
204};
205
206
207/* local function prototypes */
208static int bluetooth_open (struct tty_struct *tty, struct file *filp);
209static void bluetooth_close (struct tty_struct *tty, struct file *filp);
210static int bluetooth_write (struct tty_struct *tty, const unsigned char *buf, int count);
211static int bluetooth_write_room (struct tty_struct *tty);
212static int bluetooth_chars_in_buffer (struct tty_struct *tty);
213static void bluetooth_throttle (struct tty_struct *tty);
214static void bluetooth_unthrottle (struct tty_struct *tty);
215static int bluetooth_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
216static void bluetooth_set_termios (struct tty_struct *tty, struct termios *old);
217
218static void bluetooth_int_callback (struct urb *urb, struct pt_regs *regs);
219static void bluetooth_ctrl_callback (struct urb *urb, struct pt_regs *regs);
220static void bluetooth_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
221static void bluetooth_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
222
223static int usb_bluetooth_probe (struct usb_interface *intf,
224 const struct usb_device_id *id);
225static void usb_bluetooth_disconnect (struct usb_interface *intf);
226
227
228static struct usb_device_id usb_bluetooth_ids [] = {
229 { USB_DEVICE_INFO(WIRELESS_CLASS_CODE, RF_SUBCLASS_CODE, BLUETOOTH_PROGRAMMING_PROTOCOL_CODE) },
230 { } /* Terminating entry */
231};
232
233MODULE_DEVICE_TABLE (usb, usb_bluetooth_ids);
234
235static struct usb_driver usb_bluetooth_driver = {
236 .owner = THIS_MODULE,
237 .name = "bluetty",
238 .probe = usb_bluetooth_probe,
239 .disconnect = usb_bluetooth_disconnect,
240 .id_table = usb_bluetooth_ids,
241};
242
243static struct tty_driver *bluetooth_tty_driver;
244static struct usb_bluetooth *bluetooth_table[BLUETOOTH_TTY_MINORS];
245
246
247static inline int bluetooth_paranoia_check (struct usb_bluetooth *bluetooth, const char *function)
248{
249 if (!bluetooth) {
250 dbg("%s - bluetooth == NULL", function);
251 return -1;
252 }
253 if (bluetooth->magic != USB_BLUETOOTH_MAGIC) {
254 dbg("%s - bad magic number for bluetooth", function);
255 return -1;
256 }
257
258 return 0;
259}
260
261
262static inline struct usb_bluetooth* get_usb_bluetooth (struct usb_bluetooth *bluetooth, const char *function)
263{
264 if (!bluetooth ||
265 bluetooth_paranoia_check (bluetooth, function)) {
266 /* then say that we don't have a valid usb_bluetooth thing, which will
267 * end up generating -ENODEV return values */
268 return NULL;
269 }
270
271 return bluetooth;
272}
273
274
275static inline struct usb_bluetooth *get_bluetooth_by_index (int index)
276{
277 return bluetooth_table[index];
278}
279
280
281static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int value, const unsigned char *buf, int len)
282{
283 struct urb *urb = NULL;
284 struct usb_ctrlrequest *dr = NULL;
285 int i;
286 int status;
287
288 dbg ("%s", __FUNCTION__);
289
290 /* try to find a free urb in our list */
291 for (i = 0; i < NUM_CONTROL_URBS; ++i) {
292 if (bluetooth->control_urb_pool[i]->status != -EINPROGRESS) {
293 urb = bluetooth->control_urb_pool[i];
294 dr = &bluetooth->dr[i];
295 break;
296 }
297 }
298 if (urb == NULL) {
299 dbg ("%s - no free urbs", __FUNCTION__);
300 return -ENOMEM;
301 }
302
303 /* keep increasing the urb transfer buffer to fit the size of the message */
304 if (urb->transfer_buffer == NULL) {
305 urb->transfer_buffer = kmalloc (len, GFP_KERNEL);
306 if (urb->transfer_buffer == NULL) {
307 err ("%s - out of memory", __FUNCTION__);
308 return -ENOMEM;
309 }
310 }
311 if (urb->transfer_buffer_length < len) {
312 kfree(urb->transfer_buffer);
313 urb->transfer_buffer = kmalloc (len, GFP_KERNEL);
314 if (urb->transfer_buffer == NULL) {
315 err ("%s - out of memory", __FUNCTION__);
316 return -ENOMEM;
317 }
318 }
319 memcpy (urb->transfer_buffer, buf, len);
320
321 dr->bRequestType= BLUETOOTH_CONTROL_REQUEST_TYPE;
322 dr->bRequest = request;
323 dr->wValue = cpu_to_le16((u16) value);
324 dr->wIndex = cpu_to_le16((u16) bluetooth->control_out_bInterfaceNum);
325 dr->wLength = cpu_to_le16((u16) len);
326
327 usb_fill_control_urb (urb, bluetooth->dev, usb_sndctrlpipe(bluetooth->dev, 0),
328 (unsigned char*)dr, urb->transfer_buffer, len, bluetooth_ctrl_callback, bluetooth);
329
330 /* send it down the pipe */
331 status = usb_submit_urb(urb, GFP_KERNEL);
332 if (status)
333 dbg("%s - usb_submit_urb(control) failed with status = %d", __FUNCTION__, status);
334
335 return status;
336}
337
338
339
340
341
342/*****************************************************************************
343 * Driver tty interface functions
344 *****************************************************************************/
345static int bluetooth_open (struct tty_struct *tty, struct file * filp)
346{
347 struct usb_bluetooth *bluetooth;
348 int result;
349
350 dbg("%s", __FUNCTION__);
351
352 /* initialize the pointer incase something fails */
353 tty->driver_data = NULL;
354
355 /* get the bluetooth object associated with this tty pointer */
356 bluetooth = get_bluetooth_by_index (tty->index);
357
358 if (bluetooth_paranoia_check (bluetooth, __FUNCTION__)) {
359 return -ENODEV;
360 }
361
362 down (&bluetooth->lock);
363
364 ++bluetooth->open_count;
365 if (bluetooth->open_count == 1) {
366 /* set up our structure making the tty driver remember our object, and us it */
367 tty->driver_data = bluetooth;
368 bluetooth->tty = tty;
369
370 /* force low_latency on so that our tty_push actually forces the data through,
371 * otherwise it is scheduled, and with high data rates (like with OHCI) data
372 * can get lost. */
373 bluetooth->tty->low_latency = 1;
374
375 /* Reset the packet position counters */
376 bluetooth->int_packet_pos = 0;
377 bluetooth->bulk_packet_pos = 0;
378
379#ifndef BTBUGGYHARDWARE
380 /* Start reading from the device */
381 usb_fill_bulk_urb (bluetooth->read_urb, bluetooth->dev,
382 usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
383 bluetooth->bulk_in_buffer,
384 bluetooth->bulk_in_buffer_size,
385 bluetooth_read_bulk_callback, bluetooth);
386 result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL);
387 if (result)
388 dbg("%s - usb_submit_urb(read bulk) failed with status %d", __FUNCTION__, result);
389#endif
390 usb_fill_int_urb (bluetooth->interrupt_in_urb, bluetooth->dev,
391 usb_rcvintpipe(bluetooth->dev, bluetooth->interrupt_in_endpointAddress),
392 bluetooth->interrupt_in_buffer,
393 bluetooth->interrupt_in_buffer_size,
394 bluetooth_int_callback, bluetooth,
395 bluetooth->interrupt_in_interval);
396 result = usb_submit_urb(bluetooth->interrupt_in_urb, GFP_KERNEL);
397 if (result)
398 dbg("%s - usb_submit_urb(interrupt in) failed with status %d", __FUNCTION__, result);
399 }
400
401 up(&bluetooth->lock);
402
403 return 0;
404}
405
406
407static void bluetooth_close (struct tty_struct *tty, struct file * filp)
408{
409 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
410
411 if (!bluetooth) {
412 return;
413 }
414
415 dbg("%s", __FUNCTION__);
416
417 if (!bluetooth->open_count) {
418 dbg ("%s - device not opened", __FUNCTION__);
419 return;
420 }
421
422 down (&bluetooth->lock);
423
424 --bluetooth->open_count;
425 if (bluetooth->open_count <= 0) {
426 bluetooth->open_count = 0;
427
428 /* shutdown any in-flight urbs that we know about */
429 usb_kill_urb (bluetooth->read_urb);
430 usb_kill_urb (bluetooth->interrupt_in_urb);
431 }
432 up(&bluetooth->lock);
433}
434
435
436static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, int count)
437{
438 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
439 struct urb *urb = NULL;
440 unsigned char *temp_buffer = NULL;
441 const unsigned char *current_buffer;
442 unsigned char *urb_buffer;
443 int i;
444 int retval = 0;
445
446 if (!bluetooth) {
447 return -ENODEV;
448 }
449
450 dbg("%s - %d byte(s)", __FUNCTION__, count);
451
452 if (!bluetooth->open_count) {
453 dbg ("%s - device not opened", __FUNCTION__);
454 return -EINVAL;
455 }
456
457 if (count == 0) {
458 dbg("%s - write request of 0 bytes", __FUNCTION__);
459 return 0;
460 }
461 if (count == 1) {
462 dbg("%s - write request only included type %d", __FUNCTION__, buf[0]);
463 return 1;
464 }
465
466#ifdef DEBUG
467 printk (KERN_DEBUG __FILE__ ": %s - length = %d, data = ", __FUNCTION__, count);
468 for (i = 0; i < count; ++i) {
469 printk ("%.2x ", buf[i]);
470 }
471 printk ("\n");
472#endif
473
474 current_buffer = buf;
475
476 switch (*current_buffer) {
477 /* First byte indicates the type of packet */
478 case CMD_PKT:
479 /* dbg("%s- Send cmd_pkt len:%d", __FUNCTION__, count);*/
480
481 retval = bluetooth_ctrl_msg (bluetooth, 0x00, 0x00, &current_buffer[1], count-1);
482 if (retval) {
483 goto exit;
484 }
485 retval = count;
486 break;
487
488 case ACL_PKT:
489 ++current_buffer;
490 --count;
491
492 urb_buffer = kmalloc (count, GFP_ATOMIC);
493 if (!urb_buffer) {
494 dev_err(&bluetooth->dev->dev, "out of memory\n");
495 retval = -ENOMEM;
496 goto exit;
497 }
498
499 urb = usb_alloc_urb(0, GFP_ATOMIC);
500 if (!urb) {
501 dev_err(&bluetooth->dev->dev, "no more free urbs\n");
502 kfree(urb_buffer);
503 retval = -ENOMEM;
504 goto exit;
505 }
506 memcpy (urb_buffer, current_buffer, count);
507
508 /* build up our urb */
509 usb_fill_bulk_urb(urb, bluetooth->dev,
510 usb_sndbulkpipe(bluetooth->dev,
511 bluetooth->bulk_out_endpointAddress),
512 urb_buffer,
513 count,
514 bluetooth_write_bulk_callback,
515 bluetooth);
516
517
518 /* send it down the pipe */
519 retval = usb_submit_urb(urb, GFP_KERNEL);
520 if (retval) {
521 dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __FUNCTION__, retval);
522 goto exit;
523 }
524
525 /* we are done with this urb, so let the host driver
526 * really free it when it is finished with it */
527 usb_free_urb (urb);
528 retval = count + 1;
529 break;
530
531 default :
532 dbg("%s - unsupported (at this time) write type", __FUNCTION__);
533 retval = -EINVAL;
534 break;
535 }
536
537exit:
538 kfree(temp_buffer);
539
540 return retval;
541}
542
543
544static int bluetooth_write_room (struct tty_struct *tty)
545{
546 dbg("%s", __FUNCTION__);
547
548 /*
549 * We really can take anything the user throws at us
550 * but let's pick a nice big number to tell the tty
551 * layer that we have lots of free space
552 */
553 return 2048;
554}
555
556
557static int bluetooth_chars_in_buffer (struct tty_struct *tty)
558{
559 dbg("%s", __FUNCTION__);
560
561 /*
562 * We can't really account for how much data we
563 * have sent out, but hasn't made it through to the
564 * device, so just tell the tty layer that everything
565 * is flushed.
566 */
567 return 0;
568}
569
570
571static void bluetooth_throttle (struct tty_struct * tty)
572{
573 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
574
575 if (!bluetooth) {
576 return;
577 }
578
579 dbg("%s", __FUNCTION__);
580
581 if (!bluetooth->open_count) {
582 dbg ("%s - device not open", __FUNCTION__);
583 return;
584 }
585
586 dbg("%s unsupported (at this time)", __FUNCTION__);
587
588 return;
589}
590
591
592static void bluetooth_unthrottle (struct tty_struct * tty)
593{
594 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
595
596 if (!bluetooth) {
597 return;
598 }
599
600 dbg("%s", __FUNCTION__);
601
602 if (!bluetooth->open_count) {
603 dbg ("%s - device not open", __FUNCTION__);
604 return;
605 }
606
607 dbg("%s unsupported (at this time)", __FUNCTION__);
608}
609
610
611static int bluetooth_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
612{
613 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
614
615 if (!bluetooth) {
616 return -ENODEV;
617 }
618
619 dbg("%s - cmd 0x%.4x", __FUNCTION__, cmd);
620
621 if (!bluetooth->open_count) {
622 dbg ("%s - device not open", __FUNCTION__);
623 return -ENODEV;
624 }
625
626 /* FIXME!!! */
627 return -ENOIOCTLCMD;
628}
629
630
631static void bluetooth_set_termios (struct tty_struct *tty, struct termios * old)
632{
633 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
634
635 if (!bluetooth) {
636 return;
637 }
638
639 dbg("%s", __FUNCTION__);
640
641 if (!bluetooth->open_count) {
642 dbg ("%s - device not open", __FUNCTION__);
643 return;
644 }
645
646 /* FIXME!!! */
647
648 return;
649}
650
651
652#ifdef BTBUGGYHARDWARE
653void btusb_enable_bulk_read(struct tty_struct *tty){
654 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
655 int result;
656
657 if (!bluetooth) {
658 return;
659 }
660
661 dbg("%s", __FUNCTION__);
662
663 if (!bluetooth->open_count) {
664 dbg ("%s - device not open", __FUNCTION__);
665 return;
666 }
667
668 if (bluetooth->read_urb) {
669 usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev,
670 usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
671 bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size,
672 bluetooth_read_bulk_callback, bluetooth);
673 result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL);
674 if (result)
675 err ("%s - failed submitting read urb, error %d", __FUNCTION__, result);
676 }
677}
678
679void btusb_disable_bulk_read(struct tty_struct *tty){
680 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
681
682 if (!bluetooth) {
683 return;
684 }
685
686 dbg("%s", __FUNCTION__);
687
688 if (!bluetooth->open_count) {
689 dbg ("%s - device not open", __FUNCTION__);
690 return;
691 }
692
693 if ((bluetooth->read_urb) && (bluetooth->read_urb->actual_length))
694 usb_kill_urb(bluetooth->read_urb);
695}
696#endif
697
698
699/*****************************************************************************
700 * urb callback functions
701 *****************************************************************************/
702
703
704static void bluetooth_int_callback (struct urb *urb, struct pt_regs *regs)
705{
706 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__);
707 unsigned char *data = urb->transfer_buffer;
708 unsigned int i;
709 unsigned int count = urb->actual_length;
710 unsigned int packet_size;
711 int status;
712
713 dbg("%s", __FUNCTION__);
714
715 if (!bluetooth) {
716 dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__);
717 return;
718 }
719
720 switch (urb->status) {
721 case 0:
722 /* success */
723 break;
724 case -ECONNRESET:
725 case -ENOENT:
726 case -ESHUTDOWN:
727 /* this urb is terminated, clean up */
728 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
729 return;
730 default:
731 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
732 goto exit;
733 }
734
735 if (!count) {
736 dbg("%s - zero length int", __FUNCTION__);
737 goto exit;
738 }
739
740
741#ifdef DEBUG
742 if (count) {
743 printk (KERN_DEBUG __FILE__ ": %s- length = %d, data = ", __FUNCTION__, count);
744 for (i = 0; i < count; ++i) {
745 printk ("%.2x ", data[i]);
746 }
747 printk ("\n");
748 }
749#endif
750
751#ifdef BTBUGGYHARDWARE
752 if ((count >= 2) && (data[0] == 0xFF) && (data[1] == 0x00)) {
753 data += 2;
754 count -= 2;
755 }
756 if (count == 0) {
757 urb->actual_length = 0;
758 goto exit;
759 }
760#endif
761 /* We add a packet type identifier to the beginning of each
762 HCI frame. This makes the data in the tty look like a
763 serial USB devices. Each HCI frame can be broken across
764 multiple URBs so we buffer them until we have a full hci
765 packet */
766
767 if (!bluetooth->int_packet_pos) {
768 bluetooth->int_buffer[0] = EVENT_PKT;
769 bluetooth->int_packet_pos++;
770 }
771
772 if (bluetooth->int_packet_pos + count > EVENT_BUFFER_SIZE) {
773 err("%s - exceeded EVENT_BUFFER_SIZE", __FUNCTION__);
774 bluetooth->int_packet_pos = 0;
775 goto exit;
776 }
777
778 memcpy (&bluetooth->int_buffer[bluetooth->int_packet_pos],
779 urb->transfer_buffer, count);
780 bluetooth->int_packet_pos += count;
781 urb->actual_length = 0;
782
783 if (bluetooth->int_packet_pos >= EVENT_HDR_SIZE)
784 packet_size = bluetooth->int_buffer[2];
785 else
786 goto exit;
787
788 if (packet_size + EVENT_HDR_SIZE < bluetooth->int_packet_pos) {
789 err("%s - packet was too long", __FUNCTION__);
790 bluetooth->int_packet_pos = 0;
791 goto exit;
792 }
793
794 if (packet_size + EVENT_HDR_SIZE == bluetooth->int_packet_pos) {
795 for (i = 0; i < bluetooth->int_packet_pos; ++i) {
796 /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them */
797 if (bluetooth->tty->flip.count >= TTY_FLIPBUF_SIZE) {
798 tty_flip_buffer_push(bluetooth->tty);
799 }
800 tty_insert_flip_char(bluetooth->tty, bluetooth->int_buffer[i], 0);
801 }
802 tty_flip_buffer_push(bluetooth->tty);
803
804 bluetooth->int_packet_pos = 0;
805 }
806
807exit:
808 status = usb_submit_urb (urb, GFP_ATOMIC);
809 if (status)
810 err ("%s - usb_submit_urb failed with result %d",
811 __FUNCTION__, status);
812}
813
814
815static void bluetooth_ctrl_callback (struct urb *urb, struct pt_regs *regs)
816{
817 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__);
818
819 dbg("%s", __FUNCTION__);
820
821 if (!bluetooth) {
822 dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__);
823 return;
824 }
825
826 if (urb->status) {
827 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
828 return;
829 }
830}
831
832
833static void bluetooth_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
834{
835 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__);
836 unsigned char *data = urb->transfer_buffer;
837 unsigned int count = urb->actual_length;
838 unsigned int i;
839 unsigned int packet_size;
840 int result;
841
842
843 dbg("%s", __FUNCTION__);
844
845 if (!bluetooth) {
846 dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__);
847 return;
848 }
849
850 if (urb->status) {
851 dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
852 if (urb->status == -ENOENT) {
853 dbg("%s - URB canceled, won't reschedule", __FUNCTION__);
854 return;
855 }
856 goto exit;
857 }
858
859 if (!count) {
860 dbg("%s - zero length read bulk", __FUNCTION__);
861 goto exit;
862 }
863
864#ifdef DEBUG
865 if (count) {
866 printk (KERN_DEBUG __FILE__ ": %s- length = %d, data = ", __FUNCTION__, count);
867 for (i = 0; i < count; ++i) {
868 printk ("%.2x ", data[i]);
869 }
870 printk ("\n");
871 }
872#endif
873#ifdef BTBUGGYHARDWARE
874 if ((count == 4) && (data[0] == 0x00) && (data[1] == 0x00)
875 && (data[2] == 0x00) && (data[3] == 0x00)) {
876 urb->actual_length = 0;
877 usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev,
878 usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
879 bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size,
880 bluetooth_read_bulk_callback, bluetooth);
881 result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL);
882 if (result)
883 err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
884
885 return;
886 }
887#endif
888 /* We add a packet type identifier to the beginning of each
889 HCI frame. This makes the data in the tty look like a
890 serial USB devices. Each HCI frame can be broken across
891 multiple URBs so we buffer them until we have a full hci
892 packet */
893
894 if (!bluetooth->bulk_packet_pos) {
895 bluetooth->bulk_buffer[0] = ACL_PKT;
896 bluetooth->bulk_packet_pos++;
897 }
898
899 if (bluetooth->bulk_packet_pos + count > ACL_BUFFER_SIZE) {
900 err("%s - exceeded ACL_BUFFER_SIZE", __FUNCTION__);
901 bluetooth->bulk_packet_pos = 0;
902 goto exit;
903 }
904
905 memcpy (&bluetooth->bulk_buffer[bluetooth->bulk_packet_pos],
906 urb->transfer_buffer, count);
907 bluetooth->bulk_packet_pos += count;
908 urb->actual_length = 0;
909
910 if (bluetooth->bulk_packet_pos >= ACL_HDR_SIZE) {
911 packet_size = CHAR2INT16(bluetooth->bulk_buffer[4],bluetooth->bulk_buffer[3]);
912 } else {
913 goto exit;
914 }
915
916 if (packet_size + ACL_HDR_SIZE < bluetooth->bulk_packet_pos) {
917 err("%s - packet was too long", __FUNCTION__);
918 bluetooth->bulk_packet_pos = 0;
919 goto exit;
920 }
921
922 if (packet_size + ACL_HDR_SIZE == bluetooth->bulk_packet_pos) {
923 for (i = 0; i < bluetooth->bulk_packet_pos; ++i) {
924 /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
925 if (bluetooth->tty->flip.count >= TTY_FLIPBUF_SIZE) {
926 tty_flip_buffer_push(bluetooth->tty);
927 }
928 tty_insert_flip_char(bluetooth->tty, bluetooth->bulk_buffer[i], 0);
929 }
930 tty_flip_buffer_push(bluetooth->tty);
931 bluetooth->bulk_packet_pos = 0;
932 }
933
934exit:
935 if (!bluetooth || !bluetooth->open_count)
936 return;
937
938 usb_fill_bulk_urb(bluetooth->read_urb, bluetooth->dev,
939 usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
940 bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size,
941 bluetooth_read_bulk_callback, bluetooth);
942 result = usb_submit_urb(bluetooth->read_urb, GFP_KERNEL);
943 if (result)
944 err ("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
945
946 return;
947}
948
949
950static void bluetooth_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
951{
952 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)urb->context, __FUNCTION__);
953
954 dbg("%s", __FUNCTION__);
955
956 /* free up the transfer buffer, as usb_free_urb() does not do this */
957 kfree(urb->transfer_buffer);
958
959 if (!bluetooth) {
960 dbg("%s - bad bluetooth pointer, exiting", __FUNCTION__);
961 return;
962 }
963
964 if (urb->status) {
965 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
966 return;
967 }
968
969 /* wake up our little function to let the tty layer know that something happened */
970 schedule_work(&bluetooth->work);
971}
972
973
974static void bluetooth_softint(void *private)
975{
976 struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)private, __FUNCTION__);
977
978 dbg("%s", __FUNCTION__);
979
980 if (!bluetooth)
981 return;
982
983 tty_wakeup(bluetooth->tty);
984}
985
986
987static int usb_bluetooth_probe (struct usb_interface *intf,
988 const struct usb_device_id *id)
989{
990 struct usb_device *dev = interface_to_usbdev (intf);
991 struct usb_bluetooth *bluetooth = NULL;
992 struct usb_host_interface *interface;
993 struct usb_endpoint_descriptor *endpoint;
994 struct usb_endpoint_descriptor *interrupt_in_endpoint[8];
995 struct usb_endpoint_descriptor *bulk_in_endpoint[8];
996 struct usb_endpoint_descriptor *bulk_out_endpoint[8];
997 int control_out_endpoint;
998
999 int minor;
1000 int buffer_size;
1001 int i;
1002 int num_interrupt_in = 0;
1003 int num_bulk_in = 0;
1004 int num_bulk_out = 0;
1005
1006 interface = intf->cur_altsetting;
1007 control_out_endpoint = interface->desc.bInterfaceNumber;
1008
1009 /* find the endpoints that we need */
1010 for (i = 0; i < interface->desc.bNumEndpoints; ++i) {
1011 endpoint = &interface->endpoint[i].desc;
1012
1013 if ((endpoint->bEndpointAddress & 0x80) &&
1014 ((endpoint->bmAttributes & 3) == 0x02)) {
1015 /* we found a bulk in endpoint */
1016 dbg("found bulk in");
1017 bulk_in_endpoint[num_bulk_in] = endpoint;
1018 ++num_bulk_in;
1019 }
1020
1021 if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
1022 ((endpoint->bmAttributes & 3) == 0x02)) {
1023 /* we found a bulk out endpoint */
1024 dbg("found bulk out");
1025 bulk_out_endpoint[num_bulk_out] = endpoint;
1026 ++num_bulk_out;
1027 }
1028
1029 if ((endpoint->bEndpointAddress & 0x80) &&
1030 ((endpoint->bmAttributes & 3) == 0x03)) {
1031 /* we found a interrupt in endpoint */
1032 dbg("found interrupt in");
1033 interrupt_in_endpoint[num_interrupt_in] = endpoint;
1034 ++num_interrupt_in;
1035 }
1036 }
1037
1038 /* according to the spec, we can only have 1 bulk_in, 1 bulk_out, and 1 interrupt_in endpoints */
1039 if ((num_bulk_in != 1) ||
1040 (num_bulk_out != 1) ||
1041 (num_interrupt_in != 1)) {
1042 dbg ("%s - improper number of endpoints. Bluetooth driver not bound.", __FUNCTION__);
1043 return -EIO;
1044 }
1045
1046 info("USB Bluetooth converter detected");
1047
1048 for (minor = 0; minor < BLUETOOTH_TTY_MINORS && bluetooth_table[minor]; ++minor)
1049 ;
1050 if (bluetooth_table[minor]) {
1051 err("No more free Bluetooth devices");
1052 return -ENODEV;
1053 }
1054
1055 if (!(bluetooth = kmalloc(sizeof(struct usb_bluetooth), GFP_KERNEL))) {
1056 err("Out of memory");
1057 return -ENOMEM;
1058 }
1059
1060 memset(bluetooth, 0, sizeof(struct usb_bluetooth));
1061
1062 bluetooth->magic = USB_BLUETOOTH_MAGIC;
1063 bluetooth->dev = dev;
1064 bluetooth->minor = minor;
1065 INIT_WORK(&bluetooth->work, bluetooth_softint, bluetooth);
1066 init_MUTEX(&bluetooth->lock);
1067
1068 /* record the interface number for the control out */
1069 bluetooth->control_out_bInterfaceNum = control_out_endpoint;
1070
1071 /* create our control out urb pool */
1072 for (i = 0; i < NUM_CONTROL_URBS; ++i) {
1073 struct urb *urb = usb_alloc_urb(0, GFP_KERNEL);
1074 if (urb == NULL) {
1075 err("No free urbs available");
1076 goto probe_error;
1077 }
1078 urb->transfer_buffer = NULL;
1079 bluetooth->control_urb_pool[i] = urb;
1080 }
1081
1082 /* set up the endpoint information */
1083 endpoint = bulk_in_endpoint[0];
1084 bluetooth->read_urb = usb_alloc_urb (0, GFP_KERNEL);
1085 if (!bluetooth->read_urb) {
1086 err("No free urbs available");
1087 goto probe_error;
1088 }
1089 bluetooth->bulk_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
1090 bluetooth->bulk_in_endpointAddress = endpoint->bEndpointAddress;
1091 bluetooth->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
1092 if (!bluetooth->bulk_in_buffer) {
1093 err("Couldn't allocate bulk_in_buffer");
1094 goto probe_error;
1095 }
1096 usb_fill_bulk_urb(bluetooth->read_urb, dev, usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
1097 bluetooth->bulk_in_buffer, buffer_size, bluetooth_read_bulk_callback, bluetooth);
1098
1099 endpoint = bulk_out_endpoint[0];
1100 bluetooth->bulk_out_endpointAddress = endpoint->bEndpointAddress;
1101 bluetooth->bulk_out_buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
1102
1103 endpoint = interrupt_in_endpoint[0];
1104 bluetooth->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
1105 if (!bluetooth->interrupt_in_urb) {
1106 err("No free urbs available");
1107 goto probe_error;
1108 }
1109 bluetooth->interrupt_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
1110 bluetooth->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
1111 bluetooth->interrupt_in_interval = endpoint->bInterval;
1112 bluetooth->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
1113 if (!bluetooth->interrupt_in_buffer) {
1114 err("Couldn't allocate interrupt_in_buffer");
1115 goto probe_error;
1116 }
1117 usb_fill_int_urb(bluetooth->interrupt_in_urb, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress),
1118 bluetooth->interrupt_in_buffer, buffer_size, bluetooth_int_callback,
1119 bluetooth, endpoint->bInterval);
1120
1121 /* initialize the devfs nodes for this device and let the user know what bluetooths we are bound to */
1122 tty_register_device (bluetooth_tty_driver, minor, &intf->dev);
1123 info("Bluetooth converter now attached to ttyUB%d (or usb/ttub/%d for devfs)", minor, minor);
1124
1125 bluetooth_table[minor] = bluetooth;
1126
1127 /* success */
1128 usb_set_intfdata (intf, bluetooth);
1129 return 0;
1130
1131probe_error:
1132 if (bluetooth->read_urb)
1133 usb_free_urb (bluetooth->read_urb);
1134 if (bluetooth->bulk_in_buffer)
1135 kfree (bluetooth->bulk_in_buffer);
1136 if (bluetooth->interrupt_in_urb)
1137 usb_free_urb (bluetooth->interrupt_in_urb);
1138 if (bluetooth->interrupt_in_buffer)
1139 kfree (bluetooth->interrupt_in_buffer);
1140 for (i = 0; i < NUM_CONTROL_URBS; ++i)
1141 if (bluetooth->control_urb_pool[i]) {
1142 if (bluetooth->control_urb_pool[i]->transfer_buffer)
1143 kfree (bluetooth->control_urb_pool[i]->transfer_buffer);
1144 usb_free_urb (bluetooth->control_urb_pool[i]);
1145 }
1146
1147 bluetooth_table[minor] = NULL;
1148
1149 /* free up any memory that we allocated */
1150 kfree (bluetooth);
1151 return -EIO;
1152}
1153
1154
1155static void usb_bluetooth_disconnect(struct usb_interface *intf)
1156{
1157 struct usb_bluetooth *bluetooth = usb_get_intfdata (intf);
1158 int i;
1159
1160 usb_set_intfdata (intf, NULL);
1161 if (bluetooth) {
1162 if ((bluetooth->open_count) && (bluetooth->tty))
1163 tty_hangup(bluetooth->tty);
1164
1165 bluetooth->open_count = 0;
1166
1167 if (bluetooth->read_urb) {
1168 usb_kill_urb (bluetooth->read_urb);
1169 usb_free_urb (bluetooth->read_urb);
1170 }
1171 if (bluetooth->bulk_in_buffer)
1172 kfree (bluetooth->bulk_in_buffer);
1173
1174 if (bluetooth->interrupt_in_urb) {
1175 usb_kill_urb (bluetooth->interrupt_in_urb);
1176 usb_free_urb (bluetooth->interrupt_in_urb);
1177 }
1178 if (bluetooth->interrupt_in_buffer)
1179 kfree (bluetooth->interrupt_in_buffer);
1180
1181 tty_unregister_device (bluetooth_tty_driver, bluetooth->minor);
1182
1183 for (i = 0; i < NUM_CONTROL_URBS; ++i) {
1184 if (bluetooth->control_urb_pool[i]) {
1185 usb_kill_urb (bluetooth->control_urb_pool[i]);
1186 if (bluetooth->control_urb_pool[i]->transfer_buffer)
1187 kfree (bluetooth->control_urb_pool[i]->transfer_buffer);
1188 usb_free_urb (bluetooth->control_urb_pool[i]);
1189 }
1190 }
1191
1192 info("Bluetooth converter now disconnected from ttyUB%d", bluetooth->minor);
1193
1194 bluetooth_table[bluetooth->minor] = NULL;
1195
1196 /* free up any memory that we allocated */
1197 kfree (bluetooth);
1198 } else {
1199 info("device disconnected");
1200 }
1201}
1202
1203static struct tty_operations bluetooth_ops = {
1204 .open = bluetooth_open,
1205 .close = bluetooth_close,
1206 .write = bluetooth_write,
1207 .write_room = bluetooth_write_room,
1208 .ioctl = bluetooth_ioctl,
1209 .set_termios = bluetooth_set_termios,
1210 .throttle = bluetooth_throttle,
1211 .unthrottle = bluetooth_unthrottle,
1212 .chars_in_buffer = bluetooth_chars_in_buffer,
1213};
1214
1215static int usb_bluetooth_init(void)
1216{
1217 int i;
1218 int result;
1219
1220 /* Initialize our global data */
1221 for (i = 0; i < BLUETOOTH_TTY_MINORS; ++i) {
1222 bluetooth_table[i] = NULL;
1223 }
1224
1225 info ("USB Bluetooth support registered");
1226
1227 bluetooth_tty_driver = alloc_tty_driver(BLUETOOTH_TTY_MINORS);
1228 if (!bluetooth_tty_driver)
1229 return -ENOMEM;
1230
1231 bluetooth_tty_driver->owner = THIS_MODULE;
1232 bluetooth_tty_driver->driver_name = "usb-bluetooth";
1233 bluetooth_tty_driver->name = "ttyUB";
1234 bluetooth_tty_driver->devfs_name = "usb/ttub/";
1235 bluetooth_tty_driver->major = BLUETOOTH_TTY_MAJOR;
1236 bluetooth_tty_driver->minor_start = 0;
1237 bluetooth_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1238 bluetooth_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1239 bluetooth_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
1240 bluetooth_tty_driver->init_termios = tty_std_termios;
1241 bluetooth_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1242 tty_set_operations(bluetooth_tty_driver, &bluetooth_ops);
1243 if (tty_register_driver (bluetooth_tty_driver)) {
1244 err("%s - failed to register tty driver", __FUNCTION__);
1245 put_tty_driver(bluetooth_tty_driver);
1246 return -1;
1247 }
1248
1249 /* register the USB driver */
1250 result = usb_register(&usb_bluetooth_driver);
1251 if (result < 0) {
1252 tty_unregister_driver(bluetooth_tty_driver);
1253 put_tty_driver(bluetooth_tty_driver);
1254 err("usb_register failed for the USB bluetooth driver. Error number %d", result);
1255 return -1;
1256 }
1257
1258 info(DRIVER_DESC " " DRIVER_VERSION);
1259
1260 return 0;
1261}
1262
1263
1264static void usb_bluetooth_exit(void)
1265{
1266 usb_deregister(&usb_bluetooth_driver);
1267 tty_unregister_driver(bluetooth_tty_driver);
1268 put_tty_driver(bluetooth_tty_driver);
1269}
1270
1271
1272module_init(usb_bluetooth_init);
1273module_exit(usb_bluetooth_exit);
1274
1275/* Module information */
1276MODULE_AUTHOR( DRIVER_AUTHOR );
1277MODULE_DESCRIPTION( DRIVER_DESC );
1278MODULE_LICENSE("GPL");
1279
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 16ecad30e29c..1b4751412970 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -827,11 +827,10 @@ skip_normal_probe:
827 return -ENODEV; 827 return -ENODEV;
828 } 828 }
829 829
830 if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) { 830 if (!(acm = kzalloc(sizeof(struct acm), GFP_KERNEL))) {
831 dev_dbg(&intf->dev, "out of memory (acm kmalloc)\n"); 831 dev_dbg(&intf->dev, "out of memory (acm kzalloc)\n");
832 goto alloc_fail; 832 goto alloc_fail;
833 } 833 }
834 memset(acm, 0, sizeof(struct acm));
835 834
836 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); 835 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
837 readsize = le16_to_cpu(epread->wMaxPacketSize); 836 readsize = le16_to_cpu(epread->wMaxPacketSize);
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index e195709c9c7f..357e75335f17 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -844,9 +844,8 @@ static struct file_operations usblp_fops = {
844}; 844};
845 845
846static struct usb_class_driver usblp_class = { 846static struct usb_class_driver usblp_class = {
847 .name = "usb/lp%d", 847 .name = "lp%d",
848 .fops = &usblp_fops, 848 .fops = &usblp_fops,
849 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
850 .minor_base = USBLP_MINOR_BASE, 849 .minor_base = USBLP_MINOR_BASE,
851}; 850};
852 851
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 1a9ff6184943..ff03184da403 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -61,14 +61,17 @@ config USB_DYNAMIC_MINORS
61 If you are unsure about this, say N here. 61 If you are unsure about this, say N here.
62 62
63config USB_SUSPEND 63config USB_SUSPEND
64 bool "USB suspend/resume (EXPERIMENTAL)" 64 bool "USB selective suspend/resume and wakeup (EXPERIMENTAL)"
65 depends on USB && PM && EXPERIMENTAL 65 depends on USB && PM && EXPERIMENTAL
66 help 66 help
67 If you say Y here, you can use driver calls or the sysfs 67 If you say Y here, you can use driver calls or the sysfs
68 "power/state" file to suspend or resume individual USB 68 "power/state" file to suspend or resume individual USB
69 peripherals. There are many related features, such as 69 peripherals.
70 remote wakeup and driver-specific suspend processing, that 70
71 may not yet work as expected. 71 Also, USB "remote wakeup" signaling is supported, whereby some
72 USB devices (like keyboards and network adapters) can wake up
73 their parent hub. That wakeup cascades up the USB tree, and
74 could wake the system from states like suspend-to-RAM.
72 75
73 If you are unsure about this, say N here. 76 If you are unsure about this, say N here.
74 77
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index d5503cf0bf74..dd1c4d2a0c31 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ 5usbcore-objs := usb.o hub.o hcd.o urb.o message.o \
6 config.o file.o buffer.o sysfs.o devio.o 6 config.o file.o buffer.o sysfs.o devio.o notify.o
7 7
8ifeq ($(CONFIG_PCI),y) 8ifeq ($(CONFIG_PCI),y)
9 usbcore-objs += hcd-pci.o 9 usbcore-objs += hcd-pci.o
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index fc15b4acc8af..57e800ac3cee 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -106,7 +106,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
106void *hcd_buffer_alloc ( 106void *hcd_buffer_alloc (
107 struct usb_bus *bus, 107 struct usb_bus *bus,
108 size_t size, 108 size_t size,
109 unsigned mem_flags, 109 gfp_t mem_flags,
110 dma_addr_t *dma 110 dma_addr_t *dma
111) 111)
112{ 112{
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 99595e07b653..993019500cc3 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -112,8 +112,12 @@ void usb_release_interface_cache(struct kref *ref)
112 struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref); 112 struct usb_interface_cache *intfc = ref_to_usb_interface_cache(ref);
113 int j; 113 int j;
114 114
115 for (j = 0; j < intfc->num_altsetting; j++) 115 for (j = 0; j < intfc->num_altsetting; j++) {
116 kfree(intfc->altsetting[j].endpoint); 116 struct usb_host_interface *alt = &intfc->altsetting[j];
117
118 kfree(alt->endpoint);
119 kfree(alt->string);
120 }
117 kfree(intfc); 121 kfree(intfc);
118} 122}
119 123
@@ -188,10 +192,9 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
188 } 192 }
189 193
190 len = sizeof(struct usb_host_endpoint) * num_ep; 194 len = sizeof(struct usb_host_endpoint) * num_ep;
191 alt->endpoint = kmalloc(len, GFP_KERNEL); 195 alt->endpoint = kzalloc(len, GFP_KERNEL);
192 if (!alt->endpoint) 196 if (!alt->endpoint)
193 return -ENOMEM; 197 return -ENOMEM;
194 memset(alt->endpoint, 0, len);
195 198
196 /* Parse all the endpoint descriptors */ 199 /* Parse all the endpoint descriptors */
197 n = 0; 200 n = 0;
@@ -353,10 +356,9 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx,
353 } 356 }
354 357
355 len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j; 358 len = sizeof(*intfc) + sizeof(struct usb_host_interface) * j;
356 config->intf_cache[i] = intfc = kmalloc(len, GFP_KERNEL); 359 config->intf_cache[i] = intfc = kzalloc(len, GFP_KERNEL);
357 if (!intfc) 360 if (!intfc)
358 return -ENOMEM; 361 return -ENOMEM;
359 memset(intfc, 0, len);
360 kref_init(&intfc->ref); 362 kref_init(&intfc->ref);
361 } 363 }
362 364
@@ -422,8 +424,6 @@ void usb_destroy_configuration(struct usb_device *dev)
422 struct usb_host_config *cf = &dev->config[c]; 424 struct usb_host_config *cf = &dev->config[c];
423 425
424 kfree(cf->string); 426 kfree(cf->string);
425 cf->string = NULL;
426
427 for (i = 0; i < cf->desc.bNumInterfaces; i++) { 427 for (i = 0; i < cf->desc.bNumInterfaces; i++) {
428 if (cf->intf_cache[i]) 428 if (cf->intf_cache[i])
429 kref_put(&cf->intf_cache[i]->ref, 429 kref_put(&cf->intf_cache[i]->ref,
@@ -459,16 +459,14 @@ int usb_get_configuration(struct usb_device *dev)
459 } 459 }
460 460
461 length = ncfg * sizeof(struct usb_host_config); 461 length = ncfg * sizeof(struct usb_host_config);
462 dev->config = kmalloc(length, GFP_KERNEL); 462 dev->config = kzalloc(length, GFP_KERNEL);
463 if (!dev->config) 463 if (!dev->config)
464 goto err2; 464 goto err2;
465 memset(dev->config, 0, length);
466 465
467 length = ncfg * sizeof(char *); 466 length = ncfg * sizeof(char *);
468 dev->rawdescriptors = kmalloc(length, GFP_KERNEL); 467 dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
469 if (!dev->rawdescriptors) 468 if (!dev->rawdescriptors)
470 goto err2; 469 goto err2;
471 memset(dev->rawdescriptors, 0, length);
472 470
473 buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL); 471 buffer = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
474 if (!buffer) 472 if (!buffer)
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 487ff672b104..942cd437dc48 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -46,6 +46,7 @@
46#include <linux/usb.h> 46#include <linux/usb.h>
47#include <linux/usbdevice_fs.h> 47#include <linux/usbdevice_fs.h>
48#include <linux/cdev.h> 48#include <linux/cdev.h>
49#include <linux/notifier.h>
49#include <asm/uaccess.h> 50#include <asm/uaccess.h>
50#include <asm/byteorder.h> 51#include <asm/byteorder.h>
51#include <linux/moduleparam.h> 52#include <linux/moduleparam.h>
@@ -209,10 +210,10 @@ err:
209static struct async *alloc_async(unsigned int numisoframes) 210static struct async *alloc_async(unsigned int numisoframes)
210{ 211{
211 unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor); 212 unsigned int assize = sizeof(struct async) + numisoframes * sizeof(struct usb_iso_packet_descriptor);
212 struct async *as = kmalloc(assize, GFP_KERNEL); 213 struct async *as = kzalloc(assize, GFP_KERNEL);
214
213 if (!as) 215 if (!as)
214 return NULL; 216 return NULL;
215 memset(as, 0, assize);
216 as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL); 217 as->urb = usb_alloc_urb(numisoframes, GFP_KERNEL);
217 if (!as->urb) { 218 if (!as->urb) {
218 kfree(as); 219 kfree(as);
@@ -279,6 +280,28 @@ static inline struct async *async_getpending(struct dev_state *ps, void __user *
279 return NULL; 280 return NULL;
280} 281}
281 282
283static void snoop_urb(struct urb *urb, void __user *userurb)
284{
285 int j;
286 unsigned char *data = urb->transfer_buffer;
287
288 if (!usbfs_snoop)
289 return;
290
291 if (urb->pipe & USB_DIR_IN)
292 dev_info(&urb->dev->dev, "direction=IN\n");
293 else
294 dev_info(&urb->dev->dev, "direction=OUT\n");
295 dev_info(&urb->dev->dev, "userurb=%p\n", userurb);
296 dev_info(&urb->dev->dev, "transfer_buffer_length=%d\n",
297 urb->transfer_buffer_length);
298 dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length);
299 dev_info(&urb->dev->dev, "data: ");
300 for (j = 0; j < urb->transfer_buffer_length; ++j)
301 printk ("%02x ", data[j]);
302 printk("\n");
303}
304
282static void async_completed(struct urb *urb, struct pt_regs *regs) 305static void async_completed(struct urb *urb, struct pt_regs *regs)
283{ 306{
284 struct async *as = (struct async *)urb->context; 307 struct async *as = (struct async *)urb->context;
@@ -296,7 +319,9 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
296 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 319 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
297 as->euid); 320 as->euid);
298 } 321 }
299 wake_up(&ps->wait); 322 snoop(&urb->dev->dev, "urb complete\n");
323 snoop_urb(urb, as->userurb);
324 wake_up(&ps->wait);
300} 325}
301 326
302static void destroy_async (struct dev_state *ps, struct list_head *list) 327static void destroy_async (struct dev_state *ps, struct list_head *list)
@@ -493,6 +518,23 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, unsig
493 return ret; 518 return ret;
494} 519}
495 520
521static struct usb_device *usbdev_lookup_minor(int minor)
522{
523 struct class_device *class_dev;
524 struct usb_device *dev = NULL;
525
526 down(&usb_device_class->sem);
527 list_for_each_entry(class_dev, &usb_device_class->children, node) {
528 if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) {
529 dev = class_dev->class_data;
530 break;
531 }
532 }
533 up(&usb_device_class->sem);
534
535 return dev;
536};
537
496/* 538/*
497 * file operations 539 * file operations
498 */ 540 */
@@ -601,7 +643,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
601 if (usbfs_snoop) { 643 if (usbfs_snoop) {
602 dev_info(&dev->dev, "control read: data "); 644 dev_info(&dev->dev, "control read: data ");
603 for (j = 0; j < i; ++j) 645 for (j = 0; j < i; ++j)
604 printk ("%02x ", (unsigned char)(tbuf)[j]); 646 printk("%02x ", (unsigned char)(tbuf)[j]);
605 printk("\n"); 647 printk("\n");
606 } 648 }
607 if (copy_to_user(ctrl.data, tbuf, i)) { 649 if (copy_to_user(ctrl.data, tbuf, i)) {
@@ -624,7 +666,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
624 if (usbfs_snoop) { 666 if (usbfs_snoop) {
625 dev_info(&dev->dev, "control write: data: "); 667 dev_info(&dev->dev, "control write: data: ");
626 for (j = 0; j < ctrl.wLength; ++j) 668 for (j = 0; j < ctrl.wLength; ++j)
627 printk ("%02x ", (unsigned char)(tbuf)[j]); 669 printk("%02x ", (unsigned char)(tbuf)[j]);
628 printk("\n"); 670 printk("\n");
629 } 671 }
630 usb_unlock_device(dev); 672 usb_unlock_device(dev);
@@ -649,7 +691,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
649 unsigned int tmo, len1, pipe; 691 unsigned int tmo, len1, pipe;
650 int len2; 692 int len2;
651 unsigned char *tbuf; 693 unsigned char *tbuf;
652 int i, ret; 694 int i, j, ret;
653 695
654 if (copy_from_user(&bulk, arg, sizeof(bulk))) 696 if (copy_from_user(&bulk, arg, sizeof(bulk)))
655 return -EFAULT; 697 return -EFAULT;
@@ -674,10 +716,18 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
674 kfree(tbuf); 716 kfree(tbuf);
675 return -EINVAL; 717 return -EINVAL;
676 } 718 }
719 snoop(&dev->dev, "bulk read: len=0x%02x timeout=%04d\n",
720 bulk.len, bulk.timeout);
677 usb_unlock_device(dev); 721 usb_unlock_device(dev);
678 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 722 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
679 usb_lock_device(dev); 723 usb_lock_device(dev);
680 if (!i && len2) { 724 if (!i && len2) {
725 if (usbfs_snoop) {
726 dev_info(&dev->dev, "bulk read: data ");
727 for (j = 0; j < len2; ++j)
728 printk("%02x ", (unsigned char)(tbuf)[j]);
729 printk("\n");
730 }
681 if (copy_to_user(bulk.data, tbuf, len2)) { 731 if (copy_to_user(bulk.data, tbuf, len2)) {
682 kfree(tbuf); 732 kfree(tbuf);
683 return -EFAULT; 733 return -EFAULT;
@@ -690,6 +740,14 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
690 return -EFAULT; 740 return -EFAULT;
691 } 741 }
692 } 742 }
743 snoop(&dev->dev, "bulk write: len=0x%02x timeout=%04d\n",
744 bulk.len, bulk.timeout);
745 if (usbfs_snoop) {
746 dev_info(&dev->dev, "bulk write: data: ");
747 for (j = 0; j < len1; ++j)
748 printk("%02x ", (unsigned char)(tbuf)[j]);
749 printk("\n");
750 }
693 usb_unlock_device(dev); 751 usb_unlock_device(dev);
694 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 752 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
695 usb_lock_device(dev); 753 usb_lock_device(dev);
@@ -835,7 +893,6 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg)
835 return status; 893 return status;
836} 894}
837 895
838
839static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, 896static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
840 struct usbdevfs_iso_packet_desc __user *iso_frame_desc, 897 struct usbdevfs_iso_packet_desc __user *iso_frame_desc,
841 void __user *arg) 898 void __user *arg)
@@ -896,6 +953,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
896 kfree(dr); 953 kfree(dr);
897 return -EFAULT; 954 return -EFAULT;
898 } 955 }
956 snoop(&ps->dev->dev, "control urb\n");
899 break; 957 break;
900 958
901 case USBDEVFS_URB_TYPE_BULK: 959 case USBDEVFS_URB_TYPE_BULK:
@@ -910,6 +968,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
910 return -EINVAL; 968 return -EINVAL;
911 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) 969 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length))
912 return -EFAULT; 970 return -EFAULT;
971 snoop(&ps->dev->dev, "bulk urb\n");
913 break; 972 break;
914 973
915 case USBDEVFS_URB_TYPE_ISO: 974 case USBDEVFS_URB_TYPE_ISO:
@@ -939,6 +998,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
939 return -EINVAL; 998 return -EINVAL;
940 } 999 }
941 uurb->buffer_length = totlen; 1000 uurb->buffer_length = totlen;
1001 snoop(&ps->dev->dev, "iso urb\n");
942 break; 1002 break;
943 1003
944 case USBDEVFS_URB_TYPE_INTERRUPT: 1004 case USBDEVFS_URB_TYPE_INTERRUPT:
@@ -954,6 +1014,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
954 return -EINVAL; 1014 return -EINVAL;
955 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) 1015 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length))
956 return -EFAULT; 1016 return -EFAULT;
1017 snoop(&ps->dev->dev, "interrupt urb\n");
957 break; 1018 break;
958 1019
959 default: 1020 default:
@@ -1003,6 +1064,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1003 return -EFAULT; 1064 return -EFAULT;
1004 } 1065 }
1005 } 1066 }
1067 snoop(&as->urb->dev->dev, "submit urb\n");
1068 snoop_urb(as->urb, as->userurb);
1006 async_newpending(as); 1069 async_newpending(as);
1007 if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { 1070 if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) {
1008 dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); 1071 dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret);
@@ -1238,23 +1301,20 @@ static int proc_releaseinterface(struct dev_state *ps, void __user *arg)
1238 return 0; 1301 return 0;
1239} 1302}
1240 1303
1241static int proc_ioctl (struct dev_state *ps, void __user *arg) 1304static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1242{ 1305{
1243 struct usbdevfs_ioctl ctrl;
1244 int size; 1306 int size;
1245 void *buf = NULL; 1307 void *buf = NULL;
1246 int retval = 0; 1308 int retval = 0;
1247 struct usb_interface *intf = NULL; 1309 struct usb_interface *intf = NULL;
1248 struct usb_driver *driver = NULL; 1310 struct usb_driver *driver = NULL;
1249 1311
1250 /* get input parameters and alloc buffer */ 1312 /* alloc buffer */
1251 if (copy_from_user(&ctrl, arg, sizeof (ctrl))) 1313 if ((size = _IOC_SIZE (ctl->ioctl_code)) > 0) {
1252 return -EFAULT;
1253 if ((size = _IOC_SIZE (ctrl.ioctl_code)) > 0) {
1254 if ((buf = kmalloc (size, GFP_KERNEL)) == NULL) 1314 if ((buf = kmalloc (size, GFP_KERNEL)) == NULL)
1255 return -ENOMEM; 1315 return -ENOMEM;
1256 if ((_IOC_DIR(ctrl.ioctl_code) & _IOC_WRITE)) { 1316 if ((_IOC_DIR(ctl->ioctl_code) & _IOC_WRITE)) {
1257 if (copy_from_user (buf, ctrl.data, size)) { 1317 if (copy_from_user (buf, ctl->data, size)) {
1258 kfree(buf); 1318 kfree(buf);
1259 return -EFAULT; 1319 return -EFAULT;
1260 } 1320 }
@@ -1270,9 +1330,9 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
1270 1330
1271 if (ps->dev->state != USB_STATE_CONFIGURED) 1331 if (ps->dev->state != USB_STATE_CONFIGURED)
1272 retval = -EHOSTUNREACH; 1332 retval = -EHOSTUNREACH;
1273 else if (!(intf = usb_ifnum_to_if (ps->dev, ctrl.ifno))) 1333 else if (!(intf = usb_ifnum_to_if (ps->dev, ctl->ifno)))
1274 retval = -EINVAL; 1334 retval = -EINVAL;
1275 else switch (ctrl.ioctl_code) { 1335 else switch (ctl->ioctl_code) {
1276 1336
1277 /* disconnect kernel driver from interface */ 1337 /* disconnect kernel driver from interface */
1278 case USBDEVFS_DISCONNECT: 1338 case USBDEVFS_DISCONNECT:
@@ -1304,7 +1364,7 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
1304 if (driver == NULL || driver->ioctl == NULL) { 1364 if (driver == NULL || driver->ioctl == NULL) {
1305 retval = -ENOTTY; 1365 retval = -ENOTTY;
1306 } else { 1366 } else {
1307 retval = driver->ioctl (intf, ctrl.ioctl_code, buf); 1367 retval = driver->ioctl (intf, ctl->ioctl_code, buf);
1308 if (retval == -ENOIOCTLCMD) 1368 if (retval == -ENOIOCTLCMD)
1309 retval = -ENOTTY; 1369 retval = -ENOTTY;
1310 } 1370 }
@@ -1313,15 +1373,42 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg)
1313 1373
1314 /* cleanup and return */ 1374 /* cleanup and return */
1315 if (retval >= 0 1375 if (retval >= 0
1316 && (_IOC_DIR (ctrl.ioctl_code) & _IOC_READ) != 0 1376 && (_IOC_DIR (ctl->ioctl_code) & _IOC_READ) != 0
1317 && size > 0 1377 && size > 0
1318 && copy_to_user (ctrl.data, buf, size) != 0) 1378 && copy_to_user (ctl->data, buf, size) != 0)
1319 retval = -EFAULT; 1379 retval = -EFAULT;
1320 1380
1321 kfree(buf); 1381 kfree(buf);
1322 return retval; 1382 return retval;
1323} 1383}
1324 1384
1385static int proc_ioctl_default(struct dev_state *ps, void __user *arg)
1386{
1387 struct usbdevfs_ioctl ctrl;
1388
1389 if (copy_from_user(&ctrl, arg, sizeof (ctrl)))
1390 return -EFAULT;
1391 return proc_ioctl(ps, &ctrl);
1392}
1393
1394#ifdef CONFIG_COMPAT
1395static int proc_ioctl_compat(struct dev_state *ps, void __user *arg)
1396{
1397 struct usbdevfs_ioctl32 __user *uioc;
1398 struct usbdevfs_ioctl ctrl;
1399 u32 udata;
1400
1401 uioc = compat_ptr(arg);
1402 if (get_user(ctrl.ifno, &uioc->ifno) ||
1403 get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
1404 __get_user(udata, &uioc->data))
1405 return -EFAULT;
1406 ctrl.data = compat_ptr(udata);
1407
1408 return proc_ioctl(ps, &ctrl);
1409}
1410#endif
1411
1325/* 1412/*
1326 * NOTE: All requests here that have interface numbers as parameters 1413 * NOTE: All requests here that have interface numbers as parameters
1327 * are assuming that somehow the configuration has been prevented from 1414 * are assuming that somehow the configuration has been prevented from
@@ -1422,6 +1509,10 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1422 ret = proc_reapurbnonblock_compat(ps, p); 1509 ret = proc_reapurbnonblock_compat(ps, p);
1423 break; 1510 break;
1424 1511
1512 case USBDEVFS_IOCTL32:
1513 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__);
1514 ret = proc_ioctl_compat(ps, p);
1515 break;
1425#endif 1516#endif
1426 1517
1427 case USBDEVFS_DISCARDURB: 1518 case USBDEVFS_DISCARDURB:
@@ -1456,7 +1547,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1456 1547
1457 case USBDEVFS_IOCTL: 1548 case USBDEVFS_IOCTL:
1458 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); 1549 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__);
1459 ret = proc_ioctl(ps, p); 1550 ret = proc_ioctl_default(ps, p);
1460 break; 1551 break;
1461 } 1552 }
1462 usb_unlock_device(dev); 1553 usb_unlock_device(dev);
@@ -1488,39 +1579,40 @@ struct file_operations usbfs_device_file_operations = {
1488 .release = usbdev_release, 1579 .release = usbdev_release,
1489}; 1580};
1490 1581
1491struct usb_device *usbdev_lookup_minor(int minor) 1582static void usbdev_add(struct usb_device *dev)
1492{
1493 struct class_device *class_dev;
1494 struct usb_device *dev = NULL;
1495
1496 down(&usb_device_class->sem);
1497 list_for_each_entry(class_dev, &usb_device_class->children, node) {
1498 if (class_dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) {
1499 dev = class_dev->class_data;
1500 break;
1501 }
1502 }
1503 up(&usb_device_class->sem);
1504
1505 return dev;
1506};
1507
1508void usbdev_add(struct usb_device *dev)
1509{ 1583{
1510 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); 1584 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);
1511 1585
1512 dev->class_dev = class_device_create(usb_device_class, 1586 dev->class_dev = class_device_create(usb_device_class, NULL,
1513 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, 1587 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
1514 "usbdev%d.%d", dev->bus->busnum, dev->devnum); 1588 "usbdev%d.%d", dev->bus->busnum, dev->devnum);
1515 1589
1516 dev->class_dev->class_data = dev; 1590 dev->class_dev->class_data = dev;
1517} 1591}
1518 1592
1519void usbdev_remove(struct usb_device *dev) 1593static void usbdev_remove(struct usb_device *dev)
1520{ 1594{
1521 class_device_unregister(dev->class_dev); 1595 class_device_unregister(dev->class_dev);
1522} 1596}
1523 1597
1598static int usbdev_notify(struct notifier_block *self, unsigned long action,
1599 void *dev)
1600{
1601 switch (action) {
1602 case USB_DEVICE_ADD:
1603 usbdev_add(dev);
1604 break;
1605 case USB_DEVICE_REMOVE:
1606 usbdev_remove(dev);
1607 break;
1608 }
1609 return NOTIFY_OK;
1610}
1611
1612static struct notifier_block usbdev_nb = {
1613 .notifier_call = usbdev_notify,
1614};
1615
1524static struct cdev usb_device_cdev = { 1616static struct cdev usb_device_cdev = {
1525 .kobj = {.name = "usb_device", }, 1617 .kobj = {.name = "usb_device", },
1526 .owner = THIS_MODULE, 1618 .owner = THIS_MODULE,
@@ -1540,24 +1632,32 @@ int __init usbdev_init(void)
1540 retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX); 1632 retval = cdev_add(&usb_device_cdev, USB_DEVICE_DEV, USB_DEVICE_MAX);
1541 if (retval) { 1633 if (retval) {
1542 err("unable to get usb_device major %d", USB_DEVICE_MAJOR); 1634 err("unable to get usb_device major %d", USB_DEVICE_MAJOR);
1543 unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); 1635 goto error_cdev;
1544 goto out;
1545 } 1636 }
1546 usb_device_class = class_create(THIS_MODULE, "usb_device"); 1637 usb_device_class = class_create(THIS_MODULE, "usb_device");
1547 if (IS_ERR(usb_device_class)) { 1638 if (IS_ERR(usb_device_class)) {
1548 err("unable to register usb_device class"); 1639 err("unable to register usb_device class");
1549 retval = PTR_ERR(usb_device_class); 1640 retval = PTR_ERR(usb_device_class);
1550 usb_device_class = NULL; 1641 goto error_class;
1551 cdev_del(&usb_device_cdev);
1552 unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX);
1553 } 1642 }
1554 1643
1644 usb_register_notify(&usbdev_nb);
1645
1555out: 1646out:
1556 return retval; 1647 return retval;
1648
1649error_class:
1650 usb_device_class = NULL;
1651 cdev_del(&usb_device_cdev);
1652
1653error_cdev:
1654 unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX);
1655 goto out;
1557} 1656}
1558 1657
1559void usbdev_cleanup(void) 1658void usbdev_cleanup(void)
1560{ 1659{
1660 usb_unregister_notify(&usbdev_nb);
1561 class_destroy(usb_device_class); 1661 class_destroy(usb_device_class);
1562 cdev_del(&usb_device_cdev); 1662 cdev_del(&usb_device_cdev);
1563 unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX); 1663 unregister_chrdev_region(USB_DEVICE_DEV, USB_DEVICE_MAX);
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 65ca131cc44c..e695308095ae 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -17,7 +17,6 @@
17 17
18#include <linux/config.h> 18#include <linux/config.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/devfs_fs_kernel.h>
21#include <linux/spinlock.h> 20#include <linux/spinlock.h>
22#include <linux/errno.h> 21#include <linux/errno.h>
23 22
@@ -88,8 +87,6 @@ int usb_major_init(void)
88 goto out; 87 goto out;
89 } 88 }
90 89
91 devfs_mk_dir("usb");
92
93out: 90out:
94 return error; 91 return error;
95} 92}
@@ -97,7 +94,6 @@ out:
97void usb_major_cleanup(void) 94void usb_major_cleanup(void)
98{ 95{
99 class_destroy(usb_class); 96 class_destroy(usb_class);
100 devfs_remove("usb");
101 unregister_chrdev(USB_MAJOR, "usb"); 97 unregister_chrdev(USB_MAJOR, "usb");
102} 98}
103 99
@@ -112,8 +108,7 @@ void usb_major_cleanup(void)
112 * enabled, the minor number will be based on the next available free minor, 108 * enabled, the minor number will be based on the next available free minor,
113 * starting at the class_driver->minor_base. 109 * starting at the class_driver->minor_base.
114 * 110 *
115 * This function also creates the devfs file for the usb device, if devfs 111 * This function also creates a usb class device in the sysfs tree.
116 * is enabled, and creates a usb class device in the sysfs tree.
117 * 112 *
118 * usb_deregister_dev() must be called when the driver is done with 113 * usb_deregister_dev() must be called when the driver is done with
119 * the minor numbers given out by this function. 114 * the minor numbers given out by this function.
@@ -162,22 +157,20 @@ int usb_register_dev(struct usb_interface *intf,
162 157
163 intf->minor = minor; 158 intf->minor = minor;
164 159
165 /* handle the devfs registration */
166 snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base);
167 devfs_mk_cdev(MKDEV(USB_MAJOR, minor), class_driver->mode, name);
168
169 /* create a usb class device for this usb interface */ 160 /* create a usb class device for this usb interface */
161 snprintf(name, BUS_ID_SIZE, class_driver->name, minor - minor_base);
170 temp = strrchr(name, '/'); 162 temp = strrchr(name, '/');
171 if (temp && (temp[1] != 0x00)) 163 if (temp && (temp[1] != 0x00))
172 ++temp; 164 ++temp;
173 else 165 else
174 temp = name; 166 temp = name;
175 intf->class_dev = class_device_create(usb_class, MKDEV(USB_MAJOR, minor), &intf->dev, "%s", temp); 167 intf->class_dev = class_device_create(usb_class, NULL,
168 MKDEV(USB_MAJOR, minor),
169 &intf->dev, "%s", temp);
176 if (IS_ERR(intf->class_dev)) { 170 if (IS_ERR(intf->class_dev)) {
177 spin_lock (&minor_lock); 171 spin_lock (&minor_lock);
178 usb_minors[intf->minor] = NULL; 172 usb_minors[intf->minor] = NULL;
179 spin_unlock (&minor_lock); 173 spin_unlock (&minor_lock);
180 devfs_remove (name);
181 retval = PTR_ERR(intf->class_dev); 174 retval = PTR_ERR(intf->class_dev);
182 } 175 }
183exit: 176exit:
@@ -195,9 +188,8 @@ EXPORT_SYMBOL(usb_register_dev);
195 * call to usb_register_dev() (usually when the device is disconnected 188 * call to usb_register_dev() (usually when the device is disconnected
196 * from the system.) 189 * from the system.)
197 * 190 *
198 * This function also cleans up the devfs file for the usb device, if devfs 191 * This function also removes the usb class device from the sysfs tree.
199 * is enabled, and removes the usb class device from the sysfs tree. 192 *
200 *
201 * This should be called by all drivers that use the USB major number. 193 * This should be called by all drivers that use the USB major number.
202 */ 194 */
203void usb_deregister_dev(struct usb_interface *intf, 195void usb_deregister_dev(struct usb_interface *intf,
@@ -220,7 +212,6 @@ void usb_deregister_dev(struct usb_interface *intf,
220 spin_unlock (&minor_lock); 212 spin_unlock (&minor_lock);
221 213
222 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); 214 snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
223 devfs_remove (name);
224 class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor)); 215 class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor));
225 intf->class_dev = NULL; 216 intf->class_dev = NULL;
226 intf->minor = -1; 217 intf->minor = -1;
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 6385d1a99b60..84d9e69329bb 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -30,6 +30,8 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <linux/usb.h> 32#include <linux/usb.h>
33
34#include "usb.h"
33#include "hcd.h" 35#include "hcd.h"
34 36
35 37
@@ -197,6 +199,26 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
197 199
198 hcd = pci_get_drvdata(dev); 200 hcd = pci_get_drvdata(dev);
199 201
202 /* Root hub suspend should have stopped all downstream traffic,
203 * and all bus master traffic. And done so for both the interface
204 * and the stub usb_device (which we check here). But maybe it
205 * didn't; writing sysfs power/state files ignores such rules...
206 *
207 * We must ignore the FREEZE vs SUSPEND distinction here, because
208 * otherwise the swsusp will save (and restore) garbage state.
209 */
210 if (hcd->self.root_hub->dev.power.power_state.event == PM_EVENT_ON)
211 return -EBUSY;
212
213 if (hcd->driver->suspend) {
214 retval = hcd->driver->suspend(hcd, message);
215 if (retval) {
216 dev_dbg (&dev->dev, "PCI pre-suspend fail, %d\n",
217 retval);
218 goto done;
219 }
220 }
221
200 /* FIXME until the generic PM interfaces change a lot more, this 222 /* FIXME until the generic PM interfaces change a lot more, this
201 * can't use PCI D1 and D2 states. For example, the confusion 223 * can't use PCI D1 and D2 states. For example, the confusion
202 * between messages and states will need to vanish, and messages 224 * between messages and states will need to vanish, and messages
@@ -215,31 +237,13 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
215 */ 237 */
216 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 238 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
217 239
218 switch (hcd->state) { 240 /* Downstream ports from this root hub should already be quiesced, so
219 241 * there will be no DMA activity. Now we can shut down the upstream
220 /* entry if root hub wasn't yet suspended ... from sysfs, 242 * link (except maybe for PME# resume signaling) and enter some PCI
221 * without autosuspend, or if USB_SUSPEND isn't configured. 243 * low power state, if the hardware allows.
222 */ 244 */
223 case HC_STATE_RUNNING: 245 if (hcd->state == HC_STATE_SUSPENDED) {
224 hcd->state = HC_STATE_QUIESCING;
225 retval = hcd->driver->suspend (hcd, message);
226 if (retval) {
227 dev_dbg (hcd->self.controller,
228 "suspend fail, retval %d\n",
229 retval);
230 break;
231 }
232 hcd->state = HC_STATE_SUSPENDED;
233 /* FALLTHROUGH */
234 246
235 /* entry with CONFIG_USB_SUSPEND, or hcds that autosuspend: the
236 * controller and/or root hub will already have been suspended,
237 * but it won't be ready for a PCI resume call.
238 *
239 * FIXME only CONFIG_USB_SUSPEND guarantees hub_suspend() will
240 * have been called, otherwise root hub timers still run ...
241 */
242 case HC_STATE_SUSPENDED:
243 /* no DMA or IRQs except when HC is active */ 247 /* no DMA or IRQs except when HC is active */
244 if (dev->current_state == PCI_D0) { 248 if (dev->current_state == PCI_D0) {
245 pci_save_state (dev); 249 pci_save_state (dev);
@@ -248,7 +252,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
248 252
249 if (!has_pci_pm) { 253 if (!has_pci_pm) {
250 dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n"); 254 dev_dbg (hcd->self.controller, "--> PCI D0/legacy\n");
251 break; 255 goto done;
252 } 256 }
253 257
254 /* NOTE: dev->current_state becomes nonzero only here, and 258 /* NOTE: dev->current_state becomes nonzero only here, and
@@ -259,28 +263,29 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
259 retval = pci_set_power_state (dev, PCI_D3hot); 263 retval = pci_set_power_state (dev, PCI_D3hot);
260 if (retval == 0) { 264 if (retval == 0) {
261 dev_dbg (hcd->self.controller, "--> PCI D3\n"); 265 dev_dbg (hcd->self.controller, "--> PCI D3\n");
262 retval = pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup); 266
263 if (retval) 267 /* Ignore these return values. We rely on pci code to
264 break; 268 * reject requests the hardware can't implement, rather
265 retval = pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup); 269 * than coding the same thing.
266 } else if (retval < 0) { 270 */
271 (void) pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup);
272 (void) pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup);
273 } else {
267 dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n", 274 dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n",
268 retval); 275 retval);
269 (void) usb_hcd_pci_resume (dev); 276 (void) usb_hcd_pci_resume (dev);
270 break;
271 } 277 }
272 break; 278
273 default: 279 } else {
274 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", 280 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n",
275 hcd->state); 281 hcd->state);
276 WARN_ON(1); 282 WARN_ON(1);
277 retval = -EINVAL; 283 retval = -EINVAL;
278 break;
279 } 284 }
280 285
281 /* update power_state **ONLY** to make sysfs happier */ 286done:
282 if (retval == 0) 287 if (retval == 0)
283 dev->dev.power.power_state = message; 288 dev->dev.power.power_state = PMSG_SUSPEND;
284 return retval; 289 return retval;
285} 290}
286EXPORT_SYMBOL (usb_hcd_pci_suspend); 291EXPORT_SYMBOL (usb_hcd_pci_suspend);
@@ -336,20 +341,9 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
336 dev->current_state); 341 dev->current_state);
337 } 342 }
338#endif 343#endif
339 retval = pci_enable_wake (dev, dev->current_state, 0); 344 /* yes, ignore these results too... */
340 if (retval) { 345 (void) pci_enable_wake (dev, dev->current_state, 0);
341 dev_err(hcd->self.controller, 346 (void) pci_enable_wake (dev, PCI_D3cold, 0);
342 "can't enable_wake to %d, %d!\n",
343 dev->current_state, retval);
344 return retval;
345 }
346 retval = pci_enable_wake (dev, PCI_D3cold, 0);
347 if (retval) {
348 dev_err(hcd->self.controller,
349 "can't enable_wake to %d, %d!\n",
350 PCI_D3cold, retval);
351 return retval;
352 }
353 } else { 347 } else {
354 /* Same basic cases: clean (powered/not), dirty */ 348 /* Same basic cases: clean (powered/not), dirty */
355 dev_dbg(hcd->self.controller, "PCI legacy resume\n"); 349 dev_dbg(hcd->self.controller, "PCI legacy resume\n");
@@ -371,17 +365,17 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
371 365
372 dev->dev.power.power_state = PMSG_ON; 366 dev->dev.power.power_state = PMSG_ON;
373 367
374 hcd->state = HC_STATE_RESUMING;
375 hcd->saw_irq = 0; 368 hcd->saw_irq = 0;
376 369
377 retval = hcd->driver->resume (hcd); 370 if (hcd->driver->resume) {
378 if (!HC_IS_RUNNING (hcd->state)) { 371 retval = hcd->driver->resume(hcd);
379 dev_dbg (hcd->self.controller, 372 if (retval) {
380 "resume fail, retval %d\n", retval); 373 dev_err (hcd->self.controller,
381 usb_hc_died (hcd); 374 "PCI post-resume error %d!\n", retval);
375 usb_hc_died (hcd);
376 }
382 } 377 }
383 378
384 retval = pci_enable_device(dev);
385 return retval; 379 return retval;
386} 380}
387EXPORT_SYMBOL (usb_hcd_pci_resume); 381EXPORT_SYMBOL (usb_hcd_pci_resume);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1017a97a418b..6c7ca5b08cd6 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -130,7 +130,7 @@ static const u8 usb2_rh_dev_descriptor [18] = {
130 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 130 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
131 0x00, /* __u8 bDeviceSubClass; */ 131 0x00, /* __u8 bDeviceSubClass; */
132 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/ 132 0x01, /* __u8 bDeviceProtocol; [ usb 2.0 single TT ]*/
133 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ 133 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */
134 134
135 0x00, 0x00, /* __le16 idVendor; */ 135 0x00, 0x00, /* __le16 idVendor; */
136 0x00, 0x00, /* __le16 idProduct; */ 136 0x00, 0x00, /* __le16 idProduct; */
@@ -153,7 +153,7 @@ static const u8 usb11_rh_dev_descriptor [18] = {
153 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 153 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */
154 0x00, /* __u8 bDeviceSubClass; */ 154 0x00, /* __u8 bDeviceSubClass; */
155 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */ 155 0x00, /* __u8 bDeviceProtocol; [ low/full speeds only ] */
156 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ 156 0x40, /* __u8 bMaxPacketSize0; 64 Bytes */
157 157
158 0x00, 0x00, /* __le16 idVendor; */ 158 0x00, 0x00, /* __le16 idVendor; */
159 0x00, 0x00, /* __le16 idProduct; */ 159 0x00, 0x00, /* __le16 idProduct; */
@@ -458,22 +458,18 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb)
458 458
459 default: 459 default:
460 /* non-generic request */ 460 /* non-generic request */
461 if (HC_IS_SUSPENDED (hcd->state)) 461 switch (typeReq) {
462 status = -EAGAIN; 462 case GetHubStatus:
463 else { 463 case GetPortStatus:
464 switch (typeReq) { 464 len = 4;
465 case GetHubStatus: 465 break;
466 case GetPortStatus: 466 case GetHubDescriptor:
467 len = 4; 467 len = sizeof (struct usb_hub_descriptor);
468 break; 468 break;
469 case GetHubDescriptor:
470 len = sizeof (struct usb_hub_descriptor);
471 break;
472 }
473 status = hcd->driver->hub_control (hcd,
474 typeReq, wValue, wIndex,
475 tbuf, wLength);
476 } 469 }
470 status = hcd->driver->hub_control (hcd,
471 typeReq, wValue, wIndex,
472 tbuf, wLength);
477 break; 473 break;
478error: 474error:
479 /* "protocol stall" on error */ 475 /* "protocol stall" on error */
@@ -487,7 +483,7 @@ error:
487 "CTRL: TypeReq=0x%x val=0x%x " 483 "CTRL: TypeReq=0x%x val=0x%x "
488 "idx=0x%x len=%d ==> %d\n", 484 "idx=0x%x len=%d ==> %d\n",
489 typeReq, wValue, wIndex, 485 typeReq, wValue, wIndex,
490 wLength, urb->status); 486 wLength, status);
491 } 487 }
492 } 488 }
493 if (len) { 489 if (len) {
@@ -748,10 +744,9 @@ struct usb_bus *usb_alloc_bus (struct usb_operations *op)
748{ 744{
749 struct usb_bus *bus; 745 struct usb_bus *bus;
750 746
751 bus = kmalloc (sizeof *bus, GFP_KERNEL); 747 bus = kzalloc (sizeof *bus, GFP_KERNEL);
752 if (!bus) 748 if (!bus)
753 return NULL; 749 return NULL;
754 memset(bus, 0, sizeof(struct usb_bus));
755 usb_bus_init (bus); 750 usb_bus_init (bus);
756 bus->op = op; 751 bus->op = op;
757 return bus; 752 return bus;
@@ -782,7 +777,8 @@ static int usb_register_bus(struct usb_bus *bus)
782 return -E2BIG; 777 return -E2BIG;
783 } 778 }
784 779
785 bus->class_dev = class_device_create(usb_host_class, MKDEV(0,0), bus->controller, "usb_host%d", busnum); 780 bus->class_dev = class_device_create(usb_host_class, NULL, MKDEV(0,0),
781 bus->controller, "usb_host%d", busnum);
786 if (IS_ERR(bus->class_dev)) { 782 if (IS_ERR(bus->class_dev)) {
787 clear_bit(busnum, busmap.busmap); 783 clear_bit(busnum, busmap.busmap);
788 up(&usb_bus_list_lock); 784 up(&usb_bus_list_lock);
@@ -795,8 +791,7 @@ static int usb_register_bus(struct usb_bus *bus)
795 list_add (&bus->bus_list, &usb_bus_list); 791 list_add (&bus->bus_list, &usb_bus_list);
796 up (&usb_bus_list_lock); 792 up (&usb_bus_list_lock);
797 793
798 usbfs_add_bus (bus); 794 usb_notify_add_bus(bus);
799 usbmon_notify_bus_add (bus);
800 795
801 dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum); 796 dev_info (bus->controller, "new USB bus registered, assigned bus number %d\n", bus->busnum);
802 return 0; 797 return 0;
@@ -823,8 +818,7 @@ static void usb_deregister_bus (struct usb_bus *bus)
823 list_del (&bus->bus_list); 818 list_del (&bus->bus_list);
824 up (&usb_bus_list_lock); 819 up (&usb_bus_list_lock);
825 820
826 usbmon_notify_bus_remove (bus); 821 usb_notify_remove_bus(bus);
827 usbfs_remove_bus (bus);
828 822
829 clear_bit (bus->busnum, busmap.busmap); 823 clear_bit (bus->busnum, busmap.busmap);
830 824
@@ -1112,7 +1106,7 @@ static void urb_unlink (struct urb *urb)
1112 * expects usb_submit_urb() to have sanity checked and conditioned all 1106 * expects usb_submit_urb() to have sanity checked and conditioned all
1113 * inputs in the urb 1107 * inputs in the urb
1114 */ 1108 */
1115static int hcd_submit_urb (struct urb *urb, unsigned mem_flags) 1109static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1116{ 1110{
1117 int status; 1111 int status;
1118 struct usb_hcd *hcd = urb->dev->bus->hcpriv; 1112 struct usb_hcd *hcd = urb->dev->bus->hcpriv;
@@ -1142,10 +1136,20 @@ static int hcd_submit_urb (struct urb *urb, unsigned mem_flags)
1142 else switch (hcd->state) { 1136 else switch (hcd->state) {
1143 case HC_STATE_RUNNING: 1137 case HC_STATE_RUNNING:
1144 case HC_STATE_RESUMING: 1138 case HC_STATE_RESUMING:
1139doit:
1145 usb_get_dev (urb->dev); 1140 usb_get_dev (urb->dev);
1146 list_add_tail (&urb->urb_list, &ep->urb_list); 1141 list_add_tail (&urb->urb_list, &ep->urb_list);
1147 status = 0; 1142 status = 0;
1148 break; 1143 break;
1144 case HC_STATE_SUSPENDED:
1145 /* HC upstream links (register access, wakeup signaling) can work
1146 * even when the downstream links (and DMA etc) are quiesced; let
1147 * usbcore talk to the root hub.
1148 */
1149 if (hcd->self.controller->power.power_state.event == PM_EVENT_ON
1150 && urb->dev->parent == NULL)
1151 goto doit;
1152 /* FALL THROUGH */
1149 default: 1153 default:
1150 status = -ESHUTDOWN; 1154 status = -ESHUTDOWN;
1151 break; 1155 break;
@@ -1293,12 +1297,6 @@ static int hcd_unlink_urb (struct urb *urb, int status)
1293 goto done; 1297 goto done;
1294 } 1298 }
1295 1299
1296 /* running ~= hc unlink handshake works (irq, timer, etc)
1297 * halted ~= no unlink handshake is needed
1298 * suspended, resuming == should never happen
1299 */
1300 WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT);
1301
1302 /* insist the urb is still queued */ 1300 /* insist the urb is still queued */
1303 list_for_each(tmp, &ep->urb_list) { 1301 list_for_each(tmp, &ep->urb_list) {
1304 if (tmp == &urb->urb_list) 1302 if (tmp == &urb->urb_list)
@@ -1430,28 +1428,92 @@ rescan:
1430 1428
1431/*-------------------------------------------------------------------------*/ 1429/*-------------------------------------------------------------------------*/
1432 1430
1433#ifdef CONFIG_USB_SUSPEND 1431#ifdef CONFIG_PM
1434 1432
1435static int hcd_hub_suspend (struct usb_bus *bus) 1433int hcd_bus_suspend (struct usb_bus *bus)
1436{ 1434{
1437 struct usb_hcd *hcd; 1435 struct usb_hcd *hcd;
1436 int status;
1438 1437
1439 hcd = container_of (bus, struct usb_hcd, self); 1438 hcd = container_of (bus, struct usb_hcd, self);
1440 if (hcd->driver->hub_suspend) 1439 if (!hcd->driver->bus_suspend)
1441 return hcd->driver->hub_suspend (hcd); 1440 return -ENOENT;
1442 return 0; 1441 hcd->state = HC_STATE_QUIESCING;
1442 status = hcd->driver->bus_suspend (hcd);
1443 if (status == 0)
1444 hcd->state = HC_STATE_SUSPENDED;
1445 else
1446 dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n",
1447 "suspend", status);
1448 return status;
1443} 1449}
1444 1450
1445static int hcd_hub_resume (struct usb_bus *bus) 1451int hcd_bus_resume (struct usb_bus *bus)
1446{ 1452{
1447 struct usb_hcd *hcd; 1453 struct usb_hcd *hcd;
1454 int status;
1448 1455
1449 hcd = container_of (bus, struct usb_hcd, self); 1456 hcd = container_of (bus, struct usb_hcd, self);
1450 if (hcd->driver->hub_resume) 1457 if (!hcd->driver->bus_resume)
1451 return hcd->driver->hub_resume (hcd); 1458 return -ENOENT;
1452 return 0; 1459 if (hcd->state == HC_STATE_RUNNING)
1460 return 0;
1461 hcd->state = HC_STATE_RESUMING;
1462 status = hcd->driver->bus_resume (hcd);
1463 if (status == 0)
1464 hcd->state = HC_STATE_RUNNING;
1465 else {
1466 dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n",
1467 "resume", status);
1468 usb_hc_died(hcd);
1469 }
1470 return status;
1453} 1471}
1454 1472
1473/*
1474 * usb_hcd_suspend_root_hub - HCD autosuspends downstream ports
1475 * @hcd: host controller for this root hub
1476 *
1477 * This call arranges that usb_hcd_resume_root_hub() is safe to call later;
1478 * that the HCD's root hub polling is deactivated; and that the root's hub
1479 * driver is suspended. HCDs may call this to autosuspend when their root
1480 * hub's downstream ports are all inactive: unpowered, disconnected,
1481 * disabled, or suspended.
1482 *
1483 * The HCD will autoresume on device connect change detection (using SRP
1484 * or a D+/D- pullup). The HCD also autoresumes on remote wakeup signaling
1485 * from any ports that are suspended (if that is enabled). In most cases,
1486 * overcurrent signaling (on powered ports) will also start autoresume.
1487 *
1488 * Always called with IRQs blocked.
1489 */
1490void usb_hcd_suspend_root_hub (struct usb_hcd *hcd)
1491{
1492 struct urb *urb;
1493
1494 spin_lock (&hcd_root_hub_lock);
1495 usb_suspend_root_hub (hcd->self.root_hub);
1496
1497 /* force status urb to complete/unlink while suspended */
1498 if (hcd->status_urb) {
1499 urb = hcd->status_urb;
1500 urb->status = -ECONNRESET;
1501 urb->hcpriv = NULL;
1502 urb->actual_length = 0;
1503
1504 del_timer (&hcd->rh_timer);
1505 hcd->poll_pending = 0;
1506 hcd->status_urb = NULL;
1507 } else
1508 urb = NULL;
1509 spin_unlock (&hcd_root_hub_lock);
1510 hcd->state = HC_STATE_SUSPENDED;
1511
1512 if (urb)
1513 usb_hcd_giveback_urb (hcd, urb, NULL);
1514}
1515EXPORT_SYMBOL_GPL(usb_hcd_suspend_root_hub);
1516
1455/** 1517/**
1456 * usb_hcd_resume_root_hub - called by HCD to resume its root hub 1518 * usb_hcd_resume_root_hub - called by HCD to resume its root hub
1457 * @hcd: host controller for this root hub 1519 * @hcd: host controller for this root hub
@@ -1459,7 +1521,7 @@ static int hcd_hub_resume (struct usb_bus *bus)
1459 * The USB host controller calls this function when its root hub is 1521 * The USB host controller calls this function when its root hub is
1460 * suspended (with the remote wakeup feature enabled) and a remote 1522 * suspended (with the remote wakeup feature enabled) and a remote
1461 * wakeup request is received. It queues a request for khubd to 1523 * wakeup request is received. It queues a request for khubd to
1462 * resume the root hub. 1524 * resume the root hub (that is, manage its downstream ports again).
1463 */ 1525 */
1464void usb_hcd_resume_root_hub (struct usb_hcd *hcd) 1526void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
1465{ 1527{
@@ -1470,13 +1532,9 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
1470 usb_resume_root_hub (hcd->self.root_hub); 1532 usb_resume_root_hub (hcd->self.root_hub);
1471 spin_unlock_irqrestore (&hcd_root_hub_lock, flags); 1533 spin_unlock_irqrestore (&hcd_root_hub_lock, flags);
1472} 1534}
1535EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
1473 1536
1474#else
1475void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
1476{
1477}
1478#endif 1537#endif
1479EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
1480 1538
1481/*-------------------------------------------------------------------------*/ 1539/*-------------------------------------------------------------------------*/
1482 1540
@@ -1529,10 +1587,6 @@ static struct usb_operations usb_hcd_operations = {
1529 .buffer_alloc = hcd_buffer_alloc, 1587 .buffer_alloc = hcd_buffer_alloc,
1530 .buffer_free = hcd_buffer_free, 1588 .buffer_free = hcd_buffer_free,
1531 .disable = hcd_endpoint_disable, 1589 .disable = hcd_endpoint_disable,
1532#ifdef CONFIG_USB_SUSPEND
1533 .hub_suspend = hcd_hub_suspend,
1534 .hub_resume = hcd_hub_resume,
1535#endif
1536}; 1590};
1537 1591
1538/*-------------------------------------------------------------------------*/ 1592/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index ac451fa7e4d2..24a62a2ff86d 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -142,22 +142,18 @@ struct hcd_timeout { /* timeouts we allocate */
142 142
143struct usb_operations { 143struct usb_operations {
144 int (*get_frame_number) (struct usb_device *usb_dev); 144 int (*get_frame_number) (struct usb_device *usb_dev);
145 int (*submit_urb) (struct urb *urb, unsigned mem_flags); 145 int (*submit_urb) (struct urb *urb, gfp_t mem_flags);
146 int (*unlink_urb) (struct urb *urb, int status); 146 int (*unlink_urb) (struct urb *urb, int status);
147 147
148 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */ 148 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
149 void *(*buffer_alloc)(struct usb_bus *bus, size_t size, 149 void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
150 unsigned mem_flags, 150 gfp_t mem_flags,
151 dma_addr_t *dma); 151 dma_addr_t *dma);
152 void (*buffer_free)(struct usb_bus *bus, size_t size, 152 void (*buffer_free)(struct usb_bus *bus, size_t size,
153 void *addr, dma_addr_t dma); 153 void *addr, dma_addr_t dma);
154 154
155 void (*disable)(struct usb_device *udev, 155 void (*disable)(struct usb_device *udev,
156 struct usb_host_endpoint *ep); 156 struct usb_host_endpoint *ep);
157
158 /* global suspend/resume of bus */
159 int (*hub_suspend)(struct usb_bus *);
160 int (*hub_resume)(struct usb_bus *);
161}; 157};
162 158
163/* each driver provides one of these, and hardware init support */ 159/* each driver provides one of these, and hardware init support */
@@ -182,12 +178,12 @@ struct hc_driver {
182 int (*start) (struct usb_hcd *hcd); 178 int (*start) (struct usb_hcd *hcd);
183 179
184 /* NOTE: these suspend/resume calls relate to the HC as 180 /* NOTE: these suspend/resume calls relate to the HC as
185 * a whole, not just the root hub; they're for bus glue. 181 * a whole, not just the root hub; they're for PCI bus glue.
186 */ 182 */
187 /* called after all devices were suspended */ 183 /* called after suspending the hub, before entering D3 etc */
188 int (*suspend) (struct usb_hcd *hcd, pm_message_t message); 184 int (*suspend) (struct usb_hcd *hcd, pm_message_t message);
189 185
190 /* called before any devices get resumed */ 186 /* called after entering D0 (etc), before resuming the hub */
191 int (*resume) (struct usb_hcd *hcd); 187 int (*resume) (struct usb_hcd *hcd);
192 188
193 /* cleanly make HCD stop writing memory and doing I/O */ 189 /* cleanly make HCD stop writing memory and doing I/O */
@@ -200,7 +196,7 @@ struct hc_driver {
200 int (*urb_enqueue) (struct usb_hcd *hcd, 196 int (*urb_enqueue) (struct usb_hcd *hcd,
201 struct usb_host_endpoint *ep, 197 struct usb_host_endpoint *ep,
202 struct urb *urb, 198 struct urb *urb,
203 unsigned mem_flags); 199 gfp_t mem_flags);
204 int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb); 200 int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
205 201
206 /* hw synch, freeing endpoint resources that urb_dequeue can't */ 202 /* hw synch, freeing endpoint resources that urb_dequeue can't */
@@ -212,8 +208,8 @@ struct hc_driver {
212 int (*hub_control) (struct usb_hcd *hcd, 208 int (*hub_control) (struct usb_hcd *hcd,
213 u16 typeReq, u16 wValue, u16 wIndex, 209 u16 typeReq, u16 wValue, u16 wIndex,
214 char *buf, u16 wLength); 210 char *buf, u16 wLength);
215 int (*hub_suspend)(struct usb_hcd *); 211 int (*bus_suspend)(struct usb_hcd *);
216 int (*hub_resume)(struct usb_hcd *); 212 int (*bus_resume)(struct usb_hcd *);
217 int (*start_port_reset)(struct usb_hcd *, unsigned port_num); 213 int (*start_port_reset)(struct usb_hcd *, unsigned port_num);
218 void (*hub_irq_enable)(struct usb_hcd *); 214 void (*hub_irq_enable)(struct usb_hcd *);
219 /* Needed only if port-change IRQs are level-triggered */ 215 /* Needed only if port-change IRQs are level-triggered */
@@ -247,7 +243,7 @@ int hcd_buffer_create (struct usb_hcd *hcd);
247void hcd_buffer_destroy (struct usb_hcd *hcd); 243void hcd_buffer_destroy (struct usb_hcd *hcd);
248 244
249void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, 245void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,
250 unsigned mem_flags, dma_addr_t *dma); 246 gfp_t mem_flags, dma_addr_t *dma);
251void hcd_buffer_free (struct usb_bus *bus, size_t size, 247void hcd_buffer_free (struct usb_bus *bus, size_t size,
252 void *addr, dma_addr_t dma); 248 void *addr, dma_addr_t dma);
253 249
@@ -355,8 +351,6 @@ extern long usb_calc_bus_time (int speed, int is_input,
355 351
356extern struct usb_bus *usb_alloc_bus (struct usb_operations *); 352extern struct usb_bus *usb_alloc_bus (struct usb_operations *);
357 353
358extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);
359
360extern void usb_set_device_state(struct usb_device *udev, 354extern void usb_set_device_state(struct usb_device *udev,
361 enum usb_device_state new_state); 355 enum usb_device_state new_state);
362 356
@@ -378,6 +372,33 @@ extern int usb_find_interface_driver (struct usb_device *dev,
378 372
379#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) 373#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
380 374
375#ifdef CONFIG_PM
376extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd);
377extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);
378extern int hcd_bus_suspend (struct usb_bus *bus);
379extern int hcd_bus_resume (struct usb_bus *bus);
380#else
381static inline void usb_hcd_suspend_root_hub(struct usb_hcd *hcd)
382{
383 return;
384}
385
386static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
387{
388 return;
389}
390
391static inline int hcd_bus_suspend(struct usb_bus *bus)
392{
393 return 0;
394}
395
396static inline int hcd_bus_resume (struct usb_bus *bus)
397{
398 return 0;
399}
400#endif /* CONFIG_PM */
401
381/* 402/*
382 * USB device fs stuff 403 * USB device fs stuff
383 */ 404 */
@@ -388,23 +409,13 @@ extern int usb_find_interface_driver (struct usb_device *dev,
388 * these are expected to be called from the USB core/hub thread 409 * these are expected to be called from the USB core/hub thread
389 * with the kernel lock held 410 * with the kernel lock held
390 */ 411 */
391extern void usbfs_add_bus(struct usb_bus *bus);
392extern void usbfs_remove_bus(struct usb_bus *bus);
393extern void usbfs_add_device(struct usb_device *dev);
394extern void usbfs_remove_device(struct usb_device *dev);
395extern void usbfs_update_special (void); 412extern void usbfs_update_special (void);
396
397extern int usbfs_init(void); 413extern int usbfs_init(void);
398extern void usbfs_cleanup(void); 414extern void usbfs_cleanup(void);
399 415
400#else /* CONFIG_USB_DEVICEFS */ 416#else /* CONFIG_USB_DEVICEFS */
401 417
402static inline void usbfs_add_bus(struct usb_bus *bus) {}
403static inline void usbfs_remove_bus(struct usb_bus *bus) {}
404static inline void usbfs_add_device(struct usb_device *dev) {}
405static inline void usbfs_remove_device(struct usb_device *dev) {}
406static inline void usbfs_update_special (void) {} 418static inline void usbfs_update_special (void) {}
407
408static inline int usbfs_init(void) { return 0; } 419static inline int usbfs_init(void) { return 0; }
409static inline void usbfs_cleanup(void) { } 420static inline void usbfs_cleanup(void) { }
410 421
@@ -419,8 +430,6 @@ struct usb_mon_operations {
419 void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err); 430 void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err);
420 void (*urb_complete)(struct usb_bus *bus, struct urb *urb); 431 void (*urb_complete)(struct usb_bus *bus, struct urb *urb);
421 /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */ 432 /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
422 void (*bus_add)(struct usb_bus *bus);
423 void (*bus_remove)(struct usb_bus *bus);
424}; 433};
425 434
426extern struct usb_mon_operations *mon_ops; 435extern struct usb_mon_operations *mon_ops;
@@ -443,18 +452,6 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb)
443 if (bus->monitored) 452 if (bus->monitored)
444 (*mon_ops->urb_complete)(bus, urb); 453 (*mon_ops->urb_complete)(bus, urb);
445} 454}
446
447static inline void usbmon_notify_bus_add(struct usb_bus *bus)
448{
449 if (mon_ops)
450 (*mon_ops->bus_add)(bus);
451}
452
453static inline void usbmon_notify_bus_remove(struct usb_bus *bus)
454{
455 if (mon_ops)
456 (*mon_ops->bus_remove)(bus);
457}
458 455
459int usb_mon_register(struct usb_mon_operations *ops); 456int usb_mon_register(struct usb_mon_operations *ops);
460void usb_mon_deregister(void); 457void usb_mon_deregister(void);
@@ -465,8 +462,6 @@ static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {}
465static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb, 462static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
466 int error) {} 463 int error) {}
467static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {} 464static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb) {}
468static inline void usbmon_notify_bus_add(struct usb_bus *bus) {}
469static inline void usbmon_notify_bus_remove(struct usb_bus *bus) {}
470 465
471#endif /* CONFIG_USB_MON */ 466#endif /* CONFIG_USB_MON */
472 467
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a12cab5314e9..256d9f698715 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -436,9 +436,10 @@ static void hub_power_on(struct usb_hub *hub)
436{ 436{
437 int port1; 437 int port1;
438 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; 438 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
439 u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
439 440
440 /* if hub supports power switching, enable power on each port */ 441 /* if hub supports power switching, enable power on each port */
441 if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) < 2) { 442 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2) {
442 dev_dbg(hub->intfdev, "enabling power on all ports\n"); 443 dev_dbg(hub->intfdev, "enabling power on all ports\n");
443 for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++) 444 for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
444 set_port_feature(hub->hdev, port1, 445 set_port_feature(hub->hdev, port1,
@@ -449,10 +450,18 @@ static void hub_power_on(struct usb_hub *hub)
449 msleep(max(pgood_delay, (unsigned) 100)); 450 msleep(max(pgood_delay, (unsigned) 100));
450} 451}
451 452
452static void hub_quiesce(struct usb_hub *hub) 453static inline void __hub_quiesce(struct usb_hub *hub)
453{ 454{
454 /* stop khubd and related activity */ 455 /* (nonblocking) khubd and related activity won't re-trigger */
455 hub->quiescing = 1; 456 hub->quiescing = 1;
457 hub->activating = 0;
458 hub->resume_root_hub = 0;
459}
460
461static void hub_quiesce(struct usb_hub *hub)
462{
463 /* (blocking) stop khubd and related activity */
464 __hub_quiesce(hub);
456 usb_kill_urb(hub->urb); 465 usb_kill_urb(hub->urb);
457 if (hub->has_indicators) 466 if (hub->has_indicators)
458 cancel_delayed_work(&hub->leds); 467 cancel_delayed_work(&hub->leds);
@@ -466,6 +475,7 @@ static void hub_activate(struct usb_hub *hub)
466 475
467 hub->quiescing = 0; 476 hub->quiescing = 0;
468 hub->activating = 1; 477 hub->activating = 1;
478 hub->resume_root_hub = 0;
469 status = usb_submit_urb(hub->urb, GFP_NOIO); 479 status = usb_submit_urb(hub->urb, GFP_NOIO);
470 if (status < 0) 480 if (status < 0)
471 dev_err(hub->intfdev, "activate --> %d\n", status); 481 dev_err(hub->intfdev, "activate --> %d\n", status);
@@ -516,6 +526,7 @@ static int hub_configure(struct usb_hub *hub,
516 struct usb_device *hdev = hub->hdev; 526 struct usb_device *hdev = hub->hdev;
517 struct device *hub_dev = hub->intfdev; 527 struct device *hub_dev = hub->intfdev;
518 u16 hubstatus, hubchange; 528 u16 hubstatus, hubchange;
529 u16 wHubCharacteristics;
519 unsigned int pipe; 530 unsigned int pipe;
520 int maxp, ret; 531 int maxp, ret;
521 char *message; 532 char *message;
@@ -561,9 +572,9 @@ static int hub_configure(struct usb_hub *hub,
561 dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, 572 dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild,
562 (hdev->maxchild == 1) ? "" : "s"); 573 (hdev->maxchild == 1) ? "" : "s");
563 574
564 le16_to_cpus(&hub->descriptor->wHubCharacteristics); 575 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
565 576
566 if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) { 577 if (wHubCharacteristics & HUB_CHAR_COMPOUND) {
567 int i; 578 int i;
568 char portstr [USB_MAXCHILDREN + 1]; 579 char portstr [USB_MAXCHILDREN + 1];
569 580
@@ -576,7 +587,7 @@ static int hub_configure(struct usb_hub *hub,
576 } else 587 } else
577 dev_dbg(hub_dev, "standalone hub\n"); 588 dev_dbg(hub_dev, "standalone hub\n");
578 589
579 switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) { 590 switch (wHubCharacteristics & HUB_CHAR_LPSM) {
580 case 0x00: 591 case 0x00:
581 dev_dbg(hub_dev, "ganged power switching\n"); 592 dev_dbg(hub_dev, "ganged power switching\n");
582 break; 593 break;
@@ -589,7 +600,7 @@ static int hub_configure(struct usb_hub *hub,
589 break; 600 break;
590 } 601 }
591 602
592 switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) { 603 switch (wHubCharacteristics & HUB_CHAR_OCPM) {
593 case 0x00: 604 case 0x00:
594 dev_dbg(hub_dev, "global over-current protection\n"); 605 dev_dbg(hub_dev, "global over-current protection\n");
595 break; 606 break;
@@ -629,7 +640,7 @@ static int hub_configure(struct usb_hub *hub,
629 } 640 }
630 641
631 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */ 642 /* Note 8 FS bit times == (8 bits / 12000000 bps) ~= 666ns */
632 switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_TTTT) { 643 switch (wHubCharacteristics & HUB_CHAR_TTTT) {
633 case HUB_TTTT_8_BITS: 644 case HUB_TTTT_8_BITS:
634 if (hdev->descriptor.bDeviceProtocol != 0) { 645 if (hdev->descriptor.bDeviceProtocol != 0) {
635 hub->tt.think_time = 666; 646 hub->tt.think_time = 666;
@@ -659,7 +670,7 @@ static int hub_configure(struct usb_hub *hub,
659 } 670 }
660 671
661 /* probe() zeroes hub->indicator[] */ 672 /* probe() zeroes hub->indicator[] */
662 if (hub->descriptor->wHubCharacteristics & HUB_CHAR_PORTIND) { 673 if (wHubCharacteristics & HUB_CHAR_PORTIND) {
663 hub->has_indicators = 1; 674 hub->has_indicators = 1;
664 dev_dbg(hub_dev, "Port indicators are supported\n"); 675 dev_dbg(hub_dev, "Port indicators are supported\n");
665 } 676 }
@@ -704,7 +715,7 @@ static int hub_configure(struct usb_hub *hub,
704 (hubstatus & HUB_STATUS_LOCAL_POWER) 715 (hubstatus & HUB_STATUS_LOCAL_POWER)
705 ? "lost (inactive)" : "good"); 716 ? "lost (inactive)" : "good");
706 717
707 if ((hub->descriptor->wHubCharacteristics & HUB_CHAR_OCPM) == 0) 718 if ((wHubCharacteristics & HUB_CHAR_OCPM) == 0)
708 dev_dbg(hub_dev, "%sover-current condition exists\n", 719 dev_dbg(hub_dev, "%sover-current condition exists\n",
709 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); 720 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
710 721
@@ -854,14 +865,12 @@ descriptor_error:
854 /* We found a hub */ 865 /* We found a hub */
855 dev_info (&intf->dev, "USB hub found\n"); 866 dev_info (&intf->dev, "USB hub found\n");
856 867
857 hub = kmalloc(sizeof(*hub), GFP_KERNEL); 868 hub = kzalloc(sizeof(*hub), GFP_KERNEL);
858 if (!hub) { 869 if (!hub) {
859 dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n"); 870 dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n");
860 return -ENOMEM; 871 return -ENOMEM;
861 } 872 }
862 873
863 memset(hub, 0, sizeof(*hub));
864
865 INIT_LIST_HEAD(&hub->event_list); 874 INIT_LIST_HEAD(&hub->event_list);
866 hub->intfdev = &intf->dev; 875 hub->intfdev = &intf->dev;
867 hub->hdev = hdev; 876 hub->hdev = hdev;
@@ -1020,9 +1029,15 @@ void usb_set_device_state(struct usb_device *udev,
1020 spin_lock_irqsave(&device_state_lock, flags); 1029 spin_lock_irqsave(&device_state_lock, flags);
1021 if (udev->state == USB_STATE_NOTATTACHED) 1030 if (udev->state == USB_STATE_NOTATTACHED)
1022 ; /* do nothing */ 1031 ; /* do nothing */
1023 else if (new_state != USB_STATE_NOTATTACHED) 1032 else if (new_state != USB_STATE_NOTATTACHED) {
1024 udev->state = new_state; 1033 udev->state = new_state;
1025 else 1034 if (new_state == USB_STATE_CONFIGURED)
1035 device_init_wakeup(&udev->dev,
1036 (udev->actconfig->desc.bmAttributes
1037 & USB_CONFIG_ATT_WAKEUP));
1038 else if (new_state != USB_STATE_SUSPENDED)
1039 device_init_wakeup(&udev->dev, 0);
1040 } else
1026 recursively_mark_NOTATTACHED(udev); 1041 recursively_mark_NOTATTACHED(udev);
1027 spin_unlock_irqrestore(&device_state_lock, flags); 1042 spin_unlock_irqrestore(&device_state_lock, flags);
1028} 1043}
@@ -1111,14 +1126,14 @@ void usb_disconnect(struct usb_device **pdev)
1111 */ 1126 */
1112 usb_disable_device(udev, 0); 1127 usb_disable_device(udev, 0);
1113 1128
1129 usb_notify_remove_device(udev);
1130
1114 /* Free the device number, remove the /proc/bus/usb entry and 1131 /* Free the device number, remove the /proc/bus/usb entry and
1115 * the sysfs attributes, and delete the parent's children[] 1132 * the sysfs attributes, and delete the parent's children[]
1116 * (or root_hub) pointer. 1133 * (or root_hub) pointer.
1117 */ 1134 */
1118 dev_dbg (&udev->dev, "unregistering device\n"); 1135 dev_dbg (&udev->dev, "unregistering device\n");
1119 release_address(udev); 1136 release_address(udev);
1120 usbfs_remove_device(udev);
1121 usbdev_remove(udev);
1122 usb_remove_sysfs_dev_files(udev); 1137 usb_remove_sysfs_dev_files(udev);
1123 1138
1124 /* Avoid races with recursively_mark_NOTATTACHED() */ 1139 /* Avoid races with recursively_mark_NOTATTACHED() */
@@ -1189,21 +1204,6 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1189{} 1204{}
1190#endif 1205#endif
1191 1206
1192static void get_string(struct usb_device *udev, char **string, int index)
1193{
1194 char *buf;
1195
1196 if (!index)
1197 return;
1198 buf = kmalloc(256, GFP_KERNEL);
1199 if (!buf)
1200 return;
1201 if (usb_string(udev, index, buf, 256) > 0)
1202 *string = buf;
1203 else
1204 kfree(buf);
1205}
1206
1207 1207
1208#ifdef CONFIG_USB_OTG 1208#ifdef CONFIG_USB_OTG
1209#include "otg_whitelist.h" 1209#include "otg_whitelist.h"
@@ -1242,9 +1242,10 @@ int usb_new_device(struct usb_device *udev)
1242 } 1242 }
1243 1243
1244 /* read the standard strings and cache them if present */ 1244 /* read the standard strings and cache them if present */
1245 get_string(udev, &udev->product, udev->descriptor.iProduct); 1245 udev->product = usb_cache_string(udev, udev->descriptor.iProduct);
1246 get_string(udev, &udev->manufacturer, udev->descriptor.iManufacturer); 1246 udev->manufacturer = usb_cache_string(udev,
1247 get_string(udev, &udev->serial, udev->descriptor.iSerialNumber); 1247 udev->descriptor.iManufacturer);
1248 udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
1248 1249
1249 /* Tell the world! */ 1250 /* Tell the world! */
1250 dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, " 1251 dev_dbg(&udev->dev, "new device strings: Mfr=%d, Product=%d, "
@@ -1316,11 +1317,9 @@ int usb_new_device(struct usb_device *udev)
1316 * (Includes HNP test device.) 1317 * (Includes HNP test device.)
1317 */ 1318 */
1318 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1319 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1319 static int __usb_suspend_device (struct usb_device *, 1320 static int __usb_suspend_device(struct usb_device *,
1320 int port1, pm_message_t state); 1321 int port1);
1321 err = __usb_suspend_device(udev, 1322 err = __usb_suspend_device(udev, udev->bus->otg_port);
1322 udev->bus->otg_port,
1323 PMSG_SUSPEND);
1324 if (err < 0) 1323 if (err < 0)
1325 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1324 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1326 } 1325 }
@@ -1356,10 +1355,8 @@ int usb_new_device(struct usb_device *udev)
1356 } 1355 }
1357 1356
1358 /* USB device state == configured ... usable */ 1357 /* USB device state == configured ... usable */
1358 usb_notify_add_device(udev);
1359 1359
1360 /* add a /proc/bus/usb entry */
1361 usbdev_add(udev);
1362 usbfs_add_device(udev);
1363 return 0; 1360 return 0;
1364 1361
1365fail: 1362fail:
@@ -1510,7 +1507,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
1510 /* FIXME let caller ask to power down the port: 1507 /* FIXME let caller ask to power down the port:
1511 * - some devices won't enumerate without a VBUS power cycle 1508 * - some devices won't enumerate without a VBUS power cycle
1512 * - SRP saves power that way 1509 * - SRP saves power that way
1513 * - usb_suspend_device(dev, PMSG_SUSPEND) 1510 * - ... new call, TBD ...
1514 * That's easy if this hub can switch power per-port, and 1511 * That's easy if this hub can switch power per-port, and
1515 * khubd reactivates the port later (timer, SRP, etc). 1512 * khubd reactivates the port later (timer, SRP, etc).
1516 * Powerdown must be optional, because of reset/DFU. 1513 * Powerdown must be optional, because of reset/DFU.
@@ -1546,11 +1543,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1546 * NOTE: OTG devices may issue remote wakeup (or SRP) even when 1543 * NOTE: OTG devices may issue remote wakeup (or SRP) even when
1547 * we don't explicitly enable it here. 1544 * we don't explicitly enable it here.
1548 */ 1545 */
1549 if (udev->actconfig 1546 if (device_may_wakeup(&udev->dev)) {
1550 // && FIXME (remote wakeup enabled on this bus)
1551 // ... currently assuming it's always appropriate
1552 && (udev->actconfig->desc.bmAttributes
1553 & USB_CONFIG_ATT_WAKEUP) != 0) {
1554 status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1547 status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1555 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, 1548 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
1556 USB_DEVICE_REMOTE_WAKEUP, 0, 1549 USB_DEVICE_REMOTE_WAKEUP, 0,
@@ -1596,11 +1589,14 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1596 * Other than re-initializing the hub (plug/unplug, except for root hubs), 1589 * Other than re-initializing the hub (plug/unplug, except for root hubs),
1597 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd 1590 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd
1598 * timer, no SRP, no requests through sysfs. 1591 * timer, no SRP, no requests through sysfs.
1592 *
1593 * If CONFIG_USB_SUSPEND isn't enabled, devices only really suspend when
1594 * the root hub for their bus goes into global suspend ... so we don't
1595 * (falsely) update the device power state to say it suspended.
1599 */ 1596 */
1600static int __usb_suspend_device (struct usb_device *udev, int port1, 1597static int __usb_suspend_device (struct usb_device *udev, int port1)
1601 pm_message_t state)
1602{ 1598{
1603 int status; 1599 int status = 0;
1604 1600
1605 /* caller owns the udev device lock */ 1601 /* caller owns the udev device lock */
1606 if (port1 < 0) 1602 if (port1 < 0)
@@ -1611,95 +1607,39 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
1611 return 0; 1607 return 0;
1612 } 1608 }
1613 1609
1614 /* suspend interface drivers; if this is a hub, it 1610 /* all interfaces must already be suspended */
1615 * suspends the child devices
1616 */
1617 if (udev->actconfig) { 1611 if (udev->actconfig) {
1618 int i; 1612 int i;
1619 1613
1620 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1614 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1621 struct usb_interface *intf; 1615 struct usb_interface *intf;
1622 struct usb_driver *driver;
1623 1616
1624 intf = udev->actconfig->interface[i]; 1617 intf = udev->actconfig->interface[i];
1625 if (state.event <= intf->dev.power.power_state.event) 1618 if (is_active(intf)) {
1626 continue; 1619 dev_dbg(&intf->dev, "nyet suspended\n");
1627 if (!intf->dev.driver) 1620 return -EBUSY;
1628 continue;
1629 driver = to_usb_driver(intf->dev.driver);
1630
1631 if (driver->suspend) {
1632 status = driver->suspend(intf, state);
1633 if (intf->dev.power.power_state.event != state.event
1634 || status)
1635 dev_err(&intf->dev,
1636 "suspend %d fail, code %d\n",
1637 state.event, status);
1638 }
1639
1640 /* only drivers with suspend() can ever resume();
1641 * and after power loss, even they won't.
1642 * bus_rescan_devices() can rebind drivers later.
1643 *
1644 * FIXME the PM core self-deadlocks when unbinding
1645 * drivers during suspend/resume ... everything grabs
1646 * dpm_sem (not a spinlock, ugh). we want to unbind,
1647 * since we know every driver's probe/disconnect works
1648 * even for drivers that can't suspend.
1649 */
1650 if (!driver->suspend || state.event > PM_EVENT_FREEZE) {
1651#if 1
1652 dev_warn(&intf->dev, "resume is unsafe!\n");
1653#else
1654 down_write(&usb_bus_type.rwsem);
1655 device_release_driver(&intf->dev);
1656 up_write(&usb_bus_type.rwsem);
1657#endif
1658 } 1621 }
1659 } 1622 }
1660 } 1623 }
1661 1624
1662 /* 1625 /* we only change a device's upstream USB link.
1663 * FIXME this needs port power off call paths too, to help force 1626 * root hubs have no upstream USB link.
1664 * USB into the "generic" PM model. At least for devices on
1665 * ports that aren't using ganged switching (usually root hubs).
1666 *
1667 * NOTE: SRP-capable links should adopt more aggressive poweroff
1668 * policies (when HNP doesn't apply) once we have mechanisms to
1669 * turn power back on! (Likely not before 2.7...)
1670 */ 1627 */
1671 if (state.event > PM_EVENT_FREEZE) { 1628 if (udev->parent)
1672 dev_warn(&udev->dev, "no poweroff yet, suspending instead\n");
1673 }
1674
1675 /* "global suspend" of the HC-to-USB interface (root hub), or
1676 * "selective suspend" of just one hub-device link.
1677 */
1678 if (!udev->parent) {
1679 struct usb_bus *bus = udev->bus;
1680 if (bus && bus->op->hub_suspend) {
1681 status = bus->op->hub_suspend (bus);
1682 if (status == 0) {
1683 dev_dbg(&udev->dev, "usb suspend\n");
1684 usb_set_device_state(udev,
1685 USB_STATE_SUSPENDED);
1686 }
1687 } else
1688 status = -EOPNOTSUPP;
1689 } else
1690 status = hub_port_suspend(hdev_to_hub(udev->parent), port1, 1629 status = hub_port_suspend(hdev_to_hub(udev->parent), port1,
1691 udev); 1630 udev);
1692 1631
1693 if (status == 0) 1632 if (status == 0)
1694 udev->dev.power.power_state = state; 1633 udev->dev.power.power_state = PMSG_SUSPEND;
1695 return status; 1634 return status;
1696} 1635}
1697 1636
1698/** 1637#endif
1638
1639/*
1699 * usb_suspend_device - suspend a usb device 1640 * usb_suspend_device - suspend a usb device
1700 * @udev: device that's no longer in active use 1641 * @udev: device that's no longer in active use
1701 * @state: PMSG_SUSPEND to suspend 1642 * Context: must be able to sleep; device not locked; pm locks held
1702 * Context: must be able to sleep; device not locked
1703 * 1643 *
1704 * Suspends a USB device that isn't in active use, conserving power. 1644 * Suspends a USB device that isn't in active use, conserving power.
1705 * Devices may wake out of a suspend, if anything important happens, 1645 * Devices may wake out of a suspend, if anything important happens,
@@ -1707,37 +1647,50 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
1707 * suspend by the host, using usb_resume_device(). It's also routine 1647 * suspend by the host, using usb_resume_device(). It's also routine
1708 * to disconnect devices while they are suspended. 1648 * to disconnect devices while they are suspended.
1709 * 1649 *
1650 * This only affects the USB hardware for a device; its interfaces
1651 * (and, for hubs, child devices) must already have been suspended.
1652 *
1710 * Suspending OTG devices may trigger HNP, if that's been enabled 1653 * Suspending OTG devices may trigger HNP, if that's been enabled
1711 * between a pair of dual-role devices. That will change roles, such 1654 * between a pair of dual-role devices. That will change roles, such
1712 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral. 1655 * as from A-Host to A-Peripheral or from B-Host back to B-Peripheral.
1713 * 1656 *
1714 * Returns 0 on success, else negative errno. 1657 * Returns 0 on success, else negative errno.
1715 */ 1658 */
1716int usb_suspend_device(struct usb_device *udev, pm_message_t state) 1659int usb_suspend_device(struct usb_device *udev)
1717{ 1660{
1661#ifdef CONFIG_USB_SUSPEND
1718 int port1, status; 1662 int port1, status;
1719 1663
1720 port1 = locktree(udev); 1664 port1 = locktree(udev);
1721 if (port1 < 0) 1665 if (port1 < 0)
1722 return port1; 1666 return port1;
1723 1667
1724 status = __usb_suspend_device(udev, port1, state); 1668 status = __usb_suspend_device(udev, port1);
1725 usb_unlock_device(udev); 1669 usb_unlock_device(udev);
1726 return status; 1670 return status;
1671#else
1672 /* NOTE: udev->state unchanged, it's not lying ... */
1673 udev->dev.power.power_state = PMSG_SUSPEND;
1674 return 0;
1675#endif
1727} 1676}
1677EXPORT_SYMBOL_GPL(usb_suspend_device);
1728 1678
1729/* 1679/*
1680 * If the USB "suspend" state is in use (rather than "global suspend"),
1681 * many devices will be individually taken out of suspend state using
1682 * special" resume" signaling. These routines kick in shortly after
1730 * hardware resume signaling is finished, either because of selective 1683 * hardware resume signaling is finished, either because of selective
1731 * resume (by host) or remote wakeup (by device) ... now see what changed 1684 * resume (by host) or remote wakeup (by device) ... now see what changed
1732 * in the tree that's rooted at this device. 1685 * in the tree that's rooted at this device.
1733 */ 1686 */
1734static int finish_port_resume(struct usb_device *udev) 1687static int finish_device_resume(struct usb_device *udev)
1735{ 1688{
1736 int status; 1689 int status;
1737 u16 devstatus; 1690 u16 devstatus;
1738 1691
1739 /* caller owns the udev device lock */ 1692 /* caller owns the udev device lock */
1740 dev_dbg(&udev->dev, "usb resume\n"); 1693 dev_dbg(&udev->dev, "finish resume\n");
1741 1694
1742 /* usb ch9 identifies four variants of SUSPENDED, based on what 1695 /* usb ch9 identifies four variants of SUSPENDED, based on what
1743 * state the device resumes to. Linux currently won't see the 1696 * state the device resumes to. Linux currently won't see the
@@ -1747,7 +1700,6 @@ static int finish_port_resume(struct usb_device *udev)
1747 usb_set_device_state(udev, udev->actconfig 1700 usb_set_device_state(udev, udev->actconfig
1748 ? USB_STATE_CONFIGURED 1701 ? USB_STATE_CONFIGURED
1749 : USB_STATE_ADDRESS); 1702 : USB_STATE_ADDRESS);
1750 udev->dev.power.power_state = PMSG_ON;
1751 1703
1752 /* 10.5.4.5 says be sure devices in the tree are still there. 1704 /* 10.5.4.5 says be sure devices in the tree are still there.
1753 * For now let's assume the device didn't go crazy on resume, 1705 * For now let's assume the device didn't go crazy on resume,
@@ -1760,9 +1712,11 @@ static int finish_port_resume(struct usb_device *udev)
1760 status); 1712 status);
1761 else if (udev->actconfig) { 1713 else if (udev->actconfig) {
1762 unsigned i; 1714 unsigned i;
1715 int (*resume)(struct device *);
1763 1716
1764 le16_to_cpus(&devstatus); 1717 le16_to_cpus(&devstatus);
1765 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) { 1718 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)
1719 && udev->parent) {
1766 status = usb_control_msg(udev, 1720 status = usb_control_msg(udev,
1767 usb_sndctrlpipe(udev, 0), 1721 usb_sndctrlpipe(udev, 0),
1768 USB_REQ_CLEAR_FEATURE, 1722 USB_REQ_CLEAR_FEATURE,
@@ -1778,33 +1732,11 @@ static int finish_port_resume(struct usb_device *udev)
1778 } 1732 }
1779 1733
1780 /* resume interface drivers; if this is a hub, it 1734 /* resume interface drivers; if this is a hub, it
1781 * resumes the child devices 1735 * may have a child resume event to deal with soon
1782 */ 1736 */
1783 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1737 resume = udev->dev.bus->resume;
1784 struct usb_interface *intf; 1738 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++)
1785 struct usb_driver *driver; 1739 (void) resume(&udev->actconfig->interface[i]->dev);
1786
1787 intf = udev->actconfig->interface[i];
1788 if (intf->dev.power.power_state.event == PM_EVENT_ON)
1789 continue;
1790 if (!intf->dev.driver) {
1791 /* FIXME maybe force to alt 0 */
1792 continue;
1793 }
1794 driver = to_usb_driver(intf->dev.driver);
1795
1796 /* bus_rescan_devices() may rebind drivers */
1797 if (!driver->resume)
1798 continue;
1799
1800 /* can we do better than just logging errors? */
1801 status = driver->resume(intf);
1802 if (intf->dev.power.power_state.event != PM_EVENT_ON
1803 || status)
1804 dev_dbg(&intf->dev,
1805 "resume fail, state %d code %d\n",
1806 intf->dev.power.power_state.event, status);
1807 }
1808 status = 0; 1740 status = 0;
1809 1741
1810 } else if (udev->devnum <= 0) { 1742 } else if (udev->devnum <= 0) {
@@ -1814,6 +1746,8 @@ static int finish_port_resume(struct usb_device *udev)
1814 return status; 1746 return status;
1815} 1747}
1816 1748
1749#ifdef CONFIG_USB_SUSPEND
1750
1817static int 1751static int
1818hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) 1752hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1819{ 1753{
@@ -1859,7 +1793,7 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1859 /* TRSMRCY = 10 msec */ 1793 /* TRSMRCY = 10 msec */
1860 msleep(10); 1794 msleep(10);
1861 if (udev) 1795 if (udev)
1862 status = finish_port_resume(udev); 1796 status = finish_device_resume(udev);
1863 } 1797 }
1864 } 1798 }
1865 if (status < 0) 1799 if (status < 0)
@@ -1868,12 +1802,12 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1868 return status; 1802 return status;
1869} 1803}
1870 1804
1871static int hub_resume (struct usb_interface *intf); 1805#endif
1872 1806
1873/** 1807/*
1874 * usb_resume_device - re-activate a suspended usb device 1808 * usb_resume_device - re-activate a suspended usb device
1875 * @udev: device to re-activate 1809 * @udev: device to re-activate
1876 * Context: must be able to sleep; device not locked 1810 * Context: must be able to sleep; device not locked; pm locks held
1877 * 1811 *
1878 * This will re-activate the suspended device, increasing power usage 1812 * This will re-activate the suspended device, increasing power usage
1879 * while letting drivers communicate again with its endpoints. 1813 * while letting drivers communicate again with its endpoints.
@@ -1891,35 +1825,22 @@ int usb_resume_device(struct usb_device *udev)
1891 if (port1 < 0) 1825 if (port1 < 0)
1892 return port1; 1826 return port1;
1893 1827
1894 /* "global resume" of the HC-to-USB interface (root hub), or 1828#ifdef CONFIG_USB_SUSPEND
1895 * selective resume of one hub-to-device port 1829 /* selective resume of one downstream hub-to-device port */
1896 */ 1830 if (udev->parent) {
1897 if (!udev->parent) { 1831 if (udev->state == USB_STATE_SUSPENDED) {
1898 struct usb_bus *bus = udev->bus; 1832 // NOTE swsusp may bork us, device state being wrong...
1899 if (bus && bus->op->hub_resume) { 1833 // NOTE this fails if parent is also suspended...
1900 status = bus->op->hub_resume (bus); 1834 status = hub_port_resume(hdev_to_hub(udev->parent),
1835 port1, udev);
1901 } else 1836 } else
1902 status = -EOPNOTSUPP; 1837 status = 0;
1903 if (status == 0) { 1838 } else
1904 dev_dbg(&udev->dev, "usb resume\n"); 1839#endif
1905 /* TRSMRCY = 10 msec */ 1840 status = finish_device_resume(udev);
1906 msleep(10); 1841 if (status < 0)
1907 usb_set_device_state (udev, USB_STATE_CONFIGURED);
1908 udev->dev.power.power_state = PMSG_ON;
1909 status = hub_resume (udev
1910 ->actconfig->interface[0]);
1911 }
1912 } else if (udev->state == USB_STATE_SUSPENDED) {
1913 // NOTE this fails if parent is also suspended...
1914 status = hub_port_resume(hdev_to_hub(udev->parent),
1915 port1, udev);
1916 } else {
1917 status = 0;
1918 }
1919 if (status < 0) {
1920 dev_dbg(&udev->dev, "can't resume, status %d\n", 1842 dev_dbg(&udev->dev, "can't resume, status %d\n",
1921 status); 1843 status);
1922 }
1923 1844
1924 usb_unlock_device(udev); 1845 usb_unlock_device(udev);
1925 1846
@@ -1936,6 +1857,8 @@ static int remote_wakeup(struct usb_device *udev)
1936{ 1857{
1937 int status = 0; 1858 int status = 0;
1938 1859
1860#ifdef CONFIG_USB_SUSPEND
1861
1939 /* don't repeat RESUME sequence if this device 1862 /* don't repeat RESUME sequence if this device
1940 * was already woken up by some other task 1863 * was already woken up by some other task
1941 */ 1864 */
@@ -1944,38 +1867,52 @@ static int remote_wakeup(struct usb_device *udev)
1944 dev_dbg(&udev->dev, "RESUME (wakeup)\n"); 1867 dev_dbg(&udev->dev, "RESUME (wakeup)\n");
1945 /* TRSMRCY = 10 msec */ 1868 /* TRSMRCY = 10 msec */
1946 msleep(10); 1869 msleep(10);
1947 status = finish_port_resume(udev); 1870 status = finish_device_resume(udev);
1948 } 1871 }
1949 up(&udev->serialize); 1872 up(&udev->serialize);
1873#endif
1950 return status; 1874 return status;
1951} 1875}
1952 1876
1953static int hub_suspend(struct usb_interface *intf, pm_message_t state) 1877static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1954{ 1878{
1955 struct usb_hub *hub = usb_get_intfdata (intf); 1879 struct usb_hub *hub = usb_get_intfdata (intf);
1956 struct usb_device *hdev = hub->hdev; 1880 struct usb_device *hdev = hub->hdev;
1957 unsigned port1; 1881 unsigned port1;
1958 int status;
1959 1882
1960 /* stop khubd and related activity */ 1883 /* fail if children aren't already suspended */
1961 hub_quiesce(hub);
1962
1963 /* then suspend every port */
1964 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 1884 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
1965 struct usb_device *udev; 1885 struct usb_device *udev;
1966 1886
1967 udev = hdev->children [port1-1]; 1887 udev = hdev->children [port1-1];
1968 if (!udev) 1888 if (udev && (udev->dev.power.power_state.event
1969 continue; 1889 == PM_EVENT_ON
1970 down(&udev->serialize); 1890#ifdef CONFIG_USB_SUSPEND
1971 status = __usb_suspend_device(udev, port1, state); 1891 || udev->state != USB_STATE_SUSPENDED
1972 up(&udev->serialize); 1892#endif
1973 if (status < 0) 1893 )) {
1974 dev_dbg(&intf->dev, "suspend port %d --> %d\n", 1894 dev_dbg(&intf->dev, "port %d nyet suspended\n", port1);
1975 port1, status); 1895 return -EBUSY;
1896 }
1976 } 1897 }
1977 1898
1978 intf->dev.power.power_state = state; 1899 /* "global suspend" of the downstream HC-to-USB interface */
1900 if (!hdev->parent) {
1901 struct usb_bus *bus = hdev->bus;
1902 if (bus) {
1903 int status = hcd_bus_suspend (bus);
1904
1905 if (status != 0) {
1906 dev_dbg(&hdev->dev, "'global' suspend %d\n",
1907 status);
1908 return status;
1909 }
1910 } else
1911 return -EOPNOTSUPP;
1912 }
1913
1914 /* stop khubd and related activity */
1915 hub_quiesce(hub);
1979 return 0; 1916 return 0;
1980} 1917}
1981 1918
@@ -1983,11 +1920,35 @@ static int hub_resume(struct usb_interface *intf)
1983{ 1920{
1984 struct usb_device *hdev = interface_to_usbdev(intf); 1921 struct usb_device *hdev = interface_to_usbdev(intf);
1985 struct usb_hub *hub = usb_get_intfdata (intf); 1922 struct usb_hub *hub = usb_get_intfdata (intf);
1986 unsigned port1;
1987 int status; 1923 int status;
1988 1924
1989 if (intf->dev.power.power_state.event == PM_EVENT_ON) 1925 /* "global resume" of the downstream HC-to-USB interface */
1990 return 0; 1926 if (!hdev->parent) {
1927 struct usb_bus *bus = hdev->bus;
1928 if (bus) {
1929 status = hcd_bus_resume (bus);
1930 if (status) {
1931 dev_dbg(&intf->dev, "'global' resume %d\n",
1932 status);
1933 return status;
1934 }
1935 } else
1936 return -EOPNOTSUPP;
1937 if (status == 0) {
1938 /* TRSMRCY = 10 msec */
1939 msleep(10);
1940 }
1941 }
1942
1943 hub_activate(hub);
1944
1945 /* REVISIT: this recursion probably shouldn't exist. Remove
1946 * this code sometime, after retesting with different root and
1947 * external hubs.
1948 */
1949#ifdef CONFIG_USB_SUSPEND
1950 {
1951 unsigned port1;
1991 1952
1992 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 1953 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
1993 struct usb_device *udev; 1954 struct usb_device *udev;
@@ -2013,7 +1974,7 @@ static int hub_resume(struct usb_interface *intf)
2013 if (portstat & USB_PORT_STAT_SUSPEND) 1974 if (portstat & USB_PORT_STAT_SUSPEND)
2014 status = hub_port_resume(hub, port1, udev); 1975 status = hub_port_resume(hub, port1, udev);
2015 else { 1976 else {
2016 status = finish_port_resume(udev); 1977 status = finish_device_resume(udev);
2017 if (status < 0) { 1978 if (status < 0) {
2018 dev_dbg(&intf->dev, "resume port %d --> %d\n", 1979 dev_dbg(&intf->dev, "resume port %d --> %d\n",
2019 port1, status); 1980 port1, status);
@@ -2022,43 +1983,31 @@ static int hub_resume(struct usb_interface *intf)
2022 } 1983 }
2023 up(&udev->serialize); 1984 up(&udev->serialize);
2024 } 1985 }
2025 intf->dev.power.power_state = PMSG_ON; 1986 }
2026 1987#endif
2027 hub->resume_root_hub = 0;
2028 hub_activate(hub);
2029 return 0; 1988 return 0;
2030} 1989}
2031 1990
2032void usb_resume_root_hub(struct usb_device *hdev) 1991void usb_suspend_root_hub(struct usb_device *hdev)
2033{ 1992{
2034 struct usb_hub *hub = hdev_to_hub(hdev); 1993 struct usb_hub *hub = hdev_to_hub(hdev);
2035 1994
2036 hub->resume_root_hub = 1; 1995 /* This also makes any led blinker stop retriggering. We're called
2037 kick_khubd(hub); 1996 * from irq, so the blinker might still be scheduled. Caller promises
1997 * that the root hub status URB will be canceled.
1998 */
1999 __hub_quiesce(hub);
2000 mark_quiesced(to_usb_interface(hub->intfdev));
2038} 2001}
2039 2002
2040#else /* !CONFIG_USB_SUSPEND */ 2003void usb_resume_root_hub(struct usb_device *hdev)
2041
2042int usb_suspend_device(struct usb_device *udev, pm_message_t state)
2043{ 2004{
2044 return 0; 2005 struct usb_hub *hub = hdev_to_hub(hdev);
2045}
2046 2006
2047int usb_resume_device(struct usb_device *udev) 2007 hub->resume_root_hub = 1;
2048{ 2008 kick_khubd(hub);
2049 return 0;
2050} 2009}
2051 2010
2052#define hub_suspend NULL
2053#define hub_resume NULL
2054#define remote_wakeup(x) 0
2055
2056#endif /* CONFIG_USB_SUSPEND */
2057
2058EXPORT_SYMBOL(usb_suspend_device);
2059EXPORT_SYMBOL(usb_resume_device);
2060
2061
2062 2011
2063/* USB 2.0 spec, 7.1.7.3 / fig 7-29: 2012/* USB 2.0 spec, 7.1.7.3 / fig 7-29:
2064 * 2013 *
@@ -2467,6 +2416,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2467{ 2416{
2468 struct usb_device *hdev = hub->hdev; 2417 struct usb_device *hdev = hub->hdev;
2469 struct device *hub_dev = hub->intfdev; 2418 struct device *hub_dev = hub->intfdev;
2419 u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
2470 int status, i; 2420 int status, i;
2471 2421
2472 dev_dbg (hub_dev, 2422 dev_dbg (hub_dev,
@@ -2504,8 +2454,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2504 if (!(portstatus & USB_PORT_STAT_CONNECTION)) { 2454 if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
2505 2455
2506 /* maybe switch power back on (e.g. root hub was reset) */ 2456 /* maybe switch power back on (e.g. root hub was reset) */
2507 if ((hub->descriptor->wHubCharacteristics 2457 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
2508 & HUB_CHAR_LPSM) < 2
2509 && !(portstatus & (1 << USB_PORT_FEAT_POWER))) 2458 && !(portstatus & (1 << USB_PORT_FEAT_POWER)))
2510 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 2459 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
2511 2460
@@ -2684,21 +2633,28 @@ static void hub_events(void)
2684 intf = to_usb_interface(hub->intfdev); 2633 intf = to_usb_interface(hub->intfdev);
2685 hub_dev = &intf->dev; 2634 hub_dev = &intf->dev;
2686 2635
2687 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", 2636 i = hub->resume_root_hub;
2637
2638 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n",
2688 hdev->state, hub->descriptor 2639 hdev->state, hub->descriptor
2689 ? hub->descriptor->bNbrPorts 2640 ? hub->descriptor->bNbrPorts
2690 : 0, 2641 : 0,
2691 /* NOTE: expects max 15 ports... */ 2642 /* NOTE: expects max 15 ports... */
2692 (u16) hub->change_bits[0], 2643 (u16) hub->change_bits[0],
2693 (u16) hub->event_bits[0]); 2644 (u16) hub->event_bits[0],
2645 i ? ", resume root" : "");
2694 2646
2695 usb_get_intf(intf); 2647 usb_get_intf(intf);
2696 i = hub->resume_root_hub;
2697 spin_unlock_irq(&hub_event_lock); 2648 spin_unlock_irq(&hub_event_lock);
2698 2649
2699 /* Is this is a root hub wanting to be resumed? */ 2650 /* Is this is a root hub wanting to reactivate the downstream
2700 if (i) 2651 * ports? If so, be sure the interface resumes even if its
2701 usb_resume_device(hdev); 2652 * stub "device" node was never suspended.
2653 */
2654 if (i) {
2655 dpm_runtime_resume(&hdev->dev);
2656 dpm_runtime_resume(&intf->dev);
2657 }
2702 2658
2703 /* Lock the device, then check to see if we were 2659 /* Lock the device, then check to see if we were
2704 * disconnected while waiting for the lock to succeed. */ 2660 * disconnected while waiting for the lock to succeed. */
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index e7fa9b5a521e..bf23f8978024 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -131,7 +131,7 @@ struct usb_hub_descriptor {
131 __u8 bDescLength; 131 __u8 bDescLength;
132 __u8 bDescriptorType; 132 __u8 bDescriptorType;
133 __u8 bNbrPorts; 133 __u8 bNbrPorts;
134 __u16 wHubCharacteristics; 134 __le16 wHubCharacteristics;
135 __u8 bPwrOn2PwrGood; 135 __u8 bPwrOn2PwrGood;
136 __u8 bHubContrCurrent; 136 __u8 bHubContrCurrent;
137 /* add 1 bit for hub status change; round to bytes */ 137 /* add 1 bit for hub status change; round to bytes */
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index d07bba01995b..12f490fdee8f 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -39,6 +39,7 @@
39#include <linux/usbdevice_fs.h> 39#include <linux/usbdevice_fs.h>
40#include <linux/smp_lock.h> 40#include <linux/smp_lock.h>
41#include <linux/parser.h> 41#include <linux/parser.h>
42#include <linux/notifier.h>
42#include <asm/byteorder.h> 43#include <asm/byteorder.h>
43#include "usb.h" 44#include "usb.h"
44#include "hcd.h" 45#include "hcd.h"
@@ -619,7 +620,7 @@ void usbfs_update_special (void)
619 } 620 }
620} 621}
621 622
622void usbfs_add_bus(struct usb_bus *bus) 623static void usbfs_add_bus(struct usb_bus *bus)
623{ 624{
624 struct dentry *parent; 625 struct dentry *parent;
625 char name[8]; 626 char name[8];
@@ -642,12 +643,9 @@ void usbfs_add_bus(struct usb_bus *bus)
642 err ("error creating usbfs bus entry"); 643 err ("error creating usbfs bus entry");
643 return; 644 return;
644 } 645 }
645
646 usbfs_update_special();
647 usbfs_conn_disc_event();
648} 646}
649 647
650void usbfs_remove_bus(struct usb_bus *bus) 648static void usbfs_remove_bus(struct usb_bus *bus)
651{ 649{
652 if (bus->usbfs_dentry) { 650 if (bus->usbfs_dentry) {
653 fs_remove_file (bus->usbfs_dentry); 651 fs_remove_file (bus->usbfs_dentry);
@@ -659,12 +657,9 @@ void usbfs_remove_bus(struct usb_bus *bus)
659 remove_special_files(); 657 remove_special_files();
660 num_buses = 0; 658 num_buses = 0;
661 } 659 }
662
663 usbfs_update_special();
664 usbfs_conn_disc_event();
665} 660}
666 661
667void usbfs_add_device(struct usb_device *dev) 662static void usbfs_add_device(struct usb_device *dev)
668{ 663{
669 char name[8]; 664 char name[8];
670 int i; 665 int i;
@@ -690,12 +685,9 @@ void usbfs_add_device(struct usb_device *dev)
690 } 685 }
691 if (dev->usbfs_dentry->d_inode) 686 if (dev->usbfs_dentry->d_inode)
692 dev->usbfs_dentry->d_inode->i_size = i_size; 687 dev->usbfs_dentry->d_inode->i_size = i_size;
693
694 usbfs_update_special();
695 usbfs_conn_disc_event();
696} 688}
697 689
698void usbfs_remove_device(struct usb_device *dev) 690static void usbfs_remove_device(struct usb_device *dev)
699{ 691{
700 struct dev_state *ds; 692 struct dev_state *ds;
701 struct siginfo sinfo; 693 struct siginfo sinfo;
@@ -716,10 +708,33 @@ void usbfs_remove_device(struct usb_device *dev)
716 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid); 708 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid);
717 } 709 }
718 } 710 }
711}
712
713static int usbfs_notify(struct notifier_block *self, unsigned long action, void *dev)
714{
715 switch (action) {
716 case USB_DEVICE_ADD:
717 usbfs_add_device(dev);
718 break;
719 case USB_DEVICE_REMOVE:
720 usbfs_remove_device(dev);
721 break;
722 case USB_BUS_ADD:
723 usbfs_add_bus(dev);
724 break;
725 case USB_BUS_REMOVE:
726 usbfs_remove_bus(dev);
727 }
728
719 usbfs_update_special(); 729 usbfs_update_special();
720 usbfs_conn_disc_event(); 730 usbfs_conn_disc_event();
731 return NOTIFY_OK;
721} 732}
722 733
734static struct notifier_block usbfs_nb = {
735 .notifier_call = usbfs_notify,
736};
737
723/* --------------------------------------------------------------------- */ 738/* --------------------------------------------------------------------- */
724 739
725static struct proc_dir_entry *usbdir = NULL; 740static struct proc_dir_entry *usbdir = NULL;
@@ -732,6 +747,8 @@ int __init usbfs_init(void)
732 if (retval) 747 if (retval)
733 return retval; 748 return retval;
734 749
750 usb_register_notify(&usbfs_nb);
751
735 /* create mount point for usbfs */ 752 /* create mount point for usbfs */
736 usbdir = proc_mkdir("usb", proc_bus); 753 usbdir = proc_mkdir("usb", proc_bus);
737 754
@@ -740,6 +757,7 @@ int __init usbfs_init(void)
740 757
741void usbfs_cleanup(void) 758void usbfs_cleanup(void)
742{ 759{
760 usb_unregister_notify(&usbfs_nb);
743 unregister_filesystem(&usb_fs_type); 761 unregister_filesystem(&usb_fs_type);
744 if (usbdir) 762 if (usbdir)
745 remove_proc_entry("usb", proc_bus); 763 remove_proc_entry("usb", proc_bus);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f1fb67fe22a8..644a3d4f12aa 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -187,21 +187,37 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u
187 * If a thread in your driver uses this call, make sure your disconnect() 187 * If a thread in your driver uses this call, make sure your disconnect()
188 * method can wait for it to complete. Since you don't have a handle on 188 * method can wait for it to complete. Since you don't have a handle on
189 * the URB used, you can't cancel the request. 189 * the URB used, you can't cancel the request.
190 *
191 * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT
192 * ioctl, users are forced to abuse this routine by using it to submit
193 * URBs for interrupt endpoints. We will take the liberty of creating
194 * an interrupt URB (with the default interval) if the target is an
195 * interrupt endpoint.
190 */ 196 */
191int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, 197int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
192 void *data, int len, int *actual_length, int timeout) 198 void *data, int len, int *actual_length, int timeout)
193{ 199{
194 struct urb *urb; 200 struct urb *urb;
201 struct usb_host_endpoint *ep;
195 202
196 if (len < 0) 203 ep = (usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out)
204 [usb_pipeendpoint(pipe)];
205 if (!ep || len < 0)
197 return -EINVAL; 206 return -EINVAL;
198 207
199 urb=usb_alloc_urb(0, GFP_KERNEL); 208 urb = usb_alloc_urb(0, GFP_KERNEL);
200 if (!urb) 209 if (!urb)
201 return -ENOMEM; 210 return -ENOMEM;
202 211
203 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, 212 if ((ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
204 usb_api_blocking_completion, NULL); 213 USB_ENDPOINT_XFER_INT) {
214 pipe = (pipe & ~(3 << 30)) | (PIPE_INTERRUPT << 30);
215 usb_fill_int_urb(urb, usb_dev, pipe, data, len,
216 usb_api_blocking_completion, NULL,
217 ep->desc.bInterval);
218 } else
219 usb_fill_bulk_urb(urb, usb_dev, pipe, data, len,
220 usb_api_blocking_completion, NULL);
205 221
206 return usb_start_wait_urb(urb, timeout, actual_length); 222 return usb_start_wait_urb(urb, timeout, actual_length);
207} 223}
@@ -321,7 +337,7 @@ int usb_sg_init (
321 struct scatterlist *sg, 337 struct scatterlist *sg,
322 int nents, 338 int nents,
323 size_t length, 339 size_t length,
324 unsigned mem_flags 340 gfp_t mem_flags
325) 341)
326{ 342{
327 int i; 343 int i;
@@ -771,6 +787,31 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
771 return err; 787 return err;
772} 788}
773 789
790/**
791 * usb_cache_string - read a string descriptor and cache it for later use
792 * @udev: the device whose string descriptor is being read
793 * @index: the descriptor index
794 *
795 * Returns a pointer to a kmalloc'ed buffer containing the descriptor string,
796 * or NULL if the index is 0 or the string could not be read.
797 */
798char *usb_cache_string(struct usb_device *udev, int index)
799{
800 char *buf;
801 char *smallbuf = NULL;
802 int len;
803
804 if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) {
805 if ((len = usb_string(udev, index, buf, 256)) > 0) {
806 if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL)
807 return buf;
808 memcpy(smallbuf, buf, len);
809 }
810 kfree(buf);
811 }
812 return smallbuf;
813}
814
774/* 815/*
775 * usb_get_device_descriptor - (re)reads the device descriptor (usbcore) 816 * usb_get_device_descriptor - (re)reads the device descriptor (usbcore)
776 * @dev: the device whose device descriptor is being updated 817 * @dev: the device whose device descriptor is being updated
@@ -992,8 +1033,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
992 dev_dbg (&dev->dev, "unregistering interface %s\n", 1033 dev_dbg (&dev->dev, "unregistering interface %s\n",
993 interface->dev.bus_id); 1034 interface->dev.bus_id);
994 usb_remove_sysfs_intf_files(interface); 1035 usb_remove_sysfs_intf_files(interface);
995 kfree(interface->cur_altsetting->string);
996 interface->cur_altsetting->string = NULL;
997 device_del (&interface->dev); 1036 device_del (&interface->dev);
998 } 1037 }
999 1038
@@ -1133,6 +1172,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1133 */ 1172 */
1134 1173
1135 /* prevent submissions using previous endpoint settings */ 1174 /* prevent submissions using previous endpoint settings */
1175 if (device_is_registered(&iface->dev))
1176 usb_remove_sysfs_intf_files(iface);
1136 usb_disable_interface(dev, iface); 1177 usb_disable_interface(dev, iface);
1137 1178
1138 iface->cur_altsetting = alt; 1179 iface->cur_altsetting = alt;
@@ -1168,6 +1209,8 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1168 * (Likewise, EP0 never "halts" on well designed devices.) 1209 * (Likewise, EP0 never "halts" on well designed devices.)
1169 */ 1210 */
1170 usb_enable_interface(dev, iface); 1211 usb_enable_interface(dev, iface);
1212 if (device_is_registered(&iface->dev))
1213 usb_create_sysfs_intf_files(iface);
1171 1214
1172 return 0; 1215 return 0;
1173} 1216}
@@ -1217,10 +1260,8 @@ int usb_reset_configuration(struct usb_device *dev)
1217 USB_REQ_SET_CONFIGURATION, 0, 1260 USB_REQ_SET_CONFIGURATION, 0,
1218 config->desc.bConfigurationValue, 0, 1261 config->desc.bConfigurationValue, 0,
1219 NULL, 0, USB_CTRL_SET_TIMEOUT); 1262 NULL, 0, USB_CTRL_SET_TIMEOUT);
1220 if (retval < 0) { 1263 if (retval < 0)
1221 usb_set_device_state(dev, USB_STATE_ADDRESS);
1222 return retval; 1264 return retval;
1223 }
1224 1265
1225 dev->toggle[0] = dev->toggle[1] = 0; 1266 dev->toggle[0] = dev->toggle[1] = 0;
1226 1267
@@ -1229,6 +1270,8 @@ int usb_reset_configuration(struct usb_device *dev)
1229 struct usb_interface *intf = config->interface[i]; 1270 struct usb_interface *intf = config->interface[i];
1230 struct usb_host_interface *alt; 1271 struct usb_host_interface *alt;
1231 1272
1273 if (device_is_registered(&intf->dev))
1274 usb_remove_sysfs_intf_files(intf);
1232 alt = usb_altnum_to_altsetting(intf, 0); 1275 alt = usb_altnum_to_altsetting(intf, 0);
1233 1276
1234 /* No altsetting 0? We'll assume the first altsetting. 1277 /* No altsetting 0? We'll assume the first altsetting.
@@ -1241,6 +1284,8 @@ int usb_reset_configuration(struct usb_device *dev)
1241 1284
1242 intf->cur_altsetting = alt; 1285 intf->cur_altsetting = alt;
1243 usb_enable_interface(dev, intf); 1286 usb_enable_interface(dev, intf);
1287 if (device_is_registered(&intf->dev))
1288 usb_create_sysfs_intf_files(intf);
1244 } 1289 }
1245 return 0; 1290 return 0;
1246} 1291}
@@ -1328,7 +1373,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
1328 } 1373 }
1329 1374
1330 for (; n < nintf; ++n) { 1375 for (; n < nintf; ++n) {
1331 new_interfaces[n] = kmalloc( 1376 new_interfaces[n] = kzalloc(
1332 sizeof(struct usb_interface), 1377 sizeof(struct usb_interface),
1333 GFP_KERNEL); 1378 GFP_KERNEL);
1334 if (!new_interfaces[n]) { 1379 if (!new_interfaces[n]) {
@@ -1369,7 +1414,6 @@ free_interfaces:
1369 struct usb_host_interface *alt; 1414 struct usb_host_interface *alt;
1370 1415
1371 cp->interface[i] = intf = new_interfaces[i]; 1416 cp->interface[i] = intf = new_interfaces[i];
1372 memset(intf, 0, sizeof(*intf));
1373 intfc = cp->intf_cache[i]; 1417 intfc = cp->intf_cache[i];
1374 intf->altsetting = intfc->altsetting; 1418 intf->altsetting = intfc->altsetting;
1375 intf->num_altsetting = intfc->num_altsetting; 1419 intf->num_altsetting = intfc->num_altsetting;
@@ -1393,6 +1437,7 @@ free_interfaces:
1393 intf->dev.dma_mask = dev->dev.dma_mask; 1437 intf->dev.dma_mask = dev->dev.dma_mask;
1394 intf->dev.release = release_interface; 1438 intf->dev.release = release_interface;
1395 device_initialize (&intf->dev); 1439 device_initialize (&intf->dev);
1440 mark_quiesced(intf);
1396 sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", 1441 sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d",
1397 dev->bus->busnum, dev->devpath, 1442 dev->bus->busnum, dev->devpath,
1398 configuration, 1443 configuration,
@@ -1400,12 +1445,9 @@ free_interfaces:
1400 } 1445 }
1401 kfree(new_interfaces); 1446 kfree(new_interfaces);
1402 1447
1403 if ((cp->desc.iConfiguration) && 1448 if (cp->string == NULL)
1404 (cp->string == NULL)) { 1449 cp->string = usb_cache_string(dev,
1405 cp->string = kmalloc(256, GFP_KERNEL); 1450 cp->desc.iConfiguration);
1406 if (cp->string)
1407 usb_string(dev, cp->desc.iConfiguration, cp->string, 256);
1408 }
1409 1451
1410 /* Now that all the interfaces are set up, register them 1452 /* Now that all the interfaces are set up, register them
1411 * to trigger binding of drivers to interfaces. probe() 1453 * to trigger binding of drivers to interfaces. probe()
@@ -1415,13 +1457,12 @@ free_interfaces:
1415 */ 1457 */
1416 for (i = 0; i < nintf; ++i) { 1458 for (i = 0; i < nintf; ++i) {
1417 struct usb_interface *intf = cp->interface[i]; 1459 struct usb_interface *intf = cp->interface[i];
1418 struct usb_interface_descriptor *desc; 1460 struct usb_host_interface *alt = intf->cur_altsetting;
1419 1461
1420 desc = &intf->altsetting [0].desc;
1421 dev_dbg (&dev->dev, 1462 dev_dbg (&dev->dev,
1422 "adding %s (config #%d, interface %d)\n", 1463 "adding %s (config #%d, interface %d)\n",
1423 intf->dev.bus_id, configuration, 1464 intf->dev.bus_id, configuration,
1424 desc->bInterfaceNumber); 1465 alt->desc.bInterfaceNumber);
1425 ret = device_add (&intf->dev); 1466 ret = device_add (&intf->dev);
1426 if (ret != 0) { 1467 if (ret != 0) {
1427 dev_err(&dev->dev, 1468 dev_err(&dev->dev,
@@ -1430,13 +1471,6 @@ free_interfaces:
1430 ret); 1471 ret);
1431 continue; 1472 continue;
1432 } 1473 }
1433 if ((intf->cur_altsetting->desc.iInterface) &&
1434 (intf->cur_altsetting->string == NULL)) {
1435 intf->cur_altsetting->string = kmalloc(256, GFP_KERNEL);
1436 if (intf->cur_altsetting->string)
1437 usb_string(dev, intf->cur_altsetting->desc.iInterface,
1438 intf->cur_altsetting->string, 256);
1439 }
1440 usb_create_sysfs_intf_files (intf); 1474 usb_create_sysfs_intf_files (intf);
1441 } 1475 }
1442 } 1476 }
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c
new file mode 100644
index 000000000000..37da059eced7
--- /dev/null
+++ b/drivers/usb/core/notify.c
@@ -0,0 +1,120 @@
1/*
2 * All the USB notify logic
3 *
4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * notifier functions originally based on those in kernel/sys.c
7 * but fixed up to not be so broken.
8 *
9 */
10
11
12#include <linux/config.h>
13#include <linux/kernel.h>
14#include <linux/notifier.h>
15#ifdef CONFIG_USB_DEBUG
16 #define DEBUG
17#else
18 #undef DEBUG
19#endif
20#include <linux/usb.h>
21
22#include "usb.h"
23
24
25static struct notifier_block *usb_notifier_list;
26static DECLARE_MUTEX(usb_notifier_lock);
27
28static void usb_notifier_chain_register(struct notifier_block **list,
29 struct notifier_block *n)
30{
31 down(&usb_notifier_lock);
32 while (*list) {
33 if (n->priority > (*list)->priority)
34 break;
35 list = &((*list)->next);
36 }
37 n->next = *list;
38 *list = n;
39 up(&usb_notifier_lock);
40}
41
42static void usb_notifier_chain_unregister(struct notifier_block **nl,
43 struct notifier_block *n)
44{
45 down(&usb_notifier_lock);
46 while ((*nl)!=NULL) {
47 if ((*nl)==n) {
48 *nl = n->next;
49 goto exit;
50 }
51 nl=&((*nl)->next);
52 }
53exit:
54 up(&usb_notifier_lock);
55}
56
57static int usb_notifier_call_chain(struct notifier_block **n,
58 unsigned long val, void *v)
59{
60 int ret=NOTIFY_DONE;
61 struct notifier_block *nb = *n;
62
63 down(&usb_notifier_lock);
64 while (nb) {
65 ret = nb->notifier_call(nb,val,v);
66 if (ret&NOTIFY_STOP_MASK) {
67 goto exit;
68 }
69 nb = nb->next;
70 }
71exit:
72 up(&usb_notifier_lock);
73 return ret;
74}
75
76/**
77 * usb_register_notify - register a notifier callback whenever a usb change happens
78 * @nb: pointer to the notifier block for the callback events.
79 *
80 * These changes are either USB devices or busses being added or removed.
81 */
82void usb_register_notify(struct notifier_block *nb)
83{
84 usb_notifier_chain_register(&usb_notifier_list, nb);
85}
86EXPORT_SYMBOL_GPL(usb_register_notify);
87
88/**
89 * usb_unregister_notify - unregister a notifier callback
90 * @nb: pointer to the notifier block for the callback events.
91 *
92 * usb_register_notifier() must have been previously called for this function
93 * to work properly.
94 */
95void usb_unregister_notify(struct notifier_block *nb)
96{
97 usb_notifier_chain_unregister(&usb_notifier_list, nb);
98}
99EXPORT_SYMBOL_GPL(usb_unregister_notify);
100
101
102void usb_notify_add_device(struct usb_device *udev)
103{
104 usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_ADD, udev);
105}
106
107void usb_notify_remove_device(struct usb_device *udev)
108{
109 usb_notifier_call_chain(&usb_notifier_list, USB_DEVICE_REMOVE, udev);
110}
111
112void usb_notify_add_bus(struct usb_bus *ubus)
113{
114 usb_notifier_call_chain(&usb_notifier_list, USB_BUS_ADD, ubus);
115}
116
117void usb_notify_remove_bus(struct usb_bus *ubus)
118{
119 usb_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus);
120}
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 00297f113849..edd83e014452 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -22,9 +22,207 @@
22 22
23#include "usb.h" 23#include "usb.h"
24 24
25/* endpoint stuff */
26struct ep_object {
27 struct usb_endpoint_descriptor *desc;
28 struct usb_device *udev;
29 struct kobject kobj;
30};
31#define to_ep_object(_kobj) \
32 container_of(_kobj, struct ep_object, kobj)
33
34struct ep_attribute {
35 struct attribute attr;
36 ssize_t (*show)(struct usb_device *,
37 struct usb_endpoint_descriptor *, char *);
38};
39#define to_ep_attribute(_attr) \
40 container_of(_attr, struct ep_attribute, attr)
41
42#define EP_ATTR(_name) \
43struct ep_attribute ep_##_name = { \
44 .attr = {.name = #_name, .owner = THIS_MODULE, \
45 .mode = S_IRUGO}, \
46 .show = show_ep_##_name}
47
48#define usb_ep_attr(field, format_string) \
49static ssize_t show_ep_##field(struct usb_device *udev, \
50 struct usb_endpoint_descriptor *desc, \
51 char *buf) \
52{ \
53 return sprintf(buf, format_string, desc->field); \
54} \
55static EP_ATTR(field);
56
57usb_ep_attr(bLength, "%02x\n")
58usb_ep_attr(bEndpointAddress, "%02x\n")
59usb_ep_attr(bmAttributes, "%02x\n")
60usb_ep_attr(bInterval, "%02x\n")
61
62static ssize_t show_ep_wMaxPacketSize(struct usb_device *udev,
63 struct usb_endpoint_descriptor *desc, char *buf)
64{
65 return sprintf(buf, "%04x\n",
66 le16_to_cpu(desc->wMaxPacketSize) & 0x07ff);
67}
68static EP_ATTR(wMaxPacketSize);
69
70static ssize_t show_ep_type(struct usb_device *udev,
71 struct usb_endpoint_descriptor *desc, char *buf)
72{
73 char *type = "unknown";
74
75 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
76 case USB_ENDPOINT_XFER_CONTROL:
77 type = "Control";
78 break;
79 case USB_ENDPOINT_XFER_ISOC:
80 type = "Isoc";
81 break;
82 case USB_ENDPOINT_XFER_BULK:
83 type = "Bulk";
84 break;
85 case USB_ENDPOINT_XFER_INT:
86 type = "Interrupt";
87 break;
88 }
89 return sprintf(buf, "%s\n", type);
90}
91static EP_ATTR(type);
92
93static ssize_t show_ep_interval(struct usb_device *udev,
94 struct usb_endpoint_descriptor *desc, char *buf)
95{
96 char unit;
97 unsigned interval = 0;
98 unsigned in;
99
100 in = (desc->bEndpointAddress & USB_DIR_IN);
101
102 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
103 case USB_ENDPOINT_XFER_CONTROL:
104 if (udev->speed == USB_SPEED_HIGH) /* uframes per NAK */
105 interval = desc->bInterval;
106 break;
107 case USB_ENDPOINT_XFER_ISOC:
108 interval = 1 << (desc->bInterval - 1);
109 break;
110 case USB_ENDPOINT_XFER_BULK:
111 if (udev->speed == USB_SPEED_HIGH && !in) /* uframes per NAK */
112 interval = desc->bInterval;
113 break;
114 case USB_ENDPOINT_XFER_INT:
115 if (udev->speed == USB_SPEED_HIGH)
116 interval = 1 << (desc->bInterval - 1);
117 else
118 interval = desc->bInterval;
119 break;
120 }
121 interval *= (udev->speed == USB_SPEED_HIGH) ? 125 : 1000;
122 if (interval % 1000)
123 unit = 'u';
124 else {
125 unit = 'm';
126 interval /= 1000;
127 }
128
129 return sprintf(buf, "%d%cs\n", interval, unit);
130}
131static EP_ATTR(interval);
132
133static ssize_t show_ep_direction(struct usb_device *udev,
134 struct usb_endpoint_descriptor *desc, char *buf)
135{
136 char *direction;
137
138 if ((desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
139 USB_ENDPOINT_XFER_CONTROL)
140 direction = "both";
141 else if (desc->bEndpointAddress & USB_DIR_IN)
142 direction = "in";
143 else
144 direction = "out";
145 return sprintf(buf, "%s\n", direction);
146}
147static EP_ATTR(direction);
148
149static struct attribute *ep_attrs[] = {
150 &ep_bLength.attr,
151 &ep_bEndpointAddress.attr,
152 &ep_bmAttributes.attr,
153 &ep_bInterval.attr,
154 &ep_wMaxPacketSize.attr,
155 &ep_type.attr,
156 &ep_interval.attr,
157 &ep_direction.attr,
158 NULL,
159};
160
161static void ep_object_release(struct kobject *kobj)
162{
163 kfree(to_ep_object(kobj));
164}
165
166static ssize_t ep_object_show(struct kobject *kobj, struct attribute *attr,
167 char *buf)
168{
169 struct ep_object *ep_obj = to_ep_object(kobj);
170 struct ep_attribute *ep_attr = to_ep_attribute(attr);
171
172 return (ep_attr->show)(ep_obj->udev, ep_obj->desc, buf);
173}
174
175static struct sysfs_ops ep_object_sysfs_ops = {
176 .show = ep_object_show,
177};
178
179static struct kobj_type ep_object_ktype = {
180 .release = ep_object_release,
181 .sysfs_ops = &ep_object_sysfs_ops,
182 .default_attrs = ep_attrs,
183};
184
185static void usb_create_ep_files(struct kobject *parent,
186 struct usb_host_endpoint *endpoint,
187 struct usb_device *udev)
188{
189 struct ep_object *ep_obj;
190 struct kobject *kobj;
191
192 ep_obj = kzalloc(sizeof(struct ep_object), GFP_KERNEL);
193 if (!ep_obj)
194 return;
195
196 ep_obj->desc = &endpoint->desc;
197 ep_obj->udev = udev;
198
199 kobj = &ep_obj->kobj;
200 kobject_set_name(kobj, "ep_%02x", endpoint->desc.bEndpointAddress);
201 kobj->parent = parent;
202 kobj->ktype = &ep_object_ktype;
203
204 /* Don't use kobject_register, because it generates a hotplug event */
205 kobject_init(kobj);
206 if (kobject_add(kobj) == 0)
207 endpoint->kobj = kobj;
208 else
209 kobject_put(kobj);
210}
211
212static void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
213{
214
215 if (endpoint->kobj) {
216 kobject_del(endpoint->kobj);
217 kobject_put(endpoint->kobj);
218 endpoint->kobj = NULL;
219 }
220}
221
25/* Active configuration fields */ 222/* Active configuration fields */
26#define usb_actconfig_show(field, multiplier, format_string) \ 223#define usb_actconfig_show(field, multiplier, format_string) \
27static ssize_t show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 224static ssize_t show_##field (struct device *dev, \
225 struct device_attribute *attr, char *buf) \
28{ \ 226{ \
29 struct usb_device *udev; \ 227 struct usb_device *udev; \
30 struct usb_host_config *actconfig; \ 228 struct usb_host_config *actconfig; \
@@ -46,22 +244,17 @@ usb_actconfig_attr (bNumInterfaces, 1, "%2d\n")
46usb_actconfig_attr (bmAttributes, 1, "%2x\n") 244usb_actconfig_attr (bmAttributes, 1, "%2x\n")
47usb_actconfig_attr (bMaxPower, 2, "%3dmA\n") 245usb_actconfig_attr (bMaxPower, 2, "%3dmA\n")
48 246
49static ssize_t show_configuration_string(struct device *dev, struct device_attribute *attr, char *buf) 247static ssize_t show_configuration_string(struct device *dev,
248 struct device_attribute *attr, char *buf)
50{ 249{
51 struct usb_device *udev; 250 struct usb_device *udev;
52 struct usb_host_config *actconfig; 251 struct usb_host_config *actconfig;
53 int len;
54 252
55 udev = to_usb_device (dev); 253 udev = to_usb_device (dev);
56 actconfig = udev->actconfig; 254 actconfig = udev->actconfig;
57 if ((!actconfig) || (!actconfig->string)) 255 if ((!actconfig) || (!actconfig->string))
58 return 0; 256 return 0;
59 len = sprintf(buf, actconfig->string, PAGE_SIZE); 257 return sprintf(buf, "%s\n", actconfig->string);
60 if (len < 0)
61 return 0;
62 buf[len] = '\n';
63 buf[len+1] = 0;
64 return len+1;
65} 258}
66static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL); 259static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL);
67 260
@@ -69,7 +262,8 @@ static DEVICE_ATTR(configuration, S_IRUGO, show_configuration_string, NULL);
69usb_actconfig_show(bConfigurationValue, 1, "%u\n"); 262usb_actconfig_show(bConfigurationValue, 1, "%u\n");
70 263
71static ssize_t 264static ssize_t
72set_bConfigurationValue (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 265set_bConfigurationValue (struct device *dev, struct device_attribute *attr,
266 const char *buf, size_t count)
73{ 267{
74 struct usb_device *udev = udev = to_usb_device (dev); 268 struct usb_device *udev = udev = to_usb_device (dev);
75 int config, value; 269 int config, value;
@@ -87,18 +281,13 @@ static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR,
87 281
88/* String fields */ 282/* String fields */
89#define usb_string_attr(name) \ 283#define usb_string_attr(name) \
90static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ 284static ssize_t show_##name(struct device *dev, \
285 struct device_attribute *attr, char *buf) \
91{ \ 286{ \
92 struct usb_device *udev; \ 287 struct usb_device *udev; \
93 int len; \
94 \ 288 \
95 udev = to_usb_device (dev); \ 289 udev = to_usb_device (dev); \
96 len = snprintf(buf, 256, "%s", udev->name); \ 290 return sprintf(buf, "%s\n", udev->name); \
97 if (len < 0) \
98 return 0; \
99 buf[len] = '\n'; \
100 buf[len+1] = 0; \
101 return len+1; \
102} \ 291} \
103static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); 292static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
104 293
@@ -167,7 +356,8 @@ static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL);
167/* Descriptor fields */ 356/* Descriptor fields */
168#define usb_descriptor_attr_le16(field, format_string) \ 357#define usb_descriptor_attr_le16(field, format_string) \
169static ssize_t \ 358static ssize_t \
170show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 359show_##field (struct device *dev, struct device_attribute *attr, \
360 char *buf) \
171{ \ 361{ \
172 struct usb_device *udev; \ 362 struct usb_device *udev; \
173 \ 363 \
@@ -183,7 +373,8 @@ usb_descriptor_attr_le16(bcdDevice, "%04x\n")
183 373
184#define usb_descriptor_attr(field, format_string) \ 374#define usb_descriptor_attr(field, format_string) \
185static ssize_t \ 375static ssize_t \
186show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 376show_##field (struct device *dev, struct device_attribute *attr, \
377 char *buf) \
187{ \ 378{ \
188 struct usb_device *udev; \ 379 struct usb_device *udev; \
189 \ 380 \
@@ -236,19 +427,21 @@ void usb_create_sysfs_dev_files (struct usb_device *udev)
236 if (udev->serial) 427 if (udev->serial)
237 device_create_file (dev, &dev_attr_serial); 428 device_create_file (dev, &dev_attr_serial);
238 device_create_file (dev, &dev_attr_configuration); 429 device_create_file (dev, &dev_attr_configuration);
430 usb_create_ep_files(&dev->kobj, &udev->ep0, udev);
239} 431}
240 432
241void usb_remove_sysfs_dev_files (struct usb_device *udev) 433void usb_remove_sysfs_dev_files (struct usb_device *udev)
242{ 434{
243 struct device *dev = &udev->dev; 435 struct device *dev = &udev->dev;
244 436
437 usb_remove_ep_files(&udev->ep0);
245 sysfs_remove_group(&dev->kobj, &dev_attr_grp); 438 sysfs_remove_group(&dev->kobj, &dev_attr_grp);
246 439
247 if (udev->descriptor.iManufacturer) 440 if (udev->manufacturer)
248 device_remove_file(dev, &dev_attr_manufacturer); 441 device_remove_file(dev, &dev_attr_manufacturer);
249 if (udev->descriptor.iProduct) 442 if (udev->product)
250 device_remove_file(dev, &dev_attr_product); 443 device_remove_file(dev, &dev_attr_product);
251 if (udev->descriptor.iSerialNumber) 444 if (udev->serial)
252 device_remove_file(dev, &dev_attr_serial); 445 device_remove_file(dev, &dev_attr_serial);
253 device_remove_file (dev, &dev_attr_configuration); 446 device_remove_file (dev, &dev_attr_configuration);
254} 447}
@@ -256,11 +449,13 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev)
256/* Interface fields */ 449/* Interface fields */
257#define usb_intf_attr(field, format_string) \ 450#define usb_intf_attr(field, format_string) \
258static ssize_t \ 451static ssize_t \
259show_##field (struct device *dev, struct device_attribute *attr, char *buf) \ 452show_##field (struct device *dev, struct device_attribute *attr, \
453 char *buf) \
260{ \ 454{ \
261 struct usb_interface *intf = to_usb_interface (dev); \ 455 struct usb_interface *intf = to_usb_interface (dev); \
262 \ 456 \
263 return sprintf (buf, format_string, intf->cur_altsetting->desc.field); \ 457 return sprintf (buf, format_string, \
458 intf->cur_altsetting->desc.field); \
264} \ 459} \
265static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL); 460static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
266 461
@@ -271,7 +466,8 @@ usb_intf_attr (bInterfaceClass, "%02x\n")
271usb_intf_attr (bInterfaceSubClass, "%02x\n") 466usb_intf_attr (bInterfaceSubClass, "%02x\n")
272usb_intf_attr (bInterfaceProtocol, "%02x\n") 467usb_intf_attr (bInterfaceProtocol, "%02x\n")
273 468
274static ssize_t show_interface_string(struct device *dev, struct device_attribute *attr, char *buf) 469static ssize_t show_interface_string(struct device *dev,
470 struct device_attribute *attr, char *buf)
275{ 471{
276 struct usb_interface *intf; 472 struct usb_interface *intf;
277 struct usb_device *udev; 473 struct usb_device *udev;
@@ -288,34 +484,28 @@ static ssize_t show_interface_string(struct device *dev, struct device_attribute
288} 484}
289static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 485static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
290 486
291static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) 487static ssize_t show_modalias(struct device *dev,
488 struct device_attribute *attr, char *buf)
292{ 489{
293 struct usb_interface *intf; 490 struct usb_interface *intf;
294 struct usb_device *udev; 491 struct usb_device *udev;
295 int len; 492 struct usb_host_interface *alt;
296 493
297 intf = to_usb_interface(dev); 494 intf = to_usb_interface(dev);
298 udev = interface_to_usbdev(intf); 495 udev = interface_to_usbdev(intf);
299 496 alt = intf->cur_altsetting;
300 len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", 497
301 le16_to_cpu(udev->descriptor.idVendor), 498 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
302 le16_to_cpu(udev->descriptor.idProduct), 499 "ic%02Xisc%02Xip%02X\n",
303 le16_to_cpu(udev->descriptor.bcdDevice), 500 le16_to_cpu(udev->descriptor.idVendor),
304 udev->descriptor.bDeviceClass, 501 le16_to_cpu(udev->descriptor.idProduct),
305 udev->descriptor.bDeviceSubClass, 502 le16_to_cpu(udev->descriptor.bcdDevice),
306 udev->descriptor.bDeviceProtocol); 503 udev->descriptor.bDeviceClass,
307 buf += len; 504 udev->descriptor.bDeviceSubClass,
308 505 udev->descriptor.bDeviceProtocol,
309 if (udev->descriptor.bDeviceClass == 0) { 506 alt->desc.bInterfaceClass,
310 struct usb_host_interface *alt = intf->cur_altsetting; 507 alt->desc.bInterfaceSubClass,
311 508 alt->desc.bInterfaceProtocol);
312 return len + sprintf(buf, "%02Xisc%02Xip%02X\n",
313 alt->desc.bInterfaceClass,
314 alt->desc.bInterfaceSubClass,
315 alt->desc.bInterfaceProtocol);
316 } else {
317 return len + sprintf(buf, "*isc*ip*\n");
318 }
319} 509}
320static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 510static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
321 511
@@ -333,20 +523,47 @@ static struct attribute_group intf_attr_grp = {
333 .attrs = intf_attrs, 523 .attrs = intf_attrs,
334}; 524};
335 525
526static inline void usb_create_intf_ep_files(struct usb_interface *intf,
527 struct usb_device *udev)
528{
529 struct usb_host_interface *iface_desc;
530 int i;
531
532 iface_desc = intf->cur_altsetting;
533 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
534 usb_create_ep_files(&intf->dev.kobj, &iface_desc->endpoint[i],
535 udev);
536}
537
538static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
539{
540 struct usb_host_interface *iface_desc;
541 int i;
542
543 iface_desc = intf->cur_altsetting;
544 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
545 usb_remove_ep_files(&iface_desc->endpoint[i]);
546}
547
336void usb_create_sysfs_intf_files (struct usb_interface *intf) 548void usb_create_sysfs_intf_files (struct usb_interface *intf)
337{ 549{
550 struct usb_device *udev = interface_to_usbdev(intf);
551 struct usb_host_interface *alt = intf->cur_altsetting;
552
338 sysfs_create_group(&intf->dev.kobj, &intf_attr_grp); 553 sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
339 554
340 if (intf->cur_altsetting->string) 555 if (alt->string == NULL)
556 alt->string = usb_cache_string(udev, alt->desc.iInterface);
557 if (alt->string)
341 device_create_file(&intf->dev, &dev_attr_interface); 558 device_create_file(&intf->dev, &dev_attr_interface);
342 559 usb_create_intf_ep_files(intf, udev);
343} 560}
344 561
345void usb_remove_sysfs_intf_files (struct usb_interface *intf) 562void usb_remove_sysfs_intf_files (struct usb_interface *intf)
346{ 563{
564 usb_remove_intf_ep_files(intf);
347 sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp); 565 sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);
348 566
349 if (intf->cur_altsetting->string) 567 if (intf->cur_altsetting->string)
350 device_remove_file(&intf->dev, &dev_attr_interface); 568 device_remove_file(&intf->dev, &dev_attr_interface);
351
352} 569}
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index c846fefb7386..f2a1fed2a802 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -60,7 +60,7 @@ void usb_init_urb(struct urb *urb)
60 * 60 *
61 * The driver must call usb_free_urb() when it is finished with the urb. 61 * The driver must call usb_free_urb() when it is finished with the urb.
62 */ 62 */
63struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags) 63struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)
64{ 64{
65 struct urb *urb; 65 struct urb *urb;
66 66
@@ -224,7 +224,7 @@ struct urb * usb_get_urb(struct urb *urb)
224 * GFP_NOIO, unless b) or c) apply 224 * GFP_NOIO, unless b) or c) apply
225 * 225 *
226 */ 226 */
227int usb_submit_urb(struct urb *urb, unsigned mem_flags) 227int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
228{ 228{
229 int pipe, temp, max; 229 int pipe, temp, max;
230 struct usb_device *dev; 230 struct usb_device *dev;
@@ -237,7 +237,8 @@ int usb_submit_urb(struct urb *urb, unsigned mem_flags)
237 (dev->state < USB_STATE_DEFAULT) || 237 (dev->state < USB_STATE_DEFAULT) ||
238 (!dev->bus) || (dev->devnum <= 0)) 238 (!dev->bus) || (dev->devnum <= 0))
239 return -ENODEV; 239 return -ENODEV;
240 if (dev->state == USB_STATE_SUSPENDED) 240 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON
241 || dev->state == USB_STATE_SUSPENDED)
241 return -EHOSTUNREACH; 242 return -EHOSTUNREACH;
242 if (!(op = dev->bus->op) || !op->submit_urb) 243 if (!(op = dev->bus->op) || !op->submit_urb)
243 return -ENODEV; 244 return -ENODEV;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 7d131509e419..0eefff7bcb3c 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -107,10 +107,19 @@ static int usb_probe_interface(struct device *dev)
107 id = usb_match_id (intf, driver->id_table); 107 id = usb_match_id (intf, driver->id_table);
108 if (id) { 108 if (id) {
109 dev_dbg (dev, "%s - got id\n", __FUNCTION__); 109 dev_dbg (dev, "%s - got id\n", __FUNCTION__);
110
111 /* Interface "power state" doesn't correspond to any hardware
112 * state whatsoever. We use it to record when it's bound to
113 * a driver that may start I/0: it's not frozen/quiesced.
114 */
115 mark_active(intf);
110 intf->condition = USB_INTERFACE_BINDING; 116 intf->condition = USB_INTERFACE_BINDING;
111 error = driver->probe (intf, id); 117 error = driver->probe (intf, id);
112 intf->condition = error ? USB_INTERFACE_UNBOUND : 118 if (error) {
113 USB_INTERFACE_BOUND; 119 mark_quiesced(intf);
120 intf->condition = USB_INTERFACE_UNBOUND;
121 } else
122 intf->condition = USB_INTERFACE_BOUND;
114 } 123 }
115 124
116 return error; 125 return error;
@@ -136,6 +145,7 @@ static int usb_unbind_interface(struct device *dev)
136 0); 145 0);
137 usb_set_intfdata(intf, NULL); 146 usb_set_intfdata(intf, NULL);
138 intf->condition = USB_INTERFACE_UNBOUND; 147 intf->condition = USB_INTERFACE_UNBOUND;
148 mark_quiesced(intf);
139 149
140 return 0; 150 return 0;
141} 151}
@@ -299,6 +309,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
299 dev->driver = &driver->driver; 309 dev->driver = &driver->driver;
300 usb_set_intfdata(iface, priv); 310 usb_set_intfdata(iface, priv);
301 iface->condition = USB_INTERFACE_BOUND; 311 iface->condition = USB_INTERFACE_BOUND;
312 mark_active(iface);
302 313
303 /* if interface was already added, bind now; else let 314 /* if interface was already added, bind now; else let
304 * the future device_add() bind it, bypassing probe() 315 * the future device_add() bind it, bypassing probe()
@@ -345,6 +356,7 @@ void usb_driver_release_interface(struct usb_driver *driver,
345 dev->driver = NULL; 356 dev->driver = NULL;
346 usb_set_intfdata(iface, NULL); 357 usb_set_intfdata(iface, NULL);
347 iface->condition = USB_INTERFACE_UNBOUND; 358 iface->condition = USB_INTERFACE_UNBOUND;
359 mark_quiesced(iface);
348} 360}
349 361
350/** 362/**
@@ -557,6 +569,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
557{ 569{
558 struct usb_interface *intf; 570 struct usb_interface *intf;
559 struct usb_device *usb_dev; 571 struct usb_device *usb_dev;
572 struct usb_host_interface *alt;
560 int i = 0; 573 int i = 0;
561 int length = 0; 574 int length = 0;
562 575
@@ -573,7 +586,8 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
573 586
574 intf = to_usb_interface(dev); 587 intf = to_usb_interface(dev);
575 usb_dev = interface_to_usbdev (intf); 588 usb_dev = interface_to_usbdev (intf);
576 589 alt = intf->cur_altsetting;
590
577 if (usb_dev->devnum < 0) { 591 if (usb_dev->devnum < 0) {
578 pr_debug ("usb %s: already deleted?\n", dev->bus_id); 592 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
579 return -ENODEV; 593 return -ENODEV;
@@ -615,46 +629,27 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
615 usb_dev->descriptor.bDeviceProtocol)) 629 usb_dev->descriptor.bDeviceProtocol))
616 return -ENOMEM; 630 return -ENOMEM;
617 631
618 if (usb_dev->descriptor.bDeviceClass == 0) { 632 if (add_hotplug_env_var(envp, num_envp, &i,
619 struct usb_host_interface *alt = intf->cur_altsetting; 633 buffer, buffer_size, &length,
634 "INTERFACE=%d/%d/%d",
635 alt->desc.bInterfaceClass,
636 alt->desc.bInterfaceSubClass,
637 alt->desc.bInterfaceProtocol))
638 return -ENOMEM;
620 639
621 /* 2.4 only exposed interface zero. in 2.5, hotplug 640 if (add_hotplug_env_var(envp, num_envp, &i,
622 * agents are called for all interfaces, and can use 641 buffer, buffer_size, &length,
623 * $DEVPATH/bInterfaceNumber if necessary. 642 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
624 */ 643 le16_to_cpu(usb_dev->descriptor.idVendor),
625 if (add_hotplug_env_var(envp, num_envp, &i, 644 le16_to_cpu(usb_dev->descriptor.idProduct),
626 buffer, buffer_size, &length, 645 le16_to_cpu(usb_dev->descriptor.bcdDevice),
627 "INTERFACE=%d/%d/%d", 646 usb_dev->descriptor.bDeviceClass,
628 alt->desc.bInterfaceClass, 647 usb_dev->descriptor.bDeviceSubClass,
629 alt->desc.bInterfaceSubClass, 648 usb_dev->descriptor.bDeviceProtocol,
630 alt->desc.bInterfaceProtocol)) 649 alt->desc.bInterfaceClass,
631 return -ENOMEM; 650 alt->desc.bInterfaceSubClass,
632 651 alt->desc.bInterfaceProtocol))
633 if (add_hotplug_env_var(envp, num_envp, &i, 652 return -ENOMEM;
634 buffer, buffer_size, &length,
635 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
636 le16_to_cpu(usb_dev->descriptor.idVendor),
637 le16_to_cpu(usb_dev->descriptor.idProduct),
638 le16_to_cpu(usb_dev->descriptor.bcdDevice),
639 usb_dev->descriptor.bDeviceClass,
640 usb_dev->descriptor.bDeviceSubClass,
641 usb_dev->descriptor.bDeviceProtocol,
642 alt->desc.bInterfaceClass,
643 alt->desc.bInterfaceSubClass,
644 alt->desc.bInterfaceProtocol))
645 return -ENOMEM;
646 } else {
647 if (add_hotplug_env_var(envp, num_envp, &i,
648 buffer, buffer_size, &length,
649 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*",
650 le16_to_cpu(usb_dev->descriptor.idVendor),
651 le16_to_cpu(usb_dev->descriptor.idProduct),
652 le16_to_cpu(usb_dev->descriptor.bcdDevice),
653 usb_dev->descriptor.bDeviceClass,
654 usb_dev->descriptor.bDeviceSubClass,
655 usb_dev->descriptor.bDeviceProtocol))
656 return -ENOMEM;
657 }
658 653
659 envp[i] = NULL; 654 envp[i] = NULL;
660 655
@@ -709,12 +704,10 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
709{ 704{
710 struct usb_device *dev; 705 struct usb_device *dev;
711 706
712 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 707 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
713 if (!dev) 708 if (!dev)
714 return NULL; 709 return NULL;
715 710
716 memset(dev, 0, sizeof(*dev));
717
718 bus = usb_bus_get(bus); 711 bus = usb_bus_get(bus);
719 if (!bus) { 712 if (!bus) {
720 kfree(dev); 713 kfree(dev);
@@ -1147,7 +1140,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
1147void *usb_buffer_alloc ( 1140void *usb_buffer_alloc (
1148 struct usb_device *dev, 1141 struct usb_device *dev,
1149 size_t size, 1142 size_t size,
1150 unsigned mem_flags, 1143 gfp_t mem_flags,
1151 dma_addr_t *dma 1144 dma_addr_t *dma
1152) 1145)
1153{ 1146{
@@ -1402,13 +1395,30 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
1402 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 1395 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
1403} 1396}
1404 1397
1398static int verify_suspended(struct device *dev, void *unused)
1399{
1400 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
1401}
1402
1405static int usb_generic_suspend(struct device *dev, pm_message_t message) 1403static int usb_generic_suspend(struct device *dev, pm_message_t message)
1406{ 1404{
1407 struct usb_interface *intf; 1405 struct usb_interface *intf;
1408 struct usb_driver *driver; 1406 struct usb_driver *driver;
1407 int status;
1409 1408
1410 if (dev->driver == &usb_generic_driver) 1409 /* USB devices enter SUSPEND state through their hubs, but can be
1411 return usb_suspend_device (to_usb_device(dev), message); 1410 * marked for FREEZE as soon as their children are already idled.
1411 * But those semantics are useless, so we equate the two (sigh).
1412 */
1413 if (dev->driver == &usb_generic_driver) {
1414 if (dev->power.power_state.event == message.event)
1415 return 0;
1416 /* we need to rule out bogus requests through sysfs */
1417 status = device_for_each_child(dev, NULL, verify_suspended);
1418 if (status)
1419 return status;
1420 return usb_suspend_device (to_usb_device(dev));
1421 }
1412 1422
1413 if ((dev->driver == NULL) || 1423 if ((dev->driver == NULL) ||
1414 (dev->driver_data == &usb_generic_driver_data)) 1424 (dev->driver_data == &usb_generic_driver_data))
@@ -1417,23 +1427,44 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message)
1417 intf = to_usb_interface(dev); 1427 intf = to_usb_interface(dev);
1418 driver = to_usb_driver(dev->driver); 1428 driver = to_usb_driver(dev->driver);
1419 1429
1420 /* there's only one USB suspend state */ 1430 /* with no hardware, USB interfaces only use FREEZE and ON states */
1421 if (intf->dev.power.power_state.event) 1431 if (!is_active(intf))
1422 return 0; 1432 return 0;
1423 1433
1424 if (driver->suspend) 1434 if (driver->suspend && driver->resume) {
1425 return driver->suspend(intf, message); 1435 status = driver->suspend(intf, message);
1426 return 0; 1436 if (status)
1437 dev_err(dev, "%s error %d\n", "suspend", status);
1438 else
1439 mark_quiesced(intf);
1440 } else {
1441 // FIXME else if there's no suspend method, disconnect...
1442 dev_warn(dev, "no %s?\n", "suspend");
1443 status = 0;
1444 }
1445 return status;
1427} 1446}
1428 1447
1429static int usb_generic_resume(struct device *dev) 1448static int usb_generic_resume(struct device *dev)
1430{ 1449{
1431 struct usb_interface *intf; 1450 struct usb_interface *intf;
1432 struct usb_driver *driver; 1451 struct usb_driver *driver;
1452 struct usb_device *udev;
1453 int status;
1433 1454
1434 /* devices resume through their hub */ 1455 if (dev->power.power_state.event == PM_EVENT_ON)
1435 if (dev->driver == &usb_generic_driver) 1456 return 0;
1457
1458 /* mark things as "on" immediately, no matter what errors crop up */
1459 dev->power.power_state.event = PM_EVENT_ON;
1460
1461 /* devices resume through their hubs */
1462 if (dev->driver == &usb_generic_driver) {
1463 udev = to_usb_device(dev);
1464 if (udev->state == USB_STATE_NOTATTACHED)
1465 return 0;
1436 return usb_resume_device (to_usb_device(dev)); 1466 return usb_resume_device (to_usb_device(dev));
1467 }
1437 1468
1438 if ((dev->driver == NULL) || 1469 if ((dev->driver == NULL) ||
1439 (dev->driver_data == &usb_generic_driver_data)) 1470 (dev->driver_data == &usb_generic_driver_data))
@@ -1442,8 +1473,22 @@ static int usb_generic_resume(struct device *dev)
1442 intf = to_usb_interface(dev); 1473 intf = to_usb_interface(dev);
1443 driver = to_usb_driver(dev->driver); 1474 driver = to_usb_driver(dev->driver);
1444 1475
1445 if (driver->resume) 1476 udev = interface_to_usbdev(intf);
1446 return driver->resume(intf); 1477 if (udev->state == USB_STATE_NOTATTACHED)
1478 return 0;
1479
1480 /* if driver was suspended, it has a resume method;
1481 * however, sysfs can wrongly mark things as suspended
1482 * (on the "no suspend method" FIXME path above)
1483 */
1484 if (driver->resume) {
1485 status = driver->resume(intf);
1486 if (status) {
1487 dev_err(dev, "%s error %d\n", "resume", status);
1488 mark_quiesced(intf);
1489 }
1490 } else
1491 dev_warn(dev, "no %s?\n", "resume");
1447 return 0; 1492 return 0;
1448} 1493}
1449 1494
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index e6504f3370ad..1c4a68499dce 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -13,12 +13,14 @@ extern void usb_disable_device (struct usb_device *dev, int skip_ep0);
13 13
14extern int usb_get_device_descriptor(struct usb_device *dev, 14extern int usb_get_device_descriptor(struct usb_device *dev,
15 unsigned int size); 15 unsigned int size);
16extern char *usb_cache_string(struct usb_device *udev, int index);
16extern int usb_set_configuration(struct usb_device *dev, int configuration); 17extern int usb_set_configuration(struct usb_device *dev, int configuration);
17 18
18extern void usb_lock_all_devices(void); 19extern void usb_lock_all_devices(void);
19extern void usb_unlock_all_devices(void); 20extern void usb_unlock_all_devices(void);
20 21
21extern void usb_kick_khubd(struct usb_device *dev); 22extern void usb_kick_khubd(struct usb_device *dev);
23extern void usb_suspend_root_hub(struct usb_device *hdev);
22extern void usb_resume_root_hub(struct usb_device *dev); 24extern void usb_resume_root_hub(struct usb_device *dev);
23 25
24extern int usb_hub_init(void); 26extern int usb_hub_init(void);
@@ -28,6 +30,28 @@ extern void usb_major_cleanup(void);
28extern int usb_host_init(void); 30extern int usb_host_init(void);
29extern void usb_host_cleanup(void); 31extern void usb_host_cleanup(void);
30 32
33extern int usb_suspend_device(struct usb_device *dev);
34extern int usb_resume_device(struct usb_device *dev);
35
36
37/* Interfaces and their "power state" are owned by usbcore */
38
39static inline void mark_active(struct usb_interface *f)
40{
41 f->dev.power.power_state.event = PM_EVENT_ON;
42}
43
44static inline void mark_quiesced(struct usb_interface *f)
45{
46 f->dev.power.power_state.event = PM_EVENT_FREEZE;
47}
48
49static inline int is_active(struct usb_interface *f)
50{
51 return f->dev.power.power_state.event == PM_EVENT_ON;
52}
53
54
31/* for labeling diagnostics */ 55/* for labeling diagnostics */
32extern const char *usbcore_name; 56extern const char *usbcore_name;
33 57
@@ -39,9 +63,6 @@ extern void usbfs_conn_disc_event(void);
39 63
40extern int usbdev_init(void); 64extern int usbdev_init(void);
41extern void usbdev_cleanup(void); 65extern void usbdev_cleanup(void);
42extern void usbdev_add(struct usb_device *dev);
43extern void usbdev_remove(struct usb_device *dev);
44extern struct usb_device *usbdev_lookup_minor(int minor);
45 66
46struct dev_state { 67struct dev_state {
47 struct list_head list; /* state list */ 68 struct list_head list; /* state list */
@@ -58,3 +79,9 @@ struct dev_state {
58 unsigned long ifclaimed; 79 unsigned long ifclaimed;
59}; 80};
60 81
82/* internal notify stuff */
83extern void usb_notify_add_device(struct usb_device *udev);
84extern void usb_notify_remove_device(struct usb_device *udev);
85extern void usb_notify_add_bus(struct usb_bus *ubus);
86extern void usb_notify_remove_bus(struct usb_bus *ubus);
87
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 583db7c38cf1..02106bebd5c1 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -470,7 +470,7 @@ static int dummy_disable (struct usb_ep *_ep)
470} 470}
471 471
472static struct usb_request * 472static struct usb_request *
473dummy_alloc_request (struct usb_ep *_ep, unsigned mem_flags) 473dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags)
474{ 474{
475 struct dummy_ep *ep; 475 struct dummy_ep *ep;
476 struct dummy_request *req; 476 struct dummy_request *req;
@@ -507,7 +507,7 @@ dummy_alloc_buffer (
507 struct usb_ep *_ep, 507 struct usb_ep *_ep,
508 unsigned bytes, 508 unsigned bytes,
509 dma_addr_t *dma, 509 dma_addr_t *dma,
510 unsigned mem_flags 510 gfp_t mem_flags
511) { 511) {
512 char *retval; 512 char *retval;
513 struct dummy_ep *ep; 513 struct dummy_ep *ep;
@@ -541,7 +541,7 @@ fifo_complete (struct usb_ep *ep, struct usb_request *req)
541 541
542static int 542static int
543dummy_queue (struct usb_ep *_ep, struct usb_request *_req, 543dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
544 unsigned mem_flags) 544 gfp_t mem_flags)
545{ 545{
546 struct dummy_ep *ep; 546 struct dummy_ep *ep;
547 struct dummy_request *req; 547 struct dummy_request *req;
@@ -935,14 +935,10 @@ static int dummy_udc_remove (struct device *dev)
935 return 0; 935 return 0;
936} 936}
937 937
938static int dummy_udc_suspend (struct device *dev, pm_message_t state, 938static int dummy_udc_suspend (struct device *dev, pm_message_t state)
939 u32 level)
940{ 939{
941 struct dummy *dum = dev_get_drvdata(dev); 940 struct dummy *dum = dev_get_drvdata(dev);
942 941
943 if (level != SUSPEND_DISABLE)
944 return 0;
945
946 dev_dbg (dev, "%s\n", __FUNCTION__); 942 dev_dbg (dev, "%s\n", __FUNCTION__);
947 spin_lock_irq (&dum->lock); 943 spin_lock_irq (&dum->lock);
948 dum->udc_suspended = 1; 944 dum->udc_suspended = 1;
@@ -954,13 +950,10 @@ static int dummy_udc_suspend (struct device *dev, pm_message_t state,
954 return 0; 950 return 0;
955} 951}
956 952
957static int dummy_udc_resume (struct device *dev, u32 level) 953static int dummy_udc_resume (struct device *dev)
958{ 954{
959 struct dummy *dum = dev_get_drvdata(dev); 955 struct dummy *dum = dev_get_drvdata(dev);
960 956
961 if (level != RESUME_ENABLE)
962 return 0;
963
964 dev_dbg (dev, "%s\n", __FUNCTION__); 957 dev_dbg (dev, "%s\n", __FUNCTION__);
965 spin_lock_irq (&dum->lock); 958 spin_lock_irq (&dum->lock);
966 dum->udc_suspended = 0; 959 dum->udc_suspended = 0;
@@ -974,6 +967,7 @@ static int dummy_udc_resume (struct device *dev, u32 level)
974 967
975static struct device_driver dummy_udc_driver = { 968static struct device_driver dummy_udc_driver = {
976 .name = (char *) gadget_name, 969 .name = (char *) gadget_name,
970 .owner = THIS_MODULE,
977 .bus = &platform_bus_type, 971 .bus = &platform_bus_type,
978 .probe = dummy_udc_probe, 972 .probe = dummy_udc_probe,
979 .remove = dummy_udc_remove, 973 .remove = dummy_udc_remove,
@@ -999,7 +993,7 @@ static int dummy_urb_enqueue (
999 struct usb_hcd *hcd, 993 struct usb_hcd *hcd,
1000 struct usb_host_endpoint *ep, 994 struct usb_host_endpoint *ep,
1001 struct urb *urb, 995 struct urb *urb,
1002 unsigned mem_flags 996 gfp_t mem_flags
1003) { 997) {
1004 struct dummy *dum; 998 struct dummy *dum;
1005 struct urbp *urbp; 999 struct urbp *urbp;
@@ -1758,7 +1752,7 @@ static int dummy_hub_control (
1758 return retval; 1752 return retval;
1759} 1753}
1760 1754
1761static int dummy_hub_suspend (struct usb_hcd *hcd) 1755static int dummy_bus_suspend (struct usb_hcd *hcd)
1762{ 1756{
1763 struct dummy *dum = hcd_to_dummy (hcd); 1757 struct dummy *dum = hcd_to_dummy (hcd);
1764 1758
@@ -1769,7 +1763,7 @@ static int dummy_hub_suspend (struct usb_hcd *hcd)
1769 return 0; 1763 return 0;
1770} 1764}
1771 1765
1772static int dummy_hub_resume (struct usb_hcd *hcd) 1766static int dummy_bus_resume (struct usb_hcd *hcd)
1773{ 1767{
1774 struct dummy *dum = hcd_to_dummy (hcd); 1768 struct dummy *dum = hcd_to_dummy (hcd);
1775 1769
@@ -1901,8 +1895,8 @@ static const struct hc_driver dummy_hcd = {
1901 1895
1902 .hub_status_data = dummy_hub_status, 1896 .hub_status_data = dummy_hub_status,
1903 .hub_control = dummy_hub_control, 1897 .hub_control = dummy_hub_control,
1904 .hub_suspend = dummy_hub_suspend, 1898 .bus_suspend = dummy_bus_suspend,
1905 .hub_resume = dummy_hub_resume, 1899 .bus_resume = dummy_bus_resume,
1906}; 1900};
1907 1901
1908static int dummy_hcd_probe (struct device *dev) 1902static int dummy_hcd_probe (struct device *dev)
@@ -1936,52 +1930,32 @@ static int dummy_hcd_remove (struct device *dev)
1936 return 0; 1930 return 0;
1937} 1931}
1938 1932
1939static int dummy_hcd_suspend (struct device *dev, pm_message_t state, 1933static int dummy_hcd_suspend (struct device *dev, pm_message_t state)
1940 u32 level)
1941{ 1934{
1942 struct usb_hcd *hcd; 1935 struct usb_hcd *hcd;
1943 1936
1944 if (level != SUSPEND_DISABLE)
1945 return 0;
1946
1947 dev_dbg (dev, "%s\n", __FUNCTION__); 1937 dev_dbg (dev, "%s\n", __FUNCTION__);
1948 hcd = dev_get_drvdata (dev); 1938 hcd = dev_get_drvdata (dev);
1949 1939
1950#ifndef CONFIG_USB_SUSPEND
1951 /* Otherwise this would never happen */
1952 usb_lock_device (hcd->self.root_hub);
1953 dummy_hub_suspend (hcd);
1954 usb_unlock_device (hcd->self.root_hub);
1955#endif
1956
1957 hcd->state = HC_STATE_SUSPENDED; 1940 hcd->state = HC_STATE_SUSPENDED;
1958 return 0; 1941 return 0;
1959} 1942}
1960 1943
1961static int dummy_hcd_resume (struct device *dev, u32 level) 1944static int dummy_hcd_resume (struct device *dev)
1962{ 1945{
1963 struct usb_hcd *hcd; 1946 struct usb_hcd *hcd;
1964 1947
1965 if (level != RESUME_ENABLE)
1966 return 0;
1967
1968 dev_dbg (dev, "%s\n", __FUNCTION__); 1948 dev_dbg (dev, "%s\n", __FUNCTION__);
1969 hcd = dev_get_drvdata (dev); 1949 hcd = dev_get_drvdata (dev);
1970 hcd->state = HC_STATE_RUNNING; 1950 hcd->state = HC_STATE_RUNNING;
1971 1951
1972#ifndef CONFIG_USB_SUSPEND
1973 /* Otherwise this would never happen */
1974 usb_lock_device (hcd->self.root_hub);
1975 dummy_hub_resume (hcd);
1976 usb_unlock_device (hcd->self.root_hub);
1977#endif
1978
1979 usb_hcd_poll_rh_status (hcd); 1952 usb_hcd_poll_rh_status (hcd);
1980 return 0; 1953 return 0;
1981} 1954}
1982 1955
1983static struct device_driver dummy_hcd_driver = { 1956static struct device_driver dummy_hcd_driver = {
1984 .name = (char *) driver_name, 1957 .name = (char *) driver_name,
1958 .owner = THIS_MODULE,
1985 .bus = &platform_bus_type, 1959 .bus = &platform_bus_type,
1986 .probe = dummy_hcd_probe, 1960 .probe = dummy_hcd_probe,
1987 .remove = dummy_hcd_remove, 1961 .remove = dummy_hcd_remove,
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 49459e33e952..8f402f85e1ca 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -945,11 +945,11 @@ config_buf (enum usb_device_speed speed,
945 945
946/*-------------------------------------------------------------------------*/ 946/*-------------------------------------------------------------------------*/
947 947
948static void eth_start (struct eth_dev *dev, unsigned gfp_flags); 948static void eth_start (struct eth_dev *dev, gfp_t gfp_flags);
949static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags); 949static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags);
950 950
951static int 951static int
952set_ether_config (struct eth_dev *dev, unsigned gfp_flags) 952set_ether_config (struct eth_dev *dev, gfp_t gfp_flags)
953{ 953{
954 int result = 0; 954 int result = 0;
955 struct usb_gadget *gadget = dev->gadget; 955 struct usb_gadget *gadget = dev->gadget;
@@ -1081,7 +1081,7 @@ static void eth_reset_config (struct eth_dev *dev)
1081 * that returns config descriptors, and altsetting code. 1081 * that returns config descriptors, and altsetting code.
1082 */ 1082 */
1083static int 1083static int
1084eth_set_config (struct eth_dev *dev, unsigned number, unsigned gfp_flags) 1084eth_set_config (struct eth_dev *dev, unsigned number, gfp_t gfp_flags)
1085{ 1085{
1086 int result = 0; 1086 int result = 0;
1087 struct usb_gadget *gadget = dev->gadget; 1087 struct usb_gadget *gadget = dev->gadget;
@@ -1598,7 +1598,7 @@ static void defer_kevent (struct eth_dev *dev, int flag)
1598static void rx_complete (struct usb_ep *ep, struct usb_request *req); 1598static void rx_complete (struct usb_ep *ep, struct usb_request *req);
1599 1599
1600static int 1600static int
1601rx_submit (struct eth_dev *dev, struct usb_request *req, unsigned gfp_flags) 1601rx_submit (struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
1602{ 1602{
1603 struct sk_buff *skb; 1603 struct sk_buff *skb;
1604 int retval = -ENOMEM; 1604 int retval = -ENOMEM;
@@ -1724,7 +1724,7 @@ clean:
1724} 1724}
1725 1725
1726static int prealloc (struct list_head *list, struct usb_ep *ep, 1726static int prealloc (struct list_head *list, struct usb_ep *ep,
1727 unsigned n, unsigned gfp_flags) 1727 unsigned n, gfp_t gfp_flags)
1728{ 1728{
1729 unsigned i; 1729 unsigned i;
1730 struct usb_request *req; 1730 struct usb_request *req;
@@ -1763,7 +1763,7 @@ extra:
1763 return 0; 1763 return 0;
1764} 1764}
1765 1765
1766static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags) 1766static int alloc_requests (struct eth_dev *dev, unsigned n, gfp_t gfp_flags)
1767{ 1767{
1768 int status; 1768 int status;
1769 1769
@@ -1779,7 +1779,7 @@ fail:
1779 return status; 1779 return status;
1780} 1780}
1781 1781
1782static void rx_fill (struct eth_dev *dev, unsigned gfp_flags) 1782static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags)
1783{ 1783{
1784 struct usb_request *req; 1784 struct usb_request *req;
1785 unsigned long flags; 1785 unsigned long flags;
@@ -1962,7 +1962,7 @@ drop:
1962 * normally just one notification will be queued. 1962 * normally just one notification will be queued.
1963 */ 1963 */
1964 1964
1965static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, unsigned); 1965static struct usb_request *eth_req_alloc (struct usb_ep *, unsigned, gfp_t);
1966static void eth_req_free (struct usb_ep *ep, struct usb_request *req); 1966static void eth_req_free (struct usb_ep *ep, struct usb_request *req);
1967 1967
1968static void 1968static void
@@ -2024,7 +2024,7 @@ static int rndis_control_ack (struct net_device *net)
2024 2024
2025#endif /* RNDIS */ 2025#endif /* RNDIS */
2026 2026
2027static void eth_start (struct eth_dev *dev, unsigned gfp_flags) 2027static void eth_start (struct eth_dev *dev, gfp_t gfp_flags)
2028{ 2028{
2029 DEBUG (dev, "%s\n", __FUNCTION__); 2029 DEBUG (dev, "%s\n", __FUNCTION__);
2030 2030
@@ -2092,7 +2092,7 @@ static int eth_stop (struct net_device *net)
2092/*-------------------------------------------------------------------------*/ 2092/*-------------------------------------------------------------------------*/
2093 2093
2094static struct usb_request * 2094static struct usb_request *
2095eth_req_alloc (struct usb_ep *ep, unsigned size, unsigned gfp_flags) 2095eth_req_alloc (struct usb_ep *ep, unsigned size, gfp_t gfp_flags)
2096{ 2096{
2097 struct usb_request *req; 2097 struct usb_request *req;
2098 2098
@@ -2533,6 +2533,7 @@ static struct usb_gadget_driver eth_driver = {
2533 2533
2534 .driver = { 2534 .driver = {
2535 .name = (char *) shortname, 2535 .name = (char *) shortname,
2536 .owner = THIS_MODULE,
2536 // .shutdown = ... 2537 // .shutdown = ...
2537 // .suspend = ... 2538 // .suspend = ...
2538 // .resume = ... 2539 // .resume = ...
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index a41d9d4baee3..ea09aaa3cab6 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -224,6 +224,7 @@
224#include <linux/fs.h> 224#include <linux/fs.h>
225#include <linux/init.h> 225#include <linux/init.h>
226#include <linux/kernel.h> 226#include <linux/kernel.h>
227#include <linux/kthread.h>
227#include <linux/limits.h> 228#include <linux/limits.h>
228#include <linux/list.h> 229#include <linux/list.h>
229#include <linux/module.h> 230#include <linux/module.h>
@@ -669,7 +670,6 @@ struct fsg_dev {
669 wait_queue_head_t thread_wqh; 670 wait_queue_head_t thread_wqh;
670 int thread_wakeup_needed; 671 int thread_wakeup_needed;
671 struct completion thread_notifier; 672 struct completion thread_notifier;
672 int thread_pid;
673 struct task_struct *thread_task; 673 struct task_struct *thread_task;
674 sigset_t thread_signal_mask; 674 sigset_t thread_signal_mask;
675 675
@@ -1084,7 +1084,6 @@ static void wakeup_thread(struct fsg_dev *fsg)
1084static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state) 1084static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state)
1085{ 1085{
1086 unsigned long flags; 1086 unsigned long flags;
1087 struct task_struct *thread_task;
1088 1087
1089 /* Do nothing if a higher-priority exception is already in progress. 1088 /* Do nothing if a higher-priority exception is already in progress.
1090 * If a lower-or-equal priority exception is in progress, preempt it 1089 * If a lower-or-equal priority exception is in progress, preempt it
@@ -1093,9 +1092,9 @@ static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state)
1093 if (fsg->state <= new_state) { 1092 if (fsg->state <= new_state) {
1094 fsg->exception_req_tag = fsg->ep0_req_tag; 1093 fsg->exception_req_tag = fsg->ep0_req_tag;
1095 fsg->state = new_state; 1094 fsg->state = new_state;
1096 thread_task = fsg->thread_task; 1095 if (fsg->thread_task)
1097 if (thread_task) 1096 send_sig_info(SIGUSR1, SEND_SIG_FORCED,
1098 send_sig_info(SIGUSR1, SEND_SIG_FORCED, thread_task); 1097 fsg->thread_task);
1099 } 1098 }
1100 spin_unlock_irqrestore(&fsg->lock, flags); 1099 spin_unlock_irqrestore(&fsg->lock, flags);
1101} 1100}
@@ -3383,11 +3382,6 @@ static int fsg_main_thread(void *fsg_)
3383{ 3382{
3384 struct fsg_dev *fsg = (struct fsg_dev *) fsg_; 3383 struct fsg_dev *fsg = (struct fsg_dev *) fsg_;
3385 3384
3386 fsg->thread_task = current;
3387
3388 /* Release all our userspace resources */
3389 daemonize("file-storage-gadget");
3390
3391 /* Allow the thread to be killed by a signal, but set the signal mask 3385 /* Allow the thread to be killed by a signal, but set the signal mask
3392 * to block everything but INT, TERM, KILL, and USR1. */ 3386 * to block everything but INT, TERM, KILL, and USR1. */
3393 siginitsetinv(&fsg->thread_signal_mask, sigmask(SIGINT) | 3387 siginitsetinv(&fsg->thread_signal_mask, sigmask(SIGINT) |
@@ -3400,9 +3394,6 @@ static int fsg_main_thread(void *fsg_)
3400 * that expects a __user pointer and it will work okay. */ 3394 * that expects a __user pointer and it will work okay. */
3401 set_fs(get_ds()); 3395 set_fs(get_ds());
3402 3396
3403 /* Wait for the gadget registration to finish up */
3404 wait_for_completion(&fsg->thread_notifier);
3405
3406 /* The main loop */ 3397 /* The main loop */
3407 while (fsg->state != FSG_STATE_TERMINATED) { 3398 while (fsg->state != FSG_STATE_TERMINATED) {
3408 if (exception_in_progress(fsg) || signal_pending(current)) { 3399 if (exception_in_progress(fsg) || signal_pending(current)) {
@@ -3440,8 +3431,9 @@ static int fsg_main_thread(void *fsg_)
3440 spin_unlock_irq(&fsg->lock); 3431 spin_unlock_irq(&fsg->lock);
3441 } 3432 }
3442 3433
3434 spin_lock_irq(&fsg->lock);
3443 fsg->thread_task = NULL; 3435 fsg->thread_task = NULL;
3444 flush_signals(current); 3436 spin_unlock_irq(&fsg->lock);
3445 3437
3446 /* In case we are exiting because of a signal, unregister the 3438 /* In case we are exiting because of a signal, unregister the
3447 * gadget driver and close the backing file. */ 3439 * gadget driver and close the backing file. */
@@ -3831,12 +3823,11 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3831 3823
3832 /* Create the LUNs, open their backing files, and register the 3824 /* Create the LUNs, open their backing files, and register the
3833 * LUN devices in sysfs. */ 3825 * LUN devices in sysfs. */
3834 fsg->luns = kmalloc(i * sizeof(struct lun), GFP_KERNEL); 3826 fsg->luns = kzalloc(i * sizeof(struct lun), GFP_KERNEL);
3835 if (!fsg->luns) { 3827 if (!fsg->luns) {
3836 rc = -ENOMEM; 3828 rc = -ENOMEM;
3837 goto out; 3829 goto out;
3838 } 3830 }
3839 memset(fsg->luns, 0, i * sizeof(struct lun));
3840 fsg->nluns = i; 3831 fsg->nluns = i;
3841 3832
3842 for (i = 0; i < fsg->nluns; ++i) { 3833 for (i = 0; i < fsg->nluns; ++i) {
@@ -3959,10 +3950,12 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3959 sprintf(&serial[i], "%02X", c); 3950 sprintf(&serial[i], "%02X", c);
3960 } 3951 }
3961 3952
3962 if ((rc = kernel_thread(fsg_main_thread, fsg, (CLONE_VM | CLONE_FS | 3953 fsg->thread_task = kthread_create(fsg_main_thread, fsg,
3963 CLONE_FILES))) < 0) 3954 "file-storage-gadget");
3955 if (IS_ERR(fsg->thread_task)) {
3956 rc = PTR_ERR(fsg->thread_task);
3964 goto out; 3957 goto out;
3965 fsg->thread_pid = rc; 3958 }
3966 3959
3967 INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); 3960 INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
3968 INFO(fsg, "Number of LUNs=%d\n", fsg->nluns); 3961 INFO(fsg, "Number of LUNs=%d\n", fsg->nluns);
@@ -3994,7 +3987,12 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3994 DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", 3987 DBG(fsg, "removable=%d, stall=%d, buflen=%u\n",
3995 mod_data.removable, mod_data.can_stall, 3988 mod_data.removable, mod_data.can_stall,
3996 mod_data.buflen); 3989 mod_data.buflen);
3997 DBG(fsg, "I/O thread pid: %d\n", fsg->thread_pid); 3990 DBG(fsg, "I/O thread pid: %d\n", fsg->thread_task->pid);
3991
3992 set_bit(REGISTERED, &fsg->atomic_bitflags);
3993
3994 /* Tell the thread to start working */
3995 wake_up_process(fsg->thread_task);
3998 return 0; 3996 return 0;
3999 3997
4000autoconf_fail: 3998autoconf_fail:
@@ -4046,6 +4044,7 @@ static struct usb_gadget_driver fsg_driver = {
4046 4044
4047 .driver = { 4045 .driver = {
4048 .name = (char *) shortname, 4046 .name = (char *) shortname,
4047 .owner = THIS_MODULE,
4049 // .release = ... 4048 // .release = ...
4050 // .suspend = ... 4049 // .suspend = ...
4051 // .resume = ... 4050 // .resume = ...
@@ -4057,10 +4056,9 @@ static int __init fsg_alloc(void)
4057{ 4056{
4058 struct fsg_dev *fsg; 4057 struct fsg_dev *fsg;
4059 4058
4060 fsg = kmalloc(sizeof *fsg, GFP_KERNEL); 4059 fsg = kzalloc(sizeof *fsg, GFP_KERNEL);
4061 if (!fsg) 4060 if (!fsg)
4062 return -ENOMEM; 4061 return -ENOMEM;
4063 memset(fsg, 0, sizeof *fsg);
4064 spin_lock_init(&fsg->lock); 4062 spin_lock_init(&fsg->lock);
4065 init_rwsem(&fsg->filesem); 4063 init_rwsem(&fsg->filesem);
4066 init_waitqueue_head(&fsg->thread_wqh); 4064 init_waitqueue_head(&fsg->thread_wqh);
@@ -4086,15 +4084,9 @@ static int __init fsg_init(void)
4086 if ((rc = fsg_alloc()) != 0) 4084 if ((rc = fsg_alloc()) != 0)
4087 return rc; 4085 return rc;
4088 fsg = the_fsg; 4086 fsg = the_fsg;
4089 if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) { 4087 if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
4090 fsg_free(fsg); 4088 fsg_free(fsg);
4091 return rc; 4089 return rc;
4092 }
4093 set_bit(REGISTERED, &fsg->atomic_bitflags);
4094
4095 /* Tell the thread to start working */
4096 complete(&fsg->thread_notifier);
4097 return 0;
4098} 4090}
4099module_init(fsg_init); 4091module_init(fsg_init);
4100 4092
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index eaab26f4ed37..654469778ab5 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -269,7 +269,7 @@ static int goku_ep_disable(struct usb_ep *_ep)
269/*-------------------------------------------------------------------------*/ 269/*-------------------------------------------------------------------------*/
270 270
271static struct usb_request * 271static struct usb_request *
272goku_alloc_request(struct usb_ep *_ep, unsigned gfp_flags) 272goku_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
273{ 273{
274 struct goku_request *req; 274 struct goku_request *req;
275 275
@@ -327,7 +327,7 @@ goku_free_request(struct usb_ep *_ep, struct usb_request *_req)
327 */ 327 */
328static void * 328static void *
329goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes, 329goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
330 dma_addr_t *dma, unsigned gfp_flags) 330 dma_addr_t *dma, gfp_t gfp_flags)
331{ 331{
332 void *retval; 332 void *retval;
333 struct goku_ep *ep; 333 struct goku_ep *ep;
@@ -789,7 +789,7 @@ finished:
789/*-------------------------------------------------------------------------*/ 789/*-------------------------------------------------------------------------*/
790 790
791static int 791static int
792goku_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) 792goku_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
793{ 793{
794 struct goku_request *req; 794 struct goku_request *req;
795 struct goku_ep *ep; 795 struct goku_ep *ep;
@@ -1970,6 +1970,7 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
1970static struct pci_driver goku_pci_driver = { 1970static struct pci_driver goku_pci_driver = {
1971 .name = (char *) driver_name, 1971 .name = (char *) driver_name,
1972 .id_table = pci_ids, 1972 .id_table = pci_ids,
1973 .owner = THIS_MODULE,
1973 1974
1974 .probe = goku_probe, 1975 .probe = goku_probe,
1975 .remove = goku_remove, 1976 .remove = goku_remove,
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 4842577789c9..9b3673904daf 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -71,13 +71,13 @@ static char *state_names[] = {
71static int lh7a40x_ep_enable(struct usb_ep *ep, 71static int lh7a40x_ep_enable(struct usb_ep *ep,
72 const struct usb_endpoint_descriptor *); 72 const struct usb_endpoint_descriptor *);
73static int lh7a40x_ep_disable(struct usb_ep *ep); 73static int lh7a40x_ep_disable(struct usb_ep *ep);
74static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, int); 74static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, gfp_t);
75static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *); 75static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *);
76static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *, 76static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned, dma_addr_t *,
77 int); 77 gfp_t);
78static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t, 78static void lh7a40x_free_buffer(struct usb_ep *ep, void *, dma_addr_t,
79 unsigned); 79 unsigned);
80static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, int); 80static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t);
81static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); 81static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *);
82static int lh7a40x_set_halt(struct usb_ep *ep, int); 82static int lh7a40x_set_halt(struct usb_ep *ep, int);
83static int lh7a40x_fifo_status(struct usb_ep *ep); 83static int lh7a40x_fifo_status(struct usb_ep *ep);
@@ -1106,7 +1106,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep)
1106} 1106}
1107 1107
1108static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep, 1108static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep,
1109 unsigned gfp_flags) 1109 gfp_t gfp_flags)
1110{ 1110{
1111 struct lh7a40x_request *req; 1111 struct lh7a40x_request *req;
1112 1112
@@ -1134,7 +1134,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req)
1134} 1134}
1135 1135
1136static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes, 1136static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes,
1137 dma_addr_t * dma, unsigned gfp_flags) 1137 dma_addr_t * dma, gfp_t gfp_flags)
1138{ 1138{
1139 char *retval; 1139 char *retval;
1140 1140
@@ -1158,7 +1158,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma,
1158 * NOTE: Sets INDEX register 1158 * NOTE: Sets INDEX register
1159 */ 1159 */
1160static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req, 1160static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req,
1161 unsigned gfp_flags) 1161 gfp_t gfp_flags)
1162{ 1162{
1163 struct lh7a40x_request *req; 1163 struct lh7a40x_request *req;
1164 struct lh7a40x_ep *ep; 1164 struct lh7a40x_ep *ep;
@@ -2140,6 +2140,7 @@ static int lh7a40x_udc_remove(struct device *_dev)
2140 2140
2141static struct device_driver udc_driver = { 2141static struct device_driver udc_driver = {
2142 .name = (char *)driver_name, 2142 .name = (char *)driver_name,
2143 .owner = THIS_MODULE,
2143 .bus = &platform_bus_type, 2144 .bus = &platform_bus_type,
2144 .probe = lh7a40x_udc_probe, 2145 .probe = lh7a40x_udc_probe,
2145 .remove = lh7a40x_udc_remove 2146 .remove = lh7a40x_udc_remove
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 477fab2e74d1..0dc6bb00bf72 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -376,7 +376,7 @@ static int net2280_disable (struct usb_ep *_ep)
376/*-------------------------------------------------------------------------*/ 376/*-------------------------------------------------------------------------*/
377 377
378static struct usb_request * 378static struct usb_request *
379net2280_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) 379net2280_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
380{ 380{
381 struct net2280_ep *ep; 381 struct net2280_ep *ep;
382 struct net2280_request *req; 382 struct net2280_request *req;
@@ -463,7 +463,7 @@ net2280_alloc_buffer (
463 struct usb_ep *_ep, 463 struct usb_ep *_ep,
464 unsigned bytes, 464 unsigned bytes,
465 dma_addr_t *dma, 465 dma_addr_t *dma,
466 unsigned gfp_flags 466 gfp_t gfp_flags
467) 467)
468{ 468{
469 void *retval; 469 void *retval;
@@ -897,7 +897,7 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status)
897/*-------------------------------------------------------------------------*/ 897/*-------------------------------------------------------------------------*/
898 898
899static int 899static int
900net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) 900net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
901{ 901{
902 struct net2280_request *req; 902 struct net2280_request *req;
903 struct net2280_ep *ep; 903 struct net2280_ep *ep;
@@ -2948,6 +2948,7 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
2948static struct pci_driver net2280_pci_driver = { 2948static struct pci_driver net2280_pci_driver = {
2949 .name = (char *) driver_name, 2949 .name = (char *) driver_name,
2950 .id_table = pci_ids, 2950 .id_table = pci_ids,
2951 .owner = THIS_MODULE,
2951 2952
2952 .probe = net2280_probe, 2953 .probe = net2280_probe,
2953 .remove = net2280_remove, 2954 .remove = net2280_remove,
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index ff5533e69560..41c96b0afbb3 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
269/*-------------------------------------------------------------------------*/ 269/*-------------------------------------------------------------------------*/
270 270
271static struct usb_request * 271static struct usb_request *
272omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags) 272omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
273{ 273{
274 struct omap_req *req; 274 struct omap_req *req;
275 275
@@ -298,7 +298,7 @@ omap_alloc_buffer(
298 struct usb_ep *_ep, 298 struct usb_ep *_ep,
299 unsigned bytes, 299 unsigned bytes,
300 dma_addr_t *dma, 300 dma_addr_t *dma,
301 unsigned gfp_flags 301 gfp_t gfp_flags
302) 302)
303{ 303{
304 void *retval; 304 void *retval;
@@ -691,7 +691,7 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req)
691} 691}
692 692
693static void 693static void
694finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) 694finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status, int one)
695{ 695{
696 u16 count; 696 u16 count;
697 697
@@ -699,6 +699,8 @@ finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status)
699 ep->dma_counter = (u16) (req->req.dma + req->req.actual); 699 ep->dma_counter = (u16) (req->req.dma + req->req.actual);
700 count = dma_dest_len(ep, req->req.dma + req->req.actual); 700 count = dma_dest_len(ep, req->req.dma + req->req.actual);
701 count += req->req.actual; 701 count += req->req.actual;
702 if (one)
703 count--;
702 if (count <= req->req.length) 704 if (count <= req->req.length)
703 req->req.actual = count; 705 req->req.actual = count;
704 706
@@ -747,7 +749,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src)
747 if (!list_empty(&ep->queue)) { 749 if (!list_empty(&ep->queue)) {
748 req = container_of(ep->queue.next, 750 req = container_of(ep->queue.next,
749 struct omap_req, queue); 751 struct omap_req, queue);
750 finish_out_dma(ep, req, 0); 752 finish_out_dma(ep, req, 0, dman_stat & UDC_DMA_RX_SB);
751 } 753 }
752 UDC_IRQ_SRC_REG = UDC_RXN_EOT; 754 UDC_IRQ_SRC_REG = UDC_RXN_EOT;
753 755
@@ -925,7 +927,7 @@ static void dma_channel_release(struct omap_ep *ep)
925 while (UDC_RXDMA_CFG_REG & mask) 927 while (UDC_RXDMA_CFG_REG & mask)
926 udelay(10); 928 udelay(10);
927 if (req) 929 if (req)
928 finish_out_dma(ep, req, -ECONNRESET); 930 finish_out_dma(ep, req, -ECONNRESET, 0);
929 } 931 }
930 omap_free_dma(ep->lch); 932 omap_free_dma(ep->lch);
931 ep->dma_channel = 0; 933 ep->dma_channel = 0;
@@ -937,7 +939,7 @@ static void dma_channel_release(struct omap_ep *ep)
937/*-------------------------------------------------------------------------*/ 939/*-------------------------------------------------------------------------*/
938 940
939static int 941static int
940omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) 942omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
941{ 943{
942 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep); 944 struct omap_ep *ep = container_of(_ep, struct omap_ep, ep);
943 struct omap_req *req = container_of(_req, struct omap_req, req); 945 struct omap_req *req = container_of(_req, struct omap_req, req);
@@ -1786,8 +1788,12 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
1786 udc->driver->suspend(&udc->gadget); 1788 udc->driver->suspend(&udc->gadget);
1787 spin_lock(&udc->lock); 1789 spin_lock(&udc->lock);
1788 } 1790 }
1791 if (udc->transceiver)
1792 otg_set_suspend(udc->transceiver, 1);
1789 } else { 1793 } else {
1790 VDBG("resume\n"); 1794 VDBG("resume\n");
1795 if (udc->transceiver)
1796 otg_set_suspend(udc->transceiver, 0);
1791 if (udc->gadget.speed == USB_SPEED_FULL 1797 if (udc->gadget.speed == USB_SPEED_FULL
1792 && udc->driver->resume) { 1798 && udc->driver->resume) {
1793 spin_unlock(&udc->lock); 1799 spin_unlock(&udc->lock);
@@ -2909,12 +2915,10 @@ static int __exit omap_udc_remove(struct device *dev)
2909 * may involve talking to an external transceiver (e.g. isp1301). 2915 * may involve talking to an external transceiver (e.g. isp1301).
2910 */ 2916 */
2911 2917
2912static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level) 2918static int omap_udc_suspend(struct device *dev, pm_message_t message)
2913{ 2919{
2914 u32 devstat; 2920 u32 devstat;
2915 2921
2916 if (level != SUSPEND_POWER_DOWN)
2917 return 0;
2918 devstat = UDC_DEVSTAT_REG; 2922 devstat = UDC_DEVSTAT_REG;
2919 2923
2920 /* we're requesting 48 MHz clock if the pullup is enabled 2924 /* we're requesting 48 MHz clock if the pullup is enabled
@@ -2931,11 +2935,8 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level)
2931 return 0; 2935 return 0;
2932} 2936}
2933 2937
2934static int omap_udc_resume(struct device *dev, u32 level) 2938static int omap_udc_resume(struct device *dev)
2935{ 2939{
2936 if (level != RESUME_POWER_ON)
2937 return 0;
2938
2939 DBG("resume + wakeup/SRP\n"); 2940 DBG("resume + wakeup/SRP\n");
2940 omap_pullup(&udc->gadget, 1); 2941 omap_pullup(&udc->gadget, 1);
2941 2942
@@ -2948,6 +2949,7 @@ static int omap_udc_resume(struct device *dev, u32 level)
2948 2949
2949static struct device_driver udc_driver = { 2950static struct device_driver udc_driver = {
2950 .name = (char *) driver_name, 2951 .name = (char *) driver_name,
2952 .owner = THIS_MODULE,
2951 .bus = &platform_bus_type, 2953 .bus = &platform_bus_type,
2952 .probe = omap_udc_probe, 2954 .probe = omap_udc_probe,
2953 .remove = __exit_p(omap_udc_remove), 2955 .remove = __exit_p(omap_udc_remove),
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 73f8c9404156..f83a9262f953 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -332,7 +332,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
332 * pxa2xx_ep_alloc_request - allocate a request data structure 332 * pxa2xx_ep_alloc_request - allocate a request data structure
333 */ 333 */
334static struct usb_request * 334static struct usb_request *
335pxa2xx_ep_alloc_request (struct usb_ep *_ep, unsigned gfp_flags) 335pxa2xx_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags)
336{ 336{
337 struct pxa2xx_request *req; 337 struct pxa2xx_request *req;
338 338
@@ -367,7 +367,7 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req)
367 */ 367 */
368static void * 368static void *
369pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, 369pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
370 dma_addr_t *dma, unsigned gfp_flags) 370 dma_addr_t *dma, gfp_t gfp_flags)
371{ 371{
372 char *retval; 372 char *retval;
373 373
@@ -422,7 +422,7 @@ static inline void ep0_idle (struct pxa2xx_udc *dev)
422} 422}
423 423
424static int 424static int
425write_packet(volatile unsigned long *uddr, struct pxa2xx_request *req, unsigned max) 425write_packet(volatile u32 *uddr, struct pxa2xx_request *req, unsigned max)
426{ 426{
427 u8 *buf; 427 u8 *buf;
428 unsigned length, count; 428 unsigned length, count;
@@ -874,7 +874,7 @@ done:
874/*-------------------------------------------------------------------------*/ 874/*-------------------------------------------------------------------------*/
875 875
876static int 876static int
877pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags) 877pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
878{ 878{
879 struct pxa2xx_request *req; 879 struct pxa2xx_request *req;
880 struct pxa2xx_ep *ep; 880 struct pxa2xx_ep *ep;
@@ -2602,24 +2602,23 @@ static int __exit pxa2xx_udc_remove(struct device *_dev)
2602 * VBUS IRQs should probably be ignored so that the PXA device just acts 2602 * VBUS IRQs should probably be ignored so that the PXA device just acts
2603 * "dead" to USB hosts until system resume. 2603 * "dead" to USB hosts until system resume.
2604 */ 2604 */
2605static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state, u32 level) 2605static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state)
2606{ 2606{
2607 struct pxa2xx_udc *udc = dev_get_drvdata(dev); 2607 struct pxa2xx_udc *udc = dev_get_drvdata(dev);
2608 2608
2609 if (level == SUSPEND_POWER_DOWN) { 2609 if (!udc->mach->udc_command)
2610 if (!udc->mach->udc_command) 2610 WARN("USB host won't detect disconnect!\n");
2611 WARN("USB host won't detect disconnect!\n"); 2611 pullup(udc, 0);
2612 pullup(udc, 0); 2612
2613 }
2614 return 0; 2613 return 0;
2615} 2614}
2616 2615
2617static int pxa2xx_udc_resume(struct device *dev, u32 level) 2616static int pxa2xx_udc_resume(struct device *dev)
2618{ 2617{
2619 struct pxa2xx_udc *udc = dev_get_drvdata(dev); 2618 struct pxa2xx_udc *udc = dev_get_drvdata(dev);
2620 2619
2621 if (level == RESUME_POWER_ON) 2620 pullup(udc, 1);
2622 pullup(udc, 1); 2621
2623 return 0; 2622 return 0;
2624} 2623}
2625 2624
@@ -2632,6 +2631,7 @@ static int pxa2xx_udc_resume(struct device *dev, u32 level)
2632 2631
2633static struct device_driver udc_driver = { 2632static struct device_driver udc_driver = {
2634 .name = "pxa2xx-udc", 2633 .name = "pxa2xx-udc",
2634 .owner = THIS_MODULE,
2635 .bus = &platform_bus_type, 2635 .bus = &platform_bus_type,
2636 .probe = pxa2xx_udc_probe, 2636 .probe = pxa2xx_udc_probe,
2637 .shutdown = pxa2xx_udc_shutdown, 2637 .shutdown = pxa2xx_udc_shutdown,
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h
index a58f3e6e71f1..19a883f7d1b8 100644
--- a/drivers/usb/gadget/pxa2xx_udc.h
+++ b/drivers/usb/gadget/pxa2xx_udc.h
@@ -69,11 +69,11 @@ struct pxa2xx_ep {
69 * UDDR = UDC Endpoint Data Register (the fifo) 69 * UDDR = UDC Endpoint Data Register (the fifo)
70 * DRCM = DMA Request Channel Map 70 * DRCM = DMA Request Channel Map
71 */ 71 */
72 volatile unsigned long *reg_udccs; 72 volatile u32 *reg_udccs;
73 volatile unsigned long *reg_ubcr; 73 volatile u32 *reg_ubcr;
74 volatile unsigned long *reg_uddr; 74 volatile u32 *reg_uddr;
75#ifdef USE_DMA 75#ifdef USE_DMA
76 volatile unsigned long *reg_drcmr; 76 volatile u32 *reg_drcmr;
77#define drcmr(n) .reg_drcmr = & DRCMR ## n , 77#define drcmr(n) .reg_drcmr = & DRCMR ## n ,
78#else 78#else
79#define drcmr(n) 79#define drcmr(n)
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index c925d9222f53..b35ac6d334f8 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -300,18 +300,18 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed,
300 u8 type, unsigned int index, int is_otg); 300 u8 type, unsigned int index, int is_otg);
301 301
302static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len, 302static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
303 unsigned kmalloc_flags); 303 gfp_t kmalloc_flags);
304static void gs_free_req(struct usb_ep *ep, struct usb_request *req); 304static void gs_free_req(struct usb_ep *ep, struct usb_request *req);
305 305
306static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len, 306static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len,
307 unsigned kmalloc_flags); 307 gfp_t kmalloc_flags);
308static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req); 308static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req);
309 309
310static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags); 310static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags);
311static void gs_free_ports(struct gs_dev *dev); 311static void gs_free_ports(struct gs_dev *dev);
312 312
313/* circular buffer */ 313/* circular buffer */
314static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags); 314static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags);
315static void gs_buf_free(struct gs_buf *gb); 315static void gs_buf_free(struct gs_buf *gb);
316static void gs_buf_clear(struct gs_buf *gb); 316static void gs_buf_clear(struct gs_buf *gb);
317static unsigned int gs_buf_data_avail(struct gs_buf *gb); 317static unsigned int gs_buf_data_avail(struct gs_buf *gb);
@@ -2091,7 +2091,7 @@ static int gs_build_config_buf(u8 *buf, enum usb_device_speed speed,
2091 * usb_request or NULL if there is an error. 2091 * usb_request or NULL if there is an error.
2092 */ 2092 */
2093static struct usb_request * 2093static struct usb_request *
2094gs_alloc_req(struct usb_ep *ep, unsigned int len, unsigned kmalloc_flags) 2094gs_alloc_req(struct usb_ep *ep, unsigned int len, gfp_t kmalloc_flags)
2095{ 2095{
2096 struct usb_request *req; 2096 struct usb_request *req;
2097 2097
@@ -2132,7 +2132,7 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req)
2132 * endpoint, buffer len, and kmalloc flags. 2132 * endpoint, buffer len, and kmalloc flags.
2133 */ 2133 */
2134static struct gs_req_entry * 2134static struct gs_req_entry *
2135gs_alloc_req_entry(struct usb_ep *ep, unsigned len, unsigned kmalloc_flags) 2135gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
2136{ 2136{
2137 struct gs_req_entry *req; 2137 struct gs_req_entry *req;
2138 2138
@@ -2173,7 +2173,7 @@ static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req)
2173 * 2173 *
2174 * The device lock is normally held when calling this function. 2174 * The device lock is normally held when calling this function.
2175 */ 2175 */
2176static int gs_alloc_ports(struct gs_dev *dev, unsigned kmalloc_flags) 2176static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags)
2177{ 2177{
2178 int i; 2178 int i;
2179 struct gs_port *port; 2179 struct gs_port *port;
@@ -2255,7 +2255,7 @@ static void gs_free_ports(struct gs_dev *dev)
2255 * 2255 *
2256 * Allocate a circular buffer and all associated memory. 2256 * Allocate a circular buffer and all associated memory.
2257 */ 2257 */
2258static struct gs_buf *gs_buf_alloc(unsigned int size, unsigned kmalloc_flags) 2258static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags)
2259{ 2259{
2260 struct gs_buf *gb; 2260 struct gs_buf *gb;
2261 2261
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 6890e773b2a2..6c58636e914b 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -612,7 +612,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req)
612} 612}
613 613
614static struct usb_request * 614static struct usb_request *
615source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags) 615source_sink_start_ep (struct usb_ep *ep, gfp_t gfp_flags)
616{ 616{
617 struct usb_request *req; 617 struct usb_request *req;
618 int status; 618 int status;
@@ -640,7 +640,7 @@ source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags)
640} 640}
641 641
642static int 642static int
643set_source_sink_config (struct zero_dev *dev, unsigned gfp_flags) 643set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
644{ 644{
645 int result = 0; 645 int result = 0;
646 struct usb_ep *ep; 646 struct usb_ep *ep;
@@ -744,7 +744,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
744} 744}
745 745
746static int 746static int
747set_loopback_config (struct zero_dev *dev, unsigned gfp_flags) 747set_loopback_config (struct zero_dev *dev, gfp_t gfp_flags)
748{ 748{
749 int result = 0; 749 int result = 0;
750 struct usb_ep *ep; 750 struct usb_ep *ep;
@@ -845,7 +845,7 @@ static void zero_reset_config (struct zero_dev *dev)
845 * by limiting configuration choices (like the pxa2xx). 845 * by limiting configuration choices (like the pxa2xx).
846 */ 846 */
847static int 847static int
848zero_set_config (struct zero_dev *dev, unsigned number, unsigned gfp_flags) 848zero_set_config (struct zero_dev *dev, unsigned number, gfp_t gfp_flags)
849{ 849{
850 int result = 0; 850 int result = 0;
851 struct usb_gadget *gadget = dev->gadget; 851 struct usb_gadget *gadget = dev->gadget;
@@ -1302,6 +1302,7 @@ static struct usb_gadget_driver zero_driver = {
1302 1302
1303 .driver = { 1303 .driver = {
1304 .name = (char *) shortname, 1304 .name = (char *) shortname,
1305 .owner = THIS_MODULE,
1305 // .shutdown = ... 1306 // .shutdown = ...
1306 // .suspend = ... 1307 // .suspend = ...
1307 // .resume = ... 1308 // .resume = ...
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 350d14fc1cc9..58321d3f314c 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -1,8 +1,9 @@
1# 1#
2# Makefile for USB Host Controller Driver 2# Makefile for USB Host Controller Drivers
3# framework and drivers
4# 3#
5 4
5obj-$(CONFIG_PCI) += pci-quirks.o
6
6obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o 7obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
7obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o 8obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
8obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 9obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index b948ffd94f45..af3c05eb86fc 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -182,6 +182,9 @@ static int ehci_halt (struct ehci_hcd *ehci)
182{ 182{
183 u32 temp = readl (&ehci->regs->status); 183 u32 temp = readl (&ehci->regs->status);
184 184
185 /* disable any irqs left enabled by previous code */
186 writel (0, &ehci->regs->intr_enable);
187
185 if ((temp & STS_HALT) != 0) 188 if ((temp & STS_HALT) != 0)
186 return 0; 189 return 0;
187 190
@@ -297,50 +300,17 @@ static void ehci_watchdog (unsigned long param)
297 spin_unlock_irqrestore (&ehci->lock, flags); 300 spin_unlock_irqrestore (&ehci->lock, flags);
298} 301}
299 302
300#ifdef CONFIG_PCI 303/* Reboot notifiers kick in for silicon on any bus (not just pci, etc).
301 304 * This forcibly disables dma and IRQs, helping kexec and other cases
302/* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... 305 * where the next system software may expect clean state.
303 * off the controller (maybe it can boot from highspeed USB disks).
304 */ 306 */
305static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
306{
307 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
308
309 /* always say Linux will own the hardware */
310 pci_write_config_byte(pdev, where + 3, 1);
311
312 /* maybe wait a while for BIOS to respond */
313 if (cap & (1 << 16)) {
314 int msec = 5000;
315
316 do {
317 msleep(10);
318 msec -= 10;
319 pci_read_config_dword(pdev, where, &cap);
320 } while ((cap & (1 << 16)) && msec);
321 if (cap & (1 << 16)) {
322 ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n",
323 where, cap);
324 // some BIOS versions seem buggy...
325 // return 1;
326 ehci_warn (ehci, "continuing after BIOS bug...\n");
327 /* disable all SMIs, and clear "BIOS owns" flag */
328 pci_write_config_dword(pdev, where + 4, 0);
329 pci_write_config_byte(pdev, where + 2, 0);
330 } else
331 ehci_dbg(ehci, "BIOS handoff succeeded\n");
332 }
333 return 0;
334}
335
336#endif
337
338static int 307static int
339ehci_reboot (struct notifier_block *self, unsigned long code, void *null) 308ehci_reboot (struct notifier_block *self, unsigned long code, void *null)
340{ 309{
341 struct ehci_hcd *ehci; 310 struct ehci_hcd *ehci;
342 311
343 ehci = container_of (self, struct ehci_hcd, reboot_notifier); 312 ehci = container_of (self, struct ehci_hcd, reboot_notifier);
313 (void) ehci_halt (ehci);
344 314
345 /* make BIOS/etc use companion controller during reboot */ 315 /* make BIOS/etc use companion controller during reboot */
346 writel (0, &ehci->regs->configured_flag); 316 writel (0, &ehci->regs->configured_flag);
@@ -363,156 +333,90 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
363 msleep(20); 333 msleep(20);
364} 334}
365 335
336/*-------------------------------------------------------------------------*/
337
338/*
339 * ehci_work is called from some interrupts, timers, and so on.
340 * it calls driver completion functions, after dropping ehci->lock.
341 */
342static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
343{
344 timer_action_done (ehci, TIMER_IO_WATCHDOG);
345 if (ehci->reclaim_ready)
346 end_unlink_async (ehci, regs);
347
348 /* another CPU may drop ehci->lock during a schedule scan while
349 * it reports urb completions. this flag guards against bogus
350 * attempts at re-entrant schedule scanning.
351 */
352 if (ehci->scanning)
353 return;
354 ehci->scanning = 1;
355 scan_async (ehci, regs);
356 if (ehci->next_uframe != -1)
357 scan_periodic (ehci, regs);
358 ehci->scanning = 0;
366 359
367/* called by khubd or root hub init threads */ 360 /* the IO watchdog guards against hardware or driver bugs that
361 * misplace IRQs, and should let us run completely without IRQs.
362 * such lossage has been observed on both VT6202 and VT8235.
363 */
364 if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
365 (ehci->async->qh_next.ptr != NULL ||
366 ehci->periodic_sched != 0))
367 timer_action (ehci, TIMER_IO_WATCHDOG);
368}
368 369
369static int ehci_hc_reset (struct usb_hcd *hcd) 370static void ehci_stop (struct usb_hcd *hcd)
370{ 371{
371 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 372 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
372 u32 temp;
373 unsigned count = 256/4;
374 373
375 spin_lock_init (&ehci->lock); 374 ehci_dbg (ehci, "stop\n");
376 375
377 ehci->caps = hcd->regs; 376 /* Turn off port power on all root hub ports. */
378 ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase)); 377 ehci_port_power (ehci, 0);
379 dbg_hcs_params (ehci, "reset");
380 dbg_hcc_params (ehci, "reset");
381 378
382 /* cache this readonly data; minimize chip reads */ 379 /* no more interrupts ... */
383 ehci->hcs_params = readl (&ehci->caps->hcs_params); 380 del_timer_sync (&ehci->watchdog);
384 381
385#ifdef CONFIG_PCI 382 spin_lock_irq(&ehci->lock);
386 if (hcd->self.controller->bus == &pci_bus_type) { 383 if (HC_IS_RUNNING (hcd->state))
387 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 384 ehci_quiesce (ehci);
388 385
389 switch (pdev->vendor) { 386 ehci_reset (ehci);
390 case PCI_VENDOR_ID_TDI: 387 writel (0, &ehci->regs->intr_enable);
391 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 388 spin_unlock_irq(&ehci->lock);
392 ehci->is_tdi_rh_tt = 1;
393 tdi_reset (ehci);
394 }
395 break;
396 case PCI_VENDOR_ID_AMD:
397 /* AMD8111 EHCI doesn't work, according to AMD errata */
398 if (pdev->device == 0x7463) {
399 ehci_info (ehci, "ignoring AMD8111 (errata)\n");
400 return -EIO;
401 }
402 break;
403 case PCI_VENDOR_ID_NVIDIA:
404 /* NVidia reports that certain chips don't handle
405 * QH, ITD, or SITD addresses above 2GB. (But TD,
406 * data buffer, and periodic schedule are normal.)
407 */
408 switch (pdev->device) {
409 case 0x003c: /* MCP04 */
410 case 0x005b: /* CK804 */
411 case 0x00d8: /* CK8 */
412 case 0x00e8: /* CK8S */
413 if (pci_set_consistent_dma_mask(pdev,
414 DMA_31BIT_MASK) < 0)
415 ehci_warn (ehci, "can't enable NVidia "
416 "workaround for >2GB RAM\n");
417 break;
418 }
419 break;
420 }
421 389
422 /* optional debug port, normally in the first BAR */ 390 /* let companion controllers work when we aren't */
423 temp = pci_find_capability (pdev, 0x0a); 391 writel (0, &ehci->regs->configured_flag);
424 if (temp) { 392 unregister_reboot_notifier (&ehci->reboot_notifier);
425 pci_read_config_dword(pdev, temp, &temp);
426 temp >>= 16;
427 if ((temp & (3 << 13)) == (1 << 13)) {
428 temp &= 0x1fff;
429 ehci->debug = hcd->regs + temp;
430 temp = readl (&ehci->debug->control);
431 ehci_info (ehci, "debug port %d%s\n",
432 HCS_DEBUG_PORT(ehci->hcs_params),
433 (temp & DBGP_ENABLED)
434 ? " IN USE"
435 : "");
436 if (!(temp & DBGP_ENABLED))
437 ehci->debug = NULL;
438 }
439 }
440 393
441 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 394 remove_debug_files (ehci);
442 } else
443 temp = 0;
444
445 /* EHCI 0.96 and later may have "extended capabilities" */
446 while (temp && count--) {
447 u32 cap;
448
449 pci_read_config_dword (to_pci_dev(hcd->self.controller),
450 temp, &cap);
451 ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
452 switch (cap & 0xff) {
453 case 1: /* BIOS/SMM/... handoff */
454 if (bios_handoff (ehci, temp, cap) != 0)
455 return -EOPNOTSUPP;
456 break;
457 case 0: /* illegal reserved capability */
458 ehci_warn (ehci, "illegal capability!\n");
459 cap = 0;
460 /* FALLTHROUGH */
461 default: /* unknown */
462 break;
463 }
464 temp = (cap >> 8) & 0xff;
465 }
466 if (!count) {
467 ehci_err (ehci, "bogus capabilities ... PCI problems!\n");
468 return -EIO;
469 }
470 if (ehci_is_TDI(ehci))
471 ehci_reset (ehci);
472#endif
473 395
474 ehci_port_power (ehci, 0); 396 /* root hub is shut down separately (first, when possible) */
397 spin_lock_irq (&ehci->lock);
398 if (ehci->async)
399 ehci_work (ehci, NULL);
400 spin_unlock_irq (&ehci->lock);
401 ehci_mem_cleanup (ehci);
475 402
476 /* at least the Genesys GL880S needs fixup here */ 403#ifdef EHCI_STATS
477 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 404 ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
478 temp &= 0x0f; 405 ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
479 if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 406 ehci->stats.lost_iaa);
480 ehci_dbg (ehci, "bogus port configuration: " 407 ehci_dbg (ehci, "complete %ld unlink %ld\n",
481 "cc=%d x pcc=%d < ports=%d\n", 408 ehci->stats.complete, ehci->stats.unlink);
482 HCS_N_CC(ehci->hcs_params),
483 HCS_N_PCC(ehci->hcs_params),
484 HCS_N_PORTS(ehci->hcs_params));
485
486#ifdef CONFIG_PCI
487 if (hcd->self.controller->bus == &pci_bus_type) {
488 struct pci_dev *pdev;
489
490 pdev = to_pci_dev(hcd->self.controller);
491 switch (pdev->vendor) {
492 case 0x17a0: /* GENESYS */
493 /* GL880S: should be PORTS=2 */
494 temp |= (ehci->hcs_params & ~0xf);
495 ehci->hcs_params = temp;
496 break;
497 case PCI_VENDOR_ID_NVIDIA:
498 /* NF4: should be PCC=10 */
499 break;
500 }
501 }
502#endif 409#endif
503 }
504 410
505 /* force HC to halt state */ 411 dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
506 return ehci_halt (ehci);
507} 412}
508 413
509static int ehci_start (struct usb_hcd *hcd) 414static int ehci_run (struct usb_hcd *hcd)
510{ 415{
511 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 416 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
512 u32 temp; 417 u32 temp;
513 int retval; 418 int retval;
514 u32 hcc_params; 419 u32 hcc_params;
515 u8 sbrn = 0;
516 int first; 420 int first;
517 421
518 /* skip some things on restart paths */ 422 /* skip some things on restart paths */
@@ -551,27 +455,6 @@ static int ehci_start (struct usb_hcd *hcd)
551 } 455 }
552 writel (ehci->periodic_dma, &ehci->regs->frame_list); 456 writel (ehci->periodic_dma, &ehci->regs->frame_list);
553 457
554#ifdef CONFIG_PCI
555 if (hcd->self.controller->bus == &pci_bus_type) {
556 struct pci_dev *pdev;
557 u16 port_wake;
558
559 pdev = to_pci_dev(hcd->self.controller);
560
561 /* Serial Bus Release Number is at PCI 0x60 offset */
562 pci_read_config_byte(pdev, 0x60, &sbrn);
563
564 /* port wake capability, reported by boot firmware */
565 pci_read_config_word(pdev, 0x62, &port_wake);
566 hcd->can_wakeup = (port_wake & 1) != 0;
567
568 /* help hc dma work well with cachelines */
569 retval = pci_set_mwi(pdev);
570 if (retval)
571 ehci_dbg(ehci, "unable to enable MWI - not fatal.\n");
572 }
573#endif
574
575 /* 458 /*
576 * dedicate a qh for the async ring head, since we couldn't unlink 459 * dedicate a qh for the async ring head, since we couldn't unlink
577 * a 'real' qh without stopping the async schedule [4.8]. use it 460 * a 'real' qh without stopping the async schedule [4.8]. use it
@@ -667,7 +550,7 @@ static int ehci_start (struct usb_hcd *hcd)
667 temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); 550 temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
668 ehci_info (ehci, 551 ehci_info (ehci,
669 "USB %x.%x %s, EHCI %x.%02x, driver %s\n", 552 "USB %x.%x %s, EHCI %x.%02x, driver %s\n",
670 ((sbrn & 0xf0)>>4), (sbrn & 0x0f), 553 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
671 first ? "initialized" : "restarted", 554 first ? "initialized" : "restarted",
672 temp >> 8, temp & 0xff, DRIVER_VERSION); 555 temp >> 8, temp & 0xff, DRIVER_VERSION);
673 556
@@ -679,188 +562,6 @@ static int ehci_start (struct usb_hcd *hcd)
679 return 0; 562 return 0;
680} 563}
681 564
682/* always called by thread; normally rmmod */
683
684static void ehci_stop (struct usb_hcd *hcd)
685{
686 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
687
688 ehci_dbg (ehci, "stop\n");
689
690 /* Turn off port power on all root hub ports. */
691 ehci_port_power (ehci, 0);
692
693 /* no more interrupts ... */
694 del_timer_sync (&ehci->watchdog);
695
696 spin_lock_irq(&ehci->lock);
697 if (HC_IS_RUNNING (hcd->state))
698 ehci_quiesce (ehci);
699
700 ehci_reset (ehci);
701 writel (0, &ehci->regs->intr_enable);
702 spin_unlock_irq(&ehci->lock);
703
704 /* let companion controllers work when we aren't */
705 writel (0, &ehci->regs->configured_flag);
706 unregister_reboot_notifier (&ehci->reboot_notifier);
707
708 remove_debug_files (ehci);
709
710 /* root hub is shut down separately (first, when possible) */
711 spin_lock_irq (&ehci->lock);
712 if (ehci->async)
713 ehci_work (ehci, NULL);
714 spin_unlock_irq (&ehci->lock);
715 ehci_mem_cleanup (ehci);
716
717#ifdef EHCI_STATS
718 ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
719 ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
720 ehci->stats.lost_iaa);
721 ehci_dbg (ehci, "complete %ld unlink %ld\n",
722 ehci->stats.complete, ehci->stats.unlink);
723#endif
724
725 dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
726}
727
728static int ehci_get_frame (struct usb_hcd *hcd)
729{
730 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
731 return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size;
732}
733
734/*-------------------------------------------------------------------------*/
735
736#ifdef CONFIG_PM
737
738/* suspend/resume, section 4.3 */
739
740/* These routines rely on the bus (pci, platform, etc)
741 * to handle powerdown and wakeup, and currently also on
742 * transceivers that don't need any software attention to set up
743 * the right sort of wakeup.
744 */
745
746static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message)
747{
748 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
749
750 if (time_before (jiffies, ehci->next_statechange))
751 msleep (100);
752
753#ifdef CONFIG_USB_SUSPEND
754 (void) usb_suspend_device (hcd->self.root_hub, message);
755#else
756 usb_lock_device (hcd->self.root_hub);
757 (void) ehci_hub_suspend (hcd);
758 usb_unlock_device (hcd->self.root_hub);
759#endif
760
761 // save (PCI) FLADJ in case of Vaux power loss
762 // ... we'd only use it to handle clock skew
763
764 return 0;
765}
766
767static int ehci_resume (struct usb_hcd *hcd)
768{
769 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
770 unsigned port;
771 struct usb_device *root = hcd->self.root_hub;
772 int retval = -EINVAL;
773
774 // maybe restore (PCI) FLADJ
775
776 if (time_before (jiffies, ehci->next_statechange))
777 msleep (100);
778
779 /* If any port is suspended (or owned by the companion),
780 * we know we can/must resume the HC (and mustn't reset it).
781 */
782 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) {
783 u32 status;
784 port--;
785 status = readl (&ehci->regs->port_status [port]);
786 if (!(status & PORT_POWER))
787 continue;
788 if (status & (PORT_SUSPEND | PORT_OWNER)) {
789 down (&hcd->self.root_hub->serialize);
790 retval = ehci_hub_resume (hcd);
791 up (&hcd->self.root_hub->serialize);
792 break;
793 }
794 if (!root->children [port])
795 continue;
796 dbg_port (ehci, __FUNCTION__, port + 1, status);
797 usb_set_device_state (root->children[port],
798 USB_STATE_NOTATTACHED);
799 }
800
801 /* Else reset, to cope with power loss or flush-to-storage
802 * style "resume" having activated BIOS during reboot.
803 */
804 if (port == 0) {
805 (void) ehci_halt (ehci);
806 (void) ehci_reset (ehci);
807 (void) ehci_hc_reset (hcd);
808
809 /* emptying the schedule aborts any urbs */
810 spin_lock_irq (&ehci->lock);
811 if (ehci->reclaim)
812 ehci->reclaim_ready = 1;
813 ehci_work (ehci, NULL);
814 spin_unlock_irq (&ehci->lock);
815
816 /* restart; khubd will disconnect devices */
817 retval = ehci_start (hcd);
818
819 /* here we "know" root ports should always stay powered;
820 * but some controllers may lose all power.
821 */
822 ehci_port_power (ehci, 1);
823 }
824
825 return retval;
826}
827
828#endif
829
830/*-------------------------------------------------------------------------*/
831
832/*
833 * ehci_work is called from some interrupts, timers, and so on.
834 * it calls driver completion functions, after dropping ehci->lock.
835 */
836static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
837{
838 timer_action_done (ehci, TIMER_IO_WATCHDOG);
839 if (ehci->reclaim_ready)
840 end_unlink_async (ehci, regs);
841
842 /* another CPU may drop ehci->lock during a schedule scan while
843 * it reports urb completions. this flag guards against bogus
844 * attempts at re-entrant schedule scanning.
845 */
846 if (ehci->scanning)
847 return;
848 ehci->scanning = 1;
849 scan_async (ehci, regs);
850 if (ehci->next_uframe != -1)
851 scan_periodic (ehci, regs);
852 ehci->scanning = 0;
853
854 /* the IO watchdog guards against hardware or driver bugs that
855 * misplace IRQs, and should let us run completely without IRQs.
856 * such lossage has been observed on both VT6202 and VT8235.
857 */
858 if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) &&
859 (ehci->async->qh_next.ptr != NULL ||
860 ehci->periodic_sched != 0))
861 timer_action (ehci, TIMER_IO_WATCHDOG);
862}
863
864/*-------------------------------------------------------------------------*/ 565/*-------------------------------------------------------------------------*/
865 566
866static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) 567static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
@@ -983,7 +684,7 @@ static int ehci_urb_enqueue (
983 struct usb_hcd *hcd, 684 struct usb_hcd *hcd,
984 struct usb_host_endpoint *ep, 685 struct usb_host_endpoint *ep,
985 struct urb *urb, 686 struct urb *urb,
986 unsigned mem_flags 687 gfp_t mem_flags
987) { 688) {
988 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 689 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
989 struct list_head qtd_list; 690 struct list_head qtd_list;
@@ -1171,106 +872,24 @@ done:
1171 return; 872 return;
1172} 873}
1173 874
1174/*-------------------------------------------------------------------------*/ 875static int ehci_get_frame (struct usb_hcd *hcd)
1175 876{
1176static const struct hc_driver ehci_driver = { 877 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
1177 .description = hcd_name, 878 return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size;
1178 .product_desc = "EHCI Host Controller", 879}
1179 .hcd_priv_size = sizeof(struct ehci_hcd),
1180
1181 /*
1182 * generic hardware linkage
1183 */
1184 .irq = ehci_irq,
1185 .flags = HCD_MEMORY | HCD_USB2,
1186
1187 /*
1188 * basic lifecycle operations
1189 */
1190 .reset = ehci_hc_reset,
1191 .start = ehci_start,
1192#ifdef CONFIG_PM
1193 .suspend = ehci_suspend,
1194 .resume = ehci_resume,
1195#endif
1196 .stop = ehci_stop,
1197
1198 /*
1199 * managing i/o requests and associated device resources
1200 */
1201 .urb_enqueue = ehci_urb_enqueue,
1202 .urb_dequeue = ehci_urb_dequeue,
1203 .endpoint_disable = ehci_endpoint_disable,
1204
1205 /*
1206 * scheduling support
1207 */
1208 .get_frame_number = ehci_get_frame,
1209
1210 /*
1211 * root hub support
1212 */
1213 .hub_status_data = ehci_hub_status_data,
1214 .hub_control = ehci_hub_control,
1215 .hub_suspend = ehci_hub_suspend,
1216 .hub_resume = ehci_hub_resume,
1217};
1218 880
1219/*-------------------------------------------------------------------------*/ 881/*-------------------------------------------------------------------------*/
1220 882
1221/* EHCI 1.0 doesn't require PCI */
1222
1223#ifdef CONFIG_PCI
1224
1225/* PCI driver selection metadata; PCI hotplugging uses this */
1226static const struct pci_device_id pci_ids [] = { {
1227 /* handle any USB 2.0 EHCI controller */
1228 PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
1229 .driver_data = (unsigned long) &ehci_driver,
1230 },
1231 { /* end: all zeroes */ }
1232};
1233MODULE_DEVICE_TABLE (pci, pci_ids);
1234
1235/* pci driver glue; this is a "new style" PCI driver module */
1236static struct pci_driver ehci_pci_driver = {
1237 .name = (char *) hcd_name,
1238 .id_table = pci_ids,
1239
1240 .probe = usb_hcd_pci_probe,
1241 .remove = usb_hcd_pci_remove,
1242
1243#ifdef CONFIG_PM
1244 .suspend = usb_hcd_pci_suspend,
1245 .resume = usb_hcd_pci_resume,
1246#endif
1247};
1248
1249#endif /* PCI */
1250
1251
1252#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC 883#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
1253 884
1254MODULE_DESCRIPTION (DRIVER_INFO); 885MODULE_DESCRIPTION (DRIVER_INFO);
1255MODULE_AUTHOR (DRIVER_AUTHOR); 886MODULE_AUTHOR (DRIVER_AUTHOR);
1256MODULE_LICENSE ("GPL"); 887MODULE_LICENSE ("GPL");
1257 888
1258static int __init init (void) 889#ifdef CONFIG_PCI
1259{ 890#include "ehci-pci.c"
1260 if (usb_disabled()) 891#endif
1261 return -ENODEV;
1262
1263 pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
1264 hcd_name,
1265 sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
1266 sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
1267
1268 return pci_register_driver (&ehci_pci_driver);
1269}
1270module_init (init);
1271 892
1272static void __exit cleanup (void) 893#if !defined(CONFIG_PCI)
1273{ 894#error "missing bus glue for ehci-hcd"
1274 pci_unregister_driver (&ehci_pci_driver); 895#endif
1275}
1276module_exit (cleanup);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 18d3f2270316..88cb4ada686e 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -30,7 +30,7 @@
30 30
31#ifdef CONFIG_PM 31#ifdef CONFIG_PM
32 32
33static int ehci_hub_suspend (struct usb_hcd *hcd) 33static int ehci_bus_suspend (struct usb_hcd *hcd)
34{ 34{
35 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 35 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
36 int port; 36 int port;
@@ -83,7 +83,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd)
83 83
84 84
85/* caller has locked the root hub, and should reset/reinit on error */ 85/* caller has locked the root hub, and should reset/reinit on error */
86static int ehci_hub_resume (struct usb_hcd *hcd) 86static int ehci_bus_resume (struct usb_hcd *hcd)
87{ 87{
88 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 88 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
89 u32 temp; 89 u32 temp;
@@ -159,8 +159,8 @@ static int ehci_hub_resume (struct usb_hcd *hcd)
159 159
160#else 160#else
161 161
162#define ehci_hub_suspend NULL 162#define ehci_bus_suspend NULL
163#define ehci_hub_resume NULL 163#define ehci_bus_resume NULL
164 164
165#endif /* CONFIG_PM */ 165#endif /* CONFIG_PM */
166 166
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 5c38ad869485..91c2ab43cbcc 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -45,7 +45,7 @@ static inline void ehci_qtd_init (struct ehci_qtd *qtd, dma_addr_t dma)
45 INIT_LIST_HEAD (&qtd->qtd_list); 45 INIT_LIST_HEAD (&qtd->qtd_list);
46} 46}
47 47
48static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, int flags) 48static struct ehci_qtd *ehci_qtd_alloc (struct ehci_hcd *ehci, gfp_t flags)
49{ 49{
50 struct ehci_qtd *qtd; 50 struct ehci_qtd *qtd;
51 dma_addr_t dma; 51 dma_addr_t dma;
@@ -79,7 +79,7 @@ static void qh_destroy (struct kref *kref)
79 dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); 79 dma_pool_free (ehci->qh_pool, qh, qh->qh_dma);
80} 80}
81 81
82static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) 82static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
83{ 83{
84 struct ehci_qh *qh; 84 struct ehci_qh *qh;
85 dma_addr_t dma; 85 dma_addr_t dma;
@@ -161,7 +161,7 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci)
161} 161}
162 162
163/* remember to add cleanup code (above) if you add anything here */ 163/* remember to add cleanup code (above) if you add anything here */
164static int ehci_mem_init (struct ehci_hcd *ehci, int flags) 164static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
165{ 165{
166 int i; 166 int i;
167 167
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
new file mode 100644
index 000000000000..145008853966
--- /dev/null
+++ b/drivers/usb/host/ehci-pci.c
@@ -0,0 +1,415 @@
1/*
2 * EHCI HCD (Host Controller Driver) PCI Bus Glue.
3 *
4 * Copyright (c) 2000-2004 by David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#ifndef CONFIG_PCI
22#error "This file is PCI bus glue. CONFIG_PCI must be defined."
23#endif
24
25/*-------------------------------------------------------------------------*/
26
27/* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
28 * off the controller (maybe it can boot from highspeed USB disks).
29 */
30static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
31{
32 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
33
34 /* always say Linux will own the hardware */
35 pci_write_config_byte(pdev, where + 3, 1);
36
37 /* maybe wait a while for BIOS to respond */
38 if (cap & (1 << 16)) {
39 int msec = 5000;
40
41 do {
42 msleep(10);
43 msec -= 10;
44 pci_read_config_dword(pdev, where, &cap);
45 } while ((cap & (1 << 16)) && msec);
46 if (cap & (1 << 16)) {
47 ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n",
48 where, cap);
49 // some BIOS versions seem buggy...
50 // return 1;
51 ehci_warn (ehci, "continuing after BIOS bug...\n");
52 /* disable all SMIs, and clear "BIOS owns" flag */
53 pci_write_config_dword(pdev, where + 4, 0);
54 pci_write_config_byte(pdev, where + 2, 0);
55 } else
56 ehci_dbg(ehci, "BIOS handoff succeeded\n");
57 }
58 return 0;
59}
60
61/* called by khubd or root hub init threads */
62static int ehci_pci_reset (struct usb_hcd *hcd)
63{
64 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
65 u32 temp;
66 unsigned count = 256/4;
67
68 spin_lock_init (&ehci->lock);
69
70 ehci->caps = hcd->regs;
71 ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase));
72 dbg_hcs_params (ehci, "reset");
73 dbg_hcc_params (ehci, "reset");
74
75 /* cache this readonly data; minimize chip reads */
76 ehci->hcs_params = readl (&ehci->caps->hcs_params);
77
78 if (hcd->self.controller->bus == &pci_bus_type) {
79 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
80
81 switch (pdev->vendor) {
82 case PCI_VENDOR_ID_TDI:
83 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
84 ehci->is_tdi_rh_tt = 1;
85 tdi_reset (ehci);
86 }
87 break;
88 case PCI_VENDOR_ID_AMD:
89 /* AMD8111 EHCI doesn't work, according to AMD errata */
90 if (pdev->device == 0x7463) {
91 ehci_info (ehci, "ignoring AMD8111 (errata)\n");
92 return -EIO;
93 }
94 break;
95 case PCI_VENDOR_ID_NVIDIA:
96 /* NVidia reports that certain chips don't handle
97 * QH, ITD, or SITD addresses above 2GB. (But TD,
98 * data buffer, and periodic schedule are normal.)
99 */
100 switch (pdev->device) {
101 case 0x003c: /* MCP04 */
102 case 0x005b: /* CK804 */
103 case 0x00d8: /* CK8 */
104 case 0x00e8: /* CK8S */
105 if (pci_set_consistent_dma_mask(pdev,
106 DMA_31BIT_MASK) < 0)
107 ehci_warn (ehci, "can't enable NVidia "
108 "workaround for >2GB RAM\n");
109 break;
110 }
111 break;
112 }
113
114 /* optional debug port, normally in the first BAR */
115 temp = pci_find_capability (pdev, 0x0a);
116 if (temp) {
117 pci_read_config_dword(pdev, temp, &temp);
118 temp >>= 16;
119 if ((temp & (3 << 13)) == (1 << 13)) {
120 temp &= 0x1fff;
121 ehci->debug = hcd->regs + temp;
122 temp = readl (&ehci->debug->control);
123 ehci_info (ehci, "debug port %d%s\n",
124 HCS_DEBUG_PORT(ehci->hcs_params),
125 (temp & DBGP_ENABLED)
126 ? " IN USE"
127 : "");
128 if (!(temp & DBGP_ENABLED))
129 ehci->debug = NULL;
130 }
131 }
132
133 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
134 } else
135 temp = 0;
136
137 /* EHCI 0.96 and later may have "extended capabilities" */
138 while (temp && count--) {
139 u32 cap;
140
141 pci_read_config_dword (to_pci_dev(hcd->self.controller),
142 temp, &cap);
143 ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
144 switch (cap & 0xff) {
145 case 1: /* BIOS/SMM/... handoff */
146 if (bios_handoff (ehci, temp, cap) != 0)
147 return -EOPNOTSUPP;
148 break;
149 case 0: /* illegal reserved capability */
150 ehci_warn (ehci, "illegal capability!\n");
151 cap = 0;
152 /* FALLTHROUGH */
153 default: /* unknown */
154 break;
155 }
156 temp = (cap >> 8) & 0xff;
157 }
158 if (!count) {
159 ehci_err (ehci, "bogus capabilities ... PCI problems!\n");
160 return -EIO;
161 }
162 if (ehci_is_TDI(ehci))
163 ehci_reset (ehci);
164
165 ehci_port_power (ehci, 0);
166
167 /* at least the Genesys GL880S needs fixup here */
168 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
169 temp &= 0x0f;
170 if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
171 ehci_dbg (ehci, "bogus port configuration: "
172 "cc=%d x pcc=%d < ports=%d\n",
173 HCS_N_CC(ehci->hcs_params),
174 HCS_N_PCC(ehci->hcs_params),
175 HCS_N_PORTS(ehci->hcs_params));
176
177 if (hcd->self.controller->bus == &pci_bus_type) {
178 struct pci_dev *pdev;
179
180 pdev = to_pci_dev(hcd->self.controller);
181 switch (pdev->vendor) {
182 case 0x17a0: /* GENESYS */
183 /* GL880S: should be PORTS=2 */
184 temp |= (ehci->hcs_params & ~0xf);
185 ehci->hcs_params = temp;
186 break;
187 case PCI_VENDOR_ID_NVIDIA:
188 /* NF4: should be PCC=10 */
189 break;
190 }
191 }
192 }
193
194 /* force HC to halt state */
195 return ehci_halt (ehci);
196}
197
198static int ehci_pci_start (struct usb_hcd *hcd)
199{
200 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
201 int result = 0;
202
203 if (hcd->self.controller->bus == &pci_bus_type) {
204 struct pci_dev *pdev;
205 u16 port_wake;
206
207 pdev = to_pci_dev(hcd->self.controller);
208
209 /* Serial Bus Release Number is at PCI 0x60 offset */
210 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
211
212 /* port wake capability, reported by boot firmware */
213 pci_read_config_word(pdev, 0x62, &port_wake);
214 hcd->can_wakeup = (port_wake & 1) != 0;
215
216 /* help hc dma work well with cachelines */
217 result = pci_set_mwi(pdev);
218 if (result)
219 ehci_dbg(ehci, "unable to enable MWI - not fatal.\n");
220 }
221
222 return ehci_run (hcd);
223}
224
225/* always called by thread; normally rmmod */
226
227static void ehci_pci_stop (struct usb_hcd *hcd)
228{
229 ehci_stop (hcd);
230}
231
232/*-------------------------------------------------------------------------*/
233
234#ifdef CONFIG_PM
235
236/* suspend/resume, section 4.3 */
237
238/* These routines rely on the bus (pci, platform, etc)
239 * to handle powerdown and wakeup, and currently also on
240 * transceivers that don't need any software attention to set up
241 * the right sort of wakeup.
242 */
243
244static int ehci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
245{
246 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
247
248 if (time_before (jiffies, ehci->next_statechange))
249 msleep (100);
250
251#ifdef CONFIG_USB_SUSPEND
252 (void) usb_suspend_device (hcd->self.root_hub);
253#else
254 usb_lock_device (hcd->self.root_hub);
255 (void) ehci_bus_suspend (hcd);
256 usb_unlock_device (hcd->self.root_hub);
257#endif
258
259 // save (PCI) FLADJ in case of Vaux power loss
260 // ... we'd only use it to handle clock skew
261
262 return 0;
263}
264
265static int ehci_pci_resume (struct usb_hcd *hcd)
266{
267 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
268 unsigned port;
269 struct usb_device *root = hcd->self.root_hub;
270 int retval = -EINVAL;
271
272 // maybe restore (PCI) FLADJ
273
274 if (time_before (jiffies, ehci->next_statechange))
275 msleep (100);
276
277 /* If any port is suspended (or owned by the companion),
278 * we know we can/must resume the HC (and mustn't reset it).
279 */
280 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) {
281 u32 status;
282 port--;
283 status = readl (&ehci->regs->port_status [port]);
284 if (!(status & PORT_POWER))
285 continue;
286 if (status & (PORT_SUSPEND | PORT_OWNER)) {
287 down (&hcd->self.root_hub->serialize);
288 retval = ehci_bus_resume (hcd);
289 up (&hcd->self.root_hub->serialize);
290 break;
291 }
292 if (!root->children [port])
293 continue;
294 dbg_port (ehci, __FUNCTION__, port + 1, status);
295 usb_set_device_state (root->children[port],
296 USB_STATE_NOTATTACHED);
297 }
298
299 /* Else reset, to cope with power loss or flush-to-storage
300 * style "resume" having activated BIOS during reboot.
301 */
302 if (port == 0) {
303 (void) ehci_halt (ehci);
304 (void) ehci_reset (ehci);
305 (void) ehci_pci_reset (hcd);
306
307 /* emptying the schedule aborts any urbs */
308 spin_lock_irq (&ehci->lock);
309 if (ehci->reclaim)
310 ehci->reclaim_ready = 1;
311 ehci_work (ehci, NULL);
312 spin_unlock_irq (&ehci->lock);
313
314 /* restart; khubd will disconnect devices */
315 retval = ehci_run (hcd);
316
317 /* here we "know" root ports should always stay powered;
318 * but some controllers may lose all power.
319 */
320 ehci_port_power (ehci, 1);
321 }
322
323 return retval;
324}
325#endif
326
327static const struct hc_driver ehci_pci_hc_driver = {
328 .description = hcd_name,
329 .product_desc = "EHCI Host Controller",
330 .hcd_priv_size = sizeof(struct ehci_hcd),
331
332 /*
333 * generic hardware linkage
334 */
335 .irq = ehci_irq,
336 .flags = HCD_MEMORY | HCD_USB2,
337
338 /*
339 * basic lifecycle operations
340 */
341 .reset = ehci_pci_reset,
342 .start = ehci_pci_start,
343#ifdef CONFIG_PM
344 .suspend = ehci_pci_suspend,
345 .resume = ehci_pci_resume,
346#endif
347 .stop = ehci_pci_stop,
348
349 /*
350 * managing i/o requests and associated device resources
351 */
352 .urb_enqueue = ehci_urb_enqueue,
353 .urb_dequeue = ehci_urb_dequeue,
354 .endpoint_disable = ehci_endpoint_disable,
355
356 /*
357 * scheduling support
358 */
359 .get_frame_number = ehci_get_frame,
360
361 /*
362 * root hub support
363 */
364 .hub_status_data = ehci_hub_status_data,
365 .hub_control = ehci_hub_control,
366 .bus_suspend = ehci_bus_suspend,
367 .bus_resume = ehci_bus_resume,
368};
369
370/*-------------------------------------------------------------------------*/
371
372/* PCI driver selection metadata; PCI hotplugging uses this */
373static const struct pci_device_id pci_ids [] = { {
374 /* handle any USB 2.0 EHCI controller */
375 PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0),
376 .driver_data = (unsigned long) &ehci_pci_hc_driver,
377 },
378 { /* end: all zeroes */ }
379};
380MODULE_DEVICE_TABLE (pci, pci_ids);
381
382/* pci driver glue; this is a "new style" PCI driver module */
383static struct pci_driver ehci_pci_driver = {
384 .name = (char *) hcd_name,
385 .id_table = pci_ids,
386 .owner = THIS_MODULE,
387
388 .probe = usb_hcd_pci_probe,
389 .remove = usb_hcd_pci_remove,
390
391#ifdef CONFIG_PM
392 .suspend = usb_hcd_pci_suspend,
393 .resume = usb_hcd_pci_resume,
394#endif
395};
396
397static int __init ehci_hcd_pci_init (void)
398{
399 if (usb_disabled())
400 return -ENODEV;
401
402 pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
403 hcd_name,
404 sizeof (struct ehci_qh), sizeof (struct ehci_qtd),
405 sizeof (struct ehci_itd), sizeof (struct ehci_sitd));
406
407 return pci_register_driver (&ehci_pci_driver);
408}
409module_init (ehci_hcd_pci_init);
410
411static void __exit ehci_hcd_pci_cleanup (void)
412{
413 pci_unregister_driver (&ehci_pci_driver);
414}
415module_exit (ehci_hcd_pci_cleanup);
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 940d38ca7d91..5bb872c3496d 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -477,7 +477,7 @@ qh_urb_transaction (
477 struct ehci_hcd *ehci, 477 struct ehci_hcd *ehci,
478 struct urb *urb, 478 struct urb *urb,
479 struct list_head *head, 479 struct list_head *head,
480 int flags 480 gfp_t flags
481) { 481) {
482 struct ehci_qtd *qtd, *qtd_prev; 482 struct ehci_qtd *qtd, *qtd_prev;
483 dma_addr_t buf; 483 dma_addr_t buf;
@@ -629,7 +629,7 @@ static struct ehci_qh *
629qh_make ( 629qh_make (
630 struct ehci_hcd *ehci, 630 struct ehci_hcd *ehci,
631 struct urb *urb, 631 struct urb *urb,
632 int flags 632 gfp_t flags
633) { 633) {
634 struct ehci_qh *qh = ehci_qh_alloc (ehci, flags); 634 struct ehci_qh *qh = ehci_qh_alloc (ehci, flags);
635 u32 info1 = 0, info2 = 0; 635 u32 info1 = 0, info2 = 0;
@@ -906,7 +906,7 @@ submit_async (
906 struct usb_host_endpoint *ep, 906 struct usb_host_endpoint *ep,
907 struct urb *urb, 907 struct urb *urb,
908 struct list_head *qtd_list, 908 struct list_head *qtd_list,
909 unsigned mem_flags 909 gfp_t mem_flags
910) { 910) {
911 struct ehci_qtd *qtd; 911 struct ehci_qtd *qtd;
912 int epnum; 912 int epnum;
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index ccc7300baa6d..f0c8aa1ccd5d 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -589,7 +589,7 @@ static int intr_submit (
589 struct usb_host_endpoint *ep, 589 struct usb_host_endpoint *ep,
590 struct urb *urb, 590 struct urb *urb,
591 struct list_head *qtd_list, 591 struct list_head *qtd_list,
592 unsigned mem_flags 592 gfp_t mem_flags
593) { 593) {
594 unsigned epnum; 594 unsigned epnum;
595 unsigned long flags; 595 unsigned long flags;
@@ -634,7 +634,7 @@ done:
634/* ehci_iso_stream ops work with both ITD and SITD */ 634/* ehci_iso_stream ops work with both ITD and SITD */
635 635
636static struct ehci_iso_stream * 636static struct ehci_iso_stream *
637iso_stream_alloc (unsigned mem_flags) 637iso_stream_alloc (gfp_t mem_flags)
638{ 638{
639 struct ehci_iso_stream *stream; 639 struct ehci_iso_stream *stream;
640 640
@@ -851,7 +851,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
851/* ehci_iso_sched ops can be ITD-only or SITD-only */ 851/* ehci_iso_sched ops can be ITD-only or SITD-only */
852 852
853static struct ehci_iso_sched * 853static struct ehci_iso_sched *
854iso_sched_alloc (unsigned packets, unsigned mem_flags) 854iso_sched_alloc (unsigned packets, gfp_t mem_flags)
855{ 855{
856 struct ehci_iso_sched *iso_sched; 856 struct ehci_iso_sched *iso_sched;
857 int size = sizeof *iso_sched; 857 int size = sizeof *iso_sched;
@@ -924,7 +924,7 @@ itd_urb_transaction (
924 struct ehci_iso_stream *stream, 924 struct ehci_iso_stream *stream,
925 struct ehci_hcd *ehci, 925 struct ehci_hcd *ehci,
926 struct urb *urb, 926 struct urb *urb,
927 unsigned mem_flags 927 gfp_t mem_flags
928) 928)
929{ 929{
930 struct ehci_itd *itd; 930 struct ehci_itd *itd;
@@ -1418,7 +1418,7 @@ itd_complete (
1418/*-------------------------------------------------------------------------*/ 1418/*-------------------------------------------------------------------------*/
1419 1419
1420static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, 1420static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1421 unsigned mem_flags) 1421 gfp_t mem_flags)
1422{ 1422{
1423 int status = -EINVAL; 1423 int status = -EINVAL;
1424 unsigned long flags; 1424 unsigned long flags;
@@ -1529,7 +1529,7 @@ sitd_urb_transaction (
1529 struct ehci_iso_stream *stream, 1529 struct ehci_iso_stream *stream,
1530 struct ehci_hcd *ehci, 1530 struct ehci_hcd *ehci,
1531 struct urb *urb, 1531 struct urb *urb,
1532 unsigned mem_flags 1532 gfp_t mem_flags
1533) 1533)
1534{ 1534{
1535 struct ehci_sitd *sitd; 1535 struct ehci_sitd *sitd;
@@ -1779,7 +1779,7 @@ sitd_complete (
1779 1779
1780 1780
1781static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, 1781static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
1782 unsigned mem_flags) 1782 gfp_t mem_flags)
1783{ 1783{
1784 int status = -EINVAL; 1784 int status = -EINVAL;
1785 unsigned long flags; 1785 unsigned long flags;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index f34a0516d35f..18e257c2bdb5 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -97,6 +97,7 @@ struct ehci_hcd { /* one per controller */
97#else 97#else
98# define COUNT(x) do {} while (0) 98# define COUNT(x) do {} while (0)
99#endif 99#endif
100 u8 sbrn; /* packed release number */
100}; 101};
101 102
102/* convert between an HCD pointer and the corresponding EHCI_HCD */ 103/* convert between an HCD pointer and the corresponding EHCI_HCD */
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index e142056b0d2c..ddb8fc591466 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -638,7 +638,7 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs)
638 + msecs_to_jiffies(20) + 1); 638 + msecs_to_jiffies(20) + 1);
639 if (intstat & HCINT_RD) { 639 if (intstat & HCINT_RD) {
640 DBG("---- remote wakeup\n"); 640 DBG("---- remote wakeup\n");
641 schedule_work(&isp116x->rh_resume); 641 usb_hcd_resume_root_hub(hcd);
642 ret = IRQ_HANDLED; 642 ret = IRQ_HANDLED;
643 } 643 }
644 irqstat &= ~HCuPINT_OPR; 644 irqstat &= ~HCuPINT_OPR;
@@ -694,7 +694,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load)
694 694
695static int isp116x_urb_enqueue(struct usb_hcd *hcd, 695static int isp116x_urb_enqueue(struct usb_hcd *hcd,
696 struct usb_host_endpoint *hep, struct urb *urb, 696 struct usb_host_endpoint *hep, struct urb *urb,
697 unsigned mem_flags) 697 gfp_t mem_flags)
698{ 698{
699 struct isp116x *isp116x = hcd_to_isp116x(hcd); 699 struct isp116x *isp116x = hcd_to_isp116x(hcd);
700 struct usb_device *udev = urb->dev; 700 struct usb_device *udev = urb->dev;
@@ -1160,7 +1160,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
1160 1160
1161#ifdef CONFIG_PM 1161#ifdef CONFIG_PM
1162 1162
1163static int isp116x_hub_suspend(struct usb_hcd *hcd) 1163static int isp116x_bus_suspend(struct usb_hcd *hcd)
1164{ 1164{
1165 struct isp116x *isp116x = hcd_to_isp116x(hcd); 1165 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1166 unsigned long flags; 1166 unsigned long flags;
@@ -1200,7 +1200,7 @@ static int isp116x_hub_suspend(struct usb_hcd *hcd)
1200 return ret; 1200 return ret;
1201} 1201}
1202 1202
1203static int isp116x_hub_resume(struct usb_hcd *hcd) 1203static int isp116x_bus_resume(struct usb_hcd *hcd)
1204{ 1204{
1205 struct isp116x *isp116x = hcd_to_isp116x(hcd); 1205 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1206 u32 val; 1206 u32 val;
@@ -1263,21 +1263,11 @@ static int isp116x_hub_resume(struct usb_hcd *hcd)
1263 return 0; 1263 return 0;
1264} 1264}
1265 1265
1266static void isp116x_rh_resume(void *_hcd)
1267{
1268 struct usb_hcd *hcd = _hcd;
1269
1270 usb_resume_device(hcd->self.root_hub);
1271}
1272 1266
1273#else 1267#else
1274 1268
1275#define isp116x_hub_suspend NULL 1269#define isp116x_bus_suspend NULL
1276#define isp116x_hub_resume NULL 1270#define isp116x_bus_resume NULL
1277
1278static void isp116x_rh_resume(void *_hcd)
1279{
1280}
1281 1271
1282#endif 1272#endif
1283 1273
@@ -1636,8 +1626,8 @@ static struct hc_driver isp116x_hc_driver = {
1636 1626
1637 .hub_status_data = isp116x_hub_status_data, 1627 .hub_status_data = isp116x_hub_status_data,
1638 .hub_control = isp116x_hub_control, 1628 .hub_control = isp116x_hub_control,
1639 .hub_suspend = isp116x_hub_suspend, 1629 .bus_suspend = isp116x_bus_suspend,
1640 .hub_resume = isp116x_hub_resume, 1630 .bus_resume = isp116x_bus_resume,
1641}; 1631};
1642 1632
1643/*----------------------------------------------------------------*/ 1633/*----------------------------------------------------------------*/
@@ -1732,7 +1722,6 @@ static int __init isp116x_probe(struct device *dev)
1732 isp116x->addr_reg = addr_reg; 1722 isp116x->addr_reg = addr_reg;
1733 spin_lock_init(&isp116x->lock); 1723 spin_lock_init(&isp116x->lock);
1734 INIT_LIST_HEAD(&isp116x->async); 1724 INIT_LIST_HEAD(&isp116x->async);
1735 INIT_WORK(&isp116x->rh_resume, isp116x_rh_resume, hcd);
1736 isp116x->board = dev->platform_data; 1725 isp116x->board = dev->platform_data;
1737 1726
1738 if (!isp116x->board) { 1727 if (!isp116x->board) {
@@ -1774,22 +1763,13 @@ static int __init isp116x_probe(struct device *dev)
1774/* 1763/*
1775 Suspend of platform device 1764 Suspend of platform device
1776*/ 1765*/
1777static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase) 1766static int isp116x_suspend(struct device *dev, pm_message_t state)
1778{ 1767{
1779 int ret = 0; 1768 int ret = 0;
1780 struct usb_hcd *hcd = dev_get_drvdata(dev);
1781 1769
1782 VDBG("%s: state %x, phase %x\n", __func__, state, phase); 1770 VDBG("%s: state %x\n", __func__, state);
1783 1771
1784 if (phase != SUSPEND_DISABLE && phase != SUSPEND_POWER_DOWN) 1772 dev->power.power_state = state;
1785 return 0;
1786
1787 ret = usb_suspend_device(hcd->self.root_hub, state);
1788 if (!ret) {
1789 dev->power.power_state = state;
1790 INFO("%s suspended\n", hcd_name);
1791 } else
1792 ERR("%s suspend failed\n", hcd_name);
1793 1773
1794 return ret; 1774 return ret;
1795} 1775}
@@ -1797,21 +1777,14 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase)
1797/* 1777/*
1798 Resume platform device 1778 Resume platform device
1799*/ 1779*/
1800static int isp116x_resume(struct device *dev, u32 phase) 1780static int isp116x_resume(struct device *dev)
1801{ 1781{
1802 int ret = 0; 1782 int ret = 0;
1803 struct usb_hcd *hcd = dev_get_drvdata(dev);
1804 1783
1805 VDBG("%s: state %x, phase %x\n", __func__, dev->power.power_state, 1784 VDBG("%s: state %x\n", __func__, dev->power.power_state);
1806 phase); 1785
1807 if (phase != RESUME_POWER_ON) 1786 dev->power.power_state = PMSG_ON;
1808 return 0;
1809 1787
1810 ret = usb_resume_device(hcd->self.root_hub);
1811 if (!ret) {
1812 dev->power.power_state = PMSG_ON;
1813 VDBG("%s resumed\n", (char *)hcd_name);
1814 }
1815 return ret; 1788 return ret;
1816} 1789}
1817 1790
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index 58873470dcf5..c6fec96785fe 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -253,7 +253,6 @@ static const int cc_to_error[16] = {
253 253
254struct isp116x { 254struct isp116x {
255 spinlock_t lock; 255 spinlock_t lock;
256 struct work_struct rh_resume;
257 256
258 void __iomem *addr_reg; 257 void __iomem *addr_reg;
259 void __iomem *data_reg; 258 void __iomem *data_reg;
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 3981bf15c8c7..a277e258eb6c 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -214,6 +214,11 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
214 */ 214 */
215 .hub_status_data = ohci_hub_status_data, 215 .hub_status_data = ohci_hub_status_data,
216 .hub_control = ohci_hub_control, 216 .hub_control = ohci_hub_control,
217#ifdef CONFIG_PM
218 .bus_suspend = ohci_bus_suspend,
219 .bus_resume = ohci_bus_resume,
220#endif
221 .start_port_reset = ohci_start_port_reset,
217}; 222};
218 223
219/*-------------------------------------------------------------------------*/ 224/*-------------------------------------------------------------------------*/
@@ -259,6 +264,7 @@ static int ohci_hcd_au1xxx_drv_resume(struct device *dev)
259 264
260static struct device_driver ohci_hcd_au1xxx_driver = { 265static struct device_driver ohci_hcd_au1xxx_driver = {
261 .name = "au1xxx-ohci", 266 .name = "au1xxx-ohci",
267 .owner = THIS_MODULE,
262 .bus = &platform_bus_type, 268 .bus = &platform_bus_type,
263 .probe = ohci_hcd_au1xxx_drv_probe, 269 .probe = ohci_hcd_au1xxx_drv_probe,
264 .remove = ohci_hcd_au1xxx_drv_remove, 270 .remove = ohci_hcd_au1xxx_drv_remove,
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 7924c74f958e..7bfffcbbd226 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -193,10 +193,6 @@ ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size)
193 193
194 maybe_print_eds (controller, "donehead", 194 maybe_print_eds (controller, "donehead",
195 ohci_readl (controller, &regs->donehead), next, size); 195 ohci_readl (controller, &regs->donehead), next, size);
196
197 /* broken fminterval means traffic won't flow! */
198 ohci_dbg (controller, "fminterval %08x\n",
199 ohci_readl (controller, &regs->fminterval));
200} 196}
201 197
202#define dbg_port_sw(hc,num,value,next,size) \ 198#define dbg_port_sw(hc,num,value,next,size) \
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 67c1aa5eb1c1..5c0c6c8a7a82 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -180,7 +180,7 @@ static int ohci_urb_enqueue (
180 struct usb_hcd *hcd, 180 struct usb_hcd *hcd,
181 struct usb_host_endpoint *ep, 181 struct usb_host_endpoint *ep,
182 struct urb *urb, 182 struct urb *urb,
183 unsigned mem_flags 183 gfp_t mem_flags
184) { 184) {
185 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 185 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
186 struct ed *ed; 186 struct ed *ed;
@@ -723,7 +723,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
723 ohci_vdbg (ohci, "resume detect\n"); 723 ohci_vdbg (ohci, "resume detect\n");
724 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus); 724 ohci_writel (ohci, OHCI_INTR_RD, &regs->intrstatus);
725 if (hcd->state != HC_STATE_QUIESCING) 725 if (hcd->state != HC_STATE_QUIESCING)
726 schedule_work(&ohci->rh_resume); 726 usb_hcd_resume_root_hub(hcd);
727 } 727 }
728 728
729 if (ints & OHCI_INTR_WDH) { 729 if (ints & OHCI_INTR_WDH) {
@@ -791,7 +791,7 @@ static void ohci_stop (struct usb_hcd *hcd)
791 791
792/* must not be called from interrupt context */ 792/* must not be called from interrupt context */
793 793
794#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) 794#ifdef CONFIG_PM
795 795
796static int ohci_restart (struct ohci_hcd *ohci) 796static int ohci_restart (struct ohci_hcd *ohci)
797{ 797{
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index ce7b28da7a15..e01e77bc324b 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -36,7 +36,7 @@
36 36
37/*-------------------------------------------------------------------------*/ 37/*-------------------------------------------------------------------------*/
38 38
39#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) 39#ifdef CONFIG_PM
40 40
41#define OHCI_SCHED_ENABLES \ 41#define OHCI_SCHED_ENABLES \
42 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE) 42 (OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_PLE|OHCI_CTRL_IE)
@@ -45,7 +45,7 @@ static void dl_done_list (struct ohci_hcd *, struct pt_regs *);
45static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *); 45static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *);
46static int ohci_restart (struct ohci_hcd *ohci); 46static int ohci_restart (struct ohci_hcd *ohci);
47 47
48static int ohci_hub_suspend (struct usb_hcd *hcd) 48static int ohci_bus_suspend (struct usb_hcd *hcd)
49{ 49{
50 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 50 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
51 int status = 0; 51 int status = 0;
@@ -73,7 +73,6 @@ static int ohci_hub_suspend (struct usb_hcd *hcd)
73 ohci_dbg (ohci, "suspend root hub\n"); 73 ohci_dbg (ohci, "suspend root hub\n");
74 74
75 /* First stop any processing */ 75 /* First stop any processing */
76 hcd->state = HC_STATE_QUIESCING;
77 if (ohci->hc_control & OHCI_SCHED_ENABLES) { 76 if (ohci->hc_control & OHCI_SCHED_ENABLES) {
78 int limit; 77 int limit;
79 78
@@ -108,7 +107,9 @@ static int ohci_hub_suspend (struct usb_hcd *hcd)
108 else 107 else
109 ohci->hc_control &= ~OHCI_CTRL_RWE; 108 ohci->hc_control &= ~OHCI_CTRL_RWE;
110 109
111 /* Suspend hub */ 110 /* Suspend hub ... this is the "global (to this bus) suspend" mode,
111 * which doesn't imply ports will first be individually suspended.
112 */
112 ohci->hc_control &= ~OHCI_CTRL_HCFS; 113 ohci->hc_control &= ~OHCI_CTRL_HCFS;
113 ohci->hc_control |= OHCI_USB_SUSPEND; 114 ohci->hc_control |= OHCI_USB_SUSPEND;
114 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 115 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
@@ -118,8 +119,9 @@ static int ohci_hub_suspend (struct usb_hcd *hcd)
118 ohci->next_statechange = jiffies + msecs_to_jiffies (5); 119 ohci->next_statechange = jiffies + msecs_to_jiffies (5);
119 120
120done: 121done:
122 /* external suspend vs self autosuspend ... same effect */
121 if (status == 0) 123 if (status == 0)
122 hcd->state = HC_STATE_SUSPENDED; 124 usb_hcd_suspend_root_hub(hcd);
123 spin_unlock_irqrestore (&ohci->lock, flags); 125 spin_unlock_irqrestore (&ohci->lock, flags);
124 return status; 126 return status;
125} 127}
@@ -133,7 +135,7 @@ static inline struct ed *find_head (struct ed *ed)
133} 135}
134 136
135/* caller has locked the root hub */ 137/* caller has locked the root hub */
136static int ohci_hub_resume (struct usb_hcd *hcd) 138static int ohci_bus_resume (struct usb_hcd *hcd)
137{ 139{
138 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 140 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
139 u32 temp, enables; 141 u32 temp, enables;
@@ -146,7 +148,7 @@ static int ohci_hub_resume (struct usb_hcd *hcd)
146 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); 148 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
147 149
148 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { 150 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
149 /* this can happen after suspend-to-disk */ 151 /* this can happen after resuming a swsusp snapshot */
150 if (hcd->state == HC_STATE_RESUMING) { 152 if (hcd->state == HC_STATE_RESUMING) {
151 ohci_dbg (ohci, "BIOS/SMM active, control %03x\n", 153 ohci_dbg (ohci, "BIOS/SMM active, control %03x\n",
152 ohci->hc_control); 154 ohci->hc_control);
@@ -169,11 +171,12 @@ static int ohci_hub_resume (struct usb_hcd *hcd)
169 ohci_info (ohci, "wakeup\n"); 171 ohci_info (ohci, "wakeup\n");
170 break; 172 break;
171 case OHCI_USB_OPER: 173 case OHCI_USB_OPER:
172 ohci_dbg (ohci, "already resumed\n"); 174 /* this can happen after resuming a swsusp snapshot */
173 status = 0; 175 ohci_dbg (ohci, "snapshot resume? reinit\n");
176 status = -EBUSY;
174 break; 177 break;
175 default: /* RESET, we lost power */ 178 default: /* RESET, we lost power */
176 ohci_dbg (ohci, "root hub hardware reset\n"); 179 ohci_dbg (ohci, "lost power\n");
177 status = -EBUSY; 180 status = -EBUSY;
178 } 181 }
179 spin_unlock_irq (&ohci->lock); 182 spin_unlock_irq (&ohci->lock);
@@ -198,8 +201,7 @@ static int ohci_hub_resume (struct usb_hcd *hcd)
198 } 201 }
199 202
200 /* Some controllers (lucent erratum) need extra-long delays */ 203 /* Some controllers (lucent erratum) need extra-long delays */
201 hcd->state = HC_STATE_RESUMING; 204 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1);
202 mdelay (20 /* usb 11.5.1.10 */ + 15);
203 205
204 temp = ohci_readl (ohci, &ohci->regs->control); 206 temp = ohci_readl (ohci, &ohci->regs->control);
205 temp &= OHCI_CTRL_HCFS; 207 temp &= OHCI_CTRL_HCFS;
@@ -273,28 +275,10 @@ static int ohci_hub_resume (struct usb_hcd *hcd)
273 (void) ohci_readl (ohci, &ohci->regs->control); 275 (void) ohci_readl (ohci, &ohci->regs->control);
274 } 276 }
275 277
276 hcd->state = HC_STATE_RUNNING;
277 return 0; 278 return 0;
278} 279}
279 280
280static void ohci_rh_resume (void *_hcd) 281#endif /* CONFIG_PM */
281{
282 struct usb_hcd *hcd = _hcd;
283
284 usb_lock_device (hcd->self.root_hub);
285 (void) ohci_hub_resume (hcd);
286 usb_unlock_device (hcd->self.root_hub);
287}
288
289#else
290
291static void ohci_rh_resume (void *_hcd)
292{
293 struct ohci_hcd *ohci = hcd_to_ohci (_hcd);
294 ohci_dbg(ohci, "rh_resume ??\n");
295}
296
297#endif /* CONFIG_USB_SUSPEND || CONFIG_PM */
298 282
299/*-------------------------------------------------------------------------*/ 283/*-------------------------------------------------------------------------*/
300 284
@@ -367,7 +351,6 @@ done:
367#ifdef CONFIG_PM 351#ifdef CONFIG_PM
368 /* save power by suspending idle root hubs; 352 /* save power by suspending idle root hubs;
369 * INTR_RD wakes us when there's work 353 * INTR_RD wakes us when there's work
370 * NOTE: if we can do this, we don't need a root hub timer!
371 */ 354 */
372 if (can_suspend 355 if (can_suspend
373 && !changed 356 && !changed
@@ -379,8 +362,7 @@ done:
379 && usb_trylock_device (hcd->self.root_hub) 362 && usb_trylock_device (hcd->self.root_hub)
380 ) { 363 ) {
381 ohci_vdbg (ohci, "autosuspend\n"); 364 ohci_vdbg (ohci, "autosuspend\n");
382 (void) ohci_hub_suspend (hcd); 365 (void) ohci_bus_suspend (hcd);
383 hcd->state = HC_STATE_RUNNING;
384 usb_unlock_device (hcd->self.root_hub); 366 usb_unlock_device (hcd->self.root_hub);
385 } 367 }
386#endif 368#endif
@@ -554,7 +536,7 @@ static int ohci_hub_control (
554 temp = RH_PS_POCI; 536 temp = RH_PS_POCI;
555 if ((ohci->hc_control & OHCI_CTRL_HCFS) 537 if ((ohci->hc_control & OHCI_CTRL_HCFS)
556 != OHCI_USB_OPER) 538 != OHCI_USB_OPER)
557 schedule_work (&ohci->rh_resume); 539 usb_hcd_resume_root_hub(hcd);
558 break; 540 break;
559 case USB_PORT_FEAT_C_SUSPEND: 541 case USB_PORT_FEAT_C_SUSPEND:
560 temp = RH_PS_PSSC; 542 temp = RH_PS_PSSC;
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 859aca7be753..238fa4ade615 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -193,6 +193,11 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
193 */ 193 */
194 .hub_status_data = ohci_hub_status_data, 194 .hub_status_data = ohci_hub_status_data,
195 .hub_control = ohci_hub_control, 195 .hub_control = ohci_hub_control,
196#ifdef CONFIG_PM
197 .bus_suspend = ohci_bus_suspend,
198 .bus_resume = ohci_bus_resume,
199#endif
200 .start_port_reset = ohci_start_port_reset,
196}; 201};
197 202
198/*-------------------------------------------------------------------------*/ 203/*-------------------------------------------------------------------------*/
@@ -239,6 +244,7 @@ static int ohci_hcd_lh7a404_drv_resume(struct device *dev)
239 244
240static struct device_driver ohci_hcd_lh7a404_driver = { 245static struct device_driver ohci_hcd_lh7a404_driver = {
241 .name = "lh7a404-ohci", 246 .name = "lh7a404-ohci",
247 .owner = THIS_MODULE,
242 .bus = &platform_bus_type, 248 .bus = &platform_bus_type,
243 .probe = ohci_hcd_lh7a404_drv_probe, 249 .probe = ohci_hcd_lh7a404_drv_probe,
244 .remove = ohci_hcd_lh7a404_drv_remove, 250 .remove = ohci_hcd_lh7a404_drv_remove,
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index fd3c4d3714bd..bfbe328a4788 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -28,7 +28,6 @@ static void ohci_hcd_init (struct ohci_hcd *ohci)
28 ohci->next_statechange = jiffies; 28 ohci->next_statechange = jiffies;
29 spin_lock_init (&ohci->lock); 29 spin_lock_init (&ohci->lock);
30 INIT_LIST_HEAD (&ohci->pending); 30 INIT_LIST_HEAD (&ohci->pending);
31 INIT_WORK (&ohci->rh_resume, ohci_rh_resume, ohci_to_hcd(ohci));
32 ohci->reboot_notifier.notifier_call = ohci_reboot; 31 ohci->reboot_notifier.notifier_call = ohci_reboot;
33} 32}
34 33
@@ -84,7 +83,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma)
84 83
85/* TDs ... */ 84/* TDs ... */
86static struct td * 85static struct td *
87td_alloc (struct ohci_hcd *hc, unsigned mem_flags) 86td_alloc (struct ohci_hcd *hc, gfp_t mem_flags)
88{ 87{
89 dma_addr_t dma; 88 dma_addr_t dma;
90 struct td *td; 89 struct td *td;
@@ -118,7 +117,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
118 117
119/* EDs ... */ 118/* EDs ... */
120static struct ed * 119static struct ed *
121ed_alloc (struct ohci_hcd *hc, unsigned mem_flags) 120ed_alloc (struct ohci_hcd *hc, gfp_t mem_flags)
122{ 121{
123 dma_addr_t dma; 122 dma_addr_t dma;
124 struct ed *ed; 123 struct ed *ed;
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index d8f3ba7ad52e..45efeed1fcc3 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -420,9 +420,9 @@ static const struct hc_driver ohci_omap_hc_driver = {
420 */ 420 */
421 .hub_status_data = ohci_hub_status_data, 421 .hub_status_data = ohci_hub_status_data,
422 .hub_control = ohci_hub_control, 422 .hub_control = ohci_hub_control,
423#ifdef CONFIG_USB_SUSPEND 423#ifdef CONFIG_PM
424 .hub_suspend = ohci_hub_suspend, 424 .bus_suspend = ohci_bus_suspend,
425 .hub_resume = ohci_hub_resume, 425 .bus_resume = ohci_bus_resume,
426#endif 426#endif
427 .start_port_reset = ohci_start_port_reset, 427 .start_port_reset = ohci_start_port_reset,
428}; 428};
@@ -455,50 +455,32 @@ static int ohci_hcd_omap_drv_remove(struct device *dev)
455 455
456#ifdef CONFIG_PM 456#ifdef CONFIG_PM
457 457
458static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level) 458static int ohci_omap_suspend(struct device *dev, pm_message_t message)
459{ 459{
460 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 460 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
461 int status = -EINVAL; 461
462 462 if (time_before(jiffies, ohci->next_statechange))
463 if (level != SUSPEND_POWER_DOWN) 463 msleep(5);
464 return 0; 464 ohci->next_statechange = jiffies;
465 465
466 down(&ohci_to_hcd(ohci)->self.root_hub->serialize); 466 omap_ohci_clock_power(0);
467 status = ohci_hub_suspend(ohci_to_hcd(ohci)); 467 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
468 if (status == 0) { 468 dev->power.power_state = PMSG_SUSPEND;
469 omap_ohci_clock_power(0); 469 return 0;
470 ohci_to_hcd(ohci)->self.root_hub->state =
471 USB_STATE_SUSPENDED;
472 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
473 dev->power.power_state = PMSG_SUSPEND;
474 }
475 up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
476 return status;
477} 470}
478 471
479static int ohci_omap_resume(struct device *dev, u32 level) 472static int ohci_omap_resume(struct device *dev)
480{ 473{
481 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 474 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
482 int status = 0;
483
484 if (level != RESUME_POWER_ON)
485 return 0;
486 475
487 if (time_before(jiffies, ohci->next_statechange)) 476 if (time_before(jiffies, ohci->next_statechange))
488 msleep(5); 477 msleep(5);
489 ohci->next_statechange = jiffies; 478 ohci->next_statechange = jiffies;
479
490 omap_ohci_clock_power(1); 480 omap_ohci_clock_power(1);
491#ifdef CONFIG_USB_SUSPEND 481 dev->power.power_state = PMSG_ON;
492 /* get extra cleanup even if remote wakeup isn't in use */ 482 usb_hcd_resume_root_hub(dev_get_drvdata(dev));
493 status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub); 483 return 0;
494#else
495 down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
496 status = ohci_hub_resume(ohci_to_hcd(ohci));
497 up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
498#endif
499 if (status == 0)
500 dev->power.power_state = PMSG_ON;
501 return status;
502} 484}
503 485
504#endif 486#endif
@@ -510,6 +492,7 @@ static int ohci_omap_resume(struct device *dev, u32 level)
510 */ 492 */
511static struct device_driver ohci_hcd_omap_driver = { 493static struct device_driver ohci_hcd_omap_driver = {
512 .name = "ohci", 494 .name = "ohci",
495 .owner = THIS_MODULE,
513 .bus = &platform_bus_type, 496 .bus = &platform_bus_type,
514 .probe = ohci_hcd_omap_drv_probe, 497 .probe = ohci_hcd_omap_drv_probe,
515 .remove = ohci_hcd_omap_drv_remove, 498 .remove = ohci_hcd_omap_drv_remove,
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index eede6be098d2..bf1d5ab4aa3a 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -112,23 +112,13 @@ ohci_pci_start (struct usb_hcd *hcd)
112 112
113static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 113static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
114{ 114{
115 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 115 /* root hub was already suspended */
116
117 /* suspend root hub, hoping it keeps power during suspend */
118 if (time_before (jiffies, ohci->next_statechange))
119 msleep (100);
120
121#ifdef CONFIG_USB_SUSPEND
122 (void) usb_suspend_device (hcd->self.root_hub, message);
123#else
124 usb_lock_device (hcd->self.root_hub);
125 (void) ohci_hub_suspend (hcd);
126 usb_unlock_device (hcd->self.root_hub);
127#endif
128 116
129 /* let things settle down a bit */ 117 /* FIXME these PMAC things get called in the wrong places. ASIC
130 msleep (100); 118 * clocks should be turned off AFTER entering D3, and on BEFORE
131 119 * trying to enter D0. Evidently the PCI layer doesn't currently
120 * provide the right sort of platform hooks for this ...
121 */
132#ifdef CONFIG_PPC_PMAC 122#ifdef CONFIG_PPC_PMAC
133 if (_machine == _MACH_Pmac) { 123 if (_machine == _MACH_Pmac) {
134 struct device_node *of_node; 124 struct device_node *of_node;
@@ -145,9 +135,6 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
145 135
146static int ohci_pci_resume (struct usb_hcd *hcd) 136static int ohci_pci_resume (struct usb_hcd *hcd)
147{ 137{
148 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
149 int retval = 0;
150
151#ifdef CONFIG_PPC_PMAC 138#ifdef CONFIG_PPC_PMAC
152 if (_machine == _MACH_Pmac) { 139 if (_machine == _MACH_Pmac) {
153 struct device_node *of_node; 140 struct device_node *of_node;
@@ -159,19 +146,8 @@ static int ohci_pci_resume (struct usb_hcd *hcd)
159 } 146 }
160#endif /* CONFIG_PPC_PMAC */ 147#endif /* CONFIG_PPC_PMAC */
161 148
162 /* resume root hub */ 149 usb_hcd_resume_root_hub(hcd);
163 if (time_before (jiffies, ohci->next_statechange)) 150 return 0;
164 msleep (100);
165#ifdef CONFIG_USB_SUSPEND
166 /* get extra cleanup even if remote wakeup isn't in use */
167 retval = usb_resume_device (hcd->self.root_hub);
168#else
169 usb_lock_device (hcd->self.root_hub);
170 retval = ohci_hub_resume (hcd);
171 usb_unlock_device (hcd->self.root_hub);
172#endif
173
174 return retval;
175} 151}
176 152
177#endif /* CONFIG_PM */ 153#endif /* CONFIG_PM */
@@ -218,9 +194,9 @@ static const struct hc_driver ohci_pci_hc_driver = {
218 */ 194 */
219 .hub_status_data = ohci_hub_status_data, 195 .hub_status_data = ohci_hub_status_data,
220 .hub_control = ohci_hub_control, 196 .hub_control = ohci_hub_control,
221#ifdef CONFIG_USB_SUSPEND 197#ifdef CONFIG_PM
222 .hub_suspend = ohci_hub_suspend, 198 .bus_suspend = ohci_bus_suspend,
223 .hub_resume = ohci_hub_resume, 199 .bus_resume = ohci_bus_resume,
224#endif 200#endif
225 .start_port_reset = ohci_start_port_reset, 201 .start_port_reset = ohci_start_port_reset,
226}; 202};
@@ -240,6 +216,7 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
240static struct pci_driver ohci_pci_driver = { 216static struct pci_driver ohci_pci_driver = {
241 .name = (char *) hcd_name, 217 .name = (char *) hcd_name,
242 .id_table = pci_ids, 218 .id_table = pci_ids,
219 .owner = THIS_MODULE,
243 220
244 .probe = usb_hcd_pci_probe, 221 .probe = usb_hcd_pci_probe,
245 .remove = usb_hcd_pci_remove, 222 .remove = usb_hcd_pci_remove,
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index 251533363028..4832e57ae579 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -163,9 +163,9 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
163 */ 163 */
164 .hub_status_data = ohci_hub_status_data, 164 .hub_status_data = ohci_hub_status_data,
165 .hub_control = ohci_hub_control, 165 .hub_control = ohci_hub_control,
166#ifdef CONFIG_USB_SUSPEND 166#ifdef CONFIG_PM
167 .hub_suspend = ohci_hub_suspend, 167 .bus_suspend = ohci_bus_suspend,
168 .hub_resume = ohci_hub_resume, 168 .bus_resume = ohci_bus_resume,
169#endif 169#endif
170 .start_port_reset = ohci_start_port_reset, 170 .start_port_reset = ohci_start_port_reset,
171}; 171};
@@ -193,10 +193,11 @@ static int ohci_hcd_ppc_soc_drv_remove(struct device *dev)
193 193
194static struct device_driver ohci_hcd_ppc_soc_driver = { 194static struct device_driver ohci_hcd_ppc_soc_driver = {
195 .name = "ppc-soc-ohci", 195 .name = "ppc-soc-ohci",
196 .owner = THIS_MODULE,
196 .bus = &platform_bus_type, 197 .bus = &platform_bus_type,
197 .probe = ohci_hcd_ppc_soc_drv_probe, 198 .probe = ohci_hcd_ppc_soc_drv_probe,
198 .remove = ohci_hcd_ppc_soc_drv_remove, 199 .remove = ohci_hcd_ppc_soc_drv_remove,
199#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM) 200#ifdef CONFIG_PM
200 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ 201 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
201 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ 202 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
202#endif 203#endif
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 2fdb262d4726..d287dcccd415 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -278,10 +278,11 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
278 */ 278 */
279 .hub_status_data = ohci_hub_status_data, 279 .hub_status_data = ohci_hub_status_data,
280 .hub_control = ohci_hub_control, 280 .hub_control = ohci_hub_control,
281#ifdef CONFIG_USB_SUSPEND 281#ifdef CONFIG_PM
282 .hub_suspend = ohci_hub_suspend, 282 .bus_suspend = ohci_bus_suspend,
283 .hub_resume = ohci_hub_resume, 283 .bus_resume = ohci_bus_resume,
284#endif 284#endif
285 .start_port_reset = ohci_start_port_reset,
285}; 286};
286 287
287/*-------------------------------------------------------------------------*/ 288/*-------------------------------------------------------------------------*/
@@ -309,7 +310,7 @@ static int ohci_hcd_pxa27x_drv_remove(struct device *dev)
309 return 0; 310 return 0;
310} 311}
311 312
312static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u32 level) 313static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state)
313{ 314{
314// struct platform_device *pdev = to_platform_device(dev); 315// struct platform_device *pdev = to_platform_device(dev);
315// struct usb_hcd *hcd = dev_get_drvdata(dev); 316// struct usb_hcd *hcd = dev_get_drvdata(dev);
@@ -318,7 +319,7 @@ static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state, u
318 return 0; 319 return 0;
319} 320}
320 321
321static int ohci_hcd_pxa27x_drv_resume(struct device *dev, u32 level) 322static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
322{ 323{
323// struct platform_device *pdev = to_platform_device(dev); 324// struct platform_device *pdev = to_platform_device(dev);
324// struct usb_hcd *hcd = dev_get_drvdata(dev); 325// struct usb_hcd *hcd = dev_get_drvdata(dev);
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index da7d5478f74d..fab420a2ce71 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -448,11 +448,11 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
448 */ 448 */
449 .hub_status_data = ohci_s3c2410_hub_status_data, 449 .hub_status_data = ohci_s3c2410_hub_status_data,
450 .hub_control = ohci_s3c2410_hub_control, 450 .hub_control = ohci_s3c2410_hub_control,
451 451#ifdef CONFIG_PM
452#if defined(CONFIG_USB_SUSPEND) && 0 452 .bus_suspend = ohci_bus_suspend,
453 .hub_suspend = ohci_hub_suspend, 453 .bus_resume = ohci_bus_resume,
454 .hub_resume = ohci_hub_resume,
455#endif 454#endif
455 .start_port_reset = ohci_start_port_reset,
456}; 456};
457 457
458/* device driver */ 458/* device driver */
@@ -474,6 +474,7 @@ static int ohci_hcd_s3c2410_drv_remove(struct device *dev)
474 474
475static struct device_driver ohci_hcd_s3c2410_driver = { 475static struct device_driver ohci_hcd_s3c2410_driver = {
476 .name = "s3c2410-ohci", 476 .name = "s3c2410-ohci",
477 .owner = THIS_MODULE,
477 .bus = &platform_bus_type, 478 .bus = &platform_bus_type,
478 .probe = ohci_hcd_s3c2410_drv_probe, 479 .probe = ohci_hcd_s3c2410_drv_probe,
479 .remove = ohci_hcd_s3c2410_drv_remove, 480 .remove = ohci_hcd_s3c2410_drv_remove,
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 814d2be4ee7b..fb3221ebbb29 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -235,10 +235,11 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
235 */ 235 */
236 .hub_status_data = ohci_hub_status_data, 236 .hub_status_data = ohci_hub_status_data,
237 .hub_control = ohci_hub_control, 237 .hub_control = ohci_hub_control,
238#ifdef CONFIG_USB_SUSPEND 238#ifdef CONFIG_PM
239 .hub_suspend = ohci_hub_suspend, 239 .bus_suspend = ohci_bus_suspend,
240 .hub_resume = ohci_hub_resume, 240 .bus_resume = ohci_bus_resume,
241#endif 241#endif
242 .start_port_reset = ohci_start_port_reset,
242}; 243};
243 244
244/*-------------------------------------------------------------------------*/ 245/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 8a9b9d9209e9..caacf14371f5 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -389,7 +389,6 @@ struct ohci_hcd {
389 unsigned long next_statechange; /* suspend/resume */ 389 unsigned long next_statechange; /* suspend/resume */
390 u32 fminterval; /* saved register */ 390 u32 fminterval; /* saved register */
391 391
392 struct work_struct rh_resume;
393 struct notifier_block reboot_notifier; 392 struct notifier_block reboot_notifier;
394 393
395 unsigned long flags; /* for HC bugs */ 394 unsigned long flags; /* for HC bugs */
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
new file mode 100644
index 000000000000..b7fd3f644e1e
--- /dev/null
+++ b/drivers/usb/host/pci-quirks.c
@@ -0,0 +1,296 @@
1/*
2 * This file contains code to reset and initialize USB host controllers.
3 * Some of it includes work-arounds for PCI hardware and BIOS quirks.
4 * It may need to run early during booting -- before USB would normally
5 * initialize -- to ensure that Linux doesn't use any legacy modes.
6 *
7 * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
8 * (and others)
9 */
10
11#include <linux/config.h>
12#ifdef CONFIG_USB_DEBUG
13#define DEBUG
14#else
15#undef DEBUG
16#endif
17
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/pci.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/acpi.h>
24
25
26#define UHCI_USBLEGSUP 0xc0 /* legacy support */
27#define UHCI_USBCMD 0 /* command register */
28#define UHCI_USBINTR 4 /* interrupt register */
29#define UHCI_USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
30#define UHCI_USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
31#define UHCI_USBCMD_RUN 0x0001 /* RUN/STOP bit */
32#define UHCI_USBCMD_HCRESET 0x0002 /* Host Controller reset */
33#define UHCI_USBCMD_EGSM 0x0008 /* Global Suspend Mode */
34#define UHCI_USBCMD_CONFIGURE 0x0040 /* Config Flag */
35#define UHCI_USBINTR_RESUME 0x0002 /* Resume interrupt enable */
36
37#define OHCI_CONTROL 0x04
38#define OHCI_CMDSTATUS 0x08
39#define OHCI_INTRSTATUS 0x0c
40#define OHCI_INTRENABLE 0x10
41#define OHCI_INTRDISABLE 0x14
42#define OHCI_OCR (1 << 3) /* ownership change request */
43#define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
44#define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
45#define OHCI_INTR_OC (1 << 30) /* ownership change */
46
47#define EHCI_HCC_PARAMS 0x08 /* extended capabilities */
48#define EHCI_USBCMD 0 /* command register */
49#define EHCI_USBCMD_RUN (1 << 0) /* RUN/STOP bit */
50#define EHCI_USBSTS 4 /* status register */
51#define EHCI_USBSTS_HALTED (1 << 12) /* HCHalted bit */
52#define EHCI_USBINTR 8 /* interrupt register */
53#define EHCI_USBLEGSUP 0 /* legacy support register */
54#define EHCI_USBLEGSUP_BIOS (1 << 16) /* BIOS semaphore */
55#define EHCI_USBLEGSUP_OS (1 << 24) /* OS semaphore */
56#define EHCI_USBLEGCTLSTS 4 /* legacy control/status */
57#define EHCI_USBLEGCTLSTS_SOOE (1 << 13) /* SMI on ownership change */
58
59
60/*
61 * Make sure the controller is completely inactive, unable to
62 * generate interrupts or do DMA.
63 */
64void uhci_reset_hc(struct pci_dev *pdev, unsigned long base)
65{
66 /* Turn off PIRQ enable and SMI enable. (This also turns off the
67 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
68 */
69 pci_write_config_word(pdev, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC);
70
71 /* Reset the HC - this will force us to get a
72 * new notification of any already connected
73 * ports due to the virtual disconnect that it
74 * implies.
75 */
76 outw(UHCI_USBCMD_HCRESET, base + UHCI_USBCMD);
77 mb();
78 udelay(5);
79 if (inw(base + UHCI_USBCMD) & UHCI_USBCMD_HCRESET)
80 dev_warn(&pdev->dev, "HCRESET not completed yet!\n");
81
82 /* Just to be safe, disable interrupt requests and
83 * make sure the controller is stopped.
84 */
85 outw(0, base + UHCI_USBINTR);
86 outw(0, base + UHCI_USBCMD);
87}
88EXPORT_SYMBOL_GPL(uhci_reset_hc);
89
90/*
91 * Initialize a controller that was newly discovered or has just been
92 * resumed. In either case we can't be sure of its previous state.
93 *
94 * Returns: 1 if the controller was reset, 0 otherwise.
95 */
96int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
97{
98 u16 legsup;
99 unsigned int cmd, intr;
100
101 /*
102 * When restarting a suspended controller, we expect all the
103 * settings to be the same as we left them:
104 *
105 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
106 * Controller is stopped and configured with EGSM set;
107 * No interrupts enabled except possibly Resume Detect.
108 *
109 * If any of these conditions are violated we do a complete reset.
110 */
111 pci_read_config_word(pdev, UHCI_USBLEGSUP, &legsup);
112 if (legsup & ~(UHCI_USBLEGSUP_RO | UHCI_USBLEGSUP_RWC)) {
113 dev_dbg(&pdev->dev, "%s: legsup = 0x%04x\n",
114 __FUNCTION__, legsup);
115 goto reset_needed;
116 }
117
118 cmd = inw(base + UHCI_USBCMD);
119 if ((cmd & UHCI_USBCMD_RUN) || !(cmd & UHCI_USBCMD_CONFIGURE) ||
120 !(cmd & UHCI_USBCMD_EGSM)) {
121 dev_dbg(&pdev->dev, "%s: cmd = 0x%04x\n",
122 __FUNCTION__, cmd);
123 goto reset_needed;
124 }
125
126 intr = inw(base + UHCI_USBINTR);
127 if (intr & (~UHCI_USBINTR_RESUME)) {
128 dev_dbg(&pdev->dev, "%s: intr = 0x%04x\n",
129 __FUNCTION__, intr);
130 goto reset_needed;
131 }
132 return 0;
133
134reset_needed:
135 dev_dbg(&pdev->dev, "Performing full reset\n");
136 uhci_reset_hc(pdev, base);
137 return 1;
138}
139EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
140
141static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev)
142{
143 unsigned long base = 0;
144 int i;
145
146 for (i = 0; i < PCI_ROM_RESOURCE; i++)
147 if ((pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
148 base = pci_resource_start(pdev, i);
149 break;
150 }
151
152 if (base)
153 uhci_check_and_reset_hc(pdev, base);
154}
155
156static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
157{
158 void __iomem *base;
159 int wait_time;
160 u32 control;
161
162 base = ioremap_nocache(pci_resource_start(pdev, 0),
163 pci_resource_len(pdev, 0));
164 if (base == NULL) return;
165
166/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
167#ifndef __hppa__
168 control = readl(base + OHCI_CONTROL);
169 if (control & OHCI_CTRL_IR) {
170 wait_time = 500; /* arbitrary; 5 seconds */
171 writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
172 writel(OHCI_OCR, base + OHCI_CMDSTATUS);
173 while (wait_time > 0 &&
174 readl(base + OHCI_CONTROL) & OHCI_CTRL_IR) {
175 wait_time -= 10;
176 msleep(10);
177 }
178 if (wait_time <= 0)
179 printk(KERN_WARNING "%s %s: early BIOS handoff "
180 "failed (BIOS bug ?)\n",
181 pdev->dev.bus_id, "OHCI");
182
183 /* reset controller, preserving RWC */
184 writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
185 }
186#endif
187
188 /*
189 * disable interrupts
190 */
191 writel(~(u32)0, base + OHCI_INTRDISABLE);
192 writel(~(u32)0, base + OHCI_INTRSTATUS);
193
194 iounmap(base);
195}
196
197static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
198{
199 int wait_time, delta;
200 void __iomem *base, *op_reg_base;
201 u32 hcc_params, val, temp;
202 u8 cap_length;
203
204 base = ioremap_nocache(pci_resource_start(pdev, 0),
205 pci_resource_len(pdev, 0));
206 if (base == NULL) return;
207
208 cap_length = readb(base);
209 op_reg_base = base + cap_length;
210 hcc_params = readl(base + EHCI_HCC_PARAMS);
211 hcc_params = (hcc_params >> 8) & 0xff;
212 if (hcc_params) {
213 pci_read_config_dword(pdev,
214 hcc_params + EHCI_USBLEGSUP,
215 &val);
216 if (((val & 0xff) == 1) && (val & EHCI_USBLEGSUP_BIOS)) {
217 /*
218 * Ok, BIOS is in smm mode, try to hand off...
219 */
220 pci_read_config_dword(pdev,
221 hcc_params + EHCI_USBLEGCTLSTS,
222 &temp);
223 pci_write_config_dword(pdev,
224 hcc_params + EHCI_USBLEGCTLSTS,
225 temp | EHCI_USBLEGCTLSTS_SOOE);
226 val |= EHCI_USBLEGSUP_OS;
227 pci_write_config_dword(pdev,
228 hcc_params + EHCI_USBLEGSUP,
229 val);
230
231 wait_time = 500;
232 do {
233 msleep(10);
234 wait_time -= 10;
235 pci_read_config_dword(pdev,
236 hcc_params + EHCI_USBLEGSUP,
237 &val);
238 } while (wait_time && (val & EHCI_USBLEGSUP_BIOS));
239 if (!wait_time) {
240 /*
241 * well, possibly buggy BIOS...
242 */
243 printk(KERN_WARNING "%s %s: early BIOS handoff "
244 "failed (BIOS bug ?)\n",
245 pdev->dev.bus_id, "EHCI");
246 pci_write_config_dword(pdev,
247 hcc_params + EHCI_USBLEGSUP,
248 EHCI_USBLEGSUP_OS);
249 pci_write_config_dword(pdev,
250 hcc_params + EHCI_USBLEGCTLSTS,
251 0);
252 }
253 }
254 }
255
256 /*
257 * halt EHCI & disable its interrupts in any case
258 */
259 val = readl(op_reg_base + EHCI_USBSTS);
260 if ((val & EHCI_USBSTS_HALTED) == 0) {
261 val = readl(op_reg_base + EHCI_USBCMD);
262 val &= ~EHCI_USBCMD_RUN;
263 writel(val, op_reg_base + EHCI_USBCMD);
264
265 wait_time = 2000;
266 delta = 100;
267 do {
268 writel(0x3f, op_reg_base + EHCI_USBSTS);
269 udelay(delta);
270 wait_time -= delta;
271 val = readl(op_reg_base + EHCI_USBSTS);
272 if ((val == ~(u32)0) || (val & EHCI_USBSTS_HALTED)) {
273 break;
274 }
275 } while (wait_time > 0);
276 }
277 writel(0, op_reg_base + EHCI_USBINTR);
278 writel(0x3f, op_reg_base + EHCI_USBSTS);
279
280 iounmap(base);
281
282 return;
283}
284
285
286
287static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev)
288{
289 if (pdev->class == PCI_CLASS_SERIAL_USB_UHCI)
290 quirk_usb_handoff_uhci(pdev);
291 else if (pdev->class == PCI_CLASS_SERIAL_USB_OHCI)
292 quirk_usb_handoff_ohci(pdev);
293 else if (pdev->class == PCI_CLASS_SERIAL_USB_EHCI)
294 quirk_usb_disable_ehci(pdev);
295}
296DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_usb_early_handoff);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index d42a15d10a46..40169d9cf2b1 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -818,7 +818,7 @@ static int sl811h_urb_enqueue(
818 struct usb_hcd *hcd, 818 struct usb_hcd *hcd,
819 struct usb_host_endpoint *hep, 819 struct usb_host_endpoint *hep,
820 struct urb *urb, 820 struct urb *urb,
821 unsigned mem_flags 821 gfp_t mem_flags
822) { 822) {
823 struct sl811 *sl811 = hcd_to_sl811(hcd); 823 struct sl811 *sl811 = hcd_to_sl811(hcd);
824 struct usb_device *udev = urb->dev; 824 struct usb_device *udev = urb->dev;
@@ -1363,7 +1363,7 @@ error:
1363#ifdef CONFIG_PM 1363#ifdef CONFIG_PM
1364 1364
1365static int 1365static int
1366sl811h_hub_suspend(struct usb_hcd *hcd) 1366sl811h_bus_suspend(struct usb_hcd *hcd)
1367{ 1367{
1368 // SOFs off 1368 // SOFs off
1369 DBG("%s\n", __FUNCTION__); 1369 DBG("%s\n", __FUNCTION__);
@@ -1371,7 +1371,7 @@ sl811h_hub_suspend(struct usb_hcd *hcd)
1371} 1371}
1372 1372
1373static int 1373static int
1374sl811h_hub_resume(struct usb_hcd *hcd) 1374sl811h_bus_resume(struct usb_hcd *hcd)
1375{ 1375{
1376 // SOFs on 1376 // SOFs on
1377 DBG("%s\n", __FUNCTION__); 1377 DBG("%s\n", __FUNCTION__);
@@ -1380,8 +1380,8 @@ sl811h_hub_resume(struct usb_hcd *hcd)
1380 1380
1381#else 1381#else
1382 1382
1383#define sl811h_hub_suspend NULL 1383#define sl811h_bus_suspend NULL
1384#define sl811h_hub_resume NULL 1384#define sl811h_bus_resume NULL
1385 1385
1386#endif 1386#endif
1387 1387
@@ -1623,8 +1623,8 @@ static struct hc_driver sl811h_hc_driver = {
1623 */ 1623 */
1624 .hub_status_data = sl811h_hub_status_data, 1624 .hub_status_data = sl811h_hub_status_data,
1625 .hub_control = sl811h_hub_control, 1625 .hub_control = sl811h_hub_control,
1626 .hub_suspend = sl811h_hub_suspend, 1626 .bus_suspend = sl811h_bus_suspend,
1627 .hub_resume = sl811h_hub_resume, 1627 .bus_resume = sl811h_bus_resume,
1628}; 1628};
1629 1629
1630/*-------------------------------------------------------------------------*/ 1630/*-------------------------------------------------------------------------*/
@@ -1784,17 +1784,14 @@ sl811h_probe(struct device *dev)
1784 */ 1784 */
1785 1785
1786static int 1786static int
1787sl811h_suspend(struct device *dev, pm_message_t state, u32 phase) 1787sl811h_suspend(struct device *dev, pm_message_t state)
1788{ 1788{
1789 struct usb_hcd *hcd = dev_get_drvdata(dev); 1789 struct usb_hcd *hcd = dev_get_drvdata(dev);
1790 struct sl811 *sl811 = hcd_to_sl811(hcd); 1790 struct sl811 *sl811 = hcd_to_sl811(hcd);
1791 int retval = 0; 1791 int retval = 0;
1792 1792
1793 if (phase != SUSPEND_POWER_DOWN)
1794 return retval;
1795
1796 if (state.event == PM_EVENT_FREEZE) 1793 if (state.event == PM_EVENT_FREEZE)
1797 retval = sl811h_hub_suspend(hcd); 1794 retval = sl811h_bus_suspend(hcd);
1798 else if (state.event == PM_EVENT_SUSPEND) 1795 else if (state.event == PM_EVENT_SUSPEND)
1799 port_power(sl811, 0); 1796 port_power(sl811, 0);
1800 if (retval == 0) 1797 if (retval == 0)
@@ -1803,14 +1800,11 @@ sl811h_suspend(struct device *dev, pm_message_t state, u32 phase)
1803} 1800}
1804 1801
1805static int 1802static int
1806sl811h_resume(struct device *dev, u32 phase) 1803sl811h_resume(struct device *dev)
1807{ 1804{
1808 struct usb_hcd *hcd = dev_get_drvdata(dev); 1805 struct usb_hcd *hcd = dev_get_drvdata(dev);
1809 struct sl811 *sl811 = hcd_to_sl811(hcd); 1806 struct sl811 *sl811 = hcd_to_sl811(hcd);
1810 1807
1811 if (phase != RESUME_POWER_ON)
1812 return 0;
1813
1814 /* with no "check to see if VBUS is still powered" board hook, 1808 /* with no "check to see if VBUS is still powered" board hook,
1815 * let's assume it'd only be powered to enable remote wakeup. 1809 * let's assume it'd only be powered to enable remote wakeup.
1816 */ 1810 */
@@ -1822,7 +1816,7 @@ sl811h_resume(struct device *dev, u32 phase)
1822 } 1816 }
1823 1817
1824 dev->power.power_state = PMSG_ON; 1818 dev->power.power_state = PMSG_ON;
1825 return sl811h_hub_resume(hcd); 1819 return sl811h_bus_resume(hcd);
1826} 1820}
1827 1821
1828#else 1822#else
@@ -1837,6 +1831,7 @@ sl811h_resume(struct device *dev, u32 phase)
1837struct device_driver sl811h_driver = { 1831struct device_driver sl811h_driver = {
1838 .name = (char *) hcd_name, 1832 .name = (char *) hcd_name,
1839 .bus = &platform_bus_type, 1833 .bus = &platform_bus_type,
1834 .owner = THIS_MODULE,
1840 1835
1841 .probe = sl811h_probe, 1836 .probe = sl811h_probe,
1842 .remove = __devexit_p(sl811h_remove), 1837 .remove = __devexit_p(sl811h_remove),
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 4538a98b6f9d..151154df37fa 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -348,7 +348,6 @@ static int uhci_show_urbp(struct uhci_hcd *uhci, struct urb_priv *urbp, char *bu
348 348
349 if (urbp->urb->status != -EINPROGRESS) 349 if (urbp->urb->status != -EINPROGRESS)
350 out += sprintf(out, "Status=%d ", urbp->urb->status); 350 out += sprintf(out, "Status=%d ", urbp->urb->status);
351 //out += sprintf(out, "Inserttime=%lx ",urbp->inserttime);
352 //out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime); 351 //out += sprintf(out, "FSBRtime=%lx ",urbp->fsbrtime);
353 352
354 count = 0; 353 count = 0;
@@ -446,11 +445,11 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
446 out += sprintf(out, "Frame List\n"); 445 out += sprintf(out, "Frame List\n");
447 for (i = 0; i < UHCI_NUMFRAMES; ++i) { 446 for (i = 0; i < UHCI_NUMFRAMES; ++i) {
448 int shown = 0; 447 int shown = 0;
449 td = uhci->fl->frame_cpu[i]; 448 td = uhci->frame_cpu[i];
450 if (!td) 449 if (!td)
451 continue; 450 continue;
452 451
453 if (td->dma_handle != (dma_addr_t)uhci->fl->frame[i]) { 452 if (td->dma_handle != (dma_addr_t)uhci->frame[i]) {
454 show_frame_num(); 453 show_frame_num();
455 out += sprintf(out, " frame list does not match td->dma_handle!\n"); 454 out += sprintf(out, " frame list does not match td->dma_handle!\n");
456 } 455 }
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 0c024898cbea..15e0a511069b 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -101,37 +101,16 @@ static void uhci_get_current_frame_number(struct uhci_hcd *uhci);
101#include "uhci-q.c" 101#include "uhci-q.c"
102#include "uhci-hub.c" 102#include "uhci-hub.c"
103 103
104extern void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
105extern int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
106
104/* 107/*
105 * Make sure the controller is completely inactive, unable to 108 * Finish up a host controller reset and update the recorded state.
106 * generate interrupts or do DMA.
107 */ 109 */
108static void reset_hc(struct uhci_hcd *uhci) 110static void finish_reset(struct uhci_hcd *uhci)
109{ 111{
110 int port; 112 int port;
111 113
112 /* Turn off PIRQ enable and SMI enable. (This also turns off the
113 * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
114 */
115 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP,
116 USBLEGSUP_RWC);
117
118 /* Reset the HC - this will force us to get a
119 * new notification of any already connected
120 * ports due to the virtual disconnect that it
121 * implies.
122 */
123 outw(USBCMD_HCRESET, uhci->io_addr + USBCMD);
124 mb();
125 udelay(5);
126 if (inw(uhci->io_addr + USBCMD) & USBCMD_HCRESET)
127 dev_warn(uhci_dev(uhci), "HCRESET not completed yet!\n");
128
129 /* Just to be safe, disable interrupt requests and
130 * make sure the controller is stopped.
131 */
132 outw(0, uhci->io_addr + USBINTR);
133 outw(0, uhci->io_addr + USBCMD);
134
135 /* HCRESET doesn't affect the Suspend, Reset, and Resume Detect 114 /* HCRESET doesn't affect the Suspend, Reset, and Resume Detect
136 * bits in the port status and control registers. 115 * bits in the port status and control registers.
137 * We have to clear them by hand. 116 * We have to clear them by hand.
@@ -153,7 +132,8 @@ static void reset_hc(struct uhci_hcd *uhci)
153 */ 132 */
154static void hc_died(struct uhci_hcd *uhci) 133static void hc_died(struct uhci_hcd *uhci)
155{ 134{
156 reset_hc(uhci); 135 uhci_reset_hc(to_pci_dev(uhci_dev(uhci)), uhci->io_addr);
136 finish_reset(uhci);
157 uhci->hc_inaccessible = 1; 137 uhci->hc_inaccessible = 1;
158} 138}
159 139
@@ -163,44 +143,8 @@ static void hc_died(struct uhci_hcd *uhci)
163 */ 143 */
164static void check_and_reset_hc(struct uhci_hcd *uhci) 144static void check_and_reset_hc(struct uhci_hcd *uhci)
165{ 145{
166 u16 legsup; 146 if (uhci_check_and_reset_hc(to_pci_dev(uhci_dev(uhci)), uhci->io_addr))
167 unsigned int cmd, intr; 147 finish_reset(uhci);
168
169 /*
170 * When restarting a suspended controller, we expect all the
171 * settings to be the same as we left them:
172 *
173 * PIRQ and SMI disabled, no R/W bits set in USBLEGSUP;
174 * Controller is stopped and configured with EGSM set;
175 * No interrupts enabled except possibly Resume Detect.
176 *
177 * If any of these conditions are violated we do a complete reset.
178 */
179 pci_read_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, &legsup);
180 if (legsup & ~(USBLEGSUP_RO | USBLEGSUP_RWC)) {
181 dev_dbg(uhci_dev(uhci), "%s: legsup = 0x%04x\n",
182 __FUNCTION__, legsup);
183 goto reset_needed;
184 }
185
186 cmd = inw(uhci->io_addr + USBCMD);
187 if ((cmd & USBCMD_RS) || !(cmd & USBCMD_CF) || !(cmd & USBCMD_EGSM)) {
188 dev_dbg(uhci_dev(uhci), "%s: cmd = 0x%04x\n",
189 __FUNCTION__, cmd);
190 goto reset_needed;
191 }
192
193 intr = inw(uhci->io_addr + USBINTR);
194 if (intr & (~USBINTR_RESUME)) {
195 dev_dbg(uhci_dev(uhci), "%s: intr = 0x%04x\n",
196 __FUNCTION__, intr);
197 goto reset_needed;
198 }
199 return;
200
201reset_needed:
202 dev_dbg(uhci_dev(uhci), "Performing full reset\n");
203 reset_hc(uhci);
204} 148}
205 149
206/* 150/*
@@ -212,13 +156,13 @@ static void configure_hc(struct uhci_hcd *uhci)
212 outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); 156 outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF);
213 157
214 /* Store the frame list base address */ 158 /* Store the frame list base address */
215 outl(uhci->fl->dma_handle, uhci->io_addr + USBFLBASEADD); 159 outl(uhci->frame_dma_handle, uhci->io_addr + USBFLBASEADD);
216 160
217 /* Set the current frame number */ 161 /* Set the current frame number */
218 outw(uhci->frame_number, uhci->io_addr + USBFRNUM); 162 outw(uhci->frame_number, uhci->io_addr + USBFRNUM);
219 163
220 /* Mark controller as running before we enable interrupts */ 164 /* Mark controller as not halted before we enable interrupts */
221 uhci_to_hcd(uhci)->state = HC_STATE_RUNNING; 165 uhci_to_hcd(uhci)->state = HC_STATE_SUSPENDED;
222 mb(); 166 mb();
223 167
224 /* Enable PIRQ */ 168 /* Enable PIRQ */
@@ -319,6 +263,7 @@ __acquires(uhci->lock)
319 263
320static void start_rh(struct uhci_hcd *uhci) 264static void start_rh(struct uhci_hcd *uhci)
321{ 265{
266 uhci_to_hcd(uhci)->state = HC_STATE_RUNNING;
322 uhci->is_stopped = 0; 267 uhci->is_stopped = 0;
323 smp_wmb(); 268 smp_wmb();
324 269
@@ -437,36 +382,21 @@ static void release_uhci(struct uhci_hcd *uhci)
437 int i; 382 int i;
438 383
439 for (i = 0; i < UHCI_NUM_SKELQH; i++) 384 for (i = 0; i < UHCI_NUM_SKELQH; i++)
440 if (uhci->skelqh[i]) { 385 uhci_free_qh(uhci, uhci->skelqh[i]);
441 uhci_free_qh(uhci, uhci->skelqh[i]);
442 uhci->skelqh[i] = NULL;
443 }
444 386
445 if (uhci->term_td) { 387 uhci_free_td(uhci, uhci->term_td);
446 uhci_free_td(uhci, uhci->term_td);
447 uhci->term_td = NULL;
448 }
449 388
450 if (uhci->qh_pool) { 389 dma_pool_destroy(uhci->qh_pool);
451 dma_pool_destroy(uhci->qh_pool);
452 uhci->qh_pool = NULL;
453 }
454 390
455 if (uhci->td_pool) { 391 dma_pool_destroy(uhci->td_pool);
456 dma_pool_destroy(uhci->td_pool);
457 uhci->td_pool = NULL;
458 }
459 392
460 if (uhci->fl) { 393 kfree(uhci->frame_cpu);
461 dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl),
462 uhci->fl, uhci->fl->dma_handle);
463 uhci->fl = NULL;
464 }
465 394
466 if (uhci->dentry) { 395 dma_free_coherent(uhci_dev(uhci),
467 debugfs_remove(uhci->dentry); 396 UHCI_NUMFRAMES * sizeof(*uhci->frame),
468 uhci->dentry = NULL; 397 uhci->frame, uhci->frame_dma_handle);
469 } 398
399 debugfs_remove(uhci->dentry);
470} 400}
471 401
472static int uhci_reset(struct usb_hcd *hcd) 402static int uhci_reset(struct usb_hcd *hcd)
@@ -545,7 +475,6 @@ static int uhci_start(struct usb_hcd *hcd)
545 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 475 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
546 int retval = -EBUSY; 476 int retval = -EBUSY;
547 int i; 477 int i;
548 dma_addr_t dma_handle;
549 struct dentry *dentry; 478 struct dentry *dentry;
550 479
551 hcd->uses_new_polling = 1; 480 hcd->uses_new_polling = 1;
@@ -579,17 +508,23 @@ static int uhci_start(struct usb_hcd *hcd)
579 508
580 init_waitqueue_head(&uhci->waitqh); 509 init_waitqueue_head(&uhci->waitqh);
581 510
582 uhci->fl = dma_alloc_coherent(uhci_dev(uhci), sizeof(*uhci->fl), 511 uhci->frame = dma_alloc_coherent(uhci_dev(uhci),
583 &dma_handle, 0); 512 UHCI_NUMFRAMES * sizeof(*uhci->frame),
584 if (!uhci->fl) { 513 &uhci->frame_dma_handle, 0);
514 if (!uhci->frame) {
585 dev_err(uhci_dev(uhci), "unable to allocate " 515 dev_err(uhci_dev(uhci), "unable to allocate "
586 "consistent memory for frame list\n"); 516 "consistent memory for frame list\n");
587 goto err_alloc_fl; 517 goto err_alloc_frame;
588 } 518 }
519 memset(uhci->frame, 0, UHCI_NUMFRAMES * sizeof(*uhci->frame));
589 520
590 memset((void *)uhci->fl, 0, sizeof(*uhci->fl)); 521 uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu),
591 522 GFP_KERNEL);
592 uhci->fl->dma_handle = dma_handle; 523 if (!uhci->frame_cpu) {
524 dev_err(uhci_dev(uhci), "unable to allocate "
525 "memory for frame pointers\n");
526 goto err_alloc_frame_cpu;
527 }
593 528
594 uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci), 529 uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci),
595 sizeof(struct uhci_td), 16, 0); 530 sizeof(struct uhci_td), 16, 0);
@@ -672,7 +607,7 @@ static int uhci_start(struct usb_hcd *hcd)
672 irq = 7; 607 irq = 7;
673 608
674 /* Only place we don't use the frame list routines */ 609 /* Only place we don't use the frame list routines */
675 uhci->fl->frame[i] = UHCI_PTR_QH | 610 uhci->frame[i] = UHCI_PTR_QH |
676 cpu_to_le32(uhci->skelqh[irq]->dma_handle); 611 cpu_to_le32(uhci->skelqh[irq]->dma_handle);
677 } 612 }
678 613
@@ -690,31 +625,29 @@ static int uhci_start(struct usb_hcd *hcd)
690 * error exits: 625 * error exits:
691 */ 626 */
692err_alloc_skelqh: 627err_alloc_skelqh:
693 for (i = 0; i < UHCI_NUM_SKELQH; i++) 628 for (i = 0; i < UHCI_NUM_SKELQH; i++) {
694 if (uhci->skelqh[i]) { 629 if (uhci->skelqh[i])
695 uhci_free_qh(uhci, uhci->skelqh[i]); 630 uhci_free_qh(uhci, uhci->skelqh[i]);
696 uhci->skelqh[i] = NULL; 631 }
697 }
698 632
699 uhci_free_td(uhci, uhci->term_td); 633 uhci_free_td(uhci, uhci->term_td);
700 uhci->term_td = NULL;
701 634
702err_alloc_term_td: 635err_alloc_term_td:
703 dma_pool_destroy(uhci->qh_pool); 636 dma_pool_destroy(uhci->qh_pool);
704 uhci->qh_pool = NULL;
705 637
706err_create_qh_pool: 638err_create_qh_pool:
707 dma_pool_destroy(uhci->td_pool); 639 dma_pool_destroy(uhci->td_pool);
708 uhci->td_pool = NULL;
709 640
710err_create_td_pool: 641err_create_td_pool:
711 dma_free_coherent(uhci_dev(uhci), sizeof(*uhci->fl), 642 kfree(uhci->frame_cpu);
712 uhci->fl, uhci->fl->dma_handle); 643
713 uhci->fl = NULL; 644err_alloc_frame_cpu:
645 dma_free_coherent(uhci_dev(uhci),
646 UHCI_NUMFRAMES * sizeof(*uhci->frame),
647 uhci->frame, uhci->frame_dma_handle);
714 648
715err_alloc_fl: 649err_alloc_frame:
716 debugfs_remove(uhci->dentry); 650 debugfs_remove(uhci->dentry);
717 uhci->dentry = NULL;
718 651
719err_create_debug_entry: 652err_create_debug_entry:
720 return retval; 653 return retval;
@@ -726,7 +659,7 @@ static void uhci_stop(struct usb_hcd *hcd)
726 659
727 spin_lock_irq(&uhci->lock); 660 spin_lock_irq(&uhci->lock);
728 if (!uhci->hc_inaccessible) 661 if (!uhci->hc_inaccessible)
729 reset_hc(uhci); 662 hc_died(uhci);
730 uhci_scan_schedule(uhci, NULL); 663 uhci_scan_schedule(uhci, NULL);
731 spin_unlock_irq(&uhci->lock); 664 spin_unlock_irq(&uhci->lock);
732 665
@@ -774,14 +707,8 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
774 if (uhci->hc_inaccessible) /* Dead or already suspended */ 707 if (uhci->hc_inaccessible) /* Dead or already suspended */
775 goto done; 708 goto done;
776 709
777#ifndef CONFIG_USB_SUSPEND
778 /* Otherwise this would never happen */
779 suspend_rh(uhci, UHCI_RH_SUSPENDED);
780#endif
781
782 if (uhci->rh_state > UHCI_RH_SUSPENDED) { 710 if (uhci->rh_state > UHCI_RH_SUSPENDED) {
783 dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n"); 711 dev_warn(uhci_dev(uhci), "Root hub isn't suspended!\n");
784 hcd->state = HC_STATE_RUNNING;
785 rc = -EBUSY; 712 rc = -EBUSY;
786 goto done; 713 goto done;
787 }; 714 };
@@ -820,10 +747,6 @@ static int uhci_resume(struct usb_hcd *hcd)
820 check_and_reset_hc(uhci); 747 check_and_reset_hc(uhci);
821 configure_hc(uhci); 748 configure_hc(uhci);
822 749
823#ifndef CONFIG_USB_SUSPEND
824 /* Otherwise this would never happen */
825 wakeup_rh(uhci);
826#endif
827 if (uhci->rh_state == UHCI_RH_RESET) 750 if (uhci->rh_state == UHCI_RH_RESET)
828 suspend_rh(uhci, UHCI_RH_SUSPENDED); 751 suspend_rh(uhci, UHCI_RH_SUSPENDED);
829 752
@@ -881,8 +804,8 @@ static const struct hc_driver uhci_driver = {
881#ifdef CONFIG_PM 804#ifdef CONFIG_PM
882 .suspend = uhci_suspend, 805 .suspend = uhci_suspend,
883 .resume = uhci_resume, 806 .resume = uhci_resume,
884 .hub_suspend = uhci_rh_suspend, 807 .bus_suspend = uhci_rh_suspend,
885 .hub_resume = uhci_rh_resume, 808 .bus_resume = uhci_rh_resume,
886#endif 809#endif
887 .stop = uhci_stop, 810 .stop = uhci_stop,
888 811
@@ -908,6 +831,7 @@ MODULE_DEVICE_TABLE(pci, uhci_pci_ids);
908static struct pci_driver uhci_pci_driver = { 831static struct pci_driver uhci_pci_driver = {
909 .name = (char *)hcd_name, 832 .name = (char *)hcd_name,
910 .id_table = uhci_pci_ids, 833 .id_table = uhci_pci_ids,
834 .owner = THIS_MODULE,
911 835
912 .probe = usb_hcd_pci_probe, 836 .probe = usb_hcd_pci_probe,
913 .remove = usb_hcd_pci_remove, 837 .remove = usb_hcd_pci_remove,
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 282f40b75881..e576db57a926 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -7,6 +7,7 @@
7#define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT) 7#define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)
8#define PIPE_DEVEP_MASK 0x0007ff00 8#define PIPE_DEVEP_MASK 0x0007ff00
9 9
10
10/* 11/*
11 * Universal Host Controller Interface data structures and defines 12 * Universal Host Controller Interface data structures and defines
12 */ 13 */
@@ -82,15 +83,10 @@
82#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */ 83#define UHCI_MAX_SOF_NUMBER 2047 /* in an SOF packet */
83#define CAN_SCHEDULE_FRAMES 1000 /* how far future frames can be scheduled */ 84#define CAN_SCHEDULE_FRAMES 1000 /* how far future frames can be scheduled */
84 85
85struct uhci_frame_list {
86 __le32 frame[UHCI_NUMFRAMES];
87
88 void *frame_cpu[UHCI_NUMFRAMES];
89
90 dma_addr_t dma_handle;
91};
92 86
93struct urb_priv; 87/*
88 * Queue Headers
89 */
94 90
95/* 91/*
96 * One role of a QH is to hold a queue of TDs for some endpoint. Each QH is 92 * One role of a QH is to hold a queue of TDs for some endpoint. Each QH is
@@ -116,13 +112,13 @@ struct uhci_qh {
116 112
117 struct urb_priv *urbp; 113 struct urb_priv *urbp;
118 114
119 struct list_head list; /* P: uhci->frame_list_lock */ 115 struct list_head list;
120 struct list_head remove_list; /* P: uhci->remove_list_lock */ 116 struct list_head remove_list;
121} __attribute__((aligned(16))); 117} __attribute__((aligned(16)));
122 118
123/* 119/*
124 * We need a special accessor for the element pointer because it is 120 * We need a special accessor for the element pointer because it is
125 * subject to asynchronous updates by the controller 121 * subject to asynchronous updates by the controller.
126 */ 122 */
127static __le32 inline qh_element(struct uhci_qh *qh) { 123static __le32 inline qh_element(struct uhci_qh *qh) {
128 __le32 element = qh->element; 124 __le32 element = qh->element;
@@ -131,6 +127,11 @@ static __le32 inline qh_element(struct uhci_qh *qh) {
131 return element; 127 return element;
132} 128}
133 129
130
131/*
132 * Transfer Descriptors
133 */
134
134/* 135/*
135 * for TD <status>: 136 * for TD <status>:
136 */ 137 */
@@ -183,17 +184,10 @@ static __le32 inline qh_element(struct uhci_qh *qh) {
183 * 184 *
184 * That's silly, the hardware doesn't care. The hardware only cares that 185 * That's silly, the hardware doesn't care. The hardware only cares that
185 * the hardware words are 16-byte aligned, and we can have any amount of 186 * the hardware words are 16-byte aligned, and we can have any amount of
186 * sw space after the TD entry as far as I can tell. 187 * sw space after the TD entry.
187 *
188 * But let's just go with the documentation, at least for 32-bit machines.
189 * On 64-bit machines we probably want to take advantage of the fact that
190 * hw doesn't really care about the size of the sw-only area.
191 *
192 * Alas, not anymore, we have more than 4 words for software, woops.
193 * Everything still works tho, surprise! -jerdfelt
194 * 188 *
195 * td->link points to either another TD (not necessarily for the same urb or 189 * td->link points to either another TD (not necessarily for the same urb or
196 * even the same endpoint), or nothing (PTR_TERM), or a QH (for queued urbs) 190 * even the same endpoint), or nothing (PTR_TERM), or a QH (for queued urbs).
197 */ 191 */
198struct uhci_td { 192struct uhci_td {
199 /* Hardware fields */ 193 /* Hardware fields */
@@ -205,18 +199,16 @@ struct uhci_td {
205 /* Software fields */ 199 /* Software fields */
206 dma_addr_t dma_handle; 200 dma_addr_t dma_handle;
207 201
208 struct urb *urb; 202 struct list_head list;
209 203 struct list_head remove_list;
210 struct list_head list; /* P: urb->lock */
211 struct list_head remove_list; /* P: uhci->td_remove_list_lock */
212 204
213 int frame; /* for iso: what frame? */ 205 int frame; /* for iso: what frame? */
214 struct list_head fl_list; /* P: uhci->frame_list_lock */ 206 struct list_head fl_list;
215} __attribute__((aligned(16))); 207} __attribute__((aligned(16)));
216 208
217/* 209/*
218 * We need a special accessor for the control/status word because it is 210 * We need a special accessor for the control/status word because it is
219 * subject to asynchronous updates by the controller 211 * subject to asynchronous updates by the controller.
220 */ 212 */
221static u32 inline td_status(struct uhci_td *td) { 213static u32 inline td_status(struct uhci_td *td) {
222 __le32 status = td->status; 214 __le32 status = td->status;
@@ -227,6 +219,10 @@ static u32 inline td_status(struct uhci_td *td) {
227 219
228 220
229/* 221/*
222 * Skeleton Queue Headers
223 */
224
225/*
230 * The UHCI driver places Interrupt, Control and Bulk into QH's both 226 * The UHCI driver places Interrupt, Control and Bulk into QH's both
231 * to group together TD's for one transfer, and also to faciliate queuing 227 * to group together TD's for one transfer, and also to faciliate queuing
232 * of URB's. To make it easy to insert entries into the schedule, we have 228 * of URB's. To make it easy to insert entries into the schedule, we have
@@ -256,15 +252,15 @@ static u32 inline td_status(struct uhci_td *td) {
256 * 252 *
257 * The terminating QH is used for 2 reasons: 253 * The terminating QH is used for 2 reasons:
258 * - To place a terminating TD which is used to workaround a PIIX bug 254 * - To place a terminating TD which is used to workaround a PIIX bug
259 * (see Intel errata for explanation) 255 * (see Intel errata for explanation), and
260 * - To loop back to the full-speed control queue for full-speed bandwidth 256 * - To loop back to the full-speed control queue for full-speed bandwidth
261 * reclamation 257 * reclamation.
262 * 258 *
263 * Isochronous transfers are stored before the start of the skeleton 259 * Isochronous transfers are stored before the start of the skeleton
264 * schedule and don't use QH's. While the UHCI spec doesn't forbid the 260 * schedule and don't use QH's. While the UHCI spec doesn't forbid the
265 * use of QH's for Isochronous, it doesn't use them either. Since we don't 261 * use of QH's for Isochronous, it doesn't use them either. And the spec
266 * need to use them either, we follow the spec diagrams in hope that it'll 262 * says that queues never advance on an error completion status, which
267 * be more compatible with future UHCI implementations. 263 * makes them totally unsuitable for Isochronous transfers.
268 */ 264 */
269 265
270#define UHCI_NUM_SKELQH 12 266#define UHCI_NUM_SKELQH 12
@@ -314,8 +310,13 @@ static inline int __interval_to_skel(int interval)
314 return 0; /* int128 for 128-255 ms (Max.) */ 310 return 0; /* int128 for 128-255 ms (Max.) */
315} 311}
316 312
313
314/*
315 * The UHCI controller and root hub
316 */
317
317/* 318/*
318 * States for the root hub. 319 * States for the root hub:
319 * 320 *
320 * To prevent "bouncing" in the presence of electrical noise, 321 * To prevent "bouncing" in the presence of electrical noise,
321 * when there are no devices attached we delay for 1 second in the 322 * when there are no devices attached we delay for 1 second in the
@@ -326,7 +327,7 @@ static inline int __interval_to_skel(int interval)
326 */ 327 */
327enum uhci_rh_state { 328enum uhci_rh_state {
328 /* In the following states the HC must be halted. 329 /* In the following states the HC must be halted.
329 * These two must come first */ 330 * These two must come first. */
330 UHCI_RH_RESET, 331 UHCI_RH_RESET,
331 UHCI_RH_SUSPENDED, 332 UHCI_RH_SUSPENDED,
332 333
@@ -338,13 +339,13 @@ enum uhci_rh_state {
338 UHCI_RH_SUSPENDING, 339 UHCI_RH_SUSPENDING,
339 340
340 /* In the following states it's an error if the HC is halted. 341 /* In the following states it's an error if the HC is halted.
341 * These two must come last */ 342 * These two must come last. */
342 UHCI_RH_RUNNING, /* The normal state */ 343 UHCI_RH_RUNNING, /* The normal state */
343 UHCI_RH_RUNNING_NODEVS, /* Running with no devices attached */ 344 UHCI_RH_RUNNING_NODEVS, /* Running with no devices attached */
344}; 345};
345 346
346/* 347/*
347 * This describes the full uhci information. 348 * The full UHCI controller information:
348 */ 349 */
349struct uhci_hcd { 350struct uhci_hcd {
350 351
@@ -361,7 +362,11 @@ struct uhci_hcd {
361 struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */ 362 struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */
362 363
363 spinlock_t lock; 364 spinlock_t lock;
364 struct uhci_frame_list *fl; /* P: uhci->lock */ 365
366 dma_addr_t frame_dma_handle; /* Hardware frame list */
367 __le32 *frame;
368 void **frame_cpu; /* CPU's frame list */
369
365 int fsbr; /* Full-speed bandwidth reclamation */ 370 int fsbr; /* Full-speed bandwidth reclamation */
366 unsigned long fsbrtimeout; /* FSBR delay */ 371 unsigned long fsbrtimeout; /* FSBR delay */
367 372
@@ -385,22 +390,22 @@ struct uhci_hcd {
385 unsigned long ports_timeout; /* Time to stop signalling */ 390 unsigned long ports_timeout; /* Time to stop signalling */
386 391
387 /* Main list of URB's currently controlled by this HC */ 392 /* Main list of URB's currently controlled by this HC */
388 struct list_head urb_list; /* P: uhci->lock */ 393 struct list_head urb_list;
389 394
390 /* List of QH's that are done, but waiting to be unlinked (race) */ 395 /* List of QH's that are done, but waiting to be unlinked (race) */
391 struct list_head qh_remove_list; /* P: uhci->lock */ 396 struct list_head qh_remove_list;
392 unsigned int qh_remove_age; /* Age in frames */ 397 unsigned int qh_remove_age; /* Age in frames */
393 398
394 /* List of TD's that are done, but waiting to be freed (race) */ 399 /* List of TD's that are done, but waiting to be freed (race) */
395 struct list_head td_remove_list; /* P: uhci->lock */ 400 struct list_head td_remove_list;
396 unsigned int td_remove_age; /* Age in frames */ 401 unsigned int td_remove_age; /* Age in frames */
397 402
398 /* List of asynchronously unlinked URB's */ 403 /* List of asynchronously unlinked URB's */
399 struct list_head urb_remove_list; /* P: uhci->lock */ 404 struct list_head urb_remove_list;
400 unsigned int urb_remove_age; /* Age in frames */ 405 unsigned int urb_remove_age; /* Age in frames */
401 406
402 /* List of URB's awaiting completion callback */ 407 /* List of URB's awaiting completion callback */
403 struct list_head complete_list; /* P: uhci->lock */ 408 struct list_head complete_list;
404 409
405 int rh_numports; /* Number of root-hub ports */ 410 int rh_numports; /* Number of root-hub ports */
406 411
@@ -419,13 +424,17 @@ static inline struct usb_hcd *uhci_to_hcd(struct uhci_hcd *uhci)
419 424
420#define uhci_dev(u) (uhci_to_hcd(u)->self.controller) 425#define uhci_dev(u) (uhci_to_hcd(u)->self.controller)
421 426
427
428/*
429 * Private per-URB data
430 */
422struct urb_priv { 431struct urb_priv {
423 struct list_head urb_list; 432 struct list_head urb_list;
424 433
425 struct urb *urb; 434 struct urb *urb;
426 435
427 struct uhci_qh *qh; /* QH for this URB */ 436 struct uhci_qh *qh; /* QH for this URB */
428 struct list_head td_list; /* P: urb->lock */ 437 struct list_head td_list;
429 438
430 unsigned fsbr : 1; /* URB turned on FSBR */ 439 unsigned fsbr : 1; /* URB turned on FSBR */
431 unsigned fsbr_timeout : 1; /* URB timed out on FSBR */ 440 unsigned fsbr_timeout : 1; /* URB timed out on FSBR */
@@ -434,12 +443,12 @@ struct urb_priv {
434 /* a control transfer, retrigger */ 443 /* a control transfer, retrigger */
435 /* the status phase */ 444 /* the status phase */
436 445
437 unsigned long inserttime; /* In jiffies */
438 unsigned long fsbrtime; /* In jiffies */ 446 unsigned long fsbrtime; /* In jiffies */
439 447
440 struct list_head queue_list; /* P: uhci->frame_list_lock */ 448 struct list_head queue_list;
441}; 449};
442 450
451
443/* 452/*
444 * Locking in uhci.c 453 * Locking in uhci.c
445 * 454 *
@@ -459,6 +468,5 @@ struct urb_priv {
459 468
460#define PCI_VENDOR_ID_GENESYS 0x17a0 469#define PCI_VENDOR_ID_GENESYS 0x17a0
461#define PCI_DEVICE_ID_GL880S_UHCI 0x8083 470#define PCI_DEVICE_ID_GL880S_UHCI 0x8083
462#define PCI_DEVICE_ID_GL880S_EHCI 0x8084
463 471
464#endif 472#endif
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index ea0d168a8c67..7e46887d9e12 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -89,10 +89,10 @@ static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td,
89 td->frame = framenum; 89 td->frame = framenum;
90 90
91 /* Is there a TD already mapped there? */ 91 /* Is there a TD already mapped there? */
92 if (uhci->fl->frame_cpu[framenum]) { 92 if (uhci->frame_cpu[framenum]) {
93 struct uhci_td *ftd, *ltd; 93 struct uhci_td *ftd, *ltd;
94 94
95 ftd = uhci->fl->frame_cpu[framenum]; 95 ftd = uhci->frame_cpu[framenum];
96 ltd = list_entry(ftd->fl_list.prev, struct uhci_td, fl_list); 96 ltd = list_entry(ftd->fl_list.prev, struct uhci_td, fl_list);
97 97
98 list_add_tail(&td->fl_list, &ftd->fl_list); 98 list_add_tail(&td->fl_list, &ftd->fl_list);
@@ -101,29 +101,32 @@ static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td,
101 wmb(); 101 wmb();
102 ltd->link = cpu_to_le32(td->dma_handle); 102 ltd->link = cpu_to_le32(td->dma_handle);
103 } else { 103 } else {
104 td->link = uhci->fl->frame[framenum]; 104 td->link = uhci->frame[framenum];
105 wmb(); 105 wmb();
106 uhci->fl->frame[framenum] = cpu_to_le32(td->dma_handle); 106 uhci->frame[framenum] = cpu_to_le32(td->dma_handle);
107 uhci->fl->frame_cpu[framenum] = td; 107 uhci->frame_cpu[framenum] = td;
108 } 108 }
109} 109}
110 110
111static void uhci_remove_td(struct uhci_hcd *uhci, struct uhci_td *td) 111static inline void uhci_remove_td_frame_list(struct uhci_hcd *uhci,
112 struct uhci_td *td)
112{ 113{
113 /* If it's not inserted, don't remove it */ 114 /* If it's not inserted, don't remove it */
114 if (td->frame == -1 && list_empty(&td->fl_list)) 115 if (td->frame == -1) {
116 WARN_ON(!list_empty(&td->fl_list));
115 return; 117 return;
118 }
116 119
117 if (td->frame != -1 && uhci->fl->frame_cpu[td->frame] == td) { 120 if (uhci->frame_cpu[td->frame] == td) {
118 if (list_empty(&td->fl_list)) { 121 if (list_empty(&td->fl_list)) {
119 uhci->fl->frame[td->frame] = td->link; 122 uhci->frame[td->frame] = td->link;
120 uhci->fl->frame_cpu[td->frame] = NULL; 123 uhci->frame_cpu[td->frame] = NULL;
121 } else { 124 } else {
122 struct uhci_td *ntd; 125 struct uhci_td *ntd;
123 126
124 ntd = list_entry(td->fl_list.next, struct uhci_td, fl_list); 127 ntd = list_entry(td->fl_list.next, struct uhci_td, fl_list);
125 uhci->fl->frame[td->frame] = cpu_to_le32(ntd->dma_handle); 128 uhci->frame[td->frame] = cpu_to_le32(ntd->dma_handle);
126 uhci->fl->frame_cpu[td->frame] = ntd; 129 uhci->frame_cpu[td->frame] = ntd;
127 } 130 }
128 } else { 131 } else {
129 struct uhci_td *ptd; 132 struct uhci_td *ptd;
@@ -132,13 +135,20 @@ static void uhci_remove_td(struct uhci_hcd *uhci, struct uhci_td *td)
132 ptd->link = td->link; 135 ptd->link = td->link;
133 } 136 }
134 137
135 wmb();
136 td->link = UHCI_PTR_TERM;
137
138 list_del_init(&td->fl_list); 138 list_del_init(&td->fl_list);
139 td->frame = -1; 139 td->frame = -1;
140} 140}
141 141
142static void unlink_isochronous_tds(struct uhci_hcd *uhci, struct urb *urb)
143{
144 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;
145 struct uhci_td *td;
146
147 list_for_each_entry(td, &urbp->td_list, list)
148 uhci_remove_td_frame_list(uhci, td);
149 wmb();
150}
151
142/* 152/*
143 * Inserts a td list into qh. 153 * Inserts a td list into qh.
144 */ 154 */
@@ -443,7 +453,6 @@ static struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci, struct urb *u
443 453
444 memset((void *)urbp, 0, sizeof(*urbp)); 454 memset((void *)urbp, 0, sizeof(*urbp));
445 455
446 urbp->inserttime = jiffies;
447 urbp->fsbrtime = jiffies; 456 urbp->fsbrtime = jiffies;
448 urbp->urb = urb; 457 urbp->urb = urb;
449 458
@@ -462,8 +471,6 @@ static void uhci_add_td_to_urb(struct urb *urb, struct uhci_td *td)
462{ 471{
463 struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv; 472 struct urb_priv *urbp = (struct urb_priv *)urb->hcpriv;
464 473
465 td->urb = urb;
466
467 list_add_tail(&td->list, &urbp->td_list); 474 list_add_tail(&td->list, &urbp->td_list);
468} 475}
469 476
@@ -473,8 +480,6 @@ static void uhci_remove_td_from_urb(struct uhci_td *td)
473 return; 480 return;
474 481
475 list_del_init(&td->list); 482 list_del_init(&td->list);
476
477 td->urb = NULL;
478} 483}
479 484
480static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb) 485static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb)
@@ -503,7 +508,6 @@ static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb)
503 508
504 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { 509 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
505 uhci_remove_td_from_urb(td); 510 uhci_remove_td_from_urb(td);
506 uhci_remove_td(uhci, td);
507 list_add(&td->remove_list, &uhci->td_remove_list); 511 list_add(&td->remove_list, &uhci->td_remove_list);
508 } 512 }
509 513
@@ -1073,6 +1077,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1073 struct uhci_td *td; 1077 struct uhci_td *td;
1074 int i, ret, frame; 1078 int i, ret, frame;
1075 int status, destination; 1079 int status, destination;
1080 struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv;
1076 1081
1077 status = TD_CTRL_ACTIVE | TD_CTRL_IOS; 1082 status = TD_CTRL_ACTIVE | TD_CTRL_IOS;
1078 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); 1083 destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe);
@@ -1081,11 +1086,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1081 if (ret) 1086 if (ret)
1082 return ret; 1087 return ret;
1083 1088
1084 frame = urb->start_frame; 1089 for (i = 0; i < urb->number_of_packets; i++) {
1085 for (i = 0; i < urb->number_of_packets; i++, frame += urb->interval) {
1086 if (!urb->iso_frame_desc[i].length)
1087 continue;
1088
1089 td = uhci_alloc_td(uhci); 1090 td = uhci_alloc_td(uhci);
1090 if (!td) 1091 if (!td)
1091 return -ENOMEM; 1092 return -ENOMEM;
@@ -1096,8 +1097,12 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1096 1097
1097 if (i + 1 >= urb->number_of_packets) 1098 if (i + 1 >= urb->number_of_packets)
1098 td->status |= cpu_to_le32(TD_CTRL_IOC); 1099 td->status |= cpu_to_le32(TD_CTRL_IOC);
1100 }
1099 1101
1102 frame = urb->start_frame;
1103 list_for_each_entry(td, &urbp->td_list, list) {
1100 uhci_insert_td_frame_list(uhci, td, frame); 1104 uhci_insert_td_frame_list(uhci, td, frame);
1105 frame += urb->interval;
1101 } 1106 }
1102 1107
1103 return -EINPROGRESS; 1108 return -EINPROGRESS;
@@ -1110,7 +1115,7 @@ static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1110 int status; 1115 int status;
1111 int i, ret = 0; 1116 int i, ret = 0;
1112 1117
1113 urb->actual_length = 0; 1118 urb->actual_length = urb->error_count = 0;
1114 1119
1115 i = 0; 1120 i = 0;
1116 list_for_each_entry(td, &urbp->td_list, list) { 1121 list_for_each_entry(td, &urbp->td_list, list) {
@@ -1134,6 +1139,7 @@ static int uhci_result_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1134 1139
1135 i++; 1140 i++;
1136 } 1141 }
1142 unlink_isochronous_tds(uhci, urb);
1137 1143
1138 return ret; 1144 return ret;
1139} 1145}
@@ -1164,7 +1170,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb)
1164 1170
1165static int uhci_urb_enqueue(struct usb_hcd *hcd, 1171static int uhci_urb_enqueue(struct usb_hcd *hcd,
1166 struct usb_host_endpoint *ep, 1172 struct usb_host_endpoint *ep,
1167 struct urb *urb, unsigned mem_flags) 1173 struct urb *urb, gfp_t mem_flags)
1168{ 1174{
1169 int ret; 1175 int ret;
1170 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 1176 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
@@ -1366,6 +1372,8 @@ static int uhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
1366 goto done; 1372 goto done;
1367 list_del_init(&urbp->urb_list); 1373 list_del_init(&urbp->urb_list);
1368 1374
1375 if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
1376 unlink_isochronous_tds(uhci, urb);
1369 uhci_unlink_generic(uhci, urb); 1377 uhci_unlink_generic(uhci, urb);
1370 1378
1371 uhci_get_current_frame_number(uhci); 1379 uhci_get_current_frame_number(uhci);
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index a330a4b50e16..1d973bcf56aa 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -425,9 +425,8 @@ static void mdc800_usb_download_notify (struct urb *urb, struct pt_regs *res)
425static struct usb_driver mdc800_usb_driver; 425static struct usb_driver mdc800_usb_driver;
426static struct file_operations mdc800_device_ops; 426static struct file_operations mdc800_device_ops;
427static struct usb_class_driver mdc800_class = { 427static struct usb_class_driver mdc800_class = {
428 .name = "usb/mdc800%d", 428 .name = "mdc800%d",
429 .fops = &mdc800_device_ops, 429 .fops = &mdc800_device_ops,
430 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
431 .minor_base = MDC800_DEVICE_MINOR_BASE, 430 .minor_base = MDC800_DEVICE_MINOR_BASE,
432}; 431};
433 432
@@ -976,13 +975,13 @@ static struct usb_driver mdc800_usb_driver =
976 Init and Cleanup this driver (Main Functions) 975 Init and Cleanup this driver (Main Functions)
977*************************************************************************/ 976*************************************************************************/
978 977
979#define try(A) if (!(A)) goto cleanup_on_fail;
980
981static int __init usb_mdc800_init (void) 978static int __init usb_mdc800_init (void)
982{ 979{
983 int retval = -ENODEV; 980 int retval = -ENODEV;
984 /* Allocate Memory */ 981 /* Allocate Memory */
985 try (mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL)); 982 mdc800=kmalloc (sizeof (struct mdc800_data), GFP_KERNEL);
983 if (!mdc800)
984 goto cleanup_on_fail;
986 985
987 memset(mdc800, 0, sizeof(struct mdc800_data)); 986 memset(mdc800, 0, sizeof(struct mdc800_data));
988 mdc800->dev = NULL; 987 mdc800->dev = NULL;
@@ -998,13 +997,25 @@ static int __init usb_mdc800_init (void)
998 mdc800->downloaded = 0; 997 mdc800->downloaded = 0;
999 mdc800->written = 0; 998 mdc800->written = 0;
1000 999
1001 try (mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL)); 1000 mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL);
1002 try (mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL)); 1001 if (!mdc800->irq_urb_buffer)
1003 try (mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL)); 1002 goto cleanup_on_fail;
1003 mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL);
1004 if (!mdc800->write_urb_buffer)
1005 goto cleanup_on_fail;
1006 mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL);
1007 if (!mdc800->download_urb_buffer)
1008 goto cleanup_on_fail;
1004 1009
1005 try (mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL)); 1010 mdc800->irq_urb=usb_alloc_urb (0, GFP_KERNEL);
1006 try (mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL)); 1011 if (!mdc800->irq_urb)
1007 try (mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL)); 1012 goto cleanup_on_fail;
1013 mdc800->download_urb=usb_alloc_urb (0, GFP_KERNEL);
1014 if (!mdc800->download_urb)
1015 goto cleanup_on_fail;
1016 mdc800->write_urb=usb_alloc_urb (0, GFP_KERNEL);
1017 if (!mdc800->write_urb)
1018 goto cleanup_on_fail;
1008 1019
1009 /* Register the driver */ 1020 /* Register the driver */
1010 retval = usb_register(&mdc800_usb_driver); 1021 retval = usb_register(&mdc800_usb_driver);
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index c84e1486054f..c89d0769b3da 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -773,11 +773,10 @@ static int mts_usb_probe(struct usb_interface *intf,
773 } 773 }
774 774
775 775
776 new_desc = kmalloc(sizeof(struct mts_desc), GFP_KERNEL); 776 new_desc = kzalloc(sizeof(struct mts_desc), GFP_KERNEL);
777 if (!new_desc) 777 if (!new_desc)
778 goto out; 778 goto out;
779 779
780 memset(new_desc, 0, sizeof(*new_desc));
781 new_desc->urb = usb_alloc_urb(0, GFP_KERNEL); 780 new_desc->urb = usb_alloc_urb(0, GFP_KERNEL);
782 if (!new_desc->urb) 781 if (!new_desc->urb)
783 goto out_kfree; 782 goto out_kfree;
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 74f8760d7c07..a32558b4048e 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -53,7 +53,7 @@ struct usb_acecad {
53 char name[128]; 53 char name[128];
54 char phys[64]; 54 char phys[64];
55 struct usb_device *usbdev; 55 struct usb_device *usbdev;
56 struct input_dev dev; 56 struct input_dev *input;
57 struct urb *irq; 57 struct urb *irq;
58 58
59 signed char *data; 59 signed char *data;
@@ -64,7 +64,7 @@ static void usb_acecad_irq(struct urb *urb, struct pt_regs *regs)
64{ 64{
65 struct usb_acecad *acecad = urb->context; 65 struct usb_acecad *acecad = urb->context;
66 unsigned char *data = acecad->data; 66 unsigned char *data = acecad->data;
67 struct input_dev *dev = &acecad->dev; 67 struct input_dev *dev = acecad->input;
68 int prox, status; 68 int prox, status;
69 69
70 switch (urb->status) { 70 switch (urb->status) {
@@ -135,8 +135,8 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
135 struct usb_host_interface *interface = intf->cur_altsetting; 135 struct usb_host_interface *interface = intf->cur_altsetting;
136 struct usb_endpoint_descriptor *endpoint; 136 struct usb_endpoint_descriptor *endpoint;
137 struct usb_acecad *acecad; 137 struct usb_acecad *acecad;
138 struct input_dev *input_dev;
138 int pipe, maxp; 139 int pipe, maxp;
139 char path[64];
140 140
141 if (interface->desc.bNumEndpoints != 1) 141 if (interface->desc.bNumEndpoints != 1)
142 return -ENODEV; 142 return -ENODEV;
@@ -153,8 +153,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
153 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 153 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
154 154
155 acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL); 155 acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
156 if (!acecad) 156 input_dev = input_allocate_device();
157 return -ENOMEM; 157 if (!acecad || !input_dev)
158 goto fail1;
158 159
159 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 160 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma);
160 if (!acecad->data) 161 if (!acecad->data)
@@ -164,6 +165,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
164 if (!acecad->irq) 165 if (!acecad->irq)
165 goto fail2; 166 goto fail2;
166 167
168 acecad->usbdev = dev;
169 acecad->input = input_dev;
170
167 if (dev->manufacturer) 171 if (dev->manufacturer)
168 strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); 172 strlcpy(acecad->name, dev->manufacturer, sizeof(acecad->name));
169 173
@@ -173,48 +177,48 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
173 strlcat(acecad->name, dev->product, sizeof(acecad->name)); 177 strlcat(acecad->name, dev->product, sizeof(acecad->name));
174 } 178 }
175 179
176 usb_make_path(dev, path, sizeof(path)); 180 usb_make_path(dev, acecad->phys, sizeof(acecad->phys));
177 snprintf(acecad->phys, sizeof(acecad->phys), "%s/input0", path); 181 strlcat(acecad->phys, "/input0", sizeof(acecad->phys));
178 182
179 acecad->usbdev = dev; 183 input_dev->name = acecad->name;
184 input_dev->phys = acecad->phys;
185 usb_to_input_id(dev, &input_dev->id);
186 input_dev->cdev.dev = &intf->dev;
187 input_dev->private = acecad;
180 188
181 acecad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 189 input_dev->open = usb_acecad_open;
182 acecad->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 190 input_dev->close = usb_acecad_close;
183 acecad->dev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 191
184 acecad->dev.keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2); 192 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
193 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
194 input_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
195 input_dev->keybit[LONG(BTN_DIGI)] = BIT(BTN_TOOL_PEN) |BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2);
185 196
186 switch (id->driver_info) { 197 switch (id->driver_info) {
187 case 0: 198 case 0:
188 acecad->dev.absmax[ABS_X] = 5000; 199 input_dev->absmax[ABS_X] = 5000;
189 acecad->dev.absmax[ABS_Y] = 3750; 200 input_dev->absmax[ABS_Y] = 3750;
190 acecad->dev.absmax[ABS_PRESSURE] = 512; 201 input_dev->absmax[ABS_PRESSURE] = 512;
191 if (!strlen(acecad->name)) 202 if (!strlen(acecad->name))
192 snprintf(acecad->name, sizeof(acecad->name), 203 snprintf(acecad->name, sizeof(acecad->name),
193 "USB Acecad Flair Tablet %04x:%04x", 204 "USB Acecad Flair Tablet %04x:%04x",
194 dev->descriptor.idVendor, dev->descriptor.idProduct); 205 le16_to_cpu(dev->descriptor.idVendor),
206 le16_to_cpu(dev->descriptor.idProduct));
195 break; 207 break;
196 case 1: 208 case 1:
197 acecad->dev.absmax[ABS_X] = 3000; 209 input_dev->absmax[ABS_X] = 3000;
198 acecad->dev.absmax[ABS_Y] = 2250; 210 input_dev->absmax[ABS_Y] = 2250;
199 acecad->dev.absmax[ABS_PRESSURE] = 1024; 211 input_dev->absmax[ABS_PRESSURE] = 1024;
200 if (!strlen(acecad->name)) 212 if (!strlen(acecad->name))
201 snprintf(acecad->name, sizeof(acecad->name), 213 snprintf(acecad->name, sizeof(acecad->name),
202 "USB Acecad 302 Tablet %04x:%04x", 214 "USB Acecad 302 Tablet %04x:%04x",
203 dev->descriptor.idVendor, dev->descriptor.idProduct); 215 le16_to_cpu(dev->descriptor.idVendor),
216 le16_to_cpu(dev->descriptor.idProduct));
204 break; 217 break;
205 } 218 }
206 219
207 acecad->dev.absfuzz[ABS_X] = 4; 220 input_dev->absfuzz[ABS_X] = 4;
208 acecad->dev.absfuzz[ABS_Y] = 4; 221 input_dev->absfuzz[ABS_Y] = 4;
209
210 acecad->dev.private = acecad;
211 acecad->dev.open = usb_acecad_open;
212 acecad->dev.close = usb_acecad_close;
213
214 acecad->dev.name = acecad->name;
215 acecad->dev.phys = acecad->phys;
216 usb_to_input_id(dev, &acecad->dev.id);
217 acecad->dev.dev = &intf->dev;
218 222
219 usb_fill_int_urb(acecad->irq, dev, pipe, 223 usb_fill_int_urb(acecad->irq, dev, pipe,
220 acecad->data, maxp > 8 ? 8 : maxp, 224 acecad->data, maxp > 8 ? 8 : maxp,
@@ -222,17 +226,15 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
222 acecad->irq->transfer_dma = acecad->data_dma; 226 acecad->irq->transfer_dma = acecad->data_dma;
223 acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 227 acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
224 228
225 input_register_device(&acecad->dev); 229 input_register_device(acecad->input);
226
227 printk(KERN_INFO "input: %s with packet size %d on %s\n",
228 acecad->name, maxp, path);
229 230
230 usb_set_intfdata(intf, acecad); 231 usb_set_intfdata(intf, acecad);
231 232
232 return 0; 233 return 0;
233 234
234 fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma); 235 fail2: usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
235 fail1: kfree(acecad); 236 fail1: input_free_device(input_dev);
237 kfree(acecad);
236 return -ENOMEM; 238 return -ENOMEM;
237} 239}
238 240
@@ -243,7 +245,7 @@ static void usb_acecad_disconnect(struct usb_interface *intf)
243 usb_set_intfdata(intf, NULL); 245 usb_set_intfdata(intf, NULL);
244 if (acecad) { 246 if (acecad) {
245 usb_kill_urb(acecad->irq); 247 usb_kill_urb(acecad->irq);
246 input_unregister_device(&acecad->dev); 248 input_unregister_device(acecad->input);
247 usb_free_urb(acecad->irq); 249 usb_free_urb(acecad->irq);
248 usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma); 250 usb_buffer_free(interface_to_usbdev(intf), 10, acecad->data, acecad->data_dma);
249 kfree(acecad); 251 kfree(acecad);
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index cd0cbfe20723..1c3b472a3bca 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -317,7 +317,7 @@ struct aiptek_settings {
317}; 317};
318 318
319struct aiptek { 319struct aiptek {
320 struct input_dev inputdev; /* input device struct */ 320 struct input_dev *inputdev; /* input device struct */
321 struct usb_device *usbdev; /* usb device struct */ 321 struct usb_device *usbdev; /* usb device struct */
322 struct urb *urb; /* urb for incoming reports */ 322 struct urb *urb; /* urb for incoming reports */
323 dma_addr_t data_dma; /* our dma stuffage */ 323 dma_addr_t data_dma; /* our dma stuffage */
@@ -402,7 +402,7 @@ static void aiptek_irq(struct urb *urb, struct pt_regs *regs)
402{ 402{
403 struct aiptek *aiptek = urb->context; 403 struct aiptek *aiptek = urb->context;
404 unsigned char *data = aiptek->data; 404 unsigned char *data = aiptek->data;
405 struct input_dev *inputdev = &aiptek->inputdev; 405 struct input_dev *inputdev = aiptek->inputdev;
406 int jitterable = 0; 406 int jitterable = 0;
407 int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck; 407 int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck;
408 408
@@ -955,20 +955,20 @@ static int aiptek_program_tablet(struct aiptek *aiptek)
955 /* Query getXextension */ 955 /* Query getXextension */
956 if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0) 956 if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0)
957 return ret; 957 return ret;
958 aiptek->inputdev.absmin[ABS_X] = 0; 958 aiptek->inputdev->absmin[ABS_X] = 0;
959 aiptek->inputdev.absmax[ABS_X] = ret - 1; 959 aiptek->inputdev->absmax[ABS_X] = ret - 1;
960 960
961 /* Query getYextension */ 961 /* Query getYextension */
962 if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0) 962 if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0)
963 return ret; 963 return ret;
964 aiptek->inputdev.absmin[ABS_Y] = 0; 964 aiptek->inputdev->absmin[ABS_Y] = 0;
965 aiptek->inputdev.absmax[ABS_Y] = ret - 1; 965 aiptek->inputdev->absmax[ABS_Y] = ret - 1;
966 966
967 /* Query getPressureLevels */ 967 /* Query getPressureLevels */
968 if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0) 968 if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0)
969 return ret; 969 return ret;
970 aiptek->inputdev.absmin[ABS_PRESSURE] = 0; 970 aiptek->inputdev->absmin[ABS_PRESSURE] = 0;
971 aiptek->inputdev.absmax[ABS_PRESSURE] = ret - 1; 971 aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1;
972 972
973 /* Depending on whether we are in absolute or relative mode, we will 973 /* Depending on whether we are in absolute or relative mode, we will
974 * do a switchToTablet(absolute) or switchToMouse(relative) command. 974 * do a switchToTablet(absolute) or switchToMouse(relative) command.
@@ -1025,8 +1025,8 @@ static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr
1025 return 0; 1025 return 0;
1026 1026
1027 return snprintf(buf, PAGE_SIZE, "%dx%d\n", 1027 return snprintf(buf, PAGE_SIZE, "%dx%d\n",
1028 aiptek->inputdev.absmax[ABS_X] + 1, 1028 aiptek->inputdev->absmax[ABS_X] + 1,
1029 aiptek->inputdev.absmax[ABS_Y] + 1); 1029 aiptek->inputdev->absmax[ABS_Y] + 1);
1030} 1030}
1031 1031
1032/* These structs define the sysfs files, param #1 is the name of the 1032/* These structs define the sysfs files, param #1 is the name of the
@@ -1048,7 +1048,7 @@ static ssize_t show_tabletProductId(struct device *dev, struct device_attribute
1048 return 0; 1048 return 0;
1049 1049
1050 return snprintf(buf, PAGE_SIZE, "0x%04x\n", 1050 return snprintf(buf, PAGE_SIZE, "0x%04x\n",
1051 aiptek->inputdev.id.product); 1051 aiptek->inputdev->id.product);
1052} 1052}
1053 1053
1054static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL); 1054static DEVICE_ATTR(product_id, S_IRUGO, show_tabletProductId, NULL);
@@ -1063,7 +1063,7 @@ static ssize_t show_tabletVendorId(struct device *dev, struct device_attribute *
1063 if (aiptek == NULL) 1063 if (aiptek == NULL)
1064 return 0; 1064 return 0;
1065 1065
1066 return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev.id.vendor); 1066 return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->inputdev->id.vendor);
1067} 1067}
1068 1068
1069static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL); 1069static DEVICE_ATTR(vendor_id, S_IRUGO, show_tabletVendorId, NULL);
@@ -1977,7 +1977,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1977 struct input_dev *inputdev; 1977 struct input_dev *inputdev;
1978 struct input_handle *inputhandle; 1978 struct input_handle *inputhandle;
1979 struct list_head *node, *next; 1979 struct list_head *node, *next;
1980 char path[64 + 1];
1981 int i; 1980 int i;
1982 int speeds[] = { 0, 1981 int speeds[] = { 0,
1983 AIPTEK_PROGRAMMABLE_DELAY_50, 1982 AIPTEK_PROGRAMMABLE_DELAY_50,
@@ -1996,24 +1995,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1996 */ 1995 */
1997 speeds[0] = programmableDelay; 1996 speeds[0] = programmableDelay;
1998 1997
1999 if ((aiptek = kmalloc(sizeof(struct aiptek), GFP_KERNEL)) == NULL) 1998 aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL);
2000 return -ENOMEM; 1999 inputdev = input_allocate_device();
2001 memset(aiptek, 0, sizeof(struct aiptek)); 2000 if (!aiptek || !inputdev)
2001 goto fail1;
2002 2002
2003 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 2003 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
2004 SLAB_ATOMIC, &aiptek->data_dma); 2004 SLAB_ATOMIC, &aiptek->data_dma);
2005 if (aiptek->data == NULL) { 2005 if (!aiptek->data)
2006 kfree(aiptek); 2006 goto fail1;
2007 return -ENOMEM;
2008 }
2009 2007
2010 aiptek->urb = usb_alloc_urb(0, GFP_KERNEL); 2008 aiptek->urb = usb_alloc_urb(0, GFP_KERNEL);
2011 if (aiptek->urb == NULL) { 2009 if (!aiptek->urb)
2012 usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data, 2010 goto fail2;
2013 aiptek->data_dma); 2011
2014 kfree(aiptek); 2012 aiptek->inputdev = inputdev;
2015 return -ENOMEM; 2013 aiptek->usbdev = usbdev;
2016 } 2014 aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
2015 aiptek->inDelay = 0;
2016 aiptek->endDelay = 0;
2017 aiptek->previousJitterable = 0;
2017 2018
2018 /* Set up the curSettings struct. Said struct contains the current 2019 /* Set up the curSettings struct. Said struct contains the current
2019 * programmable parameters. The newSetting struct contains changes 2020 * programmable parameters. The newSetting struct contains changes
@@ -2036,31 +2037,48 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2036 2037
2037 /* Both structs should have equivalent settings 2038 /* Both structs should have equivalent settings
2038 */ 2039 */
2039 memcpy(&aiptek->newSetting, &aiptek->curSetting, 2040 aiptek->newSetting = aiptek->curSetting;
2040 sizeof(struct aiptek_settings)); 2041
2042 /* Determine the usb devices' physical path.
2043 * Asketh not why we always pretend we're using "../input0",
2044 * but I suspect this will have to be refactored one
2045 * day if a single USB device can be a keyboard & a mouse
2046 * & a tablet, and the inputX number actually will tell
2047 * us something...
2048 */
2049 usb_make_path(usbdev, aiptek->features.usbPath,
2050 sizeof(aiptek->features.usbPath));
2051 strlcat(aiptek->features.usbPath, "/input0",
2052 sizeof(aiptek->features.usbPath));
2053
2054 /* Set up client data, pointers to open and close routines
2055 * for the input device.
2056 */
2057 inputdev->name = "Aiptek";
2058 inputdev->phys = aiptek->features.usbPath;
2059 usb_to_input_id(usbdev, &inputdev->id);
2060 inputdev->cdev.dev = &intf->dev;
2061 inputdev->private = aiptek;
2062 inputdev->open = aiptek_open;
2063 inputdev->close = aiptek_close;
2041 2064
2042 /* Now program the capacities of the tablet, in terms of being 2065 /* Now program the capacities of the tablet, in terms of being
2043 * an input device. 2066 * an input device.
2044 */ 2067 */
2045 aiptek->inputdev.evbit[0] |= BIT(EV_KEY) 2068 inputdev->evbit[0] |= BIT(EV_KEY)
2046 | BIT(EV_ABS) 2069 | BIT(EV_ABS)
2047 | BIT(EV_REL) 2070 | BIT(EV_REL)
2048 | BIT(EV_MSC); 2071 | BIT(EV_MSC);
2049 2072
2050 aiptek->inputdev.absbit[0] |= 2073 inputdev->absbit[0] |= BIT(ABS_MISC);
2051 (BIT(ABS_X) |
2052 BIT(ABS_Y) |
2053 BIT(ABS_PRESSURE) |
2054 BIT(ABS_TILT_X) |
2055 BIT(ABS_TILT_Y) | BIT(ABS_WHEEL) | BIT(ABS_MISC));
2056 2074
2057 aiptek->inputdev.relbit[0] |= 2075 inputdev->relbit[0] |=
2058 (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC)); 2076 (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC));
2059 2077
2060 aiptek->inputdev.keybit[LONG(BTN_LEFT)] |= 2078 inputdev->keybit[LONG(BTN_LEFT)] |=
2061 (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE)); 2079 (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE));
2062 2080
2063 aiptek->inputdev.keybit[LONG(BTN_DIGI)] |= 2081 inputdev->keybit[LONG(BTN_DIGI)] |=
2064 (BIT(BTN_TOOL_PEN) | 2082 (BIT(BTN_TOOL_PEN) |
2065 BIT(BTN_TOOL_RUBBER) | 2083 BIT(BTN_TOOL_RUBBER) |
2066 BIT(BTN_TOOL_PENCIL) | 2084 BIT(BTN_TOOL_PENCIL) |
@@ -2070,70 +2088,26 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2070 BIT(BTN_TOOL_LENS) | 2088 BIT(BTN_TOOL_LENS) |
2071 BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2)); 2089 BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2));
2072 2090
2073 aiptek->inputdev.mscbit[0] = BIT(MSC_SERIAL); 2091 inputdev->mscbit[0] = BIT(MSC_SERIAL);
2074 2092
2075 /* Programming the tablet macro keys needs to be done with a for loop 2093 /* Programming the tablet macro keys needs to be done with a for loop
2076 * as the keycodes are discontiguous. 2094 * as the keycodes are discontiguous.
2077 */ 2095 */
2078 for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) 2096 for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i)
2079 set_bit(macroKeyEvents[i], aiptek->inputdev.keybit); 2097 set_bit(macroKeyEvents[i], inputdev->keybit);
2080
2081 /* Set up client data, pointers to open and close routines
2082 * for the input device.
2083 */
2084 aiptek->inputdev.private = aiptek;
2085 aiptek->inputdev.open = aiptek_open;
2086 aiptek->inputdev.close = aiptek_close;
2087 2098
2088 /* Determine the usb devices' physical path. 2099 /*
2089 * Asketh not why we always pretend we're using "../input0", 2100 * Program the input device coordinate capacities. We do not yet
2090 * but I suspect this will have to be refactored one
2091 * day if a single USB device can be a keyboard & a mouse
2092 * & a tablet, and the inputX number actually will tell
2093 * us something...
2094 */
2095 if (usb_make_path(usbdev, path, 64) > 0)
2096 sprintf(aiptek->features.usbPath, "%s/input0", path);
2097
2098 /* Program the input device coordinate capacities. We do not yet
2099 * know what maximum X, Y, and Z values are, so we're putting fake 2101 * know what maximum X, Y, and Z values are, so we're putting fake
2100 * values in. Later, we'll ask the tablet to put in the correct 2102 * values in. Later, we'll ask the tablet to put in the correct
2101 * values. 2103 * values.
2102 */ 2104 */
2103 aiptek->inputdev.absmin[ABS_X] = 0; 2105 input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0);
2104 aiptek->inputdev.absmax[ABS_X] = 2999; 2106 input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0);
2105 aiptek->inputdev.absmin[ABS_Y] = 0; 2107 input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0);
2106 aiptek->inputdev.absmax[ABS_Y] = 2249; 2108 input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
2107 aiptek->inputdev.absmin[ABS_PRESSURE] = 0; 2109 input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
2108 aiptek->inputdev.absmax[ABS_PRESSURE] = 511; 2110 input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
2109 aiptek->inputdev.absmin[ABS_TILT_X] = AIPTEK_TILT_MIN;
2110 aiptek->inputdev.absmax[ABS_TILT_X] = AIPTEK_TILT_MAX;
2111 aiptek->inputdev.absmin[ABS_TILT_Y] = AIPTEK_TILT_MIN;
2112 aiptek->inputdev.absmax[ABS_TILT_Y] = AIPTEK_TILT_MAX;
2113 aiptek->inputdev.absmin[ABS_WHEEL] = AIPTEK_WHEEL_MIN;
2114 aiptek->inputdev.absmax[ABS_WHEEL] = AIPTEK_WHEEL_MAX - 1;
2115 aiptek->inputdev.absfuzz[ABS_X] = 0;
2116 aiptek->inputdev.absfuzz[ABS_Y] = 0;
2117 aiptek->inputdev.absfuzz[ABS_PRESSURE] = 0;
2118 aiptek->inputdev.absfuzz[ABS_TILT_X] = 0;
2119 aiptek->inputdev.absfuzz[ABS_TILT_Y] = 0;
2120 aiptek->inputdev.absfuzz[ABS_WHEEL] = 0;
2121 aiptek->inputdev.absflat[ABS_X] = 0;
2122 aiptek->inputdev.absflat[ABS_Y] = 0;
2123 aiptek->inputdev.absflat[ABS_PRESSURE] = 0;
2124 aiptek->inputdev.absflat[ABS_TILT_X] = 0;
2125 aiptek->inputdev.absflat[ABS_TILT_Y] = 0;
2126 aiptek->inputdev.absflat[ABS_WHEEL] = 0;
2127 aiptek->inputdev.name = "Aiptek";
2128 aiptek->inputdev.phys = aiptek->features.usbPath;
2129 usb_to_input_id(usbdev, &aiptek->inputdev.id);
2130 aiptek->inputdev.dev = &intf->dev;
2131
2132 aiptek->usbdev = usbdev;
2133 aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
2134 aiptek->inDelay = 0;
2135 aiptek->endDelay = 0;
2136 aiptek->previousJitterable = 0;
2137 2111
2138 endpoint = &intf->altsetting[0].endpoint[0].desc; 2112 endpoint = &intf->altsetting[0].endpoint[0].desc;
2139 2113
@@ -2150,28 +2124,6 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2150 aiptek->urb->transfer_dma = aiptek->data_dma; 2124 aiptek->urb->transfer_dma = aiptek->data_dma;
2151 aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 2125 aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2152 2126
2153 /* Register the tablet as an Input Device
2154 */
2155 input_register_device(&aiptek->inputdev);
2156
2157 /* We now will look for the evdev device which is mapped to
2158 * the tablet. The partial name is kept in the link list of
2159 * input_handles associated with this input device.
2160 * What identifies an evdev input_handler is that it begins
2161 * with 'event', continues with a digit, and that in turn
2162 * is mapped to /{devfs}/input/eventN.
2163 */
2164 inputdev = &aiptek->inputdev;
2165 list_for_each_safe(node, next, &inputdev->h_list) {
2166 inputhandle = to_handle(node);
2167 if (strncmp(inputhandle->name, "event", 5) == 0) {
2168 strcpy(aiptek->features.inputPath, inputhandle->name);
2169 break;
2170 }
2171 }
2172
2173 info("input: Aiptek on %s (%s)\n", path, aiptek->features.inputPath);
2174
2175 /* Program the tablet. This sets the tablet up in the mode 2127 /* Program the tablet. This sets the tablet up in the mode
2176 * specified in newSetting, and also queries the tablet's 2128 * specified in newSetting, and also queries the tablet's
2177 * physical capacities. 2129 * physical capacities.
@@ -2186,13 +2138,32 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2186 for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { 2138 for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) {
2187 aiptek->curSetting.programmableDelay = speeds[i]; 2139 aiptek->curSetting.programmableDelay = speeds[i];
2188 (void)aiptek_program_tablet(aiptek); 2140 (void)aiptek_program_tablet(aiptek);
2189 if (aiptek->inputdev.absmax[ABS_X] > 0) { 2141 if (aiptek->inputdev->absmax[ABS_X] > 0) {
2190 info("input: Aiptek using %d ms programming speed\n", 2142 info("input: Aiptek using %d ms programming speed\n",
2191 aiptek->curSetting.programmableDelay); 2143 aiptek->curSetting.programmableDelay);
2192 break; 2144 break;
2193 } 2145 }
2194 } 2146 }
2195 2147
2148 /* Register the tablet as an Input Device
2149 */
2150 input_register_device(aiptek->inputdev);
2151
2152 /* We now will look for the evdev device which is mapped to
2153 * the tablet. The partial name is kept in the link list of
2154 * input_handles associated with this input device.
2155 * What identifies an evdev input_handler is that it begins
2156 * with 'event', continues with a digit, and that in turn
2157 * is mapped to input/eventN.
2158 */
2159 list_for_each_safe(node, next, &inputdev->h_list) {
2160 inputhandle = to_handle(node);
2161 if (strncmp(inputhandle->name, "event", 5) == 0) {
2162 strcpy(aiptek->features.inputPath, inputhandle->name);
2163 break;
2164 }
2165 }
2166
2196 /* Associate this driver's struct with the usb interface. 2167 /* Associate this driver's struct with the usb interface.
2197 */ 2168 */
2198 usb_set_intfdata(intf, aiptek); 2169 usb_set_intfdata(intf, aiptek);
@@ -2207,6 +2178,12 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2207 info("aiptek: error loading 'evdev' module"); 2178 info("aiptek: error loading 'evdev' module");
2208 2179
2209 return 0; 2180 return 0;
2181
2182fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
2183 aiptek->data_dma);
2184fail1: input_free_device(inputdev);
2185 kfree(aiptek);
2186 return -ENOMEM;
2210} 2187}
2211 2188
2212/* Forward declaration */ 2189/* Forward declaration */
@@ -2234,7 +2211,7 @@ static void aiptek_disconnect(struct usb_interface *intf)
2234 /* Free & unhook everything from the system. 2211 /* Free & unhook everything from the system.
2235 */ 2212 */
2236 usb_kill_urb(aiptek->urb); 2213 usb_kill_urb(aiptek->urb);
2237 input_unregister_device(&aiptek->inputdev); 2214 input_unregister_device(aiptek->inputdev);
2238 aiptek_delete_files(&intf->dev); 2215 aiptek_delete_files(&intf->dev);
2239 usb_free_urb(aiptek->urb); 2216 usb_free_urb(aiptek->urb);
2240 usb_buffer_free(interface_to_usbdev(intf), 2217 usb_buffer_free(interface_to_usbdev(intf),
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index e03c1c567a14..15840db092a5 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -39,7 +39,7 @@
39#define APPLE_VENDOR_ID 0x05AC 39#define APPLE_VENDOR_ID 0x05AC
40 40
41#define ATP_DEVICE(prod) \ 41#define ATP_DEVICE(prod) \
42 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ 42 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
43 USB_DEVICE_ID_MATCH_INT_CLASS | \ 43 USB_DEVICE_ID_MATCH_INT_CLASS | \
44 USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 44 USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
45 .idVendor = APPLE_VENDOR_ID, \ 45 .idVendor = APPLE_VENDOR_ID, \
@@ -78,9 +78,9 @@ MODULE_DEVICE_TABLE (usb, atp_table);
78 * We try to keep the touchpad aspect ratio while still doing only simple 78 * We try to keep the touchpad aspect ratio while still doing only simple
79 * arithmetics. 79 * arithmetics.
80 * The factors below give coordinates like: 80 * The factors below give coordinates like:
81 * 0 <= x < 960 on 12" and 15" Powerbooks 81 * 0 <= x < 960 on 12" and 15" Powerbooks
82 * 0 <= x < 1600 on 17" Powerbooks 82 * 0 <= x < 1600 on 17" Powerbooks
83 * 0 <= y < 646 83 * 0 <= y < 646
84 */ 84 */
85#define ATP_XFACT 64 85#define ATP_XFACT 64
86#define ATP_YFACT 43 86#define ATP_YFACT 43
@@ -93,11 +93,12 @@ MODULE_DEVICE_TABLE (usb, atp_table);
93 93
94/* Structure to hold all of our device specific stuff */ 94/* Structure to hold all of our device specific stuff */
95struct atp { 95struct atp {
96 char phys[64];
96 struct usb_device * udev; /* usb device */ 97 struct usb_device * udev; /* usb device */
97 struct urb * urb; /* usb request block */ 98 struct urb * urb; /* usb request block */
98 signed char * data; /* transferred data */ 99 signed char * data; /* transferred data */
99 int open; /* non-zero if opened */ 100 int open; /* non-zero if opened */
100 struct input_dev input; /* input dev */ 101 struct input_dev *input; /* input dev */
101 int valid; /* are the sensors valid ? */ 102 int valid; /* are the sensors valid ? */
102 int x_old; /* last reported x/y, */ 103 int x_old; /* last reported x/y, */
103 int y_old; /* used for smoothing */ 104 int y_old; /* used for smoothing */
@@ -114,11 +115,11 @@ struct atp {
114 int i; \ 115 int i; \
115 printk("appletouch: %s %lld", msg, (long long)jiffies); \ 116 printk("appletouch: %s %lld", msg, (long long)jiffies); \
116 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \ 117 for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) \
117 printk(" %02x", tab[i]); \ 118 printk(" %02x", tab[i]); \
118 printk("\n"); \ 119 printk("\n"); \
119 } 120 }
120 121
121#define dprintk(format, a...) \ 122#define dprintk(format, a...) \
122 do { \ 123 do { \
123 if (debug) printk(format, ##a); \ 124 if (debug) printk(format, ##a); \
124 } while (0) 125 } while (0)
@@ -219,8 +220,8 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs)
219 for (i = 16; i < ATP_XSENSORS; i++) 220 for (i = 16; i < ATP_XSENSORS; i++)
220 if (dev->xy_cur[i]) { 221 if (dev->xy_cur[i]) {
221 printk("appletouch: 17\" model detected.\n"); 222 printk("appletouch: 17\" model detected.\n");
222 input_set_abs_params(&dev->input, ABS_X, 0, 223 input_set_abs_params(dev->input, ABS_X, 0,
223 (ATP_XSENSORS - 1) * 224 (ATP_XSENSORS - 1) *
224 ATP_XFACT - 1, 225 ATP_XFACT - 1,
225 ATP_FUZZ, 0); 226 ATP_FUZZ, 0);
226 break; 227 break;
@@ -260,12 +261,12 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs)
260 "Xz: %3d Yz: %3d\n", 261 "Xz: %3d Yz: %3d\n",
261 x, y, x_z, y_z); 262 x, y, x_z, y_z);
262 263
263 input_report_key(&dev->input, BTN_TOUCH, 1); 264 input_report_key(dev->input, BTN_TOUCH, 1);
264 input_report_abs(&dev->input, ABS_X, x); 265 input_report_abs(dev->input, ABS_X, x);
265 input_report_abs(&dev->input, ABS_Y, y); 266 input_report_abs(dev->input, ABS_Y, y);
266 input_report_abs(&dev->input, ABS_PRESSURE, 267 input_report_abs(dev->input, ABS_PRESSURE,
267 min(ATP_PRESSURE, x_z + y_z)); 268 min(ATP_PRESSURE, x_z + y_z));
268 atp_report_fingers(&dev->input, max(x_f, y_f)); 269 atp_report_fingers(dev->input, max(x_f, y_f));
269 } 270 }
270 dev->x_old = x; 271 dev->x_old = x;
271 dev->y_old = y; 272 dev->y_old = y;
@@ -273,17 +274,17 @@ static void atp_complete(struct urb* urb, struct pt_regs* regs)
273 else if (!x && !y) { 274 else if (!x && !y) {
274 275
275 dev->x_old = dev->y_old = -1; 276 dev->x_old = dev->y_old = -1;
276 input_report_key(&dev->input, BTN_TOUCH, 0); 277 input_report_key(dev->input, BTN_TOUCH, 0);
277 input_report_abs(&dev->input, ABS_PRESSURE, 0); 278 input_report_abs(dev->input, ABS_PRESSURE, 0);
278 atp_report_fingers(&dev->input, 0); 279 atp_report_fingers(dev->input, 0);
279 280
280 /* reset the accumulator on release */ 281 /* reset the accumulator on release */
281 memset(dev->xy_acc, 0, sizeof(dev->xy_acc)); 282 memset(dev->xy_acc, 0, sizeof(dev->xy_acc));
282 } 283 }
283 284
284 input_report_key(&dev->input, BTN_LEFT, !!dev->data[80]); 285 input_report_key(dev->input, BTN_LEFT, !!dev->data[80]);
285 286
286 input_sync(&dev->input); 287 input_sync(dev->input);
287 288
288exit: 289exit:
289 retval = usb_submit_urb(dev->urb, GFP_ATOMIC); 290 retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
@@ -314,21 +315,14 @@ static void atp_close(struct input_dev *input)
314 315
315static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id) 316static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id)
316{ 317{
317 struct atp *dev = NULL; 318 struct atp *dev;
319 struct input_dev *input_dev;
320 struct usb_device *udev = interface_to_usbdev(iface);
318 struct usb_host_interface *iface_desc; 321 struct usb_host_interface *iface_desc;
319 struct usb_endpoint_descriptor *endpoint; 322 struct usb_endpoint_descriptor *endpoint;
320 int int_in_endpointAddr = 0; 323 int int_in_endpointAddr = 0;
321 int i, retval = -ENOMEM; 324 int i, retval = -ENOMEM;
322 325
323 /* allocate memory for our device state and initialize it */
324 dev = kmalloc(sizeof(struct atp), GFP_KERNEL);
325 if (dev == NULL) {
326 err("Out of memory");
327 goto err_kmalloc;
328 }
329 memset(dev, 0, sizeof(struct atp));
330
331 dev->udev = interface_to_usbdev(iface);
332 326
333 /* set up the endpoint information */ 327 /* set up the endpoint information */
334 /* use only the first interrupt-in endpoint */ 328 /* use only the first interrupt-in endpoint */
@@ -345,70 +339,82 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
345 } 339 }
346 } 340 }
347 if (!int_in_endpointAddr) { 341 if (!int_in_endpointAddr) {
348 retval = -EIO;
349 err("Could not find int-in endpoint"); 342 err("Could not find int-in endpoint");
350 goto err_endpoint; 343 return -EIO;
351 } 344 }
352 345
353 /* save our data pointer in this interface device */ 346 /* allocate memory for our device state and initialize it */
354 usb_set_intfdata(iface, dev); 347 dev = kzalloc(sizeof(struct atp), GFP_KERNEL);
348 input_dev = input_allocate_device();
349 if (!dev || !input_dev) {
350 err("Out of memory");
351 goto err_free_devs;
352 }
353
354 dev->udev = udev;
355 dev->input = input_dev;
355 356
356 dev->urb = usb_alloc_urb(0, GFP_KERNEL); 357 dev->urb = usb_alloc_urb(0, GFP_KERNEL);
357 if (!dev->urb) { 358 if (!dev->urb) {
358 retval = -ENOMEM; 359 retval = -ENOMEM;
359 goto err_usballoc; 360 goto err_free_devs;
360 } 361 }
362
361 dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL, 363 dev->data = usb_buffer_alloc(dev->udev, ATP_DATASIZE, GFP_KERNEL,
362 &dev->urb->transfer_dma); 364 &dev->urb->transfer_dma);
363 if (!dev->data) { 365 if (!dev->data) {
364 retval = -ENOMEM; 366 retval = -ENOMEM;
365 goto err_usbbufalloc; 367 goto err_free_urb;
366 } 368 }
367 usb_fill_int_urb(dev->urb, dev->udev, 369
368 usb_rcvintpipe(dev->udev, int_in_endpointAddr), 370 usb_fill_int_urb(dev->urb, udev,
371 usb_rcvintpipe(udev, int_in_endpointAddr),
369 dev->data, ATP_DATASIZE, atp_complete, dev, 1); 372 dev->data, ATP_DATASIZE, atp_complete, dev, 1);
370 373
371 init_input_dev(&dev->input); 374 usb_make_path(udev, dev->phys, sizeof(dev->phys));
372 dev->input.name = "appletouch"; 375 strlcat(dev->phys, "/input0", sizeof(dev->phys));
373 dev->input.dev = &iface->dev; 376
374 dev->input.private = dev; 377 input_dev->name = "appletouch";
375 dev->input.open = atp_open; 378 input_dev->phys = dev->phys;
376 dev->input.close = atp_close; 379 usb_to_input_id(dev->udev, &input_dev->id);
380 input_dev->cdev.dev = &iface->dev;
377 381
378 usb_to_input_id(dev->udev, &dev->input.id); 382 input_dev->private = dev;
383 input_dev->open = atp_open;
384 input_dev->close = atp_close;
379 385
380 set_bit(EV_ABS, dev->input.evbit); 386 set_bit(EV_ABS, input_dev->evbit);
381 387
382 /* 388 /*
383 * 12" and 15" Powerbooks only have 16 x sensors, 389 * 12" and 15" Powerbooks only have 16 x sensors,
384 * 17" models are detected later. 390 * 17" models are detected later.
385 */ 391 */
386 input_set_abs_params(&dev->input, ABS_X, 0, 392 input_set_abs_params(input_dev, ABS_X, 0,
387 (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0); 393 (16 - 1) * ATP_XFACT - 1, ATP_FUZZ, 0);
388 input_set_abs_params(&dev->input, ABS_Y, 0, 394 input_set_abs_params(input_dev, ABS_Y, 0,
389 (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0); 395 (ATP_YSENSORS - 1) * ATP_YFACT - 1, ATP_FUZZ, 0);
390 input_set_abs_params(&dev->input, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); 396 input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0);
391 397
392 set_bit(EV_KEY, dev->input.evbit); 398 set_bit(EV_KEY, input_dev->evbit);
393 set_bit(BTN_TOUCH, dev->input.keybit); 399 set_bit(BTN_TOUCH, input_dev->keybit);
394 set_bit(BTN_TOOL_FINGER, dev->input.keybit); 400 set_bit(BTN_TOOL_FINGER, input_dev->keybit);
395 set_bit(BTN_TOOL_DOUBLETAP, dev->input.keybit); 401 set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
396 set_bit(BTN_TOOL_TRIPLETAP, dev->input.keybit); 402 set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
397 set_bit(BTN_LEFT, dev->input.keybit); 403 set_bit(BTN_LEFT, input_dev->keybit);
398 404
399 input_register_device(&dev->input); 405 input_register_device(dev->input);
400 406
401 printk(KERN_INFO "input: appletouch connected\n"); 407 /* save our data pointer in this interface device */
408 usb_set_intfdata(iface, dev);
402 409
403 return 0; 410 return 0;
404 411
405err_usbbufalloc: 412 err_free_urb:
406 usb_free_urb(dev->urb); 413 usb_free_urb(dev->urb);
407err_usballoc: 414 err_free_devs:
408 usb_set_intfdata(iface, NULL); 415 usb_set_intfdata(iface, NULL);
409err_endpoint:
410 kfree(dev); 416 kfree(dev);
411err_kmalloc: 417 input_free_device(input_dev);
412 return retval; 418 return retval;
413} 419}
414 420
@@ -419,7 +425,7 @@ static void atp_disconnect(struct usb_interface *iface)
419 usb_set_intfdata(iface, NULL); 425 usb_set_intfdata(iface, NULL);
420 if (dev) { 426 if (dev) {
421 usb_kill_urb(dev->urb); 427 usb_kill_urb(dev->urb);
422 input_unregister_device(&dev->input); 428 input_unregister_device(dev->input);
423 usb_free_urb(dev->urb); 429 usb_free_urb(dev->urb);
424 usb_buffer_free(dev->udev, ATP_DATASIZE, 430 usb_buffer_free(dev->udev, ATP_DATASIZE,
425 dev->data, dev->urb->transfer_dma); 431 dev->data, dev->urb->transfer_dma);
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index fd99681ee483..9a2a47db9494 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -112,7 +112,6 @@
112 112
113#define NAME_BUFSIZE 80 /* size of product name, path buffers */ 113#define NAME_BUFSIZE 80 /* size of product name, path buffers */
114#define DATA_BUFSIZE 63 /* size of URB data buffers */ 114#define DATA_BUFSIZE 63 /* size of URB data buffers */
115#define ATI_INPUTNUM 1 /* Which input device to register as */
116 115
117static unsigned long channel_mask; 116static unsigned long channel_mask;
118module_param(channel_mask, ulong, 0444); 117module_param(channel_mask, ulong, 0444);
@@ -162,7 +161,7 @@ static char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
162static DECLARE_MUTEX(disconnect_sem); 161static DECLARE_MUTEX(disconnect_sem);
163 162
164struct ati_remote { 163struct ati_remote {
165 struct input_dev idev; 164 struct input_dev *idev;
166 struct usb_device *udev; 165 struct usb_device *udev;
167 struct usb_interface *interface; 166 struct usb_interface *interface;
168 167
@@ -198,15 +197,13 @@ struct ati_remote {
198#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ 197#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/
199 198
200/* Translation table from hardware messages to input events. */ 199/* Translation table from hardware messages to input events. */
201static struct 200static struct {
202{
203 short kind; 201 short kind;
204 unsigned char data1, data2; 202 unsigned char data1, data2;
205 int type; 203 int type;
206 unsigned int code; 204 unsigned int code;
207 int value; 205 int value;
208} ati_remote_tbl[] = 206} ati_remote_tbl[] = {
209{
210 /* Directional control pad axes */ 207 /* Directional control pad axes */
211 {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */ 208 {KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */
212 {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */ 209 {KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */
@@ -286,7 +283,6 @@ static struct
286 283
287/* Local function prototypes */ 284/* Local function prototypes */
288static void ati_remote_dump (unsigned char *data, unsigned int actual_length); 285static void ati_remote_dump (unsigned char *data, unsigned int actual_length);
289static void ati_remote_delete (struct ati_remote *dev);
290static int ati_remote_open (struct input_dev *inputdev); 286static int ati_remote_open (struct input_dev *inputdev);
291static void ati_remote_close (struct input_dev *inputdev); 287static void ati_remote_close (struct input_dev *inputdev);
292static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data); 288static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data);
@@ -428,7 +424,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
428{ 424{
429 struct ati_remote *ati_remote = urb->context; 425 struct ati_remote *ati_remote = urb->context;
430 unsigned char *data= ati_remote->inbuf; 426 unsigned char *data= ati_remote->inbuf;
431 struct input_dev *dev = &ati_remote->idev; 427 struct input_dev *dev = ati_remote->idev;
432 int index, acc; 428 int index, acc;
433 int remote_num; 429 int remote_num;
434 430
@@ -587,38 +583,55 @@ static void ati_remote_irq_in(struct urb *urb, struct pt_regs *regs)
587} 583}
588 584
589/* 585/*
590 * ati_remote_delete 586 * ati_remote_alloc_buffers
591 */ 587 */
592static void ati_remote_delete(struct ati_remote *ati_remote) 588static int ati_remote_alloc_buffers(struct usb_device *udev,
589 struct ati_remote *ati_remote)
593{ 590{
594 if (ati_remote->irq_urb) 591 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
595 usb_kill_urb(ati_remote->irq_urb); 592 &ati_remote->inbuf_dma);
593 if (!ati_remote->inbuf)
594 return -1;
596 595
597 if (ati_remote->out_urb) 596 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC,
598 usb_kill_urb(ati_remote->out_urb); 597 &ati_remote->outbuf_dma);
598 if (!ati_remote->outbuf)
599 return -1;
599 600
600 input_unregister_device(&ati_remote->idev); 601 ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
602 if (!ati_remote->irq_urb)
603 return -1;
601 604
602 if (ati_remote->inbuf) 605 ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL);
603 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 606 if (!ati_remote->out_urb)
604 ati_remote->inbuf, ati_remote->inbuf_dma); 607 return -1;
605 608
606 if (ati_remote->outbuf) 609 return 0;
607 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 610}
608 ati_remote->outbuf, ati_remote->outbuf_dma);
609 611
612/*
613 * ati_remote_free_buffers
614 */
615static void ati_remote_free_buffers(struct ati_remote *ati_remote)
616{
610 if (ati_remote->irq_urb) 617 if (ati_remote->irq_urb)
611 usb_free_urb(ati_remote->irq_urb); 618 usb_free_urb(ati_remote->irq_urb);
612 619
613 if (ati_remote->out_urb) 620 if (ati_remote->out_urb)
614 usb_free_urb(ati_remote->out_urb); 621 usb_free_urb(ati_remote->out_urb);
615 622
616 kfree(ati_remote); 623 if (ati_remote->inbuf)
624 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
625 ati_remote->inbuf, ati_remote->inbuf_dma);
626
627 if (ati_remote->outbuf)
628 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
629 ati_remote->inbuf, ati_remote->outbuf_dma);
617} 630}
618 631
619static void ati_remote_input_init(struct ati_remote *ati_remote) 632static void ati_remote_input_init(struct ati_remote *ati_remote)
620{ 633{
621 struct input_dev *idev = &(ati_remote->idev); 634 struct input_dev *idev = ati_remote->idev;
622 int i; 635 int i;
623 636
624 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 637 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
@@ -637,7 +650,7 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
637 idev->phys = ati_remote->phys; 650 idev->phys = ati_remote->phys;
638 651
639 usb_to_input_id(ati_remote->udev, &idev->id); 652 usb_to_input_id(ati_remote->udev, &idev->id);
640 idev->dev = &ati_remote->udev->dev; 653 idev->cdev.dev = &ati_remote->udev->dev;
641} 654}
642 655
643static int ati_remote_initialize(struct ati_remote *ati_remote) 656static int ati_remote_initialize(struct ati_remote *ati_remote)
@@ -674,7 +687,7 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)
674 (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { 687 (ati_remote_sendpacket(ati_remote, 0x8007, init2))) {
675 dev_err(&ati_remote->interface->dev, 688 dev_err(&ati_remote->interface->dev,
676 "Initializing ati_remote hardware failed.\n"); 689 "Initializing ati_remote hardware failed.\n");
677 return 1; 690 return -EIO;
678 } 691 }
679 692
680 return 0; 693 return 0;
@@ -686,95 +699,83 @@ static int ati_remote_initialize(struct ati_remote *ati_remote)
686static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id) 699static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id)
687{ 700{
688 struct usb_device *udev = interface_to_usbdev(interface); 701 struct usb_device *udev = interface_to_usbdev(interface);
689 struct ati_remote *ati_remote = NULL; 702 struct usb_host_interface *iface_host = interface->cur_altsetting;
690 struct usb_host_interface *iface_host; 703 struct usb_endpoint_descriptor *endpoint_in, *endpoint_out;
691 int retval = -ENOMEM; 704 struct ati_remote *ati_remote;
692 char path[64]; 705 struct input_dev *input_dev;
693 706 int err = -ENOMEM;
694 /* Allocate and clear an ati_remote struct */
695 if (!(ati_remote = kmalloc(sizeof (struct ati_remote), GFP_KERNEL)))
696 return -ENOMEM;
697 memset(ati_remote, 0x00, sizeof (struct ati_remote));
698 707
699 iface_host = interface->cur_altsetting;
700 if (iface_host->desc.bNumEndpoints != 2) { 708 if (iface_host->desc.bNumEndpoints != 2) {
701 err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__); 709 err("%s: Unexpected desc.bNumEndpoints\n", __FUNCTION__);
702 retval = -ENODEV; 710 return -ENODEV;
703 goto error;
704 } 711 }
705 712
706 ati_remote->endpoint_in = &(iface_host->endpoint[0].desc); 713 endpoint_in = &iface_host->endpoint[0].desc;
707 ati_remote->endpoint_out = &(iface_host->endpoint[1].desc); 714 endpoint_out = &iface_host->endpoint[1].desc;
708 ati_remote->udev = udev;
709 ati_remote->interface = interface;
710 715
711 if (!(ati_remote->endpoint_in->bEndpointAddress & 0x80)) { 716 if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) {
712 err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); 717 err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__);
713 retval = -ENODEV; 718 return -ENODEV;
714 goto error;
715 } 719 }
716 if ((ati_remote->endpoint_in->bmAttributes & 3) != 3) { 720 if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) {
717 err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__); 721 err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__);
718 retval = -ENODEV; 722 return -ENODEV;
719 goto error;
720 } 723 }
721 if (le16_to_cpu(ati_remote->endpoint_in->wMaxPacketSize) == 0) { 724 if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) {
722 err("%s: endpoint_in message size==0? \n", __FUNCTION__); 725 err("%s: endpoint_in message size==0? \n", __FUNCTION__);
723 retval = -ENODEV; 726 return -ENODEV;
724 goto error;
725 } 727 }
726 728
727 /* Allocate URB buffers, URBs */ 729 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
728 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 730 input_dev = input_allocate_device();
729 &ati_remote->inbuf_dma); 731 if (!ati_remote || !input_dev)
730 if (!ati_remote->inbuf) 732 goto fail1;
731 goto error;
732 733
733 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 734 /* Allocate URB buffers, URBs */
734 &ati_remote->outbuf_dma); 735 if (ati_remote_alloc_buffers(udev, ati_remote))
735 if (!ati_remote->outbuf) 736 goto fail2;
736 goto error;
737 737
738 ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); 738 ati_remote->endpoint_in = endpoint_in;
739 if (!ati_remote->irq_urb) 739 ati_remote->endpoint_out = endpoint_out;
740 goto error; 740 ati_remote->udev = udev;
741 ati_remote->idev = input_dev;
742 ati_remote->interface = interface;
741 743
742 ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); 744 usb_make_path(udev, ati_remote->phys, sizeof(ati_remote->phys));
743 if (!ati_remote->out_urb) 745 strlcpy(ati_remote->phys, "/input0", sizeof(ati_remote->phys));
744 goto error;
745 746
746 usb_make_path(udev, path, NAME_BUFSIZE);
747 sprintf(ati_remote->phys, "%s/input%d", path, ATI_INPUTNUM);
748 if (udev->manufacturer) 747 if (udev->manufacturer)
749 strcat(ati_remote->name, udev->manufacturer); 748 strlcpy(ati_remote->name, udev->manufacturer, sizeof(ati_remote->name));
750 749
751 if (udev->product) 750 if (udev->product)
752 sprintf(ati_remote->name, "%s %s", ati_remote->name, udev->product); 751 snprintf(ati_remote->name, sizeof(ati_remote->name),
752 "%s %s", ati_remote->name, udev->product);
753 753
754 if (!strlen(ati_remote->name)) 754 if (!strlen(ati_remote->name))
755 sprintf(ati_remote->name, DRIVER_DESC "(%04x,%04x)", 755 snprintf(ati_remote->name, sizeof(ati_remote->name),
756 DRIVER_DESC "(%04x,%04x)",
756 le16_to_cpu(ati_remote->udev->descriptor.idVendor), 757 le16_to_cpu(ati_remote->udev->descriptor.idVendor),
757 le16_to_cpu(ati_remote->udev->descriptor.idProduct)); 758 le16_to_cpu(ati_remote->udev->descriptor.idProduct));
758 759
760 ati_remote_input_init(ati_remote);
761
759 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ 762 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */
760 retval = ati_remote_initialize(ati_remote); 763 err = ati_remote_initialize(ati_remote);
761 if (retval) 764 if (err)
762 goto error; 765 goto fail3;
763 766
764 /* Set up and register input device */ 767 /* Set up and register input device */
765 ati_remote_input_init(ati_remote); 768 input_register_device(ati_remote->idev);
766 input_register_device(&ati_remote->idev);
767
768 dev_info(&ati_remote->interface->dev, "Input registered: %s on %s\n",
769 ati_remote->name, path);
770 769
771 usb_set_intfdata(interface, ati_remote); 770 usb_set_intfdata(interface, ati_remote);
771 return 0;
772 772
773error: 773fail3: usb_kill_urb(ati_remote->irq_urb);
774 if (retval) 774 usb_kill_urb(ati_remote->out_urb);
775 ati_remote_delete(ati_remote); 775fail2: ati_remote_free_buffers(ati_remote);
776 776fail1: input_free_device(input_dev);
777 return retval; 777 kfree(ati_remote);
778 return err;
778} 779}
779 780
780/* 781/*
@@ -791,7 +792,11 @@ static void ati_remote_disconnect(struct usb_interface *interface)
791 return; 792 return;
792 } 793 }
793 794
794 ati_remote_delete(ati_remote); 795 usb_kill_urb(ati_remote->irq_urb);
796 usb_kill_urb(ati_remote->out_urb);
797 input_unregister_device(ati_remote->idev);
798 ati_remote_free_buffers(ati_remote);
799 kfree(ati_remote);
795} 800}
796 801
797/* 802/*
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 41f92b924761..79ddce4555ab 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1619,8 +1619,8 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1619 struct hid_descriptor *hdesc; 1619 struct hid_descriptor *hdesc;
1620 struct hid_device *hid; 1620 struct hid_device *hid;
1621 unsigned quirks = 0, rsize = 0; 1621 unsigned quirks = 0, rsize = 0;
1622 char *buf, *rdesc; 1622 char *rdesc;
1623 int n, insize = 0; 1623 int n, len, insize = 0;
1624 1624
1625 for (n = 0; hid_blacklist[n].idVendor; n++) 1625 for (n = 0; hid_blacklist[n].idVendor; n++)
1626 if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) && 1626 if ((hid_blacklist[n].idVendor == le16_to_cpu(dev->descriptor.idVendor)) &&
@@ -1630,10 +1630,11 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1630 if (quirks & HID_QUIRK_IGNORE) 1630 if (quirks & HID_QUIRK_IGNORE)
1631 return NULL; 1631 return NULL;
1632 1632
1633 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) && ((!interface->desc.bNumEndpoints) || 1633 if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
1634 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) { 1634 (!interface->desc.bNumEndpoints ||
1635 dbg("class descriptor not present\n"); 1635 usb_get_extra_descriptor(&interface->endpoint[0], HID_DT_HID, &hdesc))) {
1636 return NULL; 1636 dbg("class descriptor not present\n");
1637 return NULL;
1637 } 1638 }
1638 1639
1639 for (n = 0; n < hdesc->bNumDescriptors; n++) 1640 for (n = 0; n < hdesc->bNumDescriptors; n++)
@@ -1749,38 +1750,43 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1749 1750
1750 hid->name[0] = 0; 1751 hid->name[0] = 0;
1751 1752
1752 if (!(buf = kmalloc(64, GFP_KERNEL))) 1753 if (dev->manufacturer)
1753 goto fail; 1754 strlcpy(hid->name, dev->manufacturer, sizeof(hid->name));
1755
1756 if (dev->product) {
1757 if (dev->manufacturer)
1758 strlcat(hid->name, " ", sizeof(hid->name));
1759 strlcat(hid->name, dev->product, sizeof(hid->name));
1760 }
1754 1761
1755 if (dev->manufacturer) { 1762 if (!strlen(hid->name))
1756 strcat(hid->name, dev->manufacturer); 1763 snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
1757 if (dev->product) 1764 le16_to_cpu(dev->descriptor.idVendor),
1758 snprintf(hid->name, 64, "%s %s", hid->name, dev->product); 1765 le16_to_cpu(dev->descriptor.idProduct));
1759 } else if (dev->product) { 1766
1760 snprintf(hid->name, 128, "%s", dev->product); 1767 usb_make_path(dev, hid->phys, sizeof(hid->phys));
1761 } else 1768 strlcat(hid->phys, "/input", sizeof(hid->phys));
1762 snprintf(hid->name, 128, "%04x:%04x", 1769 len = strlen(hid->phys);
1763 le16_to_cpu(dev->descriptor.idVendor), 1770 if (len < sizeof(hid->phys) - 1)
1764 le16_to_cpu(dev->descriptor.idProduct)); 1771 snprintf(hid->phys + len, sizeof(hid->phys) - len,
1765 1772 "%d", intf->altsetting[0].desc.bInterfaceNumber);
1766 usb_make_path(dev, buf, 64);
1767 snprintf(hid->phys, 64, "%s/input%d", buf,
1768 intf->altsetting[0].desc.bInterfaceNumber);
1769 1773
1770 if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0) 1774 if (usb_string(dev, dev->descriptor.iSerialNumber, hid->uniq, 64) <= 0)
1771 hid->uniq[0] = 0; 1775 hid->uniq[0] = 0;
1772 1776
1773 kfree(buf);
1774
1775 hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL); 1777 hid->urbctrl = usb_alloc_urb(0, GFP_KERNEL);
1776 if (!hid->urbctrl) 1778 if (!hid->urbctrl)
1777 goto fail; 1779 goto fail;
1780
1778 usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr, 1781 usb_fill_control_urb(hid->urbctrl, dev, 0, (void *) hid->cr,
1779 hid->ctrlbuf, 1, hid_ctrl, hid); 1782 hid->ctrlbuf, 1, hid_ctrl, hid);
1780 hid->urbctrl->setup_dma = hid->cr_dma; 1783 hid->urbctrl->setup_dma = hid->cr_dma;
1781 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma; 1784 hid->urbctrl->transfer_dma = hid->ctrlbuf_dma;
1782 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP); 1785 hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
1783 1786
1787 /* May be needed for some devices */
1788 usb_clear_halt(hid->dev, hid->urbin->pipe);
1789
1784 return hid; 1790 return hid;
1785 1791
1786fail: 1792fail:
@@ -1884,7 +1890,6 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1884 struct hid_device *hid = usb_get_intfdata (intf); 1890 struct hid_device *hid = usb_get_intfdata (intf);
1885 1891
1886 usb_kill_urb(hid->urbin); 1892 usb_kill_urb(hid->urbin);
1887 intf->dev.power.power_state = PMSG_SUSPEND;
1888 dev_dbg(&intf->dev, "suspend\n"); 1893 dev_dbg(&intf->dev, "suspend\n");
1889 return 0; 1894 return 0;
1890} 1895}
@@ -1894,7 +1899,6 @@ static int hid_resume(struct usb_interface *intf)
1894 struct hid_device *hid = usb_get_intfdata (intf); 1899 struct hid_device *hid = usb_get_intfdata (intf);
1895 int status; 1900 int status;
1896 1901
1897 intf->dev.power.power_state = PMSG_ON;
1898 if (hid->open) 1902 if (hid->open)
1899 status = usb_submit_urb(hid->urbin, GFP_NOIO); 1903 status = usb_submit_urb(hid->urbin, GFP_NOIO);
1900 else 1904 else
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 0b6452248a39..9ff25eb520a6 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -76,8 +76,8 @@ static struct {
76static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, 76static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
77 struct hid_usage *usage) 77 struct hid_usage *usage)
78{ 78{
79 struct input_dev *input = &hidinput->input; 79 struct input_dev *input = hidinput->input;
80 struct hid_device *device = hidinput->input.private; 80 struct hid_device *device = input->private;
81 int max = 0, code; 81 int max = 0, code;
82 unsigned long *bit = NULL; 82 unsigned long *bit = NULL;
83 83
@@ -461,7 +461,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
461 461
462 if (!field->hidinput) 462 if (!field->hidinput)
463 return; 463 return;
464 input = &field->hidinput->input; 464
465 input = field->hidinput->input;
465 466
466 input_regs(input, regs); 467 input_regs(input, regs);
467 468
@@ -533,13 +534,10 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
533 534
534void hidinput_report_event(struct hid_device *hid, struct hid_report *report) 535void hidinput_report_event(struct hid_device *hid, struct hid_report *report)
535{ 536{
536 struct list_head *lh;
537 struct hid_input *hidinput; 537 struct hid_input *hidinput;
538 538
539 list_for_each (lh, &hid->inputs) { 539 list_for_each_entry(hidinput, &hid->inputs, list)
540 hidinput = list_entry(lh, struct hid_input, list); 540 input_sync(hidinput->input);
541 input_sync(&hidinput->input);
542 }
543} 541}
544 542
545static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field) 543static int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field)
@@ -604,6 +602,7 @@ int hidinput_connect(struct hid_device *hid)
604 struct usb_device *dev = hid->dev; 602 struct usb_device *dev = hid->dev;
605 struct hid_report *report; 603 struct hid_report *report;
606 struct hid_input *hidinput = NULL; 604 struct hid_input *hidinput = NULL;
605 struct input_dev *input_dev;
607 int i, j, k; 606 int i, j, k;
608 607
609 INIT_LIST_HEAD(&hid->inputs); 608 INIT_LIST_HEAD(&hid->inputs);
@@ -624,25 +623,28 @@ int hidinput_connect(struct hid_device *hid)
624 continue; 623 continue;
625 624
626 if (!hidinput) { 625 if (!hidinput) {
627 hidinput = kmalloc(sizeof(*hidinput), GFP_KERNEL); 626 hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL);
628 if (!hidinput) { 627 input_dev = input_allocate_device();
628 if (!hidinput || !input_dev) {
629 kfree(hidinput);
630 input_free_device(input_dev);
629 err("Out of memory during hid input probe"); 631 err("Out of memory during hid input probe");
630 return -1; 632 return -1;
631 } 633 }
632 memset(hidinput, 0, sizeof(*hidinput));
633 634
634 list_add_tail(&hidinput->list, &hid->inputs); 635 input_dev->private = hid;
636 input_dev->event = hidinput_input_event;
637 input_dev->open = hidinput_open;
638 input_dev->close = hidinput_close;
635 639
636 hidinput->input.private = hid; 640 input_dev->name = hid->name;
637 hidinput->input.event = hidinput_input_event; 641 input_dev->phys = hid->phys;
638 hidinput->input.open = hidinput_open; 642 input_dev->uniq = hid->uniq;
639 hidinput->input.close = hidinput_close; 643 usb_to_input_id(dev, &input_dev->id);
644 input_dev->cdev.dev = &hid->intf->dev;
640 645
641 hidinput->input.name = hid->name; 646 hidinput->input = input_dev;
642 hidinput->input.phys = hid->phys; 647 list_add_tail(&hidinput->list, &hid->inputs);
643 hidinput->input.uniq = hid->uniq;
644 usb_to_input_id(dev, &hidinput->input.id);
645 hidinput->input.dev = &hid->intf->dev;
646 } 648 }
647 649
648 for (i = 0; i < report->maxfield; i++) 650 for (i = 0; i < report->maxfield; i++)
@@ -657,7 +659,7 @@ int hidinput_connect(struct hid_device *hid)
657 * UGCI) cram a lot of unrelated inputs into the 659 * UGCI) cram a lot of unrelated inputs into the
658 * same interface. */ 660 * same interface. */
659 hidinput->report = report; 661 hidinput->report = report;
660 input_register_device(&hidinput->input); 662 input_register_device(hidinput->input);
661 hidinput = NULL; 663 hidinput = NULL;
662 } 664 }
663 } 665 }
@@ -667,7 +669,7 @@ int hidinput_connect(struct hid_device *hid)
667 * only useful in this case, and not for multi-input quirks. */ 669 * only useful in this case, and not for multi-input quirks. */
668 if (hidinput) { 670 if (hidinput) {
669 hid_ff_init(hid); 671 hid_ff_init(hid);
670 input_register_device(&hidinput->input); 672 input_register_device(hidinput->input);
671 } 673 }
672 674
673 return 0; 675 return 0;
@@ -675,13 +677,11 @@ int hidinput_connect(struct hid_device *hid)
675 677
676void hidinput_disconnect(struct hid_device *hid) 678void hidinput_disconnect(struct hid_device *hid)
677{ 679{
678 struct list_head *lh, *next; 680 struct hid_input *hidinput, *next;
679 struct hid_input *hidinput;
680 681
681 list_for_each_safe(lh, next, &hid->inputs) { 682 list_for_each_entry_safe(hidinput, next, &hid->inputs, list) {
682 hidinput = list_entry(lh, struct hid_input, list);
683 input_unregister_device(&hidinput->input);
684 list_del(&hidinput->list); 683 list_del(&hidinput->list);
684 input_unregister_device(hidinput->input);
685 kfree(hidinput); 685 kfree(hidinput);
686 } 686 }
687} 687}
diff --git a/drivers/usb/input/hid-lgff.c b/drivers/usb/input/hid-lgff.c
index 0c4c77aa31ea..f82c9c9e5d51 100644
--- a/drivers/usb/input/hid-lgff.c
+++ b/drivers/usb/input/hid-lgff.c
@@ -255,22 +255,19 @@ static void hid_lgff_input_init(struct hid_device* hid)
255 u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor); 255 u16 idVendor = le16_to_cpu(hid->dev->descriptor.idVendor);
256 u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct); 256 u16 idProduct = le16_to_cpu(hid->dev->descriptor.idProduct);
257 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 257 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
258 struct input_dev *input_dev = hidinput->input;
258 259
259 while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct)) 260 while (dev->idVendor && (idVendor != dev->idVendor || idProduct != dev->idProduct))
260 dev++; 261 dev++;
261 262
262 ff = dev->ff; 263 for (ff = dev->ff; *ff >= 0; ff++)
264 set_bit(*ff, input_dev->ffbit);
263 265
264 while (*ff >= 0) { 266 input_dev->upload_effect = hid_lgff_upload_effect;
265 set_bit(*ff, hidinput->input.ffbit); 267 input_dev->flush = hid_lgff_flush;
266 ++ff;
267 }
268
269 hidinput->input.upload_effect = hid_lgff_upload_effect;
270 hidinput->input.flush = hid_lgff_flush;
271 268
272 set_bit(EV_FF, hidinput->input.evbit); 269 set_bit(EV_FF, input_dev->evbit);
273 hidinput->input.ff_effects_max = LGFF_EFFECTS; 270 input_dev->ff_effects_max = LGFF_EFFECTS;
274} 271}
275 272
276static void hid_lgff_exit(struct hid_device* hid) 273static void hid_lgff_exit(struct hid_device* hid)
diff --git a/drivers/usb/input/hid-tmff.c b/drivers/usb/input/hid-tmff.c
index 8f6a0a6f94a9..023fd5ac31c8 100644
--- a/drivers/usb/input/hid-tmff.c
+++ b/drivers/usb/input/hid-tmff.c
@@ -111,6 +111,7 @@ int hid_tmff_init(struct hid_device *hid)
111 struct tmff_device *private; 111 struct tmff_device *private;
112 struct list_head *pos; 112 struct list_head *pos;
113 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); 113 struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
114 struct input_dev *input_dev = hidinput->input;
114 115
115 private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL); 116 private = kmalloc(sizeof(struct tmff_device), GFP_KERNEL);
116 if (!private) 117 if (!private)
@@ -155,7 +156,7 @@ int hid_tmff_init(struct hid_device *hid)
155 private->report = report; 156 private->report = report;
156 private->rumble = field; 157 private->rumble = field;
157 158
158 set_bit(FF_RUMBLE, hidinput->input.ffbit); 159 set_bit(FF_RUMBLE, input_dev->ffbit);
159 break; 160 break;
160 161
161 default: 162 default:
@@ -164,11 +165,11 @@ int hid_tmff_init(struct hid_device *hid)
164 } 165 }
165 166
166 /* Fallthrough to here only when a valid usage is found */ 167 /* Fallthrough to here only when a valid usage is found */
167 hidinput->input.upload_effect = hid_tmff_upload_effect; 168 input_dev->upload_effect = hid_tmff_upload_effect;
168 hidinput->input.flush = hid_tmff_flush; 169 input_dev->flush = hid_tmff_flush;
169 170
170 set_bit(EV_FF, hidinput->input.evbit); 171 set_bit(EV_FF, input_dev->evbit);
171 hidinput->input.ff_effects_max = TMFF_EFFECTS; 172 input_dev->ff_effects_max = TMFF_EFFECTS;
172 } 173 }
173 } 174 }
174 175
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index ec2412c42f1e..ee48a2276104 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -371,7 +371,7 @@ struct hid_control_fifo {
371struct hid_input { 371struct hid_input {
372 struct list_head list; 372 struct list_head list;
373 struct hid_report *report; 373 struct hid_report *report;
374 struct input_dev input; 374 struct input_dev *input;
375}; 375};
376 376
377struct hid_device { /* device report descriptor */ 377struct hid_device { /* device report descriptor */
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index d32427818af7..440377c7a0da 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -732,9 +732,8 @@ static struct file_operations hiddev_fops = {
732}; 732};
733 733
734static struct usb_class_driver hiddev_class = { 734static struct usb_class_driver hiddev_class = {
735 .name = "usb/hid/hiddev%d", 735 .name = "hiddev%d",
736 .fops = &hiddev_fops, 736 .fops = &hiddev_fops,
737 .mode = S_IFCHR | S_IRUGO | S_IWUSR,
738 .minor_base = HIDDEV_MINOR_BASE, 737 .minor_base = HIDDEV_MINOR_BASE,
739}; 738};
740 739
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index becb87efb869..3b581853cf10 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -73,7 +73,7 @@ MODULE_LICENSE( DRIVER_LICENSE );
73 73
74struct itmtouch_dev { 74struct itmtouch_dev {
75 struct usb_device *usbdev; /* usb device */ 75 struct usb_device *usbdev; /* usb device */
76 struct input_dev inputdev; /* input device */ 76 struct input_dev *inputdev; /* input device */
77 struct urb *readurb; /* urb */ 77 struct urb *readurb; /* urb */
78 char rbuf[ITM_BUFSIZE]; /* data */ 78 char rbuf[ITM_BUFSIZE]; /* data */
79 int users; 79 int users;
@@ -88,9 +88,9 @@ static struct usb_device_id itmtouch_ids [] = {
88 88
89static void itmtouch_irq(struct urb *urb, struct pt_regs *regs) 89static void itmtouch_irq(struct urb *urb, struct pt_regs *regs)
90{ 90{
91 struct itmtouch_dev * itmtouch = urb->context; 91 struct itmtouch_dev *itmtouch = urb->context;
92 unsigned char *data = urb->transfer_buffer; 92 unsigned char *data = urb->transfer_buffer;
93 struct input_dev *dev = &itmtouch->inputdev; 93 struct input_dev *dev = itmtouch->inputdev;
94 int retval; 94 int retval;
95 95
96 switch (urb->status) { 96 switch (urb->status) {
@@ -156,49 +156,62 @@ static void itmtouch_close(struct input_dev *input)
156static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id) 156static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id *id)
157{ 157{
158 struct itmtouch_dev *itmtouch; 158 struct itmtouch_dev *itmtouch;
159 struct input_dev *input_dev;
159 struct usb_host_interface *interface; 160 struct usb_host_interface *interface;
160 struct usb_endpoint_descriptor *endpoint; 161 struct usb_endpoint_descriptor *endpoint;
161 struct usb_device *udev = interface_to_usbdev(intf); 162 struct usb_device *udev = interface_to_usbdev(intf);
162 unsigned int pipe; 163 unsigned int pipe;
163 unsigned int maxp; 164 unsigned int maxp;
164 char path[PATH_SIZE];
165 165
166 interface = intf->cur_altsetting; 166 interface = intf->cur_altsetting;
167 endpoint = &interface->endpoint[0].desc; 167 endpoint = &interface->endpoint[0].desc;
168 168
169 if (!(itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL))) { 169 itmtouch = kzalloc(sizeof(struct itmtouch_dev), GFP_KERNEL);
170 input_dev = input_allocate_device();
171 if (!itmtouch || !input_dev) {
170 err("%s - Out of memory.", __FUNCTION__); 172 err("%s - Out of memory.", __FUNCTION__);
171 return -ENOMEM; 173 goto fail;
172 } 174 }
173 175
174 itmtouch->usbdev = udev; 176 itmtouch->usbdev = udev;
177 itmtouch->inputdev = input_dev;
175 178
176 itmtouch->inputdev.private = itmtouch; 179 if (udev->manufacturer)
177 itmtouch->inputdev.open = itmtouch_open; 180 strlcpy(itmtouch->name, udev->manufacturer, sizeof(itmtouch->name));
178 itmtouch->inputdev.close = itmtouch_close;
179 181
180 usb_make_path(udev, path, PATH_SIZE); 182 if (udev->product) {
181 183 if (udev->manufacturer)
182 itmtouch->inputdev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 184 strlcat(itmtouch->name, " ", sizeof(itmtouch->name));
183 itmtouch->inputdev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 185 strlcat(itmtouch->name, udev->product, sizeof(itmtouch->name));
184 itmtouch->inputdev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 186 }
185
186 itmtouch->inputdev.name = itmtouch->name;
187 itmtouch->inputdev.phys = itmtouch->phys;
188 usb_to_input_id(udev, &itmtouch->inputdev.id);
189 itmtouch->inputdev.dev = &intf->dev;
190 187
191 if (!strlen(itmtouch->name)) 188 if (!strlen(itmtouch->name))
192 sprintf(itmtouch->name, "USB ITM touchscreen"); 189 sprintf(itmtouch->name, "USB ITM touchscreen");
193 190
191 usb_make_path(udev, itmtouch->phys, sizeof(itmtouch->phys));
192 strlcpy(itmtouch->phys, "/input0", sizeof(itmtouch->phys));
193
194 input_dev->name = itmtouch->name;
195 input_dev->phys = itmtouch->phys;
196 usb_to_input_id(udev, &input_dev->id);
197 input_dev->cdev.dev = &intf->dev;
198 input_dev->private = itmtouch;
199
200 input_dev->open = itmtouch_open;
201 input_dev->close = itmtouch_close;
202
203 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
204 input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
205 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
206
194 /* device limits */ 207 /* device limits */
195 /* as specified by the ITM datasheet, X and Y are 12bit, 208 /* as specified by the ITM datasheet, X and Y are 12bit,
196 * Z (pressure) is 8 bit. However, the fields are defined up 209 * Z (pressure) is 8 bit. However, the fields are defined up
197 * to 14 bits for future possible expansion. 210 * to 14 bits for future possible expansion.
198 */ 211 */
199 input_set_abs_params(&itmtouch->inputdev, ABS_X, 0, 0x0FFF, 2, 0); 212 input_set_abs_params(input_dev, ABS_X, 0, 0x0FFF, 2, 0);
200 input_set_abs_params(&itmtouch->inputdev, ABS_Y, 0, 0x0FFF, 2, 0); 213 input_set_abs_params(input_dev, ABS_Y, 0, 0x0FFF, 2, 0);
201 input_set_abs_params(&itmtouch->inputdev, ABS_PRESSURE, 0, 0xFF, 2, 0); 214 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xFF, 2, 0);
202 215
203 /* initialise the URB so we can read from the transport stream */ 216 /* initialise the URB so we can read from the transport stream */
204 pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress); 217 pipe = usb_rcvintpipe(itmtouch->usbdev, endpoint->bEndpointAddress);
@@ -208,22 +221,23 @@ static int itmtouch_probe(struct usb_interface *intf, const struct usb_device_id
208 maxp = ITM_BUFSIZE; 221 maxp = ITM_BUFSIZE;
209 222
210 itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL); 223 itmtouch->readurb = usb_alloc_urb(0, GFP_KERNEL);
211
212 if (!itmtouch->readurb) { 224 if (!itmtouch->readurb) {
213 dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__); 225 dbg("%s - usb_alloc_urb failed: itmtouch->readurb", __FUNCTION__);
214 kfree(itmtouch); 226 goto fail;
215 return -ENOMEM;
216 } 227 }
217 228
218 usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf, 229 usb_fill_int_urb(itmtouch->readurb, itmtouch->usbdev, pipe, itmtouch->rbuf,
219 maxp, itmtouch_irq, itmtouch, endpoint->bInterval); 230 maxp, itmtouch_irq, itmtouch, endpoint->bInterval);
220 231
221 input_register_device(&itmtouch->inputdev); 232 input_register_device(itmtouch->inputdev);
222 233
223 printk(KERN_INFO "itmtouch: %s registered on %s\n", itmtouch->name, path);
224 usb_set_intfdata(intf, itmtouch); 234 usb_set_intfdata(intf, itmtouch);
225 235
226 return 0; 236 return 0;
237
238 fail: input_free_device(input_dev);
239 kfree(itmtouch);
240 return -ENOMEM;
227} 241}
228 242
229static void itmtouch_disconnect(struct usb_interface *intf) 243static void itmtouch_disconnect(struct usb_interface *intf)
@@ -233,7 +247,7 @@ static void itmtouch_disconnect(struct usb_interface *intf)
233 usb_set_intfdata(intf, NULL); 247 usb_set_intfdata(intf, NULL);
234 248
235 if (itmtouch) { 249 if (itmtouch) {
236 input_unregister_device(&itmtouch->inputdev); 250 input_unregister_device(itmtouch->inputdev);
237 usb_kill_urb(itmtouch->readurb); 251 usb_kill_urb(itmtouch->readurb);
238 usb_free_urb(itmtouch->readurb); 252 usb_free_urb(itmtouch->readurb);
239 kfree(itmtouch); 253 kfree(itmtouch);
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index b6f6ac8d9c2f..a248664b5d1d 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(kb_pressure_click, "pressure threshold for clicks");
34struct kbtab { 34struct kbtab {
35 signed char *data; 35 signed char *data;
36 dma_addr_t data_dma; 36 dma_addr_t data_dma;
37 struct input_dev dev; 37 struct input_dev *dev;
38 struct usb_device *usbdev; 38 struct usb_device *usbdev;
39 struct urb *irq; 39 struct urb *irq;
40 int x, y; 40 int x, y;
@@ -48,7 +48,7 @@ static void kbtab_irq(struct urb *urb, struct pt_regs *regs)
48{ 48{
49 struct kbtab *kbtab = urb->context; 49 struct kbtab *kbtab = urb->context;
50 unsigned char *data = kbtab->data; 50 unsigned char *data = kbtab->data;
51 struct input_dev *dev = &kbtab->dev; 51 struct input_dev *dev = kbtab->dev;
52 int retval; 52 int retval;
53 53
54 switch (urb->status) { 54 switch (urb->status) {
@@ -124,53 +124,43 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
124 struct usb_device *dev = interface_to_usbdev(intf); 124 struct usb_device *dev = interface_to_usbdev(intf);
125 struct usb_endpoint_descriptor *endpoint; 125 struct usb_endpoint_descriptor *endpoint;
126 struct kbtab *kbtab; 126 struct kbtab *kbtab;
127 char path[64]; 127 struct input_dev *input_dev;
128 128
129 if (!(kbtab = kmalloc(sizeof(struct kbtab), GFP_KERNEL))) 129 kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
130 return -ENOMEM; 130 input_dev = input_allocate_device();
131 memset(kbtab, 0, sizeof(struct kbtab)); 131 if (!kbtab || !input_dev)
132 goto fail1;
132 133
133 kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma); 134 kbtab->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &kbtab->data_dma);
134 if (!kbtab->data) { 135 if (!kbtab->data)
135 kfree(kbtab); 136 goto fail1;
136 return -ENOMEM;
137 }
138 137
139 kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); 138 kbtab->irq = usb_alloc_urb(0, GFP_KERNEL);
140 if (!kbtab->irq) { 139 if (!kbtab->irq)
141 usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma); 140 goto fail2;
142 kfree(kbtab);
143 return -ENOMEM;
144 }
145
146 kbtab->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC);
147 kbtab->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
148
149 kbtab->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
150
151 kbtab->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH);
152 141
153 kbtab->dev.mscbit[0] |= BIT(MSC_SERIAL); 142 kbtab->usbdev = dev;
154 143 kbtab->dev = input_dev;
155 kbtab->dev.absmax[ABS_X] = 0x2000;
156 kbtab->dev.absmax[ABS_Y] = 0x1750;
157 kbtab->dev.absmax[ABS_PRESSURE] = 0xff;
158 144
159 kbtab->dev.absfuzz[ABS_X] = 4; 145 usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys));
160 kbtab->dev.absfuzz[ABS_Y] = 4; 146 strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys));
161 147
162 kbtab->dev.private = kbtab; 148 input_dev->name = "KB Gear Tablet";
163 kbtab->dev.open = kbtab_open; 149 input_dev->phys = kbtab->phys;
164 kbtab->dev.close = kbtab_close; 150 usb_to_input_id(dev, &input_dev->id);
151 input_dev->cdev.dev = &intf->dev;
152 input_dev->private = kbtab;
165 153
166 usb_make_path(dev, path, 64); 154 input_dev->open = kbtab_open;
167 sprintf(kbtab->phys, "%s/input0", path); 155 input_dev->close = kbtab_close;
168 156
169 kbtab->dev.name = "KB Gear Tablet"; 157 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_MSC);
170 kbtab->dev.phys = kbtab->phys; 158 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
171 usb_to_input_id(dev, &kbtab->dev.id); 159 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH);
172 kbtab->dev.dev = &intf->dev; 160 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
173 kbtab->usbdev = dev; 161 input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0);
162 input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0);
163 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0);
174 164
175 endpoint = &intf->cur_altsetting->endpoint[0].desc; 165 endpoint = &intf->cur_altsetting->endpoint[0].desc;
176 166
@@ -181,23 +171,25 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
181 kbtab->irq->transfer_dma = kbtab->data_dma; 171 kbtab->irq->transfer_dma = kbtab->data_dma;
182 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 172 kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
183 173
184 input_register_device(&kbtab->dev); 174 input_register_device(kbtab->dev);
185
186 printk(KERN_INFO "input: KB Gear Tablet on %s\n", path);
187 175
188 usb_set_intfdata(intf, kbtab); 176 usb_set_intfdata(intf, kbtab);
189
190 return 0; 177 return 0;
178
179fail2: usb_buffer_free(dev, 10, kbtab->data, kbtab->data_dma);
180fail1: input_free_device(input_dev);
181 kfree(kbtab);
182 return -ENOMEM;
191} 183}
192 184
193static void kbtab_disconnect(struct usb_interface *intf) 185static void kbtab_disconnect(struct usb_interface *intf)
194{ 186{
195 struct kbtab *kbtab = usb_get_intfdata (intf); 187 struct kbtab *kbtab = usb_get_intfdata(intf);
196 188
197 usb_set_intfdata(intf, NULL); 189 usb_set_intfdata(intf, NULL);
198 if (kbtab) { 190 if (kbtab) {
199 usb_kill_urb(kbtab->irq); 191 usb_kill_urb(kbtab->irq);
200 input_unregister_device(&kbtab->dev); 192 input_unregister_device(kbtab->dev);
201 usb_free_urb(kbtab->irq); 193 usb_free_urb(kbtab->irq);
202 usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma); 194 usb_buffer_free(interface_to_usbdev(intf), 10, kbtab->data, kbtab->data_dma);
203 kfree(kbtab); 195 kfree(kbtab);
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 99de1b33c07d..5b8d65f62abf 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -20,6 +20,7 @@
20#include <linux/moduleparam.h> 20#include <linux/moduleparam.h>
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/usb.h> 22#include <linux/usb.h>
23#include <linux/usb_input.h>
23 24
24#define DRIVER_VERSION "v0.1" 25#define DRIVER_VERSION "v0.1"
25#define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>" 26#define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>"
@@ -75,7 +76,7 @@ struct usb_keyspan {
75 char name[128]; 76 char name[128];
76 char phys[64]; 77 char phys[64];
77 struct usb_device* udev; 78 struct usb_device* udev;
78 struct input_dev input; 79 struct input_dev *input;
79 struct usb_interface* interface; 80 struct usb_interface* interface;
80 struct usb_endpoint_descriptor* in_endpoint; 81 struct usb_endpoint_descriptor* in_endpoint;
81 struct urb* irq_urb; 82 struct urb* irq_urb;
@@ -136,12 +137,11 @@ static struct usb_driver keyspan_driver;
136 */ 137 */
137static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/ 138static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/
138{ 139{
139 char codes[4*RECV_SIZE]; 140 char codes[4 * RECV_SIZE];
140 int i; 141 int i;
141 142
142 for (i = 0; i < RECV_SIZE; i++) { 143 for (i = 0; i < RECV_SIZE; i++)
143 snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]); 144 snprintf(codes + i * 3, 4, "%02x ", dev->in_buffer[i]);
144 }
145 145
146 dev_info(&dev->udev->dev, "%s\n", codes); 146 dev_info(&dev->udev->dev, "%s\n", codes);
147} 147}
@@ -153,7 +153,7 @@ static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/
153static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed) 153static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
154{ 154{
155 if (dev->data.bits_left >= bits_needed) 155 if (dev->data.bits_left >= bits_needed)
156 return(0); 156 return 0;
157 157
158 /* 158 /*
159 * Somehow we've missed the last message. The message will be repeated 159 * Somehow we've missed the last message. The message will be repeated
@@ -162,7 +162,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
162 if (dev->data.pos >= dev->data.len) { 162 if (dev->data.pos >= dev->data.len) {
163 dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", 163 dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n",
164 __FUNCTION__, dev->data.pos, dev->data.len); 164 __FUNCTION__, dev->data.pos, dev->data.len);
165 return(-1); 165 return -1;
166 } 166 }
167 167
168 /* Load as much as we can into the tester. */ 168 /* Load as much as we can into the tester. */
@@ -172,7 +172,7 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
172 dev->data.bits_left += 8; 172 dev->data.bits_left += 8;
173 } 173 }
174 174
175 return(0); 175 return 0;
176} 176}
177 177
178/* 178/*
@@ -311,10 +311,10 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs)
311 __FUNCTION__, message.system, message.button, message.toggle); 311 __FUNCTION__, message.system, message.button, message.toggle);
312 312
313 if (message.toggle != remote->toggle) { 313 if (message.toggle != remote->toggle) {
314 input_regs(&remote->input, regs); 314 input_regs(remote->input, regs);
315 input_report_key(&remote->input, keyspan_key_table[message.button], 1); 315 input_report_key(remote->input, keyspan_key_table[message.button], 1);
316 input_report_key(&remote->input, keyspan_key_table[message.button], 0); 316 input_report_key(remote->input, keyspan_key_table[message.button], 0);
317 input_sync(&remote->input); 317 input_sync(remote->input);
318 remote->toggle = message.toggle; 318 remote->toggle = message.toggle;
319 } 319 }
320 320
@@ -397,14 +397,9 @@ static int keyspan_open(struct input_dev *dev)
397{ 397{
398 struct usb_keyspan *remote = dev->private; 398 struct usb_keyspan *remote = dev->private;
399 399
400 if (remote->open++)
401 return 0;
402
403 remote->irq_urb->dev = remote->udev; 400 remote->irq_urb->dev = remote->udev;
404 if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) { 401 if (usb_submit_urb(remote->irq_urb, GFP_KERNEL))
405 remote->open--;
406 return -EIO; 402 return -EIO;
407 }
408 403
409 return 0; 404 return 0;
410} 405}
@@ -413,8 +408,26 @@ static void keyspan_close(struct input_dev *dev)
413{ 408{
414 struct usb_keyspan *remote = dev->private; 409 struct usb_keyspan *remote = dev->private;
415 410
416 if (!--remote->open) 411 usb_kill_urb(remote->irq_urb);
417 usb_kill_urb(remote->irq_urb); 412}
413
414static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_interface *iface)
415{
416
417 struct usb_endpoint_descriptor *endpoint;
418 int i;
419
420 for (i = 0; i < iface->desc.bNumEndpoints; ++i) {
421 endpoint = &iface->endpoint[i].desc;
422
423 if ((endpoint->bEndpointAddress & USB_DIR_IN) &&
424 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
425 /* we found our interrupt in endpoint */
426 return endpoint;
427 }
428 }
429
430 return NULL;
418} 431}
419 432
420/* 433/*
@@ -422,110 +435,78 @@ static void keyspan_close(struct input_dev *dev)
422 */ 435 */
423static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id) 436static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id)
424{ 437{
425 int i; 438 struct usb_device *udev = interface_to_usbdev(interface);
426 int retval = -ENOMEM;
427 char path[64];
428 char *buf;
429 struct usb_keyspan *remote = NULL;
430 struct usb_host_interface *iface_desc;
431 struct usb_endpoint_descriptor *endpoint; 439 struct usb_endpoint_descriptor *endpoint;
432 struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); 440 struct usb_keyspan *remote;
441 struct input_dev *input_dev;
442 int i, retval;
433 443
434 /* allocate memory for our device state and initialize it */ 444 endpoint = keyspan_get_in_endpoint(interface->cur_altsetting);
435 remote = kmalloc(sizeof(*remote), GFP_KERNEL); 445 if (!endpoint)
436 if (remote == NULL) { 446 return -ENODEV;
437 err("Out of memory\n"); 447
438 goto error; 448 remote = kzalloc(sizeof(*remote), GFP_KERNEL);
449 input_dev = input_allocate_device();
450 if (!remote || !input_dev) {
451 retval = -ENOMEM;
452 goto fail1;
439 } 453 }
440 memset(remote, 0x00, sizeof(*remote));
441 454
442 remote->udev = udev; 455 remote->udev = udev;
456 remote->input = input_dev;
443 remote->interface = interface; 457 remote->interface = interface;
458 remote->in_endpoint = endpoint;
444 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 459 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
445 460
446 /* set up the endpoint information */ 461 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);
447 /* use only the first in interrupt endpoint */ 462 if (!remote->in_buffer) {
448 iface_desc = interface->cur_altsetting; 463 retval = -ENOMEM;
449 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 464 goto fail1;
450 endpoint = &iface_desc->endpoint[i].desc;
451
452 if (!remote->in_endpoint &&
453 (endpoint->bEndpointAddress & USB_DIR_IN) &&
454 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
455 /* we found our interrupt in endpoint */
456 remote->in_endpoint = endpoint;
457
458 remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);
459 if (!remote->in_buffer) {
460 retval = -ENOMEM;
461 goto error;
462 }
463 }
464 }
465
466 if (!remote->in_endpoint) {
467 err("Could not find interrupt input endpoint.\n");
468 retval = -ENODEV;
469 goto error;
470 } 465 }
471 466
472 remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); 467 remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
473 if (!remote->irq_urb) { 468 if (!remote->irq_urb) {
474 err("Failed to allocate urb.\n");
475 retval = -ENOMEM; 469 retval = -ENOMEM;
476 goto error; 470 goto fail2;
477 } 471 }
478 472
479 retval = keyspan_setup(remote->udev); 473 retval = keyspan_setup(udev);
480 if (retval) { 474 if (retval) {
481 err("Failed to setup device.\n");
482 retval = -ENODEV; 475 retval = -ENODEV;
483 goto error; 476 goto fail3;
484 }
485
486 /*
487 * Setup the input system with the bits we are going to be reporting
488 */
489 remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
490 for (i = 0; i < 32; ++i) {
491 if (keyspan_key_table[i] != KEY_RESERVED) {
492 set_bit(keyspan_key_table[i], remote->input.keybit);
493 }
494 } 477 }
495 478
496 remote->input.private = remote; 479 if (udev->manufacturer)
497 remote->input.open = keyspan_open; 480 strlcpy(remote->name, udev->manufacturer, sizeof(remote->name));
498 remote->input.close = keyspan_close;
499
500 usb_make_path(remote->udev, path, 64);
501 sprintf(remote->phys, "%s/input0", path);
502 481
503 remote->input.name = remote->name; 482 if (udev->product) {
504 remote->input.phys = remote->phys; 483 if (udev->manufacturer)
505 remote->input.id.bustype = BUS_USB; 484 strlcat(remote->name, " ", sizeof(remote->name));
506 remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor); 485 strlcat(remote->name, udev->product, sizeof(remote->name));
507 remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct);
508 remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice);
509
510 if (!(buf = kmalloc(63, GFP_KERNEL))) {
511 usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
512 kfree(remote);
513 return -ENOMEM;
514 } 486 }
515 487
516 if (remote->udev->descriptor.iManufacturer && 488 if (!strlen(remote->name))
517 usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0) 489 snprintf(remote->name, sizeof(remote->name),
518 strcat(remote->name, buf); 490 "USB Keyspan Remote %04x:%04x",
491 le16_to_cpu(udev->descriptor.idVendor),
492 le16_to_cpu(udev->descriptor.idProduct));
519 493
520 if (remote->udev->descriptor.iProduct && 494 usb_make_path(udev, remote->phys, sizeof(remote->phys));
521 usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0) 495 strlcat(remote->phys, "/input0", sizeof(remote->phys));
522 sprintf(remote->name, "%s %s", remote->name, buf);
523 496
524 if (!strlen(remote->name)) 497 input_dev->name = remote->name;
525 sprintf(remote->name, "USB Keyspan Remote %04x:%04x", 498 input_dev->phys = remote->phys;
526 remote->input.id.vendor, remote->input.id.product); 499 usb_to_input_id(udev, &input_dev->id);
500 input_dev->cdev.dev = &interface->dev;
527 501
528 kfree(buf); 502 input_dev->evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
503 for (i = 0; i < ARRAY_SIZE(keyspan_key_table); i++)
504 if (keyspan_key_table[i] != KEY_RESERVED)
505 set_bit(keyspan_key_table[i], input_dev->keybit);
506
507 input_dev->private = remote;
508 input_dev->open = keyspan_open;
509 input_dev->close = keyspan_close;
529 510
530 /* 511 /*
531 * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open() 512 * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open()
@@ -538,27 +519,17 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
538 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 519 remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
539 520
540 /* we can register the device now, as it is ready */ 521 /* we can register the device now, as it is ready */
541 input_register_device(&remote->input); 522 input_register_device(remote->input);
542 523
543 /* save our data pointer in this interface device */ 524 /* save our data pointer in this interface device */
544 usb_set_intfdata(interface, remote); 525 usb_set_intfdata(interface, remote);
545 526
546 /* let the user know what node this device is now attached to */
547 info("connected: %s on %s", remote->name, path);
548 return 0; 527 return 0;
549 528
550error: 529 fail3: usb_free_urb(remote->irq_urb);
551 /* 530 fail2: usb_buffer_free(udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
552 * In case of error we need to clean up any allocated buffers 531 fail1: kfree(remote);
553 */ 532 input_free_device(input_dev);
554 if (remote->irq_urb)
555 usb_free_urb(remote->irq_urb);
556
557 if (remote->in_buffer)
558 usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
559
560 if (remote)
561 kfree(remote);
562 533
563 return retval; 534 return retval;
564} 535}
@@ -570,23 +541,16 @@ static void keyspan_disconnect(struct usb_interface *interface)
570{ 541{
571 struct usb_keyspan *remote; 542 struct usb_keyspan *remote;
572 543
573 /* prevent keyspan_open() from racing keyspan_disconnect() */
574 lock_kernel();
575
576 remote = usb_get_intfdata(interface); 544 remote = usb_get_intfdata(interface);
577 usb_set_intfdata(interface, NULL); 545 usb_set_intfdata(interface, NULL);
578 546
579 if (remote) { /* We have a valid driver structure so clean up everything we allocated. */ 547 if (remote) { /* We have a valid driver structure so clean up everything we allocated. */
580 input_unregister_device(&remote->input); 548 input_unregister_device(remote->input);
581 usb_kill_urb(remote->irq_urb); 549 usb_kill_urb(remote->irq_urb);
582 usb_free_urb(remote->irq_urb); 550 usb_free_urb(remote->irq_urb);
583 usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma); 551 usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
584 kfree(remote); 552 kfree(remote);
585 } 553 }
586
587 unlock_kernel();
588
589 info("USB Keyspan now disconnected");
590} 554}
591 555
592/* 556/*
diff --git a/drivers/usb/input/map_to_7segment.h b/drivers/usb/input/map_to_7segment.h
index 52ff27f15127..a424094d9fe2 100644
--- a/drivers/usb/input/map_to_7segment.h
+++ b/drivers/usb/input/map_to_7segment.h
@@ -79,7 +79,7 @@ struct seg7_conversion_map {
79 79
80static inline int map_to_seg7(struct seg7_conversion_map *map, int c) 80static inline int map_to_seg7(struct seg7_conversion_map *map, int c)
81{ 81{
82 return c & 0x7f ? map->table[c] : -EINVAL; 82 return c >= 0 && c < sizeof(map->table) ? map->table[c] : -EINVAL;
83} 83}
84 84
85#define SEG7_CONVERSION_MAP(_name, _map) \ 85#define SEG7_CONVERSION_MAP(_name, _map) \
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index ff9275057a18..7fce526560ca 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -98,7 +98,7 @@ struct mtouch_usb {
98 dma_addr_t data_dma; 98 dma_addr_t data_dma;
99 struct urb *irq; 99 struct urb *irq;
100 struct usb_device *udev; 100 struct usb_device *udev;
101 struct input_dev input; 101 struct input_dev *input;
102 char name[128]; 102 char name[128];
103 char phys[64]; 103 char phys[64];
104}; 104};
@@ -135,14 +135,14 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs)
135 goto exit; 135 goto exit;
136 } 136 }
137 137
138 input_regs(&mtouch->input, regs); 138 input_regs(mtouch->input, regs);
139 input_report_key(&mtouch->input, BTN_TOUCH, 139 input_report_key(mtouch->input, BTN_TOUCH,
140 MTOUCHUSB_GET_TOUCHED(mtouch->data)); 140 MTOUCHUSB_GET_TOUCHED(mtouch->data));
141 input_report_abs(&mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data)); 141 input_report_abs(mtouch->input, ABS_X, MTOUCHUSB_GET_XC(mtouch->data));
142 input_report_abs(&mtouch->input, ABS_Y, 142 input_report_abs(mtouch->input, ABS_Y,
143 (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC) 143 (raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC)
144 - MTOUCHUSB_GET_YC(mtouch->data)); 144 - MTOUCHUSB_GET_YC(mtouch->data));
145 input_sync(&mtouch->input); 145 input_sync(mtouch->input);
146 146
147exit: 147exit:
148 retval = usb_submit_urb(urb, GFP_ATOMIC); 148 retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -195,10 +195,10 @@ static void mtouchusb_free_buffers(struct usb_device *udev, struct mtouch_usb *m
195static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id) 195static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
196{ 196{
197 struct mtouch_usb *mtouch; 197 struct mtouch_usb *mtouch;
198 struct input_dev *input_dev;
198 struct usb_host_interface *interface; 199 struct usb_host_interface *interface;
199 struct usb_endpoint_descriptor *endpoint; 200 struct usb_endpoint_descriptor *endpoint;
200 struct usb_device *udev = interface_to_usbdev(intf); 201 struct usb_device *udev = interface_to_usbdev(intf);
201 char path[64];
202 int nRet; 202 int nRet;
203 203
204 dbg("%s - called", __FUNCTION__); 204 dbg("%s - called", __FUNCTION__);
@@ -209,57 +209,55 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
209 dbg("%s - setting endpoint", __FUNCTION__); 209 dbg("%s - setting endpoint", __FUNCTION__);
210 endpoint = &interface->endpoint[0].desc; 210 endpoint = &interface->endpoint[0].desc;
211 211
212 if (!(mtouch = kmalloc(sizeof(struct mtouch_usb), GFP_KERNEL))) { 212 mtouch = kzalloc(sizeof(struct mtouch_usb), GFP_KERNEL);
213 input_dev = input_allocate_device();
214 if (!mtouch || !input_dev) {
213 err("%s - Out of memory.", __FUNCTION__); 215 err("%s - Out of memory.", __FUNCTION__);
214 return -ENOMEM; 216 goto fail1;
215 } 217 }
216 218
217 memset(mtouch, 0, sizeof(struct mtouch_usb));
218 mtouch->udev = udev;
219
220 dbg("%s - allocating buffers", __FUNCTION__); 219 dbg("%s - allocating buffers", __FUNCTION__);
221 if (mtouchusb_alloc_buffers(udev, mtouch)) { 220 if (mtouchusb_alloc_buffers(udev, mtouch))
222 mtouchusb_free_buffers(udev, mtouch); 221 goto fail2;
223 kfree(mtouch);
224 return -ENOMEM;
225 }
226 222
227 mtouch->input.private = mtouch; 223 mtouch->udev = udev;
228 mtouch->input.open = mtouchusb_open; 224 mtouch->input = input_dev;
229 mtouch->input.close = mtouchusb_close;
230
231 usb_make_path(udev, path, 64);
232 sprintf(mtouch->phys, "%s/input0", path);
233
234 mtouch->input.name = mtouch->name;
235 mtouch->input.phys = mtouch->phys;
236 usb_to_input_id(udev, &mtouch->input.id);
237 mtouch->input.dev = &intf->dev;
238
239 mtouch->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
240 mtouch->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
241 mtouch->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
242
243 /* Used to Scale Compensated Data and Flip Y */
244 mtouch->input.absmin[ABS_X] = MTOUCHUSB_MIN_XC;
245 mtouch->input.absmax[ABS_X] = raw_coordinates ?
246 MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC;
247 mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ;
248 mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT;
249 mtouch->input.absmin[ABS_Y] = MTOUCHUSB_MIN_YC;
250 mtouch->input.absmax[ABS_Y] = raw_coordinates ?
251 MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC;
252 mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ;
253 mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT;
254 225
255 if (udev->manufacturer) 226 if (udev->manufacturer)
256 strcat(mtouch->name, udev->manufacturer); 227 strlcpy(mtouch->name, udev->manufacturer, sizeof(mtouch->name));
257 if (udev->product) 228
258 sprintf(mtouch->name, "%s %s", mtouch->name, udev->product); 229 if (udev->product) {
230 if (udev->manufacturer)
231 strlcat(mtouch->name, " ", sizeof(mtouch->name));
232 strlcat(mtouch->name, udev->product, sizeof(mtouch->name));
233 }
259 234
260 if (!strlen(mtouch->name)) 235 if (!strlen(mtouch->name))
261 sprintf(mtouch->name, "USB Touchscreen %04x:%04x", 236 snprintf(mtouch->name, sizeof(mtouch->name),
262 mtouch->input.id.vendor, mtouch->input.id.product); 237 "USB Touchscreen %04x:%04x",
238 le16_to_cpu(udev->descriptor.idVendor),
239 le16_to_cpu(udev->descriptor.idProduct));
240
241 usb_make_path(udev, mtouch->phys, sizeof(mtouch->phys));
242 strlcpy(mtouch->phys, "/input0", sizeof(mtouch->phys));
243
244 input_dev->name = mtouch->name;
245 input_dev->phys = mtouch->phys;
246 usb_to_input_id(udev, &input_dev->id);
247 input_dev->cdev.dev = &intf->dev;
248 input_dev->private = mtouch;
249
250 input_dev->open = mtouchusb_open;
251 input_dev->close = mtouchusb_close;
252
253 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
254 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
255 input_set_abs_params(input_dev, ABS_X, MTOUCHUSB_MIN_XC,
256 raw_coordinates ? MTOUCHUSB_MAX_RAW_XC : MTOUCHUSB_MAX_CALIB_XC,
257 MTOUCHUSB_XC_FUZZ, MTOUCHUSB_XC_FLAT);
258 input_set_abs_params(input_dev, ABS_Y, MTOUCHUSB_MIN_YC,
259 raw_coordinates ? MTOUCHUSB_MAX_RAW_YC : MTOUCHUSB_MAX_CALIB_YC,
260 MTOUCHUSB_YC_FUZZ, MTOUCHUSB_YC_FLAT);
263 261
264 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), 262 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
265 MTOUCHUSB_RESET, 263 MTOUCHUSB_RESET,
@@ -272,9 +270,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
272 mtouch->irq = usb_alloc_urb(0, GFP_KERNEL); 270 mtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
273 if (!mtouch->irq) { 271 if (!mtouch->irq) {
274 dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__); 272 dbg("%s - usb_alloc_urb failed: mtouch->irq", __FUNCTION__);
275 mtouchusb_free_buffers(udev, mtouch); 273 goto fail2;
276 kfree(mtouch);
277 return -ENOMEM;
278 } 274 }
279 275
280 dbg("%s - usb_fill_int_urb", __FUNCTION__); 276 dbg("%s - usb_fill_int_urb", __FUNCTION__);
@@ -284,7 +280,7 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
284 mtouchusb_irq, mtouch, endpoint->bInterval); 280 mtouchusb_irq, mtouch, endpoint->bInterval);
285 281
286 dbg("%s - input_register_device", __FUNCTION__); 282 dbg("%s - input_register_device", __FUNCTION__);
287 input_register_device(&mtouch->input); 283 input_register_device(mtouch->input);
288 284
289 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0), 285 nRet = usb_control_msg(mtouch->udev, usb_rcvctrlpipe(udev, 0),
290 MTOUCHUSB_ASYNC_REPORT, 286 MTOUCHUSB_ASYNC_REPORT,
@@ -293,10 +289,13 @@ static int mtouchusb_probe(struct usb_interface *intf, const struct usb_device_i
293 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", 289 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
294 __FUNCTION__, nRet); 290 __FUNCTION__, nRet);
295 291
296 printk(KERN_INFO "input: %s on %s\n", mtouch->name, path);
297 usb_set_intfdata(intf, mtouch); 292 usb_set_intfdata(intf, mtouch);
298
299 return 0; 293 return 0;
294
295fail2: mtouchusb_free_buffers(udev, mtouch);
296fail1: input_free_device(input_dev);
297 kfree(mtouch);
298 return -ENOMEM;
300} 299}
301 300
302static void mtouchusb_disconnect(struct usb_interface *intf) 301static void mtouchusb_disconnect(struct usb_interface *intf)
@@ -308,7 +307,7 @@ static void mtouchusb_disconnect(struct usb_interface *intf)
308 if (mtouch) { 307 if (mtouch) {
309 dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__); 308 dbg("%s - mtouch is initialized, cleaning up", __FUNCTION__);
310 usb_kill_urb(mtouch->irq); 309 usb_kill_urb(mtouch->irq);
311 input_unregister_device(&mtouch->input); 310 input_unregister_device(mtouch->input);
312 usb_free_urb(mtouch->irq); 311 usb_free_urb(mtouch->irq);
313 mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch); 312 mtouchusb_free_buffers(interface_to_usbdev(intf), mtouch);
314 kfree(mtouch); 313 kfree(mtouch);
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c
index acc71ec560e9..a00672c96644 100644
--- a/drivers/usb/input/pid.c
+++ b/drivers/usb/input/pid.c
@@ -262,6 +262,7 @@ int hid_pid_init(struct hid_device *hid)
262{ 262{
263 struct hid_ff_pid *private; 263 struct hid_ff_pid *private;
264 struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list); 264 struct hid_input *hidinput = list_entry(&hid->inputs, struct hid_input, list);
265 struct input_dev *input_dev = hidinput->input;
265 266
266 private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL); 267 private = hid->ff_private = kzalloc(sizeof(struct hid_ff_pid), GFP_KERNEL);
267 if (!private) 268 if (!private)
@@ -281,11 +282,12 @@ int hid_pid_init(struct hid_device *hid)
281 usb_fill_control_urb(private->urbffout, hid->dev, 0, 282 usb_fill_control_urb(private->urbffout, hid->dev, 0,
282 (void *)&private->ffcr, private->ctrl_buffer, 8, 283 (void *)&private->ffcr, private->ctrl_buffer, 8,
283 hid_pid_ctrl_out, hid); 284 hid_pid_ctrl_out, hid);
284 hidinput->input.upload_effect = hid_pid_upload_effect; 285
285 hidinput->input.flush = hid_pid_flush; 286 input_dev->upload_effect = hid_pid_upload_effect;
286 hidinput->input.ff_effects_max = 8; // A random default 287 input_dev->flush = hid_pid_flush;
287 set_bit(EV_FF, hidinput->input.evbit); 288 input_dev->ff_effects_max = 8; // A random default
288 set_bit(EV_FF_STATUS, hidinput->input.evbit); 289 set_bit(EV_FF, input_dev->evbit);
290 set_bit(EV_FF_STATUS, input_dev->evbit);
289 291
290 spin_lock_init(&private->lock); 292 spin_lock_init(&private->lock);
291 293
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index ad4afe7e5897..b7476233ef5d 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -68,7 +68,7 @@ struct powermate_device {
68 struct usb_ctrlrequest *configcr; 68 struct usb_ctrlrequest *configcr;
69 dma_addr_t configcr_dma; 69 dma_addr_t configcr_dma;
70 struct usb_device *udev; 70 struct usb_device *udev;
71 struct input_dev input; 71 struct input_dev *input;
72 spinlock_t lock; 72 spinlock_t lock;
73 int static_brightness; 73 int static_brightness;
74 int pulse_speed; 74 int pulse_speed;
@@ -106,10 +106,10 @@ static void powermate_irq(struct urb *urb, struct pt_regs *regs)
106 } 106 }
107 107
108 /* handle updates to device state */ 108 /* handle updates to device state */
109 input_regs(&pm->input, regs); 109 input_regs(pm->input, regs);
110 input_report_key(&pm->input, BTN_0, pm->data[0] & 0x01); 110 input_report_key(pm->input, BTN_0, pm->data[0] & 0x01);
111 input_report_rel(&pm->input, REL_DIAL, pm->data[1]); 111 input_report_rel(pm->input, REL_DIAL, pm->data[1]);
112 input_sync(&pm->input); 112 input_sync(pm->input);
113 113
114exit: 114exit:
115 retval = usb_submit_urb (urb, GFP_ATOMIC); 115 retval = usb_submit_urb (urb, GFP_ATOMIC);
@@ -153,10 +153,10 @@ static void powermate_sync_state(struct powermate_device *pm)
153 153
154 Only values of 'arg' quite close to 255 are particularly useful/spectacular. 154 Only values of 'arg' quite close to 255 are particularly useful/spectacular.
155 */ 155 */
156 if (pm->pulse_speed < 255){ 156 if (pm->pulse_speed < 255) {
157 op = 0; // divide 157 op = 0; // divide
158 arg = 255 - pm->pulse_speed; 158 arg = 255 - pm->pulse_speed;
159 } else if (pm->pulse_speed > 255){ 159 } else if (pm->pulse_speed > 255) {
160 op = 2; // multiply 160 op = 2; // multiply
161 arg = pm->pulse_speed - 255; 161 arg = pm->pulse_speed - 255;
162 } else { 162 } else {
@@ -166,11 +166,11 @@ static void powermate_sync_state(struct powermate_device *pm)
166 pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE ); 166 pm->configcr->wValue = cpu_to_le16( (pm->pulse_table << 8) | SET_PULSE_MODE );
167 pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op ); 167 pm->configcr->wIndex = cpu_to_le16( (arg << 8) | op );
168 pm->requires_update &= ~UPDATE_PULSE_MODE; 168 pm->requires_update &= ~UPDATE_PULSE_MODE;
169 }else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS){ 169 } else if (pm->requires_update & UPDATE_STATIC_BRIGHTNESS) {
170 pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS ); 170 pm->configcr->wValue = cpu_to_le16( SET_STATIC_BRIGHTNESS );
171 pm->configcr->wIndex = cpu_to_le16( pm->static_brightness ); 171 pm->configcr->wIndex = cpu_to_le16( pm->static_brightness );
172 pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS; 172 pm->requires_update &= ~UPDATE_STATIC_BRIGHTNESS;
173 }else{ 173 } else {
174 printk(KERN_ERR "powermate: unknown update required"); 174 printk(KERN_ERR "powermate: unknown update required");
175 pm->requires_update = 0; /* fudge the bug */ 175 pm->requires_update = 0; /* fudge the bug */
176 return; 176 return;
@@ -228,19 +228,19 @@ static void powermate_pulse_led(struct powermate_device *pm, int static_brightne
228 spin_lock_irqsave(&pm->lock, flags); 228 spin_lock_irqsave(&pm->lock, flags);
229 229
230 /* mark state updates which are required */ 230 /* mark state updates which are required */
231 if (static_brightness != pm->static_brightness){ 231 if (static_brightness != pm->static_brightness) {
232 pm->static_brightness = static_brightness; 232 pm->static_brightness = static_brightness;
233 pm->requires_update |= UPDATE_STATIC_BRIGHTNESS; 233 pm->requires_update |= UPDATE_STATIC_BRIGHTNESS;
234 } 234 }
235 if (pulse_asleep != pm->pulse_asleep){ 235 if (pulse_asleep != pm->pulse_asleep) {
236 pm->pulse_asleep = pulse_asleep; 236 pm->pulse_asleep = pulse_asleep;
237 pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS); 237 pm->requires_update |= (UPDATE_PULSE_ASLEEP | UPDATE_STATIC_BRIGHTNESS);
238 } 238 }
239 if (pulse_awake != pm->pulse_awake){ 239 if (pulse_awake != pm->pulse_awake) {
240 pm->pulse_awake = pulse_awake; 240 pm->pulse_awake = pulse_awake;
241 pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS); 241 pm->requires_update |= (UPDATE_PULSE_AWAKE | UPDATE_STATIC_BRIGHTNESS);
242 } 242 }
243 if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table){ 243 if (pulse_speed != pm->pulse_speed || pulse_table != pm->pulse_table) {
244 pm->pulse_speed = pulse_speed; 244 pm->pulse_speed = pulse_speed;
245 pm->pulse_table = pulse_table; 245 pm->pulse_table = pulse_table;
246 pm->requires_update |= UPDATE_PULSE_MODE; 246 pm->requires_update |= UPDATE_PULSE_MODE;
@@ -283,6 +283,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev
283 SLAB_ATOMIC, &pm->data_dma); 283 SLAB_ATOMIC, &pm->data_dma);
284 if (!pm->data) 284 if (!pm->data)
285 return -1; 285 return -1;
286
286 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), 287 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
287 SLAB_ATOMIC, &pm->configcr_dma); 288 SLAB_ATOMIC, &pm->configcr_dma);
288 if (!pm->configcr) 289 if (!pm->configcr)
@@ -308,8 +309,9 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
308 struct usb_host_interface *interface; 309 struct usb_host_interface *interface;
309 struct usb_endpoint_descriptor *endpoint; 310 struct usb_endpoint_descriptor *endpoint;
310 struct powermate_device *pm; 311 struct powermate_device *pm;
312 struct input_dev *input_dev;
311 int pipe, maxp; 313 int pipe, maxp;
312 char path[64]; 314 int err = -ENOMEM;
313 315
314 interface = intf->cur_altsetting; 316 interface = intf->cur_altsetting;
315 endpoint = &interface->endpoint[0].desc; 317 endpoint = &interface->endpoint[0].desc;
@@ -323,42 +325,61 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
323 0, interface->desc.bInterfaceNumber, NULL, 0, 325 0, interface->desc.bInterfaceNumber, NULL, 0,
324 USB_CTRL_SET_TIMEOUT); 326 USB_CTRL_SET_TIMEOUT);
325 327
326 if (!(pm = kmalloc(sizeof(struct powermate_device), GFP_KERNEL))) 328 pm = kzalloc(sizeof(struct powermate_device), GFP_KERNEL);
327 return -ENOMEM; 329 input_dev = input_allocate_device();
328 330 if (!pm || !input_dev)
329 memset(pm, 0, sizeof(struct powermate_device)); 331 goto fail1;
330 pm->udev = udev;
331 332
332 if (powermate_alloc_buffers(udev, pm)) { 333 if (powermate_alloc_buffers(udev, pm))
333 powermate_free_buffers(udev, pm); 334 goto fail2;
334 kfree(pm);
335 return -ENOMEM;
336 }
337 335
338 pm->irq = usb_alloc_urb(0, GFP_KERNEL); 336 pm->irq = usb_alloc_urb(0, GFP_KERNEL);
339 if (!pm->irq) { 337 if (!pm->irq)
340 powermate_free_buffers(udev, pm); 338 goto fail2;
341 kfree(pm);
342 return -ENOMEM;
343 }
344 339
345 pm->config = usb_alloc_urb(0, GFP_KERNEL); 340 pm->config = usb_alloc_urb(0, GFP_KERNEL);
346 if (!pm->config) { 341 if (!pm->config)
347 usb_free_urb(pm->irq); 342 goto fail3;
348 powermate_free_buffers(udev, pm); 343
349 kfree(pm); 344 pm->udev = udev;
350 return -ENOMEM; 345 pm->input = input_dev;
351 } 346
347 usb_make_path(udev, pm->phys, sizeof(pm->phys));
348 strlcpy(pm->phys, "/input0", sizeof(pm->phys));
352 349
353 spin_lock_init(&pm->lock); 350 spin_lock_init(&pm->lock);
354 init_input_dev(&pm->input); 351
352 switch (le16_to_cpu(udev->descriptor.idProduct)) {
353 case POWERMATE_PRODUCT_NEW:
354 input_dev->name = pm_name_powermate;
355 break;
356 case POWERMATE_PRODUCT_OLD:
357 input_dev->name = pm_name_soundknob;
358 break;
359 default:
360 input_dev->name = pm_name_soundknob;
361 printk(KERN_WARNING "powermate: unknown product id %04x\n",
362 le16_to_cpu(udev->descriptor.idProduct));
363 }
364
365 input_dev->phys = pm->phys;
366 usb_to_input_id(udev, &input_dev->id);
367 input_dev->cdev.dev = &intf->dev;
368 input_dev->private = pm;
369
370 input_dev->event = powermate_input_event;
371
372 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC);
373 input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0);
374 input_dev->relbit[LONG(REL_DIAL)] = BIT(REL_DIAL);
375 input_dev->mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED);
355 376
356 /* get a handle to the interrupt data pipe */ 377 /* get a handle to the interrupt data pipe */
357 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 378 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
358 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 379 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
359 380
360 if(maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX){ 381 if (maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX) {
361 printk("powermate: Expected payload of %d--%d bytes, found %d bytes!\n", 382 printk(KERN_WARNING "powermate: Expected payload of %d--%d bytes, found %d bytes!\n",
362 POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp); 383 POWERMATE_PAYLOAD_SIZE_MIN, POWERMATE_PAYLOAD_SIZE_MAX, maxp);
363 maxp = POWERMATE_PAYLOAD_SIZE_MAX; 384 maxp = POWERMATE_PAYLOAD_SIZE_MAX;
364 } 385 }
@@ -371,35 +392,11 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
371 392
372 /* register our interrupt URB with the USB system */ 393 /* register our interrupt URB with the USB system */
373 if (usb_submit_urb(pm->irq, GFP_KERNEL)) { 394 if (usb_submit_urb(pm->irq, GFP_KERNEL)) {
374 powermate_free_buffers(udev, pm); 395 err = -EIO;
375 kfree(pm); 396 goto fail4;
376 return -EIO; /* failure */
377 } 397 }
378 398
379 switch (le16_to_cpu(udev->descriptor.idProduct)) { 399 input_register_device(pm->input);
380 case POWERMATE_PRODUCT_NEW: pm->input.name = pm_name_powermate; break;
381 case POWERMATE_PRODUCT_OLD: pm->input.name = pm_name_soundknob; break;
382 default:
383 pm->input.name = pm_name_soundknob;
384 printk(KERN_WARNING "powermate: unknown product id %04x\n",
385 le16_to_cpu(udev->descriptor.idProduct));
386 }
387
388 pm->input.private = pm;
389 pm->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REL) | BIT(EV_MSC);
390 pm->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
391 pm->input.relbit[LONG(REL_DIAL)] = BIT(REL_DIAL);
392 pm->input.mscbit[LONG(MSC_PULSELED)] = BIT(MSC_PULSELED);
393 usb_to_input_id(udev, &pm->input.id);
394 pm->input.event = powermate_input_event;
395 pm->input.dev = &intf->dev;
396 pm->input.phys = pm->phys;
397
398 input_register_device(&pm->input);
399
400 usb_make_path(udev, path, 64);
401 snprintf(pm->phys, 64, "%s/input0", path);
402 printk(KERN_INFO "input: %s on %s\n", pm->input.name, pm->input.phys);
403 400
404 /* force an update of everything */ 401 /* force an update of everything */
405 pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS; 402 pm->requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS;
@@ -407,6 +404,13 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
407 404
408 usb_set_intfdata(intf, pm); 405 usb_set_intfdata(intf, pm);
409 return 0; 406 return 0;
407
408fail4: usb_free_urb(pm->config);
409fail3: usb_free_urb(pm->irq);
410fail2: powermate_free_buffers(udev, pm);
411fail1: input_free_device(input_dev);
412 kfree(pm);
413 return err;
410} 414}
411 415
412/* Called when a USB device we've accepted ownership of is removed */ 416/* Called when a USB device we've accepted ownership of is removed */
@@ -418,7 +422,7 @@ static void powermate_disconnect(struct usb_interface *intf)
418 if (pm) { 422 if (pm) {
419 pm->requires_update = 0; 423 pm->requires_update = 0;
420 usb_kill_urb(pm->irq); 424 usb_kill_urb(pm->irq);
421 input_unregister_device(&pm->input); 425 input_unregister_device(pm->input);
422 usb_free_urb(pm->irq); 426 usb_free_urb(pm->irq);
423 usb_free_urb(pm->config); 427 usb_free_urb(pm->config);
424 powermate_free_buffers(interface_to_usbdev(intf), pm); 428 powermate_free_buffers(interface_to_usbdev(intf), pm);
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 4276c24a5080..0043e6ebcd1f 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -68,14 +68,16 @@ struct touchkit_usb {
68 dma_addr_t data_dma; 68 dma_addr_t data_dma;
69 struct urb *irq; 69 struct urb *irq;
70 struct usb_device *udev; 70 struct usb_device *udev;
71 struct input_dev input; 71 struct input_dev *input;
72 char name[128]; 72 char name[128];
73 char phys[64]; 73 char phys[64];
74}; 74};
75 75
76static struct usb_device_id touchkit_devices[] = { 76static struct usb_device_id touchkit_devices[] = {
77 {USB_DEVICE(0x3823, 0x0001)}, 77 {USB_DEVICE(0x3823, 0x0001)},
78 {USB_DEVICE(0x0123, 0x0001)},
78 {USB_DEVICE(0x0eef, 0x0001)}, 79 {USB_DEVICE(0x0eef, 0x0001)},
80 {USB_DEVICE(0x0eef, 0x0002)},
79 {} 81 {}
80}; 82};
81 83
@@ -115,12 +117,12 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
115 y = TOUCHKIT_GET_Y(touchkit->data); 117 y = TOUCHKIT_GET_Y(touchkit->data);
116 } 118 }
117 119
118 input_regs(&touchkit->input, regs); 120 input_regs(touchkit->input, regs);
119 input_report_key(&touchkit->input, BTN_TOUCH, 121 input_report_key(touchkit->input, BTN_TOUCH,
120 TOUCHKIT_GET_TOUCHED(touchkit->data)); 122 TOUCHKIT_GET_TOUCHED(touchkit->data));
121 input_report_abs(&touchkit->input, ABS_X, x); 123 input_report_abs(touchkit->input, ABS_X, x);
122 input_report_abs(&touchkit->input, ABS_Y, y); 124 input_report_abs(touchkit->input, ABS_Y, y);
123 input_sync(&touchkit->input); 125 input_sync(touchkit->input);
124 126
125exit: 127exit:
126 retval = usb_submit_urb(urb, GFP_ATOMIC); 128 retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -171,87 +173,81 @@ static void touchkit_free_buffers(struct usb_device *udev,
171static int touchkit_probe(struct usb_interface *intf, 173static int touchkit_probe(struct usb_interface *intf,
172 const struct usb_device_id *id) 174 const struct usb_device_id *id)
173{ 175{
174 int ret;
175 struct touchkit_usb *touchkit; 176 struct touchkit_usb *touchkit;
177 struct input_dev *input_dev;
176 struct usb_host_interface *interface; 178 struct usb_host_interface *interface;
177 struct usb_endpoint_descriptor *endpoint; 179 struct usb_endpoint_descriptor *endpoint;
178 struct usb_device *udev = interface_to_usbdev(intf); 180 struct usb_device *udev = interface_to_usbdev(intf);
179 char path[64];
180 181
181 interface = intf->cur_altsetting; 182 interface = intf->cur_altsetting;
182 endpoint = &interface->endpoint[0].desc; 183 endpoint = &interface->endpoint[0].desc;
183 184
184 touchkit = kmalloc(sizeof(struct touchkit_usb), GFP_KERNEL); 185 touchkit = kzalloc(sizeof(struct touchkit_usb), GFP_KERNEL);
185 if (!touchkit) 186 input_dev = input_allocate_device();
186 return -ENOMEM; 187 if (!touchkit || !input_dev)
187
188 memset(touchkit, 0, sizeof(struct touchkit_usb));
189 touchkit->udev = udev;
190
191 if (touchkit_alloc_buffers(udev, touchkit)) {
192 ret = -ENOMEM;
193 goto out_free; 188 goto out_free;
194 }
195
196 touchkit->input.private = touchkit;
197 touchkit->input.open = touchkit_open;
198 touchkit->input.close = touchkit_close;
199
200 usb_make_path(udev, path, 64);
201 sprintf(touchkit->phys, "%s/input0", path);
202
203 touchkit->input.name = touchkit->name;
204 touchkit->input.phys = touchkit->phys;
205 usb_to_input_id(udev, &touchkit->input.id);
206 touchkit->input.dev = &intf->dev;
207
208 touchkit->input.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
209 touchkit->input.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
210 touchkit->input.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
211
212 /* Used to Scale Compensated Data */
213 touchkit->input.absmin[ABS_X] = TOUCHKIT_MIN_XC;
214 touchkit->input.absmax[ABS_X] = TOUCHKIT_MAX_XC;
215 touchkit->input.absfuzz[ABS_X] = TOUCHKIT_XC_FUZZ;
216 touchkit->input.absflat[ABS_X] = TOUCHKIT_XC_FLAT;
217 touchkit->input.absmin[ABS_Y] = TOUCHKIT_MIN_YC;
218 touchkit->input.absmax[ABS_Y] = TOUCHKIT_MAX_YC;
219 touchkit->input.absfuzz[ABS_Y] = TOUCHKIT_YC_FUZZ;
220 touchkit->input.absflat[ABS_Y] = TOUCHKIT_YC_FLAT;
221
222 if (udev->manufacturer)
223 strcat(touchkit->name, udev->manufacturer);
224 if (udev->product)
225 sprintf(touchkit->name, "%s %s", touchkit->name, udev->product);
226 189
227 if (!strlen(touchkit->name)) 190 if (touchkit_alloc_buffers(udev, touchkit))
228 sprintf(touchkit->name, "USB Touchscreen %04x:%04x", 191 goto out_free;
229 touchkit->input.id.vendor, touchkit->input.id.product);
230 192
231 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL); 193 touchkit->irq = usb_alloc_urb(0, GFP_KERNEL);
232 if (!touchkit->irq) { 194 if (!touchkit->irq) {
233 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__); 195 dbg("%s - usb_alloc_urb failed: touchkit->irq", __FUNCTION__);
234 ret = -ENOMEM;
235 goto out_free_buffers; 196 goto out_free_buffers;
236 } 197 }
237 198
199 touchkit->udev = udev;
200 touchkit->input = input_dev;
201
202 if (udev->manufacturer)
203 strlcpy(touchkit->name, udev->manufacturer, sizeof(touchkit->name));
204
205 if (udev->product) {
206 if (udev->manufacturer)
207 strlcat(touchkit->name, " ", sizeof(touchkit->name));
208 strlcat(touchkit->name, udev->product, sizeof(touchkit->name));
209 }
210
211 if (!strlen(touchkit->name))
212 snprintf(touchkit->name, sizeof(touchkit->name),
213 "USB Touchscreen %04x:%04x",
214 le16_to_cpu(udev->descriptor.idVendor),
215 le16_to_cpu(udev->descriptor.idProduct));
216
217 usb_make_path(udev, touchkit->phys, sizeof(touchkit->phys));
218 strlcpy(touchkit->phys, "/input0", sizeof(touchkit->phys));
219
220 input_dev->name = touchkit->name;
221 input_dev->phys = touchkit->phys;
222 usb_to_input_id(udev, &input_dev->id);
223 input_dev->cdev.dev = &intf->dev;
224 input_dev->private = touchkit;
225 input_dev->open = touchkit_open;
226 input_dev->close = touchkit_close;
227
228 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
229 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
230 input_set_abs_params(input_dev, ABS_X, TOUCHKIT_MIN_XC, TOUCHKIT_MAX_XC,
231 TOUCHKIT_XC_FUZZ, TOUCHKIT_XC_FLAT);
232 input_set_abs_params(input_dev, ABS_Y, TOUCHKIT_MIN_YC, TOUCHKIT_MAX_YC,
233 TOUCHKIT_YC_FUZZ, TOUCHKIT_YC_FLAT);
234
238 usb_fill_int_urb(touchkit->irq, touchkit->udev, 235 usb_fill_int_urb(touchkit->irq, touchkit->udev,
239 usb_rcvintpipe(touchkit->udev, 0x81), 236 usb_rcvintpipe(touchkit->udev, 0x81),
240 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE, 237 touchkit->data, TOUCHKIT_REPORT_DATA_SIZE,
241 touchkit_irq, touchkit, endpoint->bInterval); 238 touchkit_irq, touchkit, endpoint->bInterval);
242 239
243 input_register_device(&touchkit->input); 240 input_register_device(touchkit->input);
244 241
245 printk(KERN_INFO "input: %s on %s\n", touchkit->name, path);
246 usb_set_intfdata(intf, touchkit); 242 usb_set_intfdata(intf, touchkit);
247
248 return 0; 243 return 0;
249 244
250out_free_buffers: 245out_free_buffers:
251 touchkit_free_buffers(udev, touchkit); 246 touchkit_free_buffers(udev, touchkit);
252out_free: 247out_free:
248 input_free_device(input_dev);
253 kfree(touchkit); 249 kfree(touchkit);
254 return ret; 250 return -ENOMEM;
255} 251}
256 252
257static void touchkit_disconnect(struct usb_interface *intf) 253static void touchkit_disconnect(struct usb_interface *intf)
@@ -265,8 +261,8 @@ static void touchkit_disconnect(struct usb_interface *intf)
265 261
266 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__); 262 dbg("%s - touchkit is initialized, cleaning up", __FUNCTION__);
267 usb_set_intfdata(intf, NULL); 263 usb_set_intfdata(intf, NULL);
268 input_unregister_device(&touchkit->input);
269 usb_kill_urb(touchkit->irq); 264 usb_kill_urb(touchkit->irq);
265 input_unregister_device(touchkit->input);
270 usb_free_urb(touchkit->irq); 266 usb_free_urb(touchkit->irq);
271 touchkit_free_buffers(interface_to_usbdev(intf), touchkit); 267 touchkit_free_buffers(interface_to_usbdev(intf), touchkit);
272 kfree(touchkit); 268 kfree(touchkit);
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 28987f15eeee..226b6f90a907 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -66,7 +66,7 @@ static unsigned char usb_kbd_keycode[256] = {
66}; 66};
67 67
68struct usb_kbd { 68struct usb_kbd {
69 struct input_dev dev; 69 struct input_dev *dev;
70 struct usb_device *usbdev; 70 struct usb_device *usbdev;
71 unsigned char old[8]; 71 unsigned char old[8];
72 struct urb *irq, *led; 72 struct urb *irq, *led;
@@ -99,29 +99,29 @@ static void usb_kbd_irq(struct urb *urb, struct pt_regs *regs)
99 goto resubmit; 99 goto resubmit;
100 } 100 }
101 101
102 input_regs(&kbd->dev, regs); 102 input_regs(kbd->dev, regs);
103 103
104 for (i = 0; i < 8; i++) 104 for (i = 0; i < 8; i++)
105 input_report_key(&kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); 105 input_report_key(kbd->dev, usb_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1);
106 106
107 for (i = 2; i < 8; i++) { 107 for (i = 2; i < 8; i++) {
108 108
109 if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) { 109 if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == kbd->new + 8) {
110 if (usb_kbd_keycode[kbd->old[i]]) 110 if (usb_kbd_keycode[kbd->old[i]])
111 input_report_key(&kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); 111 input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0);
112 else 112 else
113 info("Unknown key (scancode %#x) released.", kbd->old[i]); 113 info("Unknown key (scancode %#x) released.", kbd->old[i]);
114 } 114 }
115 115
116 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { 116 if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) {
117 if (usb_kbd_keycode[kbd->new[i]]) 117 if (usb_kbd_keycode[kbd->new[i]])
118 input_report_key(&kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); 118 input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1);
119 else 119 else
120 info("Unknown key (scancode %#x) pressed.", kbd->new[i]); 120 info("Unknown key (scancode %#x) pressed.", kbd->new[i]);
121 } 121 }
122 } 122 }
123 123
124 input_sync(&kbd->dev); 124 input_sync(kbd->dev);
125 125
126 memcpy(kbd->old, kbd->new, 8); 126 memcpy(kbd->old, kbd->new, 8);
127 127
@@ -227,12 +227,12 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
227static int usb_kbd_probe(struct usb_interface *iface, 227static int usb_kbd_probe(struct usb_interface *iface,
228 const struct usb_device_id *id) 228 const struct usb_device_id *id)
229{ 229{
230 struct usb_device * dev = interface_to_usbdev(iface); 230 struct usb_device *dev = interface_to_usbdev(iface);
231 struct usb_host_interface *interface; 231 struct usb_host_interface *interface;
232 struct usb_endpoint_descriptor *endpoint; 232 struct usb_endpoint_descriptor *endpoint;
233 struct usb_kbd *kbd; 233 struct usb_kbd *kbd;
234 struct input_dev *input_dev;
234 int i, pipe, maxp; 235 int i, pipe, maxp;
235 char path[64];
236 236
237 interface = iface->cur_altsetting; 237 interface = iface->cur_altsetting;
238 238
@@ -240,37 +240,59 @@ static int usb_kbd_probe(struct usb_interface *iface,
240 return -ENODEV; 240 return -ENODEV;
241 241
242 endpoint = &interface->endpoint[0].desc; 242 endpoint = &interface->endpoint[0].desc;
243 if (!(endpoint->bEndpointAddress & 0x80)) 243 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
244 return -ENODEV; 244 return -ENODEV;
245 if ((endpoint->bmAttributes & 3) != 3) 245 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
246 return -ENODEV; 246 return -ENODEV;
247 247
248 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 248 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
249 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 249 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
250 250
251 if (!(kbd = kmalloc(sizeof(struct usb_kbd), GFP_KERNEL))) 251 kbd = kzalloc(sizeof(struct usb_kbd), GFP_KERNEL);
252 return -ENOMEM; 252 input_dev = input_allocate_device();
253 memset(kbd, 0, sizeof(struct usb_kbd)); 253 if (!kbd || !input_dev)
254 goto fail1;
254 255
255 if (usb_kbd_alloc_mem(dev, kbd)) { 256 if (usb_kbd_alloc_mem(dev, kbd))
256 usb_kbd_free_mem(dev, kbd); 257 goto fail2;
257 kfree(kbd);
258 return -ENOMEM;
259 }
260 258
261 kbd->usbdev = dev; 259 kbd->usbdev = dev;
260 kbd->dev = input_dev;
261
262 if (dev->manufacturer)
263 strlcpy(kbd->name, dev->manufacturer, sizeof(kbd->name));
264
265 if (dev->product) {
266 if (dev->manufacturer)
267 strlcat(kbd->name, " ", sizeof(kbd->name));
268 strlcat(kbd->name, dev->product, sizeof(kbd->name));
269 }
270
271 if (!strlen(kbd->name))
272 snprintf(kbd->name, sizeof(kbd->name),
273 "USB HIDBP Keyboard %04x:%04x",
274 le16_to_cpu(dev->descriptor.idVendor),
275 le16_to_cpu(dev->descriptor.idProduct));
276
277 usb_make_path(dev, kbd->phys, sizeof(kbd->phys));
278 strlcpy(kbd->phys, "/input0", sizeof(kbd->phys));
262 279
263 kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); 280 input_dev->name = kbd->name;
264 kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); 281 input_dev->phys = kbd->phys;
282 usb_to_input_id(dev, &input_dev->id);
283 input_dev->cdev.dev = &iface->dev;
284 input_dev->private = kbd;
285
286 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
287 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA);
265 288
266 for (i = 0; i < 255; i++) 289 for (i = 0; i < 255; i++)
267 set_bit(usb_kbd_keycode[i], kbd->dev.keybit); 290 set_bit(usb_kbd_keycode[i], input_dev->keybit);
268 clear_bit(0, kbd->dev.keybit); 291 clear_bit(0, input_dev->keybit);
269 292
270 kbd->dev.private = kbd; 293 input_dev->event = usb_kbd_event;
271 kbd->dev.event = usb_kbd_event; 294 input_dev->open = usb_kbd_open;
272 kbd->dev.open = usb_kbd_open; 295 input_dev->close = usb_kbd_close;
273 kbd->dev.close = usb_kbd_close;
274 296
275 usb_fill_int_urb(kbd->irq, dev, pipe, 297 usb_fill_int_urb(kbd->irq, dev, pipe,
276 kbd->new, (maxp > 8 ? 8 : maxp), 298 kbd->new, (maxp > 8 ? 8 : maxp),
@@ -284,37 +306,22 @@ static int usb_kbd_probe(struct usb_interface *iface,
284 kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber); 306 kbd->cr->wIndex = cpu_to_le16(interface->desc.bInterfaceNumber);
285 kbd->cr->wLength = cpu_to_le16(1); 307 kbd->cr->wLength = cpu_to_le16(1);
286 308
287 usb_make_path(dev, path, 64);
288 sprintf(kbd->phys, "%s/input0", path);
289
290 kbd->dev.name = kbd->name;
291 kbd->dev.phys = kbd->phys;
292 usb_to_input_id(dev, &kbd->dev.id);
293 kbd->dev.dev = &iface->dev;
294
295 if (dev->manufacturer)
296 strcat(kbd->name, dev->manufacturer);
297 if (dev->product)
298 sprintf(kbd->name, "%s %s", kbd->name, dev->product);
299
300 if (!strlen(kbd->name))
301 sprintf(kbd->name, "USB HIDBP Keyboard %04x:%04x",
302 kbd->dev.id.vendor, kbd->dev.id.product);
303
304 usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), 309 usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0),
305 (void *) kbd->cr, kbd->leds, 1, 310 (void *) kbd->cr, kbd->leds, 1,
306 usb_kbd_led, kbd); 311 usb_kbd_led, kbd);
307 kbd->led->setup_dma = kbd->cr_dma; 312 kbd->led->setup_dma = kbd->cr_dma;
308 kbd->led->transfer_dma = kbd->leds_dma; 313 kbd->led->transfer_dma = kbd->leds_dma;
309 kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP 314 kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
310 | URB_NO_SETUP_DMA_MAP);
311 315
312 input_register_device(&kbd->dev); 316 input_register_device(kbd->dev);
313
314 printk(KERN_INFO "input: %s on %s\n", kbd->name, path);
315 317
316 usb_set_intfdata(iface, kbd); 318 usb_set_intfdata(iface, kbd);
317 return 0; 319 return 0;
320
321fail2: usb_kbd_free_mem(dev, kbd);
322fail1: input_free_device(input_dev);
323 kfree(kbd);
324 return -ENOMEM;
318} 325}
319 326
320static void usb_kbd_disconnect(struct usb_interface *intf) 327static void usb_kbd_disconnect(struct usb_interface *intf)
@@ -324,7 +331,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf)
324 usb_set_intfdata(intf, NULL); 331 usb_set_intfdata(intf, NULL);
325 if (kbd) { 332 if (kbd) {
326 usb_kill_urb(kbd->irq); 333 usb_kill_urb(kbd->irq);
327 input_unregister_device(&kbd->dev); 334 input_unregister_device(kbd->dev);
328 usb_kbd_free_mem(interface_to_usbdev(intf), kbd); 335 usb_kbd_free_mem(interface_to_usbdev(intf), kbd);
329 kfree(kbd); 336 kfree(kbd);
330 } 337 }
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 4104dec847fb..230f6b1b314a 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -50,7 +50,7 @@ struct usb_mouse {
50 char name[128]; 50 char name[128];
51 char phys[64]; 51 char phys[64];
52 struct usb_device *usbdev; 52 struct usb_device *usbdev;
53 struct input_dev dev; 53 struct input_dev *dev;
54 struct urb *irq; 54 struct urb *irq;
55 55
56 signed char *data; 56 signed char *data;
@@ -61,7 +61,7 @@ static void usb_mouse_irq(struct urb *urb, struct pt_regs *regs)
61{ 61{
62 struct usb_mouse *mouse = urb->context; 62 struct usb_mouse *mouse = urb->context;
63 signed char *data = mouse->data; 63 signed char *data = mouse->data;
64 struct input_dev *dev = &mouse->dev; 64 struct input_dev *dev = mouse->dev;
65 int status; 65 int status;
66 66
67 switch (urb->status) { 67 switch (urb->status) {
@@ -115,14 +115,14 @@ static void usb_mouse_close(struct input_dev *dev)
115 usb_kill_urb(mouse->irq); 115 usb_kill_urb(mouse->irq);
116} 116}
117 117
118static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_id * id) 118static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id)
119{ 119{
120 struct usb_device * dev = interface_to_usbdev(intf); 120 struct usb_device *dev = interface_to_usbdev(intf);
121 struct usb_host_interface *interface; 121 struct usb_host_interface *interface;
122 struct usb_endpoint_descriptor *endpoint; 122 struct usb_endpoint_descriptor *endpoint;
123 struct usb_mouse *mouse; 123 struct usb_mouse *mouse;
124 struct input_dev *input_dev;
124 int pipe, maxp; 125 int pipe, maxp;
125 char path[64];
126 126
127 interface = intf->cur_altsetting; 127 interface = intf->cur_altsetting;
128 128
@@ -130,59 +130,62 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
130 return -ENODEV; 130 return -ENODEV;
131 131
132 endpoint = &interface->endpoint[0].desc; 132 endpoint = &interface->endpoint[0].desc;
133 if (!(endpoint->bEndpointAddress & 0x80)) 133 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
134 return -ENODEV; 134 return -ENODEV;
135 if ((endpoint->bmAttributes & 3) != 3) 135 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
136 return -ENODEV; 136 return -ENODEV;
137 137
138 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 138 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
139 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); 139 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
140 140
141 if (!(mouse = kmalloc(sizeof(struct usb_mouse), GFP_KERNEL))) 141 mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL);
142 return -ENOMEM; 142 input_dev = input_allocate_device();
143 memset(mouse, 0, sizeof(struct usb_mouse)); 143 if (!mouse || !input_dev)
144 goto fail1;
144 145
145 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); 146 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma);
146 if (!mouse->data) { 147 if (!mouse->data)
147 kfree(mouse); 148 goto fail1;
148 return -ENOMEM;
149 }
150 149
151 mouse->irq = usb_alloc_urb(0, GFP_KERNEL); 150 mouse->irq = usb_alloc_urb(0, GFP_KERNEL);
152 if (!mouse->irq) { 151 if (!mouse->irq)
153 usb_buffer_free(dev, 8, mouse->data, mouse->data_dma); 152 goto fail2;
154 kfree(mouse);
155 return -ENODEV;
156 }
157 153
158 mouse->usbdev = dev; 154 mouse->usbdev = dev;
155 mouse->dev = input_dev;
156
157 if (dev->manufacturer)
158 strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name));
159 159
160 mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 160 if (dev->product) {
161 mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 161 if (dev->manufacturer)
162 mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y); 162 strlcat(mouse->name, " ", sizeof(mouse->name));
163 mouse->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); 163 strlcat(mouse->name, dev->product, sizeof(mouse->name));
164 mouse->dev.relbit[0] |= BIT(REL_WHEEL); 164 }
165 165
166 mouse->dev.private = mouse; 166 if (!strlen(mouse->name))
167 mouse->dev.open = usb_mouse_open; 167 snprintf(mouse->name, sizeof(mouse->name),
168 mouse->dev.close = usb_mouse_close; 168 "USB HIDBP Mouse %04x:%04x",
169 le16_to_cpu(dev->descriptor.idVendor),
170 le16_to_cpu(dev->descriptor.idProduct));
169 171
170 usb_make_path(dev, path, 64); 172 usb_make_path(dev, mouse->phys, sizeof(mouse->phys));
171 sprintf(mouse->phys, "%s/input0", path); 173 strlcat(mouse->phys, "/input0", sizeof(mouse->phys));
172 174
173 mouse->dev.name = mouse->name; 175 input_dev->name = mouse->name;
174 mouse->dev.phys = mouse->phys; 176 input_dev->phys = mouse->phys;
175 usb_to_input_id(dev, &mouse->dev.id); 177 usb_to_input_id(dev, &input_dev->id);
176 mouse->dev.dev = &intf->dev; 178 input_dev->cdev.dev = &intf->dev;
177 179
178 if (dev->manufacturer) 180 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
179 strcat(mouse->name, dev->manufacturer); 181 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
180 if (dev->product) 182 input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
181 sprintf(mouse->name, "%s %s", mouse->name, dev->product); 183 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA);
184 input_dev->relbit[0] |= BIT(REL_WHEEL);
182 185
183 if (!strlen(mouse->name)) 186 input_dev->private = mouse;
184 sprintf(mouse->name, "USB HIDBP Mouse %04x:%04x", 187 input_dev->open = usb_mouse_open;
185 mouse->dev.id.vendor, mouse->dev.id.product); 188 input_dev->close = usb_mouse_close;
186 189
187 usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data, 190 usb_fill_int_urb(mouse->irq, dev, pipe, mouse->data,
188 (maxp > 8 ? 8 : maxp), 191 (maxp > 8 ? 8 : maxp),
@@ -190,11 +193,15 @@ static int usb_mouse_probe(struct usb_interface * intf, const struct usb_device_
190 mouse->irq->transfer_dma = mouse->data_dma; 193 mouse->irq->transfer_dma = mouse->data_dma;
191 mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 194 mouse->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
192 195
193 input_register_device(&mouse->dev); 196 input_register_device(mouse->dev);
194 printk(KERN_INFO "input: %s on %s\n", mouse->name, path);
195 197
196 usb_set_intfdata(intf, mouse); 198 usb_set_intfdata(intf, mouse);
197 return 0; 199 return 0;
200
201fail2: usb_buffer_free(dev, 8, mouse->data, mouse->data_dma);
202fail1: input_free_device(input_dev);
203 kfree(mouse);
204 return -ENOMEM;
198} 205}
199 206
200static void usb_mouse_disconnect(struct usb_interface *intf) 207static void usb_mouse_disconnect(struct usb_interface *intf)
@@ -204,7 +211,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf)
204 usb_set_intfdata(intf, NULL); 211 usb_set_intfdata(intf, NULL);
205 if (mouse) { 212 if (mouse) {
206 usb_kill_urb(mouse->irq); 213 usb_kill_urb(mouse->irq);
207 input_unregister_device(&mouse->dev); 214 input_unregister_device(mouse->dev);
208 usb_free_urb(mouse->irq); 215 usb_free_urb(mouse->irq);
209 usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma); 216 usb_buffer_free(interface_to_usbdev(intf), 8, mouse->data, mouse->data_dma);
210 kfree(mouse); 217 kfree(mouse);
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index 3b266af3048a..ea0f75773ae1 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -111,7 +111,7 @@ struct wacom_features {
111struct wacom { 111struct wacom {
112 signed char *data; 112 signed char *data;
113 dma_addr_t data_dma; 113 dma_addr_t data_dma;
114 struct input_dev dev; 114 struct input_dev *dev;
115 struct usb_device *usbdev; 115 struct usb_device *usbdev;
116 struct urb *irq; 116 struct urb *irq;
117 struct wacom_features *features; 117 struct wacom_features *features;
@@ -135,7 +135,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
135{ 135{
136 struct wacom *wacom = urb->context; 136 struct wacom *wacom = urb->context;
137 unsigned char *data = wacom->data; 137 unsigned char *data = wacom->data;
138 struct input_dev *dev = &wacom->dev; 138 struct input_dev *dev = wacom->dev;
139 int prox, pressure; 139 int prox, pressure;
140 int retval; 140 int retval;
141 141
@@ -225,7 +225,7 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
225{ 225{
226 struct wacom *wacom = urb->context; 226 struct wacom *wacom = urb->context;
227 unsigned char *data = wacom->data; 227 unsigned char *data = wacom->data;
228 struct input_dev *dev = &wacom->dev; 228 struct input_dev *dev = wacom->dev;
229 int retval; 229 int retval;
230 230
231 switch (urb->status) { 231 switch (urb->status) {
@@ -275,7 +275,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
275{ 275{
276 struct wacom *wacom = urb->context; 276 struct wacom *wacom = urb->context;
277 unsigned char *data = wacom->data; 277 unsigned char *data = wacom->data;
278 struct input_dev *dev = &wacom->dev; 278 struct input_dev *dev = wacom->dev;
279 int retval; 279 int retval;
280 280
281 switch (urb->status) { 281 switch (urb->status) {
@@ -318,7 +318,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
318{ 318{
319 struct wacom *wacom = urb->context; 319 struct wacom *wacom = urb->context;
320 unsigned char *data = wacom->data; 320 unsigned char *data = wacom->data;
321 struct input_dev *dev = &wacom->dev; 321 struct input_dev *dev = wacom->dev;
322 int x, y; 322 int x, y;
323 int retval; 323 int retval;
324 324
@@ -397,7 +397,7 @@ static int wacom_intuos_inout(struct urb *urb)
397{ 397{
398 struct wacom *wacom = urb->context; 398 struct wacom *wacom = urb->context;
399 unsigned char *data = wacom->data; 399 unsigned char *data = wacom->data;
400 struct input_dev *dev = &wacom->dev; 400 struct input_dev *dev = wacom->dev;
401 int idx; 401 int idx;
402 402
403 /* tool number */ 403 /* tool number */
@@ -479,7 +479,7 @@ static void wacom_intuos_general(struct urb *urb)
479{ 479{
480 struct wacom *wacom = urb->context; 480 struct wacom *wacom = urb->context;
481 unsigned char *data = wacom->data; 481 unsigned char *data = wacom->data;
482 struct input_dev *dev = &wacom->dev; 482 struct input_dev *dev = wacom->dev;
483 unsigned int t; 483 unsigned int t;
484 484
485 /* general pen packet */ 485 /* general pen packet */
@@ -509,7 +509,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
509{ 509{
510 struct wacom *wacom = urb->context; 510 struct wacom *wacom = urb->context;
511 unsigned char *data = wacom->data; 511 unsigned char *data = wacom->data;
512 struct input_dev *dev = &wacom->dev; 512 struct input_dev *dev = wacom->dev;
513 unsigned int t; 513 unsigned int t;
514 int idx; 514 int idx;
515 int retval; 515 int retval;
@@ -738,95 +738,83 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
738{ 738{
739 struct usb_device *dev = interface_to_usbdev(intf); 739 struct usb_device *dev = interface_to_usbdev(intf);
740 struct usb_endpoint_descriptor *endpoint; 740 struct usb_endpoint_descriptor *endpoint;
741 char rep_data[2] = {0x02, 0x02};
742 struct wacom *wacom; 741 struct wacom *wacom;
743 char path[64]; 742 struct input_dev *input_dev;
743 char rep_data[2] = {0x02, 0x02};
744 744
745 if (!(wacom = kmalloc(sizeof(struct wacom), GFP_KERNEL))) 745 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
746 return -ENOMEM; 746 input_dev = input_allocate_device();
747 memset(wacom, 0, sizeof(struct wacom)); 747 if (!wacom || !input_dev)
748 goto fail1;
748 749
749 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma); 750 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
750 if (!wacom->data) { 751 if (!wacom->data)
751 kfree(wacom); 752 goto fail1;
752 return -ENOMEM;
753 }
754 753
755 wacom->irq = usb_alloc_urb(0, GFP_KERNEL); 754 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
756 if (!wacom->irq) { 755 if (!wacom->irq)
757 usb_buffer_free(dev, 10, wacom->data, wacom->data_dma); 756 goto fail2;
758 kfree(wacom); 757
759 return -ENOMEM; 758 wacom->usbdev = dev;
760 } 759 wacom->dev = input_dev;
760 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
761 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
761 762
762 wacom->features = wacom_features + (id - wacom_ids); 763 wacom->features = wacom_features + (id - wacom_ids);
764 if (wacom->features->pktlen > 10)
765 BUG();
766
767 input_dev->name = wacom->features->name;
768 usb_to_input_id(dev, &input_dev->id);
763 769
764 wacom->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); 770 input_dev->cdev.dev = &intf->dev;
765 wacom->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); 771 input_dev->private = wacom;
766 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); 772 input_dev->open = wacom_open;
773 input_dev->close = wacom_close;
774
775 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
776 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
777 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0);
778 input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0);
779 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0);
767 780
768 switch (wacom->features->type) { 781 switch (wacom->features->type) {
769 case GRAPHIRE: 782 case GRAPHIRE:
770 wacom->dev.evbit[0] |= BIT(EV_REL); 783 input_dev->evbit[0] |= BIT(EV_REL);
771 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 784 input_dev->relbit[0] |= BIT(REL_WHEEL);
772 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE); 785 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
773 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 786 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
774 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2); 787 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
775 break; 788 break;
776 789
777 case INTUOS3: 790 case INTUOS3:
778 case CINTIQ: 791 case CINTIQ:
779 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 792 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
780 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 793 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
781 wacom->dev.absbit[0] |= BIT(ABS_RX) | BIT(ABS_RY); 794 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
795 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
782 /* fall through */ 796 /* fall through */
783 797
784 case INTUOS: 798 case INTUOS:
785 wacom->dev.evbit[0] |= BIT(EV_MSC) | BIT(EV_REL); 799 input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
786 wacom->dev.mscbit[0] |= BIT(MSC_SERIAL); 800 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
787 wacom->dev.relbit[0] |= BIT(REL_WHEEL); 801 input_dev->relbit[0] |= BIT(REL_WHEEL);
788 wacom->dev.keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA); 802 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
789 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH) 803 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
790 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2); 804 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
791 wacom->dev.absbit[0] |= BIT(ABS_DISTANCE) | BIT(ABS_WHEEL) | BIT(ABS_TILT_X) | BIT(ABS_TILT_Y) | BIT(ABS_RZ) | BIT(ABS_THROTTLE); 805 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
806 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
807 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
808 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
809 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
810 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
792 break; 811 break;
793 812
794 case PL: 813 case PL:
795 wacom->dev.keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER); 814 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);
796 break; 815 break;
797 } 816 }
798 817
799 wacom->dev.absmax[ABS_X] = wacom->features->x_max;
800 wacom->dev.absmax[ABS_Y] = wacom->features->y_max;
801 wacom->dev.absmax[ABS_PRESSURE] = wacom->features->pressure_max;
802 wacom->dev.absmax[ABS_DISTANCE] = wacom->features->distance_max;
803 wacom->dev.absmax[ABS_TILT_X] = 127;
804 wacom->dev.absmax[ABS_TILT_Y] = 127;
805 wacom->dev.absmax[ABS_WHEEL] = 1023;
806
807 wacom->dev.absmax[ABS_RX] = 4097;
808 wacom->dev.absmax[ABS_RY] = 4097;
809 wacom->dev.absmin[ABS_RZ] = -900;
810 wacom->dev.absmax[ABS_RZ] = 899;
811 wacom->dev.absmin[ABS_THROTTLE] = -1023;
812 wacom->dev.absmax[ABS_THROTTLE] = 1023;
813
814 wacom->dev.absfuzz[ABS_X] = 4;
815 wacom->dev.absfuzz[ABS_Y] = 4;
816
817 wacom->dev.private = wacom;
818 wacom->dev.open = wacom_open;
819 wacom->dev.close = wacom_close;
820
821 usb_make_path(dev, path, 64);
822 sprintf(wacom->phys, "%s/input0", path);
823
824 wacom->dev.name = wacom->features->name;
825 wacom->dev.phys = wacom->phys;
826 usb_to_input_id(dev, &wacom->dev.id);
827 wacom->dev.dev = &intf->dev;
828 wacom->usbdev = dev;
829
830 endpoint = &intf->cur_altsetting->endpoint[0].desc; 818 endpoint = &intf->cur_altsetting->endpoint[0].desc;
831 819
832 if (wacom->features->pktlen > 10) 820 if (wacom->features->pktlen > 10)
@@ -839,18 +827,20 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
839 wacom->irq->transfer_dma = wacom->data_dma; 827 wacom->irq->transfer_dma = wacom->data_dma;
840 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 828 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
841 829
842 input_register_device(&wacom->dev); 830 input_register_device(wacom->dev);
843 831
844 /* ask the tablet to report tablet data */ 832 /* ask the tablet to report tablet data */
845 usb_set_report(intf, 3, 2, rep_data, 2); 833 usb_set_report(intf, 3, 2, rep_data, 2);
846 /* repeat once (not sure why the first call often fails) */ 834 /* repeat once (not sure why the first call often fails) */
847 usb_set_report(intf, 3, 2, rep_data, 2); 835 usb_set_report(intf, 3, 2, rep_data, 2);
848 836
849 printk(KERN_INFO "input: %s on %s\n", wacom->features->name, path);
850
851 usb_set_intfdata(intf, wacom); 837 usb_set_intfdata(intf, wacom);
852
853 return 0; 838 return 0;
839
840fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
841fail1: input_free_device(input_dev);
842 kfree(wacom);
843 return -ENOMEM;
854} 844}
855 845
856static void wacom_disconnect(struct usb_interface *intf) 846static void wacom_disconnect(struct usb_interface *intf)
@@ -860,7 +850,7 @@ static void wacom_disconnect(struct usb_interface *intf)
860 usb_set_intfdata(intf, NULL); 850 usb_set_intfdata(intf, NULL);
861 if (wacom) { 851 if (wacom) {
862 usb_kill_urb(wacom->irq); 852 usb_kill_urb(wacom->irq);
863 input_unregister_device(&wacom->dev); 853 input_unregister_device(wacom->dev);
864 usb_free_urb(wacom->irq); 854 usb_free_urb(wacom->irq);
865 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma); 855 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
866 kfree(wacom); 856 kfree(wacom);
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index 18125e0bffa2..43112f040b6d 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -103,7 +103,7 @@ static struct usb_device_id xpad_table [] = {
103MODULE_DEVICE_TABLE (usb, xpad_table); 103MODULE_DEVICE_TABLE (usb, xpad_table);
104 104
105struct usb_xpad { 105struct usb_xpad {
106 struct input_dev dev; /* input device interface */ 106 struct input_dev *dev; /* input device interface */
107 struct usb_device *udev; /* usb device */ 107 struct usb_device *udev; /* usb device */
108 108
109 struct urb *irq_in; /* urb for interrupt in report */ 109 struct urb *irq_in; /* urb for interrupt in report */
@@ -125,7 +125,7 @@ struct usb_xpad {
125 125
126static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs) 126static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, struct pt_regs *regs)
127{ 127{
128 struct input_dev *dev = &xpad->dev; 128 struct input_dev *dev = xpad->dev;
129 129
130 input_regs(dev, regs); 130 input_regs(dev, regs);
131 131
@@ -214,9 +214,9 @@ static void xpad_close (struct input_dev *dev)
214static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 214static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
215{ 215{
216 struct usb_device *udev = interface_to_usbdev (intf); 216 struct usb_device *udev = interface_to_usbdev (intf);
217 struct usb_xpad *xpad = NULL; 217 struct usb_xpad *xpad;
218 struct input_dev *input_dev;
218 struct usb_endpoint_descriptor *ep_irq_in; 219 struct usb_endpoint_descriptor *ep_irq_in;
219 char path[64];
220 int i; 220 int i;
221 221
222 for (i = 0; xpad_device[i].idVendor; i++) { 222 for (i = 0; xpad_device[i].idVendor; i++) {
@@ -225,89 +225,80 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
225 break; 225 break;
226 } 226 }
227 227
228 if ((xpad = kmalloc (sizeof(struct usb_xpad), GFP_KERNEL)) == NULL) { 228 xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
229 err("cannot allocate memory for new pad"); 229 input_dev = input_allocate_device();
230 return -ENOMEM; 230 if (!xpad || !input_dev)
231 } 231 goto fail1;
232 memset(xpad, 0, sizeof(struct usb_xpad));
233 232
234 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 233 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
235 SLAB_ATOMIC, &xpad->idata_dma); 234 SLAB_ATOMIC, &xpad->idata_dma);
236 if (!xpad->idata) { 235 if (!xpad->idata)
237 kfree(xpad); 236 goto fail1;
238 return -ENOMEM;
239 }
240 237
241 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); 238 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
242 if (!xpad->irq_in) { 239 if (!xpad->irq_in)
243 err("cannot allocate memory for new pad irq urb"); 240 goto fail2;
244 usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
245 kfree(xpad);
246 return -ENOMEM;
247 }
248
249 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
250
251 usb_fill_int_urb(xpad->irq_in, udev,
252 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
253 xpad->idata, XPAD_PKT_LEN, xpad_irq_in,
254 xpad, ep_irq_in->bInterval);
255 xpad->irq_in->transfer_dma = xpad->idata_dma;
256 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
257 241
258 xpad->udev = udev; 242 xpad->udev = udev;
243 xpad->dev = input_dev;
244 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
245 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
259 246
260 usb_to_input_id(udev, &xpad->dev.id); 247 input_dev->name = xpad_device[i].name;
261 xpad->dev.dev = &intf->dev; 248 input_dev->phys = xpad->phys;
262 xpad->dev.private = xpad; 249 usb_to_input_id(udev, &input_dev->id);
263 xpad->dev.name = xpad_device[i].name; 250 input_dev->cdev.dev = &intf->dev;
264 xpad->dev.phys = xpad->phys; 251 input_dev->private = xpad;
265 xpad->dev.open = xpad_open; 252 input_dev->open = xpad_open;
266 xpad->dev.close = xpad_close; 253 input_dev->close = xpad_close;
267
268 usb_make_path(udev, path, 64);
269 snprintf(xpad->phys, 64, "%s/input0", path);
270 254
271 xpad->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 255 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
272 256
273 for (i = 0; xpad_btn[i] >= 0; i++) 257 for (i = 0; xpad_btn[i] >= 0; i++)
274 set_bit(xpad_btn[i], xpad->dev.keybit); 258 set_bit(xpad_btn[i], input_dev->keybit);
275 259
276 for (i = 0; xpad_abs[i] >= 0; i++) { 260 for (i = 0; xpad_abs[i] >= 0; i++) {
277 261
278 signed short t = xpad_abs[i]; 262 signed short t = xpad_abs[i];
279 263
280 set_bit(t, xpad->dev.absbit); 264 set_bit(t, input_dev->absbit);
281 265
282 switch (t) { 266 switch (t) {
283 case ABS_X: 267 case ABS_X:
284 case ABS_Y: 268 case ABS_Y:
285 case ABS_RX: 269 case ABS_RX:
286 case ABS_RY: /* the two sticks */ 270 case ABS_RY: /* the two sticks */
287 xpad->dev.absmax[t] = 32767; 271 input_set_abs_params(input_dev, t, -32768, 32767, 16, 128);
288 xpad->dev.absmin[t] = -32768;
289 xpad->dev.absflat[t] = 128;
290 xpad->dev.absfuzz[t] = 16;
291 break; 272 break;
292 case ABS_Z: 273 case ABS_Z:
293 case ABS_RZ: /* the triggers */ 274 case ABS_RZ: /* the triggers */
294 xpad->dev.absmax[t] = 255; 275 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
295 xpad->dev.absmin[t] = 0;
296 break; 276 break;
297 case ABS_HAT0X: 277 case ABS_HAT0X:
298 case ABS_HAT0Y: /* the d-pad */ 278 case ABS_HAT0Y: /* the d-pad */
299 xpad->dev.absmax[t] = 1; 279 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
300 xpad->dev.absmin[t] = -1;
301 break; 280 break;
302 } 281 }
303 } 282 }
304 283
305 input_register_device(&xpad->dev); 284 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
285 usb_fill_int_urb(xpad->irq_in, udev,
286 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
287 xpad->idata, XPAD_PKT_LEN, xpad_irq_in,
288 xpad, ep_irq_in->bInterval);
289 xpad->irq_in->transfer_dma = xpad->idata_dma;
290 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
306 291
307 printk(KERN_INFO "input: %s on %s", xpad->dev.name, path); 292 input_register_device(xpad->dev);
308 293
309 usb_set_intfdata(intf, xpad); 294 usb_set_intfdata(intf, xpad);
310 return 0; 295 return 0;
296
297fail2: usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
298fail1: input_free_device(input_dev);
299 kfree(xpad);
300 return -ENOMEM;
301
311} 302}
312 303
313static void xpad_disconnect(struct usb_interface *intf) 304static void xpad_disconnect(struct usb_interface *intf)
@@ -317,7 +308,7 @@ static void xpad_disconnect(struct usb_interface *intf)
317 usb_set_intfdata(intf, NULL); 308 usb_set_intfdata(intf, NULL);
318 if (xpad) { 309 if (xpad) {
319 usb_kill_urb(xpad->irq_in); 310 usb_kill_urb(xpad->irq_in);
320 input_unregister_device(&xpad->dev); 311 input_unregister_device(xpad->dev);
321 usb_free_urb(xpad->irq_in); 312 usb_free_urb(xpad->irq_in);
322 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 313 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
323 kfree(xpad); 314 kfree(xpad);
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 58a176ef96a5..f526aebea502 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -54,6 +54,7 @@
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/rwsem.h> 55#include <linux/rwsem.h>
56#include <linux/usb.h> 56#include <linux/usb.h>
57#include <linux/usb_input.h>
57 58
58#include "map_to_7segment.h" 59#include "map_to_7segment.h"
59#include "yealink.h" 60#include "yealink.h"
@@ -101,12 +102,12 @@ static const struct lcd_segment_map {
101}; 102};
102 103
103struct yealink_dev { 104struct yealink_dev {
104 struct input_dev idev; /* input device */ 105 struct input_dev *idev; /* input device */
105 struct usb_device *udev; /* usb device */ 106 struct usb_device *udev; /* usb device */
106 107
107 /* irq input channel */ 108 /* irq input channel */
108 struct yld_ctl_packet *irq_data; 109 struct yld_ctl_packet *irq_data;
109 dma_addr_t irq_dma; 110 dma_addr_t irq_dma;
110 struct urb *urb_irq; 111 struct urb *urb_irq;
111 112
112 /* control output channel */ 113 /* control output channel */
@@ -237,7 +238,7 @@ static int map_p1k_to_key(int scancode)
237 */ 238 */
238static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs) 239static void report_key(struct yealink_dev *yld, int key, struct pt_regs *regs)
239{ 240{
240 struct input_dev *idev = &yld->idev; 241 struct input_dev *idev = yld->idev;
241 242
242 input_regs(idev, regs); 243 input_regs(idev, regs);
243 if (yld->key_code >= 0) { 244 if (yld->key_code >= 0) {
@@ -809,8 +810,12 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
809 } 810 }
810 if (yld->urb_ctl) 811 if (yld->urb_ctl)
811 usb_free_urb(yld->urb_ctl); 812 usb_free_urb(yld->urb_ctl);
812 if (yld->idev.dev) 813 if (yld->idev) {
813 input_unregister_device(&yld->idev); 814 if (err)
815 input_free_device(yld->idev);
816 else
817 input_unregister_device(yld->idev);
818 }
814 if (yld->ctl_req) 819 if (yld->ctl_req)
815 usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)), 820 usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)),
816 yld->ctl_req, yld->ctl_req_dma); 821 yld->ctl_req, yld->ctl_req_dma);
@@ -857,7 +862,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
857 struct usb_host_interface *interface; 862 struct usb_host_interface *interface;
858 struct usb_endpoint_descriptor *endpoint; 863 struct usb_endpoint_descriptor *endpoint;
859 struct yealink_dev *yld; 864 struct yealink_dev *yld;
860 char path[64]; 865 struct input_dev *input_dev;
861 int ret, pipe, i; 866 int ret, pipe, i;
862 867
863 i = usb_match(udev); 868 i = usb_match(udev);
@@ -866,17 +871,21 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
866 871
867 interface = intf->cur_altsetting; 872 interface = intf->cur_altsetting;
868 endpoint = &interface->endpoint[0].desc; 873 endpoint = &interface->endpoint[0].desc;
869 if (!(endpoint->bEndpointAddress & 0x80)) 874 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
870 return -EIO; 875 return -EIO;
871 if ((endpoint->bmAttributes & 3) != 3) 876 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
872 return -EIO; 877 return -EIO;
873 878
874 if ((yld = kmalloc(sizeof(struct yealink_dev), GFP_KERNEL)) == NULL) 879 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL);
880 if (!yld)
875 return -ENOMEM; 881 return -ENOMEM;
876 882
877 memset(yld, 0, sizeof(*yld));
878 yld->udev = udev; 883 yld->udev = udev;
879 884
885 yld->idev = input_dev = input_allocate_device();
886 if (!input_dev)
887 return usb_cleanup(yld, -ENOMEM);
888
880 /* allocate usb buffers */ 889 /* allocate usb buffers */
881 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 890 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
882 SLAB_ATOMIC, &yld->irq_dma); 891 SLAB_ATOMIC, &yld->irq_dma);
@@ -935,42 +944,37 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
935 yld->urb_ctl->dev = udev; 944 yld->urb_ctl->dev = udev;
936 945
937 /* find out the physical bus location */ 946 /* find out the physical bus location */
938 if (usb_make_path(udev, path, sizeof(path)) > 0) 947 usb_make_path(udev, yld->phys, sizeof(yld->phys));
939 snprintf(yld->phys, sizeof(yld->phys)-1, "%s/input0", path); 948 strlcat(yld->phys, "/input0", sizeof(yld->phys));
940 949
941 /* register settings for the input device */ 950 /* register settings for the input device */
942 init_input_dev(&yld->idev); 951 input_dev->name = yld_device[i].name;
943 yld->idev.private = yld; 952 input_dev->phys = yld->phys;
944 yld->idev.id.bustype = BUS_USB; 953 usb_to_input_id(udev, &input_dev->id);
945 yld->idev.id.vendor = le16_to_cpu(udev->descriptor.idVendor); 954 input_dev->cdev.dev = &intf->dev;
946 yld->idev.id.product = le16_to_cpu(udev->descriptor.idProduct); 955
947 yld->idev.id.version = le16_to_cpu(udev->descriptor.bcdDevice); 956 input_dev->private = yld;
948 yld->idev.dev = &intf->dev; 957 input_dev->open = input_open;
949 yld->idev.name = yld_device[i].name; 958 input_dev->close = input_close;
950 yld->idev.phys = yld->phys; 959 /* input_dev->event = input_ev; TODO */
951 /* yld->idev.event = input_ev; TODO */
952 yld->idev.open = input_open;
953 yld->idev.close = input_close;
954 960
955 /* register available key events */ 961 /* register available key events */
956 yld->idev.evbit[0] = BIT(EV_KEY); 962 input_dev->evbit[0] = BIT(EV_KEY);
957 for (i = 0; i < 256; i++) { 963 for (i = 0; i < 256; i++) {
958 int k = map_p1k_to_key(i); 964 int k = map_p1k_to_key(i);
959 if (k >= 0) { 965 if (k >= 0) {
960 set_bit(k & 0xff, yld->idev.keybit); 966 set_bit(k & 0xff, input_dev->keybit);
961 if (k >> 8) 967 if (k >> 8)
962 set_bit(k >> 8, yld->idev.keybit); 968 set_bit(k >> 8, input_dev->keybit);
963 } 969 }
964 } 970 }
965 971
966 printk(KERN_INFO "input: %s on %s\n", yld->idev.name, path); 972 input_register_device(yld->idev);
967
968 input_register_device(&yld->idev);
969 973
970 usb_set_intfdata(intf, yld); 974 usb_set_intfdata(intf, yld);
971 975
972 /* clear visible elements */ 976 /* clear visible elements */
973 for (i=0; i<ARRAY_SIZE(lcdMap); i++) 977 for (i = 0; i < ARRAY_SIZE(lcdMap); i++)
974 setChar(yld, i, ' '); 978 setChar(yld, i, ' ');
975 979
976 /* display driver version on LCD line 3 */ 980 /* display driver version on LCD line 3 */
diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
index 6ca2fae99d2d..27b23c55bbc7 100644
--- a/drivers/usb/media/dabusb.c
+++ b/drivers/usb/media/dabusb.c
@@ -707,9 +707,8 @@ static struct file_operations dabusb_fops =
707}; 707};
708 708
709static struct usb_class_driver dabusb_class = { 709static struct usb_class_driver dabusb_class = {
710 .name = "usb/dabusb%d", 710 .name = "dabusb%d",
711 .fops = &dabusb_fops, 711 .fops = &dabusb_fops,
712 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
713 .minor_base = DABUSB_MINOR, 712 .minor_base = DABUSB_MINOR,
714}; 713};
715 714
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
index 20ac9e1069d4..9fe2c2710d13 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/usb/media/konicawc.c
@@ -119,7 +119,7 @@ struct konicawc {
119 int yplanesz; /* Number of bytes in the Y plane */ 119 int yplanesz; /* Number of bytes in the Y plane */
120 unsigned int buttonsts:1; 120 unsigned int buttonsts:1;
121#ifdef CONFIG_INPUT 121#ifdef CONFIG_INPUT
122 struct input_dev input; 122 struct input_dev *input;
123 char input_physname[64]; 123 char input_physname[64];
124#endif 124#endif
125}; 125};
@@ -218,6 +218,57 @@ static void konicawc_adjust_picture(struct uvd *uvd)
218 konicawc_camera_on(uvd); 218 konicawc_camera_on(uvd);
219} 219}
220 220
221#ifdef CONFIG_INPUT
222
223static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev)
224{
225 struct input_dev *input_dev;
226
227 usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
228 strncat(cam->input_physname, "/input0", sizeof(cam->input_physname));
229
230 cam->input = input_dev = input_allocate_device();
231 if (!input_dev) {
232 warn("Not enough memory for camera's input device\n");
233 return;
234 }
235
236 input_dev->name = "Konicawc snapshot button";
237 input_dev->phys = cam->input_physname;
238 usb_to_input_id(dev, &input_dev->id);
239 input_dev->cdev.dev = &dev->dev;
240
241 input_dev->evbit[0] = BIT(EV_KEY);
242 input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0);
243
244 input_dev->private = cam;
245
246 input_register_device(cam->input);
247}
248
249static void konicawc_unregister_input(struct konicawc *cam)
250{
251 if (cam->input) {
252 input_unregister_device(cam->input);
253 cam->input = NULL;
254 }
255}
256
257static void konicawc_report_buttonstat(struct konicawc *cam)
258{
259 if (cam->input) {
260 input_report_key(cam->input, BTN_0, cam->buttonsts);
261 input_sync(cam->input);
262 }
263}
264
265#else
266
267static inline void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) { }
268static inline void konicawc_unregister_input(struct konicawc *cam) { }
269static inline void konicawc_report_buttonstat(struct konicawc *cam) { }
270
271#endif /* CONFIG_INPUT */
221 272
222static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) 273static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb)
223{ 274{
@@ -273,10 +324,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
273 if(button != cam->buttonsts) { 324 if(button != cam->buttonsts) {
274 DEBUG(2, "button: %sclicked", button ? "" : "un"); 325 DEBUG(2, "button: %sclicked", button ? "" : "un");
275 cam->buttonsts = button; 326 cam->buttonsts = button;
276#ifdef CONFIG_INPUT 327 konicawc_report_buttonstat(cam);
277 input_report_key(&cam->input, BTN_0, cam->buttonsts);
278 input_sync(&cam->input);
279#endif
280 } 328 }
281 329
282 if(sts == 0x01) { /* drop frame */ 330 if(sts == 0x01) { /* drop frame */
@@ -645,9 +693,9 @@ static int konicawc_set_video_mode(struct uvd *uvd, struct video_window *vw)
645 RingQueue_Flush(&uvd->dp); 693 RingQueue_Flush(&uvd->dp);
646 cam->lastframe = -2; 694 cam->lastframe = -2;
647 if(uvd->curframe != -1) { 695 if(uvd->curframe != -1) {
648 uvd->frame[uvd->curframe].curline = 0; 696 uvd->frame[uvd->curframe].curline = 0;
649 uvd->frame[uvd->curframe].seqRead_Length = 0; 697 uvd->frame[uvd->curframe].seqRead_Length = 0;
650 uvd->frame[uvd->curframe].seqRead_Index = 0; 698 uvd->frame[uvd->curframe].seqRead_Index = 0;
651 } 699 }
652 700
653 konicawc_start_data(uvd); 701 konicawc_start_data(uvd);
@@ -718,7 +766,6 @@ static void konicawc_configure_video(struct uvd *uvd)
718 DEBUG(1, "setting initial values"); 766 DEBUG(1, "setting initial values");
719} 767}
720 768
721
722static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) 769static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid)
723{ 770{
724 struct usb_device *dev = interface_to_usbdev(intf); 771 struct usb_device *dev = interface_to_usbdev(intf);
@@ -839,21 +886,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
839 err("usbvideo_RegisterVideoDevice() failed."); 886 err("usbvideo_RegisterVideoDevice() failed.");
840 uvd = NULL; 887 uvd = NULL;
841 } 888 }
842#ifdef CONFIG_INPUT 889
843 /* Register input device for button */ 890 konicawc_register_input(cam, dev);
844 memset(&cam->input, 0, sizeof(struct input_dev));
845 cam->input.name = "Konicawc snapshot button";
846 cam->input.private = cam;
847 cam->input.evbit[0] = BIT(EV_KEY);
848 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
849 usb_to_input_id(dev, &cam->input.id);
850 input_register_device(&cam->input);
851
852 usb_make_path(dev, cam->input_physname, 56);
853 strcat(cam->input_physname, "/input0");
854 cam->input.phys = cam->input_physname;
855 info("konicawc: %s on %s\n", cam->input.name, cam->input.phys);
856#endif
857 } 891 }
858 892
859 if (uvd) { 893 if (uvd) {
@@ -869,10 +903,9 @@ static void konicawc_free_uvd(struct uvd *uvd)
869 int i; 903 int i;
870 struct konicawc *cam = (struct konicawc *)uvd->user_data; 904 struct konicawc *cam = (struct konicawc *)uvd->user_data;
871 905
872#ifdef CONFIG_INPUT 906 konicawc_unregister_input(cam);
873 input_unregister_device(&cam->input); 907
874#endif 908 for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
875 for (i=0; i < USBVIDEO_NUMSBUF; i++) {
876 usb_free_urb(cam->sts_urb[i]); 909 usb_free_urb(cam->sts_urb[i]);
877 cam->sts_urb[i] = NULL; 910 cam->sts_urb[i] = NULL;
878 } 911 }
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index ae4681f9f0ea..5f33f7c64885 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -1873,9 +1873,8 @@ static struct file_operations auerswald_fops =
1873}; 1873};
1874 1874
1875static struct usb_class_driver auerswald_class = { 1875static struct usb_class_driver auerswald_class = {
1876 .name = "usb/auer%d", 1876 .name = "auer%d",
1877 .fops = &auerswald_fops, 1877 .fops = &auerswald_fops,
1878 .mode = S_IFCHR | S_IRUGO | S_IWUGO,
1879 .minor_base = AUER_MINOR_BASE, 1878 .minor_base = AUER_MINOR_BASE,
1880}; 1879};
1881 1880
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 733acc213726..3944a55ed74c 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -105,11 +105,10 @@ static struct file_operations idmouse_fops = {
105 .release = idmouse_release, 105 .release = idmouse_release,
106}; 106};
107 107
108/* class driver information for devfs */ 108/* class driver information */
109static struct usb_class_driver idmouse_class = { 109static struct usb_class_driver idmouse_class = {
110 .name = "usb/idmouse%d", 110 .name = "idmouse%d",
111 .fops = &idmouse_fops, 111 .fops = &idmouse_fops,
112 .mode = S_IFCHR | S_IRUSR | S_IRGRP | S_IROTH, /* filemode (char, 444) */
113 .minor_base = USB_IDMOUSE_MINOR_BASE, 112 .minor_base = USB_IDMOUSE_MINOR_BASE,
114}; 113};
115 114
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 7d06105763d4..2703e205bc8f 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -271,12 +271,11 @@ static struct file_operations tower_fops = {
271 271
272/* 272/*
273 * usb class driver info in order to get a minor number from the usb core, 273 * usb class driver info in order to get a minor number from the usb core,
274 * and to have the device registered with devfs and the driver core 274 * and to have the device registered with the driver core
275 */ 275 */
276static struct usb_class_driver tower_class = { 276static struct usb_class_driver tower_class = {
277 .name = "usb/legousbtower%d", 277 .name = "legousbtower%d",
278 .fops = &tower_fops, 278 .fops = &tower_fops,
279 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
280 .minor_base = LEGO_USB_TOWER_MINOR_BASE, 279 .minor_base = LEGO_USB_TOWER_MINOR_BASE,
281}; 280};
282 281
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index 26f77e29c7a6..7d02d8ec6b1a 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -443,9 +443,8 @@ file_operations usb_rio_fops = {
443}; 443};
444 444
445static struct usb_class_driver usb_rio_class = { 445static struct usb_class_driver usb_rio_class = {
446 .name = "usb/rio500%d", 446 .name = "rio500%d",
447 .fops = &usb_rio_fops, 447 .fops = &usb_rio_fops,
448 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
449 .minor_base = RIO_MINOR, 448 .minor_base = RIO_MINOR,
450}; 449};
451 450
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 39db3155723a..c946c9a538a0 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -2440,7 +2440,7 @@ int
2440sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init) 2440sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)
2441{ 2441{
2442 int ret = 0, slot = sisusb->font_slot, i; 2442 int ret = 0, slot = sisusb->font_slot, i;
2443 struct font_desc *myfont; 2443 const struct font_desc *myfont;
2444 u8 *tempbuf; 2444 u8 *tempbuf;
2445 u16 *tempbufb; 2445 u16 *tempbufb;
2446 size_t written; 2446 size_t written;
@@ -3239,12 +3239,7 @@ static struct file_operations usb_sisusb_fops = {
3239}; 3239};
3240 3240
3241static struct usb_class_driver usb_sisusb_class = { 3241static struct usb_class_driver usb_sisusb_class = {
3242#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
3243 .name = "usb/sisusbvga%d",
3244 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
3245#else
3246 .name = "sisusbvga%d", 3242 .name = "sisusbvga%d",
3247#endif
3248 .fops = &usb_sisusb_fops, 3243 .fops = &usb_sisusb_fops,
3249 .minor_base = SISUSB_MINOR 3244 .minor_base = SISUSB_MINOR
3250}; 3245};
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 096ab3029676..85f3725334b0 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -251,13 +251,12 @@ static struct file_operations lcd_fops = {
251}; 251};
252 252
253/* 253/*
254 * * usb class driver info in order to get a minor number from the usb core, 254 * usb class driver info in order to get a minor number from the usb core,
255 * * and to have the device registered with devfs and the driver core 255 * and to have the device registered with the driver core
256 * */ 256 */
257static struct usb_class_driver lcd_class = { 257static struct usb_class_driver lcd_class = {
258 .name = "usb/lcd%d", 258 .name = "lcd%d",
259 .fops = &lcd_fops, 259 .fops = &lcd_fops,
260 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
261 .minor_base = USBLCD_MINOR, 260 .minor_base = USBLCD_MINOR,
262}; 261};
263 262
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 54799eb0bc60..90a96257d6ce 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -983,6 +983,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
983 reqp->number = i % NUM_SUBCASES; 983 reqp->number = i % NUM_SUBCASES;
984 reqp->expected = expected; 984 reqp->expected = expected;
985 u->setup_packet = (char *) &reqp->setup; 985 u->setup_packet = (char *) &reqp->setup;
986 u->transfer_flags |= URB_NO_SETUP_DMA_MAP;
986 987
987 u->context = &context; 988 u->context = &context;
988 u->complete = ctrl_complete; 989 u->complete = ctrl_complete;
@@ -1948,21 +1949,11 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1948 1949
1949static int usbtest_suspend (struct usb_interface *intf, pm_message_t message) 1950static int usbtest_suspend (struct usb_interface *intf, pm_message_t message)
1950{ 1951{
1951 struct usbtest_dev *dev = usb_get_intfdata (intf);
1952
1953 down (&dev->sem);
1954 intf->dev.power.power_state = PMSG_SUSPEND;
1955 up (&dev->sem);
1956 return 0; 1952 return 0;
1957} 1953}
1958 1954
1959static int usbtest_resume (struct usb_interface *intf) 1955static int usbtest_resume (struct usb_interface *intf)
1960{ 1956{
1961 struct usbtest_dev *dev = usb_get_intfdata (intf);
1962
1963 down (&dev->sem);
1964 intf->dev.power.power_state = PMSG_ON;
1965 up (&dev->sem);
1966 return 0; 1957 return 0;
1967} 1958}
1968 1959
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 03fb70ef2eb3..0592cb5e6c4d 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -137,7 +137,7 @@ static void async_complete(struct urb *urb, struct pt_regs *ptregs)
137 137
138static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv, 138static struct uss720_async_request *submit_async_request(struct parport_uss720_private *priv,
139 __u8 request, __u8 requesttype, __u16 value, __u16 index, 139 __u8 request, __u8 requesttype, __u16 value, __u16 index,
140 unsigned int mem_flags) 140 gfp_t mem_flags)
141{ 141{
142 struct usb_device *usbdev; 142 struct usb_device *usbdev;
143 struct uss720_async_request *rq; 143 struct uss720_async_request *rq;
@@ -204,7 +204,7 @@ static unsigned int kill_all_async_requests_priv(struct parport_uss720_private *
204 204
205/* --------------------------------------------------------------------- */ 205/* --------------------------------------------------------------------- */
206 206
207static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, unsigned int mem_flags) 207static int get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, gfp_t mem_flags)
208{ 208{
209 struct parport_uss720_private *priv; 209 struct parport_uss720_private *priv;
210 struct uss720_async_request *rq; 210 struct uss720_async_request *rq;
@@ -238,7 +238,7 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha
238 return -EIO; 238 return -EIO;
239} 239}
240 240
241static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, unsigned int mem_flags) 241static int set_1284_register(struct parport *pp, unsigned char reg, unsigned char val, gfp_t mem_flags)
242{ 242{
243 struct parport_uss720_private *priv; 243 struct parport_uss720_private *priv;
244 struct uss720_async_request *rq; 244 struct uss720_async_request *rq;
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index 508a21028db4..c34944c75047 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -11,6 +11,7 @@
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/notifier.h>
14 15
15#include "usb_mon.h" 16#include "usb_mon.h"
16#include "../core/hcd.h" 17#include "../core/hcd.h"
@@ -205,6 +206,23 @@ static void mon_bus_remove(struct usb_bus *ubus)
205 up(&mon_lock); 206 up(&mon_lock);
206} 207}
207 208
209static int mon_notify(struct notifier_block *self, unsigned long action,
210 void *dev)
211{
212 switch (action) {
213 case USB_BUS_ADD:
214 mon_bus_add(dev);
215 break;
216 case USB_BUS_REMOVE:
217 mon_bus_remove(dev);
218 }
219 return NOTIFY_OK;
220}
221
222static struct notifier_block mon_nb = {
223 .notifier_call = mon_notify,
224};
225
208/* 226/*
209 * Ops 227 * Ops
210 */ 228 */
@@ -212,8 +230,6 @@ static struct usb_mon_operations mon_ops_0 = {
212 .urb_submit = mon_submit, 230 .urb_submit = mon_submit,
213 .urb_submit_error = mon_submit_error, 231 .urb_submit_error = mon_submit_error,
214 .urb_complete = mon_complete, 232 .urb_complete = mon_complete,
215 .bus_add = mon_bus_add,
216 .bus_remove = mon_bus_remove,
217}; 233};
218 234
219/* 235/*
@@ -329,6 +345,8 @@ static int __init mon_init(void)
329 } 345 }
330 // MOD_INC_USE_COUNT(which_module?); 346 // MOD_INC_USE_COUNT(which_module?);
331 347
348 usb_register_notify(&mon_nb);
349
332 down(&usb_bus_list_lock); 350 down(&usb_bus_list_lock);
333 list_for_each_entry (ubus, &usb_bus_list, bus_list) { 351 list_for_each_entry (ubus, &usb_bus_list, bus_list) {
334 mon_bus_init(mondir, ubus); 352 mon_bus_init(mondir, ubus);
@@ -342,6 +360,7 @@ static void __exit mon_exit(void)
342 struct mon_bus *mbus; 360 struct mon_bus *mbus;
343 struct list_head *p; 361 struct list_head *p;
344 362
363 usb_unregister_notify(&mon_nb);
345 usb_mon_deregister(); 364 usb_mon_deregister();
346 365
347 down(&mon_lock); 366 down(&mon_lock);
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 8c010bb44eb8..efd6ca7e4ac5 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -294,7 +294,7 @@ config USB_NET_ZAURUS
294 This also supports some related device firmware, as used in some 294 This also supports some related device firmware, as used in some
295 PDAs from Olympus and some cell phones from Motorola. 295 PDAs from Olympus and some cell phones from Motorola.
296 296
297 If you install an alternate ROM image, such as the Linux 2.6 based 297 If you install an alternate image, such as the Linux 2.6 based
298 versions of OpenZaurus, you should no longer need to support this 298 versions of OpenZaurus, you should no longer need to support this
299 protocol. Only the "eth-fd" or "net_fd" drivers in these devices 299 protocol. Only the "eth-fd" or "net_fd" drivers in these devices
300 really need this non-conformant variant of CDC Ethernet (or in 300 really need this non-conformant variant of CDC Ethernet (or in
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 861f00a43750..252a34fbb42c 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -753,7 +753,7 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
753} 753}
754 754
755static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, 755static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
756 unsigned flags) 756 gfp_t flags)
757{ 757{
758 int padlen; 758 int padlen;
759 int headroom = skb_headroom(skb); 759 int headroom = skb_headroom(skb);
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
index c8763ae33c73..c0f263b202a6 100644
--- a/drivers/usb/net/gl620a.c
+++ b/drivers/usb/net/gl620a.c
@@ -301,7 +301,7 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
301} 301}
302 302
303static struct sk_buff * 303static struct sk_buff *
304genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) 304genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
305{ 305{
306 int padlen; 306 int padlen;
307 int length = skb->len; 307 int length = skb->len;
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index e04b0ce3611a..6bef1be6b36c 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -469,7 +469,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
469 0, 469 0,
470 KAWETH_CONTROL_TIMEOUT); 470 KAWETH_CONTROL_TIMEOUT);
471 471
472 udelay(10000); 472 mdelay(10);
473 473
474 kaweth_dbg("kaweth_reset() returns %d.",result); 474 kaweth_dbg("kaweth_reset() returns %d.",result);
475 475
@@ -477,13 +477,13 @@ static int kaweth_reset(struct kaweth_device *kaweth)
477} 477}
478 478
479static void kaweth_usb_receive(struct urb *, struct pt_regs *regs); 479static void kaweth_usb_receive(struct urb *, struct pt_regs *regs);
480static int kaweth_resubmit_rx_urb(struct kaweth_device *, unsigned); 480static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t);
481 481
482/**************************************************************** 482/****************************************************************
483 int_callback 483 int_callback
484*****************************************************************/ 484*****************************************************************/
485 485
486static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, int mf) 486static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf)
487{ 487{
488 int status; 488 int status;
489 489
@@ -550,7 +550,7 @@ static void kaweth_resubmit_tl(void *d)
550 * kaweth_resubmit_rx_urb 550 * kaweth_resubmit_rx_urb
551 ****************************************************************/ 551 ****************************************************************/
552static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, 552static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
553 unsigned mem_flags) 553 gfp_t mem_flags)
554{ 554{
555 int result; 555 int result;
556 556
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index a4309c4a491b..cee55f8cf64f 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -500,7 +500,7 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
500} 500}
501 501
502static struct sk_buff * 502static struct sk_buff *
503net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) 503net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
504{ 504{
505 int padlen; 505 int padlen;
506 struct sk_buff *skb2; 506 struct sk_buff *skb2;
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 6a4ffe6c3977..537eb181d985 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -1384,7 +1384,6 @@ static int pegasus_suspend (struct usb_interface *intf, pm_message_t message)
1384 usb_kill_urb(pegasus->rx_urb); 1384 usb_kill_urb(pegasus->rx_urb);
1385 usb_kill_urb(pegasus->intr_urb); 1385 usb_kill_urb(pegasus->intr_urb);
1386 } 1386 }
1387 intf->dev.power.power_state = PMSG_SUSPEND;
1388 return 0; 1387 return 0;
1389} 1388}
1390 1389
@@ -1392,7 +1391,6 @@ static int pegasus_resume (struct usb_interface *intf)
1392{ 1391{
1393 struct pegasus *pegasus = usb_get_intfdata(intf); 1392 struct pegasus *pegasus = usb_get_intfdata(intf);
1394 1393
1395 intf->dev.power.power_state = PMSG_ON;
1396 netif_device_attach (pegasus->net); 1394 netif_device_attach (pegasus->net);
1397 if (netif_running(pegasus->net)) { 1395 if (netif_running(pegasus->net)) {
1398 pegasus->rx_urb->status = 0; 1396 pegasus->rx_urb->status = 0;
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index b98f2a833442..9fbd59b55cb6 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -181,6 +181,8 @@ PEGASUS_DEV( "Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046,
181 DEFAULT_GPIO_RESET ) 181 DEFAULT_GPIO_RESET )
182PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, 182PEGASUS_DEV( "SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046,
183 DEFAULT_GPIO_RESET | PEGASUS_II ) 183 DEFAULT_GPIO_RESET | PEGASUS_II )
184PEGASUS_DEV( "Philips USB 10/100 Ethernet", VENDOR_ACCTON, 0xb004,
185 DEFAULT_GPIO_RESET | PEGASUS_II )
184PEGASUS_DEV( "ADMtek ADM8511 \"Pegasus II\" USB Ethernet", 186PEGASUS_DEV( "ADMtek ADM8511 \"Pegasus II\" USB Ethernet",
185 VENDOR_ADMTEK, 0x8511, 187 VENDOR_ADMTEK, 0x8511,
186 DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA ) 188 DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA )
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index 2ed2e5fb7778..b5a925dc1beb 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -517,7 +517,7 @@ static int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
517} 517}
518 518
519static struct sk_buff * 519static struct sk_buff *
520rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) 520rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
521{ 521{
522 struct rndis_data_hdr *hdr; 522 struct rndis_data_hdr *hdr;
523 struct sk_buff *skb2; 523 struct sk_buff *skb2;
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index c3d4e3589e30..787dd3591d6a 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -909,6 +909,7 @@ static void rtl8150_disconnect(struct usb_interface *intf)
909 usb_set_intfdata(intf, NULL); 909 usb_set_intfdata(intf, NULL);
910 if (dev) { 910 if (dev) {
911 set_bit(RTL8150_UNPLUG, &dev->flags); 911 set_bit(RTL8150_UNPLUG, &dev->flags);
912 tasklet_disable(&dev->tl);
912 unregister_netdev(dev->netdev); 913 unregister_netdev(dev->netdev);
913 unlink_all_urbs(dev); 914 unlink_all_urbs(dev);
914 free_all_urbs(dev); 915 free_all_urbs(dev);
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 6c460918d54f..74f05c9c84d5 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
288 288
289static void rx_complete (struct urb *urb, struct pt_regs *regs); 289static void rx_complete (struct urb *urb, struct pt_regs *regs);
290 290
291static void rx_submit (struct usbnet *dev, struct urb *urb, unsigned flags) 291static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
292{ 292{
293 struct sk_buff *skb; 293 struct sk_buff *skb;
294 struct skb_data *entry; 294 struct skb_data *entry;
@@ -1185,7 +1185,6 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
1185 netif_device_detach (dev->net); 1185 netif_device_detach (dev->net);
1186 (void) unlink_urbs (dev, &dev->rxq); 1186 (void) unlink_urbs (dev, &dev->rxq);
1187 (void) unlink_urbs (dev, &dev->txq); 1187 (void) unlink_urbs (dev, &dev->txq);
1188 intf->dev.power.power_state = PMSG_SUSPEND;
1189 return 0; 1188 return 0;
1190} 1189}
1191EXPORT_SYMBOL_GPL(usbnet_suspend); 1190EXPORT_SYMBOL_GPL(usbnet_suspend);
@@ -1194,7 +1193,6 @@ int usbnet_resume (struct usb_interface *intf)
1194{ 1193{
1195 struct usbnet *dev = usb_get_intfdata(intf); 1194 struct usbnet *dev = usb_get_intfdata(intf);
1196 1195
1197 intf->dev.power.power_state = PMSG_ON;
1198 netif_device_attach (dev->net); 1196 netif_device_attach (dev->net);
1199 tasklet_schedule (&dev->bh); 1197 tasklet_schedule (&dev->bh);
1200 return 0; 1198 return 0;
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h
index 7aa0abd1a9bd..89fc4958eecf 100644
--- a/drivers/usb/net/usbnet.h
+++ b/drivers/usb/net/usbnet.h
@@ -107,7 +107,7 @@ struct driver_info {
107 107
108 /* fixup tx packet (add framing) */ 108 /* fixup tx packet (add framing) */
109 struct sk_buff *(*tx_fixup)(struct usbnet *dev, 109 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
110 struct sk_buff *skb, unsigned flags); 110 struct sk_buff *skb, gfp_t flags);
111 111
112 /* for new devices, use the descriptor-reading code instead */ 112 /* for new devices, use the descriptor-reading code instead */
113 int in; /* rx endpoint */ 113 int in; /* rx endpoint */
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c
index ee3b892aeabc..5d4b7d55b097 100644
--- a/drivers/usb/net/zaurus.c
+++ b/drivers/usb/net/zaurus.c
@@ -62,7 +62,7 @@
62 */ 62 */
63 63
64static struct sk_buff * 64static struct sk_buff *
65zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, unsigned flags) 65zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
66{ 66{
67 int padlen; 67 int padlen;
68 struct sk_buff *skb2; 68 struct sk_buff *skb2;
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index c4e479ee926a..2f52261c7cc1 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -521,7 +521,7 @@ static int zd1201_setconfig(struct zd1201 *zd, int rid, void *buf, int len, int
521 int reqlen; 521 int reqlen;
522 char seq=0; 522 char seq=0;
523 struct urb *urb; 523 struct urb *urb;
524 unsigned int gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC; 524 gfp_t gfp_mask = wait ? GFP_NOIO : GFP_ATOMIC;
525 525
526 len += 4; /* first 4 are for header */ 526 len += 4; /* first 4 are for header */
527 527
diff --git a/drivers/usb/serial/ChangeLog.old b/drivers/usb/serial/ChangeLog.old
new file mode 100644
index 000000000000..c1b279939bbf
--- /dev/null
+++ b/drivers/usb/serial/ChangeLog.old
@@ -0,0 +1,730 @@
1This is the contents of some of the drivers/usb/serial/ files that had old
2changelog comments. They were quite old, and out of date, and we don't keep
3them anymore, so I've put them here, away from the source files, in case
4people still care to see them.
5
6- Greg Kroah-Hartman <greg@kroah.com> October 20, 2005
7
8-----------------------------------------------------------------------
9usb-serial.h Change Log comments:
10
11 (03/26/2002) gkh
12 removed the port->tty check from port_paranoia_check() due to serial
13 consoles not having a tty device assigned to them.
14
15 (12/03/2001) gkh
16 removed active from the port structure.
17 added documentation to the usb_serial_device_type structure
18
19 (10/10/2001) gkh
20 added vendor and product to serial structure. Needed to determine device
21 owner when the device is disconnected.
22
23 (05/30/2001) gkh
24 added sem to port structure and removed port_lock
25
26 (10/05/2000) gkh
27 Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help
28 fix bug with urb->dev not being set properly, now that the usb core
29 needs it.
30
31 (09/11/2000) gkh
32 Added usb_serial_debug_data function to help get rid of #DEBUG in the
33 drivers.
34
35 (08/28/2000) gkh
36 Added port_lock to port structure.
37
38 (08/08/2000) gkh
39 Added open_count to port structure.
40
41 (07/23/2000) gkh
42 Added bulk_out_endpointAddress to port structure.
43
44 (07/19/2000) gkh, pberger, and borchers
45 Modifications to allow usb-serial drivers to be modules.
46
47-----------------------------------------------------------------------
48usb-serial.c Change Log comments:
49
50 (12/10/2002) gkh
51 Split the ports off into their own struct device, and added a
52 usb-serial bus driver.
53
54 (11/19/2002) gkh
55 removed a few #ifdefs for the generic code and cleaned up the failure
56 logic in initialization.
57
58 (10/02/2002) gkh
59 moved the console code to console.c and out of this file.
60
61 (06/05/2002) gkh
62 moved location of startup() call in serial_probe() until after all
63 of the port information and endpoints are initialized. This makes
64 things easier for some drivers.
65
66 (04/10/2002) gkh
67 added serial_read_proc function which creates a
68 /proc/tty/driver/usb-serial file.
69
70 (03/27/2002) gkh
71 Got USB serial console code working properly and merged into the main
72 version of the tree. Thanks to Randy Dunlap for the initial version
73 of this code, and for pushing me to finish it up.
74 The USB serial console works with any usb serial driver device.
75
76 (03/21/2002) gkh
77 Moved all manipulation of port->open_count into the core. Now the
78 individual driver's open and close functions are called only when the
79 first open() and last close() is called. Making the drivers a bit
80 smaller and simpler.
81 Fixed a bug if a driver didn't have the owner field set.
82
83 (02/26/2002) gkh
84 Moved all locking into the main serial_* functions, instead of having
85 the individual drivers have to grab the port semaphore. This should
86 reduce races.
87 Reworked the MOD_INC logic a bit to always increment and decrement, even
88 if the generic driver is being used.
89
90 (10/10/2001) gkh
91 usb_serial_disconnect() now sets the serial->dev pointer is to NULL to
92 help prevent child drivers from accessing the device since it is now
93 gone.
94
95 (09/13/2001) gkh
96 Moved generic driver initialize after we have registered with the USB
97 core. Thanks to Randy Dunlap for pointing this problem out.
98
99 (07/03/2001) gkh
100 Fixed module paramater size. Thanks to John Brockmeyer for the pointer.
101 Fixed vendor and product getting defined through the MODULE_PARM macro
102 if the Generic driver wasn't compiled in.
103 Fixed problem with generic_shutdown() not being called for drivers that
104 don't have a shutdown() function.
105
106 (06/06/2001) gkh
107 added evil hack that is needed for the prolific pl2303 device due to the
108 crazy way its endpoints are set up.
109
110 (05/30/2001) gkh
111 switched from using spinlock to a semaphore, which fixes lots of problems.
112
113 (04/08/2001) gb
114 Identify version on module load.
115
116 2001_02_05 gkh
117 Fixed buffer overflows bug with the generic serial driver. Thanks to
118 Todd Squires <squirest@ct0.com> for fixing this.
119
120 (01/10/2001) gkh
121 Fixed bug where the generic serial adaptor grabbed _any_ device that was
122 offered to it.
123
124 (12/12/2000) gkh
125 Removed MOD_INC and MOD_DEC from poll and disconnect functions, and
126 moved them to the serial_open and serial_close functions.
127 Also fixed bug with there not being a MOD_DEC for the generic driver
128 (thanks to Gary Brubaker for finding this.)
129
130 (11/29/2000) gkh
131 Small NULL pointer initialization cleanup which saves a bit of disk image
132
133 (11/01/2000) Adam J. Richter
134 instead of using idVendor/idProduct pairs, usb serial drivers
135 now identify their hardware interest with usb_device_id tables,
136 which they usually have anyhow for use with MODULE_DEVICE_TABLE.
137
138 (10/05/2000) gkh
139 Fixed bug with urb->dev not being set properly, now that the usb
140 core needs it.
141
142 (09/11/2000) gkh
143 Removed DEBUG #ifdefs with call to usb_serial_debug_data
144
145 (08/28/2000) gkh
146 Added port_lock to port structure.
147 Added locks for SMP safeness to generic driver
148 Fixed the ability to open a generic device's port more than once.
149
150 (07/23/2000) gkh
151 Added bulk_out_endpointAddress to port structure.
152
153 (07/19/2000) gkh, pberger, and borchers
154 Modifications to allow usb-serial drivers to be modules.
155
156 (07/03/2000) gkh
157 Added more debugging to serial_ioctl call
158
159 (06/25/2000) gkh
160 Changed generic_write_bulk_callback to not call wake_up_interruptible
161 directly, but to have port_softint do it at a safer time.
162
163 (06/23/2000) gkh
164 Cleaned up debugging statements in a quest to find UHCI timeout bug.
165
166 (05/22/2000) gkh
167 Changed the makefile, enabling the big CONFIG_USB_SERIAL_SOMTHING to be
168 removed from the individual device source files.
169
170 (05/03/2000) gkh
171 Added the Digi Acceleport driver from Al Borchers and Peter Berger.
172
173 (05/02/2000) gkh
174 Changed devfs and tty register code to work properly now. This was based on
175 the ACM driver changes by Vojtech Pavlik.
176
177 (04/27/2000) Ryan VanderBijl
178 Put calls to *_paranoia_checks into one function.
179
180 (04/23/2000) gkh
181 Fixed bug that Randy Dunlap found for Generic devices with no bulk out ports.
182 Moved when the startup code printed out the devices that are supported.
183
184 (04/19/2000) gkh
185 Added driver for ZyXEL omni.net lcd plus ISDN TA
186 Made startup info message specify which drivers were compiled in.
187
188 (04/03/2000) gkh
189 Changed the probe process to remove the module unload races.
190 Changed where the tty layer gets initialized to have devfs work nicer.
191 Added initial devfs support.
192
193 (03/26/2000) gkh
194 Split driver up into device specific pieces.
195
196 (03/19/2000) gkh
197 Fixed oops that could happen when device was removed while a program
198 was talking to the device.
199 Removed the static urbs and now all urbs are created and destroyed
200 dynamically.
201 Reworked the internal interface. Now everything is based on the
202 usb_serial_port structure instead of the larger usb_serial structure.
203 This fixes the bug that a multiport device could not have more than
204 one port open at one time.
205
206 (03/17/2000) gkh
207 Added config option for debugging messages.
208 Added patch for keyspan pda from Brian Warner.
209
210 (03/06/2000) gkh
211 Added the keyspan pda code from Brian Warner <warner@lothar.com>
212 Moved a bunch of the port specific stuff into its own structure. This
213 is in anticipation of the true multiport devices (there's a bug if you
214 try to access more than one port of any multiport device right now)
215
216 (02/21/2000) gkh
217 Made it so that any serial devices only have to specify which functions
218 they want to overload from the generic function calls (great,
219 inheritance in C, in a driver, just what I wanted...)
220 Added support for set_termios and ioctl function calls. No drivers take
221 advantage of this yet.
222 Removed the #ifdef MODULE, now there is no module specific code.
223 Cleaned up a few comments in usb-serial.h that were wrong (thanks again
224 to Miles Lott).
225 Small fix to get_free_serial.
226
227 (02/14/2000) gkh
228 Removed the Belkin and Peracom functionality from the driver due to
229 the lack of support from the vendor, and me not wanting people to
230 accidenatly buy the device, expecting it to work with Linux.
231 Added read_bulk_callback and write_bulk_callback to the type structure
232 for the needs of the FTDI and WhiteHEAT driver.
233 Changed all reverences to FTDI to FTDI_SIO at the request of Bill
234 Ryder.
235 Changed the output urb size back to the max endpoint size to make
236 the ftdi_sio driver have it easier, and due to the fact that it didn't
237 really increase the speed any.
238
239 (02/11/2000) gkh
240 Added VISOR_FUNCTION_CONSOLE to the visor startup function. This was a
241 patch from Miles Lott (milos@insync.net).
242 Fixed bug with not restoring the minor range that a device grabs, if
243 the startup function fails (thanks Miles for finding this).
244
245 (02/05/2000) gkh
246 Added initial framework for the Keyspan PDA serial converter so that
247 Brian Warner has a place to put his code.
248 Made the ezusb specific functions generic enough that different
249 devices can use them (whiteheat and keyspan_pda both need them).
250 Split out a whole bunch of structure and other stuff to a separate
251 usb-serial.h file.
252 Made the Visor connection messages a little more understandable, now
253 that Miles Lott (milos@insync.net) has gotten the Generic channel to
254 work. Also made them always show up in the log file.
255
256 (01/25/2000) gkh
257 Added initial framework for FTDI serial converter so that Bill Ryder
258 has a place to put his code.
259 Added the vendor specific info from Handspring. Now we can print out
260 informational debug messages as well as understand what is happening.
261
262 (01/23/2000) gkh
263 Fixed problem of crash when trying to open a port that didn't have a
264 device assigned to it. Made the minor node finding a little smarter,
265 now it looks to find a continuous space for the new device.
266
267 (01/21/2000) gkh
268 Fixed bug in visor_startup with patch from Miles Lott (milos@insync.net)
269 Fixed get_serial_by_minor which was all messed up for multi port
270 devices. Fixed multi port problem for generic devices. Now the number
271 of ports is determined by the number of bulk out endpoints for the
272 generic device.
273
274 (01/19/2000) gkh
275 Removed lots of cruft that was around from the old (pre urb) driver
276 interface.
277 Made the serial_table dynamic. This should save lots of memory when
278 the number of minor nodes goes up to 256.
279 Added initial support for devices that have more than one port.
280 Added more debugging comments for the Visor, and added a needed
281 set_configuration call.
282
283 (01/17/2000) gkh
284 Fixed the WhiteHEAT firmware (my processing tool had a bug)
285 and added new debug loader firmware for it.
286 Removed the put_char function as it isn't really needed.
287 Added visor startup commands as found by the Win98 dump.
288
289 (01/13/2000) gkh
290 Fixed the vendor id for the generic driver to the one I meant it to be.
291
292 (01/12/2000) gkh
293 Forget the version numbering...that's pretty useless...
294 Made the driver able to be compiled so that the user can select which
295 converter they want to use. This allows people who only want the Visor
296 support to not pay the memory size price of the WhiteHEAT.
297 Fixed bug where the generic driver (idVendor=0000 and idProduct=0000)
298 grabbed the root hub. Not good.
299
300 version 0.4.0 (01/10/2000) gkh
301 Added whiteheat.h containing the firmware for the ConnectTech WhiteHEAT
302 device. Added startup function to allow firmware to be downloaded to
303 a device if it needs to be.
304 Added firmware download logic to the WhiteHEAT device.
305 Started to add #defines to split up the different drivers for potential
306 configuration option.
307
308 version 0.3.1 (12/30/99) gkh
309 Fixed problems with urb for bulk out.
310 Added initial support for multiple sets of endpoints. This enables
311 the Handspring Visor to be attached successfully. Only the first
312 bulk in / bulk out endpoint pair is being used right now.
313
314 version 0.3.0 (12/27/99) gkh
315 Added initial support for the Handspring Visor based on a patch from
316 Miles Lott (milos@sneety.insync.net)
317 Cleaned up the code a bunch and converted over to using urbs only.
318
319 version 0.2.3 (12/21/99) gkh
320 Added initial support for the Connect Tech WhiteHEAT converter.
321 Incremented the number of ports in expectation of getting the
322 WhiteHEAT to work properly (4 ports per connection).
323 Added notification on insertion and removal of what port the
324 device is/was connected to (and what kind of device it was).
325
326 version 0.2.2 (12/16/99) gkh
327 Changed major number to the new allocated number. We're legal now!
328
329 version 0.2.1 (12/14/99) gkh
330 Fixed bug that happens when device node is opened when there isn't a
331 device attached to it. Thanks to marek@webdesign.no for noticing this.
332
333 version 0.2.0 (11/10/99) gkh
334 Split up internals to make it easier to add different types of serial
335 converters to the code.
336 Added a "generic" driver that gets it's vendor and product id
337 from when the module is loaded. Thanks to David E. Nelson (dnelson@jump.net)
338 for the idea and sample code (from the usb scanner driver.)
339 Cleared up any licensing questions by releasing it under the GNU GPL.
340
341 version 0.1.2 (10/25/99) gkh
342 Fixed bug in detecting device.
343
344 version 0.1.1 (10/05/99) gkh
345 Changed the major number to not conflict with anything else.
346
347 version 0.1 (09/28/99) gkh
348 Can recognize the two different devices and start up a read from
349 device when asked to. Writes also work. No control signals yet, this
350 all is vendor specific data (i.e. no spec), also no control for
351 different baud rates or other bit settings.
352 Currently we are using the same devid as the acm driver. This needs
353 to change.
354
355-----------------------------------------------------------------------
356visor.c Change Log comments:
357
358 (06/03/2003) Judd Montgomery <judd at jpilot.org>
359 Added support for module parameter options for untested/unknown
360 devices.
361
362 (03/09/2003) gkh
363 Added support for the Sony Clie NZ90V device. Thanks to Martin Brachtl
364 <brachtl@redgrep.cz> for the information.
365
366 (03/05/2003) gkh
367 Think Treo support is now working.
368
369 (04/03/2002) gkh
370 Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI
371 <hiro@zob.ne.jp> for the information.
372
373 (03/27/2002) gkh
374 Removed assumptions that port->tty was always valid (is not true
375 for usb serial console devices.)
376
377 (03/23/2002) gkh
378 Added support for the Palm i705 device, thanks to Thomas Riemer
379 <tom@netmech.com> for the information.
380
381 (03/21/2002) gkh
382 Added support for the Palm m130 device, thanks to Udo Eisenbarth
383 <udo.eisenbarth@web.de> for the information.
384
385 (02/27/2002) gkh
386 Reworked the urb handling logic. We have no more pool, but dynamically
387 allocate the urb and the transfer buffer on the fly. In testing this
388 does not incure any measurable overhead. This also relies on the fact
389 that we have proper reference counting logic for urbs.
390
391 (02/21/2002) SilaS
392 Added initial support for the Palm m515 devices.
393
394 (02/14/2002) gkh
395 Added support for the Clie S-360 device.
396
397 (12/18/2001) gkh
398 Added better Clie support for 3.5 devices. Thanks to Geoffrey Levand
399 for the patch.
400
401 (11/11/2001) gkh
402 Added support for the m125 devices, and added check to prevent oopses
403 for Clié devices that lie about the number of ports they have.
404
405 (08/30/2001) gkh
406 Added support for the Clie devices, both the 3.5 and 4.0 os versions.
407 Many thanks to Daniel Burke, and Bryan Payne for helping with this.
408
409 (08/23/2001) gkh
410 fixed a few potential bugs pointed out by Oliver Neukum.
411
412 (05/30/2001) gkh
413 switched from using spinlock to a semaphore, which fixes lots of problems.
414
415 (05/28/2000) gkh
416 Added initial support for the Palm m500 and Palm m505 devices.
417
418 (04/08/2001) gb
419 Identify version on module load.
420
421 (01/21/2000) gkh
422 Added write_room and chars_in_buffer, as they were previously using the
423 generic driver versions which is all wrong now that we are using an urb
424 pool. Thanks to Wolfgang Grandegger for pointing this out to me.
425 Removed count assignment in the write function, which was not needed anymore
426 either. Thanks to Al Borchers for pointing this out.
427
428 (12/12/2000) gkh
429 Moved MOD_DEC to end of visor_close to be nicer, as the final write
430 message can sleep.
431
432 (11/12/2000) gkh
433 Fixed bug with data being dropped on the floor by forcing tty->low_latency
434 to be on. Hopefully this fixes the OHCI issue!
435
436 (11/01/2000) Adam J. Richter
437 usb_device_id table support
438
439 (10/05/2000) gkh
440 Fixed bug with urb->dev not being set properly, now that the usb
441 core needs it.
442
443 (09/11/2000) gkh
444 Got rid of always calling kmalloc for every urb we wrote out to the
445 device.
446 Added visor_read_callback so we can keep track of bytes in and out for
447 those people who like to know the speed of their device.
448 Removed DEBUG #ifdefs with call to usb_serial_debug_data
449
450 (09/06/2000) gkh
451 Fixed oops in visor_exit. Need to uncomment usb_unlink_urb call _after_
452 the host controller drivers set urb->dev = NULL when the urb is finished.
453
454 (08/28/2000) gkh
455 Added locks for SMP safeness.
456
457 (08/08/2000) gkh
458 Fixed endian problem in visor_startup.
459 Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
460 than once.
461
462 (07/23/2000) gkh
463 Added pool of write urbs to speed up transfers to the visor.
464
465 (07/19/2000) gkh
466 Added module_init and module_exit functions to handle the fact that this
467 driver is a loadable module now.
468
469 (07/03/2000) gkh
470 Added visor_set_ioctl and visor_set_termios functions (they don't do much
471 of anything, but are good for debugging.)
472
473 (06/25/2000) gkh
474 Fixed bug in visor_unthrottle that should help with the disconnect in PPP
475 bug that people have been reporting.
476
477 (06/23/2000) gkh
478 Cleaned up debugging statements in a quest to find UHCI timeout bug.
479
480 (04/27/2000) Ryan VanderBijl
481 Fixed memory leak in visor_close
482
483 (03/26/2000) gkh
484 Split driver up into device specific pieces.
485
486-----------------------------------------------------------------------
487pl2303.c Change Log comments:
488
489 2002_Mar_26 gkh
490 allowed driver to work properly if there is no tty assigned to a port
491 (this happens for serial console devices.)
492
493 2001_Oct_06 gkh
494 Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it.
495
496 2001_Sep_19 gkh
497 Added break support.
498
499 2001_Aug_30 gkh
500 fixed oops in write_bulk_callback.
501
502 2001_Aug_28 gkh
503 reworked buffer logic to be like other usb-serial drivers. Hopefully
504 removing some reported problems.
505
506 2001_Jun_06 gkh
507 finished porting to 2.4 format.
508
509
510-----------------------------------------------------------------------
511io_edgeport.c Change Log comments:
512
513 2003_04_03 al borchers
514 - fixed a bug (that shows up with dosemu) where the tty struct is
515 used in a callback after it has been freed
516
517 2.3 2002_03_08 greg kroah-hartman
518 - fixed bug when multiple devices were attached at the same time.
519
520 2.2 2001_11_14 greg kroah-hartman
521 - fixed bug in edge_close that kept the port from being used more
522 than once.
523 - fixed memory leak on device removal.
524 - fixed potential double free of memory when command urb submitting
525 failed.
526 - other small cleanups when the device is removed
527
528 2.1 2001_07_09 greg kroah-hartman
529 - added support for TIOCMBIS and TIOCMBIC.
530
531 (04/08/2001) gb
532 - Identify version on module load.
533
534 2.0 2001_03_05 greg kroah-hartman
535 - reworked entire driver to fit properly in with the other usb-serial
536 drivers. Occasional oopses still happen, but it's a good start.
537
538 1.2.3 (02/23/2001) greg kroah-hartman
539 - changed device table to work properly for 2.4.x final format.
540 - fixed problem with dropping data at high data rates.
541
542 1.2.2 (11/27/2000) greg kroah-hartman
543 - cleaned up more NTisms.
544 - Added device table for 2.4.0-test11
545
546 1.2.1 (11/08/2000) greg kroah-hartman
547 - Started to clean up NTisms.
548 - Fixed problem with dev field of urb for kernels >= 2.4.0-test9
549
550 1.2 (10/17/2000) David Iacovelli
551 Remove all EPIC code and GPL source
552 Fix RELEVANT_IFLAG macro to include flow control
553 changes port configuration changes.
554 Fix redefinition of SERIAL_MAGIC
555 Change all timeout values to 5 seconds
556 Tried to fix the UHCI multiple urb submission, but failed miserably.
557 it seems to work fine with OHCI.
558 ( Greg take a look at the #if 0 at end of WriteCmdUsb() we must
559 find a way to work arount this UHCI bug )
560
561 1.1 (10/11/2000) David Iacovelli
562 Fix XON/XOFF flow control to support both IXON and IXOFF
563
564 0.9.27 (06/30/2000) David Iacovelli
565 Added transmit queue and now allocate urb for command writes.
566
567 0.9.26 (06/29/2000) David Iacovelli
568 Add support for 80251 based edgeport
569
570 0.9.25 (06/27/2000) David Iacovelli
571 Do not close the port if it has multiple opens.
572
573 0.9.24 (05/26/2000) David Iacovelli
574 Add IOCTLs to support RXTX and JAVA POS
575 and first cut at running BlackBox Demo
576
577 0.9.23 (05/24/2000) David Iacovelli
578 Add IOCTLs to support RXTX and JAVA POS
579
580 0.9.22 (05/23/2000) David Iacovelli
581 fixed bug in enumeration. If epconfig turns on mapping by
582 path after a device is already plugged in, we now update
583 the mapping correctly
584
585 0.9.21 (05/16/2000) David Iacovelli
586 Added BlockUntilChaseResp() to also wait for txcredits
587 Updated the way we allocate and handle write URBs
588 Add debug code to dump buffers
589
590 0.9.20 (05/01/2000) David Iacovelli
591 change driver to use usb/tts/
592
593 0.9.19 (05/01/2000) David Iacovelli
594 Update code to compile if DEBUG is off
595
596 0.9.18 (04/28/2000) David Iacovelli
597 cleanup and test tty_register with devfs
598
599 0.9.17 (04/27/2000) greg kroah-hartman
600 changed tty_register around to be like the way it
601 was before, but now it works properly with devfs.
602
603 0.9.16 (04/26/2000) david iacovelli
604 Fixed bug in GetProductInfo()
605
606 0.9.15 (04/25/2000) david iacovelli
607 Updated enumeration
608
609 0.9.14 (04/24/2000) david iacovelli
610 Removed all config/status IOCTLS and
611 converted to using /proc/edgeport
612 still playing with devfs
613
614 0.9.13 (04/24/2000) david iacovelli
615 Removed configuration based on ttyUSB0
616 Added support for configuration using /prod/edgeport
617 first attempt at using devfs (not working yet!)
618 Added IOCTL to GetProductInfo()
619 Added support for custom baud rates
620 Add support for random port numbers
621
622 0.9.12 (04/18/2000) david iacovelli
623 added additional configuration IOCTLs
624 use ttyUSB0 for configuration
625
626 0.9.11 (04/17/2000) greg kroah-hartman
627 fixed module initialization race conditions.
628 made all urbs dynamically allocated.
629 made driver devfs compatible. now it only registers the tty device
630 when the device is actually plugged in.
631
632 0.9.10 (04/13/2000) greg kroah-hartman
633 added proc interface framework.
634
635 0.9.9 (04/13/2000) david iacovelli
636 added enumeration code and ioctls to configure the device
637
638 0.9.8 (04/12/2000) david iacovelli
639 Change interrupt read start when device is plugged in
640 and stop when device is removed
641 process interrupt reads when all ports are closed
642 (keep value of rxBytesAvail consistent with the edgeport)
643 set the USB_BULK_QUEUE flag so that we can shove a bunch
644 of urbs at once down the pipe
645
646 0.9.7 (04/10/2000) david iacovelli
647 start to add enumeration code.
648 generate serial number for epic devices
649 add support for kdb
650
651 0.9.6 (03/30/2000) david iacovelli
652 add IOCTL to get string, manufacture, and boot descriptors
653
654 0.9.5 (03/14/2000) greg kroah-hartman
655 more error checking added to SerialOpen to try to fix UHCI open problem
656
657 0.9.4 (03/09/2000) greg kroah-hartman
658 added more error checking to handle oops when data is hanging
659 around and tty is abruptly closed.
660
661 0.9.3 (03/09/2000) david iacovelli
662 Add epic support for xon/xoff chars
663 play with performance
664
665 0.9.2 (03/08/2000) greg kroah-hartman
666 changed most "info" calls to "dbg"
667 implemented flow control properly in the termios call
668
669 0.9.1 (03/08/2000) david iacovelli
670 added EPIC support
671 enabled bootloader update
672
673 0.9 (03/08/2000) greg kroah-hartman
674 Release to IO networks.
675 Integrated changes that David made
676 made getting urbs for writing SMP safe
677
678 0.8 (03/07/2000) greg kroah-hartman
679 Release to IO networks.
680 Fixed problems that were seen in code by David.
681 Now both Edgeport/4 and Edgeport/2 works properly.
682 Changed most of the functions to use port instead of serial.
683
684 0.7 (02/27/2000) greg kroah-hartman
685 Milestone 3 release.
686 Release to IO Networks
687 ioctl for waiting on line change implemented.
688 ioctl for getting statistics implemented.
689 multiport support working.
690 lsr and msr registers are now handled properly.
691 change break now hooked up and working.
692 support for all known Edgeport devices.
693
694 0.6 (02/22/2000) greg kroah-hartman
695 Release to IO networks.
696 CHASE is implemented correctly when port is closed.
697 SerialOpen now blocks correctly until port is fully opened.
698
699 0.5 (02/20/2000) greg kroah-hartman
700 Release to IO networks.
701 Known problems:
702 modem status register changes are not sent on to the user
703 CHASE is not implemented when the port is closed.
704
705 0.4 (02/16/2000) greg kroah-hartman
706 Second cut at the CeBit demo.
707 Doesn't leak memory on every write to the port
708 Still small leaks on startup.
709 Added support for Edgeport/2 and Edgeport/8
710
711 0.3 (02/15/2000) greg kroah-hartman
712 CeBit demo release.
713 Force the line settings to 4800, 8, 1, e for the demo.
714 Warning! This version leaks memory like crazy!
715
716 0.2 (01/30/2000) greg kroah-hartman
717 Milestone 1 release.
718 Device is found by USB subsystem, enumerated, fimware is downloaded
719 and the descriptors are printed to the debug log, config is set, and
720 green light starts to blink. Open port works, and data can be sent
721 and received at the default settings of the UART. Loopback connector
722 and debug log confirms this.
723
724 0.1 (01/23/2000) greg kroah-hartman
725 Initial release to help IO Networks try to set up their test system.
726 Edgeport4 is recognized, firmware is downloaded, config is set so
727 device blinks green light every 3 sec. Port is bound, but opening,
728 closing, and sending data do not work properly.
729
730
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 9438909e87a5..7b5e8e4ee2bb 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -394,6 +394,15 @@ config USB_SERIAL_MCT_U232
394 To compile this driver as a module, choose M here: the 394 To compile this driver as a module, choose M here: the
395 module will be called mct_u232. 395 module will be called mct_u232.
396 396
397config USB_SERIAL_NOKIA_DKU2
398 tristate "USB Nokia DKU2 Driver"
399 depends on USB_SERIAL
400 help
401 Say Y here if you want to use a Nokia DKU2 device.
402
403 To compile this driver as a module, choose M here: the
404 module will be called nokia_dku2.
405
397config USB_SERIAL_PL2303 406config USB_SERIAL_PL2303
398 tristate "USB Prolific 2303 Single Port Serial Driver" 407 tristate "USB Prolific 2303 Single Port Serial Driver"
399 depends on USB_SERIAL 408 depends on USB_SERIAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 6c7cdcc99a9e..55fd461793b7 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
31obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 31obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
32obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 32obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
33obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 33obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
34obj-$(CONFIG_USB_SERIAL_NOKIA_DKU2) += nokia_dku2.o
34obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 35obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
35obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 36obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
36obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 37obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 926d4c2c1600..1f29d8837327 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -30,9 +30,11 @@ static struct usb_driver airprime_driver = {
30 .id_table = id_table, 30 .id_table = id_table,
31}; 31};
32 32
33static struct usb_serial_device_type airprime_device = { 33static struct usb_serial_driver airprime_device = {
34 .owner = THIS_MODULE, 34 .driver = {
35 .name = "airprime", 35 .owner = THIS_MODULE,
36 .name = "airprime",
37 },
36 .id_table = id_table, 38 .id_table = id_table,
37 .num_interrupt_in = NUM_DONT_CARE, 39 .num_interrupt_in = NUM_DONT_CARE,
38 .num_bulk_in = NUM_DONT_CARE, 40 .num_bulk_in = NUM_DONT_CARE,
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index abb1b2c543bb..84bc0ee4f061 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -121,10 +121,12 @@ static struct usb_driver belkin_driver = {
121}; 121};
122 122
123/* All of the device info needed for the serial converters */ 123/* All of the device info needed for the serial converters */
124static struct usb_serial_device_type belkin_device = { 124static struct usb_serial_driver belkin_device = {
125 .owner = THIS_MODULE, 125 .driver = {
126 .name = "Belkin / Peracom / GoHubs USB Serial Adapter", 126 .owner = THIS_MODULE,
127 .short_name = "belkin", 127 .name = "belkin",
128 },
129 .description = "Belkin / Peracom / GoHubs USB Serial Adapter",
128 .id_table = id_table_combined, 130 .id_table = id_table_combined,
129 .num_interrupt_in = 1, 131 .num_interrupt_in = 1,
130 .num_bulk_in = 1, 132 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 2f612c2d894b..664139afcfa9 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -18,7 +18,7 @@
18 18
19static int usb_serial_device_match (struct device *dev, struct device_driver *drv) 19static int usb_serial_device_match (struct device *dev, struct device_driver *drv)
20{ 20{
21 struct usb_serial_device_type *driver; 21 struct usb_serial_driver *driver;
22 const struct usb_serial_port *port; 22 const struct usb_serial_port *port;
23 23
24 /* 24 /*
@@ -44,7 +44,7 @@ struct bus_type usb_serial_bus_type = {
44 44
45static int usb_serial_device_probe (struct device *dev) 45static int usb_serial_device_probe (struct device *dev)
46{ 46{
47 struct usb_serial_device_type *driver; 47 struct usb_serial_driver *driver;
48 struct usb_serial_port *port; 48 struct usb_serial_port *port;
49 int retval = 0; 49 int retval = 0;
50 int minor; 50 int minor;
@@ -57,13 +57,13 @@ static int usb_serial_device_probe (struct device *dev)
57 57
58 driver = port->serial->type; 58 driver = port->serial->type;
59 if (driver->port_probe) { 59 if (driver->port_probe) {
60 if (!try_module_get(driver->owner)) { 60 if (!try_module_get(driver->driver.owner)) {
61 dev_err(dev, "module get failed, exiting\n"); 61 dev_err(dev, "module get failed, exiting\n");
62 retval = -EIO; 62 retval = -EIO;
63 goto exit; 63 goto exit;
64 } 64 }
65 retval = driver->port_probe (port); 65 retval = driver->port_probe (port);
66 module_put(driver->owner); 66 module_put(driver->driver.owner);
67 if (retval) 67 if (retval)
68 goto exit; 68 goto exit;
69 } 69 }
@@ -72,7 +72,7 @@ static int usb_serial_device_probe (struct device *dev)
72 tty_register_device (usb_serial_tty_driver, minor, dev); 72 tty_register_device (usb_serial_tty_driver, minor, dev);
73 dev_info(&port->serial->dev->dev, 73 dev_info(&port->serial->dev->dev,
74 "%s converter now attached to ttyUSB%d\n", 74 "%s converter now attached to ttyUSB%d\n",
75 driver->name, minor); 75 driver->description, minor);
76 76
77exit: 77exit:
78 return retval; 78 return retval;
@@ -80,7 +80,7 @@ exit:
80 80
81static int usb_serial_device_remove (struct device *dev) 81static int usb_serial_device_remove (struct device *dev)
82{ 82{
83 struct usb_serial_device_type *driver; 83 struct usb_serial_driver *driver;
84 struct usb_serial_port *port; 84 struct usb_serial_port *port;
85 int retval = 0; 85 int retval = 0;
86 int minor; 86 int minor;
@@ -92,43 +92,38 @@ static int usb_serial_device_remove (struct device *dev)
92 92
93 driver = port->serial->type; 93 driver = port->serial->type;
94 if (driver->port_remove) { 94 if (driver->port_remove) {
95 if (!try_module_get(driver->owner)) { 95 if (!try_module_get(driver->driver.owner)) {
96 dev_err(dev, "module get failed, exiting\n"); 96 dev_err(dev, "module get failed, exiting\n");
97 retval = -EIO; 97 retval = -EIO;
98 goto exit; 98 goto exit;
99 } 99 }
100 retval = driver->port_remove (port); 100 retval = driver->port_remove (port);
101 module_put(driver->owner); 101 module_put(driver->driver.owner);
102 } 102 }
103exit: 103exit:
104 minor = port->number; 104 minor = port->number;
105 tty_unregister_device (usb_serial_tty_driver, minor); 105 tty_unregister_device (usb_serial_tty_driver, minor);
106 dev_info(dev, "%s converter now disconnected from ttyUSB%d\n", 106 dev_info(dev, "%s converter now disconnected from ttyUSB%d\n",
107 driver->name, minor); 107 driver->description, minor);
108 108
109 return retval; 109 return retval;
110} 110}
111 111
112int usb_serial_bus_register(struct usb_serial_device_type *device) 112int usb_serial_bus_register(struct usb_serial_driver *driver)
113{ 113{
114 int retval; 114 int retval;
115 115
116 if (device->short_name) 116 driver->driver.bus = &usb_serial_bus_type;
117 device->driver.name = (char *)device->short_name; 117 driver->driver.probe = usb_serial_device_probe;
118 else 118 driver->driver.remove = usb_serial_device_remove;
119 device->driver.name = (char *)device->name;
120 device->driver.bus = &usb_serial_bus_type;
121 device->driver.probe = usb_serial_device_probe;
122 device->driver.remove = usb_serial_device_remove;
123 device->driver.owner = device->owner;
124 119
125 retval = driver_register(&device->driver); 120 retval = driver_register(&driver->driver);
126 121
127 return retval; 122 return retval;
128} 123}
129 124
130void usb_serial_bus_deregister(struct usb_serial_device_type *device) 125void usb_serial_bus_deregister(struct usb_serial_driver *driver)
131{ 126{
132 driver_unregister (&device->driver); 127 driver_unregister(&driver->driver);
133} 128}
134 129
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 97c78c21e8d1..c5334dd89b12 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -67,15 +67,17 @@ MODULE_DEVICE_TABLE (usb, id_table);
67 67
68static struct usb_driver cp2101_driver = { 68static struct usb_driver cp2101_driver = {
69 .owner = THIS_MODULE, 69 .owner = THIS_MODULE,
70 .name = "CP2101", 70 .name = "cp2101",
71 .probe = usb_serial_probe, 71 .probe = usb_serial_probe,
72 .disconnect = usb_serial_disconnect, 72 .disconnect = usb_serial_disconnect,
73 .id_table = id_table, 73 .id_table = id_table,
74}; 74};
75 75
76static struct usb_serial_device_type cp2101_device = { 76static struct usb_serial_driver cp2101_device = {
77 .owner = THIS_MODULE, 77 .driver = {
78 .name = "CP2101", 78 .owner = THIS_MODULE,
79 .name = "cp2101",
80 },
79 .id_table = id_table, 81 .id_table = id_table,
80 .num_interrupt_in = 0, 82 .num_interrupt_in = 0,
81 .num_bulk_in = 0, 83 .num_bulk_in = 0,
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index b5b431067b08..e581e4ae8483 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -83,10 +83,12 @@ static struct usb_driver cyberjack_driver = {
83 .id_table = id_table, 83 .id_table = id_table,
84}; 84};
85 85
86static struct usb_serial_device_type cyberjack_device = { 86static struct usb_serial_driver cyberjack_device = {
87 .owner = THIS_MODULE, 87 .driver = {
88 .name = "Reiner SCT Cyberjack USB card reader", 88 .owner = THIS_MODULE,
89 .short_name = "cyberjack", 89 .name = "cyberjack",
90 },
91 .description = "Reiner SCT Cyberjack USB card reader",
90 .id_table = id_table, 92 .id_table = id_table,
91 .num_interrupt_in = 1, 93 .num_interrupt_in = 1,
92 .num_bulk_in = 1, 94 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 9ee1aaff2fcd..af9290ed257b 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -176,10 +176,12 @@ static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, u
176static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count); 176static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
177 177
178 178
179static struct usb_serial_device_type cypress_earthmate_device = { 179static struct usb_serial_driver cypress_earthmate_device = {
180 .owner = THIS_MODULE, 180 .driver = {
181 .name = "DeLorme Earthmate USB", 181 .owner = THIS_MODULE,
182 .short_name = "earthmate", 182 .name = "earthmate",
183 },
184 .description = "DeLorme Earthmate USB",
183 .id_table = id_table_earthmate, 185 .id_table = id_table_earthmate,
184 .num_interrupt_in = 1, 186 .num_interrupt_in = 1,
185 .num_interrupt_out = 1, 187 .num_interrupt_out = 1,
@@ -203,10 +205,12 @@ static struct usb_serial_device_type cypress_earthmate_device = {
203 .write_int_callback = cypress_write_int_callback, 205 .write_int_callback = cypress_write_int_callback,
204}; 206};
205 207
206static struct usb_serial_device_type cypress_hidcom_device = { 208static struct usb_serial_driver cypress_hidcom_device = {
207 .owner = THIS_MODULE, 209 .driver = {
208 .name = "HID->COM RS232 Adapter", 210 .owner = THIS_MODULE,
209 .short_name = "cyphidcom", 211 .name = "cyphidcom",
212 },
213 .description = "HID->COM RS232 Adapter",
210 .id_table = id_table_cyphidcomrs232, 214 .id_table = id_table_cyphidcomrs232,
211 .num_interrupt_in = 1, 215 .num_interrupt_in = 1,
212 .num_interrupt_out = 1, 216 .num_interrupt_out = 1,
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index a19a47f6cf12..dc74644a603d 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -503,10 +503,12 @@ static struct usb_driver digi_driver = {
503 503
504/* device info needed for the Digi serial converter */ 504/* device info needed for the Digi serial converter */
505 505
506static struct usb_serial_device_type digi_acceleport_2_device = { 506static struct usb_serial_driver digi_acceleport_2_device = {
507 .owner = THIS_MODULE, 507 .driver = {
508 .name = "Digi 2 port USB adapter", 508 .owner = THIS_MODULE,
509 .short_name = "digi_2", 509 .name = "digi_2",
510 },
511 .description = "Digi 2 port USB adapter",
510 .id_table = id_table_2, 512 .id_table = id_table_2,
511 .num_interrupt_in = 0, 513 .num_interrupt_in = 0,
512 .num_bulk_in = 4, 514 .num_bulk_in = 4,
@@ -530,10 +532,12 @@ static struct usb_serial_device_type digi_acceleport_2_device = {
530 .shutdown = digi_shutdown, 532 .shutdown = digi_shutdown,
531}; 533};
532 534
533static struct usb_serial_device_type digi_acceleport_4_device = { 535static struct usb_serial_driver digi_acceleport_4_device = {
534 .owner = THIS_MODULE, 536 .driver = {
535 .name = "Digi 4 port USB adapter", 537 .owner = THIS_MODULE,
536 .short_name = "digi_4", 538 .name = "digi_4",
539 },
540 .description = "Digi 4 port USB adapter",
537 .id_table = id_table_4, 541 .id_table = id_table_4,
538 .num_interrupt_in = 0, 542 .num_interrupt_in = 0,
539 .num_bulk_in = 5, 543 .num_bulk_in = 5,
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 8d562ab454a8..0b0546dcc7b9 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -112,9 +112,11 @@ static struct usb_driver empeg_driver = {
112 .id_table = id_table, 112 .id_table = id_table,
113}; 113};
114 114
115static struct usb_serial_device_type empeg_device = { 115static struct usb_serial_driver empeg_device = {
116 .owner = THIS_MODULE, 116 .driver = {
117 .name = "Empeg", 117 .owner = THIS_MODULE,
118 .name = "empeg",
119 },
118 .id_table = id_table, 120 .id_table = id_table,
119 .num_interrupt_in = 0, 121 .num_interrupt_in = 0,
120 .num_bulk_in = 1, 122 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 5a8631c8a4a7..61204bf7cd78 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -411,6 +411,8 @@ static struct usb_device_id id_table_combined [] = {
411 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) }, 411 { USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
412 { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) }, 412 { USB_DEVICE(FTDI_VID, FTDI_ELV_UR100_PID) },
413 { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) }, 413 { USB_DEVICE(FTDI_VID, FTDI_ELV_ALC8500_PID) },
414 { USB_DEVICE(FTDI_VID, FTDI_PYRAMID_PID) },
415 { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) },
414 /* 416 /*
415 * These will probably use user-space drivers. Uncomment them if 417 * These will probably use user-space drivers. Uncomment them if
416 * you need them or use the user-specified vendor/product module 418 * you need them or use the user-specified vendor/product module
@@ -428,7 +430,6 @@ static struct usb_device_id id_table_combined [] = {
428 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */ 430 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_T1100_PID) }, */
429 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */ 431 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCD200_PID) }, */
430 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */ 432 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_ULA200_PID) }, */
431 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1000PC_PID) }, */
432 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */ 433 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_CSI8_PID) }, */
433 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */ 434 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_EM1000DL_PID) }, */
434 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */ 435 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_PCK100_PID) }, */
@@ -471,6 +472,9 @@ static struct usb_device_id id_table_combined [] = {
471 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, 472 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) },
472 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, 473 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) },
473 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 474 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
475 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
476 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
477 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
474 { }, /* Optional parameter entry */ 478 { }, /* Optional parameter entry */
475 { } /* Terminating entry */ 479 { } /* Terminating entry */
476}; 480};
@@ -558,10 +562,12 @@ static unsigned short int ftdi_232am_baud_to_divisor (int baud);
558static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base); 562static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base);
559static __u32 ftdi_232bm_baud_to_divisor (int baud); 563static __u32 ftdi_232bm_baud_to_divisor (int baud);
560 564
561static struct usb_serial_device_type ftdi_sio_device = { 565static struct usb_serial_driver ftdi_sio_device = {
562 .owner = THIS_MODULE, 566 .driver = {
563 .name = "FTDI USB Serial Device", 567 .owner = THIS_MODULE,
564 .short_name = "ftdi_sio", 568 .name = "ftdi_sio",
569 },
570 .description = "FTDI USB Serial Device",
565 .id_table = id_table_combined, 571 .id_table = id_table_combined,
566 .num_interrupt_in = 0, 572 .num_interrupt_in = 0,
567 .num_bulk_in = 1, 573 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 2c35d74cc6d6..ddb63df31ce6 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -199,6 +199,19 @@
199#define FTDI_PIEGROUP_PID 0xF208 /* Product Id */ 199#define FTDI_PIEGROUP_PID 0xF208 /* Product Id */
200 200
201/* 201/*
202 * Definitions for Artemis astronomical USB based cameras
203 * Check it at http://www.artemisccd.co.uk/
204 */
205#define FTDI_ARTEMIS_PID 0xDF28 /* All Artemis Cameras */
206
207/*
208 * Definitions for ATIK Instruments astronomical USB based cameras
209 * Check it at http://www.atik-instruments.com/
210 */
211#define FTDI_ATIK_ATK16_PID 0xDF30 /* ATIK ATK-16 Camera */
212#define FTDI_ATIK_ATK16HR_PID 0xDF31 /* ATIK ATK-16HR Camera */
213
214/*
202 * Protego product ids 215 * Protego product ids
203 */ 216 */
204#define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */ 217#define PROTEGO_SPECIAL_1 0xFC70 /* special/unknown device */
@@ -329,6 +342,9 @@
329#define EVOLUTION_VID 0xDEEE /* Vendor ID */ 342#define EVOLUTION_VID 0xDEEE /* Vendor ID */
330#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ 343#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
331 344
345/* Pyramid Computer GmbH */
346#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
347
332/* Commands */ 348/* Commands */
333#define FTDI_SIO_RESET 0 /* Reset the port */ 349#define FTDI_SIO_RESET 0 /* Reset the port */
334#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 350#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 2ef614d5c8f2..35820bda7ae1 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1468,16 +1468,13 @@ static void garmin_shutdown (struct usb_serial *serial)
1468} 1468}
1469 1469
1470 1470
1471
1472
1473
1474
1475
1476/* All of the device info needed */ 1471/* All of the device info needed */
1477static struct usb_serial_device_type garmin_device = { 1472static struct usb_serial_driver garmin_device = {
1478 .owner = THIS_MODULE, 1473 .driver = {
1479 .name = "Garmin GPS usb/tty", 1474 .owner = THIS_MODULE,
1480 .short_name = "garmin_gps", 1475 .name = "garmin_gps",
1476 },
1477 .description = "Garmin GPS usb/tty",
1481 .id_table = id_table, 1478 .id_table = id_table,
1482 .num_interrupt_in = 1, 1479 .num_interrupt_in = 1,
1483 .num_bulk_in = 1, 1480 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 5f7d3193d355..8909208f506a 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -36,10 +36,11 @@ MODULE_PARM_DESC(product, "User specified USB idProduct");
36static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */ 36static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
37 37
38/* All of the device info needed for the Generic Serial Converter */ 38/* All of the device info needed for the Generic Serial Converter */
39struct usb_serial_device_type usb_serial_generic_device = { 39struct usb_serial_driver usb_serial_generic_device = {
40 .owner = THIS_MODULE, 40 .driver = {
41 .name = "Generic", 41 .owner = THIS_MODULE,
42 .short_name = "generic", 42 .name = "generic",
43 },
43 .id_table = generic_device_ids, 44 .id_table = generic_device_ids,
44 .num_interrupt_in = NUM_DONT_CARE, 45 .num_interrupt_in = NUM_DONT_CARE,
45 .num_bulk_in = NUM_DONT_CARE, 46 .num_bulk_in = NUM_DONT_CARE,
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 64d55fbd206e..8eadfb705601 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -38,15 +38,17 @@ MODULE_DEVICE_TABLE(usb, id_table);
38 38
39static struct usb_driver hp49gp_driver = { 39static struct usb_driver hp49gp_driver = {
40 .owner = THIS_MODULE, 40 .owner = THIS_MODULE,
41 .name = "HP4X", 41 .name = "hp4X",
42 .probe = usb_serial_probe, 42 .probe = usb_serial_probe,
43 .disconnect = usb_serial_disconnect, 43 .disconnect = usb_serial_disconnect,
44 .id_table = id_table, 44 .id_table = id_table,
45}; 45};
46 46
47static struct usb_serial_device_type hp49gp_device = { 47static struct usb_serial_driver hp49gp_device = {
48 .owner = THIS_MODULE, 48 .driver = {
49 .name = "HP4X", 49 .owner = THIS_MODULE,
50 .name = "hp4X",
51 },
50 .id_table = id_table, 52 .id_table = id_table,
51 .num_interrupt_in = NUM_DONT_CARE, 53 .num_interrupt_in = NUM_DONT_CARE,
52 .num_bulk_in = NUM_DONT_CARE, 54 .num_bulk_in = NUM_DONT_CARE,
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 04bfe279d763..dc4c498bd1ed 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -27,225 +27,6 @@
27 * Networks technical support, or Peter Berger <pberger@brimson.com>, 27 * Networks technical support, or Peter Berger <pberger@brimson.com>,
28 * or Al Borchers <alborchers@steinerpoint.com>. 28 * or Al Borchers <alborchers@steinerpoint.com>.
29 * 29 *
30 * Version history:
31 *
32 * 2003_04_03 al borchers
33 * - fixed a bug (that shows up with dosemu) where the tty struct is
34 * used in a callback after it has been freed
35 *
36 * 2.3 2002_03_08 greg kroah-hartman
37 * - fixed bug when multiple devices were attached at the same time.
38 *
39 * 2.2 2001_11_14 greg kroah-hartman
40 * - fixed bug in edge_close that kept the port from being used more
41 * than once.
42 * - fixed memory leak on device removal.
43 * - fixed potential double free of memory when command urb submitting
44 * failed.
45 * - other small cleanups when the device is removed
46 *
47 * 2.1 2001_07_09 greg kroah-hartman
48 * - added support for TIOCMBIS and TIOCMBIC.
49 *
50 * (04/08/2001) gb
51 * - Identify version on module load.
52 *
53 * 2.0 2001_03_05 greg kroah-hartman
54 * - reworked entire driver to fit properly in with the other usb-serial
55 * drivers. Occasional oopses still happen, but it's a good start.
56 *
57 * 1.2.3 (02/23/2001) greg kroah-hartman
58 * - changed device table to work properly for 2.4.x final format.
59 * - fixed problem with dropping data at high data rates.
60 *
61 * 1.2.2 (11/27/2000) greg kroah-hartman
62 * - cleaned up more NTisms.
63 * - Added device table for 2.4.0-test11
64 *
65 * 1.2.1 (11/08/2000) greg kroah-hartman
66 * - Started to clean up NTisms.
67 * - Fixed problem with dev field of urb for kernels >= 2.4.0-test9
68 *
69 * 1.2 (10/17/2000) David Iacovelli
70 * Remove all EPIC code and GPL source
71 * Fix RELEVANT_IFLAG macro to include flow control
72 * changes port configuration changes.
73 * Fix redefinition of SERIAL_MAGIC
74 * Change all timeout values to 5 seconds
75 * Tried to fix the UHCI multiple urb submission, but failed miserably.
76 * it seems to work fine with OHCI.
77 * ( Greg take a look at the #if 0 at end of WriteCmdUsb() we must
78 * find a way to work arount this UHCI bug )
79 *
80 * 1.1 (10/11/2000) David Iacovelli
81 * Fix XON/XOFF flow control to support both IXON and IXOFF
82 *
83 * 0.9.27 (06/30/2000) David Iacovelli
84 * Added transmit queue and now allocate urb for command writes.
85 *
86 * 0.9.26 (06/29/2000) David Iacovelli
87 * Add support for 80251 based edgeport
88 *
89 * 0.9.25 (06/27/2000) David Iacovelli
90 * Do not close the port if it has multiple opens.
91 *
92 * 0.9.24 (05/26/2000) David Iacovelli
93 * Add IOCTLs to support RXTX and JAVA POS
94 * and first cut at running BlackBox Demo
95 *
96 * 0.9.23 (05/24/2000) David Iacovelli
97 * Add IOCTLs to support RXTX and JAVA POS
98 *
99 * 0.9.22 (05/23/2000) David Iacovelli
100 * fixed bug in enumeration. If epconfig turns on mapping by
101 * path after a device is already plugged in, we now update
102 * the mapping correctly
103 *
104 * 0.9.21 (05/16/2000) David Iacovelli
105 * Added BlockUntilChaseResp() to also wait for txcredits
106 * Updated the way we allocate and handle write URBs
107 * Add debug code to dump buffers
108 *
109 * 0.9.20 (05/01/2000) David Iacovelli
110 * change driver to use usb/tts/
111 *
112 * 0.9.19 (05/01/2000) David Iacovelli
113 * Update code to compile if DEBUG is off
114 *
115 * 0.9.18 (04/28/2000) David Iacovelli
116 * cleanup and test tty_register with devfs
117 *
118 * 0.9.17 (04/27/2000) greg kroah-hartman
119 * changed tty_register around to be like the way it
120 * was before, but now it works properly with devfs.
121 *
122 * 0.9.16 (04/26/2000) david iacovelli
123 * Fixed bug in GetProductInfo()
124 *
125 * 0.9.15 (04/25/2000) david iacovelli
126 * Updated enumeration
127 *
128 * 0.9.14 (04/24/2000) david iacovelli
129 * Removed all config/status IOCTLS and
130 * converted to using /proc/edgeport
131 * still playing with devfs
132 *
133 * 0.9.13 (04/24/2000) david iacovelli
134 * Removed configuration based on ttyUSB0
135 * Added support for configuration using /prod/edgeport
136 * first attempt at using devfs (not working yet!)
137 * Added IOCTL to GetProductInfo()
138 * Added support for custom baud rates
139 * Add support for random port numbers
140 *
141 * 0.9.12 (04/18/2000) david iacovelli
142 * added additional configuration IOCTLs
143 * use ttyUSB0 for configuration
144 *
145 * 0.9.11 (04/17/2000) greg kroah-hartman
146 * fixed module initialization race conditions.
147 * made all urbs dynamically allocated.
148 * made driver devfs compatible. now it only registers the tty device
149 * when the device is actually plugged in.
150 *
151 * 0.9.10 (04/13/2000) greg kroah-hartman
152 * added proc interface framework.
153 *
154 * 0.9.9 (04/13/2000) david iacovelli
155 * added enumeration code and ioctls to configure the device
156 *
157 * 0.9.8 (04/12/2000) david iacovelli
158 * Change interrupt read start when device is plugged in
159 * and stop when device is removed
160 * process interrupt reads when all ports are closed
161 * (keep value of rxBytesAvail consistent with the edgeport)
162 * set the USB_BULK_QUEUE flag so that we can shove a bunch
163 * of urbs at once down the pipe
164 *
165 * 0.9.7 (04/10/2000) david iacovelli
166 * start to add enumeration code.
167 * generate serial number for epic devices
168 * add support for kdb
169 *
170 * 0.9.6 (03/30/2000) david iacovelli
171 * add IOCTL to get string, manufacture, and boot descriptors
172 *
173 * 0.9.5 (03/14/2000) greg kroah-hartman
174 * more error checking added to SerialOpen to try to fix UHCI open problem
175 *
176 * 0.9.4 (03/09/2000) greg kroah-hartman
177 * added more error checking to handle oops when data is hanging
178 * around and tty is abruptly closed.
179 *
180 * 0.9.3 (03/09/2000) david iacovelli
181 * Add epic support for xon/xoff chars
182 * play with performance
183 *
184 * 0.9.2 (03/08/2000) greg kroah-hartman
185 * changed most "info" calls to "dbg"
186 * implemented flow control properly in the termios call
187 *
188 * 0.9.1 (03/08/2000) david iacovelli
189 * added EPIC support
190 * enabled bootloader update
191 *
192 * 0.9 (03/08/2000) greg kroah-hartman
193 * Release to IO networks.
194 * Integrated changes that David made
195 * made getting urbs for writing SMP safe
196 *
197 * 0.8 (03/07/2000) greg kroah-hartman
198 * Release to IO networks.
199 * Fixed problems that were seen in code by David.
200 * Now both Edgeport/4 and Edgeport/2 works properly.
201 * Changed most of the functions to use port instead of serial.
202 *
203 * 0.7 (02/27/2000) greg kroah-hartman
204 * Milestone 3 release.
205 * Release to IO Networks
206 * ioctl for waiting on line change implemented.
207 * ioctl for getting statistics implemented.
208 * multiport support working.
209 * lsr and msr registers are now handled properly.
210 * change break now hooked up and working.
211 * support for all known Edgeport devices.
212 *
213 * 0.6 (02/22/2000) greg kroah-hartman
214 * Release to IO networks.
215 * CHASE is implemented correctly when port is closed.
216 * SerialOpen now blocks correctly until port is fully opened.
217 *
218 * 0.5 (02/20/2000) greg kroah-hartman
219 * Release to IO networks.
220 * Known problems:
221 * modem status register changes are not sent on to the user
222 * CHASE is not implemented when the port is closed.
223 *
224 * 0.4 (02/16/2000) greg kroah-hartman
225 * Second cut at the CeBit demo.
226 * Doesn't leak memory on every write to the port
227 * Still small leaks on startup.
228 * Added support for Edgeport/2 and Edgeport/8
229 *
230 * 0.3 (02/15/2000) greg kroah-hartman
231 * CeBit demo release.
232 * Force the line settings to 4800, 8, 1, e for the demo.
233 * Warning! This version leaks memory like crazy!
234 *
235 * 0.2 (01/30/2000) greg kroah-hartman
236 * Milestone 1 release.
237 * Device is found by USB subsystem, enumerated, fimware is downloaded
238 * and the descriptors are printed to the debug log, config is set, and
239 * green light starts to blink. Open port works, and data can be sent
240 * and received at the default settings of the UART. Loopback connector
241 * and debug log confirms this.
242 *
243 * 0.1 (01/23/2000) greg kroah-hartman
244 * Initial release to help IO Networks try to set up their test system.
245 * Edgeport4 is recognized, firmware is downloaded, config is set so
246 * device blinks green light every 3 sec. Port is bound, but opening,
247 * closing, and sending data do not work properly.
248 *
249 */ 30 */
250 31
251#include <linux/config.h> 32#include <linux/config.h>
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
index e7ffe02408bd..fad561c04c76 100644
--- a/drivers/usb/serial/io_tables.h
+++ b/drivers/usb/serial/io_tables.h
@@ -75,10 +75,12 @@ static struct usb_device_id id_table_combined [] = {
75 75
76MODULE_DEVICE_TABLE (usb, id_table_combined); 76MODULE_DEVICE_TABLE (usb, id_table_combined);
77 77
78static struct usb_serial_device_type edgeport_2port_device = { 78static struct usb_serial_driver edgeport_2port_device = {
79 .owner = THIS_MODULE, 79 .driver = {
80 .name = "Edgeport 2 port adapter", 80 .owner = THIS_MODULE,
81 .short_name = "edgeport_2", 81 .name = "edgeport_2",
82 },
83 .description = "Edgeport 2 port adapter",
82 .id_table = edgeport_2port_id_table, 84 .id_table = edgeport_2port_id_table,
83 .num_interrupt_in = 1, 85 .num_interrupt_in = 1,
84 .num_bulk_in = 1, 86 .num_bulk_in = 1,
@@ -103,10 +105,12 @@ static struct usb_serial_device_type edgeport_2port_device = {
103 .write_bulk_callback = edge_bulk_out_data_callback, 105 .write_bulk_callback = edge_bulk_out_data_callback,
104}; 106};
105 107
106static struct usb_serial_device_type edgeport_4port_device = { 108static struct usb_serial_driver edgeport_4port_device = {
107 .owner = THIS_MODULE, 109 .driver = {
108 .name = "Edgeport 4 port adapter", 110 .owner = THIS_MODULE,
109 .short_name = "edgeport_4", 111 .name = "edgeport_4",
112 },
113 .description = "Edgeport 4 port adapter",
110 .id_table = edgeport_4port_id_table, 114 .id_table = edgeport_4port_id_table,
111 .num_interrupt_in = 1, 115 .num_interrupt_in = 1,
112 .num_bulk_in = 1, 116 .num_bulk_in = 1,
@@ -131,10 +135,12 @@ static struct usb_serial_device_type edgeport_4port_device = {
131 .write_bulk_callback = edge_bulk_out_data_callback, 135 .write_bulk_callback = edge_bulk_out_data_callback,
132}; 136};
133 137
134static struct usb_serial_device_type edgeport_8port_device = { 138static struct usb_serial_driver edgeport_8port_device = {
135 .owner = THIS_MODULE, 139 .driver = {
136 .name = "Edgeport 8 port adapter", 140 .owner = THIS_MODULE,
137 .short_name = "edgeport_8", 141 .name = "edgeport_8",
142 },
143 .description = "Edgeport 8 port adapter",
138 .id_table = edgeport_8port_id_table, 144 .id_table = edgeport_8port_id_table,
139 .num_interrupt_in = 1, 145 .num_interrupt_in = 1,
140 .num_bulk_in = 1, 146 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index ebf9967f7c86..832b6d6734c0 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2982,10 +2982,12 @@ static unsigned int edge_buf_get(struct edge_buf *eb, char *buf,
2982} 2982}
2983 2983
2984 2984
2985static struct usb_serial_device_type edgeport_1port_device = { 2985static struct usb_serial_driver edgeport_1port_device = {
2986 .owner = THIS_MODULE, 2986 .driver = {
2987 .name = "Edgeport TI 1 port adapter", 2987 .owner = THIS_MODULE,
2988 .short_name = "edgeport_ti_1", 2988 .name = "edgeport_ti_1",
2989 },
2990 .description = "Edgeport TI 1 port adapter",
2989 .id_table = edgeport_1port_id_table, 2991 .id_table = edgeport_1port_id_table,
2990 .num_interrupt_in = 1, 2992 .num_interrupt_in = 1,
2991 .num_bulk_in = 1, 2993 .num_bulk_in = 1,
@@ -3010,10 +3012,12 @@ static struct usb_serial_device_type edgeport_1port_device = {
3010 .write_bulk_callback = edge_bulk_out_callback, 3012 .write_bulk_callback = edge_bulk_out_callback,
3011}; 3013};
3012 3014
3013static struct usb_serial_device_type edgeport_2port_device = { 3015static struct usb_serial_driver edgeport_2port_device = {
3014 .owner = THIS_MODULE, 3016 .driver = {
3015 .name = "Edgeport TI 2 port adapter", 3017 .owner = THIS_MODULE,
3016 .short_name = "edgeport_ti_2", 3018 .name = "edgeport_ti_2",
3019 },
3020 .description = "Edgeport TI 2 port adapter",
3017 .id_table = edgeport_2port_id_table, 3021 .id_table = edgeport_2port_id_table,
3018 .num_interrupt_in = 1, 3022 .num_interrupt_in = 1,
3019 .num_bulk_in = 2, 3023 .num_bulk_in = 2,
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index c05c2a2a0f31..d5d066488100 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -92,24 +92,7 @@ static void ipaq_destroy_lists(struct usb_serial_port *port);
92static struct usb_device_id ipaq_id_table [] = { 92static struct usb_device_id ipaq_id_table [] = {
93 /* The first entry is a placeholder for the insmod-specified device */ 93 /* The first entry is a placeholder for the insmod-specified device */
94 { USB_DEVICE(0x049F, 0x0003) }, 94 { USB_DEVICE(0x049F, 0x0003) },
95 { USB_DEVICE(0x1690, 0x0601) }, /* Askey USB Sync */ 95 { USB_DEVICE(0x0104, 0x00BE) }, /* Socket USB Sync */
96 { USB_DEVICE(0x0960, 0x0065) }, /* BCOM USB Sync 0065 */
97 { USB_DEVICE(0x0960, 0x0066) }, /* BCOM USB Sync 0066 */
98 { USB_DEVICE(0x0960, 0x0067) }, /* BCOM USB Sync 0067 */
99 { USB_DEVICE(0x07CF, 0x2001) }, /* CASIO USB Sync 2001 */
100 { USB_DEVICE(0x07CF, 0x2002) }, /* CASIO USB Sync 2002 */
101 { USB_DEVICE(0x07CF, 0x2003) }, /* CASIO USB Sync 2003 */
102 { USB_DEVICE(0x049F, 0x0003) }, /* Compaq iPAQ USB Sync */
103 { USB_DEVICE(0x049F, 0x0032) }, /* Compaq iPAQ USB Sync */
104 { USB_DEVICE(0x413C, 0x4001) }, /* Dell Axim USB Sync */
105 { USB_DEVICE(0x413C, 0x4002) }, /* Dell Axim USB Sync */
106 { USB_DEVICE(0x413C, 0x4003) }, /* Dell Axim USB Sync */
107 { USB_DEVICE(0x413C, 0x4004) }, /* Dell Axim USB Sync */
108 { USB_DEVICE(0x413C, 0x4005) }, /* Dell Axim USB Sync */
109 { USB_DEVICE(0x413C, 0x4006) }, /* Dell Axim USB Sync */
110 { USB_DEVICE(0x413C, 0x4007) }, /* Dell Axim USB Sync */
111 { USB_DEVICE(0x413C, 0x4008) }, /* Dell Axim USB Sync */
112 { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */
113 { USB_DEVICE(0x03F0, 0x1016) }, /* HP USB Sync */ 96 { USB_DEVICE(0x03F0, 0x1016) }, /* HP USB Sync */
114 { USB_DEVICE(0x03F0, 0x1116) }, /* HP USB Sync 1611 */ 97 { USB_DEVICE(0x03F0, 0x1116) }, /* HP USB Sync 1611 */
115 { USB_DEVICE(0x03F0, 0x1216) }, /* HP USB Sync 1612 */ 98 { USB_DEVICE(0x03F0, 0x1216) }, /* HP USB Sync 1612 */
@@ -125,7 +108,13 @@ static struct usb_device_id ipaq_id_table [] = {
125 { USB_DEVICE(0x03F0, 0x5016) }, /* HP USB Sync 1650 */ 108 { USB_DEVICE(0x03F0, 0x5016) }, /* HP USB Sync 1650 */
126 { USB_DEVICE(0x03F0, 0x5116) }, /* HP USB Sync 1651 */ 109 { USB_DEVICE(0x03F0, 0x5116) }, /* HP USB Sync 1651 */
127 { USB_DEVICE(0x03F0, 0x5216) }, /* HP USB Sync 1652 */ 110 { USB_DEVICE(0x03F0, 0x5216) }, /* HP USB Sync 1652 */
128 { USB_DEVICE(0x094B, 0x0001) }, /* Linkup Systems USB Sync */ 111 { USB_DEVICE(0x0409, 0x00D5) }, /* NEC USB Sync */
112 { USB_DEVICE(0x0409, 0x00D6) }, /* NEC USB Sync */
113 { USB_DEVICE(0x0409, 0x00D7) }, /* NEC USB Sync */
114 { USB_DEVICE(0x0409, 0x8024) }, /* NEC USB Sync */
115 { USB_DEVICE(0x0409, 0x8025) }, /* NEC USB Sync */
116 { USB_DEVICE(0x043E, 0x9C01) }, /* LGE USB Sync */
117 { USB_DEVICE(0x045E, 0x00CE) }, /* Microsoft USB Sync */
129 { USB_DEVICE(0x045E, 0x0400) }, /* Windows Powered Pocket PC 2002 */ 118 { USB_DEVICE(0x045E, 0x0400) }, /* Windows Powered Pocket PC 2002 */
130 { USB_DEVICE(0x045E, 0x0401) }, /* Windows Powered Pocket PC 2002 */ 119 { USB_DEVICE(0x045E, 0x0401) }, /* Windows Powered Pocket PC 2002 */
131 { USB_DEVICE(0x045E, 0x0402) }, /* Windows Powered Pocket PC 2002 */ 120 { USB_DEVICE(0x045E, 0x0402) }, /* Windows Powered Pocket PC 2002 */
@@ -251,17 +240,81 @@ static struct usb_device_id ipaq_id_table [] = {
251 { USB_DEVICE(0x045E, 0x04E8) }, /* Windows Powered Smartphone 2003 */ 240 { USB_DEVICE(0x045E, 0x04E8) }, /* Windows Powered Smartphone 2003 */
252 { USB_DEVICE(0x045E, 0x04E9) }, /* Windows Powered Smartphone 2003 */ 241 { USB_DEVICE(0x045E, 0x04E9) }, /* Windows Powered Smartphone 2003 */
253 { USB_DEVICE(0x045E, 0x04EA) }, /* Windows Powered Smartphone 2003 */ 242 { USB_DEVICE(0x045E, 0x04EA) }, /* Windows Powered Smartphone 2003 */
254 { USB_DEVICE(0x0961, 0x0010) }, /* Portatec USB Sync */ 243 { USB_DEVICE(0x049F, 0x0003) }, /* Compaq iPAQ USB Sync */
255 { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ 244 { USB_DEVICE(0x049F, 0x0032) }, /* Compaq iPAQ USB Sync */
256 { USB_DEVICE(0x0104, 0x00BE) }, /* Socket USB Sync */ 245 { USB_DEVICE(0x04A4, 0x0014) }, /* Hitachi USB Sync */
246 { USB_DEVICE(0x04AD, 0x0301) }, /* USB Sync 0301 */
247 { USB_DEVICE(0x04AD, 0x0302) }, /* USB Sync 0302 */
248 { USB_DEVICE(0x04AD, 0x0303) }, /* USB Sync 0303 */
249 { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */
250 { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */
251 { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */
252 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */
253 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */
254 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */
255 { USB_DEVICE(0x04E8, 0x5F03) }, /* Samsung NEXiO USB Sync */
256 { USB_DEVICE(0x04E8, 0x5F04) }, /* Samsung NEXiO USB Sync */
257 { USB_DEVICE(0x04E8, 0x6611) }, /* Samsung MITs USB Sync */
258 { USB_DEVICE(0x04E8, 0x6613) }, /* Samsung MITs USB Sync */
259 { USB_DEVICE(0x04E8, 0x6615) }, /* Samsung MITs USB Sync */
260 { USB_DEVICE(0x04E8, 0x6617) }, /* Samsung MITs USB Sync */
261 { USB_DEVICE(0x04E8, 0x6619) }, /* Samsung MITs USB Sync */
262 { USB_DEVICE(0x04E8, 0x661B) }, /* Samsung MITs USB Sync */
263 { USB_DEVICE(0x04E8, 0x662E) }, /* Samsung MITs USB Sync */
264 { USB_DEVICE(0x04E8, 0x6630) }, /* Samsung MITs USB Sync */
265 { USB_DEVICE(0x04E8, 0x6632) }, /* Samsung MITs USB Sync */
266 { USB_DEVICE(0x04f1, 0x3011) }, /* JVC USB Sync */
267 { USB_DEVICE(0x04F1, 0x3012) }, /* JVC USB Sync */
268 { USB_DEVICE(0x0502, 0x1631) }, /* c10 Series */
269 { USB_DEVICE(0x0502, 0x1632) }, /* c20 Series */
270 { USB_DEVICE(0x0502, 0x16E1) }, /* Acer n10 Handheld USB Sync */
271 { USB_DEVICE(0x0502, 0x16E2) }, /* Acer n20 Handheld USB Sync */
272 { USB_DEVICE(0x0502, 0x16E3) }, /* Acer n30 Handheld USB Sync */
273 { USB_DEVICE(0x0536, 0x01A0) }, /* HHP PDT */
274 { USB_DEVICE(0x0543, 0x0ED9) }, /* ViewSonic Color Pocket PC V35 */
275 { USB_DEVICE(0x0543, 0x1527) }, /* ViewSonic Color Pocket PC V36 */
276 { USB_DEVICE(0x0543, 0x1529) }, /* ViewSonic Color Pocket PC V37 */
277 { USB_DEVICE(0x0543, 0x152B) }, /* ViewSonic Color Pocket PC V38 */
278 { USB_DEVICE(0x0543, 0x152E) }, /* ViewSonic Pocket PC */
279 { USB_DEVICE(0x0543, 0x1921) }, /* ViewSonic Communicator Pocket PC */
280 { USB_DEVICE(0x0543, 0x1922) }, /* ViewSonic Smartphone */
281 { USB_DEVICE(0x0543, 0x1923) }, /* ViewSonic Pocket PC V30 */
282 { USB_DEVICE(0x05E0, 0x2000) }, /* Symbol USB Sync */
283 { USB_DEVICE(0x05E0, 0x2001) }, /* Symbol USB Sync 0x2001 */
284 { USB_DEVICE(0x05E0, 0x2002) }, /* Symbol USB Sync 0x2002 */
285 { USB_DEVICE(0x05E0, 0x2003) }, /* Symbol USB Sync 0x2003 */
286 { USB_DEVICE(0x05E0, 0x2004) }, /* Symbol USB Sync 0x2004 */
287 { USB_DEVICE(0x05E0, 0x2005) }, /* Symbol USB Sync 0x2005 */
288 { USB_DEVICE(0x05E0, 0x2006) }, /* Symbol USB Sync 0x2006 */
289 { USB_DEVICE(0x05E0, 0x2007) }, /* Symbol USB Sync 0x2007 */
290 { USB_DEVICE(0x05E0, 0x2008) }, /* Symbol USB Sync 0x2008 */
291 { USB_DEVICE(0x05E0, 0x2009) }, /* Symbol USB Sync 0x2009 */
292 { USB_DEVICE(0x05E0, 0x200A) }, /* Symbol USB Sync 0x200A */
293 { USB_DEVICE(0x067E, 0x1001) }, /* Intermec Mobile Computer */
294 { USB_DEVICE(0x07CF, 0x2001) }, /* CASIO USB Sync 2001 */
295 { USB_DEVICE(0x07CF, 0x2002) }, /* CASIO USB Sync 2002 */
296 { USB_DEVICE(0x07CF, 0x2003) }, /* CASIO USB Sync 2003 */
257 { USB_DEVICE(0x0930, 0x0700) }, /* TOSHIBA USB Sync 0700 */ 297 { USB_DEVICE(0x0930, 0x0700) }, /* TOSHIBA USB Sync 0700 */
258 { USB_DEVICE(0x0930, 0x0705) }, /* TOSHIBA Pocket PC e310 */ 298 { USB_DEVICE(0x0930, 0x0705) }, /* TOSHIBA Pocket PC e310 */
299 { USB_DEVICE(0x0930, 0x0706) }, /* TOSHIBA Pocket PC e740 */
259 { USB_DEVICE(0x0930, 0x0707) }, /* TOSHIBA Pocket PC e330 Series */ 300 { USB_DEVICE(0x0930, 0x0707) }, /* TOSHIBA Pocket PC e330 Series */
260 { USB_DEVICE(0x0930, 0x0708) }, /* TOSHIBA Pocket PC e350 Series */ 301 { USB_DEVICE(0x0930, 0x0708) }, /* TOSHIBA Pocket PC e350 Series */
261 { USB_DEVICE(0x0930, 0x0706) }, /* TOSHIBA Pocket PC e740 */
262 { USB_DEVICE(0x0930, 0x0709) }, /* TOSHIBA Pocket PC e750 Series */ 302 { USB_DEVICE(0x0930, 0x0709) }, /* TOSHIBA Pocket PC e750 Series */
263 { USB_DEVICE(0x0930, 0x070A) }, /* TOSHIBA Pocket PC e400 Series */ 303 { USB_DEVICE(0x0930, 0x070A) }, /* TOSHIBA Pocket PC e400 Series */
264 { USB_DEVICE(0x0930, 0x070B) }, /* TOSHIBA Pocket PC e800 Series */ 304 { USB_DEVICE(0x0930, 0x070B) }, /* TOSHIBA Pocket PC e800 Series */
305 { USB_DEVICE(0x094B, 0x0001) }, /* Linkup Systems USB Sync */
306 { USB_DEVICE(0x0960, 0x0065) }, /* BCOM USB Sync 0065 */
307 { USB_DEVICE(0x0960, 0x0066) }, /* BCOM USB Sync 0066 */
308 { USB_DEVICE(0x0960, 0x0067) }, /* BCOM USB Sync 0067 */
309 { USB_DEVICE(0x0961, 0x0010) }, /* Portatec USB Sync */
310 { USB_DEVICE(0x099E, 0x0052) }, /* Trimble GeoExplorer */
311 { USB_DEVICE(0x099E, 0x4000) }, /* TDS Data Collector */
312 { USB_DEVICE(0x0B05, 0x4200) }, /* ASUS USB Sync */
313 { USB_DEVICE(0x0B05, 0x4201) }, /* ASUS USB Sync */
314 { USB_DEVICE(0x0B05, 0x4202) }, /* ASUS USB Sync */
315 { USB_DEVICE(0x0B05, 0x420F) }, /* ASUS USB Sync */
316 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
317 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
265 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */ 318 { USB_DEVICE(0x0BB4, 0x00CE) }, /* HTC USB Sync */
266 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */ 319 { USB_DEVICE(0x0BB4, 0x0A01) }, /* PocketPC USB Sync */
267 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */ 320 { USB_DEVICE(0x0BB4, 0x0A02) }, /* PocketPC USB Sync */
@@ -422,116 +475,67 @@ static struct usb_device_id ipaq_id_table [] = {
422 { USB_DEVICE(0x0BB4, 0x0A9D) }, /* SmartPhone USB Sync */ 475 { USB_DEVICE(0x0BB4, 0x0A9D) }, /* SmartPhone USB Sync */
423 { USB_DEVICE(0x0BB4, 0x0A9E) }, /* SmartPhone USB Sync */ 476 { USB_DEVICE(0x0BB4, 0x0A9E) }, /* SmartPhone USB Sync */
424 { USB_DEVICE(0x0BB4, 0x0A9F) }, /* SmartPhone USB Sync */ 477 { USB_DEVICE(0x0BB4, 0x0A9F) }, /* SmartPhone USB Sync */
425 { USB_DEVICE(0x0409, 0x00D5) }, /* NEC USB Sync */
426 { USB_DEVICE(0x0409, 0x00D6) }, /* NEC USB Sync */
427 { USB_DEVICE(0x0409, 0x00D7) }, /* NEC USB Sync */
428 { USB_DEVICE(0x0409, 0x8024) }, /* NEC USB Sync */
429 { USB_DEVICE(0x0409, 0x8025) }, /* NEC USB Sync */
430 { USB_DEVICE(0x04A4, 0x0014) }, /* Hitachi USB Sync */
431 { USB_DEVICE(0x0BF8, 0x1001) }, /* Fujitsu Siemens Computers USB Sync */ 478 { USB_DEVICE(0x0BF8, 0x1001) }, /* Fujitsu Siemens Computers USB Sync */
432 { USB_DEVICE(0x0F98, 0x0201) }, /* Cyberbank USB Sync */ 479 { USB_DEVICE(0x0C44, 0x03A2) }, /* Motorola iDEN Smartphone */
433 { USB_DEVICE(0x0502, 0x16E1) }, /* Acer n10 Handheld USB Sync */
434 { USB_DEVICE(0x0502, 0x16E3) }, /* Acer n30 Handheld USB Sync */
435 { USB_DEVICE(0x0502, 0x16E2) }, /* Acer n20 Handheld USB Sync */
436 { USB_DEVICE(0x0502, 0x1631) }, /* c10 Series */
437 { USB_DEVICE(0x0502, 0x1632) }, /* c20 Series */
438 { USB_DEVICE(0x0B05, 0x9202) }, /* ASUS USB Sync */
439 { USB_DEVICE(0x0B05, 0x420F) }, /* ASUS USB Sync */
440 { USB_DEVICE(0x0B05, 0x4200) }, /* ASUS USB Sync */
441 { USB_DEVICE(0x0B05, 0x4201) }, /* ASUS USB Sync */
442 { USB_DEVICE(0x0B05, 0x4202) }, /* ASUS USB Sync */
443 { USB_DEVICE(0x0B05, 0x9200) }, /* ASUS USB Sync */
444 { USB_DEVICE(0x0C8E, 0x6000) }, /* Cesscom Luxian Series */ 480 { USB_DEVICE(0x0C8E, 0x6000) }, /* Cesscom Luxian Series */
445 { USB_DEVICE(0x04AD, 0x0301) }, /* USB Sync 0301 */ 481 { USB_DEVICE(0x0CAD, 0x9001) }, /* Motorola PowerPad Pocket PC Device */
446 { USB_DEVICE(0x04AD, 0x0302) }, /* USB Sync 0302 */ 482 { USB_DEVICE(0x0F4E, 0x0200) }, /* Freedom Scientific USB Sync */
447 { USB_DEVICE(0x04AD, 0x0303) }, /* USB Sync 0303 */ 483 { USB_DEVICE(0x0F98, 0x0201) }, /* Cyberbank USB Sync */
484 { USB_DEVICE(0x0FB8, 0x3001) }, /* Wistron USB Sync */
485 { USB_DEVICE(0x0FB8, 0x3002) }, /* Wistron USB Sync */
486 { USB_DEVICE(0x0FB8, 0x3003) }, /* Wistron USB Sync */
487 { USB_DEVICE(0x0FB8, 0x4001) }, /* Wistron USB Sync */
488 { USB_DEVICE(0x1066, 0x00CE) }, /* E-TEN USB Sync */
448 { USB_DEVICE(0x1066, 0x0300) }, /* E-TEN P3XX Pocket PC */ 489 { USB_DEVICE(0x1066, 0x0300) }, /* E-TEN P3XX Pocket PC */
449 { USB_DEVICE(0x1066, 0x0500) }, /* E-TEN P5XX Pocket PC */ 490 { USB_DEVICE(0x1066, 0x0500) }, /* E-TEN P5XX Pocket PC */
450 { USB_DEVICE(0x1066, 0x0600) }, /* E-TEN P6XX Pocket PC */ 491 { USB_DEVICE(0x1066, 0x0600) }, /* E-TEN P6XX Pocket PC */
451 { USB_DEVICE(0x1066, 0x0700) }, /* E-TEN P7XX Pocket PC */ 492 { USB_DEVICE(0x1066, 0x0700) }, /* E-TEN P7XX Pocket PC */
452 { USB_DEVICE(0x1066, 0x00CE) }, /* E-TEN USB Sync */ 493 { USB_DEVICE(0x1114, 0x0001) }, /* Psion Teklogix Sync 753x */
453 { USB_DEVICE(0x0F4E, 0x0200) }, /* Freedom Scientific USB Sync */ 494 { USB_DEVICE(0x1114, 0x0004) }, /* Psion Teklogix Sync netBookPro */
454 { USB_DEVICE(0x04C5, 0x1058) }, /* FUJITSU USB Sync */ 495 { USB_DEVICE(0x1114, 0x0006) }, /* Psion Teklogix Sync 7525 */
455 { USB_DEVICE(0x04C5, 0x1079) }, /* FUJITSU USB Sync */ 496 { USB_DEVICE(0x1182, 0x1388) }, /* VES USB Sync */
456 { USB_DEVICE(0x067E, 0x1001) }, /* Intermec Mobile Computer */ 497 { USB_DEVICE(0x11D9, 0x1002) }, /* Rugged Pocket PC 2003 */
457 { USB_DEVICE(0x04f1, 0x3011) }, /* JVC USB Sync */ 498 { USB_DEVICE(0x11D9, 0x1003) }, /* Rugged Pocket PC 2003 */
458 { USB_DEVICE(0x04F1, 0x3012) }, /* JVC USB Sync */ 499 { USB_DEVICE(0x1231, 0xCE01) }, /* USB Sync 03 */
459 { USB_DEVICE(0x3708, 0x20CE) }, /* Legend USB Sync */ 500 { USB_DEVICE(0x1231, 0xCE02) }, /* USB Sync 03 */
460 { USB_DEVICE(0x3708, 0x21CE) }, /* Lenovo USB Sync */ 501 { USB_DEVICE(0x1690, 0x0601) }, /* Askey USB Sync */
461 { USB_DEVICE(0x043E, 0x9C01) }, /* LGE USB Sync */ 502 { USB_DEVICE(0x22B8, 0x4204) }, /* Motorola MPx200 Smartphone */
462 { USB_DEVICE(0x04DA, 0x2500) }, /* Panasonic USB Sync */ 503 { USB_DEVICE(0x22B8, 0x4214) }, /* Motorola MPc GSM */
463 { USB_DEVICE(0x3340, 0x0B1C) }, /* Generic PPC StrongARM */ 504 { USB_DEVICE(0x22B8, 0x4224) }, /* Motorola MPx220 Smartphone */
464 { USB_DEVICE(0x3340, 0x0E3A) }, /* Generic PPC USB Sync */ 505 { USB_DEVICE(0x22B8, 0x4234) }, /* Motorola MPc CDMA */
465 { USB_DEVICE(0x3340, 0x0F3A) }, /* Generic SmartPhone USB Sync */ 506 { USB_DEVICE(0x22B8, 0x4244) }, /* Motorola MPx100 Smartphone */
466 { USB_DEVICE(0x3340, 0x0F1C) }, /* Itautec USB Sync */ 507 { USB_DEVICE(0x3340, 0x011C) }, /* Mio DigiWalker PPC StrongARM */
467 { USB_DEVICE(0x3340, 0x1326) }, /* Itautec USB Sync */
468 { USB_DEVICE(0x3340, 0x3326) }, /* MEDION Winodws Moble USB Sync */
469 { USB_DEVICE(0x3340, 0x0326) }, /* Mio DigiWalker 338 */ 508 { USB_DEVICE(0x3340, 0x0326) }, /* Mio DigiWalker 338 */
470 { USB_DEVICE(0x3340, 0x0426) }, /* Mio DigiWalker 338 */ 509 { USB_DEVICE(0x3340, 0x0426) }, /* Mio DigiWalker 338 */
471 { USB_DEVICE(0x3340, 0x011C) }, /* Mio DigiWalker PPC StrongARM */
472 { USB_DEVICE(0x3340, 0x053A) }, /* Mio DigiWalker SmartPhone USB Sync */
473 { USB_DEVICE(0x3340, 0x043A) }, /* Mio DigiWalker USB Sync */ 510 { USB_DEVICE(0x3340, 0x043A) }, /* Mio DigiWalker USB Sync */
474 { USB_DEVICE(0x3340, 0x071C) }, /* MiTAC USB Sync */
475 { USB_DEVICE(0x3340, 0x051C) }, /* MiTAC USB Sync 528 */ 511 { USB_DEVICE(0x3340, 0x051C) }, /* MiTAC USB Sync 528 */
476 { USB_DEVICE(0x3340, 0x2326) }, /* Vobis USB Sync */ 512 { USB_DEVICE(0x3340, 0x053A) }, /* Mio DigiWalker SmartPhone USB Sync */
513 { USB_DEVICE(0x3340, 0x071C) }, /* MiTAC USB Sync */
514 { USB_DEVICE(0x3340, 0x0B1C) }, /* Generic PPC StrongARM */
515 { USB_DEVICE(0x3340, 0x0E3A) }, /* Generic PPC USB Sync */
516 { USB_DEVICE(0x3340, 0x0F1C) }, /* Itautec USB Sync */
517 { USB_DEVICE(0x3340, 0x0F3A) }, /* Generic SmartPhone USB Sync */
518 { USB_DEVICE(0x3340, 0x1326) }, /* Itautec USB Sync */
477 { USB_DEVICE(0x3340, 0x191C) }, /* YAKUMO USB Sync */ 519 { USB_DEVICE(0x3340, 0x191C) }, /* YAKUMO USB Sync */
520 { USB_DEVICE(0x3340, 0x2326) }, /* Vobis USB Sync */
521 { USB_DEVICE(0x3340, 0x3326) }, /* MEDION Winodws Moble USB Sync */
522 { USB_DEVICE(0x3708, 0x20CE) }, /* Legend USB Sync */
523 { USB_DEVICE(0x3708, 0x21CE) }, /* Lenovo USB Sync */
478 { USB_DEVICE(0x4113, 0x0210) }, /* Mobile Media Technology USB Sync */ 524 { USB_DEVICE(0x4113, 0x0210) }, /* Mobile Media Technology USB Sync */
479 { USB_DEVICE(0x4113, 0x0211) }, /* Mobile Media Technology USB Sync */ 525 { USB_DEVICE(0x4113, 0x0211) }, /* Mobile Media Technology USB Sync */
480 { USB_DEVICE(0x4113, 0x0400) }, /* Mobile Media Technology USB Sync */ 526 { USB_DEVICE(0x4113, 0x0400) }, /* Mobile Media Technology USB Sync */
481 { USB_DEVICE(0x4113, 0x0410) }, /* Mobile Media Technology USB Sync */ 527 { USB_DEVICE(0x4113, 0x0410) }, /* Mobile Media Technology USB Sync */
482 { USB_DEVICE(0x0CAD, 0x9001) }, /* Motorola PowerPad Pocket PC Device */ 528 { USB_DEVICE(0x413C, 0x4001) }, /* Dell Axim USB Sync */
483 { USB_DEVICE(0x0C44, 0x03A2) }, /* Motorola iDEN Smartphone */ 529 { USB_DEVICE(0x413C, 0x4002) }, /* Dell Axim USB Sync */
484 { USB_DEVICE(0x04E8, 0x6611) }, /* Samsung MITs USB Sync */ 530 { USB_DEVICE(0x413C, 0x4003) }, /* Dell Axim USB Sync */
485 { USB_DEVICE(0x04E8, 0x6613) }, /* Samsung MITs USB Sync */ 531 { USB_DEVICE(0x413C, 0x4004) }, /* Dell Axim USB Sync */
486 { USB_DEVICE(0x04E8, 0x6615) }, /* Samsung MITs USB Sync */ 532 { USB_DEVICE(0x413C, 0x4005) }, /* Dell Axim USB Sync */
487 { USB_DEVICE(0x04E8, 0x6617) }, /* Samsung MITs USB Sync */ 533 { USB_DEVICE(0x413C, 0x4006) }, /* Dell Axim USB Sync */
488 { USB_DEVICE(0x04E8, 0x6619) }, /* Samsung MITs USB Sync */ 534 { USB_DEVICE(0x413C, 0x4007) }, /* Dell Axim USB Sync */
489 { USB_DEVICE(0x04E8, 0x661B) }, /* Samsung MITs USB Sync */ 535 { USB_DEVICE(0x413C, 0x4008) }, /* Dell Axim USB Sync */
490 { USB_DEVICE(0x04E8, 0x5F00) }, /* Samsung NEXiO USB Sync */ 536 { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */
491 { USB_DEVICE(0x04E8, 0x5F01) }, /* Samsung NEXiO USB Sync */
492 { USB_DEVICE(0x04E8, 0x5F02) }, /* Samsung NEXiO USB Sync */
493 { USB_DEVICE(0x04E8, 0x5F03) }, /* Samsung NEXiO USB Sync */
494 { USB_DEVICE(0x04E8, 0x5F04) }, /* Samsung NEXiO USB Sync */
495 { USB_DEVICE(0x04E8, 0x662E) }, /* Samsung MITs USB Sync */
496 { USB_DEVICE(0x04E8, 0x6630) }, /* Samsung MITs USB Sync */
497 { USB_DEVICE(0x04E8, 0x6632) }, /* Samsung MITs USB Sync */
498 { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ 537 { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */
499 { USB_DEVICE(0x05E0, 0x2000) }, /* Symbol USB Sync */ 538 { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */
500 { USB_DEVICE(0x05E0, 0x2001) }, /* Symbol USB Sync 0x2001 */
501 { USB_DEVICE(0x05E0, 0x2002) }, /* Symbol USB Sync 0x2002 */
502 { USB_DEVICE(0x05E0, 0x2003) }, /* Symbol USB Sync 0x2003 */
503 { USB_DEVICE(0x05E0, 0x2004) }, /* Symbol USB Sync 0x2004 */
504 { USB_DEVICE(0x05E0, 0x2005) }, /* Symbol USB Sync 0x2005 */
505 { USB_DEVICE(0x05E0, 0x2006) }, /* Symbol USB Sync 0x2006 */
506 { USB_DEVICE(0x05E0, 0x2007) }, /* Symbol USB Sync 0x2007 */
507 { USB_DEVICE(0x05E0, 0x2008) }, /* Symbol USB Sync 0x2008 */
508 { USB_DEVICE(0x05E0, 0x2009) }, /* Symbol USB Sync 0x2009 */
509 { USB_DEVICE(0x05E0, 0x200A) }, /* Symbol USB Sync 0x200A */
510 { USB_DEVICE(0x1182, 0x1388) }, /* VES USB Sync */
511 { USB_DEVICE(0x0543, 0x0ED9) }, /* ViewSonic Color Pocket PC V35 */
512 { USB_DEVICE(0x0543, 0x1527) }, /* ViewSonic Color Pocket PC V36 */
513 { USB_DEVICE(0x0543, 0x1529) }, /* ViewSonic Color Pocket PC V37 */
514 { USB_DEVICE(0x0543, 0x152B) }, /* ViewSonic Color Pocket PC V38 */
515 { USB_DEVICE(0x0543, 0x152E) }, /* ViewSonic Pocket PC */
516 { USB_DEVICE(0x0543, 0x1921) }, /* ViewSonic Communicator Pocket PC */
517 { USB_DEVICE(0x0543, 0x1922) }, /* ViewSonic Smartphone */
518 { USB_DEVICE(0x0543, 0x1923) }, /* ViewSonic Pocket PC V30 */
519 { USB_DEVICE(0x0536, 0x01A0) }, /* HHP PDT */
520 { USB_DEVICE(0x099E, 0x0052) }, /* Trimble GeoExplorer */
521 { USB_DEVICE(0x099E, 0x4000) }, /* TDS Data Collector */
522 { USB_DEVICE(0x0FB8, 0x3001) }, /* Wistron USB Sync */
523 { USB_DEVICE(0x0FB8, 0x3002) }, /* Wistron USB Sync */
524 { USB_DEVICE(0x0FB8, 0x3003) }, /* Wistron USB Sync */
525 { USB_DEVICE(0x0FB8, 0x4001) }, /* Wistron USB Sync */
526 { USB_DEVICE(0x11D9, 0x1003) }, /* Rugged Pocket PC 2003 */
527 { USB_DEVICE(0x11D9, 0x1002) }, /* Rugged Pocket PC 2003 */
528 { USB_DEVICE(0x22B8, 0x4204) }, /* Motorola MPx200 Smartphone */
529 { USB_DEVICE(0x22B8, 0x4214) }, /* Motorola MPc GSM */
530 { USB_DEVICE(0x22B8, 0x4224) }, /* Motorola MPx220 Smartphone */
531 { USB_DEVICE(0x22B8, 0x4234) }, /* Motorola MPc CDMA */
532 { USB_DEVICE(0x22B8, 0x4244) }, /* Motorola MPx100 Smartphone */
533 { USB_DEVICE(0x1231, 0xCE01) }, /* USB Sync 03 */
534 { USB_DEVICE(0x1231, 0xCE02) }, /* USB Sync 03 */
535 { } /* Terminating entry */ 539 { } /* Terminating entry */
536}; 540};
537 541
@@ -547,9 +551,12 @@ static struct usb_driver ipaq_driver = {
547 551
548 552
549/* All of the device info needed for the Compaq iPAQ */ 553/* All of the device info needed for the Compaq iPAQ */
550static struct usb_serial_device_type ipaq_device = { 554static struct usb_serial_driver ipaq_device = {
551 .owner = THIS_MODULE, 555 .driver = {
552 .name = "PocketPC PDA", 556 .owner = THIS_MODULE,
557 .name = "ipaq",
558 },
559 .description = "PocketPC PDA",
553 .id_table = ipaq_id_table, 560 .id_table = ipaq_id_table,
554 .num_interrupt_in = NUM_DONT_CARE, 561 .num_interrupt_in = NUM_DONT_CARE,
555 .num_bulk_in = 1, 562 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 85e242459c27..a02fada85362 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -443,10 +443,12 @@ static int ipw_disconnect(struct usb_serial_port *port)
443 return 0; 443 return 0;
444} 444}
445 445
446static struct usb_serial_device_type ipw_device = { 446static struct usb_serial_driver ipw_device = {
447 .owner = THIS_MODULE, 447 .driver = {
448 .name = "IPWireless converter", 448 .owner = THIS_MODULE,
449 .short_name = "ipw", 449 .name = "ipw",
450 },
451 .description = "IPWireless converter",
450 .id_table = usb_ipw_ids, 452 .id_table = usb_ipw_ids,
451 .num_interrupt_in = NUM_DONT_CARE, 453 .num_interrupt_in = NUM_DONT_CARE,
452 .num_bulk_in = 1, 454 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 937b2fdd7171..19f329e9bdcf 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -133,9 +133,12 @@ static struct usb_driver ir_driver = {
133}; 133};
134 134
135 135
136static struct usb_serial_device_type ir_device = { 136static struct usb_serial_driver ir_device = {
137 .owner = THIS_MODULE, 137 .driver = {
138 .name = "IR Dongle", 138 .owner = THIS_MODULE,
139 .name = "ir-usb",
140 },
141 .description = "IR Dongle",
139 .id_table = id_table, 142 .id_table = id_table,
140 .num_interrupt_in = 1, 143 .num_interrupt_in = 1,
141 .num_bulk_in = 1, 144 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index e9b45b768aca..5cfc13b5e56f 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -570,10 +570,12 @@ static struct usb_device_id keyspan_4port_ids[] = {
570}; 570};
571 571
572/* Structs for the devices, pre and post renumeration. */ 572/* Structs for the devices, pre and post renumeration. */
573static struct usb_serial_device_type keyspan_pre_device = { 573static struct usb_serial_driver keyspan_pre_device = {
574 .owner = THIS_MODULE, 574 .driver = {
575 .name = "Keyspan - (without firmware)", 575 .owner = THIS_MODULE,
576 .short_name = "keyspan_no_firm", 576 .name = "keyspan_no_firm",
577 },
578 .description = "Keyspan - (without firmware)",
577 .id_table = keyspan_pre_ids, 579 .id_table = keyspan_pre_ids,
578 .num_interrupt_in = NUM_DONT_CARE, 580 .num_interrupt_in = NUM_DONT_CARE,
579 .num_bulk_in = NUM_DONT_CARE, 581 .num_bulk_in = NUM_DONT_CARE,
@@ -582,10 +584,12 @@ static struct usb_serial_device_type keyspan_pre_device = {
582 .attach = keyspan_fake_startup, 584 .attach = keyspan_fake_startup,
583}; 585};
584 586
585static struct usb_serial_device_type keyspan_1port_device = { 587static struct usb_serial_driver keyspan_1port_device = {
586 .owner = THIS_MODULE, 588 .driver = {
587 .name = "Keyspan 1 port adapter", 589 .owner = THIS_MODULE,
588 .short_name = "keyspan_1", 590 .name = "keyspan_1",
591 },
592 .description = "Keyspan 1 port adapter",
589 .id_table = keyspan_1port_ids, 593 .id_table = keyspan_1port_ids,
590 .num_interrupt_in = NUM_DONT_CARE, 594 .num_interrupt_in = NUM_DONT_CARE,
591 .num_bulk_in = NUM_DONT_CARE, 595 .num_bulk_in = NUM_DONT_CARE,
@@ -607,10 +611,12 @@ static struct usb_serial_device_type keyspan_1port_device = {
607 .shutdown = keyspan_shutdown, 611 .shutdown = keyspan_shutdown,
608}; 612};
609 613
610static struct usb_serial_device_type keyspan_2port_device = { 614static struct usb_serial_driver keyspan_2port_device = {
611 .owner = THIS_MODULE, 615 .driver = {
612 .name = "Keyspan 2 port adapter", 616 .owner = THIS_MODULE,
613 .short_name = "keyspan_2", 617 .name = "keyspan_2",
618 },
619 .description = "Keyspan 2 port adapter",
614 .id_table = keyspan_2port_ids, 620 .id_table = keyspan_2port_ids,
615 .num_interrupt_in = NUM_DONT_CARE, 621 .num_interrupt_in = NUM_DONT_CARE,
616 .num_bulk_in = NUM_DONT_CARE, 622 .num_bulk_in = NUM_DONT_CARE,
@@ -632,10 +638,12 @@ static struct usb_serial_device_type keyspan_2port_device = {
632 .shutdown = keyspan_shutdown, 638 .shutdown = keyspan_shutdown,
633}; 639};
634 640
635static struct usb_serial_device_type keyspan_4port_device = { 641static struct usb_serial_driver keyspan_4port_device = {
636 .owner = THIS_MODULE, 642 .driver = {
637 .name = "Keyspan 4 port adapter", 643 .owner = THIS_MODULE,
638 .short_name = "keyspan_4", 644 .name = "keyspan_4",
645 },
646 .description = "Keyspan 4 port adapter",
639 .id_table = keyspan_4port_ids, 647 .id_table = keyspan_4port_ids,
640 .num_interrupt_in = NUM_DONT_CARE, 648 .num_interrupt_in = NUM_DONT_CARE,
641 .num_bulk_in = 5, 649 .num_bulk_in = 5,
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 635c384cb15a..cd4f48bd83b6 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -783,10 +783,12 @@ static void keyspan_pda_shutdown (struct usb_serial *serial)
783} 783}
784 784
785#ifdef KEYSPAN 785#ifdef KEYSPAN
786static struct usb_serial_device_type keyspan_pda_fake_device = { 786static struct usb_serial_driver keyspan_pda_fake_device = {
787 .owner = THIS_MODULE, 787 .driver = {
788 .name = "Keyspan PDA - (prerenumeration)", 788 .owner = THIS_MODULE,
789 .short_name = "keyspan_pda_pre", 789 .name = "keyspan_pda_pre",
790 },
791 .description = "Keyspan PDA - (prerenumeration)",
790 .id_table = id_table_fake, 792 .id_table = id_table_fake,
791 .num_interrupt_in = NUM_DONT_CARE, 793 .num_interrupt_in = NUM_DONT_CARE,
792 .num_bulk_in = NUM_DONT_CARE, 794 .num_bulk_in = NUM_DONT_CARE,
@@ -797,10 +799,12 @@ static struct usb_serial_device_type keyspan_pda_fake_device = {
797#endif 799#endif
798 800
799#ifdef XIRCOM 801#ifdef XIRCOM
800static struct usb_serial_device_type xircom_pgs_fake_device = { 802static struct usb_serial_driver xircom_pgs_fake_device = {
801 .owner = THIS_MODULE, 803 .driver = {
802 .name = "Xircom / Entregra PGS - (prerenumeration)", 804 .owner = THIS_MODULE,
803 .short_name = "xircom_no_firm", 805 .name = "xircom_no_firm",
806 },
807 .description = "Xircom / Entregra PGS - (prerenumeration)",
804 .id_table = id_table_fake_xircom, 808 .id_table = id_table_fake_xircom,
805 .num_interrupt_in = NUM_DONT_CARE, 809 .num_interrupt_in = NUM_DONT_CARE,
806 .num_bulk_in = NUM_DONT_CARE, 810 .num_bulk_in = NUM_DONT_CARE,
@@ -810,10 +814,12 @@ static struct usb_serial_device_type xircom_pgs_fake_device = {
810}; 814};
811#endif 815#endif
812 816
813static struct usb_serial_device_type keyspan_pda_device = { 817static struct usb_serial_driver keyspan_pda_device = {
814 .owner = THIS_MODULE, 818 .driver = {
815 .name = "Keyspan PDA", 819 .owner = THIS_MODULE,
816 .short_name = "keyspan_pda", 820 .name = "keyspan_pda",
821 },
822 .description = "Keyspan PDA",
817 .id_table = id_table_std, 823 .id_table = id_table_std,
818 .num_interrupt_in = 1, 824 .num_interrupt_in = 1,
819 .num_bulk_in = 0, 825 .num_bulk_in = 0,
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index a11e829e38c8..a8951c0fd020 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -123,10 +123,12 @@ static struct usb_driver kl5kusb105d_driver = {
123 .id_table = id_table, 123 .id_table = id_table,
124}; 124};
125 125
126static struct usb_serial_device_type kl5kusb105d_device = { 126static struct usb_serial_driver kl5kusb105d_device = {
127 .owner = THIS_MODULE, 127 .driver = {
128 .name = "KL5KUSB105D / PalmConnect", 128 .owner = THIS_MODULE,
129 .short_name = "kl5kusb105d", 129 .name = "kl5kusb105d",
130 },
131 .description = "KL5KUSB105D / PalmConnect",
130 .id_table = id_table, 132 .id_table = id_table,
131 .num_interrupt_in = 1, 133 .num_interrupt_in = 1,
132 .num_bulk_in = 1, 134 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index fe4c98a75171..9456dd9dd136 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -105,9 +105,12 @@ static struct usb_driver kobil_driver = {
105}; 105};
106 106
107 107
108static struct usb_serial_device_type kobil_device = { 108static struct usb_serial_driver kobil_device = {
109 .owner = THIS_MODULE, 109 .driver = {
110 .name = "KOBIL USB smart card terminal", 110 .owner = THIS_MODULE,
111 .name = "kobil",
112 },
113 .description = "KOBIL USB smart card terminal",
111 .id_table = id_table, 114 .id_table = id_table,
112 .num_interrupt_in = NUM_DONT_CARE, 115 .num_interrupt_in = NUM_DONT_CARE,
113 .num_bulk_in = 0, 116 .num_bulk_in = 0,
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 50b6369647d2..ca5dbadb9b7e 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -132,10 +132,12 @@ static struct usb_driver mct_u232_driver = {
132 .id_table = id_table_combined, 132 .id_table = id_table_combined,
133}; 133};
134 134
135static struct usb_serial_device_type mct_u232_device = { 135static struct usb_serial_driver mct_u232_device = {
136 .owner = THIS_MODULE, 136 .driver = {
137 .name = "MCT U232", 137 .owner = THIS_MODULE,
138 .short_name = "mct_u232", 138 .name = "mct_u232",
139 },
140 .description = "MCT U232",
139 .id_table = id_table_combined, 141 .id_table = id_table_combined,
140 .num_interrupt_in = 2, 142 .num_interrupt_in = 2,
141 .num_bulk_in = 0, 143 .num_bulk_in = 0,
diff --git a/drivers/usb/serial/nokia_dku2.c b/drivers/usb/serial/nokia_dku2.c
new file mode 100644
index 000000000000..fad01bef3a64
--- /dev/null
+++ b/drivers/usb/serial/nokia_dku2.c
@@ -0,0 +1,142 @@
1/*
2 * Nokia DKU2 USB driver
3 *
4 * Copyright (C) 2004
5 * Author: C Kemp
6 *
7 * This program is largely derived from work by the linux-usb group
8 * and associated source files. Please see the usb/serial files for
9 * individual credits and copyrights.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * 20.09.2005 - Matthias Blaesing <matthias.blaesing@rwth-aachen.de>
17 * Added short name to device structure to make driver load into kernel 2.6.13
18 *
19 * 20.09.2005 - Matthias Blaesing <matthias.blaesing@rwth-aachen.de>
20 * Added usb_deregister to exit code - to allow remove and reinsert of module
21 */
22
23
24#include <linux/config.h>
25#include <linux/kernel.h>
26#include <linux/errno.h>
27#include <linux/init.h>
28#include <linux/slab.h>
29#include <linux/tty.h>
30#include <linux/tty_driver.h>
31#include <linux/tty_flip.h>
32#include <linux/module.h>
33#include <linux/usb.h>
34#include "usb-serial.h"
35
36
37#define NOKIA_VENDOR_ID 0x0421
38#define NOKIA7600_PRODUCT_ID 0x0400
39#define NOKIA6230_PRODUCT_ID 0x040f
40#define NOKIA6170_PRODUCT_ID 0x0416
41#define NOKIA6670_PRODUCT_ID 0x041d
42#define NOKIA6680_PRODUCT_ID 0x041e
43#define NOKIA6230i_PRODUCT_ID 0x0428
44
45#define NOKIA_AT_PORT 0x82
46#define NOKIA_FBUS_PORT 0x86
47
48/*
49 * Version Information
50 */
51#define DRIVER_VERSION "v0.2"
52#define DRIVER_AUTHOR "C Kemp"
53#define DRIVER_DESC "Nokia DKU2 Driver"
54
55static struct usb_device_id id_table [] = {
56 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA7600_PRODUCT_ID) },
57 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6230_PRODUCT_ID) },
58 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6170_PRODUCT_ID) },
59 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6670_PRODUCT_ID) },
60 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6680_PRODUCT_ID) },
61 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6230i_PRODUCT_ID) },
62 { } /* Terminating entry */
63};
64MODULE_DEVICE_TABLE(usb, id_table);
65
66/* The only thing which makes this device different from a generic
67 * device is that we have to set an alternative configuration to make
68 * the relevant endpoints available. In 2.6 this is really easy... */
69static int nokia_probe(struct usb_serial *serial,
70 const struct usb_device_id *id)
71{
72 int retval = -ENODEV;
73
74 if (serial->interface->altsetting[0].endpoint[0].desc.bEndpointAddress == NOKIA_AT_PORT) {
75 /* the AT port */
76 dev_info(&serial->dev->dev, "Nokia AT Port:\n");
77 retval = 0;
78 } else if (serial->interface->num_altsetting == 2 &&
79 serial->interface->altsetting[1].endpoint[0].desc.bEndpointAddress == NOKIA_FBUS_PORT) {
80 /* the FBUS port */
81 dev_info(&serial->dev->dev, "Nokia FBUS Port:\n");
82 usb_set_interface(serial->dev, 10, 1);
83 retval = 0;
84 }
85
86 return retval;
87}
88
89static struct usb_driver nokia_driver = {
90 .owner = THIS_MODULE,
91 .name = "nokia_dku2",
92 .probe = usb_serial_probe,
93 .disconnect = usb_serial_disconnect,
94 .id_table = id_table,
95};
96
97static struct usb_serial_driver nokia_serial_driver = {
98 .driver = {
99 .owner = THIS_MODULE,
100 .name = "nokia_dku2",
101 },
102 .description = "Nokia 7600/6230(i)/6170/66x0 DKU2 driver",
103 .id_table = id_table,
104 .num_interrupt_in = 1,
105 .num_bulk_in = 1,
106 .num_bulk_out = 1,
107 .num_ports = 1,
108 .probe = nokia_probe,
109};
110
111static int __init nokia_init(void)
112{
113 int retval;
114
115 retval = usb_serial_register(&nokia_serial_driver);
116 if (retval)
117 return retval;
118
119 retval = usb_register(&nokia_driver);
120 if (retval) {
121 usb_serial_deregister(&nokia_serial_driver);
122 return retval;
123 }
124
125 info(DRIVER_VERSION " " DRIVER_AUTHOR);
126 info(DRIVER_DESC);
127
128 return retval;
129}
130
131static void __exit nokia_exit(void)
132{
133 usb_deregister(&nokia_driver);
134 usb_serial_deregister(&nokia_serial_driver);
135}
136
137module_init(nokia_init);
138module_exit(nokia_exit);
139
140MODULE_AUTHOR(DRIVER_AUTHOR);
141MODULE_DESCRIPTION(DRIVER_DESC);
142MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 6a99ae192df1..3caf97072ac0 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -88,10 +88,12 @@ static struct usb_driver omninet_driver = {
88}; 88};
89 89
90 90
91static struct usb_serial_device_type zyxel_omninet_device = { 91static struct usb_serial_driver zyxel_omninet_device = {
92 .owner = THIS_MODULE, 92 .driver = {
93 .name = "ZyXEL - omni.net lcd plus usb", 93 .owner = THIS_MODULE,
94 .short_name = "omninet", 94 .name = "omninet",
95 },
96 .description = "ZyXEL - omni.net lcd plus usb",
95 .id_table = id_table, 97 .id_table = id_table,
96 .num_interrupt_in = 1, 98 .num_interrupt_in = 1,
97 .num_bulk_in = 1, 99 .num_bulk_in = 1,
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 4989e5740d18..7716000045b7 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -105,10 +105,12 @@ static struct usb_driver option_driver = {
105/* The card has three separate interfaces, wich the serial driver 105/* The card has three separate interfaces, wich the serial driver
106 * recognizes separately, thus num_port=1. 106 * recognizes separately, thus num_port=1.
107 */ 107 */
108static struct usb_serial_device_type option_3port_device = { 108static struct usb_serial_driver option_3port_device = {
109 .owner = THIS_MODULE, 109 .driver = {
110 .name = "Option 3G data card", 110 .owner = THIS_MODULE,
111 .short_name = "option", 111 .name = "option",
112 },
113 .description = "Option 3G data card",
112 .id_table = option_ids, 114 .id_table = option_ids,
113 .num_interrupt_in = NUM_DONT_CARE, 115 .num_interrupt_in = NUM_DONT_CARE,
114 .num_bulk_in = NUM_DONT_CARE, 116 .num_bulk_in = NUM_DONT_CARE,
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 3cf245bdda54..165c119bf10e 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -8,31 +8,10 @@
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License.
12 * (at your option) any later version.
13 * 12 *
14 * See Documentation/usb/usb-serial.txt for more information on using this driver 13 * See Documentation/usb/usb-serial.txt for more information on using this driver
15 * 14 *
16 * 2002_Mar_26 gkh
17 * allowed driver to work properly if there is no tty assigned to a port
18 * (this happens for serial console devices.)
19 *
20 * 2001_Oct_06 gkh
21 * Added RTS and DTR line control. Thanks to joe@bndlg.de for parts of it.
22 *
23 * 2001_Sep_19 gkh
24 * Added break support.
25 *
26 * 2001_Aug_30 gkh
27 * fixed oops in write_bulk_callback.
28 *
29 * 2001_Aug_28 gkh
30 * reworked buffer logic to be like other usb-serial drivers. Hopefully
31 * removing some reported problems.
32 *
33 * 2001_Jun_06 gkh
34 * finished porting to 2.4 format.
35 *
36 */ 15 */
37 16
38#include <linux/config.h> 17#include <linux/config.h>
@@ -55,7 +34,6 @@
55/* 34/*
56 * Version Information 35 * Version Information
57 */ 36 */
58#define DRIVER_VERSION "v0.12"
59#define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" 37#define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver"
60 38
61static int debug; 39static int debug;
@@ -175,9 +153,11 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
175 153
176 154
177/* All of the device info needed for the PL2303 SIO serial converter */ 155/* All of the device info needed for the PL2303 SIO serial converter */
178static struct usb_serial_device_type pl2303_device = { 156static struct usb_serial_driver pl2303_device = {
179 .owner = THIS_MODULE, 157 .driver = {
180 .name = "PL-2303", 158 .owner = THIS_MODULE,
159 .name = "pl2303",
160 },
181 .id_table = id_table, 161 .id_table = id_table,
182 .num_interrupt_in = NUM_DONT_CARE, 162 .num_interrupt_in = NUM_DONT_CARE,
183 .num_bulk_in = 1, 163 .num_bulk_in = 1,
@@ -1195,7 +1175,7 @@ static int __init pl2303_init (void)
1195 retval = usb_register(&pl2303_driver); 1175 retval = usb_register(&pl2303_driver);
1196 if (retval) 1176 if (retval)
1197 goto failed_usb_register; 1177 goto failed_usb_register;
1198 info(DRIVER_DESC " " DRIVER_VERSION); 1178 info(DRIVER_DESC);
1199 return 0; 1179 return 0;
1200failed_usb_register: 1180failed_usb_register:
1201 usb_serial_deregister(&pl2303_device); 1181 usb_serial_deregister(&pl2303_device);
@@ -1215,7 +1195,6 @@ module_init(pl2303_init);
1215module_exit(pl2303_exit); 1195module_exit(pl2303_exit);
1216 1196
1217MODULE_DESCRIPTION(DRIVER_DESC); 1197MODULE_DESCRIPTION(DRIVER_DESC);
1218MODULE_VERSION(DRIVER_VERSION);
1219MODULE_LICENSE("GPL"); 1198MODULE_LICENSE("GPL");
1220 1199
1221module_param(debug, bool, S_IRUGO | S_IWUSR); 1200module_param(debug, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 96a17568cbf1..c22bdc0c4dfd 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -92,7 +92,7 @@ MODULE_DESCRIPTION (DRIVER_DESC);
92MODULE_LICENSE("GPL"); 92MODULE_LICENSE("GPL");
93 93
94#if defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) && !defined(CONFIG_USBD_SAFE_SERIAL_PRODUCT) 94#if defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) && !defined(CONFIG_USBD_SAFE_SERIAL_PRODUCT)
95#abort "SAFE_SERIAL_VENDOR defined without SAFE_SERIAL_PRODUCT" 95#error "SAFE_SERIAL_VENDOR defined without SAFE_SERIAL_PRODUCT"
96#endif 96#endif
97 97
98#if ! defined(CONFIG_USBD_SAFE_SERIAL_VENDOR) 98#if ! defined(CONFIG_USBD_SAFE_SERIAL_VENDOR)
@@ -397,9 +397,11 @@ static int safe_startup (struct usb_serial *serial)
397 return 0; 397 return 0;
398} 398}
399 399
400static struct usb_serial_device_type safe_device = { 400static struct usb_serial_driver safe_device = {
401 .owner = THIS_MODULE, 401 .driver = {
402 .name = "Safe", 402 .owner = THIS_MODULE,
403 .name = "safe_serial",
404 },
403 .id_table = id_table, 405 .id_table = id_table,
404 .num_interrupt_in = NUM_DONT_CARE, 406 .num_interrupt_in = NUM_DONT_CARE,
405 .num_bulk_in = NUM_DONT_CARE, 407 .num_bulk_in = NUM_DONT_CARE,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 59c88de3e7ae..205dbf7201da 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -255,9 +255,12 @@ static struct usb_driver ti_usb_driver = {
255 .id_table = ti_id_table_combined, 255 .id_table = ti_id_table_combined,
256}; 256};
257 257
258static struct usb_serial_device_type ti_1port_device = { 258static struct usb_serial_driver ti_1port_device = {
259 .owner = THIS_MODULE, 259 .driver = {
260 .name = "TI USB 3410 1 port adapter", 260 .owner = THIS_MODULE,
261 .name = "ti_usb_3410_5052_1",
262 },
263 .description = "TI USB 3410 1 port adapter",
261 .id_table = ti_id_table_3410, 264 .id_table = ti_id_table_3410,
262 .num_interrupt_in = 1, 265 .num_interrupt_in = 1,
263 .num_bulk_in = 1, 266 .num_bulk_in = 1,
@@ -282,9 +285,12 @@ static struct usb_serial_device_type ti_1port_device = {
282 .write_bulk_callback = ti_bulk_out_callback, 285 .write_bulk_callback = ti_bulk_out_callback,
283}; 286};
284 287
285static struct usb_serial_device_type ti_2port_device = { 288static struct usb_serial_driver ti_2port_device = {
286 .owner = THIS_MODULE, 289 .driver = {
287 .name = "TI USB 5052 2 port adapter", 290 .owner = THIS_MODULE,
291 .name = "ti_usb_3410_5052_2",
292 },
293 .description = "TI USB 5052 2 port adapter",
288 .id_table = ti_id_table_5052, 294 .id_table = ti_id_table_5052,
289 .num_interrupt_in = 1, 295 .num_interrupt_in = 1,
290 .num_bulk_in = 2, 296 .num_bulk_in = 2,
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index e77fbdfc782d..0c4881d18cd5 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * USB Serial Converter driver 2 * USB Serial Converter driver
3 * 3 *
4 * Copyright (C) 1999 - 2004 Greg Kroah-Hartman (greg@kroah.com) 4 * Copyright (C) 1999 - 2005 Greg Kroah-Hartman (greg@kroah.com)
5 * Copyright (C) 2000 Peter Berger (pberger@brimson.com) 5 * Copyright (C) 2000 Peter Berger (pberger@brimson.com)
6 * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com) 6 * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com)
7 * 7 *
@@ -9,316 +9,11 @@
9 * modify it under the terms of the GNU General Public License version 9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation. 10 * 2 as published by the Free Software Foundation.
11 * 11 *
12 * This driver was originally based on the ACM driver by Armin Fuerst (which was 12 * This driver was originally based on the ACM driver by Armin Fuerst (which was
13 * based on a driver by Brad Keryan) 13 * based on a driver by Brad Keryan)
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this driver
16 * 16 *
17 * (12/10/2002) gkh
18 * Split the ports off into their own struct device, and added a
19 * usb-serial bus driver.
20 *
21 * (11/19/2002) gkh
22 * removed a few #ifdefs for the generic code and cleaned up the failure
23 * logic in initialization.
24 *
25 * (10/02/2002) gkh
26 * moved the console code to console.c and out of this file.
27 *
28 * (06/05/2002) gkh
29 * moved location of startup() call in serial_probe() until after all
30 * of the port information and endpoints are initialized. This makes
31 * things easier for some drivers.
32 *
33 * (04/10/2002) gkh
34 * added serial_read_proc function which creates a
35 * /proc/tty/driver/usb-serial file.
36 *
37 * (03/27/2002) gkh
38 * Got USB serial console code working properly and merged into the main
39 * version of the tree. Thanks to Randy Dunlap for the initial version
40 * of this code, and for pushing me to finish it up.
41 * The USB serial console works with any usb serial driver device.
42 *
43 * (03/21/2002) gkh
44 * Moved all manipulation of port->open_count into the core. Now the
45 * individual driver's open and close functions are called only when the
46 * first open() and last close() is called. Making the drivers a bit
47 * smaller and simpler.
48 * Fixed a bug if a driver didn't have the owner field set.
49 *
50 * (02/26/2002) gkh
51 * Moved all locking into the main serial_* functions, instead of having
52 * the individual drivers have to grab the port semaphore. This should
53 * reduce races.
54 * Reworked the MOD_INC logic a bit to always increment and decrement, even
55 * if the generic driver is being used.
56 *
57 * (10/10/2001) gkh
58 * usb_serial_disconnect() now sets the serial->dev pointer is to NULL to
59 * help prevent child drivers from accessing the device since it is now
60 * gone.
61 *
62 * (09/13/2001) gkh
63 * Moved generic driver initialize after we have registered with the USB
64 * core. Thanks to Randy Dunlap for pointing this problem out.
65 *
66 * (07/03/2001) gkh
67 * Fixed module paramater size. Thanks to John Brockmeyer for the pointer.
68 * Fixed vendor and product getting defined through the MODULE_PARM macro
69 * if the Generic driver wasn't compiled in.
70 * Fixed problem with generic_shutdown() not being called for drivers that
71 * don't have a shutdown() function.
72 *
73 * (06/06/2001) gkh
74 * added evil hack that is needed for the prolific pl2303 device due to the
75 * crazy way its endpoints are set up.
76 *
77 * (05/30/2001) gkh
78 * switched from using spinlock to a semaphore, which fixes lots of problems.
79 *
80 * (04/08/2001) gb
81 * Identify version on module load.
82 *
83 * 2001_02_05 gkh
84 * Fixed buffer overflows bug with the generic serial driver. Thanks to
85 * Todd Squires <squirest@ct0.com> for fixing this.
86 *
87 * (01/10/2001) gkh
88 * Fixed bug where the generic serial adaptor grabbed _any_ device that was
89 * offered to it.
90 *
91 * (12/12/2000) gkh
92 * Removed MOD_INC and MOD_DEC from poll and disconnect functions, and
93 * moved them to the serial_open and serial_close functions.
94 * Also fixed bug with there not being a MOD_DEC for the generic driver
95 * (thanks to Gary Brubaker for finding this.)
96 *
97 * (11/29/2000) gkh
98 * Small NULL pointer initialization cleanup which saves a bit of disk image
99 *
100 * (11/01/2000) Adam J. Richter
101 * instead of using idVendor/idProduct pairs, usb serial drivers
102 * now identify their hardware interest with usb_device_id tables,
103 * which they usually have anyhow for use with MODULE_DEVICE_TABLE.
104 *
105 * (10/05/2000) gkh
106 * Fixed bug with urb->dev not being set properly, now that the usb
107 * core needs it.
108 *
109 * (09/11/2000) gkh
110 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
111 *
112 * (08/28/2000) gkh
113 * Added port_lock to port structure.
114 * Added locks for SMP safeness to generic driver
115 * Fixed the ability to open a generic device's port more than once.
116 *
117 * (07/23/2000) gkh
118 * Added bulk_out_endpointAddress to port structure.
119 *
120 * (07/19/2000) gkh, pberger, and borchers
121 * Modifications to allow usb-serial drivers to be modules.
122 *
123 * (07/03/2000) gkh
124 * Added more debugging to serial_ioctl call
125 *
126 * (06/25/2000) gkh
127 * Changed generic_write_bulk_callback to not call wake_up_interruptible
128 * directly, but to have port_softint do it at a safer time.
129 *
130 * (06/23/2000) gkh
131 * Cleaned up debugging statements in a quest to find UHCI timeout bug.
132 *
133 * (05/22/2000) gkh
134 * Changed the makefile, enabling the big CONFIG_USB_SERIAL_SOMTHING to be
135 * removed from the individual device source files.
136 *
137 * (05/03/2000) gkh
138 * Added the Digi Acceleport driver from Al Borchers and Peter Berger.
139 *
140 * (05/02/2000) gkh
141 * Changed devfs and tty register code to work properly now. This was based on
142 * the ACM driver changes by Vojtech Pavlik.
143 *
144 * (04/27/2000) Ryan VanderBijl
145 * Put calls to *_paranoia_checks into one function.
146 *
147 * (04/23/2000) gkh
148 * Fixed bug that Randy Dunlap found for Generic devices with no bulk out ports.
149 * Moved when the startup code printed out the devices that are supported.
150 *
151 * (04/19/2000) gkh
152 * Added driver for ZyXEL omni.net lcd plus ISDN TA
153 * Made startup info message specify which drivers were compiled in.
154 *
155 * (04/03/2000) gkh
156 * Changed the probe process to remove the module unload races.
157 * Changed where the tty layer gets initialized to have devfs work nicer.
158 * Added initial devfs support.
159 *
160 * (03/26/2000) gkh
161 * Split driver up into device specific pieces.
162 *
163 * (03/19/2000) gkh
164 * Fixed oops that could happen when device was removed while a program
165 * was talking to the device.
166 * Removed the static urbs and now all urbs are created and destroyed
167 * dynamically.
168 * Reworked the internal interface. Now everything is based on the
169 * usb_serial_port structure instead of the larger usb_serial structure.
170 * This fixes the bug that a multiport device could not have more than
171 * one port open at one time.
172 *
173 * (03/17/2000) gkh
174 * Added config option for debugging messages.
175 * Added patch for keyspan pda from Brian Warner.
176 *
177 * (03/06/2000) gkh
178 * Added the keyspan pda code from Brian Warner <warner@lothar.com>
179 * Moved a bunch of the port specific stuff into its own structure. This
180 * is in anticipation of the true multiport devices (there's a bug if you
181 * try to access more than one port of any multiport device right now)
182 *
183 * (02/21/2000) gkh
184 * Made it so that any serial devices only have to specify which functions
185 * they want to overload from the generic function calls (great,
186 * inheritance in C, in a driver, just what I wanted...)
187 * Added support for set_termios and ioctl function calls. No drivers take
188 * advantage of this yet.
189 * Removed the #ifdef MODULE, now there is no module specific code.
190 * Cleaned up a few comments in usb-serial.h that were wrong (thanks again
191 * to Miles Lott).
192 * Small fix to get_free_serial.
193 *
194 * (02/14/2000) gkh
195 * Removed the Belkin and Peracom functionality from the driver due to
196 * the lack of support from the vendor, and me not wanting people to
197 * accidenatly buy the device, expecting it to work with Linux.
198 * Added read_bulk_callback and write_bulk_callback to the type structure
199 * for the needs of the FTDI and WhiteHEAT driver.
200 * Changed all reverences to FTDI to FTDI_SIO at the request of Bill
201 * Ryder.
202 * Changed the output urb size back to the max endpoint size to make
203 * the ftdi_sio driver have it easier, and due to the fact that it didn't
204 * really increase the speed any.
205 *
206 * (02/11/2000) gkh
207 * Added VISOR_FUNCTION_CONSOLE to the visor startup function. This was a
208 * patch from Miles Lott (milos@insync.net).
209 * Fixed bug with not restoring the minor range that a device grabs, if
210 * the startup function fails (thanks Miles for finding this).
211 *
212 * (02/05/2000) gkh
213 * Added initial framework for the Keyspan PDA serial converter so that
214 * Brian Warner has a place to put his code.
215 * Made the ezusb specific functions generic enough that different
216 * devices can use them (whiteheat and keyspan_pda both need them).
217 * Split out a whole bunch of structure and other stuff to a separate
218 * usb-serial.h file.
219 * Made the Visor connection messages a little more understandable, now
220 * that Miles Lott (milos@insync.net) has gotten the Generic channel to
221 * work. Also made them always show up in the log file.
222 *
223 * (01/25/2000) gkh
224 * Added initial framework for FTDI serial converter so that Bill Ryder
225 * has a place to put his code.
226 * Added the vendor specific info from Handspring. Now we can print out
227 * informational debug messages as well as understand what is happening.
228 *
229 * (01/23/2000) gkh
230 * Fixed problem of crash when trying to open a port that didn't have a
231 * device assigned to it. Made the minor node finding a little smarter,
232 * now it looks to find a continuous space for the new device.
233 *
234 * (01/21/2000) gkh
235 * Fixed bug in visor_startup with patch from Miles Lott (milos@insync.net)
236 * Fixed get_serial_by_minor which was all messed up for multi port
237 * devices. Fixed multi port problem for generic devices. Now the number
238 * of ports is determined by the number of bulk out endpoints for the
239 * generic device.
240 *
241 * (01/19/2000) gkh
242 * Removed lots of cruft that was around from the old (pre urb) driver
243 * interface.
244 * Made the serial_table dynamic. This should save lots of memory when
245 * the number of minor nodes goes up to 256.
246 * Added initial support for devices that have more than one port.
247 * Added more debugging comments for the Visor, and added a needed
248 * set_configuration call.
249 *
250 * (01/17/2000) gkh
251 * Fixed the WhiteHEAT firmware (my processing tool had a bug)
252 * and added new debug loader firmware for it.
253 * Removed the put_char function as it isn't really needed.
254 * Added visor startup commands as found by the Win98 dump.
255 *
256 * (01/13/2000) gkh
257 * Fixed the vendor id for the generic driver to the one I meant it to be.
258 *
259 * (01/12/2000) gkh
260 * Forget the version numbering...that's pretty useless...
261 * Made the driver able to be compiled so that the user can select which
262 * converter they want to use. This allows people who only want the Visor
263 * support to not pay the memory size price of the WhiteHEAT.
264 * Fixed bug where the generic driver (idVendor=0000 and idProduct=0000)
265 * grabbed the root hub. Not good.
266 *
267 * version 0.4.0 (01/10/2000) gkh
268 * Added whiteheat.h containing the firmware for the ConnectTech WhiteHEAT
269 * device. Added startup function to allow firmware to be downloaded to
270 * a device if it needs to be.
271 * Added firmware download logic to the WhiteHEAT device.
272 * Started to add #defines to split up the different drivers for potential
273 * configuration option.
274 *
275 * version 0.3.1 (12/30/99) gkh
276 * Fixed problems with urb for bulk out.
277 * Added initial support for multiple sets of endpoints. This enables
278 * the Handspring Visor to be attached successfully. Only the first
279 * bulk in / bulk out endpoint pair is being used right now.
280 *
281 * version 0.3.0 (12/27/99) gkh
282 * Added initial support for the Handspring Visor based on a patch from
283 * Miles Lott (milos@sneety.insync.net)
284 * Cleaned up the code a bunch and converted over to using urbs only.
285 *
286 * version 0.2.3 (12/21/99) gkh
287 * Added initial support for the Connect Tech WhiteHEAT converter.
288 * Incremented the number of ports in expectation of getting the
289 * WhiteHEAT to work properly (4 ports per connection).
290 * Added notification on insertion and removal of what port the
291 * device is/was connected to (and what kind of device it was).
292 *
293 * version 0.2.2 (12/16/99) gkh
294 * Changed major number to the new allocated number. We're legal now!
295 *
296 * version 0.2.1 (12/14/99) gkh
297 * Fixed bug that happens when device node is opened when there isn't a
298 * device attached to it. Thanks to marek@webdesign.no for noticing this.
299 *
300 * version 0.2.0 (11/10/99) gkh
301 * Split up internals to make it easier to add different types of serial
302 * converters to the code.
303 * Added a "generic" driver that gets it's vendor and product id
304 * from when the module is loaded. Thanks to David E. Nelson (dnelson@jump.net)
305 * for the idea and sample code (from the usb scanner driver.)
306 * Cleared up any licensing questions by releasing it under the GNU GPL.
307 *
308 * version 0.1.2 (10/25/99) gkh
309 * Fixed bug in detecting device.
310 *
311 * version 0.1.1 (10/05/99) gkh
312 * Changed the major number to not conflict with anything else.
313 *
314 * version 0.1 (09/28/99) gkh
315 * Can recognize the two different devices and start up a read from
316 * device when asked to. Writes also work. No control signals yet, this
317 * all is vendor specific data (i.e. no spec), also no control for
318 * different baud rates or other bit settings.
319 * Currently we are using the same devid as the acm driver. This needs
320 * to change.
321 *
322 */ 17 */
323 18
324#include <linux/config.h> 19#include <linux/config.h>
@@ -342,7 +37,6 @@
342/* 37/*
343 * Version Information 38 * Version Information
344 */ 39 */
345#define DRIVER_VERSION "v2.0"
346#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/" 40#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
347#define DRIVER_DESC "USB Serial Driver core" 41#define DRIVER_DESC "USB Serial Driver core"
348 42
@@ -427,7 +121,7 @@ static void destroy_serial(struct kref *kref)
427 121
428 serial = to_usb_serial(kref); 122 serial = to_usb_serial(kref);
429 123
430 dbg ("%s - %s", __FUNCTION__, serial->type->name); 124 dbg("%s - %s", __FUNCTION__, serial->type->description);
431 125
432 serial->type->shutdown(serial); 126 serial->type->shutdown(serial);
433 127
@@ -507,7 +201,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
507 /* lock this module before we call it 201 /* lock this module before we call it
508 * this may fail, which means we must bail out, 202 * this may fail, which means we must bail out,
509 * safe because we are called with BKL held */ 203 * safe because we are called with BKL held */
510 if (!try_module_get(serial->type->owner)) { 204 if (!try_module_get(serial->type->driver.owner)) {
511 retval = -ENODEV; 205 retval = -ENODEV;
512 goto bailout_kref_put; 206 goto bailout_kref_put;
513 } 207 }
@@ -522,7 +216,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
522 return 0; 216 return 0;
523 217
524bailout_module_put: 218bailout_module_put:
525 module_put(serial->type->owner); 219 module_put(serial->type->driver.owner);
526bailout_kref_put: 220bailout_kref_put:
527 kref_put(&serial->kref, destroy_serial); 221 kref_put(&serial->kref, destroy_serial);
528 port->open_count = 0; 222 port->open_count = 0;
@@ -553,7 +247,7 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
553 port->tty = NULL; 247 port->tty = NULL;
554 } 248 }
555 249
556 module_put(port->serial->type->owner); 250 module_put(port->serial->type->driver.owner);
557 } 251 }
558 252
559 kref_put(&port->serial->kref, destroy_serial); 253 kref_put(&port->serial->kref, destroy_serial);
@@ -711,16 +405,16 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
711 char tmp[40]; 405 char tmp[40];
712 406
713 dbg("%s", __FUNCTION__); 407 dbg("%s", __FUNCTION__);
714 length += sprintf (page, "usbserinfo:1.0 driver:%s\n", DRIVER_VERSION); 408 length += sprintf (page, "usbserinfo:1.0 driver:2.0\n");
715 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { 409 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
716 serial = usb_serial_get_by_index(i); 410 serial = usb_serial_get_by_index(i);
717 if (serial == NULL) 411 if (serial == NULL)
718 continue; 412 continue;
719 413
720 length += sprintf (page+length, "%d:", i); 414 length += sprintf (page+length, "%d:", i);
721 if (serial->type->owner) 415 if (serial->type->driver.owner)
722 length += sprintf (page+length, " module:%s", module_name(serial->type->owner)); 416 length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner));
723 length += sprintf (page+length, " name:\"%s\"", serial->type->name); 417 length += sprintf (page+length, " name:\"%s\"", serial->type->description);
724 length += sprintf (page+length, " vendor:%04x product:%04x", 418 length += sprintf (page+length, " vendor:%04x product:%04x",
725 le16_to_cpu(serial->dev->descriptor.idVendor), 419 le16_to_cpu(serial->dev->descriptor.idVendor),
726 le16_to_cpu(serial->dev->descriptor.idProduct)); 420 le16_to_cpu(serial->dev->descriptor.idProduct));
@@ -823,7 +517,7 @@ static void port_release(struct device *dev)
823 517
824static struct usb_serial * create_serial (struct usb_device *dev, 518static struct usb_serial * create_serial (struct usb_device *dev,
825 struct usb_interface *interface, 519 struct usb_interface *interface,
826 struct usb_serial_device_type *type) 520 struct usb_serial_driver *driver)
827{ 521{
828 struct usb_serial *serial; 522 struct usb_serial *serial;
829 523
@@ -834,22 +528,22 @@ static struct usb_serial * create_serial (struct usb_device *dev,
834 } 528 }
835 memset (serial, 0, sizeof(*serial)); 529 memset (serial, 0, sizeof(*serial));
836 serial->dev = usb_get_dev(dev); 530 serial->dev = usb_get_dev(dev);
837 serial->type = type; 531 serial->type = driver;
838 serial->interface = interface; 532 serial->interface = interface;
839 kref_init(&serial->kref); 533 kref_init(&serial->kref);
840 534
841 return serial; 535 return serial;
842} 536}
843 537
844static struct usb_serial_device_type *search_serial_device(struct usb_interface *iface) 538static struct usb_serial_driver *search_serial_device(struct usb_interface *iface)
845{ 539{
846 struct list_head *p; 540 struct list_head *p;
847 const struct usb_device_id *id; 541 const struct usb_device_id *id;
848 struct usb_serial_device_type *t; 542 struct usb_serial_driver *t;
849 543
850 /* List trough know devices and see if the usb id matches */ 544 /* List trough know devices and see if the usb id matches */
851 list_for_each(p, &usb_serial_driver_list) { 545 list_for_each(p, &usb_serial_driver_list) {
852 t = list_entry(p, struct usb_serial_device_type, driver_list); 546 t = list_entry(p, struct usb_serial_driver, driver_list);
853 id = usb_match_id(iface, t->id_table); 547 id = usb_match_id(iface, t->id_table);
854 if (id != NULL) { 548 if (id != NULL) {
855 dbg("descriptor matches"); 549 dbg("descriptor matches");
@@ -872,7 +566,7 @@ int usb_serial_probe(struct usb_interface *interface,
872 struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS]; 566 struct usb_endpoint_descriptor *interrupt_out_endpoint[MAX_NUM_PORTS];
873 struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS]; 567 struct usb_endpoint_descriptor *bulk_in_endpoint[MAX_NUM_PORTS];
874 struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; 568 struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
875 struct usb_serial_device_type *type = NULL; 569 struct usb_serial_driver *type = NULL;
876 int retval; 570 int retval;
877 int minor; 571 int minor;
878 int buffer_size; 572 int buffer_size;
@@ -900,7 +594,7 @@ int usb_serial_probe(struct usb_interface *interface,
900 if (type->probe) { 594 if (type->probe) {
901 const struct usb_device_id *id; 595 const struct usb_device_id *id;
902 596
903 if (!try_module_get(type->owner)) { 597 if (!try_module_get(type->driver.owner)) {
904 dev_err(&interface->dev, "module get failed, exiting\n"); 598 dev_err(&interface->dev, "module get failed, exiting\n");
905 kfree (serial); 599 kfree (serial);
906 return -EIO; 600 return -EIO;
@@ -908,7 +602,7 @@ int usb_serial_probe(struct usb_interface *interface,
908 602
909 id = usb_match_id(interface, type->id_table); 603 id = usb_match_id(interface, type->id_table);
910 retval = type->probe(serial, id); 604 retval = type->probe(serial, id);
911 module_put(type->owner); 605 module_put(type->driver.owner);
912 606
913 if (retval) { 607 if (retval) {
914 dbg ("sub driver rejected device"); 608 dbg ("sub driver rejected device");
@@ -992,7 +686,7 @@ int usb_serial_probe(struct usb_interface *interface,
992#endif 686#endif
993 687
994 /* found all that we need */ 688 /* found all that we need */
995 dev_info(&interface->dev, "%s converter detected\n", type->name); 689 dev_info(&interface->dev, "%s converter detected\n", type->description);
996 690
997#ifdef CONFIG_USB_SERIAL_GENERIC 691#ifdef CONFIG_USB_SERIAL_GENERIC
998 if (type == &usb_serial_generic_device) { 692 if (type == &usb_serial_generic_device) {
@@ -1007,13 +701,13 @@ int usb_serial_probe(struct usb_interface *interface,
1007 if (!num_ports) { 701 if (!num_ports) {
1008 /* if this device type has a calc_num_ports function, call it */ 702 /* if this device type has a calc_num_ports function, call it */
1009 if (type->calc_num_ports) { 703 if (type->calc_num_ports) {
1010 if (!try_module_get(type->owner)) { 704 if (!try_module_get(type->driver.owner)) {
1011 dev_err(&interface->dev, "module get failed, exiting\n"); 705 dev_err(&interface->dev, "module get failed, exiting\n");
1012 kfree (serial); 706 kfree (serial);
1013 return -EIO; 707 return -EIO;
1014 } 708 }
1015 num_ports = type->calc_num_ports (serial); 709 num_ports = type->calc_num_ports (serial);
1016 module_put(type->owner); 710 module_put(type->driver.owner);
1017 } 711 }
1018 if (!num_ports) 712 if (!num_ports)
1019 num_ports = type->num_ports; 713 num_ports = type->num_ports;
@@ -1158,12 +852,12 @@ int usb_serial_probe(struct usb_interface *interface,
1158 852
1159 /* if this device type has an attach function, call it */ 853 /* if this device type has an attach function, call it */
1160 if (type->attach) { 854 if (type->attach) {
1161 if (!try_module_get(type->owner)) { 855 if (!try_module_get(type->driver.owner)) {
1162 dev_err(&interface->dev, "module get failed, exiting\n"); 856 dev_err(&interface->dev, "module get failed, exiting\n");
1163 goto probe_error; 857 goto probe_error;
1164 } 858 }
1165 retval = type->attach (serial); 859 retval = type->attach (serial);
1166 module_put(type->owner); 860 module_put(type->driver.owner);
1167 if (retval < 0) 861 if (retval < 0)
1168 goto probe_error; 862 goto probe_error;
1169 if (retval > 0) { 863 if (retval > 0) {
@@ -1330,7 +1024,7 @@ static int __init usb_serial_init(void)
1330 goto exit_generic; 1024 goto exit_generic;
1331 } 1025 }
1332 1026
1333 info(DRIVER_DESC " " DRIVER_VERSION); 1027 info(DRIVER_DESC);
1334 1028
1335 return result; 1029 return result;
1336 1030
@@ -1375,7 +1069,7 @@ module_exit(usb_serial_exit);
1375 } \ 1069 } \
1376 } while (0) 1070 } while (0)
1377 1071
1378static void fixup_generic(struct usb_serial_device_type *device) 1072static void fixup_generic(struct usb_serial_driver *device)
1379{ 1073{
1380 set_to_generic_if_null(device, open); 1074 set_to_generic_if_null(device, open);
1381 set_to_generic_if_null(device, write); 1075 set_to_generic_if_null(device, write);
@@ -1387,30 +1081,33 @@ static void fixup_generic(struct usb_serial_device_type *device)
1387 set_to_generic_if_null(device, shutdown); 1081 set_to_generic_if_null(device, shutdown);
1388} 1082}
1389 1083
1390int usb_serial_register(struct usb_serial_device_type *new_device) 1084int usb_serial_register(struct usb_serial_driver *driver)
1391{ 1085{
1392 int retval; 1086 int retval;
1393 1087
1394 fixup_generic(new_device); 1088 fixup_generic(driver);
1089
1090 if (!driver->description)
1091 driver->description = driver->driver.name;
1395 1092
1396 /* Add this device to our list of devices */ 1093 /* Add this device to our list of devices */
1397 list_add(&new_device->driver_list, &usb_serial_driver_list); 1094 list_add(&driver->driver_list, &usb_serial_driver_list);
1398 1095
1399 retval = usb_serial_bus_register(new_device); 1096 retval = usb_serial_bus_register(driver);
1400 if (retval) { 1097 if (retval) {
1401 err("problem %d when registering driver %s", retval, new_device->name); 1098 err("problem %d when registering driver %s", retval, driver->description);
1402 list_del(&new_device->driver_list); 1099 list_del(&driver->driver_list);
1403 } 1100 }
1404 else 1101 else
1405 info("USB Serial support registered for %s", new_device->name); 1102 info("USB Serial support registered for %s", driver->description);
1406 1103
1407 return retval; 1104 return retval;
1408} 1105}
1409 1106
1410 1107
1411void usb_serial_deregister(struct usb_serial_device_type *device) 1108void usb_serial_deregister(struct usb_serial_driver *device)
1412{ 1109{
1413 info("USB Serial deregistering driver %s", device->name); 1110 info("USB Serial deregistering driver %s", device->description);
1414 list_del(&device->driver_list); 1111 list_del(&device->driver_list);
1415 usb_serial_bus_deregister(device); 1112 usb_serial_bus_deregister(device);
1416} 1113}
@@ -1429,7 +1126,6 @@ EXPORT_SYMBOL_GPL(usb_serial_port_softint);
1429/* Module information */ 1126/* Module information */
1430MODULE_AUTHOR( DRIVER_AUTHOR ); 1127MODULE_AUTHOR( DRIVER_AUTHOR );
1431MODULE_DESCRIPTION( DRIVER_DESC ); 1128MODULE_DESCRIPTION( DRIVER_DESC );
1432MODULE_VERSION( DRIVER_VERSION );
1433MODULE_LICENSE("GPL"); 1129MODULE_LICENSE("GPL");
1434 1130
1435module_param(debug, bool, S_IRUGO | S_IWUSR); 1131module_param(debug, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
index 57f92f054c75..238a5a871ed6 100644
--- a/drivers/usb/serial/usb-serial.h
+++ b/drivers/usb/serial/usb-serial.h
@@ -1,53 +1,13 @@
1/* 1/*
2 * USB Serial Converter driver 2 * USB Serial Converter driver
3 * 3 *
4 * Copyright (C) 1999 - 2004 4 * Copyright (C) 1999 - 2005
5 * Greg Kroah-Hartman (greg@kroah.com) 5 * Greg Kroah-Hartman (greg@kroah.com)
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License.
10 * (at your option) any later version.
11 * 10 *
12 * See Documentation/usb/usb-serial.txt for more information on using this driver
13 *
14 * (03/26/2002) gkh
15 * removed the port->tty check from port_paranoia_check() due to serial
16 * consoles not having a tty device assigned to them.
17 *
18 * (12/03/2001) gkh
19 * removed active from the port structure.
20 * added documentation to the usb_serial_device_type structure
21 *
22 * (10/10/2001) gkh
23 * added vendor and product to serial structure. Needed to determine device
24 * owner when the device is disconnected.
25 *
26 * (05/30/2001) gkh
27 * added sem to port structure and removed port_lock
28 *
29 * (10/05/2000) gkh
30 * Added interrupt_in_endpointAddress and bulk_in_endpointAddress to help
31 * fix bug with urb->dev not being set properly, now that the usb core
32 * needs it.
33 *
34 * (09/11/2000) gkh
35 * Added usb_serial_debug_data function to help get rid of #DEBUG in the
36 * drivers.
37 *
38 * (08/28/2000) gkh
39 * Added port_lock to port structure.
40 *
41 * (08/08/2000) gkh
42 * Added open_count to port structure.
43 *
44 * (07/23/2000) gkh
45 * Added bulk_out_endpointAddress to port structure.
46 *
47 * (07/19/2000) gkh, pberger, and borchers
48 * Modifications to allow usb-serial drivers to be modules.
49 *
50 *
51 */ 11 */
52 12
53 13
@@ -143,7 +103,7 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void
143/** 103/**
144 * usb_serial - structure used by the usb-serial core for a device 104 * usb_serial - structure used by the usb-serial core for a device
145 * @dev: pointer to the struct usb_device for this device 105 * @dev: pointer to the struct usb_device for this device
146 * @type: pointer to the struct usb_serial_device_type for this device 106 * @type: pointer to the struct usb_serial_driver for this device
147 * @interface: pointer to the struct usb_interface for this device 107 * @interface: pointer to the struct usb_interface for this device
148 * @minor: the starting minor number for this device 108 * @minor: the starting minor number for this device
149 * @num_ports: the number of ports this device has 109 * @num_ports: the number of ports this device has
@@ -159,7 +119,7 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void
159 */ 119 */
160struct usb_serial { 120struct usb_serial {
161 struct usb_device * dev; 121 struct usb_device * dev;
162 struct usb_serial_device_type * type; 122 struct usb_serial_driver * type;
163 struct usb_interface * interface; 123 struct usb_interface * interface;
164 unsigned char minor; 124 unsigned char minor;
165 unsigned char num_ports; 125 unsigned char num_ports;
@@ -188,13 +148,9 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
188} 148}
189 149
190/** 150/**
191 * usb_serial_device_type - a structure that defines a usb serial device 151 * usb_serial_driver - describes a usb serial driver
192 * @owner: pointer to the module that owns this device. 152 * @description: pointer to a string that describes this driver. This string used
193 * @name: pointer to a string that describes this device. This string used
194 * in the syslog messages when a device is inserted or removed. 153 * in the syslog messages when a device is inserted or removed.
195 * @short_name: a pointer to a string that describes this device in
196 * KOBJ_NAME_LEN characters or less. This is used for the sysfs interface
197 * to describe the driver.
198 * @id_table: pointer to a list of usb_device_id structures that define all 154 * @id_table: pointer to a list of usb_device_id structures that define all
199 * of the devices this structure can support. 155 * of the devices this structure can support.
200 * @num_interrupt_in: the number of interrupt in endpoints this device will 156 * @num_interrupt_in: the number of interrupt in endpoints this device will
@@ -221,16 +177,19 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data)
221 * @shutdown: pointer to the driver's shutdown function. This will be 177 * @shutdown: pointer to the driver's shutdown function. This will be
222 * called when the device is removed from the system. 178 * called when the device is removed from the system.
223 * 179 *
224 * This structure is defines a USB Serial device. It provides all of 180 * This structure is defines a USB Serial driver. It provides all of
225 * the information that the USB serial core code needs. If the function 181 * the information that the USB serial core code needs. If the function
226 * pointers are defined, then the USB serial core code will call them when 182 * pointers are defined, then the USB serial core code will call them when
227 * the corresponding tty port functions are called. If they are not 183 * the corresponding tty port functions are called. If they are not
228 * called, the generic serial function will be used instead. 184 * called, the generic serial function will be used instead.
185 *
186 * The driver.owner field should be set to the module owner of this driver.
187 * The driver.name field should be set to the name of this driver (remember
188 * it will show up in sysfs, so it needs to be short and to the point.
189 * Useing the module name is a good idea.)
229 */ 190 */
230struct usb_serial_device_type { 191struct usb_serial_driver {
231 struct module *owner; 192 const char *description;
232 char *name;
233 char *short_name;
234 const struct usb_device_id *id_table; 193 const struct usb_device_id *id_table;
235 char num_interrupt_in; 194 char num_interrupt_in;
236 char num_interrupt_out; 195 char num_interrupt_out;
@@ -269,10 +228,10 @@ struct usb_serial_device_type {
269 void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs); 228 void (*read_bulk_callback)(struct urb *urb, struct pt_regs *regs);
270 void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs); 229 void (*write_bulk_callback)(struct urb *urb, struct pt_regs *regs);
271}; 230};
272#define to_usb_serial_driver(d) container_of(d, struct usb_serial_device_type, driver) 231#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver)
273 232
274extern int usb_serial_register(struct usb_serial_device_type *new_device); 233extern int usb_serial_register(struct usb_serial_driver *driver);
275extern void usb_serial_deregister(struct usb_serial_device_type *device); 234extern void usb_serial_deregister(struct usb_serial_driver *driver);
276extern void usb_serial_port_softint(void *private); 235extern void usb_serial_port_softint(void *private);
277 236
278extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 237extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
@@ -303,10 +262,10 @@ extern void usb_serial_generic_shutdown (struct usb_serial *serial);
303extern int usb_serial_generic_register (int debug); 262extern int usb_serial_generic_register (int debug);
304extern void usb_serial_generic_deregister (void); 263extern void usb_serial_generic_deregister (void);
305 264
306extern int usb_serial_bus_register (struct usb_serial_device_type *device); 265extern int usb_serial_bus_register (struct usb_serial_driver *device);
307extern void usb_serial_bus_deregister (struct usb_serial_device_type *device); 266extern void usb_serial_bus_deregister (struct usb_serial_driver *device);
308 267
309extern struct usb_serial_device_type usb_serial_generic_device; 268extern struct usb_serial_driver usb_serial_generic_device;
310extern struct bus_type usb_serial_bus_type; 269extern struct bus_type usb_serial_bus_type;
311extern struct tty_driver *usb_serial_tty_driver; 270extern struct tty_driver *usb_serial_tty_driver;
312 271
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 31c57adcb623..a473c1c34559 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -7,139 +7,10 @@
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License.
11 * (at your option) any later version.
12 * 11 *
13 * See Documentation/usb/usb-serial.txt for more information on using this driver 12 * See Documentation/usb/usb-serial.txt for more information on using this driver
14 * 13 *
15 * (06/03/2003) Judd Montgomery <judd at jpilot.org>
16 * Added support for module parameter options for untested/unknown
17 * devices.
18 *
19 * (03/09/2003) gkh
20 * Added support for the Sony Clie NZ90V device. Thanks to Martin Brachtl
21 * <brachtl@redgrep.cz> for the information.
22 *
23 * (03/05/2003) gkh
24 * Think Treo support is now working.
25 *
26 * (04/03/2002) gkh
27 * Added support for the Sony OS 4.1 devices. Thanks to Hiroyuki ARAKI
28 * <hiro@zob.ne.jp> for the information.
29 *
30 * (03/27/2002) gkh
31 * Removed assumptions that port->tty was always valid (is not true
32 * for usb serial console devices.)
33 *
34 * (03/23/2002) gkh
35 * Added support for the Palm i705 device, thanks to Thomas Riemer
36 * <tom@netmech.com> for the information.
37 *
38 * (03/21/2002) gkh
39 * Added support for the Palm m130 device, thanks to Udo Eisenbarth
40 * <udo.eisenbarth@web.de> for the information.
41 *
42 * (02/27/2002) gkh
43 * Reworked the urb handling logic. We have no more pool, but dynamically
44 * allocate the urb and the transfer buffer on the fly. In testing this
45 * does not incure any measurable overhead. This also relies on the fact
46 * that we have proper reference counting logic for urbs.
47 *
48 * (02/21/2002) SilaS
49 * Added initial support for the Palm m515 devices.
50 *
51 * (02/14/2002) gkh
52 * Added support for the Clie S-360 device.
53 *
54 * (12/18/2001) gkh
55 * Added better Clie support for 3.5 devices. Thanks to Geoffrey Levand
56 * for the patch.
57 *
58 * (11/11/2001) gkh
59 * Added support for the m125 devices, and added check to prevent oopses
60 * for Clié devices that lie about the number of ports they have.
61 *
62 * (08/30/2001) gkh
63 * Added support for the Clie devices, both the 3.5 and 4.0 os versions.
64 * Many thanks to Daniel Burke, and Bryan Payne for helping with this.
65 *
66 * (08/23/2001) gkh
67 * fixed a few potential bugs pointed out by Oliver Neukum.
68 *
69 * (05/30/2001) gkh
70 * switched from using spinlock to a semaphore, which fixes lots of problems.
71 *
72 * (05/28/2000) gkh
73 * Added initial support for the Palm m500 and Palm m505 devices.
74 *
75 * (04/08/2001) gb
76 * Identify version on module load.
77 *
78 * (01/21/2000) gkh
79 * Added write_room and chars_in_buffer, as they were previously using the
80 * generic driver versions which is all wrong now that we are using an urb
81 * pool. Thanks to Wolfgang Grandegger for pointing this out to me.
82 * Removed count assignment in the write function, which was not needed anymore
83 * either. Thanks to Al Borchers for pointing this out.
84 *
85 * (12/12/2000) gkh
86 * Moved MOD_DEC to end of visor_close to be nicer, as the final write
87 * message can sleep.
88 *
89 * (11/12/2000) gkh
90 * Fixed bug with data being dropped on the floor by forcing tty->low_latency
91 * to be on. Hopefully this fixes the OHCI issue!
92 *
93 * (11/01/2000) Adam J. Richter
94 * usb_device_id table support
95 *
96 * (10/05/2000) gkh
97 * Fixed bug with urb->dev not being set properly, now that the usb
98 * core needs it.
99 *
100 * (09/11/2000) gkh
101 * Got rid of always calling kmalloc for every urb we wrote out to the
102 * device.
103 * Added visor_read_callback so we can keep track of bytes in and out for
104 * those people who like to know the speed of their device.
105 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
106 *
107 * (09/06/2000) gkh
108 * Fixed oops in visor_exit. Need to uncomment usb_unlink_urb call _after_
109 * the host controller drivers set urb->dev = NULL when the urb is finished.
110 *
111 * (08/28/2000) gkh
112 * Added locks for SMP safeness.
113 *
114 * (08/08/2000) gkh
115 * Fixed endian problem in visor_startup.
116 * Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
117 * than once.
118 *
119 * (07/23/2000) gkh
120 * Added pool of write urbs to speed up transfers to the visor.
121 *
122 * (07/19/2000) gkh
123 * Added module_init and module_exit functions to handle the fact that this
124 * driver is a loadable module now.
125 *
126 * (07/03/2000) gkh
127 * Added visor_set_ioctl and visor_set_termios functions (they don't do much
128 * of anything, but are good for debugging.)
129 *
130 * (06/25/2000) gkh
131 * Fixed bug in visor_unthrottle that should help with the disconnect in PPP
132 * bug that people have been reporting.
133 *
134 * (06/23/2000) gkh
135 * Cleaned up debugging statements in a quest to find UHCI timeout bug.
136 *
137 * (04/27/2000) Ryan VanderBijl
138 * Fixed memory leak in visor_close
139 *
140 * (03/26/2000) gkh
141 * Split driver up into device specific pieces.
142 *
143 */ 14 */
144 15
145#include <linux/config.h> 16#include <linux/config.h>
@@ -161,7 +32,6 @@
161/* 32/*
162 * Version Information 33 * Version Information
163 */ 34 */
164#define DRIVER_VERSION "v2.1"
165#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" 35#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>"
166#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" 36#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
167 37
@@ -311,10 +181,12 @@ static struct usb_driver visor_driver = {
311}; 181};
312 182
313/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ 183/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
314static struct usb_serial_device_type handspring_device = { 184static struct usb_serial_driver handspring_device = {
315 .owner = THIS_MODULE, 185 .driver = {
316 .name = "Handspring Visor / Palm OS", 186 .owner = THIS_MODULE,
317 .short_name = "visor", 187 .name = "visor",
188 },
189 .description = "Handspring Visor / Palm OS",
318 .id_table = id_table, 190 .id_table = id_table,
319 .num_interrupt_in = NUM_DONT_CARE, 191 .num_interrupt_in = NUM_DONT_CARE,
320 .num_bulk_in = 2, 192 .num_bulk_in = 2,
@@ -339,10 +211,12 @@ static struct usb_serial_device_type handspring_device = {
339}; 211};
340 212
341/* All of the device info needed for the Clie UX50, TH55 Palm 5.0 devices */ 213/* All of the device info needed for the Clie UX50, TH55 Palm 5.0 devices */
342static struct usb_serial_device_type clie_5_device = { 214static struct usb_serial_driver clie_5_device = {
343 .owner = THIS_MODULE, 215 .driver = {
344 .name = "Sony Clie 5.0", 216 .owner = THIS_MODULE,
345 .short_name = "clie_5", 217 .name = "clie_5",
218 },
219 .description = "Sony Clie 5.0",
346 .id_table = clie_id_5_table, 220 .id_table = clie_id_5_table,
347 .num_interrupt_in = NUM_DONT_CARE, 221 .num_interrupt_in = NUM_DONT_CARE,
348 .num_bulk_in = 2, 222 .num_bulk_in = 2,
@@ -367,10 +241,12 @@ static struct usb_serial_device_type clie_5_device = {
367}; 241};
368 242
369/* device info for the Sony Clie OS version 3.5 */ 243/* device info for the Sony Clie OS version 3.5 */
370static struct usb_serial_device_type clie_3_5_device = { 244static struct usb_serial_driver clie_3_5_device = {
371 .owner = THIS_MODULE, 245 .driver = {
372 .name = "Sony Clie 3.5", 246 .owner = THIS_MODULE,
373 .short_name = "clie_3.5", 247 .name = "clie_3.5",
248 },
249 .description = "Sony Clie 3.5",
374 .id_table = clie_id_3_5_table, 250 .id_table = clie_id_3_5_table,
375 .num_interrupt_in = 0, 251 .num_interrupt_in = 0,
376 .num_bulk_in = 1, 252 .num_bulk_in = 1,
@@ -782,7 +658,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
782 break; 658 break;
783 } 659 }
784 dev_info(dev, "%s: port %d, is for %s use\n", 660 dev_info(dev, "%s: port %d, is for %s use\n",
785 serial->type->name, 661 serial->type->description,
786 connection_info->connections[i].port, string); 662 connection_info->connections[i].port, string);
787 } 663 }
788 } 664 }
@@ -791,11 +667,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
791 */ 667 */
792 if (num_ports == 0 || num_ports > 2) { 668 if (num_ports == 0 || num_ports > 2) {
793 dev_warn (dev, "%s: No valid connect info available\n", 669 dev_warn (dev, "%s: No valid connect info available\n",
794 serial->type->name); 670 serial->type->description);
795 num_ports = 2; 671 num_ports = 2;
796 } 672 }
797 673
798 dev_info(dev, "%s: Number of ports: %d\n", serial->type->name, 674 dev_info(dev, "%s: Number of ports: %d\n", serial->type->description,
799 num_ports); 675 num_ports);
800 676
801 /* 677 /*
@@ -1125,7 +1001,7 @@ static int __init visor_init (void)
1125 retval = usb_register(&visor_driver); 1001 retval = usb_register(&visor_driver);
1126 if (retval) 1002 if (retval)
1127 goto failed_usb_register; 1003 goto failed_usb_register;
1128 info(DRIVER_DESC " " DRIVER_VERSION); 1004 info(DRIVER_DESC);
1129 1005
1130 return 0; 1006 return 0;
1131failed_usb_register: 1007failed_usb_register:
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index cf3bc30675a1..18c3183be769 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -156,10 +156,12 @@ static void whiteheat_unthrottle (struct usb_serial_port *port);
156static void whiteheat_read_callback (struct urb *urb, struct pt_regs *regs); 156static void whiteheat_read_callback (struct urb *urb, struct pt_regs *regs);
157static void whiteheat_write_callback (struct urb *urb, struct pt_regs *regs); 157static void whiteheat_write_callback (struct urb *urb, struct pt_regs *regs);
158 158
159static struct usb_serial_device_type whiteheat_fake_device = { 159static struct usb_serial_driver whiteheat_fake_device = {
160 .owner = THIS_MODULE, 160 .driver = {
161 .name = "Connect Tech - WhiteHEAT - (prerenumeration)", 161 .owner = THIS_MODULE,
162 .short_name = "whiteheatnofirm", 162 .name = "whiteheatnofirm",
163 },
164 .description = "Connect Tech - WhiteHEAT - (prerenumeration)",
163 .id_table = id_table_prerenumeration, 165 .id_table = id_table_prerenumeration,
164 .num_interrupt_in = NUM_DONT_CARE, 166 .num_interrupt_in = NUM_DONT_CARE,
165 .num_bulk_in = NUM_DONT_CARE, 167 .num_bulk_in = NUM_DONT_CARE,
@@ -169,10 +171,12 @@ static struct usb_serial_device_type whiteheat_fake_device = {
169 .attach = whiteheat_firmware_attach, 171 .attach = whiteheat_firmware_attach,
170}; 172};
171 173
172static struct usb_serial_device_type whiteheat_device = { 174static struct usb_serial_driver whiteheat_device = {
173 .owner = THIS_MODULE, 175 .driver = {
174 .name = "Connect Tech - WhiteHEAT", 176 .owner = THIS_MODULE,
175 .short_name = "whiteheat", 177 .name = "whiteheat",
178 },
179 .description = "Connect Tech - WhiteHEAT",
176 .id_table = id_table_std, 180 .id_table = id_table_std,
177 .num_interrupt_in = NUM_DONT_CARE, 181 .num_interrupt_in = NUM_DONT_CARE,
178 .num_bulk_in = NUM_DONT_CARE, 182 .num_bulk_in = NUM_DONT_CARE,
@@ -382,10 +386,10 @@ static int whiteheat_attach (struct usb_serial *serial)
382 usb_clear_halt(serial->dev, pipe); 386 usb_clear_halt(serial->dev, pipe);
383 ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS); 387 ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS);
384 if (ret) { 388 if (ret) {
385 err("%s: Couldn't send command [%d]", serial->type->name, ret); 389 err("%s: Couldn't send command [%d]", serial->type->description, ret);
386 goto no_firmware; 390 goto no_firmware;
387 } else if (alen != sizeof(command)) { 391 } else if (alen != sizeof(command)) {
388 err("%s: Send command incomplete [%d]", serial->type->name, alen); 392 err("%s: Send command incomplete [%d]", serial->type->description, alen);
389 goto no_firmware; 393 goto no_firmware;
390 } 394 }
391 395
@@ -394,19 +398,19 @@ static int whiteheat_attach (struct usb_serial *serial)
394 usb_clear_halt(serial->dev, pipe); 398 usb_clear_halt(serial->dev, pipe);
395 ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); 399 ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);
396 if (ret) { 400 if (ret) {
397 err("%s: Couldn't get results [%d]", serial->type->name, ret); 401 err("%s: Couldn't get results [%d]", serial->type->description, ret);
398 goto no_firmware; 402 goto no_firmware;
399 } else if (alen != sizeof(result)) { 403 } else if (alen != sizeof(result)) {
400 err("%s: Get results incomplete [%d]", serial->type->name, alen); 404 err("%s: Get results incomplete [%d]", serial->type->description, alen);
401 goto no_firmware; 405 goto no_firmware;
402 } else if (result[0] != command[0]) { 406 } else if (result[0] != command[0]) {
403 err("%s: Command failed [%d]", serial->type->name, result[0]); 407 err("%s: Command failed [%d]", serial->type->description, result[0]);
404 goto no_firmware; 408 goto no_firmware;
405 } 409 }
406 410
407 hw_info = (struct whiteheat_hw_info *)&result[1]; 411 hw_info = (struct whiteheat_hw_info *)&result[1];
408 412
409 info("%s: Driver %s: Firmware v%d.%02d", serial->type->name, 413 info("%s: Driver %s: Firmware v%d.%02d", serial->type->description,
410 DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); 414 DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev);
411 415
412 for (i = 0; i < serial->num_ports; i++) { 416 for (i = 0; i < serial->num_ports; i++) {
@@ -414,7 +418,7 @@ static int whiteheat_attach (struct usb_serial *serial)
414 418
415 info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); 419 info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
416 if (info == NULL) { 420 if (info == NULL) {
417 err("%s: Out of memory for port structures\n", serial->type->name); 421 err("%s: Out of memory for port structures\n", serial->type->description);
418 goto no_private; 422 goto no_private;
419 } 423 }
420 424
@@ -484,7 +488,7 @@ static int whiteheat_attach (struct usb_serial *serial)
484 488
485 command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); 489 command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL);
486 if (command_info == NULL) { 490 if (command_info == NULL) {
487 err("%s: Out of memory for port structures\n", serial->type->name); 491 err("%s: Out of memory for port structures\n", serial->type->description);
488 goto no_command_private; 492 goto no_command_private;
489 } 493 }
490 494
@@ -501,9 +505,9 @@ static int whiteheat_attach (struct usb_serial *serial)
501 505
502no_firmware: 506no_firmware:
503 /* Firmware likely not running */ 507 /* Firmware likely not running */
504 err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->name); 508 err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description);
505 err("%s: If the firmware is not running (status led not blinking)\n", serial->type->name); 509 err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description);
506 err("%s: please contact support@connecttech.com\n", serial->type->name); 510 err("%s: please contact support@connecttech.com\n", serial->type->description);
507 return -ENODEV; 511 return -ENODEV;
508 512
509no_command_private: 513no_command_private:
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index bb9819cc8826..1a9679f76f5a 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -2,7 +2,8 @@
2# USB Storage driver configuration 2# USB Storage driver configuration
3# 3#
4 4
5comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information" 5comment "NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'"
6comment "may also be needed; see USB_STORAGE Help for more information"
6 depends on USB 7 depends on USB
7 8
8config USB_STORAGE 9config USB_STORAGE
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 2c9402dc702b..89401a59f952 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -5,7 +5,7 @@
5 * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu> 5 * Copyright (c) 2005 Nick Sillik <n.sillik@temple.edu>
6 * 6 *
7 * Initial work by: 7 * Initial work by:
8 * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se> 8 * Copyright (c) 2003 Erik Thyren <erth7411@student.uu.se>
9 * 9 *
10 * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann) 10 * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann)
11 * 11 *
@@ -46,7 +46,7 @@ void onetouch_release_input(void *onetouch_);
46struct usb_onetouch { 46struct usb_onetouch {
47 char name[128]; 47 char name[128];
48 char phys[64]; 48 char phys[64];
49 struct input_dev dev; /* input device interface */ 49 struct input_dev *dev; /* input device interface */
50 struct usb_device *udev; /* usb device */ 50 struct usb_device *udev; /* usb device */
51 51
52 struct urb *irq; /* urb for interrupt in report */ 52 struct urb *irq; /* urb for interrupt in report */
@@ -58,7 +58,7 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs)
58{ 58{
59 struct usb_onetouch *onetouch = urb->context; 59 struct usb_onetouch *onetouch = urb->context;
60 signed char *data = onetouch->data; 60 signed char *data = onetouch->data;
61 struct input_dev *dev = &onetouch->dev; 61 struct input_dev *dev = onetouch->dev;
62 int status; 62 int status;
63 63
64 switch (urb->status) { 64 switch (urb->status) {
@@ -74,11 +74,9 @@ static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs)
74 } 74 }
75 75
76 input_regs(dev, regs); 76 input_regs(dev, regs);
77 77 input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02);
78 input_report_key(&onetouch->dev, ONETOUCH_BUTTON,
79 data[0] & 0x02);
80
81 input_sync(dev); 78 input_sync(dev);
79
82resubmit: 80resubmit:
83 status = usb_submit_urb (urb, SLAB_ATOMIC); 81 status = usb_submit_urb (urb, SLAB_ATOMIC);
84 if (status) 82 if (status)
@@ -113,8 +111,8 @@ int onetouch_connect_input(struct us_data *ss)
113 struct usb_host_interface *interface; 111 struct usb_host_interface *interface;
114 struct usb_endpoint_descriptor *endpoint; 112 struct usb_endpoint_descriptor *endpoint;
115 struct usb_onetouch *onetouch; 113 struct usb_onetouch *onetouch;
114 struct input_dev *input_dev;
116 int pipe, maxp; 115 int pipe, maxp;
117 char path[64];
118 116
119 interface = ss->pusb_intf->cur_altsetting; 117 interface = ss->pusb_intf->cur_altsetting;
120 118
@@ -122,62 +120,62 @@ int onetouch_connect_input(struct us_data *ss)
122 return -ENODEV; 120 return -ENODEV;
123 121
124 endpoint = &interface->endpoint[2].desc; 122 endpoint = &interface->endpoint[2].desc;
125 if(!(endpoint->bEndpointAddress & USB_DIR_IN)) 123 if (!(endpoint->bEndpointAddress & USB_DIR_IN))
126 return -ENODEV; 124 return -ENODEV;
127 if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 125 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
128 != USB_ENDPOINT_XFER_INT) 126 != USB_ENDPOINT_XFER_INT)
129 return -ENODEV; 127 return -ENODEV;
130 128
131 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 129 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
132 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); 130 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
133 131
134 if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL))) 132 onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);
135 return -ENOMEM; 133 input_dev = input_allocate_device();
134 if (!onetouch || !input_dev)
135 goto fail1;
136 136
137 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 137 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
138 SLAB_ATOMIC, &onetouch->data_dma); 138 SLAB_ATOMIC, &onetouch->data_dma);
139 if (!onetouch->data){ 139 if (!onetouch->data)
140 kfree(onetouch); 140 goto fail1;
141 return -ENOMEM;
142 }
143 141
144 onetouch->irq = usb_alloc_urb(0, GFP_KERNEL); 142 onetouch->irq = usb_alloc_urb(0, GFP_KERNEL);
145 if (!onetouch->irq){ 143 if (!onetouch->irq)
146 kfree(onetouch); 144 goto fail2;
147 usb_buffer_free(udev, ONETOUCH_PKT_LEN,
148 onetouch->data, onetouch->data_dma);
149 return -ENODEV;
150 }
151
152 145
153 onetouch->udev = udev; 146 onetouch->udev = udev;
147 onetouch->dev = input_dev;
154 148
155 set_bit(EV_KEY, onetouch->dev.evbit); 149 if (udev->manufacturer)
156 set_bit(ONETOUCH_BUTTON, onetouch->dev.keybit); 150 strlcpy(onetouch->name, udev->manufacturer,
157 clear_bit(0, onetouch->dev.keybit); 151 sizeof(onetouch->name));
152 if (udev->product) {
153 if (udev->manufacturer)
154 strlcat(onetouch->name, " ", sizeof(onetouch->name));
155 strlcat(onetouch->name, udev->product, sizeof(onetouch->name));
156 }
158 157
159 onetouch->dev.private = onetouch; 158 if (!strlen(onetouch->name))
160 onetouch->dev.open = usb_onetouch_open; 159 snprintf(onetouch->name, sizeof(onetouch->name),
161 onetouch->dev.close = usb_onetouch_close; 160 "Maxtor Onetouch %04x:%04x",
161 le16_to_cpu(udev->descriptor.idVendor),
162 le16_to_cpu(udev->descriptor.idProduct));
162 163
163 usb_make_path(udev, path, sizeof(path)); 164 usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys));
164 sprintf(onetouch->phys, "%s/input0", path); 165 strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys));
165 166
166 onetouch->dev.name = onetouch->name; 167 input_dev->name = onetouch->name;
167 onetouch->dev.phys = onetouch->phys; 168 input_dev->phys = onetouch->phys;
169 usb_to_input_id(udev, &input_dev->id);
170 input_dev->cdev.dev = &udev->dev;
168 171
169 usb_to_input_id(udev, &onetouch->dev.id); 172 set_bit(EV_KEY, input_dev->evbit);
173 set_bit(ONETOUCH_BUTTON, input_dev->keybit);
174 clear_bit(0, input_dev->keybit);
170 175
171 onetouch->dev.dev = &udev->dev; 176 input_dev->private = onetouch;
172 177 input_dev->open = usb_onetouch_open;
173 if (udev->manufacturer) 178 input_dev->close = usb_onetouch_close;
174 strcat(onetouch->name, udev->manufacturer);
175 if (udev->product)
176 sprintf(onetouch->name, "%s %s", onetouch->name,
177 udev->product);
178 if (!strlen(onetouch->name))
179 sprintf(onetouch->name, "Maxtor Onetouch %04x:%04x",
180 onetouch->dev.id.vendor, onetouch->dev.id.product);
181 179
182 usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data, 180 usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data,
183 (maxp > 8 ? 8 : maxp), 181 (maxp > 8 ? 8 : maxp),
@@ -188,10 +186,15 @@ int onetouch_connect_input(struct us_data *ss)
188 ss->extra_destructor = onetouch_release_input; 186 ss->extra_destructor = onetouch_release_input;
189 ss->extra = onetouch; 187 ss->extra = onetouch;
190 188
191 input_register_device(&onetouch->dev); 189 input_register_device(onetouch->dev);
192 printk(KERN_INFO "usb-input: %s on %s\n", onetouch->dev.name, path);
193 190
194 return 0; 191 return 0;
192
193 fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN,
194 onetouch->data, onetouch->data_dma);
195 fail1: kfree(onetouch);
196 input_free_device(input_dev);
197 return -ENOMEM;
195} 198}
196 199
197void onetouch_release_input(void *onetouch_) 200void onetouch_release_input(void *onetouch_)
@@ -200,11 +203,9 @@ void onetouch_release_input(void *onetouch_)
200 203
201 if (onetouch) { 204 if (onetouch) {
202 usb_kill_urb(onetouch->irq); 205 usb_kill_urb(onetouch->irq);
203 input_unregister_device(&onetouch->dev); 206 input_unregister_device(onetouch->dev);
204 usb_free_urb(onetouch->irq); 207 usb_free_urb(onetouch->irq);
205 usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN, 208 usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN,
206 onetouch->data, onetouch->data_dma); 209 onetouch->data, onetouch->data_dma);
207 printk(KERN_INFO "usb-input: deregistering %s\n",
208 onetouch->dev.name);
209 } 210 }
210} 211}
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 356342c6e7a2..33c55a6261bb 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1,4 +1,4 @@
1/* Driver for SCM Microsystems USB-ATAPI cable 1/* Driver for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable
2 * 2 *
3 * $Id: shuttle_usbat.c,v 1.17 2002/04/22 03:39:43 mdharm Exp $ 3 * $Id: shuttle_usbat.c,v 1.17 2002/04/22 03:39:43 mdharm Exp $
4 * 4 *
@@ -67,10 +67,10 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us);
67static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us); 67static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us);
68 68
69/* 69/*
70 * Convenience function to produce an ATAPI read/write sectors command 70 * Convenience function to produce an ATA read/write sectors command
71 * Use cmd=0x20 for read, cmd=0x30 for write 71 * Use cmd=0x20 for read, cmd=0x30 for write
72 */ 72 */
73static void usbat_pack_atapi_sector_cmd(unsigned char *buf, 73static void usbat_pack_ata_sector_cmd(unsigned char *buf,
74 unsigned char thistime, 74 unsigned char thistime,
75 u32 sector, unsigned char cmd) 75 u32 sector, unsigned char cmd)
76{ 76{
@@ -196,10 +196,12 @@ static int usbat_check_status(struct us_data *us)
196 if (rc != USB_STOR_XFER_GOOD) 196 if (rc != USB_STOR_XFER_GOOD)
197 return USB_STOR_TRANSPORT_FAILED; 197 return USB_STOR_TRANSPORT_FAILED;
198 198
199 if (*reply & 0x01 && *reply != 0x51) // error/check condition (0x51 is ok) 199 /* error/check condition (0x51 is ok) */
200 if (*reply & 0x01 && *reply != 0x51)
200 return USB_STOR_TRANSPORT_FAILED; 201 return USB_STOR_TRANSPORT_FAILED;
201 202
202 if (*reply & 0x20) // device fault 203 /* device fault */
204 if (*reply & 0x20)
203 return USB_STOR_TRANSPORT_FAILED; 205 return USB_STOR_TRANSPORT_FAILED;
204 206
205 return USB_STOR_TRANSPORT_GOOD; 207 return USB_STOR_TRANSPORT_GOOD;
@@ -222,29 +224,39 @@ static int usbat_set_shuttle_features(struct us_data *us,
222 command[0] = 0x40; 224 command[0] = 0x40;
223 command[1] = USBAT_CMD_SET_FEAT; 225 command[1] = USBAT_CMD_SET_FEAT;
224 226
225 // The only bit relevant to ATA access is bit 6 227 /*
226 // which defines 8 bit data access (set) or 16 bit (unset) 228 * The only bit relevant to ATA access is bit 6
229 * which defines 8 bit data access (set) or 16 bit (unset)
230 */
227 command[2] = epp_control; 231 command[2] = epp_control;
228 232
229 // If FCQ is set in the qualifier (defined in R/W cmd), then bits U0, U1, 233 /*
230 // ET1 and ET2 define an external event to be checked for on event of a 234 * If FCQ is set in the qualifier (defined in R/W cmd), then bits U0, U1,
231 // _read_blocks or _write_blocks operation. The read/write will not take 235 * ET1 and ET2 define an external event to be checked for on event of a
232 // place unless the defined trigger signal is active. 236 * _read_blocks or _write_blocks operation. The read/write will not take
237 * place unless the defined trigger signal is active.
238 */
233 command[3] = external_trigger; 239 command[3] = external_trigger;
234 240
235 // The resultant byte of the mask operation (see mask_byte) is compared for 241 /*
236 // equivalence with this test pattern. If equal, the read/write will take 242 * The resultant byte of the mask operation (see mask_byte) is compared for
237 // place. 243 * equivalence with this test pattern. If equal, the read/write will take
244 * place.
245 */
238 command[4] = test_pattern; 246 command[4] = test_pattern;
239 247
240 // This value is logically ANDed with the status register field specified 248 /*
241 // in the read/write command. 249 * This value is logically ANDed with the status register field specified
250 * in the read/write command.
251 */
242 command[5] = mask_byte; 252 command[5] = mask_byte;
243 253
244 // If ALQ is set in the qualifier, this field contains the address of the 254 /*
245 // registers where the byte count should be read for transferring the data. 255 * If ALQ is set in the qualifier, this field contains the address of the
246 // If ALQ is not set, then this field contains the number of bytes to be 256 * registers where the byte count should be read for transferring the data.
247 // transferred. 257 * If ALQ is not set, then this field contains the number of bytes to be
258 * transferred.
259 */
248 command[6] = subcountL; 260 command[6] = subcountL;
249 command[7] = subcountH; 261 command[7] = subcountH;
250 262
@@ -273,26 +285,26 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes)
273 285
274 if (result!=USB_STOR_XFER_GOOD) 286 if (result!=USB_STOR_XFER_GOOD)
275 return USB_STOR_TRANSPORT_ERROR; 287 return USB_STOR_TRANSPORT_ERROR;
276 if (*status & 0x01) { // check condition 288 if (*status & 0x01) { /* check condition */
277 result = usbat_read(us, USBAT_ATA, 0x10, status); 289 result = usbat_read(us, USBAT_ATA, 0x10, status);
278 return USB_STOR_TRANSPORT_FAILED; 290 return USB_STOR_TRANSPORT_FAILED;
279 } 291 }
280 if (*status & 0x20) // device fault 292 if (*status & 0x20) /* device fault */
281 return USB_STOR_TRANSPORT_FAILED; 293 return USB_STOR_TRANSPORT_FAILED;
282 294
283 if ((*status & 0x80)==0x00) { // not busy 295 if ((*status & 0x80)==0x00) { /* not busy */
284 US_DEBUGP("Waited not busy for %d steps\n", i); 296 US_DEBUGP("Waited not busy for %d steps\n", i);
285 return USB_STOR_TRANSPORT_GOOD; 297 return USB_STOR_TRANSPORT_GOOD;
286 } 298 }
287 299
288 if (i<500) 300 if (i<500)
289 msleep(10); // 5 seconds 301 msleep(10); /* 5 seconds */
290 else if (i<700) 302 else if (i<700)
291 msleep(50); // 10 seconds 303 msleep(50); /* 10 seconds */
292 else if (i<1200) 304 else if (i<1200)
293 msleep(100); // 50 seconds 305 msleep(100); /* 50 seconds */
294 else 306 else
295 msleep(1000); // X minutes 307 msleep(1000); /* X minutes */
296 } 308 }
297 309
298 US_DEBUGP("Waited not busy for %d minutes, timing out.\n", 310 US_DEBUGP("Waited not busy for %d minutes, timing out.\n",
@@ -412,9 +424,12 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
412 424
413 if (i==0) { 425 if (i==0) {
414 cmdlen = 16; 426 cmdlen = 16;
415 // Write to multiple registers 427 /*
416 // Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here, 428 * Write to multiple registers
417 // but that's what came out of the trace every single time. 429 * Not really sure the 0x07, 0x17, 0xfc, 0xe7 is
430 * necessary here, but that's what came out of the
431 * trace every single time.
432 */
418 command[0] = 0x40; 433 command[0] = 0x40;
419 command[1] = access | USBAT_CMD_WRITE_REGS; 434 command[1] = access | USBAT_CMD_WRITE_REGS;
420 command[2] = 0x07; 435 command[2] = 0x07;
@@ -426,7 +441,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
426 } else 441 } else
427 cmdlen = 8; 442 cmdlen = 8;
428 443
429 // Conditionally read or write blocks 444 /* Conditionally read or write blocks */
430 command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0); 445 command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0);
431 command[cmdlen-7] = access | 446 command[cmdlen-7] = access |
432 (direction==DMA_TO_DEVICE ? 447 (direction==DMA_TO_DEVICE ?
@@ -456,11 +471,6 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
456 471
457 } 472 }
458 473
459
460 //US_DEBUGP("Transfer %s %d bytes, sg buffers %d\n",
461 // direction == DMA_TO_DEVICE ? "out" : "in",
462 // len, use_sg);
463
464 result = usb_stor_bulk_transfer_sg(us, 474 result = usb_stor_bulk_transfer_sg(us,
465 pipe, content, len, use_sg, NULL); 475 pipe, content, len, use_sg, NULL);
466 476
@@ -508,9 +518,9 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us,
508 518
509 if (result!=USB_STOR_XFER_GOOD) 519 if (result!=USB_STOR_XFER_GOOD)
510 return USB_STOR_TRANSPORT_ERROR; 520 return USB_STOR_TRANSPORT_ERROR;
511 if (*status & 0x01) // check condition 521 if (*status & 0x01) /* check condition */
512 return USB_STOR_TRANSPORT_FAILED; 522 return USB_STOR_TRANSPORT_FAILED;
513 if (*status & 0x20) // device fault 523 if (*status & 0x20) /* device fault */
514 return USB_STOR_TRANSPORT_FAILED; 524 return USB_STOR_TRANSPORT_FAILED;
515 525
516 US_DEBUGP("Redoing %s\n", 526 US_DEBUGP("Redoing %s\n",
@@ -547,32 +557,32 @@ static int usbat_multiple_write(struct us_data *us,
547 557
548 BUG_ON(num_registers > US_IOBUF_SIZE/2); 558 BUG_ON(num_registers > US_IOBUF_SIZE/2);
549 559
550 // Write to multiple registers, ATA access 560 /* Write to multiple registers, ATA access */
551 command[0] = 0x40; 561 command[0] = 0x40;
552 command[1] = USBAT_ATA | USBAT_CMD_WRITE_REGS; 562 command[1] = USBAT_ATA | USBAT_CMD_WRITE_REGS;
553 563
554 // No relevance 564 /* No relevance */
555 command[2] = 0; 565 command[2] = 0;
556 command[3] = 0; 566 command[3] = 0;
557 command[4] = 0; 567 command[4] = 0;
558 command[5] = 0; 568 command[5] = 0;
559 569
560 // Number of bytes to be transferred (incl. addresses and data) 570 /* Number of bytes to be transferred (incl. addresses and data) */
561 command[6] = LSB_of(num_registers*2); 571 command[6] = LSB_of(num_registers*2);
562 command[7] = MSB_of(num_registers*2); 572 command[7] = MSB_of(num_registers*2);
563 573
564 // The setup command 574 /* The setup command */
565 result = usbat_execute_command(us, command, 8); 575 result = usbat_execute_command(us, command, 8);
566 if (result != USB_STOR_XFER_GOOD) 576 if (result != USB_STOR_XFER_GOOD)
567 return USB_STOR_TRANSPORT_ERROR; 577 return USB_STOR_TRANSPORT_ERROR;
568 578
569 // Create the reg/data, reg/data sequence 579 /* Create the reg/data, reg/data sequence */
570 for (i=0; i<num_registers; i++) { 580 for (i=0; i<num_registers; i++) {
571 data[i<<1] = registers[i]; 581 data[i<<1] = registers[i];
572 data[1+(i<<1)] = data_out[i]; 582 data[1+(i<<1)] = data_out[i];
573 } 583 }
574 584
575 // Send the data 585 /* Send the data */
576 result = usbat_bulk_write(us, data, num_registers*2); 586 result = usbat_bulk_write(us, data, num_registers*2);
577 if (result != USB_STOR_XFER_GOOD) 587 if (result != USB_STOR_XFER_GOOD)
578 return USB_STOR_TRANSPORT_ERROR; 588 return USB_STOR_TRANSPORT_ERROR;
@@ -606,17 +616,17 @@ static int usbat_read_blocks(struct us_data *us,
606 command[1] = USBAT_ATA | USBAT_CMD_COND_READ_BLOCK; 616 command[1] = USBAT_ATA | USBAT_CMD_COND_READ_BLOCK;
607 command[2] = USBAT_ATA_DATA; 617 command[2] = USBAT_ATA_DATA;
608 command[3] = USBAT_ATA_STATUS; 618 command[3] = USBAT_ATA_STATUS;
609 command[4] = 0xFD; // Timeout (ms); 619 command[4] = 0xFD; /* Timeout (ms); */
610 command[5] = USBAT_QUAL_FCQ; 620 command[5] = USBAT_QUAL_FCQ;
611 command[6] = LSB_of(len); 621 command[6] = LSB_of(len);
612 command[7] = MSB_of(len); 622 command[7] = MSB_of(len);
613 623
614 // Multiple block read setup command 624 /* Multiple block read setup command */
615 result = usbat_execute_command(us, command, 8); 625 result = usbat_execute_command(us, command, 8);
616 if (result != USB_STOR_XFER_GOOD) 626 if (result != USB_STOR_XFER_GOOD)
617 return USB_STOR_TRANSPORT_FAILED; 627 return USB_STOR_TRANSPORT_FAILED;
618 628
619 // Read the blocks we just asked for 629 /* Read the blocks we just asked for */
620 result = usbat_bulk_read(us, buffer, len); 630 result = usbat_bulk_read(us, buffer, len);
621 if (result != USB_STOR_XFER_GOOD) 631 if (result != USB_STOR_XFER_GOOD)
622 return USB_STOR_TRANSPORT_FAILED; 632 return USB_STOR_TRANSPORT_FAILED;
@@ -647,17 +657,17 @@ static int usbat_write_blocks(struct us_data *us,
647 command[1] = USBAT_ATA | USBAT_CMD_COND_WRITE_BLOCK; 657 command[1] = USBAT_ATA | USBAT_CMD_COND_WRITE_BLOCK;
648 command[2] = USBAT_ATA_DATA; 658 command[2] = USBAT_ATA_DATA;
649 command[3] = USBAT_ATA_STATUS; 659 command[3] = USBAT_ATA_STATUS;
650 command[4] = 0xFD; // Timeout (ms) 660 command[4] = 0xFD; /* Timeout (ms) */
651 command[5] = USBAT_QUAL_FCQ; 661 command[5] = USBAT_QUAL_FCQ;
652 command[6] = LSB_of(len); 662 command[6] = LSB_of(len);
653 command[7] = MSB_of(len); 663 command[7] = MSB_of(len);
654 664
655 // Multiple block write setup command 665 /* Multiple block write setup command */
656 result = usbat_execute_command(us, command, 8); 666 result = usbat_execute_command(us, command, 8);
657 if (result != USB_STOR_XFER_GOOD) 667 if (result != USB_STOR_XFER_GOOD)
658 return USB_STOR_TRANSPORT_FAILED; 668 return USB_STOR_TRANSPORT_FAILED;
659 669
660 // Write the data 670 /* Write the data */
661 result = usbat_bulk_write(us, buffer, len); 671 result = usbat_bulk_write(us, buffer, len);
662 if (result != USB_STOR_XFER_GOOD) 672 if (result != USB_STOR_XFER_GOOD)
663 return USB_STOR_TRANSPORT_FAILED; 673 return USB_STOR_TRANSPORT_FAILED;
@@ -711,16 +721,20 @@ static int usbat_device_reset(struct us_data *us)
711{ 721{
712 int rc; 722 int rc;
713 723
714 // Reset peripheral, enable peripheral control signals 724 /*
715 // (bring reset signal up) 725 * Reset peripheral, enable peripheral control signals
726 * (bring reset signal up)
727 */
716 rc = usbat_write_user_io(us, 728 rc = usbat_write_user_io(us,
717 USBAT_UIO_DRVRST | USBAT_UIO_OE1 | USBAT_UIO_OE0, 729 USBAT_UIO_DRVRST | USBAT_UIO_OE1 | USBAT_UIO_OE0,
718 USBAT_UIO_EPAD | USBAT_UIO_1); 730 USBAT_UIO_EPAD | USBAT_UIO_1);
719 if (rc != USB_STOR_XFER_GOOD) 731 if (rc != USB_STOR_XFER_GOOD)
720 return USB_STOR_TRANSPORT_ERROR; 732 return USB_STOR_TRANSPORT_ERROR;
721 733
722 // Enable peripheral control signals 734 /*
723 // (bring reset signal down) 735 * Enable peripheral control signals
736 * (bring reset signal down)
737 */
724 rc = usbat_write_user_io(us, 738 rc = usbat_write_user_io(us,
725 USBAT_UIO_OE1 | USBAT_UIO_OE0, 739 USBAT_UIO_OE1 | USBAT_UIO_OE0,
726 USBAT_UIO_EPAD | USBAT_UIO_1); 740 USBAT_UIO_EPAD | USBAT_UIO_1);
@@ -737,7 +751,7 @@ static int usbat_device_enable_cdt(struct us_data *us)
737{ 751{
738 int rc; 752 int rc;
739 753
740 // Enable peripheral control signals and card detect 754 /* Enable peripheral control signals and card detect */
741 rc = usbat_write_user_io(us, 755 rc = usbat_write_user_io(us,
742 USBAT_UIO_ACKD | USBAT_UIO_OE1 | USBAT_UIO_OE0, 756 USBAT_UIO_ACKD | USBAT_UIO_OE1 | USBAT_UIO_OE0,
743 USBAT_UIO_EPAD | USBAT_UIO_1); 757 USBAT_UIO_EPAD | USBAT_UIO_1);
@@ -786,7 +800,7 @@ static int usbat_flash_check_media(struct us_data *us,
786 if (rc != USB_STOR_XFER_GOOD) 800 if (rc != USB_STOR_XFER_GOOD)
787 return USB_STOR_TRANSPORT_ERROR; 801 return USB_STOR_TRANSPORT_ERROR;
788 802
789 // Check for media existence 803 /* Check for media existence */
790 rc = usbat_flash_check_media_present(uio); 804 rc = usbat_flash_check_media_present(uio);
791 if (rc == USBAT_FLASH_MEDIA_NONE) { 805 if (rc == USBAT_FLASH_MEDIA_NONE) {
792 info->sense_key = 0x02; 806 info->sense_key = 0x02;
@@ -795,11 +809,11 @@ static int usbat_flash_check_media(struct us_data *us,
795 return USB_STOR_TRANSPORT_FAILED; 809 return USB_STOR_TRANSPORT_FAILED;
796 } 810 }
797 811
798 // Check for media change 812 /* Check for media change */
799 rc = usbat_flash_check_media_changed(uio); 813 rc = usbat_flash_check_media_changed(uio);
800 if (rc == USBAT_FLASH_MEDIA_CHANGED) { 814 if (rc == USBAT_FLASH_MEDIA_CHANGED) {
801 815
802 // Reset and re-enable card detect 816 /* Reset and re-enable card detect */
803 rc = usbat_device_reset(us); 817 rc = usbat_device_reset(us);
804 if (rc != USB_STOR_TRANSPORT_GOOD) 818 if (rc != USB_STOR_TRANSPORT_GOOD)
805 return rc; 819 return rc;
@@ -855,15 +869,15 @@ static int usbat_identify_device(struct us_data *us,
855 if (rc != USB_STOR_XFER_GOOD) 869 if (rc != USB_STOR_XFER_GOOD)
856 return USB_STOR_TRANSPORT_ERROR; 870 return USB_STOR_TRANSPORT_ERROR;
857 871
858 // Check for error bit 872 /* Check for error bit, or if the command 'fell through' */
859 if (status & 0x01) { 873 if (status == 0xA1 || !(status & 0x01)) {
860 // Device is a CompactFlash reader/writer 874 /* Device is HP 8200 */
861 US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n");
862 info->devicetype = USBAT_DEV_FLASH;
863 } else {
864 // Device is HP 8200
865 US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n"); 875 US_DEBUGP("usbat_identify_device: Detected HP8200 CDRW\n");
866 info->devicetype = USBAT_DEV_HP8200; 876 info->devicetype = USBAT_DEV_HP8200;
877 } else {
878 /* Device is a CompactFlash reader/writer */
879 US_DEBUGP("usbat_identify_device: Detected Flash reader/writer\n");
880 info->devicetype = USBAT_DEV_FLASH;
867 } 881 }
868 882
869 return USB_STOR_TRANSPORT_GOOD; 883 return USB_STOR_TRANSPORT_GOOD;
@@ -916,7 +930,7 @@ static int usbat_flash_get_sector_count(struct us_data *us,
916 if (!reply) 930 if (!reply)
917 return USB_STOR_TRANSPORT_ERROR; 931 return USB_STOR_TRANSPORT_ERROR;
918 932
919 // ATAPI command : IDENTIFY DEVICE 933 /* ATA command : IDENTIFY DEVICE */
920 rc = usbat_multiple_write(us, registers, command, 3); 934 rc = usbat_multiple_write(us, registers, command, 3);
921 if (rc != USB_STOR_XFER_GOOD) { 935 if (rc != USB_STOR_XFER_GOOD) {
922 US_DEBUGP("usbat_flash_get_sector_count: Gah! identify_device failed\n"); 936 US_DEBUGP("usbat_flash_get_sector_count: Gah! identify_device failed\n");
@@ -924,7 +938,7 @@ static int usbat_flash_get_sector_count(struct us_data *us,
924 goto leave; 938 goto leave;
925 } 939 }
926 940
927 // Read device status 941 /* Read device status */
928 if (usbat_get_status(us, &status) != USB_STOR_XFER_GOOD) { 942 if (usbat_get_status(us, &status) != USB_STOR_XFER_GOOD) {
929 rc = USB_STOR_TRANSPORT_ERROR; 943 rc = USB_STOR_TRANSPORT_ERROR;
930 goto leave; 944 goto leave;
@@ -932,7 +946,7 @@ static int usbat_flash_get_sector_count(struct us_data *us,
932 946
933 msleep(100); 947 msleep(100);
934 948
935 // Read the device identification data 949 /* Read the device identification data */
936 rc = usbat_read_block(us, reply, 512); 950 rc = usbat_read_block(us, reply, 512);
937 if (rc != USB_STOR_TRANSPORT_GOOD) 951 if (rc != USB_STOR_TRANSPORT_GOOD)
938 goto leave; 952 goto leave;
@@ -977,19 +991,23 @@ static int usbat_flash_read_data(struct us_data *us,
977 if (result != USB_STOR_TRANSPORT_GOOD) 991 if (result != USB_STOR_TRANSPORT_GOOD)
978 return result; 992 return result;
979 993
980 // we're working in LBA mode. according to the ATA spec, 994 /*
981 // we can support up to 28-bit addressing. I don't know if Jumpshot 995 * we're working in LBA mode. according to the ATA spec,
982 // supports beyond 24-bit addressing. It's kind of hard to test 996 * we can support up to 28-bit addressing. I don't know if Jumpshot
983 // since it requires > 8GB CF card. 997 * supports beyond 24-bit addressing. It's kind of hard to test
998 * since it requires > 8GB CF card.
999 */
984 1000
985 if (sector > 0x0FFFFFFF) 1001 if (sector > 0x0FFFFFFF)
986 return USB_STOR_TRANSPORT_ERROR; 1002 return USB_STOR_TRANSPORT_ERROR;
987 1003
988 totallen = sectors * info->ssize; 1004 totallen = sectors * info->ssize;
989 1005
990 // Since we don't read more than 64 KB at a time, we have to create 1006 /*
991 // a bounce buffer and move the data a piece at a time between the 1007 * Since we don't read more than 64 KB at a time, we have to create
992 // bounce buffer and the actual transfer buffer. 1008 * a bounce buffer and move the data a piece at a time between the
1009 * bounce buffer and the actual transfer buffer.
1010 */
993 1011
994 alloclen = min(totallen, 65536u); 1012 alloclen = min(totallen, 65536u);
995 buffer = kmalloc(alloclen, GFP_NOIO); 1013 buffer = kmalloc(alloclen, GFP_NOIO);
@@ -997,27 +1015,29 @@ static int usbat_flash_read_data(struct us_data *us,
997 return USB_STOR_TRANSPORT_ERROR; 1015 return USB_STOR_TRANSPORT_ERROR;
998 1016
999 do { 1017 do {
1000 // loop, never allocate or transfer more than 64k at once 1018 /*
1001 // (min(128k, 255*info->ssize) is the real limit) 1019 * loop, never allocate or transfer more than 64k at once
1020 * (min(128k, 255*info->ssize) is the real limit)
1021 */
1002 len = min(totallen, alloclen); 1022 len = min(totallen, alloclen);
1003 thistime = (len / info->ssize) & 0xff; 1023 thistime = (len / info->ssize) & 0xff;
1004 1024
1005 // ATAPI command 0x20 (READ SECTORS) 1025 /* ATA command 0x20 (READ SECTORS) */
1006 usbat_pack_atapi_sector_cmd(command, thistime, sector, 0x20); 1026 usbat_pack_ata_sector_cmd(command, thistime, sector, 0x20);
1007 1027
1008 // Write/execute ATAPI read command 1028 /* Write/execute ATA read command */
1009 result = usbat_multiple_write(us, registers, command, 7); 1029 result = usbat_multiple_write(us, registers, command, 7);
1010 if (result != USB_STOR_TRANSPORT_GOOD) 1030 if (result != USB_STOR_TRANSPORT_GOOD)
1011 goto leave; 1031 goto leave;
1012 1032
1013 // Read the data we just requested 1033 /* Read the data we just requested */
1014 result = usbat_read_blocks(us, buffer, len); 1034 result = usbat_read_blocks(us, buffer, len);
1015 if (result != USB_STOR_TRANSPORT_GOOD) 1035 if (result != USB_STOR_TRANSPORT_GOOD)
1016 goto leave; 1036 goto leave;
1017 1037
1018 US_DEBUGP("usbat_flash_read_data: %d bytes\n", len); 1038 US_DEBUGP("usbat_flash_read_data: %d bytes\n", len);
1019 1039
1020 // Store the data in the transfer buffer 1040 /* Store the data in the transfer buffer */
1021 usb_stor_access_xfer_buf(buffer, len, us->srb, 1041 usb_stor_access_xfer_buf(buffer, len, us->srb,
1022 &sg_idx, &sg_offset, TO_XFER_BUF); 1042 &sg_idx, &sg_offset, TO_XFER_BUF);
1023 1043
@@ -1061,19 +1081,23 @@ static int usbat_flash_write_data(struct us_data *us,
1061 if (result != USB_STOR_TRANSPORT_GOOD) 1081 if (result != USB_STOR_TRANSPORT_GOOD)
1062 return result; 1082 return result;
1063 1083
1064 // we're working in LBA mode. according to the ATA spec, 1084 /*
1065 // we can support up to 28-bit addressing. I don't know if Jumpshot 1085 * we're working in LBA mode. according to the ATA spec,
1066 // supports beyond 24-bit addressing. It's kind of hard to test 1086 * we can support up to 28-bit addressing. I don't know if the device
1067 // since it requires > 8GB CF card. 1087 * supports beyond 24-bit addressing. It's kind of hard to test
1088 * since it requires > 8GB media.
1089 */
1068 1090
1069 if (sector > 0x0FFFFFFF) 1091 if (sector > 0x0FFFFFFF)
1070 return USB_STOR_TRANSPORT_ERROR; 1092 return USB_STOR_TRANSPORT_ERROR;
1071 1093
1072 totallen = sectors * info->ssize; 1094 totallen = sectors * info->ssize;
1073 1095
1074 // Since we don't write more than 64 KB at a time, we have to create 1096 /*
1075 // a bounce buffer and move the data a piece at a time between the 1097 * Since we don't write more than 64 KB at a time, we have to create
1076 // bounce buffer and the actual transfer buffer. 1098 * a bounce buffer and move the data a piece at a time between the
1099 * bounce buffer and the actual transfer buffer.
1100 */
1077 1101
1078 alloclen = min(totallen, 65536u); 1102 alloclen = min(totallen, 65536u);
1079 buffer = kmalloc(alloclen, GFP_NOIO); 1103 buffer = kmalloc(alloclen, GFP_NOIO);
@@ -1081,24 +1105,26 @@ static int usbat_flash_write_data(struct us_data *us,
1081 return USB_STOR_TRANSPORT_ERROR; 1105 return USB_STOR_TRANSPORT_ERROR;
1082 1106
1083 do { 1107 do {
1084 // loop, never allocate or transfer more than 64k at once 1108 /*
1085 // (min(128k, 255*info->ssize) is the real limit) 1109 * loop, never allocate or transfer more than 64k at once
1110 * (min(128k, 255*info->ssize) is the real limit)
1111 */
1086 len = min(totallen, alloclen); 1112 len = min(totallen, alloclen);
1087 thistime = (len / info->ssize) & 0xff; 1113 thistime = (len / info->ssize) & 0xff;
1088 1114
1089 // Get the data from the transfer buffer 1115 /* Get the data from the transfer buffer */
1090 usb_stor_access_xfer_buf(buffer, len, us->srb, 1116 usb_stor_access_xfer_buf(buffer, len, us->srb,
1091 &sg_idx, &sg_offset, FROM_XFER_BUF); 1117 &sg_idx, &sg_offset, FROM_XFER_BUF);
1092 1118
1093 // ATAPI command 0x30 (WRITE SECTORS) 1119 /* ATA command 0x30 (WRITE SECTORS) */
1094 usbat_pack_atapi_sector_cmd(command, thistime, sector, 0x30); 1120 usbat_pack_ata_sector_cmd(command, thistime, sector, 0x30);
1095 1121
1096 // Write/execute ATAPI write command 1122 /* Write/execute ATA write command */
1097 result = usbat_multiple_write(us, registers, command, 7); 1123 result = usbat_multiple_write(us, registers, command, 7);
1098 if (result != USB_STOR_TRANSPORT_GOOD) 1124 if (result != USB_STOR_TRANSPORT_GOOD)
1099 goto leave; 1125 goto leave;
1100 1126
1101 // Write the data 1127 /* Write the data */
1102 result = usbat_write_blocks(us, buffer, len); 1128 result = usbat_write_blocks(us, buffer, len);
1103 if (result != USB_STOR_TRANSPORT_GOOD) 1129 if (result != USB_STOR_TRANSPORT_GOOD)
1104 goto leave; 1130 goto leave;
@@ -1169,42 +1195,44 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1169 srb->transfersize); 1195 srb->transfersize);
1170 } 1196 }
1171 1197
1172 // Since we only read in one block at a time, we have to create 1198 /*
1173 // a bounce buffer and move the data a piece at a time between the 1199 * Since we only read in one block at a time, we have to create
1174 // bounce buffer and the actual transfer buffer. 1200 * a bounce buffer and move the data a piece at a time between the
1201 * bounce buffer and the actual transfer buffer.
1202 */
1175 1203
1176 len = (65535/srb->transfersize) * srb->transfersize; 1204 len = (65535/srb->transfersize) * srb->transfersize;
1177 US_DEBUGP("Max read is %d bytes\n", len); 1205 US_DEBUGP("Max read is %d bytes\n", len);
1178 len = min(len, srb->request_bufflen); 1206 len = min(len, srb->request_bufflen);
1179 buffer = kmalloc(len, GFP_NOIO); 1207 buffer = kmalloc(len, GFP_NOIO);
1180 if (buffer == NULL) // bloody hell! 1208 if (buffer == NULL) /* bloody hell! */
1181 return USB_STOR_TRANSPORT_FAILED; 1209 return USB_STOR_TRANSPORT_FAILED;
1182 sector = short_pack(data[7+3], data[7+2]); 1210 sector = short_pack(data[7+3], data[7+2]);
1183 sector <<= 16; 1211 sector <<= 16;
1184 sector |= short_pack(data[7+5], data[7+4]); 1212 sector |= short_pack(data[7+5], data[7+4]);
1185 transferred = 0; 1213 transferred = 0;
1186 1214
1187 sg_segment = 0; // for keeping track of where we are in 1215 sg_segment = 0; /* for keeping track of where we are in */
1188 sg_offset = 0; // the scatter/gather list 1216 sg_offset = 0; /* the scatter/gather list */
1189 1217
1190 while (transferred != srb->request_bufflen) { 1218 while (transferred != srb->request_bufflen) {
1191 1219
1192 if (len > srb->request_bufflen - transferred) 1220 if (len > srb->request_bufflen - transferred)
1193 len = srb->request_bufflen - transferred; 1221 len = srb->request_bufflen - transferred;
1194 1222
1195 data[3] = len&0xFF; // (cylL) = expected length (L) 1223 data[3] = len&0xFF; /* (cylL) = expected length (L) */
1196 data[4] = (len>>8)&0xFF; // (cylH) = expected length (H) 1224 data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */
1197 1225
1198 // Fix up the SCSI command sector and num sectors 1226 /* Fix up the SCSI command sector and num sectors */
1199 1227
1200 data[7+2] = MSB_of(sector>>16); // SCSI command sector 1228 data[7+2] = MSB_of(sector>>16); /* SCSI command sector */
1201 data[7+3] = LSB_of(sector>>16); 1229 data[7+3] = LSB_of(sector>>16);
1202 data[7+4] = MSB_of(sector&0xFFFF); 1230 data[7+4] = MSB_of(sector&0xFFFF);
1203 data[7+5] = LSB_of(sector&0xFFFF); 1231 data[7+5] = LSB_of(sector&0xFFFF);
1204 if (data[7+0] == GPCMD_READ_CD) 1232 if (data[7+0] == GPCMD_READ_CD)
1205 data[7+6] = 0; 1233 data[7+6] = 0;
1206 data[7+7] = MSB_of(len / srb->transfersize); // SCSI command 1234 data[7+7] = MSB_of(len / srb->transfersize); /* SCSI command */
1207 data[7+8] = LSB_of(len / srb->transfersize); // num sectors 1235 data[7+8] = LSB_of(len / srb->transfersize); /* num sectors */
1208 1236
1209 result = usbat_hp8200e_rw_block_test(us, USBAT_ATA, 1237 result = usbat_hp8200e_rw_block_test(us, USBAT_ATA,
1210 registers, data, 19, 1238 registers, data, 19,
@@ -1217,16 +1245,16 @@ static int usbat_hp8200e_handle_read10(struct us_data *us,
1217 if (result != USB_STOR_TRANSPORT_GOOD) 1245 if (result != USB_STOR_TRANSPORT_GOOD)
1218 break; 1246 break;
1219 1247
1220 // Store the data in the transfer buffer 1248 /* Store the data in the transfer buffer */
1221 usb_stor_access_xfer_buf(buffer, len, srb, 1249 usb_stor_access_xfer_buf(buffer, len, srb,
1222 &sg_segment, &sg_offset, TO_XFER_BUF); 1250 &sg_segment, &sg_offset, TO_XFER_BUF);
1223 1251
1224 // Update the amount transferred and the sector number 1252 /* Update the amount transferred and the sector number */
1225 1253
1226 transferred += len; 1254 transferred += len;
1227 sector += len / srb->transfersize; 1255 sector += len / srb->transfersize;
1228 1256
1229 } // while transferred != srb->request_bufflen 1257 } /* while transferred != srb->request_bufflen */
1230 1258
1231 kfree(buffer); 1259 kfree(buffer);
1232 return result; 1260 return result;
@@ -1237,7 +1265,7 @@ static int usbat_select_and_test_registers(struct us_data *us)
1237 int selector; 1265 int selector;
1238 unsigned char *status = us->iobuf; 1266 unsigned char *status = us->iobuf;
1239 1267
1240 // try device = master, then device = slave. 1268 /* try device = master, then device = slave. */
1241 for (selector = 0xA0; selector <= 0xB0; selector += 0x10) { 1269 for (selector = 0xA0; selector <= 0xB0; selector += 0x10) {
1242 if (usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) != 1270 if (usbat_write(us, USBAT_ATA, USBAT_ATA_DEVICE, selector) !=
1243 USB_STOR_XFER_GOOD) 1271 USB_STOR_XFER_GOOD)
@@ -1298,7 +1326,7 @@ int init_usbat(struct us_data *us)
1298 memset(us->extra, 0, sizeof(struct usbat_info)); 1326 memset(us->extra, 0, sizeof(struct usbat_info));
1299 info = (struct usbat_info *) (us->extra); 1327 info = (struct usbat_info *) (us->extra);
1300 1328
1301 // Enable peripheral control signals 1329 /* Enable peripheral control signals */
1302 rc = usbat_write_user_io(us, 1330 rc = usbat_write_user_io(us,
1303 USBAT_UIO_OE1 | USBAT_UIO_OE0, 1331 USBAT_UIO_OE1 | USBAT_UIO_OE0,
1304 USBAT_UIO_EPAD | USBAT_UIO_1); 1332 USBAT_UIO_EPAD | USBAT_UIO_1);
@@ -1337,7 +1365,7 @@ int init_usbat(struct us_data *us)
1337 1365
1338 US_DEBUGP("INIT 5\n"); 1366 US_DEBUGP("INIT 5\n");
1339 1367
1340 // Enable peripheral control signals and card detect 1368 /* Enable peripheral control signals and card detect */
1341 rc = usbat_device_enable_cdt(us); 1369 rc = usbat_device_enable_cdt(us);
1342 if (rc != USB_STOR_TRANSPORT_GOOD) 1370 if (rc != USB_STOR_TRANSPORT_GOOD)
1343 return rc; 1371 return rc;
@@ -1364,7 +1392,7 @@ int init_usbat(struct us_data *us)
1364 1392
1365 US_DEBUGP("INIT 9\n"); 1393 US_DEBUGP("INIT 9\n");
1366 1394
1367 // At this point, we need to detect which device we are using 1395 /* At this point, we need to detect which device we are using */
1368 if (usbat_set_transport(us, info)) 1396 if (usbat_set_transport(us, info))
1369 return USB_STOR_TRANSPORT_ERROR; 1397 return USB_STOR_TRANSPORT_ERROR;
1370 1398
@@ -1414,10 +1442,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1414 data[0] = 0x00; 1442 data[0] = 0x00;
1415 data[1] = 0x00; 1443 data[1] = 0x00;
1416 data[2] = 0x00; 1444 data[2] = 0x00;
1417 data[3] = len&0xFF; // (cylL) = expected length (L) 1445 data[3] = len&0xFF; /* (cylL) = expected length (L) */
1418 data[4] = (len>>8)&0xFF; // (cylH) = expected length (H) 1446 data[4] = (len>>8)&0xFF; /* (cylH) = expected length (H) */
1419 data[5] = 0xB0; // (device sel) = slave 1447 data[5] = 0xB0; /* (device sel) = slave */
1420 data[6] = 0xA0; // (command) = ATA PACKET COMMAND 1448 data[6] = 0xA0; /* (command) = ATA PACKET COMMAND */
1421 1449
1422 for (i=7; i<19; i++) { 1450 for (i=7; i<19; i++) {
1423 registers[i] = 0x10; 1451 registers[i] = 0x10;
@@ -1466,13 +1494,15 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1466 return result; 1494 return result;
1467 } 1495 }
1468 1496
1469 // Write the 12-byte command header. 1497 /*
1470 1498 * Write the 12-byte command header.
1471 // If the command is BLANK then set the timer for 75 minutes. 1499 *
1472 // Otherwise set it for 10 minutes. 1500 * If the command is BLANK then set the timer for 75 minutes.
1473 1501 * Otherwise set it for 10 minutes.
1474 // NOTE: THE 8200 DOCUMENTATION STATES THAT BLANKING A CDRW 1502 *
1475 // AT SPEED 4 IS UNRELIABLE!!! 1503 * NOTE: THE 8200 DOCUMENTATION STATES THAT BLANKING A CDRW
1504 * AT SPEED 4 IS UNRELIABLE!!!
1505 */
1476 1506
1477 if ( (result = usbat_write_block(us, 1507 if ( (result = usbat_write_block(us,
1478 USBAT_ATA, srb->cmnd, 12, 1508 USBAT_ATA, srb->cmnd, 12,
@@ -1481,19 +1511,18 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1481 return result; 1511 return result;
1482 } 1512 }
1483 1513
1484 // If there is response data to be read in 1514 /* If there is response data to be read in then do it here. */
1485 // then do it here.
1486 1515
1487 if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) { 1516 if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) {
1488 1517
1489 // How many bytes to read in? Check cylL register 1518 /* How many bytes to read in? Check cylL register */
1490 1519
1491 if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) != 1520 if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=
1492 USB_STOR_XFER_GOOD) { 1521 USB_STOR_XFER_GOOD) {
1493 return USB_STOR_TRANSPORT_ERROR; 1522 return USB_STOR_TRANSPORT_ERROR;
1494 } 1523 }
1495 1524
1496 if (len > 0xFF) { // need to read cylH also 1525 if (len > 0xFF) { /* need to read cylH also */
1497 len = *status; 1526 len = *status;
1498 if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) != 1527 if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) !=
1499 USB_STOR_XFER_GOOD) { 1528 USB_STOR_XFER_GOOD) {
@@ -1556,13 +1585,16 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1556 if (rc != USB_STOR_TRANSPORT_GOOD) 1585 if (rc != USB_STOR_TRANSPORT_GOOD)
1557 return rc; 1586 return rc;
1558 1587
1559 info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec 1588 /* hard coded 512 byte sectors as per ATA spec */
1589 info->ssize = 0x200;
1560 US_DEBUGP("usbat_flash_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", 1590 US_DEBUGP("usbat_flash_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n",
1561 info->sectors, info->ssize); 1591 info->sectors, info->ssize);
1562 1592
1563 // build the reply 1593 /*
1564 // note: must return the sector number of the last sector, 1594 * build the reply
1565 // *not* the total number of sectors 1595 * note: must return the sector number of the last sector,
1596 * *not* the total number of sectors
1597 */
1566 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); 1598 ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1);
1567 ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize); 1599 ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize);
1568 usb_stor_set_xfer_buf(ptr, 8, srb); 1600 usb_stor_set_xfer_buf(ptr, 8, srb);
@@ -1586,7 +1618,9 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1586 } 1618 }
1587 1619
1588 if (srb->cmnd[0] == READ_12) { 1620 if (srb->cmnd[0] == READ_12) {
1589 // I don't think we'll ever see a READ_12 but support it anyway... 1621 /*
1622 * I don't think we'll ever see a READ_12 but support it anyway
1623 */
1590 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 1624 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
1591 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 1625 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
1592 1626
@@ -1608,7 +1642,9 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1608 } 1642 }
1609 1643
1610 if (srb->cmnd[0] == WRITE_12) { 1644 if (srb->cmnd[0] == WRITE_12) {
1611 // I don't think we'll ever see a WRITE_12 but support it anyway... 1645 /*
1646 * I don't think we'll ever see a WRITE_12 but support it anyway
1647 */
1612 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 1648 block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) |
1613 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 1649 ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5]));
1614 1650
@@ -1645,8 +1681,10 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
1645 } 1681 }
1646 1682
1647 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { 1683 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
1648 // sure. whatever. not like we can stop the user from popping 1684 /*
1649 // the media out of the device (no locking doors, etc) 1685 * sure. whatever. not like we can stop the user from popping
1686 * the media out of the device (no locking doors, etc)
1687 */
1650 return USB_STOR_TRANSPORT_GOOD; 1688 return USB_STOR_TRANSPORT_GOOD;
1651 } 1689 }
1652 1690
diff --git a/drivers/usb/storage/shuttle_usbat.h b/drivers/usb/storage/shuttle_usbat.h
index 5b8e867e2ae5..25e7d8b340b8 100644
--- a/drivers/usb/storage/shuttle_usbat.h
+++ b/drivers/usb/storage/shuttle_usbat.h
@@ -55,8 +55,8 @@
55#define USBAT_UIO_WRITE 0 55#define USBAT_UIO_WRITE 0
56 56
57/* Qualifier bits */ 57/* Qualifier bits */
58#define USBAT_QUAL_FCQ 0x20 // full compare 58#define USBAT_QUAL_FCQ 0x20 /* full compare */
59#define USBAT_QUAL_ALQ 0x10 // auto load subcount 59#define USBAT_QUAL_ALQ 0x10 /* auto load subcount */
60 60
61/* USBAT Flash Media status types */ 61/* USBAT Flash Media status types */
62#define USBAT_FLASH_MEDIA_NONE 0 62#define USBAT_FLASH_MEDIA_NONE 0
@@ -67,39 +67,39 @@
67#define USBAT_FLASH_MEDIA_CHANGED 1 67#define USBAT_FLASH_MEDIA_CHANGED 1
68 68
69/* USBAT ATA registers */ 69/* USBAT ATA registers */
70#define USBAT_ATA_DATA 0x10 // read/write data (R/W) 70#define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */
71#define USBAT_ATA_FEATURES 0x11 // set features (W) 71#define USBAT_ATA_FEATURES 0x11 /* set features (W) */
72#define USBAT_ATA_ERROR 0x11 // error (R) 72#define USBAT_ATA_ERROR 0x11 /* error (R) */
73#define USBAT_ATA_SECCNT 0x12 // sector count (R/W) 73#define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */
74#define USBAT_ATA_SECNUM 0x13 // sector number (R/W) 74#define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */
75#define USBAT_ATA_LBA_ME 0x14 // cylinder low (R/W) 75#define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */
76#define USBAT_ATA_LBA_HI 0x15 // cylinder high (R/W) 76#define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */
77#define USBAT_ATA_DEVICE 0x16 // head/device selection (R/W) 77#define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */
78#define USBAT_ATA_STATUS 0x17 // device status (R) 78#define USBAT_ATA_STATUS 0x17 /* device status (R) */
79#define USBAT_ATA_CMD 0x17 // device command (W) 79#define USBAT_ATA_CMD 0x17 /* device command (W) */
80#define USBAT_ATA_ALTSTATUS 0x0E // status (no clear IRQ) (R) 80#define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */
81 81
82/* USBAT User I/O Data registers */ 82/* USBAT User I/O Data registers */
83#define USBAT_UIO_EPAD 0x80 // Enable Peripheral Control Signals 83#define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */
84#define USBAT_UIO_CDT 0x40 // Card Detect (Read Only) 84#define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */
85 // CDT = ACKD & !UI1 & !UI0 85 /* CDT = ACKD & !UI1 & !UI0 */
86#define USBAT_UIO_1 0x20 // I/O 1 86#define USBAT_UIO_1 0x20 /* I/O 1 */
87#define USBAT_UIO_0 0x10 // I/O 0 87#define USBAT_UIO_0 0x10 /* I/O 0 */
88#define USBAT_UIO_EPP_ATA 0x08 // 1=EPP mode, 0=ATA mode 88#define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */
89#define USBAT_UIO_UI1 0x04 // Input 1 89#define USBAT_UIO_UI1 0x04 /* Input 1 */
90#define USBAT_UIO_UI0 0x02 // Input 0 90#define USBAT_UIO_UI0 0x02 /* Input 0 */
91#define USBAT_UIO_INTR_ACK 0x01 // Interrupt (ATA & ISA)/Acknowledge (EPP) 91#define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */
92 92
93/* USBAT User I/O Enable registers */ 93/* USBAT User I/O Enable registers */
94#define USBAT_UIO_DRVRST 0x80 // Reset Peripheral 94#define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */
95#define USBAT_UIO_ACKD 0x40 // Enable Card Detect 95#define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */
96#define USBAT_UIO_OE1 0x20 // I/O 1 set=output/clr=input 96#define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */
97 // If ACKD=1, set OE1 to 1 also. 97 /* If ACKD=1, set OE1 to 1 also. */
98#define USBAT_UIO_OE0 0x10 // I/O 0 set=output/clr=input 98#define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */
99#define USBAT_UIO_ADPRST 0x01 // Reset SCM chip 99#define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */
100 100
101/* USBAT Features */ 101/* USBAT Features */
102#define USBAT_FEAT_ETEN 0x80 // External trigger enable 102#define USBAT_FEAT_ETEN 0x80 /* External trigger enable */
103#define USBAT_FEAT_U1 0x08 103#define USBAT_FEAT_U1 0x08
104#define USBAT_FEAT_U0 0x04 104#define USBAT_FEAT_U0 0x04
105#define USBAT_FEAT_ET1 0x02 105#define USBAT_FEAT_ET1 0x02
@@ -112,12 +112,12 @@ struct usbat_info {
112 int devicetype; 112 int devicetype;
113 113
114 /* Used for Flash readers only */ 114 /* Used for Flash readers only */
115 unsigned long sectors; // total sector count 115 unsigned long sectors; /* total sector count */
116 unsigned long ssize; // sector size in bytes 116 unsigned long ssize; /* sector size in bytes */
117 117
118 unsigned char sense_key; 118 unsigned char sense_key;
119 unsigned long sense_asc; // additional sense code 119 unsigned long sense_asc; /* additional sense code */
120 unsigned long sense_ascq; // additional sense code qualifier 120 unsigned long sense_ascq; /* additional sense code qualifier */
121}; 121};
122 122
123#endif 123#endif
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index c1ba5301ebfc..7ca896a342e3 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -636,11 +636,11 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
636 636
637 /* use the new buffer we have */ 637 /* use the new buffer we have */
638 old_request_buffer = srb->request_buffer; 638 old_request_buffer = srb->request_buffer;
639 srb->request_buffer = srb->sense_buffer; 639 srb->request_buffer = us->sensebuf;
640 640
641 /* set the buffer length for transfer */ 641 /* set the buffer length for transfer */
642 old_request_bufflen = srb->request_bufflen; 642 old_request_bufflen = srb->request_bufflen;
643 srb->request_bufflen = 18; 643 srb->request_bufflen = US_SENSE_SIZE;
644 644
645 /* set up for no scatter-gather use */ 645 /* set up for no scatter-gather use */
646 old_sg = srb->use_sg; 646 old_sg = srb->use_sg;
@@ -652,6 +652,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
652 temp_result = us->transport(us->srb, us); 652 temp_result = us->transport(us->srb, us);
653 653
654 /* let's clean up right away */ 654 /* let's clean up right away */
655 memcpy(srb->sense_buffer, us->sensebuf, US_SENSE_SIZE);
655 srb->resid = old_resid; 656 srb->resid = old_resid;
656 srb->request_buffer = old_request_buffer; 657 srb->request_buffer = old_request_buffer;
657 srb->request_bufflen = old_request_bufflen; 658 srb->request_bufflen = old_request_bufflen;
@@ -923,6 +924,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
923 int result; 924 int result;
924 925
925 /* issue the command */ 926 /* issue the command */
927 us->iobuf[0] = 0;
926 result = usb_stor_control_msg(us, us->recv_ctrl_pipe, 928 result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
927 US_BULK_GET_MAX_LUN, 929 US_BULK_GET_MAX_LUN,
928 USB_DIR_IN | USB_TYPE_CLASS | 930 USB_DIR_IN | USB_TYPE_CLASS |
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index 8d9e0663f8fe..0a362cc781ad 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -50,7 +50,7 @@
50#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */ 50#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */
51#define US_PR_BULK 0x50 /* bulk only */ 51#define US_PR_BULK 0x50 /* bulk only */
52#ifdef CONFIG_USB_STORAGE_USBAT 52#ifdef CONFIG_USB_STORAGE_USBAT
53#define US_PR_SCM_ATAPI 0x80 /* SCM-ATAPI bridge */ 53#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */
54#endif 54#endif
55#ifdef CONFIG_USB_STORAGE_SDDR09 55#ifdef CONFIG_USB_STORAGE_SDDR09
56#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */ 56#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index b79dad1b598c..9e926a8f2116 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -71,12 +71,12 @@ UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
71UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, 71UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
72 "HP", 72 "HP",
73 "CD-Writer+ 8200e", 73 "CD-Writer+ 8200e",
74 US_SC_8070, US_PR_SCM_ATAPI, init_usbat, 0), 74 US_SC_8070, US_PR_USBAT, init_usbat, 0),
75 75
76UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, 76UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
77 "HP", 77 "HP",
78 "CD-Writer+ CD-4e", 78 "CD-Writer+ CD-4e",
79 US_SC_8070, US_PR_SCM_ATAPI, init_usbat, 0), 79 US_SC_8070, US_PR_USBAT, init_usbat, 0),
80#endif 80#endif
81 81
82/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */ 82/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */
@@ -106,6 +106,13 @@ UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113,
106 US_SC_DEVICE, US_PR_DEVICE, NULL, 106 US_SC_DEVICE, US_PR_DEVICE, NULL,
107 US_FL_FIX_INQUIRY ), 107 US_FL_FIX_INQUIRY ),
108 108
109/* Reported by Stefan Werner <dustbln@gmx.de> */
110UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100,
111 "TrekStor",
112 "i.Beat Joy 2.0",
113 US_SC_DEVICE, US_PR_DEVICE, NULL,
114 US_FL_IGNORE_RESIDUE ),
115
109/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 116/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
110UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 117UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
111 "SMSC", 118 "SMSC",
@@ -244,6 +251,13 @@ UNUSUAL_DEV( 0x04da, 0x2372, 0x0000, 0x9999,
244 US_SC_DEVICE, US_PR_DEVICE, NULL, 251 US_SC_DEVICE, US_PR_DEVICE, NULL,
245 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ), 252 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
246 253
254/* Reported by Simeon Simeonov <simeonov_2000@yahoo.com> */
255UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999,
256 "LEICA",
257 "D-LUX Camera",
258 US_SC_DEVICE, US_PR_DEVICE, NULL,
259 US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
260
247/* Most of the following entries were developed with the help of 261/* Most of the following entries were developed with the help of
248 * Shuttle/SCM directly. 262 * Shuttle/SCM directly.
249 */ 263 */
@@ -333,9 +347,9 @@ UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
333 347
334#ifdef CONFIG_USB_STORAGE_USBAT 348#ifdef CONFIG_USB_STORAGE_USBAT
335UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 349UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
336 "SCM", 350 "Shuttle/SCM",
337 "SCM USBAT-02", 351 "USBAT-02",
338 US_SC_SCSI, US_PR_SCM_ATAPI, init_usbat, 352 US_SC_SCSI, US_PR_USBAT, init_usbat,
339 US_FL_SINGLE_LUN), 353 US_FL_SINGLE_LUN),
340#endif 354#endif
341 355
@@ -598,6 +612,16 @@ UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
598 US_SC_DEVICE, US_PR_DEVICE, NULL, 612 US_SC_DEVICE, US_PR_DEVICE, NULL,
599 US_FL_FIX_CAPACITY ), 613 US_FL_FIX_CAPACITY ),
600 614
615/*
616 * Reported by Tyson Vinson <lornoss@gmail.com>
617 * This particular productId is the iPod Nano
618 */
619UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
620 "Apple",
621 "iPod",
622 US_SC_DEVICE, US_PR_DEVICE, NULL,
623 US_FL_FIX_CAPACITY ),
624
601#ifdef CONFIG_USB_STORAGE_JUMPSHOT 625#ifdef CONFIG_USB_STORAGE_JUMPSHOT
602UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001, 626UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
603 "Lexar", 627 "Lexar",
@@ -702,6 +726,14 @@ UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200,
702 US_SC_SCSI, US_PR_CB, NULL, 726 US_SC_SCSI, US_PR_CB, NULL,
703 US_FL_SINGLE_LUN ), 727 US_FL_SINGLE_LUN ),
704 728
729#ifdef CONFIG_USB_STORAGE_USBAT
730UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
731 "Sandisk",
732 "ImageMate SDDR-05b",
733 US_SC_SCSI, US_PR_USBAT, init_usbat,
734 US_FL_SINGLE_LUN ),
735#endif
736
705UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, 737UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
706 "Sandisk", 738 "Sandisk",
707 "ImageMate SDDR-12", 739 "ImageMate SDDR-12",
@@ -724,7 +756,7 @@ UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
724#endif 756#endif
725 757
726/* Reported by Eero Volotinen <eero@ping-viini.org> */ 758/* Reported by Eero Volotinen <eero@ping-viini.org> */
727UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0406, 0x0406, 759UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999,
728 "Freecom Technologies", 760 "Freecom Technologies",
729 "FHD-Classic", 761 "FHD-Classic",
730 US_SC_DEVICE, US_PR_DEVICE, NULL, 762 US_SC_DEVICE, US_PR_DEVICE, NULL,
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index f9a9bfa1aef5..3847ebed2aa4 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -54,6 +54,7 @@
54#include <linux/module.h> 54#include <linux/module.h>
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/slab.h> 56#include <linux/slab.h>
57#include <linux/kthread.h>
57 58
58#include <scsi/scsi.h> 59#include <scsi/scsi.h>
59#include <scsi/scsi_cmnd.h> 60#include <scsi/scsi_cmnd.h>
@@ -111,11 +112,6 @@ static atomic_t total_threads = ATOMIC_INIT(0);
111static DECLARE_COMPLETION(threads_gone); 112static DECLARE_COMPLETION(threads_gone);
112 113
113 114
114static int storage_probe(struct usb_interface *iface,
115 const struct usb_device_id *id);
116
117static void storage_disconnect(struct usb_interface *iface);
118
119/* The entries in this table, except for final ones here 115/* The entries in this table, except for final ones here
120 * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, 116 * (USB_MASS_STORAGE_CLASS and the empty entry), correspond,
121 * line for line with the entries of us_unsuaul_dev_list[]. 117 * line for line with the entries of us_unsuaul_dev_list[].
@@ -233,13 +229,40 @@ static struct us_unusual_dev us_unusual_dev_list[] = {
233 { NULL } 229 { NULL }
234}; 230};
235 231
236static struct usb_driver usb_storage_driver = { 232
237 .owner = THIS_MODULE, 233#ifdef CONFIG_PM /* Minimal support for suspend and resume */
238 .name = "usb-storage", 234
239 .probe = storage_probe, 235static int storage_suspend(struct usb_interface *iface, pm_message_t message)
240 .disconnect = storage_disconnect, 236{
241 .id_table = storage_usb_ids, 237 struct us_data *us = usb_get_intfdata(iface);
242}; 238
239 /* Wait until no command is running */
240 down(&us->dev_semaphore);
241
242 US_DEBUGP("%s\n", __FUNCTION__);
243 iface->dev.power.power_state.event = message.event;
244
245 /* When runtime PM is working, we'll set a flag to indicate
246 * whether we should autoresume when a SCSI request arrives. */
247
248 up(&us->dev_semaphore);
249 return 0;
250}
251
252static int storage_resume(struct usb_interface *iface)
253{
254 struct us_data *us = usb_get_intfdata(iface);
255
256 down(&us->dev_semaphore);
257
258 US_DEBUGP("%s\n", __FUNCTION__);
259 iface->dev.power.power_state.event = PM_EVENT_ON;
260
261 up(&us->dev_semaphore);
262 return 0;
263}
264
265#endif /* CONFIG_PM */
243 266
244/* 267/*
245 * fill_inquiry_response takes an unsigned char array (which must 268 * fill_inquiry_response takes an unsigned char array (which must
@@ -288,22 +311,7 @@ static int usb_stor_control_thread(void * __us)
288 struct us_data *us = (struct us_data *)__us; 311 struct us_data *us = (struct us_data *)__us;
289 struct Scsi_Host *host = us_to_host(us); 312 struct Scsi_Host *host = us_to_host(us);
290 313
291 lock_kernel();
292
293 /*
294 * This thread doesn't need any user-level access,
295 * so get rid of all our resources.
296 */
297 daemonize("usb-storage");
298 current->flags |= PF_NOFREEZE; 314 current->flags |= PF_NOFREEZE;
299 unlock_kernel();
300
301 /* acquire a reference to the host, so it won't be deallocated
302 * until we're ready to exit */
303 scsi_host_get(host);
304
305 /* signal that we've started the thread */
306 complete(&(us->notify));
307 315
308 for(;;) { 316 for(;;) {
309 US_DEBUGP("*** thread sleeping.\n"); 317 US_DEBUGP("*** thread sleeping.\n");
@@ -467,6 +475,12 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
467 US_DEBUGP("I/O buffer allocation failed\n"); 475 US_DEBUGP("I/O buffer allocation failed\n");
468 return -ENOMEM; 476 return -ENOMEM;
469 } 477 }
478
479 us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
480 if (!us->sensebuf) {
481 US_DEBUGP("Sense buffer allocation failed\n");
482 return -ENOMEM;
483 }
470 return 0; 484 return 0;
471} 485}
472 486
@@ -555,8 +569,8 @@ static int get_transport(struct us_data *us)
555 break; 569 break;
556 570
557#ifdef CONFIG_USB_STORAGE_USBAT 571#ifdef CONFIG_USB_STORAGE_USBAT
558 case US_PR_SCM_ATAPI: 572 case US_PR_USBAT:
559 us->transport_name = "SCM/ATAPI"; 573 us->transport_name = "Shuttle USBAT";
560 us->transport = usbat_transport; 574 us->transport = usbat_transport;
561 us->transport_reset = usb_stor_CB_reset; 575 us->transport_reset = usb_stor_CB_reset;
562 us->max_lun = 1; 576 us->max_lun = 1;
@@ -740,6 +754,7 @@ static int get_pipes(struct us_data *us)
740static int usb_stor_acquire_resources(struct us_data *us) 754static int usb_stor_acquire_resources(struct us_data *us)
741{ 755{
742 int p; 756 int p;
757 struct task_struct *th;
743 758
744 us->current_urb = usb_alloc_urb(0, GFP_KERNEL); 759 us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
745 if (!us->current_urb) { 760 if (!us->current_urb) {
@@ -747,38 +762,28 @@ static int usb_stor_acquire_resources(struct us_data *us)
747 return -ENOMEM; 762 return -ENOMEM;
748 } 763 }
749 764
750 /* Lock the device while we carry out the next two operations */
751 down(&us->dev_semaphore);
752
753 /* For bulk-only devices, determine the max LUN value */
754 if (us->protocol == US_PR_BULK) {
755 p = usb_stor_Bulk_max_lun(us);
756 if (p < 0) {
757 up(&us->dev_semaphore);
758 return p;
759 }
760 us->max_lun = p;
761 }
762
763 /* Just before we start our control thread, initialize 765 /* Just before we start our control thread, initialize
764 * the device if it needs initialization */ 766 * the device if it needs initialization */
765 if (us->unusual_dev->initFunction) 767 if (us->unusual_dev->initFunction) {
766 us->unusual_dev->initFunction(us); 768 p = us->unusual_dev->initFunction(us);
767 769 if (p)
768 up(&us->dev_semaphore); 770 return p;
771 }
769 772
770 /* Start up our control thread */ 773 /* Start up our control thread */
771 p = kernel_thread(usb_stor_control_thread, us, CLONE_VM); 774 th = kthread_create(usb_stor_control_thread, us, "usb-storage");
772 if (p < 0) { 775 if (IS_ERR(th)) {
773 printk(KERN_WARNING USB_STORAGE 776 printk(KERN_WARNING USB_STORAGE
774 "Unable to start control thread\n"); 777 "Unable to start control thread\n");
775 return p; 778 return PTR_ERR(th);
776 } 779 }
777 us->pid = p;
778 atomic_inc(&total_threads);
779 780
780 /* Wait for the thread to start */ 781 /* Take a reference to the host for the control thread and
781 wait_for_completion(&(us->notify)); 782 * count it among all the threads we have launched. Then
783 * start it up. */
784 scsi_host_get(us_to_host(us));
785 atomic_inc(&total_threads);
786 wake_up_process(th);
782 787
783 return 0; 788 return 0;
784} 789}
@@ -812,6 +817,8 @@ static void dissociate_dev(struct us_data *us)
812{ 817{
813 US_DEBUGP("-- %s\n", __FUNCTION__); 818 US_DEBUGP("-- %s\n", __FUNCTION__);
814 819
820 kfree(us->sensebuf);
821
815 /* Free the device-related DMA-mapped buffers */ 822 /* Free the device-related DMA-mapped buffers */
816 if (us->cr) 823 if (us->cr)
817 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, 824 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr,
@@ -872,21 +879,6 @@ static int usb_stor_scan_thread(void * __us)
872{ 879{
873 struct us_data *us = (struct us_data *)__us; 880 struct us_data *us = (struct us_data *)__us;
874 881
875 /*
876 * This thread doesn't need any user-level access,
877 * so get rid of all our resources.
878 */
879 lock_kernel();
880 daemonize("usb-stor-scan");
881 unlock_kernel();
882
883 /* Acquire a reference to the host, so it won't be deallocated
884 * until we're ready to exit */
885 scsi_host_get(us_to_host(us));
886
887 /* Signal that we've started the thread */
888 complete(&(us->notify));
889
890 printk(KERN_DEBUG 882 printk(KERN_DEBUG
891 "usb-storage: device found at %d\n", us->pusb_dev->devnum); 883 "usb-storage: device found at %d\n", us->pusb_dev->devnum);
892 884
@@ -904,6 +896,14 @@ retry:
904 896
905 /* If the device is still connected, perform the scanning */ 897 /* If the device is still connected, perform the scanning */
906 if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 898 if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
899
900 /* For bulk-only devices, determine the max LUN value */
901 if (us->protocol == US_PR_BULK &&
902 !(us->flags & US_FL_SINGLE_LUN)) {
903 down(&us->dev_semaphore);
904 us->max_lun = usb_stor_Bulk_max_lun(us);
905 up(&us->dev_semaphore);
906 }
907 scsi_scan_host(us_to_host(us)); 907 scsi_scan_host(us_to_host(us));
908 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 908 printk(KERN_DEBUG "usb-storage: device scan complete\n");
909 909
@@ -923,6 +923,7 @@ static int storage_probe(struct usb_interface *intf,
923 struct us_data *us; 923 struct us_data *us;
924 const int id_index = id - storage_usb_ids; 924 const int id_index = id - storage_usb_ids;
925 int result; 925 int result;
926 struct task_struct *th;
926 927
927 US_DEBUGP("USB Mass Storage device detected\n"); 928 US_DEBUGP("USB Mass Storage device detected\n");
928 929
@@ -1003,17 +1004,21 @@ static int storage_probe(struct usb_interface *intf,
1003 } 1004 }
1004 1005
1005 /* Start up the thread for delayed SCSI-device scanning */ 1006 /* Start up the thread for delayed SCSI-device scanning */
1006 result = kernel_thread(usb_stor_scan_thread, us, CLONE_VM); 1007 th = kthread_create(usb_stor_scan_thread, us, "usb-stor-scan");
1007 if (result < 0) { 1008 if (IS_ERR(th)) {
1008 printk(KERN_WARNING USB_STORAGE 1009 printk(KERN_WARNING USB_STORAGE
1009 "Unable to start the device-scanning thread\n"); 1010 "Unable to start the device-scanning thread\n");
1010 quiesce_and_remove_host(us); 1011 quiesce_and_remove_host(us);
1012 result = PTR_ERR(th);
1011 goto BadDevice; 1013 goto BadDevice;
1012 } 1014 }
1013 atomic_inc(&total_threads);
1014 1015
1015 /* Wait for the thread to start */ 1016 /* Take a reference to the host for the scanning thread and
1016 wait_for_completion(&(us->notify)); 1017 * count it among all the threads we have launched. Then
1018 * start it up. */
1019 scsi_host_get(us_to_host(us));
1020 atomic_inc(&total_threads);
1021 wake_up_process(th);
1017 1022
1018 return 0; 1023 return 0;
1019 1024
@@ -1038,6 +1043,18 @@ static void storage_disconnect(struct usb_interface *intf)
1038 * Initialization and registration 1043 * Initialization and registration
1039 ***********************************************************************/ 1044 ***********************************************************************/
1040 1045
1046static struct usb_driver usb_storage_driver = {
1047 .owner = THIS_MODULE,
1048 .name = "usb-storage",
1049 .probe = storage_probe,
1050 .disconnect = storage_disconnect,
1051#ifdef CONFIG_PM
1052 .suspend = storage_suspend,
1053 .resume = storage_resume,
1054#endif
1055 .id_table = storage_usb_ids,
1056};
1057
1041static int __init usb_stor_init(void) 1058static int __init usb_stor_init(void)
1042{ 1059{
1043 int retval; 1060 int retval;
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index a195adae57b6..98b09711a739 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -117,6 +117,7 @@ enum { US_DO_ALL_FLAGS };
117 */ 117 */
118 118
119#define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */ 119#define US_IOBUF_SIZE 64 /* Size of the DMA-mapped I/O buffer */
120#define US_SENSE_SIZE 18 /* Size of the autosense data buffer */
120 121
121typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); 122typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
122typedef int (*trans_reset)(struct us_data*); 123typedef int (*trans_reset)(struct us_data*);
@@ -160,14 +161,12 @@ struct us_data {
160 struct scsi_cmnd *srb; /* current srb */ 161 struct scsi_cmnd *srb; /* current srb */
161 unsigned int tag; /* current dCBWTag */ 162 unsigned int tag; /* current dCBWTag */
162 163
163 /* thread information */
164 int pid; /* control thread */
165
166 /* control and bulk communications data */ 164 /* control and bulk communications data */
167 struct urb *current_urb; /* USB requests */ 165 struct urb *current_urb; /* USB requests */
168 struct usb_ctrlrequest *cr; /* control requests */ 166 struct usb_ctrlrequest *cr; /* control requests */
169 struct usb_sg_request current_sg; /* scatter-gather req. */ 167 struct usb_sg_request current_sg; /* scatter-gather req. */
170 unsigned char *iobuf; /* I/O buffer */ 168 unsigned char *iobuf; /* I/O buffer */
169 unsigned char *sensebuf; /* sense data buffer */
171 dma_addr_t cr_dma; /* buffer DMA addresses */ 170 dma_addr_t cr_dma; /* buffer DMA addresses */
172 dma_addr_t iobuf_dma; 171 dma_addr_t iobuf_dma;
173 172
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 353f24d45bc1..6c3a53f8f26c 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -223,9 +223,8 @@ static struct file_operations skel_fops = {
223 * and to have the device registered with devfs and the driver core 223 * and to have the device registered with devfs and the driver core
224 */ 224 */
225static struct usb_class_driver skel_class = { 225static struct usb_class_driver skel_class = {
226 .name = "usb/skel%d", 226 .name = "skel%d",
227 .fops = &skel_fops, 227 .fops = &skel_fops,
228 .mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
229 .minor_base = USB_SKEL_MINOR_BASE, 228 .minor_base = USB_SKEL_MINOR_BASE,
230}; 229};
231 230
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 321dbe91dc14..cde6fd8eb390 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -22,6 +22,7 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/list.h> 23#include <linux/list.h>
24 24
25#include <asm/sizes.h>
25#include <asm/hardware/amba.h> 26#include <asm/hardware/amba.h>
26#include <asm/hardware/clock.h> 27#include <asm/hardware/clock.h>
27 28
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 3c72c627e65e..1991fdb32dfb 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -73,17 +73,15 @@ static void corgibl_blank(int blank)
73} 73}
74 74
75#ifdef CONFIG_PM 75#ifdef CONFIG_PM
76static int corgibl_suspend(struct device *dev, pm_message_t state, u32 level) 76static int corgibl_suspend(struct device *dev, pm_message_t state)
77{ 77{
78 if (level == SUSPEND_POWER_DOWN) 78 corgibl_blank(FB_BLANK_POWERDOWN);
79 corgibl_blank(FB_BLANK_POWERDOWN);
80 return 0; 79 return 0;
81} 80}
82 81
83static int corgibl_resume(struct device *dev, u32 level) 82static int corgibl_resume(struct device *dev)
84{ 83{
85 if (level == RESUME_POWER_ON) 84 corgibl_blank(FB_BLANK_UNBLANK);
86 corgibl_blank(FB_BLANK_UNBLANK);
87 return 0; 85 return 0;
88} 86}
89#else 87#else
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index a3040429c27b..3a26f9cc8585 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -275,20 +275,20 @@ static const struct cirrusfb_board_info_rec {
275 275
276#ifdef CONFIG_PCI 276#ifdef CONFIG_PCI
277#define CHIP(id, btype) \ 277#define CHIP(id, btype) \
278 { PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_##id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (btype) } 278 { PCI_VENDOR_ID_CIRRUS, id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (btype) }
279 279
280static struct pci_device_id cirrusfb_pci_table[] = { 280static struct pci_device_id cirrusfb_pci_table[] = {
281 CHIP( CIRRUS_5436, BT_ALPINE ), 281 CHIP( PCI_DEVICE_ID_CIRRUS_5436, BT_ALPINE ),
282 CHIP( CIRRUS_5434_8, BT_ALPINE ), 282 CHIP( PCI_DEVICE_ID_CIRRUS_5434_8, BT_ALPINE ),
283 CHIP( CIRRUS_5434_4, BT_ALPINE ), 283 CHIP( PCI_DEVICE_ID_CIRRUS_5434_4, BT_ALPINE ),
284 CHIP( CIRRUS_5430, BT_ALPINE ), /* GD-5440 has identical id */ 284 CHIP( PCI_DEVICE_ID_CIRRUS_5430, BT_ALPINE ), /* GD-5440 is same id */
285 CHIP( CIRRUS_7543, BT_ALPINE ), 285 CHIP( PCI_DEVICE_ID_CIRRUS_7543, BT_ALPINE ),
286 CHIP( CIRRUS_7548, BT_ALPINE ), 286 CHIP( PCI_DEVICE_ID_CIRRUS_7548, BT_ALPINE ),
287 CHIP( CIRRUS_5480, BT_GD5480 ), /* MacPicasso probably */ 287 CHIP( PCI_DEVICE_ID_CIRRUS_5480, BT_GD5480 ), /* MacPicasso likely */
288 CHIP( CIRRUS_5446, BT_PICASSO4 ), /* Picasso 4 is a GD5446 */ 288 CHIP( PCI_DEVICE_ID_CIRRUS_5446, BT_PICASSO4 ), /* Picasso 4 is 5446 */
289 CHIP( CIRRUS_5462, BT_LAGUNA ), /* CL Laguna */ 289 CHIP( PCI_DEVICE_ID_CIRRUS_5462, BT_LAGUNA ), /* CL Laguna */
290 CHIP( CIRRUS_5464, BT_LAGUNA ), /* CL Laguna 3D */ 290 CHIP( PCI_DEVICE_ID_CIRRUS_5464, BT_LAGUNA ), /* CL Laguna 3D */
291 CHIP( CIRRUS_5465, BT_LAGUNA ), /* CL Laguna 3DA*/ 291 CHIP( PCI_DEVICE_ID_CIRRUS_5465, BT_LAGUNA ), /* CL Laguna 3DA*/
292 { 0, } 292 { 0, }
293}; 293};
294MODULE_DEVICE_TABLE(pci, cirrusfb_pci_table); 294MODULE_DEVICE_TABLE(pci, cirrusfb_pci_table);
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index eb83a7874c71..7e731691e2a9 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -110,7 +110,7 @@ config STI_CONSOLE
110 110
111config FONTS 111config FONTS
112 bool "Select compiled-in fonts" 112 bool "Select compiled-in fonts"
113 depends on FRAMEBUFFER_CONSOLE 113 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
114 help 114 help
115 Say Y here if you would like to use fonts other than the default 115 Say Y here if you would like to use fonts other than the default
116 your frame buffer console usually use. 116 your frame buffer console usually use.
@@ -123,7 +123,7 @@ config FONTS
123 123
124config FONT_8x8 124config FONT_8x8
125 bool "VGA 8x8 font" if FONTS 125 bool "VGA 8x8 font" if FONTS
126 depends on FRAMEBUFFER_CONSOLE 126 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
127 default y if !SPARC32 && !SPARC64 && !FONTS 127 default y if !SPARC32 && !SPARC64 && !FONTS
128 help 128 help
129 This is the "high resolution" font for the VGA frame buffer (the one 129 This is the "high resolution" font for the VGA frame buffer (the one
@@ -137,7 +137,7 @@ config FONT_8x8
137 137
138config FONT_8x16 138config FONT_8x16
139 bool "VGA 8x16 font" if FONTS 139 bool "VGA 8x16 font" if FONTS
140 depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || USB_SISUSBVGA_CON 140 depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON
141 default y if !SPARC32 && !SPARC64 && !FONTS 141 default y if !SPARC32 && !SPARC64 && !FONTS
142 help 142 help
143 This is the "high resolution" font for the VGA frame buffer (the one 143 This is the "high resolution" font for the VGA frame buffer (the one
@@ -147,7 +147,7 @@ config FONT_8x16
147 147
148config FONT_6x11 148config FONT_6x11
149 bool "Mac console 6x11 font (not supported by all drivers)" if FONTS 149 bool "Mac console 6x11 font (not supported by all drivers)" if FONTS
150 depends on FRAMEBUFFER_CONSOLE 150 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
151 default y if !SPARC32 && !SPARC64 && !FONTS && MAC 151 default y if !SPARC32 && !SPARC64 && !FONTS && MAC
152 help 152 help
153 Small console font with Macintosh-style high-half glyphs. Some Mac 153 Small console font with Macintosh-style high-half glyphs. Some Mac
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index d940f605acb6..a7bcd17112c0 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -511,12 +511,12 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
511 struct sti_cooked_font *cooked_font; 511 struct sti_cooked_font *cooked_font;
512 512
513 if (!fbfont_name || !strlen(fbfont_name)) 513 if (!fbfont_name || !strlen(fbfont_name))
514 return NULL; 514 return NULL;
515 fbfont = find_font(fbfont_name); 515 fbfont = find_font(fbfont_name);
516 if (!fbfont) 516 if (!fbfont)
517 fbfont = get_default_font(1024,768); 517 fbfont = get_default_font(1024,768);
518 if (!fbfont) 518 if (!fbfont)
519 return NULL; 519 return NULL;
520 520
521 DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n", 521 DPRINTK((KERN_DEBUG "selected %dx%d fb-font %s\n",
522 fbfont->width, fbfont->height, fbfont->name)); 522 fbfont->width, fbfont->height, fbfont->name));
@@ -527,7 +527,7 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
527 527
528 nf = kmalloc(size, GFP_KERNEL); 528 nf = kmalloc(size, GFP_KERNEL);
529 if (!nf) 529 if (!nf)
530 return NULL; 530 return NULL;
531 memset(nf, 0, size); 531 memset(nf, 0, size);
532 532
533 nf->first_char = 0; 533 nf->first_char = 0;
@@ -546,8 +546,8 @@ sti_select_fbfont( struct sti_cooked_rom *cooked_rom, char *fbfont_name )
546 546
547 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL); 547 cooked_font = kmalloc(sizeof(*cooked_font), GFP_KERNEL);
548 if (!cooked_font) { 548 if (!cooked_font) {
549 kfree(nf); 549 kfree(nf);
550 return NULL; 550 return NULL;
551 } 551 }
552 552
553 cooked_font->raw = nf; 553 cooked_font->raw = nf;
@@ -595,7 +595,7 @@ sti_select_font(struct sti_cooked_rom *rom,
595static void __init 595static void __init
596sti_dump_rom(struct sti_rom *rom) 596sti_dump_rom(struct sti_rom *rom)
597{ 597{
598 printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n", 598 printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n",
599 rom->graphics_id[0], 599 rom->graphics_id[0],
600 rom->graphics_id[1], 600 rom->graphics_id[1],
601 rom->revno[0] >> 4, 601 rom->revno[0] >> 4,
@@ -651,15 +651,16 @@ sti_search_font(struct sti_cooked_rom *rom, int height, int width)
651 struct sti_cooked_font *font; 651 struct sti_cooked_font *font;
652 int i = 0; 652 int i = 0;
653 653
654 for(font = rom->font_start; font; font = font->next_font, i++) { 654 for (font = rom->font_start; font; font = font->next_font, i++) {
655 if((font->raw->width == width) && (font->raw->height == height)) 655 if ((font->raw->width == width) &&
656 (font->raw->height == height))
656 return i; 657 return i;
657 } 658 }
658 return 0; 659 return 0;
659} 660}
660 661
661#define BMODE_RELOCATE(offset) offset = (offset) / 4; 662#define BMODE_RELOCATE(offset) offset = (offset) / 4;
662#define BMODE_LAST_ADDR_OFFS 0x50 663#define BMODE_LAST_ADDR_OFFS 0x50
663 664
664static void * __init 665static void * __init
665sti_bmode_font_raw(struct sti_cooked_font *f) 666sti_bmode_font_raw(struct sti_cooked_font *f)
@@ -700,35 +701,35 @@ sti_get_bmode_rom (unsigned long address)
700{ 701{
701 struct sti_rom *raw; 702 struct sti_rom *raw;
702 u32 size; 703 u32 size;
703 struct sti_rom_font *raw_font, *font_start; 704 struct sti_rom_font *raw_font, *font_start;
704 705
705 sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size); 706 sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size);
706 707
707 size = (size+3) / 4; 708 size = (size+3) / 4;
708 raw = kmalloc(size, GFP_KERNEL); 709 raw = kmalloc(size, GFP_KERNEL);
709 if (raw) { 710 if (raw) {
710 sti_bmode_rom_copy(address, size, raw); 711 sti_bmode_rom_copy(address, size, raw);
711 memmove (&raw->res004, &raw->type[0], 0x3c); 712 memmove (&raw->res004, &raw->type[0], 0x3c);
712 raw->type[3] = raw->res004; 713 raw->type[3] = raw->res004;
713 714
714 BMODE_RELOCATE (raw->region_list); 715 BMODE_RELOCATE (raw->region_list);
715 BMODE_RELOCATE (raw->font_start); 716 BMODE_RELOCATE (raw->font_start);
716 717
717 BMODE_RELOCATE (raw->init_graph); 718 BMODE_RELOCATE (raw->init_graph);
718 BMODE_RELOCATE (raw->state_mgmt); 719 BMODE_RELOCATE (raw->state_mgmt);
719 BMODE_RELOCATE (raw->font_unpmv); 720 BMODE_RELOCATE (raw->font_unpmv);
720 BMODE_RELOCATE (raw->block_move); 721 BMODE_RELOCATE (raw->block_move);
721 BMODE_RELOCATE (raw->inq_conf); 722 BMODE_RELOCATE (raw->inq_conf);
722 723
723 raw_font = ((void *)raw) + raw->font_start; 724 raw_font = ((void *)raw) + raw->font_start;
724 font_start = raw_font; 725 font_start = raw_font;
725 726
726 while (raw_font->next_font) { 727 while (raw_font->next_font) {
727 BMODE_RELOCATE (raw_font->next_font); 728 BMODE_RELOCATE (raw_font->next_font);
728 raw_font = ((void *)font_start) + raw_font->next_font; 729 raw_font = ((void *)font_start) + raw_font->next_font;
729 } 730 }
730 } 731 }
731 return raw; 732 return raw;
732} 733}
733 734
734struct sti_rom * __init 735struct sti_rom * __init
@@ -736,15 +737,15 @@ sti_get_wmode_rom (unsigned long address)
736{ 737{
737 struct sti_rom *raw; 738 struct sti_rom *raw;
738 unsigned long size; 739 unsigned long size;
739 740
740 /* read the ROM size directly from the struct in ROM */ 741 /* read the ROM size directly from the struct in ROM */
741 size = gsc_readl(address + offsetof(struct sti_rom,last_addr)); 742 size = gsc_readl(address + offsetof(struct sti_rom,last_addr));
742 743
743 raw = kmalloc(size, GFP_KERNEL); 744 raw = kmalloc(size, GFP_KERNEL);
744 if(raw) 745 if (raw)
745 sti_rom_copy(address, size, raw); 746 sti_rom_copy(address, size, raw);
746 747
747 return raw; 748 return raw;
748} 749}
749 750
750int __init 751int __init
@@ -757,14 +758,14 @@ sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address)
757 if (!cooked) 758 if (!cooked)
758 goto out_err; 759 goto out_err;
759 760
760 if (wordmode) 761 if (wordmode)
761 raw = sti_get_wmode_rom (address); 762 raw = sti_get_wmode_rom (address);
762 else 763 else
763 raw = sti_get_bmode_rom (address); 764 raw = sti_get_bmode_rom (address);
765
766 if (!raw)
767 goto out_err;
764 768
765 if (!raw)
766 goto out_err;
767
768 if (!sti_cook_fonts(cooked, raw)) { 769 if (!sti_cook_fonts(cooked, raw)) {
769 printk(KERN_ERR "No font found for STI at %08lx\n", address); 770 printk(KERN_ERR "No font found for STI at %08lx\n", address);
770 goto out_err; 771 goto out_err;
@@ -787,7 +788,7 @@ sti_read_rom(int wordmode, struct sti_struct *sti, unsigned long address)
787 sti->font_width = sti->font->raw->width; 788 sti->font_width = sti->font->raw->width;
788 sti->font_height = sti->font->raw->height; 789 sti->font_height = sti->font->raw->height;
789 if (!wordmode) 790 if (!wordmode)
790 sti->font->raw = sti_bmode_font_raw(sti->font); 791 sti->font->raw = sti_bmode_font_raw(sti->font);
791 792
792 sti->sti_mem_request = raw->sti_mem_req; 793 sti->sti_mem_request = raw->sti_mem_req;
793 sti->graphics_id[0] = raw->graphics_id[0]; 794 sti->graphics_id[0] = raw->graphics_id[0];
@@ -811,16 +812,16 @@ sti_try_rom_generic(unsigned long address, unsigned long hpa, struct pci_dev *pd
811 u32 sig; 812 u32 sig;
812 813
813 if (num_sti_roms >= MAX_STI_ROMS) { 814 if (num_sti_roms >= MAX_STI_ROMS) {
814 printk(KERN_WARNING "maximum number of STI ROMS reached !\n"); 815 printk(KERN_WARNING "maximum number of STI ROMS reached !\n");
815 return NULL; 816 return NULL;
816 } 817 }
817 818
818 sti = kmalloc(sizeof(*sti), GFP_KERNEL); 819 sti = kmalloc(sizeof(*sti), GFP_KERNEL);
819 if (!sti) { 820 if (!sti) {
820 printk(KERN_ERR "Not enough memory !\n"); 821 printk(KERN_ERR "Not enough memory !\n");
821 return NULL; 822 return NULL;
822 } 823 }
823 824
824 memset(sti, 0, sizeof(*sti)); 825 memset(sti, 0, sizeof(*sti));
825 spin_lock_init(&sti->lock); 826 spin_lock_init(&sti->lock);
826 827
@@ -932,28 +933,21 @@ static void __init sticore_check_for_default_sti(struct sti_struct *sti, char *p
932 */ 933 */
933static int __init sticore_pa_init(struct parisc_device *dev) 934static int __init sticore_pa_init(struct parisc_device *dev)
934{ 935{
935 unsigned long rom = 0;
936 char pa_path[21]; 936 char pa_path[21];
937 struct sti_struct *sti = NULL; 937 struct sti_struct *sti = NULL;
938 938 int hpa = dev->hpa.start;
939 if(dev->num_addrs) { 939
940 rom = dev->addr[0]; 940 if (dev->num_addrs && dev->addr[0])
941 } 941 sti = sti_try_rom_generic(dev->addr[0], hpa, NULL);
942 if (!rom) { 942 if (!sti)
943 rom = dev->hpa; 943 sti = sti_try_rom_generic(hpa, hpa, NULL);
944 DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa)); 944 if (!sti)
945 sti = sti_try_rom_generic(rom, dev->hpa, NULL); 945 sti = sti_try_rom_generic(PAGE0->proc_sti, hpa, NULL);
946 rom = PAGE0->proc_sti;
947 }
948 if (!sti) {
949 DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n", rom, dev->hpa));
950 sti = sti_try_rom_generic(rom, dev->hpa, NULL);
951 }
952 if (!sti) 946 if (!sti)
953 return 1; 947 return 1;
954 948
955 print_pa_hwpath(dev, pa_path); 949 print_pa_hwpath(dev, pa_path);
956 sticore_check_for_default_sti (sti, pa_path); 950 sticore_check_for_default_sti(sti, pa_path);
957 return 0; 951 return 0;
958} 952}
959 953
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 70be7009f8af..9073be4221a8 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1031,7 +1031,7 @@ register_framebuffer(struct fb_info *fb_info)
1031 break; 1031 break;
1032 fb_info->node = i; 1032 fb_info->node = i;
1033 1033
1034 fb_info->class_device = class_device_create(fb_class, MKDEV(FB_MAJOR, i), 1034 fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i),
1035 fb_info->device, "fb%d", i); 1035 fb_info->device, "fb%d", i);
1036 if (IS_ERR(fb_info->class_device)) { 1036 if (IS_ERR(fb_info->class_device)) {
1037 /* Not fatal */ 1037 /* Not fatal */
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 1d54d3d6960b..0b9301facbd3 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -424,23 +424,21 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi)
424 * Power management hooks. Note that we won't be called from IRQ context, 424 * Power management hooks. Note that we won't be called from IRQ context,
425 * unlike the blank functions above, so we may sleep. 425 * unlike the blank functions above, so we may sleep.
426 */ 426 */
427static int imxfb_suspend(struct device *dev, pm_message_t state, u32 level) 427static int imxfb_suspend(struct device *dev, pm_message_t state)
428{ 428{
429 struct imxfb_info *fbi = dev_get_drvdata(dev); 429 struct imxfb_info *fbi = dev_get_drvdata(dev);
430 pr_debug("%s\n",__FUNCTION__); 430 pr_debug("%s\n",__FUNCTION__);
431 431
432 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) 432 imxfb_disable_controller(fbi);
433 imxfb_disable_controller(fbi);
434 return 0; 433 return 0;
435} 434}
436 435
437static int imxfb_resume(struct device *dev, u32 level) 436static int imxfb_resume(struct device *dev)
438{ 437{
439 struct imxfb_info *fbi = dev_get_drvdata(dev); 438 struct imxfb_info *fbi = dev_get_drvdata(dev);
440 pr_debug("%s\n",__FUNCTION__); 439 pr_debug("%s\n",__FUNCTION__);
441 440
442 if (level == RESUME_ENABLE) 441 imxfb_enable_controller(fbi);
443 imxfb_enable_controller(fbi);
444 return 0; 442 return 0;
445} 443}
446#else 444#else
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 194eed0a238c..6206da9dd5da 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -981,21 +981,19 @@ pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data)
981 * Power management hooks. Note that we won't be called from IRQ context, 981 * Power management hooks. Note that we won't be called from IRQ context,
982 * unlike the blank functions above, so we may sleep. 982 * unlike the blank functions above, so we may sleep.
983 */ 983 */
984static int pxafb_suspend(struct device *dev, pm_message_t state, u32 level) 984static int pxafb_suspend(struct device *dev, pm_message_t state)
985{ 985{
986 struct pxafb_info *fbi = dev_get_drvdata(dev); 986 struct pxafb_info *fbi = dev_get_drvdata(dev);
987 987
988 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) 988 set_ctrlr_state(fbi, C_DISABLE_PM);
989 set_ctrlr_state(fbi, C_DISABLE_PM);
990 return 0; 989 return 0;
991} 990}
992 991
993static int pxafb_resume(struct device *dev, u32 level) 992static int pxafb_resume(struct device *dev)
994{ 993{
995 struct pxafb_info *fbi = dev_get_drvdata(dev); 994 struct pxafb_info *fbi = dev_get_drvdata(dev);
996 995
997 if (level == RESUME_ENABLE) 996 set_ctrlr_state(fbi, C_ENABLE_PM);
998 set_ctrlr_state(fbi, C_ENABLE_PM);
999 return 0; 997 return 0;
1000} 998}
1001#else 999#else
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index fa98d91c42eb..cb2f7a1de947 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -655,7 +655,7 @@ bail:
655} 655}
656 656
657#ifdef CONFIG_PM 657#ifdef CONFIG_PM
658static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state, u32 level) 658static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state)
659{ 659{
660 struct fb_info *info = dev_get_drvdata(dev); 660 struct fb_info *info = dev_get_drvdata(dev);
661 struct s1d13xxxfb_par *s1dfb = info->par; 661 struct s1d13xxxfb_par *s1dfb = info->par;
@@ -702,15 +702,12 @@ static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state, u32 level)
702 return 0; 702 return 0;
703} 703}
704 704
705static int s1d13xxxfb_resume(struct device *dev, u32 level) 705static int s1d13xxxfb_resume(struct device *dev)
706{ 706{
707 struct fb_info *info = dev_get_drvdata(dev); 707 struct fb_info *info = dev_get_drvdata(dev);
708 struct s1d13xxxfb_par *s1dfb = info->par; 708 struct s1d13xxxfb_par *s1dfb = info->par;
709 struct s1d13xxxfb_pdata *pdata = NULL; 709 struct s1d13xxxfb_pdata *pdata = NULL;
710 710
711 if (level != RESUME_ENABLE)
712 return 0;
713
714 /* awaken the chip */ 711 /* awaken the chip */
715 s1d13xxxfb_writereg(s1dfb, S1DREG_PS_CNF, 0x10); 712 s1d13xxxfb_writereg(s1dfb, S1DREG_PS_CNF, 0x10);
716 713
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 5ab79afb53b7..3862d3cb1fb2 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -847,37 +847,32 @@ static int s3c2410fb_remove(struct device *dev)
847 847
848/* suspend and resume support for the lcd controller */ 848/* suspend and resume support for the lcd controller */
849 849
850static int s3c2410fb_suspend(struct device *dev, pm_message_t state, u32 level) 850static int s3c2410fb_suspend(struct device *dev, pm_message_t state)
851{ 851{
852 struct fb_info *fbinfo = dev_get_drvdata(dev); 852 struct fb_info *fbinfo = dev_get_drvdata(dev);
853 struct s3c2410fb_info *info = fbinfo->par; 853 struct s3c2410fb_info *info = fbinfo->par;
854 854
855 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) { 855 s3c2410fb_stop_lcd();
856 s3c2410fb_stop_lcd();
857 856
858 /* sleep before disabling the clock, we need to ensure 857 /* sleep before disabling the clock, we need to ensure
859 * the LCD DMA engine is not going to get back on the bus 858 * the LCD DMA engine is not going to get back on the bus
860 * before the clock goes off again (bjd) */ 859 * before the clock goes off again (bjd) */
861 860
862 msleep(1); 861 msleep(1);
863 clk_disable(info->clk); 862 clk_disable(info->clk);
864 }
865 863
866 return 0; 864 return 0;
867} 865}
868 866
869static int s3c2410fb_resume(struct device *dev, u32 level) 867static int s3c2410fb_resume(struct device *dev)
870{ 868{
871 struct fb_info *fbinfo = dev_get_drvdata(dev); 869 struct fb_info *fbinfo = dev_get_drvdata(dev);
872 struct s3c2410fb_info *info = fbinfo->par; 870 struct s3c2410fb_info *info = fbinfo->par;
873 871
874 if (level == RESUME_ENABLE) { 872 clk_enable(info->clk);
875 clk_enable(info->clk); 873 msleep(1);
876 msleep(1);
877
878 s3c2410fb_init_registers(info);
879 874
880 } 875 s3c2410fb_init_registers(info);
881 876
882 return 0; 877 return 0;
883} 878}
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index 8000890e4271..78e5f194b0df 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -1309,21 +1309,19 @@ sa1100fb_freq_policy(struct notifier_block *nb, unsigned long val,
1309 * Power management hooks. Note that we won't be called from IRQ context, 1309 * Power management hooks. Note that we won't be called from IRQ context,
1310 * unlike the blank functions above, so we may sleep. 1310 * unlike the blank functions above, so we may sleep.
1311 */ 1311 */
1312static int sa1100fb_suspend(struct device *dev, pm_message_t state, u32 level) 1312static int sa1100fb_suspend(struct device *dev, pm_message_t state)
1313{ 1313{
1314 struct sa1100fb_info *fbi = dev_get_drvdata(dev); 1314 struct sa1100fb_info *fbi = dev_get_drvdata(dev);
1315 1315
1316 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN) 1316 set_ctrlr_state(fbi, C_DISABLE_PM);
1317 set_ctrlr_state(fbi, C_DISABLE_PM);
1318 return 0; 1317 return 0;
1319} 1318}
1320 1319
1321static int sa1100fb_resume(struct device *dev, u32 level) 1320static int sa1100fb_resume(struct device *dev)
1322{ 1321{
1323 struct sa1100fb_info *fbi = dev_get_drvdata(dev); 1322 struct sa1100fb_info *fbi = dev_get_drvdata(dev);
1324 1323
1325 if (level == RESUME_ENABLE) 1324 set_ctrlr_state(fbi, C_ENABLE_PM);
1326 set_ctrlr_state(fbi, C_ENABLE_PM);
1327 return 0; 1325 return 0;
1328} 1326}
1329#else 1327#else
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 0030c071da8f..752bf88906a9 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -438,36 +438,34 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
438 } 438 }
439} 439}
440 440
441static int w100fb_suspend(struct device *dev, pm_message_t state, uint32_t level) 441static int w100fb_suspend(struct device *dev, pm_message_t state)
442{ 442{
443 if (level == SUSPEND_POWER_DOWN) { 443 struct fb_info *info = dev_get_drvdata(dev);
444 struct fb_info *info = dev_get_drvdata(dev); 444 struct w100fb_par *par=info->par;
445 struct w100fb_par *par=info->par; 445 struct w100_tg_info *tg = par->mach->tg;
446 struct w100_tg_info *tg = par->mach->tg; 446
447 447 w100fb_save_vidmem(par);
448 w100fb_save_vidmem(par); 448 if(tg && tg->suspend)
449 if(tg && tg->suspend) 449 tg->suspend(par);
450 tg->suspend(par); 450 w100_suspend(W100_SUSPEND_ALL);
451 w100_suspend(W100_SUSPEND_ALL); 451 par->blanked = 1;
452 par->blanked = 1; 452
453 }
454 return 0; 453 return 0;
455} 454}
456 455
457static int w100fb_resume(struct device *dev, uint32_t level) 456static int w100fb_resume(struct device *dev)
458{ 457{
459 if (level == RESUME_POWER_ON) { 458 struct fb_info *info = dev_get_drvdata(dev);
460 struct fb_info *info = dev_get_drvdata(dev); 459 struct w100fb_par *par=info->par;
461 struct w100fb_par *par=info->par; 460 struct w100_tg_info *tg = par->mach->tg;
462 struct w100_tg_info *tg = par->mach->tg; 461
462 w100_hw_init(par);
463 w100fb_activate_var(par);
464 w100fb_restore_vidmem(par);
465 if(tg && tg->resume)
466 tg->resume(par);
467 par->blanked = 0;
463 468
464 w100_hw_init(par);
465 w100fb_activate_var(par);
466 w100fb_restore_vidmem(par);
467 if(tg && tg->resume)
468 tg->resume(par);
469 par->blanked = 0;
470 }
471 return 0; 469 return 0;
472} 470}
473#else 471#else
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 23c125128024..0d576987ec67 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -29,7 +29,7 @@ static int afs_file_release(struct inode *inode, struct file *file);
29 29
30static int afs_file_readpage(struct file *file, struct page *page); 30static int afs_file_readpage(struct file *file, struct page *page);
31static int afs_file_invalidatepage(struct page *page, unsigned long offset); 31static int afs_file_invalidatepage(struct page *page, unsigned long offset);
32static int afs_file_releasepage(struct page *page, int gfp_flags); 32static int afs_file_releasepage(struct page *page, gfp_t gfp_flags);
33 33
34static ssize_t afs_file_write(struct file *file, const char __user *buf, 34static ssize_t afs_file_write(struct file *file, const char __user *buf,
35 size_t size, loff_t *off); 35 size_t size, loff_t *off);
@@ -279,7 +279,7 @@ static int afs_file_invalidatepage(struct page *page, unsigned long offset)
279/* 279/*
280 * release a page and cleanup its private data 280 * release a page and cleanup its private data
281 */ 281 */
282static int afs_file_releasepage(struct page *page, int gfp_flags) 282static int afs_file_releasepage(struct page *page, gfp_t gfp_flags)
283{ 283{
284 struct cachefs_page *pageio; 284 struct cachefs_page *pageio;
285 285
diff --git a/fs/bio.c b/fs/bio.c
index 7d81a93afd48..460554b07ff9 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -778,7 +778,7 @@ static int bio_map_kern_endio(struct bio *bio, unsigned int bytes_done, int err)
778 778
779 779
780static struct bio *__bio_map_kern(request_queue_t *q, void *data, 780static struct bio *__bio_map_kern(request_queue_t *q, void *data,
781 unsigned int len, unsigned int gfp_mask) 781 unsigned int len, gfp_t gfp_mask)
782{ 782{
783 unsigned long kaddr = (unsigned long)data; 783 unsigned long kaddr = (unsigned long)data;
784 unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 784 unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -825,7 +825,7 @@ static struct bio *__bio_map_kern(request_queue_t *q, void *data,
825 * device. Returns an error pointer in case of error. 825 * device. Returns an error pointer in case of error.
826 */ 826 */
827struct bio *bio_map_kern(request_queue_t *q, void *data, unsigned int len, 827struct bio *bio_map_kern(request_queue_t *q, void *data, unsigned int len,
828 unsigned int gfp_mask) 828 gfp_t gfp_mask)
829{ 829{
830 struct bio *bio; 830 struct bio *bio;
831 831
diff --git a/fs/buffer.c b/fs/buffer.c
index 1216c0d3c8ce..b1667986442f 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -502,7 +502,7 @@ static void free_more_memory(void)
502 yield(); 502 yield();
503 503
504 for_each_pgdat(pgdat) { 504 for_each_pgdat(pgdat) {
505 zones = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones; 505 zones = pgdat->node_zonelists[gfp_zone(GFP_NOFS)].zones;
506 if (*zones) 506 if (*zones)
507 try_to_free_pages(zones, GFP_NOFS); 507 try_to_free_pages(zones, GFP_NOFS);
508 } 508 }
@@ -1571,7 +1571,7 @@ static inline void discard_buffer(struct buffer_head * bh)
1571 * 1571 *
1572 * NOTE: @gfp_mask may go away, and this function may become non-blocking. 1572 * NOTE: @gfp_mask may go away, and this function may become non-blocking.
1573 */ 1573 */
1574int try_to_release_page(struct page *page, int gfp_mask) 1574int try_to_release_page(struct page *page, gfp_t gfp_mask)
1575{ 1575{
1576 struct address_space * const mapping = page->mapping; 1576 struct address_space * const mapping = page->mapping;
1577 1577
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 3d1cce3653b8..6a3df88accfe 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -370,8 +370,8 @@ static int init_coda_psdev(void)
370 } 370 }
371 devfs_mk_dir ("coda"); 371 devfs_mk_dir ("coda");
372 for (i = 0; i < MAX_CODADEVS; i++) { 372 for (i = 0; i < MAX_CODADEVS; i++) {
373 class_device_create(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i), 373 class_device_create(coda_psdev_class, NULL,
374 NULL, "cfs%d", i); 374 MKDEV(CODA_PSDEV_MAJOR,i), NULL, "cfs%d", i);
375 err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i), 375 err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
376 S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i); 376 S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
377 if (err) 377 if (err)
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index e28a74203f3b..a327e03753ac 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -3050,6 +3050,7 @@ HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl)
3050HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) 3050HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control)
3051HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) 3051HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk)
3052HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) 3052HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal)
3053COMPATIBLE_IOCTL(USBDEVFS_IOCTL32)
3053/* i2c */ 3054/* i2c */
3054HANDLE_IOCTL(I2C_FUNCS, w_long) 3055HANDLE_IOCTL(I2C_FUNCS, w_long)
3055HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) 3056HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
diff --git a/fs/dcache.c b/fs/dcache.c
index fb10386c59be..e90512ed35a4 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -689,7 +689,7 @@ void shrink_dcache_anon(struct hlist_head *head)
689 * 689 *
690 * In this case we return -1 to tell the caller that we baled. 690 * In this case we return -1 to tell the caller that we baled.
691 */ 691 */
692static int shrink_dcache_memory(int nr, unsigned int gfp_mask) 692static int shrink_dcache_memory(int nr, gfp_t gfp_mask)
693{ 693{
694 if (nr) { 694 if (nr) {
695 if (!(gfp_mask & __GFP_FS)) 695 if (!(gfp_mask & __GFP_FS))
diff --git a/fs/dquot.c b/fs/dquot.c
index b9732335bcdc..05f3327d64a3 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -500,7 +500,7 @@ static void prune_dqcache(int count)
500 * more memory 500 * more memory
501 */ 501 */
502 502
503static int shrink_dqcache_memory(int nr, unsigned int gfp_mask) 503static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
504{ 504{
505 if (nr) { 505 if (nr) {
506 spin_lock(&dq_list_lock); 506 spin_lock(&dq_list_lock);
diff --git a/fs/exec.c b/fs/exec.c
index a04a575ad433..d2208f7c87db 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -126,8 +126,7 @@ asmlinkage long sys_uselib(const char __user * library)
126 struct nameidata nd; 126 struct nameidata nd;
127 int error; 127 int error;
128 128
129 nd.intent.open.flags = FMODE_READ; 129 error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);
130 error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
131 if (error) 130 if (error)
132 goto out; 131 goto out;
133 132
@@ -139,7 +138,7 @@ asmlinkage long sys_uselib(const char __user * library)
139 if (error) 138 if (error)
140 goto exit; 139 goto exit;
141 140
142 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); 141 file = nameidata_to_filp(&nd, O_RDONLY);
143 error = PTR_ERR(file); 142 error = PTR_ERR(file);
144 if (IS_ERR(file)) 143 if (IS_ERR(file))
145 goto out; 144 goto out;
@@ -167,6 +166,7 @@ asmlinkage long sys_uselib(const char __user * library)
167out: 166out:
168 return error; 167 return error;
169exit: 168exit:
169 release_open_intent(&nd);
170 path_release(&nd); 170 path_release(&nd);
171 goto out; 171 goto out;
172} 172}
@@ -490,8 +490,7 @@ struct file *open_exec(const char *name)
490 int err; 490 int err;
491 struct file *file; 491 struct file *file;
492 492
493 nd.intent.open.flags = FMODE_READ; 493 err = path_lookup_open(name, LOOKUP_FOLLOW, &nd, FMODE_READ);
494 err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
495 file = ERR_PTR(err); 494 file = ERR_PTR(err);
496 495
497 if (!err) { 496 if (!err) {
@@ -504,7 +503,7 @@ struct file *open_exec(const char *name)
504 err = -EACCES; 503 err = -EACCES;
505 file = ERR_PTR(err); 504 file = ERR_PTR(err);
506 if (!err) { 505 if (!err) {
507 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); 506 file = nameidata_to_filp(&nd, O_RDONLY);
508 if (!IS_ERR(file)) { 507 if (!IS_ERR(file)) {
509 err = deny_write_access(file); 508 err = deny_write_access(file);
510 if (err) { 509 if (err) {
@@ -516,6 +515,7 @@ out:
516 return file; 515 return file;
517 } 516 }
518 } 517 }
518 release_open_intent(&nd);
519 path_release(&nd); 519 path_release(&nd);
520 } 520 }
521 goto out; 521 goto out;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index b5177c90d6f1..8b38f2232796 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1434,7 +1434,7 @@ static int ext3_invalidatepage(struct page *page, unsigned long offset)
1434 return journal_invalidatepage(journal, page, offset); 1434 return journal_invalidatepage(journal, page, offset);
1435} 1435}
1436 1436
1437static int ext3_releasepage(struct page *page, int wait) 1437static int ext3_releasepage(struct page *page, gfp_t wait)
1438{ 1438{
1439 journal_t *journal = EXT3_JOURNAL(page->mapping->host); 1439 journal_t *journal = EXT3_JOURNAL(page->mapping->host);
1440 1440
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 9e24ceb019fe..097383c11154 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -510,19 +510,11 @@ static void ext3_clear_inode(struct inode *inode)
510 kfree(rsv); 510 kfree(rsv);
511} 511}
512 512
513static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) 513static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb)
514{ 514{
515 struct super_block *sb = vfs->mnt_sb; 515#if defined(CONFIG_QUOTA)
516 struct ext3_sb_info *sbi = EXT3_SB(sb); 516 struct ext3_sb_info *sbi = EXT3_SB(sb);
517 517
518 if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
519 seq_puts(seq, ",data=journal");
520 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
521 seq_puts(seq, ",data=ordered");
522 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
523 seq_puts(seq, ",data=writeback");
524
525#if defined(CONFIG_QUOTA)
526 if (sbi->s_jquota_fmt) 518 if (sbi->s_jquota_fmt)
527 seq_printf(seq, ",jqfmt=%s", 519 seq_printf(seq, ",jqfmt=%s",
528 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); 520 (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0");
@@ -539,6 +531,20 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
539 if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) 531 if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)
540 seq_puts(seq, ",grpquota"); 532 seq_puts(seq, ",grpquota");
541#endif 533#endif
534}
535
536static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
537{
538 struct super_block *sb = vfs->mnt_sb;
539
540 if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA)
541 seq_puts(seq, ",data=journal");
542 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
543 seq_puts(seq, ",data=ordered");
544 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
545 seq_puts(seq, ",data=writeback");
546
547 ext3_show_quota_options(seq, sb);
542 548
543 return 0; 549 return 0;
544} 550}
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index f1570b9f9de3..3f680c5675bf 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -46,7 +46,7 @@ static sector_t hfs_bmap(struct address_space *mapping, sector_t block)
46 return generic_block_bmap(mapping, block, hfs_get_block); 46 return generic_block_bmap(mapping, block, hfs_get_block);
47} 47}
48 48
49static int hfs_releasepage(struct page *page, int mask) 49static int hfs_releasepage(struct page *page, gfp_t mask)
50{ 50{
51 struct inode *inode = page->mapping->host; 51 struct inode *inode = page->mapping->host;
52 struct super_block *sb = inode->i_sb; 52 struct super_block *sb = inode->i_sb;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index d5642705f633..f205773ddfbe 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -40,7 +40,7 @@ static sector_t hfsplus_bmap(struct address_space *mapping, sector_t block)
40 return generic_block_bmap(mapping, block, hfsplus_get_block); 40 return generic_block_bmap(mapping, block, hfsplus_get_block);
41} 41}
42 42
43static int hfsplus_releasepage(struct page *page, int mask) 43static int hfsplus_releasepage(struct page *page, gfp_t mask)
44{ 44{
45 struct inode *inode = page->mapping->host; 45 struct inode *inode = page->mapping->host;
46 struct super_block *sb = inode->i_sb; 46 struct super_block *sb = inode->i_sb;
diff --git a/fs/inode.c b/fs/inode.c
index f80a79ff156b..7d3316527767 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -475,7 +475,7 @@ static void prune_icache(int nr_to_scan)
475 * This function is passed the number of inodes to scan, and it returns the 475 * This function is passed the number of inodes to scan, and it returns the
476 * total number of remaining possibly-reclaimable inodes. 476 * total number of remaining possibly-reclaimable inodes.
477 */ 477 */
478static int shrink_icache_memory(int nr, unsigned int gfp_mask) 478static int shrink_icache_memory(int nr, gfp_t gfp_mask)
479{ 479{
480 if (nr) { 480 if (nr) {
481 /* 481 /*
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 7ae2c4fe506b..e4b516ac4989 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -1606,7 +1606,7 @@ int journal_blocks_per_page(struct inode *inode)
1606 * Simple support for retrying memory allocations. Introduced to help to 1606 * Simple support for retrying memory allocations. Introduced to help to
1607 * debug different VM deadlock avoidance strategies. 1607 * debug different VM deadlock avoidance strategies.
1608 */ 1608 */
1609void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry) 1609void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1610{ 1610{
1611 return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0)); 1611 return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
1612} 1612}
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 49bbc2be3d72..13cb05bf6048 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1621,7 +1621,7 @@ out:
1621 * while the data is part of a transaction. Yes? 1621 * while the data is part of a transaction. Yes?
1622 */ 1622 */
1623int journal_try_to_free_buffers(journal_t *journal, 1623int journal_try_to_free_buffers(journal_t *journal,
1624 struct page *page, int unused_gfp_mask) 1624 struct page *page, gfp_t unused_gfp_mask)
1625{ 1625{
1626 struct buffer_head *head; 1626 struct buffer_head *head;
1627 struct buffer_head *bh; 1627 struct buffer_head *bh;
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index eadf319bee22..68000a50ceb6 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -74,7 +74,7 @@
74static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno, 74static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
75 int nblocks); 75 int nblocks);
76static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval); 76static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval);
77static void dbBackSplit(dmtree_t * tp, int leafno); 77static int dbBackSplit(dmtree_t * tp, int leafno);
78static int dbJoin(dmtree_t * tp, int leafno, int newval); 78static int dbJoin(dmtree_t * tp, int leafno, int newval);
79static void dbAdjTree(dmtree_t * tp, int leafno, int newval); 79static void dbAdjTree(dmtree_t * tp, int leafno, int newval);
80static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, 80static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
@@ -305,7 +305,6 @@ int dbSync(struct inode *ipbmap)
305 filemap_fdatawrite(ipbmap->i_mapping); 305 filemap_fdatawrite(ipbmap->i_mapping);
306 filemap_fdatawait(ipbmap->i_mapping); 306 filemap_fdatawait(ipbmap->i_mapping);
307 307
308 ipbmap->i_state |= I_DIRTY;
309 diWriteSpecial(ipbmap, 0); 308 diWriteSpecial(ipbmap, 0);
310 309
311 return (0); 310 return (0);
@@ -2467,7 +2466,9 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
2467 * that it is at the front of a binary buddy system. 2466 * that it is at the front of a binary buddy system.
2468 */ 2467 */
2469 if (oldval == NOFREE) { 2468 if (oldval == NOFREE) {
2470 dbBackSplit((dmtree_t *) dcp, leafno); 2469 rc = dbBackSplit((dmtree_t *) dcp, leafno);
2470 if (rc)
2471 return rc;
2471 oldval = dcp->stree[ti]; 2472 oldval = dcp->stree[ti];
2472 } 2473 }
2473 dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval); 2474 dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval);
@@ -2627,7 +2628,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
2627 * 2628 *
2628 * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit; 2629 * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit;
2629 */ 2630 */
2630static void dbBackSplit(dmtree_t * tp, int leafno) 2631static int dbBackSplit(dmtree_t * tp, int leafno)
2631{ 2632{
2632 int budsz, bud, w, bsz, size; 2633 int budsz, bud, w, bsz, size;
2633 int cursz; 2634 int cursz;
@@ -2662,7 +2663,10 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
2662 */ 2663 */
2663 for (w = leafno, bsz = budsz;; bsz <<= 1, 2664 for (w = leafno, bsz = budsz;; bsz <<= 1,
2664 w = (w < bud) ? w : bud) { 2665 w = (w < bud) ? w : bud) {
2665 assert(bsz < le32_to_cpu(tp->dmt_nleafs)); 2666 if (bsz >= le32_to_cpu(tp->dmt_nleafs)) {
2667 jfs_err("JFS: block map error in dbBackSplit");
2668 return -EIO;
2669 }
2666 2670
2667 /* determine the buddy. 2671 /* determine the buddy.
2668 */ 2672 */
@@ -2681,7 +2685,11 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
2681 } 2685 }
2682 } 2686 }
2683 2687
2684 assert(leaf[leafno] == size); 2688 if (leaf[leafno] != size) {
2689 jfs_err("JFS: wrong leaf value in dbBackSplit");
2690 return -EIO;
2691 }
2692 return 0;
2685} 2693}
2686 2694
2687 2695
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 4021d46da7e3..28201b194f53 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -57,6 +57,12 @@
57#include "jfs_debug.h" 57#include "jfs_debug.h"
58 58
59/* 59/*
60 * __mark_inode_dirty expects inodes to be hashed. Since we don't want
61 * special inodes in the fileset inode space, we hash them to a dummy head
62 */
63static HLIST_HEAD(aggregate_hash);
64
65/*
60 * imap locks 66 * imap locks
61 */ 67 */
62/* iag free list lock */ 68/* iag free list lock */
@@ -491,6 +497,8 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
491 /* release the page */ 497 /* release the page */
492 release_metapage(mp); 498 release_metapage(mp);
493 499
500 hlist_add_head(&ip->i_hash, &aggregate_hash);
501
494 return (ip); 502 return (ip);
495} 503}
496 504
@@ -514,8 +522,6 @@ void diWriteSpecial(struct inode *ip, int secondary)
514 ino_t inum = ip->i_ino; 522 ino_t inum = ip->i_ino;
515 struct metapage *mp; 523 struct metapage *mp;
516 524
517 ip->i_state &= ~I_DIRTY;
518
519 if (secondary) 525 if (secondary)
520 address = addressPXD(&sbi->ait2) >> sbi->l2nbperpage; 526 address = addressPXD(&sbi->ait2) >> sbi->l2nbperpage;
521 else 527 else
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 13d7e3f1feb4..26091a5f88d4 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -198,7 +198,7 @@ static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags)
198 } 198 }
199} 199}
200 200
201static inline struct metapage *alloc_metapage(unsigned int gfp_mask) 201static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
202{ 202{
203 return mempool_alloc(metapage_mempool, gfp_mask); 203 return mempool_alloc(metapage_mempool, gfp_mask);
204} 204}
@@ -395,6 +395,12 @@ static int metapage_writepage(struct page *page, struct writeback_control *wbc)
395 395
396 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) { 396 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) {
397 redirty = 1; 397 redirty = 1;
398 /*
399 * Make sure this page isn't blocked indefinitely.
400 * If the journal isn't undergoing I/O, push it
401 */
402 if (mp->log && !(mp->log->cflag & logGC_PAGEOUT))
403 jfs_flush_journal(mp->log, 0);
398 continue; 404 continue;
399 } 405 }
400 406
@@ -534,7 +540,7 @@ add_failed:
534 return -EIO; 540 return -EIO;
535} 541}
536 542
537static int metapage_releasepage(struct page *page, int gfp_mask) 543static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
538{ 544{
539 struct metapage *mp; 545 struct metapage *mp;
540 int busy = 0; 546 int busy = 0;
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index 9b71ed2674fe..b660c93c92de 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -2396,7 +2396,6 @@ static void txUpdateMap(struct tblock * tblk)
2396 */ 2396 */
2397 if (tblk->xflag & COMMIT_CREATE) { 2397 if (tblk->xflag & COMMIT_CREATE) {
2398 diUpdatePMap(ipimap, tblk->ino, FALSE, tblk); 2398 diUpdatePMap(ipimap, tblk->ino, FALSE, tblk);
2399 ipimap->i_state |= I_DIRTY;
2400 /* update persistent block allocation map 2399 /* update persistent block allocation map
2401 * for the allocation of inode extent; 2400 * for the allocation of inode extent;
2402 */ 2401 */
@@ -2407,7 +2406,6 @@ static void txUpdateMap(struct tblock * tblk)
2407 } else if (tblk->xflag & COMMIT_DELETE) { 2406 } else if (tblk->xflag & COMMIT_DELETE) {
2408 ip = tblk->u.ip; 2407 ip = tblk->u.ip;
2409 diUpdatePMap(ipimap, ip->i_ino, TRUE, tblk); 2408 diUpdatePMap(ipimap, ip->i_ino, TRUE, tblk);
2410 ipimap->i_state |= I_DIRTY;
2411 iput(ip); 2409 iput(ip);
2412 } 2410 }
2413} 2411}
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index a7fe2f2b969f..e72f4ebb6e9c 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -3516,16 +3516,10 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
3516 /* process entries backward from last index */ 3516 /* process entries backward from last index */
3517 index = le16_to_cpu(p->header.nextindex) - 1; 3517 index = le16_to_cpu(p->header.nextindex) - 1;
3518 3518
3519 if (p->header.flag & BT_INTERNAL)
3520 goto getChild;
3521
3522 /*
3523 * leaf page
3524 */
3525 3519
3526 /* Since this is the rightmost leaf, and we may have already freed 3520 /* Since this is the rightmost page at this level, and we may have
3527 * a page that was formerly to the right, let's make sure that the 3521 * already freed a page that was formerly to the right, let's make
3528 * next pointer is zero. 3522 * sure that the next pointer is zero.
3529 */ 3523 */
3530 if (p->header.next) { 3524 if (p->header.next) {
3531 if (log) 3525 if (log)
@@ -3539,6 +3533,12 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
3539 p->header.next = 0; 3533 p->header.next = 0;
3540 } 3534 }
3541 3535
3536 if (p->header.flag & BT_INTERNAL)
3537 goto getChild;
3538
3539 /*
3540 * leaf page
3541 */
3542 freed = 0; 3542 freed = 0;
3543 3543
3544 /* does region covered by leaf page precede Teof ? */ 3544 /* does region covered by leaf page precede Teof ? */
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 71bc34b96b2b..4226af3ea91b 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -442,6 +442,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
442 inode->i_nlink = 1; 442 inode->i_nlink = 1;
443 inode->i_size = sb->s_bdev->bd_inode->i_size; 443 inode->i_size = sb->s_bdev->bd_inode->i_size;
444 inode->i_mapping->a_ops = &jfs_metapage_aops; 444 inode->i_mapping->a_ops = &jfs_metapage_aops;
445 insert_inode_hash(inode);
445 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); 446 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
446 447
447 sbi->direct_inode = inode; 448 sbi->direct_inode = inode;
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 82c77df81c5f..c4c8601096e0 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -173,11 +173,10 @@ nlm_bind_host(struct nlm_host *host)
173 173
174 /* If we've already created an RPC client, check whether 174 /* If we've already created an RPC client, check whether
175 * RPC rebind is required 175 * RPC rebind is required
176 * Note: why keep rebinding if we're on a tcp connection?
177 */ 176 */
178 if ((clnt = host->h_rpcclnt) != NULL) { 177 if ((clnt = host->h_rpcclnt) != NULL) {
179 xprt = clnt->cl_xprt; 178 xprt = clnt->cl_xprt;
180 if (!xprt->stream && time_after_eq(jiffies, host->h_nextrebind)) { 179 if (time_after_eq(jiffies, host->h_nextrebind)) {
181 clnt->cl_port = 0; 180 clnt->cl_port = 0;
182 host->h_nextrebind = jiffies + NLM_HOST_REBIND; 181 host->h_nextrebind = jiffies + NLM_HOST_REBIND;
183 dprintk("lockd: next rebind in %ld jiffies\n", 182 dprintk("lockd: next rebind in %ld jiffies\n",
@@ -189,7 +188,6 @@ nlm_bind_host(struct nlm_host *host)
189 goto forgetit; 188 goto forgetit;
190 189
191 xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout); 190 xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
192 xprt->nocong = 1; /* No congestion control for NLM */
193 xprt->resvport = 1; /* NLM requires a reserved port */ 191 xprt->resvport = 1; /* NLM requires a reserved port */
194 192
195 /* Existing NLM servers accept AUTH_UNIX only */ 193 /* Existing NLM servers accept AUTH_UNIX only */
diff --git a/fs/locks.c b/fs/locks.c
index f7daa5f48949..a1e8b2248014 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -316,21 +316,22 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl,
316 /* POSIX-1996 leaves the case l->l_len < 0 undefined; 316 /* POSIX-1996 leaves the case l->l_len < 0 undefined;
317 POSIX-2001 defines it. */ 317 POSIX-2001 defines it. */
318 start += l->l_start; 318 start += l->l_start;
319 end = start + l->l_len - 1; 319 if (start < 0)
320 if (l->l_len < 0) { 320 return -EINVAL;
321 fl->fl_end = OFFSET_MAX;
322 if (l->l_len > 0) {
323 end = start + l->l_len - 1;
324 fl->fl_end = end;
325 } else if (l->l_len < 0) {
321 end = start - 1; 326 end = start - 1;
327 fl->fl_end = end;
322 start += l->l_len; 328 start += l->l_len;
329 if (start < 0)
330 return -EINVAL;
323 } 331 }
324
325 if (start < 0)
326 return -EINVAL;
327 if (l->l_len > 0 && end < 0)
328 return -EOVERFLOW;
329
330 fl->fl_start = start; /* we record the absolute position */ 332 fl->fl_start = start; /* we record the absolute position */
331 fl->fl_end = end; 333 if (fl->fl_end < fl->fl_start)
332 if (l->l_len == 0) 334 return -EOVERFLOW;
333 fl->fl_end = OFFSET_MAX;
334 335
335 fl->fl_owner = current->files; 336 fl->fl_owner = current->files;
336 fl->fl_pid = current->tgid; 337 fl->fl_pid = current->tgid;
@@ -362,14 +363,21 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
362 return -EINVAL; 363 return -EINVAL;
363 } 364 }
364 365
365 if (((start += l->l_start) < 0) || (l->l_len < 0)) 366 start += l->l_start;
367 if (start < 0)
366 return -EINVAL; 368 return -EINVAL;
367 fl->fl_end = start + l->l_len - 1; 369 fl->fl_end = OFFSET_MAX;
368 if (l->l_len > 0 && fl->fl_end < 0) 370 if (l->l_len > 0) {
369 return -EOVERFLOW; 371 fl->fl_end = start + l->l_len - 1;
372 } else if (l->l_len < 0) {
373 fl->fl_end = start - 1;
374 start += l->l_len;
375 if (start < 0)
376 return -EINVAL;
377 }
370 fl->fl_start = start; /* we record the absolute position */ 378 fl->fl_start = start; /* we record the absolute position */
371 if (l->l_len == 0) 379 if (fl->fl_end < fl->fl_start)
372 fl->fl_end = OFFSET_MAX; 380 return -EOVERFLOW;
373 381
374 fl->fl_owner = current->files; 382 fl->fl_owner = current->files;
375 fl->fl_pid = current->tgid; 383 fl->fl_pid = current->tgid;
@@ -829,12 +837,16 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request)
829 /* Detect adjacent or overlapping regions (if same lock type) 837 /* Detect adjacent or overlapping regions (if same lock type)
830 */ 838 */
831 if (request->fl_type == fl->fl_type) { 839 if (request->fl_type == fl->fl_type) {
840 /* In all comparisons of start vs end, use
841 * "start - 1" rather than "end + 1". If end
842 * is OFFSET_MAX, end + 1 will become negative.
843 */
832 if (fl->fl_end < request->fl_start - 1) 844 if (fl->fl_end < request->fl_start - 1)
833 goto next_lock; 845 goto next_lock;
834 /* If the next lock in the list has entirely bigger 846 /* If the next lock in the list has entirely bigger
835 * addresses than the new one, insert the lock here. 847 * addresses than the new one, insert the lock here.
836 */ 848 */
837 if (fl->fl_start > request->fl_end + 1) 849 if (fl->fl_start - 1 > request->fl_end)
838 break; 850 break;
839 851
840 /* If we come here, the new and old lock are of the 852 /* If we come here, the new and old lock are of the
diff --git a/fs/mbcache.c b/fs/mbcache.c
index b002a088857d..298997f17475 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -116,7 +116,7 @@ mb_cache_indexes(struct mb_cache *cache)
116 * What the mbcache registers as to get shrunk dynamically. 116 * What the mbcache registers as to get shrunk dynamically.
117 */ 117 */
118 118
119static int mb_cache_shrink_fn(int nr_to_scan, unsigned int gfp_mask); 119static int mb_cache_shrink_fn(int nr_to_scan, gfp_t gfp_mask);
120 120
121 121
122static inline int 122static inline int
@@ -140,7 +140,7 @@ __mb_cache_entry_unhash(struct mb_cache_entry *ce)
140 140
141 141
142static inline void 142static inline void
143__mb_cache_entry_forget(struct mb_cache_entry *ce, int gfp_mask) 143__mb_cache_entry_forget(struct mb_cache_entry *ce, gfp_t gfp_mask)
144{ 144{
145 struct mb_cache *cache = ce->e_cache; 145 struct mb_cache *cache = ce->e_cache;
146 146
@@ -193,7 +193,7 @@ forget:
193 * Returns the number of objects which are present in the cache. 193 * Returns the number of objects which are present in the cache.
194 */ 194 */
195static int 195static int
196mb_cache_shrink_fn(int nr_to_scan, unsigned int gfp_mask) 196mb_cache_shrink_fn(int nr_to_scan, gfp_t gfp_mask)
197{ 197{
198 LIST_HEAD(free_list); 198 LIST_HEAD(free_list);
199 struct list_head *l, *ltmp; 199 struct list_head *l, *ltmp;
diff --git a/fs/namei.c b/fs/namei.c
index aa62dbda93ac..aaaa81036234 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -28,6 +28,7 @@
28#include <linux/syscalls.h> 28#include <linux/syscalls.h>
29#include <linux/mount.h> 29#include <linux/mount.h>
30#include <linux/audit.h> 30#include <linux/audit.h>
31#include <linux/file.h>
31#include <asm/namei.h> 32#include <asm/namei.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33 34
@@ -317,6 +318,18 @@ void path_release_on_umount(struct nameidata *nd)
317 mntput_no_expire(nd->mnt); 318 mntput_no_expire(nd->mnt);
318} 319}
319 320
321/**
322 * release_open_intent - free up open intent resources
323 * @nd: pointer to nameidata
324 */
325void release_open_intent(struct nameidata *nd)
326{
327 if (nd->intent.open.file->f_dentry == NULL)
328 put_filp(nd->intent.open.file);
329 else
330 fput(nd->intent.open.file);
331}
332
320/* 333/*
321 * Internal lookup() using the new generic dcache. 334 * Internal lookup() using the new generic dcache.
322 * SMP-safe 335 * SMP-safe
@@ -750,6 +763,7 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
750 struct qstr this; 763 struct qstr this;
751 unsigned int c; 764 unsigned int c;
752 765
766 nd->flags |= LOOKUP_CONTINUE;
753 err = exec_permission_lite(inode, nd); 767 err = exec_permission_lite(inode, nd);
754 if (err == -EAGAIN) { 768 if (err == -EAGAIN) {
755 err = permission(inode, MAY_EXEC, nd); 769 err = permission(inode, MAY_EXEC, nd);
@@ -802,7 +816,6 @@ static fastcall int __link_path_walk(const char * name, struct nameidata *nd)
802 if (err < 0) 816 if (err < 0)
803 break; 817 break;
804 } 818 }
805 nd->flags |= LOOKUP_CONTINUE;
806 /* This does the actual lookups.. */ 819 /* This does the actual lookups.. */
807 err = do_lookup(nd, &this, &next); 820 err = do_lookup(nd, &this, &next);
808 if (err) 821 if (err)
@@ -1052,6 +1065,70 @@ out:
1052 return retval; 1065 return retval;
1053} 1066}
1054 1067
1068static int __path_lookup_intent_open(const char *name, unsigned int lookup_flags,
1069 struct nameidata *nd, int open_flags, int create_mode)
1070{
1071 struct file *filp = get_empty_filp();
1072 int err;
1073
1074 if (filp == NULL)
1075 return -ENFILE;
1076 nd->intent.open.file = filp;
1077 nd->intent.open.flags = open_flags;
1078 nd->intent.open.create_mode = create_mode;
1079 err = path_lookup(name, lookup_flags|LOOKUP_OPEN, nd);
1080 if (IS_ERR(nd->intent.open.file)) {
1081 if (err == 0) {
1082 err = PTR_ERR(nd->intent.open.file);
1083 path_release(nd);
1084 }
1085 } else if (err != 0)
1086 release_open_intent(nd);
1087 return err;
1088}
1089
1090/**
1091 * path_lookup_open - lookup a file path with open intent
1092 * @name: pointer to file name
1093 * @lookup_flags: lookup intent flags
1094 * @nd: pointer to nameidata
1095 * @open_flags: open intent flags
1096 */
1097int path_lookup_open(const char *name, unsigned int lookup_flags,
1098 struct nameidata *nd, int open_flags)
1099{
1100 return __path_lookup_intent_open(name, lookup_flags, nd,
1101 open_flags, 0);
1102}
1103
1104/**
1105 * path_lookup_create - lookup a file path with open + create intent
1106 * @name: pointer to file name
1107 * @lookup_flags: lookup intent flags
1108 * @nd: pointer to nameidata
1109 * @open_flags: open intent flags
1110 * @create_mode: create intent flags
1111 */
1112int path_lookup_create(const char *name, unsigned int lookup_flags,
1113 struct nameidata *nd, int open_flags, int create_mode)
1114{
1115 return __path_lookup_intent_open(name, lookup_flags|LOOKUP_CREATE, nd,
1116 open_flags, create_mode);
1117}
1118
1119int __user_path_lookup_open(const char __user *name, unsigned int lookup_flags,
1120 struct nameidata *nd, int open_flags)
1121{
1122 char *tmp = getname(name);
1123 int err = PTR_ERR(tmp);
1124
1125 if (!IS_ERR(tmp)) {
1126 err = __path_lookup_intent_open(tmp, lookup_flags, nd, open_flags, 0);
1127 putname(tmp);
1128 }
1129 return err;
1130}
1131
1055/* 1132/*
1056 * Restricted form of lookup. Doesn't follow links, single-component only, 1133 * Restricted form of lookup. Doesn't follow links, single-component only,
1057 * needs parent already locked. Doesn't follow mounts. 1134 * needs parent already locked. Doesn't follow mounts.
@@ -1416,27 +1493,27 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
1416 */ 1493 */
1417int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) 1494int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
1418{ 1495{
1419 int acc_mode, error = 0; 1496 int acc_mode, error;
1420 struct path path; 1497 struct path path;
1421 struct dentry *dir; 1498 struct dentry *dir;
1422 int count = 0; 1499 int count = 0;
1423 1500
1424 acc_mode = ACC_MODE(flag); 1501 acc_mode = ACC_MODE(flag);
1425 1502
1503 /* O_TRUNC implies we need access checks for write permissions */
1504 if (flag & O_TRUNC)
1505 acc_mode |= MAY_WRITE;
1506
1426 /* Allow the LSM permission hook to distinguish append 1507 /* Allow the LSM permission hook to distinguish append
1427 access from general write access. */ 1508 access from general write access. */
1428 if (flag & O_APPEND) 1509 if (flag & O_APPEND)
1429 acc_mode |= MAY_APPEND; 1510 acc_mode |= MAY_APPEND;
1430 1511
1431 /* Fill in the open() intent data */
1432 nd->intent.open.flags = flag;
1433 nd->intent.open.create_mode = mode;
1434
1435 /* 1512 /*
1436 * The simplest case - just a plain lookup. 1513 * The simplest case - just a plain lookup.
1437 */ 1514 */
1438 if (!(flag & O_CREAT)) { 1515 if (!(flag & O_CREAT)) {
1439 error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd); 1516 error = path_lookup_open(pathname, lookup_flags(flag), nd, flag);
1440 if (error) 1517 if (error)
1441 return error; 1518 return error;
1442 goto ok; 1519 goto ok;
@@ -1445,7 +1522,7 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
1445 /* 1522 /*
1446 * Create - we need to know the parent. 1523 * Create - we need to know the parent.
1447 */ 1524 */
1448 error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd); 1525 error = path_lookup_create(pathname, LOOKUP_PARENT, nd, flag, mode);
1449 if (error) 1526 if (error)
1450 return error; 1527 return error;
1451 1528
@@ -1520,6 +1597,8 @@ ok:
1520exit_dput: 1597exit_dput:
1521 dput_path(&path, nd); 1598 dput_path(&path, nd);
1522exit: 1599exit:
1600 if (!IS_ERR(nd->intent.open.file))
1601 release_open_intent(nd);
1523 path_release(nd); 1602 path_release(nd);
1524 return error; 1603 return error;
1525 1604
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 4a36839f0bbd..44135af9894c 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -142,7 +142,7 @@ static void nfs_msync_inode(struct inode *inode)
142/* 142/*
143 * Basic procedure for returning a delegation to the server 143 * Basic procedure for returning a delegation to the server
144 */ 144 */
145int nfs_inode_return_delegation(struct inode *inode) 145int __nfs_inode_return_delegation(struct inode *inode)
146{ 146{
147 struct nfs4_client *clp = NFS_SERVER(inode)->nfs4_state; 147 struct nfs4_client *clp = NFS_SERVER(inode)->nfs4_state;
148 struct nfs_inode *nfsi = NFS_I(inode); 148 struct nfs_inode *nfsi = NFS_I(inode);
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 3f6c45a29d6a..8017846b561f 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -25,7 +25,7 @@ struct nfs_delegation {
25 25
26int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 26int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
27void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 27void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
28int nfs_inode_return_delegation(struct inode *inode); 28int __nfs_inode_return_delegation(struct inode *inode);
29int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); 29int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
30 30
31struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle); 31struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle);
@@ -47,11 +47,25 @@ static inline int nfs_have_delegation(struct inode *inode, int flags)
47 return 1; 47 return 1;
48 return 0; 48 return 0;
49} 49}
50
51static inline int nfs_inode_return_delegation(struct inode *inode)
52{
53 int err = 0;
54
55 if (NFS_I(inode)->delegation != NULL)
56 err = __nfs_inode_return_delegation(inode);
57 return err;
58}
50#else 59#else
51static inline int nfs_have_delegation(struct inode *inode, int flags) 60static inline int nfs_have_delegation(struct inode *inode, int flags)
52{ 61{
53 return 0; 62 return 0;
54} 63}
64
65static inline int nfs_inode_return_delegation(struct inode *inode)
66{
67 return 0;
68}
55#endif 69#endif
56 70
57#endif 71#endif
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 2df639f143e8..8272ed3fc707 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -532,6 +532,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
532 my_entry.eof = 0; 532 my_entry.eof = 0;
533 my_entry.fh = &fh; 533 my_entry.fh = &fh;
534 my_entry.fattr = &fattr; 534 my_entry.fattr = &fattr;
535 nfs_fattr_init(&fattr);
535 desc->entry = &my_entry; 536 desc->entry = &my_entry;
536 537
537 while(!desc->entry->eof) { 538 while(!desc->entry->eof) {
@@ -565,8 +566,6 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
565 } 566 }
566 } 567 }
567 unlock_kernel(); 568 unlock_kernel();
568 if (desc->error < 0)
569 return desc->error;
570 if (res < 0) 569 if (res < 0)
571 return res; 570 return res;
572 return 0; 571 return 0;
@@ -803,6 +802,7 @@ static int nfs_dentry_delete(struct dentry *dentry)
803 */ 802 */
804static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) 803static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
805{ 804{
805 nfs_inode_return_delegation(inode);
806 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { 806 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
807 lock_kernel(); 807 lock_kernel();
808 inode->i_nlink--; 808 inode->i_nlink--;
@@ -853,12 +853,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
853 dentry->d_op = NFS_PROTO(dir)->dentry_ops; 853 dentry->d_op = NFS_PROTO(dir)->dentry_ops;
854 854
855 lock_kernel(); 855 lock_kernel();
856 /* Revalidate parent directory attribute cache */
857 error = nfs_revalidate_inode(NFS_SERVER(dir), dir);
858 if (error < 0) {
859 res = ERR_PTR(error);
860 goto out_unlock;
861 }
862 856
863 /* If we're doing an exclusive create, optimize away the lookup */ 857 /* If we're doing an exclusive create, optimize away the lookup */
864 if (nfs_is_exclusive_create(dir, nd)) 858 if (nfs_is_exclusive_create(dir, nd))
@@ -916,7 +910,6 @@ static int is_atomic_open(struct inode *dir, struct nameidata *nd)
916static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 910static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
917{ 911{
918 struct dentry *res = NULL; 912 struct dentry *res = NULL;
919 struct inode *inode = NULL;
920 int error; 913 int error;
921 914
922 /* Check that we are indeed trying to open this file */ 915 /* Check that we are indeed trying to open this file */
@@ -930,8 +923,10 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
930 dentry->d_op = NFS_PROTO(dir)->dentry_ops; 923 dentry->d_op = NFS_PROTO(dir)->dentry_ops;
931 924
932 /* Let vfs_create() deal with O_EXCL */ 925 /* Let vfs_create() deal with O_EXCL */
933 if (nd->intent.open.flags & O_EXCL) 926 if (nd->intent.open.flags & O_EXCL) {
934 goto no_entry; 927 d_add(dentry, NULL);
928 goto out;
929 }
935 930
936 /* Open the file on the server */ 931 /* Open the file on the server */
937 lock_kernel(); 932 lock_kernel();
@@ -945,32 +940,30 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
945 940
946 if (nd->intent.open.flags & O_CREAT) { 941 if (nd->intent.open.flags & O_CREAT) {
947 nfs_begin_data_update(dir); 942 nfs_begin_data_update(dir);
948 inode = nfs4_atomic_open(dir, dentry, nd); 943 res = nfs4_atomic_open(dir, dentry, nd);
949 nfs_end_data_update(dir); 944 nfs_end_data_update(dir);
950 } else 945 } else
951 inode = nfs4_atomic_open(dir, dentry, nd); 946 res = nfs4_atomic_open(dir, dentry, nd);
952 unlock_kernel(); 947 unlock_kernel();
953 if (IS_ERR(inode)) { 948 if (IS_ERR(res)) {
954 error = PTR_ERR(inode); 949 error = PTR_ERR(res);
955 switch (error) { 950 switch (error) {
956 /* Make a negative dentry */ 951 /* Make a negative dentry */
957 case -ENOENT: 952 case -ENOENT:
958 inode = NULL; 953 res = NULL;
959 break; 954 goto out;
960 /* This turned out not to be a regular file */ 955 /* This turned out not to be a regular file */
956 case -EISDIR:
957 case -ENOTDIR:
958 goto no_open;
961 case -ELOOP: 959 case -ELOOP:
962 if (!(nd->intent.open.flags & O_NOFOLLOW)) 960 if (!(nd->intent.open.flags & O_NOFOLLOW))
963 goto no_open; 961 goto no_open;
964 /* case -EISDIR: */
965 /* case -EINVAL: */ 962 /* case -EINVAL: */
966 default: 963 default:
967 res = ERR_PTR(error);
968 goto out; 964 goto out;
969 } 965 }
970 } 966 } else if (res != NULL)
971no_entry:
972 res = d_add_unique(dentry, inode);
973 if (res != NULL)
974 dentry = res; 967 dentry = res;
975 nfs_renew_times(dentry); 968 nfs_renew_times(dentry);
976 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 969 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
@@ -1014,7 +1007,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1014 */ 1007 */
1015 lock_kernel(); 1008 lock_kernel();
1016 verifier = nfs_save_change_attribute(dir); 1009 verifier = nfs_save_change_attribute(dir);
1017 ret = nfs4_open_revalidate(dir, dentry, openflags); 1010 ret = nfs4_open_revalidate(dir, dentry, openflags, nd);
1018 if (!ret) 1011 if (!ret)
1019 nfs_set_verifier(dentry, verifier); 1012 nfs_set_verifier(dentry, verifier);
1020 unlock_kernel(); 1013 unlock_kernel();
@@ -1137,7 +1130,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1137 1130
1138 lock_kernel(); 1131 lock_kernel();
1139 nfs_begin_data_update(dir); 1132 nfs_begin_data_update(dir);
1140 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags); 1133 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd);
1141 nfs_end_data_update(dir); 1134 nfs_end_data_update(dir);
1142 if (error != 0) 1135 if (error != 0)
1143 goto out_err; 1136 goto out_err;
@@ -1332,6 +1325,7 @@ static int nfs_safe_remove(struct dentry *dentry)
1332 1325
1333 nfs_begin_data_update(dir); 1326 nfs_begin_data_update(dir);
1334 if (inode != NULL) { 1327 if (inode != NULL) {
1328 nfs_inode_return_delegation(inode);
1335 nfs_begin_data_update(inode); 1329 nfs_begin_data_update(inode);
1336 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); 1330 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
1337 /* The VFS may want to delete this inode */ 1331 /* The VFS may want to delete this inode */
@@ -1438,17 +1432,14 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
1438 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1432 old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
1439 dentry->d_parent->d_name.name, dentry->d_name.name); 1433 dentry->d_parent->d_name.name, dentry->d_name.name);
1440 1434
1441 /*
1442 * Drop the dentry in advance to force a new lookup.
1443 * Since nfs_proc_link doesn't return a file handle,
1444 * we can't use the existing dentry.
1445 */
1446 lock_kernel(); 1435 lock_kernel();
1447 d_drop(dentry);
1448
1449 nfs_begin_data_update(dir); 1436 nfs_begin_data_update(dir);
1450 nfs_begin_data_update(inode); 1437 nfs_begin_data_update(inode);
1451 error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); 1438 error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name);
1439 if (error == 0) {
1440 atomic_inc(&inode->i_count);
1441 d_instantiate(dentry, inode);
1442 }
1452 nfs_end_data_update(inode); 1443 nfs_end_data_update(inode);
1453 nfs_end_data_update(dir); 1444 nfs_end_data_update(dir);
1454 unlock_kernel(); 1445 unlock_kernel();
@@ -1512,9 +1503,11 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1512 */ 1503 */
1513 if (!new_inode) 1504 if (!new_inode)
1514 goto go_ahead; 1505 goto go_ahead;
1515 if (S_ISDIR(new_inode->i_mode)) 1506 if (S_ISDIR(new_inode->i_mode)) {
1516 goto out; 1507 error = -EISDIR;
1517 else if (atomic_read(&new_dentry->d_count) > 2) { 1508 if (!S_ISDIR(old_inode->i_mode))
1509 goto out;
1510 } else if (atomic_read(&new_dentry->d_count) > 2) {
1518 int err; 1511 int err;
1519 /* copy the target dentry's name */ 1512 /* copy the target dentry's name */
1520 dentry = d_alloc(new_dentry->d_parent, 1513 dentry = d_alloc(new_dentry->d_parent,
@@ -1539,7 +1532,8 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1539#endif 1532#endif
1540 goto out; 1533 goto out;
1541 } 1534 }
1542 } 1535 } else
1536 new_inode->i_nlink--;
1543 1537
1544go_ahead: 1538go_ahead:
1545 /* 1539 /*
@@ -1549,6 +1543,7 @@ go_ahead:
1549 nfs_wb_all(old_inode); 1543 nfs_wb_all(old_inode);
1550 shrink_dcache_parent(old_dentry); 1544 shrink_dcache_parent(old_dentry);
1551 } 1545 }
1546 nfs_inode_return_delegation(old_inode);
1552 1547
1553 if (new_inode) 1548 if (new_inode)
1554 d_delete(new_dentry); 1549 d_delete(new_dentry);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 6bdcfa95de94..57d3e77d97ee 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -205,8 +205,8 @@ nfs_file_flush(struct file *file)
205 if (!status) { 205 if (!status) {
206 status = ctx->error; 206 status = ctx->error;
207 ctx->error = 0; 207 ctx->error = 0;
208 if (!status && !nfs_have_delegation(inode, FMODE_READ)) 208 if (!status)
209 __nfs_revalidate_inode(NFS_SERVER(inode), inode); 209 nfs_revalidate_inode(NFS_SERVER(inode), inode);
210 } 210 }
211 unlock_kernel(); 211 unlock_kernel();
212 return status; 212 return status;
@@ -376,22 +376,31 @@ out_swapfile:
376 376
377static int do_getlk(struct file *filp, int cmd, struct file_lock *fl) 377static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
378{ 378{
379 struct file_lock *cfl;
379 struct inode *inode = filp->f_mapping->host; 380 struct inode *inode = filp->f_mapping->host;
380 int status = 0; 381 int status = 0;
381 382
382 lock_kernel(); 383 lock_kernel();
383 /* Use local locking if mounted with "-onolock" */ 384 /* Try local locking first */
384 if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)) 385 cfl = posix_test_lock(filp, fl);
385 status = NFS_PROTO(inode)->lock(filp, cmd, fl); 386 if (cfl != NULL) {
386 else { 387 locks_copy_lock(fl, cfl);
387 struct file_lock *cfl = posix_test_lock(filp, fl); 388 goto out;
388
389 fl->fl_type = F_UNLCK;
390 if (cfl != NULL)
391 memcpy(fl, cfl, sizeof(*fl));
392 } 389 }
390
391 if (nfs_have_delegation(inode, FMODE_READ))
392 goto out_noconflict;
393
394 if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)
395 goto out_noconflict;
396
397 status = NFS_PROTO(inode)->lock(filp, cmd, fl);
398out:
393 unlock_kernel(); 399 unlock_kernel();
394 return status; 400 return status;
401out_noconflict:
402 fl->fl_type = F_UNLCK;
403 goto out;
395} 404}
396 405
397static int do_vfs_lock(struct file *file, struct file_lock *fl) 406static int do_vfs_lock(struct file *file, struct file_lock *fl)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index d4eadeea128e..f2781ca42761 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -358,6 +358,35 @@ out_no_root:
358 return no_root_error; 358 return no_root_error;
359} 359}
360 360
361static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, unsigned int timeo, unsigned int retrans)
362{
363 to->to_initval = timeo * HZ / 10;
364 to->to_retries = retrans;
365 if (!to->to_retries)
366 to->to_retries = 2;
367
368 switch (proto) {
369 case IPPROTO_TCP:
370 if (!to->to_initval)
371 to->to_initval = 60 * HZ;
372 if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
373 to->to_initval = NFS_MAX_TCP_TIMEOUT;
374 to->to_increment = to->to_initval;
375 to->to_maxval = to->to_initval + (to->to_increment * to->to_retries);
376 to->to_exponential = 0;
377 break;
378 case IPPROTO_UDP:
379 default:
380 if (!to->to_initval)
381 to->to_initval = 11 * HZ / 10;
382 if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
383 to->to_initval = NFS_MAX_UDP_TIMEOUT;
384 to->to_maxval = NFS_MAX_UDP_TIMEOUT;
385 to->to_exponential = 1;
386 break;
387 }
388}
389
361/* 390/*
362 * Create an RPC client handle. 391 * Create an RPC client handle.
363 */ 392 */
@@ -367,22 +396,12 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
367 struct rpc_timeout timeparms; 396 struct rpc_timeout timeparms;
368 struct rpc_xprt *xprt = NULL; 397 struct rpc_xprt *xprt = NULL;
369 struct rpc_clnt *clnt = NULL; 398 struct rpc_clnt *clnt = NULL;
370 int tcp = (data->flags & NFS_MOUNT_TCP); 399 int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
371
372 /* Initialize timeout values */
373 timeparms.to_initval = data->timeo * HZ / 10;
374 timeparms.to_retries = data->retrans;
375 timeparms.to_maxval = tcp ? RPC_MAX_TCP_TIMEOUT : RPC_MAX_UDP_TIMEOUT;
376 timeparms.to_exponential = 1;
377 400
378 if (!timeparms.to_initval) 401 nfs_init_timeout_values(&timeparms, proto, data->timeo, data->retrans);
379 timeparms.to_initval = (tcp ? 600 : 11) * HZ / 10;
380 if (!timeparms.to_retries)
381 timeparms.to_retries = 5;
382 402
383 /* create transport and client */ 403 /* create transport and client */
384 xprt = xprt_create_proto(tcp ? IPPROTO_TCP : IPPROTO_UDP, 404 xprt = xprt_create_proto(proto, &server->addr, &timeparms);
385 &server->addr, &timeparms);
386 if (IS_ERR(xprt)) { 405 if (IS_ERR(xprt)) {
387 dprintk("%s: cannot create RPC transport. Error = %ld\n", 406 dprintk("%s: cannot create RPC transport. Error = %ld\n",
388 __FUNCTION__, PTR_ERR(xprt)); 407 __FUNCTION__, PTR_ERR(xprt));
@@ -576,7 +595,6 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
576 { NFS_MOUNT_SOFT, ",soft", ",hard" }, 595 { NFS_MOUNT_SOFT, ",soft", ",hard" },
577 { NFS_MOUNT_INTR, ",intr", "" }, 596 { NFS_MOUNT_INTR, ",intr", "" },
578 { NFS_MOUNT_POSIX, ",posix", "" }, 597 { NFS_MOUNT_POSIX, ",posix", "" },
579 { NFS_MOUNT_TCP, ",tcp", ",udp" },
580 { NFS_MOUNT_NOCTO, ",nocto", "" }, 598 { NFS_MOUNT_NOCTO, ",nocto", "" },
581 { NFS_MOUNT_NOAC, ",noac", "" }, 599 { NFS_MOUNT_NOAC, ",noac", "" },
582 { NFS_MOUNT_NONLM, ",nolock", ",lock" }, 600 { NFS_MOUNT_NONLM, ",nolock", ",lock" },
@@ -585,6 +603,8 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
585 }; 603 };
586 struct proc_nfs_info *nfs_infop; 604 struct proc_nfs_info *nfs_infop;
587 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb); 605 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
606 char buf[12];
607 char *proto;
588 608
589 seq_printf(m, ",v%d", nfss->rpc_ops->version); 609 seq_printf(m, ",v%d", nfss->rpc_ops->version);
590 seq_printf(m, ",rsize=%d", nfss->rsize); 610 seq_printf(m, ",rsize=%d", nfss->rsize);
@@ -603,6 +623,18 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
603 else 623 else
604 seq_puts(m, nfs_infop->nostr); 624 seq_puts(m, nfs_infop->nostr);
605 } 625 }
626 switch (nfss->client->cl_xprt->prot) {
627 case IPPROTO_TCP:
628 proto = "tcp";
629 break;
630 case IPPROTO_UDP:
631 proto = "udp";
632 break;
633 default:
634 snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot);
635 proto = buf;
636 }
637 seq_printf(m, ",proto=%s", proto);
606 seq_puts(m, ",addr="); 638 seq_puts(m, ",addr=");
607 seq_escape(m, nfss->hostname, " \t\n\\"); 639 seq_escape(m, nfss->hostname, " \t\n\\");
608 return 0; 640 return 0;
@@ -753,7 +785,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
753 else 785 else
754 init_special_inode(inode, inode->i_mode, fattr->rdev); 786 init_special_inode(inode, inode->i_mode, fattr->rdev);
755 787
756 nfsi->read_cache_jiffies = fattr->timestamp; 788 nfsi->read_cache_jiffies = fattr->time_start;
789 nfsi->last_updated = jiffies;
757 inode->i_atime = fattr->atime; 790 inode->i_atime = fattr->atime;
758 inode->i_mtime = fattr->mtime; 791 inode->i_mtime = fattr->mtime;
759 inode->i_ctime = fattr->ctime; 792 inode->i_ctime = fattr->ctime;
@@ -821,6 +854,11 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
821 filemap_fdatawait(inode->i_mapping); 854 filemap_fdatawait(inode->i_mapping);
822 nfs_wb_all(inode); 855 nfs_wb_all(inode);
823 } 856 }
857 /*
858 * Return any delegations if we're going to change ACLs
859 */
860 if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
861 nfs_inode_return_delegation(inode);
824 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); 862 error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
825 if (error == 0) 863 if (error == 0)
826 nfs_refresh_inode(inode, &fattr); 864 nfs_refresh_inode(inode, &fattr);
@@ -1019,15 +1057,11 @@ int nfs_open(struct inode *inode, struct file *filp)
1019 ctx->mode = filp->f_mode; 1057 ctx->mode = filp->f_mode;
1020 nfs_file_set_open_context(filp, ctx); 1058 nfs_file_set_open_context(filp, ctx);
1021 put_nfs_open_context(ctx); 1059 put_nfs_open_context(ctx);
1022 if ((filp->f_mode & FMODE_WRITE) != 0)
1023 nfs_begin_data_update(inode);
1024 return 0; 1060 return 0;
1025} 1061}
1026 1062
1027int nfs_release(struct inode *inode, struct file *filp) 1063int nfs_release(struct inode *inode, struct file *filp)
1028{ 1064{
1029 if ((filp->f_mode & FMODE_WRITE) != 0)
1030 nfs_end_data_update(inode);
1031 nfs_file_clear_open_context(filp); 1065 nfs_file_clear_open_context(filp);
1032 return 0; 1066 return 0;
1033} 1067}
@@ -1083,14 +1117,15 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1083 goto out; 1117 goto out;
1084 } 1118 }
1085 1119
1120 spin_lock(&inode->i_lock);
1086 status = nfs_update_inode(inode, &fattr, verifier); 1121 status = nfs_update_inode(inode, &fattr, verifier);
1087 if (status) { 1122 if (status) {
1123 spin_unlock(&inode->i_lock);
1088 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n", 1124 dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Ld) refresh failed, error=%d\n",
1089 inode->i_sb->s_id, 1125 inode->i_sb->s_id,
1090 (long long)NFS_FILEID(inode), status); 1126 (long long)NFS_FILEID(inode), status);
1091 goto out; 1127 goto out;
1092 } 1128 }
1093 spin_lock(&inode->i_lock);
1094 cache_validity = nfsi->cache_validity; 1129 cache_validity = nfsi->cache_validity;
1095 nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; 1130 nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
1096 1131
@@ -1098,7 +1133,7 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
1098 * We may need to keep the attributes marked as invalid if 1133 * We may need to keep the attributes marked as invalid if
1099 * we raced with nfs_end_attr_update(). 1134 * we raced with nfs_end_attr_update().
1100 */ 1135 */
1101 if (verifier == nfsi->cache_change_attribute) 1136 if (time_after_eq(verifier, nfsi->cache_change_attribute))
1102 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); 1137 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME);
1103 spin_unlock(&inode->i_lock); 1138 spin_unlock(&inode->i_lock);
1104 1139
@@ -1165,7 +1200,7 @@ void nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
1165 if (S_ISDIR(inode->i_mode)) { 1200 if (S_ISDIR(inode->i_mode)) {
1166 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); 1201 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
1167 /* This ensures we revalidate child dentries */ 1202 /* This ensures we revalidate child dentries */
1168 nfsi->cache_change_attribute++; 1203 nfsi->cache_change_attribute = jiffies;
1169 } 1204 }
1170 spin_unlock(&inode->i_lock); 1205 spin_unlock(&inode->i_lock);
1171 1206
@@ -1197,20 +1232,19 @@ void nfs_end_data_update(struct inode *inode)
1197 struct nfs_inode *nfsi = NFS_I(inode); 1232 struct nfs_inode *nfsi = NFS_I(inode);
1198 1233
1199 if (!nfs_have_delegation(inode, FMODE_READ)) { 1234 if (!nfs_have_delegation(inode, FMODE_READ)) {
1200 /* Mark the attribute cache for revalidation */ 1235 /* Directories and symlinks: invalidate page cache */
1201 spin_lock(&inode->i_lock); 1236 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) {
1202 nfsi->cache_validity |= NFS_INO_INVALID_ATTR; 1237 spin_lock(&inode->i_lock);
1203 /* Directories and symlinks: invalidate page cache too */
1204 if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
1205 nfsi->cache_validity |= NFS_INO_INVALID_DATA; 1238 nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1206 spin_unlock(&inode->i_lock); 1239 spin_unlock(&inode->i_lock);
1240 }
1207 } 1241 }
1208 nfsi->cache_change_attribute ++; 1242 nfsi->cache_change_attribute = jiffies;
1209 atomic_dec(&nfsi->data_updates); 1243 atomic_dec(&nfsi->data_updates);
1210} 1244}
1211 1245
1212/** 1246/**
1213 * nfs_refresh_inode - verify consistency of the inode attribute cache 1247 * nfs_check_inode_attributes - verify consistency of the inode attribute cache
1214 * @inode - pointer to inode 1248 * @inode - pointer to inode
1215 * @fattr - updated attributes 1249 * @fattr - updated attributes
1216 * 1250 *
@@ -1218,13 +1252,12 @@ void nfs_end_data_update(struct inode *inode)
1218 * so that fattr carries weak cache consistency data, then it may 1252 * so that fattr carries weak cache consistency data, then it may
1219 * also update the ctime/mtime/change_attribute. 1253 * also update the ctime/mtime/change_attribute.
1220 */ 1254 */
1221int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) 1255static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fattr)
1222{ 1256{
1223 struct nfs_inode *nfsi = NFS_I(inode); 1257 struct nfs_inode *nfsi = NFS_I(inode);
1224 loff_t cur_size, new_isize; 1258 loff_t cur_size, new_isize;
1225 int data_unstable; 1259 int data_unstable;
1226 1260
1227 spin_lock(&inode->i_lock);
1228 1261
1229 /* Are we in the process of updating data on the server? */ 1262 /* Are we in the process of updating data on the server? */
1230 data_unstable = nfs_caches_unstable(inode); 1263 data_unstable = nfs_caches_unstable(inode);
@@ -1288,11 +1321,67 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1288 if (!timespec_equal(&inode->i_atime, &fattr->atime)) 1321 if (!timespec_equal(&inode->i_atime, &fattr->atime))
1289 nfsi->cache_validity |= NFS_INO_INVALID_ATIME; 1322 nfsi->cache_validity |= NFS_INO_INVALID_ATIME;
1290 1323
1291 nfsi->read_cache_jiffies = fattr->timestamp; 1324 nfsi->read_cache_jiffies = fattr->time_start;
1292 spin_unlock(&inode->i_lock);
1293 return 0; 1325 return 0;
1294} 1326}
1295 1327
1328/**
1329 * nfs_refresh_inode - try to update the inode attribute cache
1330 * @inode - pointer to inode
1331 * @fattr - updated attributes
1332 *
1333 * Check that an RPC call that returned attributes has not overlapped with
1334 * other recent updates of the inode metadata, then decide whether it is
1335 * safe to do a full update of the inode attributes, or whether just to
1336 * call nfs_check_inode_attributes.
1337 */
1338int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1339{
1340 struct nfs_inode *nfsi = NFS_I(inode);
1341 int status;
1342
1343 if ((fattr->valid & NFS_ATTR_FATTR) == 0)
1344 return 0;
1345 spin_lock(&inode->i_lock);
1346 nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
1347 if (nfs_verify_change_attribute(inode, fattr->time_start))
1348 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME);
1349 if (time_after(fattr->time_start, nfsi->last_updated))
1350 status = nfs_update_inode(inode, fattr, fattr->time_start);
1351 else
1352 status = nfs_check_inode_attributes(inode, fattr);
1353
1354 spin_unlock(&inode->i_lock);
1355 return status;
1356}
1357
1358/**
1359 * nfs_post_op_update_inode - try to update the inode attribute cache
1360 * @inode - pointer to inode
1361 * @fattr - updated attributes
1362 *
1363 * After an operation that has changed the inode metadata, mark the
1364 * attribute cache as being invalid, then try to update it.
1365 */
1366int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1367{
1368 struct nfs_inode *nfsi = NFS_I(inode);
1369 int status = 0;
1370
1371 spin_lock(&inode->i_lock);
1372 if (unlikely((fattr->valid & NFS_ATTR_FATTR) == 0)) {
1373 nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS;
1374 goto out;
1375 }
1376 status = nfs_update_inode(inode, fattr, fattr->time_start);
1377 if (time_after_eq(fattr->time_start, nfsi->cache_change_attribute))
1378 nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME|NFS_INO_REVAL_PAGECACHE);
1379 nfsi->cache_change_attribute = jiffies;
1380out:
1381 spin_unlock(&inode->i_lock);
1382 return status;
1383}
1384
1296/* 1385/*
1297 * Many nfs protocol calls return the new file attributes after 1386 * Many nfs protocol calls return the new file attributes after
1298 * an operation. Here we update the inode to reflect the state 1387 * an operation. Here we update the inode to reflect the state
@@ -1328,20 +1417,17 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1328 goto out_err; 1417 goto out_err;
1329 } 1418 }
1330 1419
1331 spin_lock(&inode->i_lock);
1332
1333 /* 1420 /*
1334 * Make sure the inode's type hasn't changed. 1421 * Make sure the inode's type hasn't changed.
1335 */ 1422 */
1336 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { 1423 if ((inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT))
1337 spin_unlock(&inode->i_lock);
1338 goto out_changed; 1424 goto out_changed;
1339 }
1340 1425
1341 /* 1426 /*
1342 * Update the read time so we don't revalidate too often. 1427 * Update the read time so we don't revalidate too often.
1343 */ 1428 */
1344 nfsi->read_cache_jiffies = fattr->timestamp; 1429 nfsi->read_cache_jiffies = fattr->time_start;
1430 nfsi->last_updated = jiffies;
1345 1431
1346 /* Are we racing with known updates of the metadata on the server? */ 1432 /* Are we racing with known updates of the metadata on the server? */
1347 data_unstable = ! (nfs_verify_change_attribute(inode, verifier) || 1433 data_unstable = ! (nfs_verify_change_attribute(inode, verifier) ||
@@ -1354,7 +1440,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1354 /* Do we perhaps have any outstanding writes? */ 1440 /* Do we perhaps have any outstanding writes? */
1355 if (nfsi->npages == 0) { 1441 if (nfsi->npages == 0) {
1356 /* No, but did we race with nfs_end_data_update()? */ 1442 /* No, but did we race with nfs_end_data_update()? */
1357 if (verifier == nfsi->cache_change_attribute) { 1443 if (time_after_eq(verifier, nfsi->cache_change_attribute)) {
1358 inode->i_size = new_isize; 1444 inode->i_size = new_isize;
1359 invalid |= NFS_INO_INVALID_DATA; 1445 invalid |= NFS_INO_INVALID_DATA;
1360 } 1446 }
@@ -1430,7 +1516,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1430 if (!nfs_have_delegation(inode, FMODE_READ)) 1516 if (!nfs_have_delegation(inode, FMODE_READ))
1431 nfsi->cache_validity |= invalid; 1517 nfsi->cache_validity |= invalid;
1432 1518
1433 spin_unlock(&inode->i_lock);
1434 return 0; 1519 return 0;
1435 out_changed: 1520 out_changed:
1436 /* 1521 /*
@@ -1639,8 +1724,7 @@ static void nfs4_clear_inode(struct inode *inode)
1639 struct nfs_inode *nfsi = NFS_I(inode); 1724 struct nfs_inode *nfsi = NFS_I(inode);
1640 1725
1641 /* If we are holding a delegation, return it! */ 1726 /* If we are holding a delegation, return it! */
1642 if (nfsi->delegation != NULL) 1727 nfs_inode_return_delegation(inode);
1643 nfs_inode_return_delegation(inode);
1644 /* First call standard NFS clear_inode() code */ 1728 /* First call standard NFS clear_inode() code */
1645 nfs_clear_inode(inode); 1729 nfs_clear_inode(inode);
1646 /* Now clear out any remaining state */ 1730 /* Now clear out any remaining state */
@@ -1669,7 +1753,7 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data,
1669 struct rpc_clnt *clnt = NULL; 1753 struct rpc_clnt *clnt = NULL;
1670 struct rpc_timeout timeparms; 1754 struct rpc_timeout timeparms;
1671 rpc_authflavor_t authflavour; 1755 rpc_authflavor_t authflavour;
1672 int proto, err = -EIO; 1756 int err = -EIO;
1673 1757
1674 sb->s_blocksize_bits = 0; 1758 sb->s_blocksize_bits = 0;
1675 sb->s_blocksize = 0; 1759 sb->s_blocksize = 0;
@@ -1687,30 +1771,8 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data,
1687 server->acdirmax = data->acdirmax*HZ; 1771 server->acdirmax = data->acdirmax*HZ;
1688 1772
1689 server->rpc_ops = &nfs_v4_clientops; 1773 server->rpc_ops = &nfs_v4_clientops;
1690 /* Initialize timeout values */
1691
1692 timeparms.to_initval = data->timeo * HZ / 10;
1693 timeparms.to_retries = data->retrans;
1694 timeparms.to_exponential = 1;
1695 if (!timeparms.to_retries)
1696 timeparms.to_retries = 5;
1697 1774
1698 proto = data->proto; 1775 nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans);
1699 /* Which IP protocol do we use? */
1700 switch (proto) {
1701 case IPPROTO_TCP:
1702 timeparms.to_maxval = RPC_MAX_TCP_TIMEOUT;
1703 if (!timeparms.to_initval)
1704 timeparms.to_initval = 600 * HZ / 10;
1705 break;
1706 case IPPROTO_UDP:
1707 timeparms.to_maxval = RPC_MAX_UDP_TIMEOUT;
1708 if (!timeparms.to_initval)
1709 timeparms.to_initval = 11 * HZ / 10;
1710 break;
1711 default:
1712 return -EINVAL;
1713 }
1714 1776
1715 clp = nfs4_get_client(&server->addr.sin_addr); 1777 clp = nfs4_get_client(&server->addr.sin_addr);
1716 if (!clp) { 1778 if (!clp) {
@@ -1735,7 +1797,7 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data,
1735 1797
1736 down_write(&clp->cl_sem); 1798 down_write(&clp->cl_sem);
1737 if (IS_ERR(clp->cl_rpcclient)) { 1799 if (IS_ERR(clp->cl_rpcclient)) {
1738 xprt = xprt_create_proto(proto, &server->addr, &timeparms); 1800 xprt = xprt_create_proto(data->proto, &server->addr, &timeparms);
1739 if (IS_ERR(xprt)) { 1801 if (IS_ERR(xprt)) {
1740 up_write(&clp->cl_sem); 1802 up_write(&clp->cl_sem);
1741 err = PTR_ERR(xprt); 1803 err = PTR_ERR(xprt);
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index d91b69044a4d..59049e864ca7 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -143,7 +143,6 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
143 fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; 143 fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO;
144 fattr->rdev = 0; 144 fattr->rdev = 0;
145 } 145 }
146 fattr->timestamp = jiffies;
147 return p; 146 return p;
148} 147}
149 148
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index edc95514046d..92c870d19ccd 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -78,7 +78,7 @@ nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
78 int status; 78 int status;
79 79
80 dprintk("%s: call fsinfo\n", __FUNCTION__); 80 dprintk("%s: call fsinfo\n", __FUNCTION__);
81 info->fattr->valid = 0; 81 nfs_fattr_init(info->fattr);
82 status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0); 82 status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0);
83 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status); 83 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status);
84 if (!(info->fattr->valid & NFS_ATTR_FATTR)) { 84 if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
@@ -98,7 +98,7 @@ nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
98 int status; 98 int status;
99 99
100 dprintk("NFS call getattr\n"); 100 dprintk("NFS call getattr\n");
101 fattr->valid = 0; 101 nfs_fattr_init(fattr);
102 status = rpc_call(server->client, NFS3PROC_GETATTR, 102 status = rpc_call(server->client, NFS3PROC_GETATTR,
103 fhandle, fattr, 0); 103 fhandle, fattr, 0);
104 dprintk("NFS reply getattr: %d\n", status); 104 dprintk("NFS reply getattr: %d\n", status);
@@ -117,7 +117,7 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
117 int status; 117 int status;
118 118
119 dprintk("NFS call setattr\n"); 119 dprintk("NFS call setattr\n");
120 fattr->valid = 0; 120 nfs_fattr_init(fattr);
121 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0); 121 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0);
122 if (status == 0) 122 if (status == 0)
123 nfs_setattr_update_inode(inode, sattr); 123 nfs_setattr_update_inode(inode, sattr);
@@ -143,8 +143,8 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name,
143 int status; 143 int status;
144 144
145 dprintk("NFS call lookup %s\n", name->name); 145 dprintk("NFS call lookup %s\n", name->name);
146 dir_attr.valid = 0; 146 nfs_fattr_init(&dir_attr);
147 fattr->valid = 0; 147 nfs_fattr_init(fattr);
148 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_LOOKUP, &arg, &res, 0); 148 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_LOOKUP, &arg, &res, 0);
149 if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) 149 if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR))
150 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_GETATTR, 150 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_GETATTR,
@@ -174,7 +174,6 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
174 int status; 174 int status;
175 175
176 dprintk("NFS call access\n"); 176 dprintk("NFS call access\n");
177 fattr.valid = 0;
178 177
179 if (mode & MAY_READ) 178 if (mode & MAY_READ)
180 arg.access |= NFS3_ACCESS_READ; 179 arg.access |= NFS3_ACCESS_READ;
@@ -189,6 +188,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
189 if (mode & MAY_EXEC) 188 if (mode & MAY_EXEC)
190 arg.access |= NFS3_ACCESS_EXECUTE; 189 arg.access |= NFS3_ACCESS_EXECUTE;
191 } 190 }
191 nfs_fattr_init(&fattr);
192 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 192 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
193 nfs_refresh_inode(inode, &fattr); 193 nfs_refresh_inode(inode, &fattr);
194 if (status == 0) { 194 if (status == 0) {
@@ -217,7 +217,7 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page,
217 int status; 217 int status;
218 218
219 dprintk("NFS call readlink\n"); 219 dprintk("NFS call readlink\n");
220 fattr.valid = 0; 220 nfs_fattr_init(&fattr);
221 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_READLINK, 221 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_READLINK,
222 &args, &fattr, 0); 222 &args, &fattr, 0);
223 nfs_refresh_inode(inode, &fattr); 223 nfs_refresh_inode(inode, &fattr);
@@ -240,7 +240,7 @@ static int nfs3_proc_read(struct nfs_read_data *rdata)
240 240
241 dprintk("NFS call read %d @ %Ld\n", rdata->args.count, 241 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
242 (long long) rdata->args.offset); 242 (long long) rdata->args.offset);
243 fattr->valid = 0; 243 nfs_fattr_init(fattr);
244 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags); 244 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
245 if (status >= 0) 245 if (status >= 0)
246 nfs_refresh_inode(inode, fattr); 246 nfs_refresh_inode(inode, fattr);
@@ -263,10 +263,10 @@ static int nfs3_proc_write(struct nfs_write_data *wdata)
263 263
264 dprintk("NFS call write %d @ %Ld\n", wdata->args.count, 264 dprintk("NFS call write %d @ %Ld\n", wdata->args.count,
265 (long long) wdata->args.offset); 265 (long long) wdata->args.offset);
266 fattr->valid = 0; 266 nfs_fattr_init(fattr);
267 status = rpc_call_sync(NFS_CLIENT(inode), &msg, rpcflags); 267 status = rpc_call_sync(NFS_CLIENT(inode), &msg, rpcflags);
268 if (status >= 0) 268 if (status >= 0)
269 nfs_refresh_inode(inode, fattr); 269 nfs_post_op_update_inode(inode, fattr);
270 dprintk("NFS reply write: %d\n", status); 270 dprintk("NFS reply write: %d\n", status);
271 return status < 0? status : wdata->res.count; 271 return status < 0? status : wdata->res.count;
272} 272}
@@ -285,10 +285,10 @@ static int nfs3_proc_commit(struct nfs_write_data *cdata)
285 285
286 dprintk("NFS call commit %d @ %Ld\n", cdata->args.count, 286 dprintk("NFS call commit %d @ %Ld\n", cdata->args.count,
287 (long long) cdata->args.offset); 287 (long long) cdata->args.offset);
288 fattr->valid = 0; 288 nfs_fattr_init(fattr);
289 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 289 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
290 if (status >= 0) 290 if (status >= 0)
291 nfs_refresh_inode(inode, fattr); 291 nfs_post_op_update_inode(inode, fattr);
292 dprintk("NFS reply commit: %d\n", status); 292 dprintk("NFS reply commit: %d\n", status);
293 return status; 293 return status;
294} 294}
@@ -299,7 +299,7 @@ static int nfs3_proc_commit(struct nfs_write_data *cdata)
299 */ 299 */
300static int 300static int
301nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 301nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
302 int flags) 302 int flags, struct nameidata *nd)
303{ 303{
304 struct nfs_fh fhandle; 304 struct nfs_fh fhandle;
305 struct nfs_fattr fattr; 305 struct nfs_fattr fattr;
@@ -329,10 +329,10 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
329 sattr->ia_mode &= ~current->fs->umask; 329 sattr->ia_mode &= ~current->fs->umask;
330 330
331again: 331again:
332 dir_attr.valid = 0; 332 nfs_fattr_init(&dir_attr);
333 fattr.valid = 0; 333 nfs_fattr_init(&fattr);
334 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_CREATE, &arg, &res, 0); 334 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_CREATE, &arg, &res, 0);
335 nfs_refresh_inode(dir, &dir_attr); 335 nfs_post_op_update_inode(dir, &dir_attr);
336 336
337 /* If the server doesn't support the exclusive creation semantics, 337 /* If the server doesn't support the exclusive creation semantics,
338 * try again with simple 'guarded' mode. */ 338 * try again with simple 'guarded' mode. */
@@ -401,9 +401,9 @@ nfs3_proc_remove(struct inode *dir, struct qstr *name)
401 int status; 401 int status;
402 402
403 dprintk("NFS call remove %s\n", name->name); 403 dprintk("NFS call remove %s\n", name->name);
404 dir_attr.valid = 0; 404 nfs_fattr_init(&dir_attr);
405 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 405 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
406 nfs_refresh_inode(dir, &dir_attr); 406 nfs_post_op_update_inode(dir, &dir_attr);
407 dprintk("NFS reply remove: %d\n", status); 407 dprintk("NFS reply remove: %d\n", status);
408 return status; 408 return status;
409} 409}
@@ -422,7 +422,7 @@ nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr
422 ptr->arg.fh = NFS_FH(dir->d_inode); 422 ptr->arg.fh = NFS_FH(dir->d_inode);
423 ptr->arg.name = name->name; 423 ptr->arg.name = name->name;
424 ptr->arg.len = name->len; 424 ptr->arg.len = name->len;
425 ptr->res.valid = 0; 425 nfs_fattr_init(&ptr->res);
426 msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE]; 426 msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
427 msg->rpc_argp = &ptr->arg; 427 msg->rpc_argp = &ptr->arg;
428 msg->rpc_resp = &ptr->res; 428 msg->rpc_resp = &ptr->res;
@@ -439,7 +439,7 @@ nfs3_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
439 return 1; 439 return 1;
440 if (msg->rpc_argp) { 440 if (msg->rpc_argp) {
441 dir_attr = (struct nfs_fattr*)msg->rpc_resp; 441 dir_attr = (struct nfs_fattr*)msg->rpc_resp;
442 nfs_refresh_inode(dir->d_inode, dir_attr); 442 nfs_post_op_update_inode(dir->d_inode, dir_attr);
443 kfree(msg->rpc_argp); 443 kfree(msg->rpc_argp);
444 } 444 }
445 return 0; 445 return 0;
@@ -465,11 +465,11 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,
465 int status; 465 int status;
466 466
467 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); 467 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
468 old_dir_attr.valid = 0; 468 nfs_fattr_init(&old_dir_attr);
469 new_dir_attr.valid = 0; 469 nfs_fattr_init(&new_dir_attr);
470 status = rpc_call(NFS_CLIENT(old_dir), NFS3PROC_RENAME, &arg, &res, 0); 470 status = rpc_call(NFS_CLIENT(old_dir), NFS3PROC_RENAME, &arg, &res, 0);
471 nfs_refresh_inode(old_dir, &old_dir_attr); 471 nfs_post_op_update_inode(old_dir, &old_dir_attr);
472 nfs_refresh_inode(new_dir, &new_dir_attr); 472 nfs_post_op_update_inode(new_dir, &new_dir_attr);
473 dprintk("NFS reply rename: %d\n", status); 473 dprintk("NFS reply rename: %d\n", status);
474 return status; 474 return status;
475} 475}
@@ -491,11 +491,11 @@ nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
491 int status; 491 int status;
492 492
493 dprintk("NFS call link %s\n", name->name); 493 dprintk("NFS call link %s\n", name->name);
494 dir_attr.valid = 0; 494 nfs_fattr_init(&dir_attr);
495 fattr.valid = 0; 495 nfs_fattr_init(&fattr);
496 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_LINK, &arg, &res, 0); 496 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_LINK, &arg, &res, 0);
497 nfs_refresh_inode(dir, &dir_attr); 497 nfs_post_op_update_inode(dir, &dir_attr);
498 nfs_refresh_inode(inode, &fattr); 498 nfs_post_op_update_inode(inode, &fattr);
499 dprintk("NFS reply link: %d\n", status); 499 dprintk("NFS reply link: %d\n", status);
500 return status; 500 return status;
501} 501}
@@ -524,10 +524,10 @@ nfs3_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
524 if (path->len > NFS3_MAXPATHLEN) 524 if (path->len > NFS3_MAXPATHLEN)
525 return -ENAMETOOLONG; 525 return -ENAMETOOLONG;
526 dprintk("NFS call symlink %s -> %s\n", name->name, path->name); 526 dprintk("NFS call symlink %s -> %s\n", name->name, path->name);
527 dir_attr.valid = 0; 527 nfs_fattr_init(&dir_attr);
528 fattr->valid = 0; 528 nfs_fattr_init(fattr);
529 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_SYMLINK, &arg, &res, 0); 529 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_SYMLINK, &arg, &res, 0);
530 nfs_refresh_inode(dir, &dir_attr); 530 nfs_post_op_update_inode(dir, &dir_attr);
531 dprintk("NFS reply symlink: %d\n", status); 531 dprintk("NFS reply symlink: %d\n", status);
532 return status; 532 return status;
533} 533}
@@ -552,13 +552,13 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
552 int status; 552 int status;
553 553
554 dprintk("NFS call mkdir %s\n", dentry->d_name.name); 554 dprintk("NFS call mkdir %s\n", dentry->d_name.name);
555 dir_attr.valid = 0;
556 fattr.valid = 0;
557 555
558 sattr->ia_mode &= ~current->fs->umask; 556 sattr->ia_mode &= ~current->fs->umask;
559 557
558 nfs_fattr_init(&dir_attr);
559 nfs_fattr_init(&fattr);
560 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKDIR, &arg, &res, 0); 560 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKDIR, &arg, &res, 0);
561 nfs_refresh_inode(dir, &dir_attr); 561 nfs_post_op_update_inode(dir, &dir_attr);
562 if (status != 0) 562 if (status != 0)
563 goto out; 563 goto out;
564 status = nfs_instantiate(dentry, &fhandle, &fattr); 564 status = nfs_instantiate(dentry, &fhandle, &fattr);
@@ -582,9 +582,9 @@ nfs3_proc_rmdir(struct inode *dir, struct qstr *name)
582 int status; 582 int status;
583 583
584 dprintk("NFS call rmdir %s\n", name->name); 584 dprintk("NFS call rmdir %s\n", name->name);
585 dir_attr.valid = 0; 585 nfs_fattr_init(&dir_attr);
586 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_RMDIR, &arg, &dir_attr, 0); 586 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_RMDIR, &arg, &dir_attr, 0);
587 nfs_refresh_inode(dir, &dir_attr); 587 nfs_post_op_update_inode(dir, &dir_attr);
588 dprintk("NFS reply rmdir: %d\n", status); 588 dprintk("NFS reply rmdir: %d\n", status);
589 return status; 589 return status;
590} 590}
@@ -634,7 +634,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
634 dprintk("NFS call readdir%s %d\n", 634 dprintk("NFS call readdir%s %d\n",
635 plus? "plus" : "", (unsigned int) cookie); 635 plus? "plus" : "", (unsigned int) cookie);
636 636
637 dir_attr.valid = 0; 637 nfs_fattr_init(&dir_attr);
638 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 638 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
639 nfs_refresh_inode(dir, &dir_attr); 639 nfs_refresh_inode(dir, &dir_attr);
640 dprintk("NFS reply readdir: %d\n", status); 640 dprintk("NFS reply readdir: %d\n", status);
@@ -676,10 +676,10 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
676 676
677 sattr->ia_mode &= ~current->fs->umask; 677 sattr->ia_mode &= ~current->fs->umask;
678 678
679 dir_attr.valid = 0; 679 nfs_fattr_init(&dir_attr);
680 fattr.valid = 0; 680 nfs_fattr_init(&fattr);
681 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0); 681 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0);
682 nfs_refresh_inode(dir, &dir_attr); 682 nfs_post_op_update_inode(dir, &dir_attr);
683 if (status != 0) 683 if (status != 0)
684 goto out; 684 goto out;
685 status = nfs_instantiate(dentry, &fh, &fattr); 685 status = nfs_instantiate(dentry, &fh, &fattr);
@@ -698,7 +698,7 @@ nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
698 int status; 698 int status;
699 699
700 dprintk("NFS call fsstat\n"); 700 dprintk("NFS call fsstat\n");
701 stat->fattr->valid = 0; 701 nfs_fattr_init(stat->fattr);
702 status = rpc_call(server->client, NFS3PROC_FSSTAT, fhandle, stat, 0); 702 status = rpc_call(server->client, NFS3PROC_FSSTAT, fhandle, stat, 0);
703 dprintk("NFS reply statfs: %d\n", status); 703 dprintk("NFS reply statfs: %d\n", status);
704 return status; 704 return status;
@@ -711,7 +711,7 @@ nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
711 int status; 711 int status;
712 712
713 dprintk("NFS call fsinfo\n"); 713 dprintk("NFS call fsinfo\n");
714 info->fattr->valid = 0; 714 nfs_fattr_init(info->fattr);
715 status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0); 715 status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0);
716 dprintk("NFS reply fsinfo: %d\n", status); 716 dprintk("NFS reply fsinfo: %d\n", status);
717 return status; 717 return status;
@@ -724,7 +724,7 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
724 int status; 724 int status;
725 725
726 dprintk("NFS call pathconf\n"); 726 dprintk("NFS call pathconf\n");
727 info->fattr->valid = 0; 727 nfs_fattr_init(info->fattr);
728 status = rpc_call(server->client, NFS3PROC_PATHCONF, fhandle, info, 0); 728 status = rpc_call(server->client, NFS3PROC_PATHCONF, fhandle, info, 0);
729 dprintk("NFS reply pathconf: %d\n", status); 729 dprintk("NFS reply pathconf: %d\n", status);
730 return status; 730 return status;
@@ -735,7 +735,7 @@ extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int);
735static void 735static void
736nfs3_read_done(struct rpc_task *task) 736nfs3_read_done(struct rpc_task *task)
737{ 737{
738 struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; 738 struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata;
739 739
740 if (nfs3_async_handle_jukebox(task)) 740 if (nfs3_async_handle_jukebox(task))
741 return; 741 return;
@@ -775,7 +775,7 @@ nfs3_write_done(struct rpc_task *task)
775 return; 775 return;
776 data = (struct nfs_write_data *)task->tk_calldata; 776 data = (struct nfs_write_data *)task->tk_calldata;
777 if (task->tk_status >= 0) 777 if (task->tk_status >= 0)
778 nfs_refresh_inode(data->inode, data->res.fattr); 778 nfs_post_op_update_inode(data->inode, data->res.fattr);
779 nfs_writeback_done(task); 779 nfs_writeback_done(task);
780} 780}
781 781
@@ -819,7 +819,7 @@ nfs3_commit_done(struct rpc_task *task)
819 return; 819 return;
820 data = (struct nfs_write_data *)task->tk_calldata; 820 data = (struct nfs_write_data *)task->tk_calldata;
821 if (task->tk_status >= 0) 821 if (task->tk_status >= 0)
822 nfs_refresh_inode(data->inode, data->res.fattr); 822 nfs_post_op_update_inode(data->inode, data->res.fattr);
823 nfs_commit_done(task); 823 nfs_commit_done(task);
824} 824}
825 825
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index db4a904810a4..0498bd36602c 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -174,7 +174,6 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
174 174
175 /* Update the mode bits */ 175 /* Update the mode bits */
176 fattr->valid |= (NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3); 176 fattr->valid |= (NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3);
177 fattr->timestamp = jiffies;
178 return p; 177 return p;
179} 178}
180 179
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index ec1a22d7b876..78a53f5a9f18 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -93,25 +93,50 @@ struct nfs4_client {
93}; 93};
94 94
95/* 95/*
96 * struct rpc_sequence ensures that RPC calls are sent in the exact
97 * order that they appear on the list.
98 */
99struct rpc_sequence {
100 struct rpc_wait_queue wait; /* RPC call delay queue */
101 spinlock_t lock; /* Protects the list */
102 struct list_head list; /* Defines sequence of RPC calls */
103};
104
105#define NFS_SEQID_CONFIRMED 1
106struct nfs_seqid_counter {
107 struct rpc_sequence *sequence;
108 int flags;
109 u32 counter;
110};
111
112struct nfs_seqid {
113 struct nfs_seqid_counter *sequence;
114 struct list_head list;
115};
116
117static inline void nfs_confirm_seqid(struct nfs_seqid_counter *seqid, int status)
118{
119 if (seqid_mutating_err(-status))
120 seqid->flags |= NFS_SEQID_CONFIRMED;
121}
122
123/*
96 * NFS4 state_owners and lock_owners are simply labels for ordered 124 * NFS4 state_owners and lock_owners are simply labels for ordered
97 * sequences of RPC calls. Their sole purpose is to provide once-only 125 * sequences of RPC calls. Their sole purpose is to provide once-only
98 * semantics by allowing the server to identify replayed requests. 126 * semantics by allowing the server to identify replayed requests.
99 *
100 * The ->so_sema is held during all state_owner seqid-mutating operations:
101 * OPEN, OPEN_DOWNGRADE, and CLOSE. Its purpose is to properly serialize
102 * so_seqid.
103 */ 127 */
104struct nfs4_state_owner { 128struct nfs4_state_owner {
129 spinlock_t so_lock;
105 struct list_head so_list; /* per-clientid list of state_owners */ 130 struct list_head so_list; /* per-clientid list of state_owners */
106 struct nfs4_client *so_client; 131 struct nfs4_client *so_client;
107 u32 so_id; /* 32-bit identifier, unique */ 132 u32 so_id; /* 32-bit identifier, unique */
108 struct semaphore so_sema;
109 u32 so_seqid; /* protected by so_sema */
110 atomic_t so_count; 133 atomic_t so_count;
111 134
112 struct rpc_cred *so_cred; /* Associated cred */ 135 struct rpc_cred *so_cred; /* Associated cred */
113 struct list_head so_states; 136 struct list_head so_states;
114 struct list_head so_delegations; 137 struct list_head so_delegations;
138 struct nfs_seqid_counter so_seqid;
139 struct rpc_sequence so_sequence;
115}; 140};
116 141
117/* 142/*
@@ -132,7 +157,7 @@ struct nfs4_lock_state {
132 fl_owner_t ls_owner; /* POSIX lock owner */ 157 fl_owner_t ls_owner; /* POSIX lock owner */
133#define NFS_LOCK_INITIALIZED 1 158#define NFS_LOCK_INITIALIZED 1
134 int ls_flags; 159 int ls_flags;
135 u32 ls_seqid; 160 struct nfs_seqid_counter ls_seqid;
136 u32 ls_id; 161 u32 ls_id;
137 nfs4_stateid ls_stateid; 162 nfs4_stateid ls_stateid;
138 atomic_t ls_count; 163 atomic_t ls_count;
@@ -153,7 +178,6 @@ struct nfs4_state {
153 struct inode *inode; /* Pointer to the inode */ 178 struct inode *inode; /* Pointer to the inode */
154 179
155 unsigned long flags; /* Do we hold any locks? */ 180 unsigned long flags; /* Do we hold any locks? */
156 struct semaphore lock_sema; /* Serializes file locking operations */
157 spinlock_t state_lock; /* Protects the lock_states list */ 181 spinlock_t state_lock; /* Protects the lock_states list */
158 182
159 nfs4_stateid stateid; 183 nfs4_stateid stateid;
@@ -191,8 +215,8 @@ extern int nfs4_proc_setclientid_confirm(struct nfs4_client *);
191extern int nfs4_proc_async_renew(struct nfs4_client *); 215extern int nfs4_proc_async_renew(struct nfs4_client *);
192extern int nfs4_proc_renew(struct nfs4_client *); 216extern int nfs4_proc_renew(struct nfs4_client *);
193extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode); 217extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode);
194extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); 218extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
195extern int nfs4_open_revalidate(struct inode *, struct dentry *, int); 219extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *);
196 220
197extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; 221extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
198extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; 222extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops;
@@ -224,12 +248,17 @@ extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state
224extern void nfs4_put_open_state(struct nfs4_state *); 248extern void nfs4_put_open_state(struct nfs4_state *);
225extern void nfs4_close_state(struct nfs4_state *, mode_t); 249extern void nfs4_close_state(struct nfs4_state *, mode_t);
226extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode); 250extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode);
227extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp);
228extern void nfs4_schedule_state_recovery(struct nfs4_client *); 251extern void nfs4_schedule_state_recovery(struct nfs4_client *);
252extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
229extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); 253extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
230extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls);
231extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); 254extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
232 255
256extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter);
257extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task);
258extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid);
259extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid);
260extern void nfs_free_seqid(struct nfs_seqid *seqid);
261
233extern const nfs4_stateid zero_stateid; 262extern const nfs4_stateid zero_stateid;
234 263
235/* nfs4xdr.c */ 264/* nfs4xdr.c */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 9701ca8c9428..933e13b383f8 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -47,6 +47,7 @@
47#include <linux/nfs_page.h> 47#include <linux/nfs_page.h>
48#include <linux/smp_lock.h> 48#include <linux/smp_lock.h>
49#include <linux/namei.h> 49#include <linux/namei.h>
50#include <linux/mount.h>
50 51
51#include "nfs4_fs.h" 52#include "nfs4_fs.h"
52#include "delegation.h" 53#include "delegation.h"
@@ -56,10 +57,11 @@
56#define NFS4_POLL_RETRY_MIN (1*HZ) 57#define NFS4_POLL_RETRY_MIN (1*HZ)
57#define NFS4_POLL_RETRY_MAX (15*HZ) 58#define NFS4_POLL_RETRY_MAX (15*HZ)
58 59
60static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid, struct nfs_seqid *seqid);
59static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); 61static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
60static int nfs4_async_handle_error(struct rpc_task *, struct nfs_server *); 62static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *);
61static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); 63static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry);
62static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struct nfs4_exception *exception); 64static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception);
63extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); 65extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
64extern struct rpc_procinfo nfs4_procedures[]; 66extern struct rpc_procinfo nfs4_procedures[];
65 67
@@ -185,8 +187,26 @@ static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinf
185{ 187{
186 struct nfs_inode *nfsi = NFS_I(inode); 188 struct nfs_inode *nfsi = NFS_I(inode);
187 189
190 spin_lock(&inode->i_lock);
191 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
188 if (cinfo->before == nfsi->change_attr && cinfo->atomic) 192 if (cinfo->before == nfsi->change_attr && cinfo->atomic)
189 nfsi->change_attr = cinfo->after; 193 nfsi->change_attr = cinfo->after;
194 spin_unlock(&inode->i_lock);
195}
196
197/* Helper for asynchronous RPC calls */
198static int nfs4_call_async(struct rpc_clnt *clnt, rpc_action tk_begin,
199 rpc_action tk_exit, void *calldata)
200{
201 struct rpc_task *task;
202
203 if (!(task = rpc_new_task(clnt, tk_exit, RPC_TASK_ASYNC)))
204 return -ENOMEM;
205
206 task->tk_calldata = calldata;
207 task->tk_action = tk_begin;
208 rpc_execute(task);
209 return 0;
190} 210}
191 211
192static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, int open_flags) 212static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, int open_flags)
@@ -195,6 +215,7 @@ static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid,
195 215
196 open_flags &= (FMODE_READ|FMODE_WRITE); 216 open_flags &= (FMODE_READ|FMODE_WRITE);
197 /* Protect against nfs4_find_state() */ 217 /* Protect against nfs4_find_state() */
218 spin_lock(&state->owner->so_lock);
198 spin_lock(&inode->i_lock); 219 spin_lock(&inode->i_lock);
199 state->state |= open_flags; 220 state->state |= open_flags;
200 /* NB! List reordering - see the reclaim code for why. */ 221 /* NB! List reordering - see the reclaim code for why. */
@@ -204,12 +225,12 @@ static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid,
204 state->nreaders++; 225 state->nreaders++;
205 memcpy(&state->stateid, stateid, sizeof(state->stateid)); 226 memcpy(&state->stateid, stateid, sizeof(state->stateid));
206 spin_unlock(&inode->i_lock); 227 spin_unlock(&inode->i_lock);
228 spin_unlock(&state->owner->so_lock);
207} 229}
208 230
209/* 231/*
210 * OPEN_RECLAIM: 232 * OPEN_RECLAIM:
211 * reclaim state on the server after a reboot. 233 * reclaim state on the server after a reboot.
212 * Assumes caller is holding the sp->so_sem
213 */ 234 */
214static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) 235static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state)
215{ 236{
@@ -218,7 +239,6 @@ static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *st
218 struct nfs_delegation *delegation = NFS_I(inode)->delegation; 239 struct nfs_delegation *delegation = NFS_I(inode)->delegation;
219 struct nfs_openargs o_arg = { 240 struct nfs_openargs o_arg = {
220 .fh = NFS_FH(inode), 241 .fh = NFS_FH(inode),
221 .seqid = sp->so_seqid,
222 .id = sp->so_id, 242 .id = sp->so_id,
223 .open_flags = state->state, 243 .open_flags = state->state,
224 .clientid = server->nfs4_state->cl_clientid, 244 .clientid = server->nfs4_state->cl_clientid,
@@ -245,8 +265,13 @@ static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *st
245 } 265 }
246 o_arg.u.delegation_type = delegation->type; 266 o_arg.u.delegation_type = delegation->type;
247 } 267 }
268 o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid);
269 if (o_arg.seqid == NULL)
270 return -ENOMEM;
248 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 271 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR);
249 nfs4_increment_seqid(status, sp); 272 /* Confirm the sequence as being established */
273 nfs_confirm_seqid(&sp->so_seqid, status);
274 nfs_increment_open_seqid(status, o_arg.seqid);
250 if (status == 0) { 275 if (status == 0) {
251 memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid)); 276 memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid));
252 if (o_res.delegation_type != 0) { 277 if (o_res.delegation_type != 0) {
@@ -256,6 +281,7 @@ static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *st
256 nfs_async_inode_return_delegation(inode, &o_res.stateid); 281 nfs_async_inode_return_delegation(inode, &o_res.stateid);
257 } 282 }
258 } 283 }
284 nfs_free_seqid(o_arg.seqid);
259 clear_bit(NFS_DELEGATED_STATE, &state->flags); 285 clear_bit(NFS_DELEGATED_STATE, &state->flags);
260 /* Ensure we update the inode attributes */ 286 /* Ensure we update the inode attributes */
261 NFS_CACHEINV(inode); 287 NFS_CACHEINV(inode);
@@ -302,23 +328,35 @@ static int _nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state
302 }; 328 };
303 int status = 0; 329 int status = 0;
304 330
305 down(&sp->so_sema);
306 if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) 331 if (!test_bit(NFS_DELEGATED_STATE, &state->flags))
307 goto out; 332 goto out;
308 if (state->state == 0) 333 if (state->state == 0)
309 goto out; 334 goto out;
310 arg.seqid = sp->so_seqid; 335 arg.seqid = nfs_alloc_seqid(&sp->so_seqid);
336 status = -ENOMEM;
337 if (arg.seqid == NULL)
338 goto out;
311 arg.open_flags = state->state; 339 arg.open_flags = state->state;
312 memcpy(arg.u.delegation.data, state->stateid.data, sizeof(arg.u.delegation.data)); 340 memcpy(arg.u.delegation.data, state->stateid.data, sizeof(arg.u.delegation.data));
313 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 341 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR);
314 nfs4_increment_seqid(status, sp); 342 nfs_increment_open_seqid(status, arg.seqid);
343 if (status != 0)
344 goto out_free;
345 if(res.rflags & NFS4_OPEN_RESULT_CONFIRM) {
346 status = _nfs4_proc_open_confirm(server->client, NFS_FH(inode),
347 sp, &res.stateid, arg.seqid);
348 if (status != 0)
349 goto out_free;
350 }
351 nfs_confirm_seqid(&sp->so_seqid, 0);
315 if (status >= 0) { 352 if (status >= 0) {
316 memcpy(state->stateid.data, res.stateid.data, 353 memcpy(state->stateid.data, res.stateid.data,
317 sizeof(state->stateid.data)); 354 sizeof(state->stateid.data));
318 clear_bit(NFS_DELEGATED_STATE, &state->flags); 355 clear_bit(NFS_DELEGATED_STATE, &state->flags);
319 } 356 }
357out_free:
358 nfs_free_seqid(arg.seqid);
320out: 359out:
321 up(&sp->so_sema);
322 dput(parent); 360 dput(parent);
323 return status; 361 return status;
324} 362}
@@ -345,11 +383,11 @@ int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state)
345 return err; 383 return err;
346} 384}
347 385
348static inline int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid) 386static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid, struct nfs_seqid *seqid)
349{ 387{
350 struct nfs_open_confirmargs arg = { 388 struct nfs_open_confirmargs arg = {
351 .fh = fh, 389 .fh = fh,
352 .seqid = sp->so_seqid, 390 .seqid = seqid,
353 .stateid = *stateid, 391 .stateid = *stateid,
354 }; 392 };
355 struct nfs_open_confirmres res; 393 struct nfs_open_confirmres res;
@@ -362,7 +400,9 @@ static inline int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nf
362 int status; 400 int status;
363 401
364 status = rpc_call_sync(clnt, &msg, RPC_TASK_NOINTR); 402 status = rpc_call_sync(clnt, &msg, RPC_TASK_NOINTR);
365 nfs4_increment_seqid(status, sp); 403 /* Confirm the sequence as being established */
404 nfs_confirm_seqid(&sp->so_seqid, status);
405 nfs_increment_open_seqid(status, seqid);
366 if (status >= 0) 406 if (status >= 0)
367 memcpy(stateid, &res.stateid, sizeof(*stateid)); 407 memcpy(stateid, &res.stateid, sizeof(*stateid));
368 return status; 408 return status;
@@ -380,21 +420,41 @@ static int _nfs4_proc_open(struct inode *dir, struct nfs4_state_owner *sp, stru
380 int status; 420 int status;
381 421
382 /* Update sequence id. The caller must serialize! */ 422 /* Update sequence id. The caller must serialize! */
383 o_arg->seqid = sp->so_seqid;
384 o_arg->id = sp->so_id; 423 o_arg->id = sp->so_id;
385 o_arg->clientid = sp->so_client->cl_clientid; 424 o_arg->clientid = sp->so_client->cl_clientid;
386 425
387 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 426 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR);
388 nfs4_increment_seqid(status, sp); 427 if (status == 0) {
428 /* OPEN on anything except a regular file is disallowed in NFSv4 */
429 switch (o_res->f_attr->mode & S_IFMT) {
430 case S_IFREG:
431 break;
432 case S_IFLNK:
433 status = -ELOOP;
434 break;
435 case S_IFDIR:
436 status = -EISDIR;
437 break;
438 default:
439 status = -ENOTDIR;
440 }
441 }
442
443 nfs_increment_open_seqid(status, o_arg->seqid);
389 if (status != 0) 444 if (status != 0)
390 goto out; 445 goto out;
391 update_changeattr(dir, &o_res->cinfo); 446 if (o_arg->open_flags & O_CREAT) {
447 update_changeattr(dir, &o_res->cinfo);
448 nfs_post_op_update_inode(dir, o_res->dir_attr);
449 } else
450 nfs_refresh_inode(dir, o_res->dir_attr);
392 if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { 451 if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) {
393 status = _nfs4_proc_open_confirm(server->client, &o_res->fh, 452 status = _nfs4_proc_open_confirm(server->client, &o_res->fh,
394 sp, &o_res->stateid); 453 sp, &o_res->stateid, o_arg->seqid);
395 if (status != 0) 454 if (status != 0)
396 goto out; 455 goto out;
397 } 456 }
457 nfs_confirm_seqid(&sp->so_seqid, 0);
398 if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) 458 if (!(o_res->f_attr->valid & NFS_ATTR_FATTR))
399 status = server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); 459 status = server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr);
400out: 460out:
@@ -441,9 +501,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
441 struct inode *inode = state->inode; 501 struct inode *inode = state->inode;
442 struct nfs_server *server = NFS_SERVER(dir); 502 struct nfs_server *server = NFS_SERVER(dir);
443 struct nfs_delegation *delegation = NFS_I(inode)->delegation; 503 struct nfs_delegation *delegation = NFS_I(inode)->delegation;
444 struct nfs_fattr f_attr = { 504 struct nfs_fattr f_attr, dir_attr;
445 .valid = 0,
446 };
447 struct nfs_openargs o_arg = { 505 struct nfs_openargs o_arg = {
448 .fh = NFS_FH(dir), 506 .fh = NFS_FH(dir),
449 .open_flags = state->state, 507 .open_flags = state->state,
@@ -453,6 +511,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
453 }; 511 };
454 struct nfs_openres o_res = { 512 struct nfs_openres o_res = {
455 .f_attr = &f_attr, 513 .f_attr = &f_attr,
514 .dir_attr = &dir_attr,
456 .server = server, 515 .server = server,
457 }; 516 };
458 int status = 0; 517 int status = 0;
@@ -465,6 +524,12 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
465 set_bit(NFS_DELEGATED_STATE, &state->flags); 524 set_bit(NFS_DELEGATED_STATE, &state->flags);
466 goto out; 525 goto out;
467 } 526 }
527 o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid);
528 status = -ENOMEM;
529 if (o_arg.seqid == NULL)
530 goto out;
531 nfs_fattr_init(&f_attr);
532 nfs_fattr_init(&dir_attr);
468 status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); 533 status = _nfs4_proc_open(dir, sp, &o_arg, &o_res);
469 if (status != 0) 534 if (status != 0)
470 goto out_nodeleg; 535 goto out_nodeleg;
@@ -490,6 +555,7 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
490 nfs_inode_reclaim_delegation(inode, sp->so_cred, &o_res); 555 nfs_inode_reclaim_delegation(inode, sp->so_cred, &o_res);
491 } 556 }
492out_nodeleg: 557out_nodeleg:
558 nfs_free_seqid(o_arg.seqid);
493 clear_bit(NFS_DELEGATED_STATE, &state->flags); 559 clear_bit(NFS_DELEGATED_STATE, &state->flags);
494out: 560out:
495 dput(parent); 561 dput(parent);
@@ -564,7 +630,6 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred
564 dprintk("%s: nfs4_get_state_owner failed!\n", __FUNCTION__); 630 dprintk("%s: nfs4_get_state_owner failed!\n", __FUNCTION__);
565 goto out_err; 631 goto out_err;
566 } 632 }
567 down(&sp->so_sema);
568 state = nfs4_get_open_state(inode, sp); 633 state = nfs4_get_open_state(inode, sp);
569 if (state == NULL) 634 if (state == NULL)
570 goto out_err; 635 goto out_err;
@@ -589,7 +654,6 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred
589 set_bit(NFS_DELEGATED_STATE, &state->flags); 654 set_bit(NFS_DELEGATED_STATE, &state->flags);
590 update_open_stateid(state, &delegation->stateid, open_flags); 655 update_open_stateid(state, &delegation->stateid, open_flags);
591out_ok: 656out_ok:
592 up(&sp->so_sema);
593 nfs4_put_state_owner(sp); 657 nfs4_put_state_owner(sp);
594 up_read(&nfsi->rwsem); 658 up_read(&nfsi->rwsem);
595 up_read(&clp->cl_sem); 659 up_read(&clp->cl_sem);
@@ -600,11 +664,12 @@ out_err:
600 if (sp != NULL) { 664 if (sp != NULL) {
601 if (state != NULL) 665 if (state != NULL)
602 nfs4_put_open_state(state); 666 nfs4_put_open_state(state);
603 up(&sp->so_sema);
604 nfs4_put_state_owner(sp); 667 nfs4_put_state_owner(sp);
605 } 668 }
606 up_read(&nfsi->rwsem); 669 up_read(&nfsi->rwsem);
607 up_read(&clp->cl_sem); 670 up_read(&clp->cl_sem);
671 if (err != -EACCES)
672 nfs_inode_return_delegation(inode);
608 return err; 673 return err;
609} 674}
610 675
@@ -635,9 +700,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st
635 struct nfs4_client *clp = server->nfs4_state; 700 struct nfs4_client *clp = server->nfs4_state;
636 struct inode *inode = NULL; 701 struct inode *inode = NULL;
637 int status; 702 int status;
638 struct nfs_fattr f_attr = { 703 struct nfs_fattr f_attr, dir_attr;
639 .valid = 0,
640 };
641 struct nfs_openargs o_arg = { 704 struct nfs_openargs o_arg = {
642 .fh = NFS_FH(dir), 705 .fh = NFS_FH(dir),
643 .open_flags = flags, 706 .open_flags = flags,
@@ -648,6 +711,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st
648 }; 711 };
649 struct nfs_openres o_res = { 712 struct nfs_openres o_res = {
650 .f_attr = &f_attr, 713 .f_attr = &f_attr,
714 .dir_attr = &dir_attr,
651 .server = server, 715 .server = server,
652 }; 716 };
653 717
@@ -665,8 +729,12 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st
665 } else 729 } else
666 o_arg.u.attrs = sattr; 730 o_arg.u.attrs = sattr;
667 /* Serialization for the sequence id */ 731 /* Serialization for the sequence id */
668 down(&sp->so_sema);
669 732
733 o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid);
734 if (o_arg.seqid == NULL)
735 return -ENOMEM;
736 nfs_fattr_init(&f_attr);
737 nfs_fattr_init(&dir_attr);
670 status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); 738 status = _nfs4_proc_open(dir, sp, &o_arg, &o_res);
671 if (status != 0) 739 if (status != 0)
672 goto out_err; 740 goto out_err;
@@ -681,7 +749,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st
681 update_open_stateid(state, &o_res.stateid, flags); 749 update_open_stateid(state, &o_res.stateid, flags);
682 if (o_res.delegation_type != 0) 750 if (o_res.delegation_type != 0)
683 nfs_inode_set_delegation(inode, cred, &o_res); 751 nfs_inode_set_delegation(inode, cred, &o_res);
684 up(&sp->so_sema); 752 nfs_free_seqid(o_arg.seqid);
685 nfs4_put_state_owner(sp); 753 nfs4_put_state_owner(sp);
686 up_read(&clp->cl_sem); 754 up_read(&clp->cl_sem);
687 *res = state; 755 *res = state;
@@ -690,7 +758,7 @@ out_err:
690 if (sp != NULL) { 758 if (sp != NULL) {
691 if (state != NULL) 759 if (state != NULL)
692 nfs4_put_open_state(state); 760 nfs4_put_open_state(state);
693 up(&sp->so_sema); 761 nfs_free_seqid(o_arg.seqid);
694 nfs4_put_state_owner(sp); 762 nfs4_put_state_owner(sp);
695 } 763 }
696 /* Note: clp->cl_sem must be released before nfs4_put_open_state()! */ 764 /* Note: clp->cl_sem must be released before nfs4_put_open_state()! */
@@ -718,7 +786,7 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, struct dentry *dentry,
718 * It is actually a sign of a bug on the client or on the server. 786 * It is actually a sign of a bug on the client or on the server.
719 * 787 *
720 * If we receive a BAD_SEQID error in the particular case of 788 * If we receive a BAD_SEQID error in the particular case of
721 * doing an OPEN, we assume that nfs4_increment_seqid() will 789 * doing an OPEN, we assume that nfs_increment_open_seqid() will
722 * have unhashed the old state_owner for us, and that we can 790 * have unhashed the old state_owner for us, and that we can
723 * therefore safely retry using a new one. We should still warn 791 * therefore safely retry using a new one. We should still warn
724 * the user though... 792 * the user though...
@@ -728,6 +796,16 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, struct dentry *dentry,
728 exception.retry = 1; 796 exception.retry = 1;
729 continue; 797 continue;
730 } 798 }
799 /*
800 * BAD_STATEID on OPEN means that the server cancelled our
801 * state before it received the OPEN_CONFIRM.
802 * Recover by retrying the request as per the discussion
803 * on Page 181 of RFC3530.
804 */
805 if (status == -NFS4ERR_BAD_STATEID) {
806 exception.retry = 1;
807 continue;
808 }
731 res = ERR_PTR(nfs4_handle_exception(NFS_SERVER(dir), 809 res = ERR_PTR(nfs4_handle_exception(NFS_SERVER(dir),
732 status, &exception)); 810 status, &exception));
733 } while (exception.retry); 811 } while (exception.retry);
@@ -755,7 +833,7 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
755 }; 833 };
756 int status; 834 int status;
757 835
758 fattr->valid = 0; 836 nfs_fattr_init(fattr);
759 837
760 if (state != NULL) { 838 if (state != NULL) {
761 msg.rpc_cred = state->owner->so_cred; 839 msg.rpc_cred = state->owner->so_cred;
@@ -787,19 +865,30 @@ struct nfs4_closedata {
787 struct nfs4_state *state; 865 struct nfs4_state *state;
788 struct nfs_closeargs arg; 866 struct nfs_closeargs arg;
789 struct nfs_closeres res; 867 struct nfs_closeres res;
868 struct nfs_fattr fattr;
790}; 869};
791 870
871static void nfs4_free_closedata(struct nfs4_closedata *calldata)
872{
873 struct nfs4_state *state = calldata->state;
874 struct nfs4_state_owner *sp = state->owner;
875
876 nfs4_put_open_state(calldata->state);
877 nfs_free_seqid(calldata->arg.seqid);
878 nfs4_put_state_owner(sp);
879 kfree(calldata);
880}
881
792static void nfs4_close_done(struct rpc_task *task) 882static void nfs4_close_done(struct rpc_task *task)
793{ 883{
794 struct nfs4_closedata *calldata = (struct nfs4_closedata *)task->tk_calldata; 884 struct nfs4_closedata *calldata = (struct nfs4_closedata *)task->tk_calldata;
795 struct nfs4_state *state = calldata->state; 885 struct nfs4_state *state = calldata->state;
796 struct nfs4_state_owner *sp = state->owner;
797 struct nfs_server *server = NFS_SERVER(calldata->inode); 886 struct nfs_server *server = NFS_SERVER(calldata->inode);
798 887
799 /* hmm. we are done with the inode, and in the process of freeing 888 /* hmm. we are done with the inode, and in the process of freeing
800 * the state_owner. we keep this around to process errors 889 * the state_owner. we keep this around to process errors
801 */ 890 */
802 nfs4_increment_seqid(task->tk_status, sp); 891 nfs_increment_open_seqid(task->tk_status, calldata->arg.seqid);
803 switch (task->tk_status) { 892 switch (task->tk_status) {
804 case 0: 893 case 0:
805 memcpy(&state->stateid, &calldata->res.stateid, 894 memcpy(&state->stateid, &calldata->res.stateid,
@@ -816,25 +905,49 @@ static void nfs4_close_done(struct rpc_task *task)
816 return; 905 return;
817 } 906 }
818 } 907 }
908 nfs_refresh_inode(calldata->inode, calldata->res.fattr);
819 state->state = calldata->arg.open_flags; 909 state->state = calldata->arg.open_flags;
820 nfs4_put_open_state(state); 910 nfs4_free_closedata(calldata);
821 up(&sp->so_sema);
822 nfs4_put_state_owner(sp);
823 up_read(&server->nfs4_state->cl_sem);
824 kfree(calldata);
825} 911}
826 912
827static inline int nfs4_close_call(struct rpc_clnt *clnt, struct nfs4_closedata *calldata) 913static void nfs4_close_begin(struct rpc_task *task)
828{ 914{
915 struct nfs4_closedata *calldata = (struct nfs4_closedata *)task->tk_calldata;
916 struct nfs4_state *state = calldata->state;
829 struct rpc_message msg = { 917 struct rpc_message msg = {
830 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE], 918 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE],
831 .rpc_argp = &calldata->arg, 919 .rpc_argp = &calldata->arg,
832 .rpc_resp = &calldata->res, 920 .rpc_resp = &calldata->res,
833 .rpc_cred = calldata->state->owner->so_cred, 921 .rpc_cred = state->owner->so_cred,
834 }; 922 };
835 if (calldata->arg.open_flags != 0) 923 int mode = 0;
924 int status;
925
926 status = nfs_wait_on_sequence(calldata->arg.seqid, task);
927 if (status != 0)
928 return;
929 /* Don't reorder reads */
930 smp_rmb();
931 /* Recalculate the new open mode in case someone reopened the file
932 * while we were waiting in line to be scheduled.
933 */
934 if (state->nreaders != 0)
935 mode |= FMODE_READ;
936 if (state->nwriters != 0)
937 mode |= FMODE_WRITE;
938 if (test_bit(NFS_DELEGATED_STATE, &state->flags))
939 state->state = mode;
940 if (mode == state->state) {
941 nfs4_free_closedata(calldata);
942 task->tk_exit = NULL;
943 rpc_exit(task, 0);
944 return;
945 }
946 nfs_fattr_init(calldata->res.fattr);
947 if (mode != 0)
836 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; 948 msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
837 return rpc_call_async(clnt, &msg, 0, nfs4_close_done, calldata); 949 calldata->arg.open_flags = mode;
950 rpc_call_setup(task, &msg, 0);
838} 951}
839 952
840/* 953/*
@@ -850,40 +963,57 @@ static inline int nfs4_close_call(struct rpc_clnt *clnt, struct nfs4_closedata *
850 */ 963 */
851int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode) 964int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode)
852{ 965{
966 struct nfs_server *server = NFS_SERVER(inode);
853 struct nfs4_closedata *calldata; 967 struct nfs4_closedata *calldata;
854 int status; 968 int status = -ENOMEM;
855 969
856 /* Tell caller we're done */ 970 calldata = kmalloc(sizeof(*calldata), GFP_KERNEL);
857 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) {
858 state->state = mode;
859 return 0;
860 }
861 calldata = (struct nfs4_closedata *)kmalloc(sizeof(*calldata), GFP_KERNEL);
862 if (calldata == NULL) 971 if (calldata == NULL)
863 return -ENOMEM; 972 goto out;
864 calldata->inode = inode; 973 calldata->inode = inode;
865 calldata->state = state; 974 calldata->state = state;
866 calldata->arg.fh = NFS_FH(inode); 975 calldata->arg.fh = NFS_FH(inode);
976 calldata->arg.stateid = &state->stateid;
867 /* Serialization for the sequence id */ 977 /* Serialization for the sequence id */
868 calldata->arg.seqid = state->owner->so_seqid; 978 calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid);
869 calldata->arg.open_flags = mode; 979 if (calldata->arg.seqid == NULL)
870 memcpy(&calldata->arg.stateid, &state->stateid, 980 goto out_free_calldata;
871 sizeof(calldata->arg.stateid)); 981 calldata->arg.bitmask = server->attr_bitmask;
872 status = nfs4_close_call(NFS_SERVER(inode)->client, calldata); 982 calldata->res.fattr = &calldata->fattr;
873 /* 983 calldata->res.server = server;
874 * Return -EINPROGRESS on success in order to indicate to the 984
875 * caller that an asynchronous RPC call has been launched, and 985 status = nfs4_call_async(server->client, nfs4_close_begin,
876 * that it will release the semaphores on completion. 986 nfs4_close_done, calldata);
877 */ 987 if (status == 0)
878 return (status == 0) ? -EINPROGRESS : status; 988 goto out;
989
990 nfs_free_seqid(calldata->arg.seqid);
991out_free_calldata:
992 kfree(calldata);
993out:
994 return status;
879} 995}
880 996
881struct inode * 997static void nfs4_intent_set_file(struct nameidata *nd, struct dentry *dentry, struct nfs4_state *state)
998{
999 struct file *filp;
1000
1001 filp = lookup_instantiate_filp(nd, dentry, NULL);
1002 if (!IS_ERR(filp)) {
1003 struct nfs_open_context *ctx;
1004 ctx = (struct nfs_open_context *)filp->private_data;
1005 ctx->state = state;
1006 } else
1007 nfs4_close_state(state, nd->intent.open.flags);
1008}
1009
1010struct dentry *
882nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 1011nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
883{ 1012{
884 struct iattr attr; 1013 struct iattr attr;
885 struct rpc_cred *cred; 1014 struct rpc_cred *cred;
886 struct nfs4_state *state; 1015 struct nfs4_state *state;
1016 struct dentry *res;
887 1017
888 if (nd->flags & LOOKUP_CREATE) { 1018 if (nd->flags & LOOKUP_CREATE) {
889 attr.ia_mode = nd->intent.open.create_mode; 1019 attr.ia_mode = nd->intent.open.create_mode;
@@ -897,16 +1027,23 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
897 1027
898 cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0); 1028 cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0);
899 if (IS_ERR(cred)) 1029 if (IS_ERR(cred))
900 return (struct inode *)cred; 1030 return (struct dentry *)cred;
901 state = nfs4_do_open(dir, dentry, nd->intent.open.flags, &attr, cred); 1031 state = nfs4_do_open(dir, dentry, nd->intent.open.flags, &attr, cred);
902 put_rpccred(cred); 1032 put_rpccred(cred);
903 if (IS_ERR(state)) 1033 if (IS_ERR(state)) {
904 return (struct inode *)state; 1034 if (PTR_ERR(state) == -ENOENT)
905 return state->inode; 1035 d_add(dentry, NULL);
1036 return (struct dentry *)state;
1037 }
1038 res = d_add_unique(dentry, state->inode);
1039 if (res != NULL)
1040 dentry = res;
1041 nfs4_intent_set_file(nd, dentry, state);
1042 return res;
906} 1043}
907 1044
908int 1045int
909nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags) 1046nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, struct nameidata *nd)
910{ 1047{
911 struct rpc_cred *cred; 1048 struct rpc_cred *cred;
912 struct nfs4_state *state; 1049 struct nfs4_state *state;
@@ -919,18 +1056,30 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags)
919 if (IS_ERR(state)) 1056 if (IS_ERR(state))
920 state = nfs4_do_open(dir, dentry, openflags, NULL, cred); 1057 state = nfs4_do_open(dir, dentry, openflags, NULL, cred);
921 put_rpccred(cred); 1058 put_rpccred(cred);
922 if (state == ERR_PTR(-ENOENT) && dentry->d_inode == 0) 1059 if (IS_ERR(state)) {
923 return 1; 1060 switch (PTR_ERR(state)) {
924 if (IS_ERR(state)) 1061 case -EPERM:
925 return 0; 1062 case -EACCES:
1063 case -EDQUOT:
1064 case -ENOSPC:
1065 case -EROFS:
1066 lookup_instantiate_filp(nd, (struct dentry *)state, NULL);
1067 return 1;
1068 case -ENOENT:
1069 if (dentry->d_inode == NULL)
1070 return 1;
1071 }
1072 goto out_drop;
1073 }
926 inode = state->inode; 1074 inode = state->inode;
1075 iput(inode);
927 if (inode == dentry->d_inode) { 1076 if (inode == dentry->d_inode) {
928 iput(inode); 1077 nfs4_intent_set_file(nd, dentry, state);
929 return 1; 1078 return 1;
930 } 1079 }
931 d_drop(dentry);
932 nfs4_close_state(state, openflags); 1080 nfs4_close_state(state, openflags);
933 iput(inode); 1081out_drop:
1082 d_drop(dentry);
934 return 0; 1083 return 0;
935} 1084}
936 1085
@@ -974,13 +1123,12 @@ static int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fh
974static int _nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle, 1123static int _nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle,
975 struct nfs_fsinfo *info) 1124 struct nfs_fsinfo *info)
976{ 1125{
977 struct nfs_fattr * fattr = info->fattr;
978 struct nfs4_lookup_root_arg args = { 1126 struct nfs4_lookup_root_arg args = {
979 .bitmask = nfs4_fattr_bitmap, 1127 .bitmask = nfs4_fattr_bitmap,
980 }; 1128 };
981 struct nfs4_lookup_res res = { 1129 struct nfs4_lookup_res res = {
982 .server = server, 1130 .server = server,
983 .fattr = fattr, 1131 .fattr = info->fattr,
984 .fh = fhandle, 1132 .fh = fhandle,
985 }; 1133 };
986 struct rpc_message msg = { 1134 struct rpc_message msg = {
@@ -988,7 +1136,7 @@ static int _nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle,
988 .rpc_argp = &args, 1136 .rpc_argp = &args,
989 .rpc_resp = &res, 1137 .rpc_resp = &res,
990 }; 1138 };
991 fattr->valid = 0; 1139 nfs_fattr_init(info->fattr);
992 return rpc_call_sync(server->client, &msg, 0); 1140 return rpc_call_sync(server->client, &msg, 0);
993} 1141}
994 1142
@@ -1051,7 +1199,7 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
1051 q.len = p - q.name; 1199 q.len = p - q.name;
1052 1200
1053 do { 1201 do {
1054 fattr->valid = 0; 1202 nfs_fattr_init(fattr);
1055 status = nfs4_handle_exception(server, 1203 status = nfs4_handle_exception(server,
1056 rpc_call_sync(server->client, &msg, 0), 1204 rpc_call_sync(server->client, &msg, 0),
1057 &exception); 1205 &exception);
@@ -1088,7 +1236,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
1088 .rpc_resp = &res, 1236 .rpc_resp = &res,
1089 }; 1237 };
1090 1238
1091 fattr->valid = 0; 1239 nfs_fattr_init(fattr);
1092 return rpc_call_sync(server->client, &msg, 0); 1240 return rpc_call_sync(server->client, &msg, 0);
1093} 1241}
1094 1242
@@ -1130,7 +1278,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
1130 struct nfs4_state *state; 1278 struct nfs4_state *state;
1131 int status; 1279 int status;
1132 1280
1133 fattr->valid = 0; 1281 nfs_fattr_init(fattr);
1134 1282
1135 cred = rpcauth_lookupcred(NFS_SERVER(inode)->client->cl_auth, 0); 1283 cred = rpcauth_lookupcred(NFS_SERVER(inode)->client->cl_auth, 0);
1136 if (IS_ERR(cred)) 1284 if (IS_ERR(cred))
@@ -1176,7 +1324,7 @@ static int _nfs4_proc_lookup(struct inode *dir, struct qstr *name,
1176 .rpc_resp = &res, 1324 .rpc_resp = &res,
1177 }; 1325 };
1178 1326
1179 fattr->valid = 0; 1327 nfs_fattr_init(fattr);
1180 1328
1181 dprintk("NFS call lookup %s\n", name->name); 1329 dprintk("NFS call lookup %s\n", name->name);
1182 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 1330 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
@@ -1325,7 +1473,7 @@ static int _nfs4_proc_read(struct nfs_read_data *rdata)
1325 dprintk("NFS call read %d @ %Ld\n", rdata->args.count, 1473 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
1326 (long long) rdata->args.offset); 1474 (long long) rdata->args.offset);
1327 1475
1328 fattr->valid = 0; 1476 nfs_fattr_init(fattr);
1329 status = rpc_call_sync(server->client, &msg, flags); 1477 status = rpc_call_sync(server->client, &msg, flags);
1330 if (!status) 1478 if (!status)
1331 renew_lease(server, timestamp); 1479 renew_lease(server, timestamp);
@@ -1362,7 +1510,7 @@ static int _nfs4_proc_write(struct nfs_write_data *wdata)
1362 dprintk("NFS call write %d @ %Ld\n", wdata->args.count, 1510 dprintk("NFS call write %d @ %Ld\n", wdata->args.count,
1363 (long long) wdata->args.offset); 1511 (long long) wdata->args.offset);
1364 1512
1365 fattr->valid = 0; 1513 nfs_fattr_init(fattr);
1366 status = rpc_call_sync(server->client, &msg, rpcflags); 1514 status = rpc_call_sync(server->client, &msg, rpcflags);
1367 dprintk("NFS reply write: %d\n", status); 1515 dprintk("NFS reply write: %d\n", status);
1368 return status; 1516 return status;
@@ -1396,7 +1544,7 @@ static int _nfs4_proc_commit(struct nfs_write_data *cdata)
1396 dprintk("NFS call commit %d @ %Ld\n", cdata->args.count, 1544 dprintk("NFS call commit %d @ %Ld\n", cdata->args.count,
1397 (long long) cdata->args.offset); 1545 (long long) cdata->args.offset);
1398 1546
1399 fattr->valid = 0; 1547 nfs_fattr_init(fattr);
1400 status = rpc_call_sync(server->client, &msg, 0); 1548 status = rpc_call_sync(server->client, &msg, 0);
1401 dprintk("NFS reply commit: %d\n", status); 1549 dprintk("NFS reply commit: %d\n", status);
1402 return status; 1550 return status;
@@ -1431,7 +1579,7 @@ static int nfs4_proc_commit(struct nfs_write_data *cdata)
1431 1579
1432static int 1580static int
1433nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 1581nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
1434 int flags) 1582 int flags, struct nameidata *nd)
1435{ 1583{
1436 struct nfs4_state *state; 1584 struct nfs4_state *state;
1437 struct rpc_cred *cred; 1585 struct rpc_cred *cred;
@@ -1453,24 +1601,30 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
1453 struct nfs_fattr fattr; 1601 struct nfs_fattr fattr;
1454 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr, 1602 status = nfs4_do_setattr(NFS_SERVER(dir), &fattr,
1455 NFS_FH(state->inode), sattr, state); 1603 NFS_FH(state->inode), sattr, state);
1456 if (status == 0) { 1604 if (status == 0)
1457 nfs_setattr_update_inode(state->inode, sattr); 1605 nfs_setattr_update_inode(state->inode, sattr);
1458 goto out; 1606 }
1459 } 1607 if (status == 0 && nd != NULL && (nd->flags & LOOKUP_OPEN))
1460 } else if (flags != 0) 1608 nfs4_intent_set_file(nd, dentry, state);
1461 goto out; 1609 else
1462 nfs4_close_state(state, flags); 1610 nfs4_close_state(state, flags);
1463out: 1611out:
1464 return status; 1612 return status;
1465} 1613}
1466 1614
1467static int _nfs4_proc_remove(struct inode *dir, struct qstr *name) 1615static int _nfs4_proc_remove(struct inode *dir, struct qstr *name)
1468{ 1616{
1617 struct nfs_server *server = NFS_SERVER(dir);
1469 struct nfs4_remove_arg args = { 1618 struct nfs4_remove_arg args = {
1470 .fh = NFS_FH(dir), 1619 .fh = NFS_FH(dir),
1471 .name = name, 1620 .name = name,
1621 .bitmask = server->attr_bitmask,
1622 };
1623 struct nfs_fattr dir_attr;
1624 struct nfs4_remove_res res = {
1625 .server = server,
1626 .dir_attr = &dir_attr,
1472 }; 1627 };
1473 struct nfs4_change_info res;
1474 struct rpc_message msg = { 1628 struct rpc_message msg = {
1475 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE], 1629 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE],
1476 .rpc_argp = &args, 1630 .rpc_argp = &args,
@@ -1478,9 +1632,12 @@ static int _nfs4_proc_remove(struct inode *dir, struct qstr *name)
1478 }; 1632 };
1479 int status; 1633 int status;
1480 1634
1481 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 1635 nfs_fattr_init(res.dir_attr);
1482 if (status == 0) 1636 status = rpc_call_sync(server->client, &msg, 0);
1483 update_changeattr(dir, &res); 1637 if (status == 0) {
1638 update_changeattr(dir, &res.cinfo);
1639 nfs_post_op_update_inode(dir, res.dir_attr);
1640 }
1484 return status; 1641 return status;
1485} 1642}
1486 1643
@@ -1498,12 +1655,14 @@ static int nfs4_proc_remove(struct inode *dir, struct qstr *name)
1498 1655
1499struct unlink_desc { 1656struct unlink_desc {
1500 struct nfs4_remove_arg args; 1657 struct nfs4_remove_arg args;
1501 struct nfs4_change_info res; 1658 struct nfs4_remove_res res;
1659 struct nfs_fattr dir_attr;
1502}; 1660};
1503 1661
1504static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, 1662static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
1505 struct qstr *name) 1663 struct qstr *name)
1506{ 1664{
1665 struct nfs_server *server = NFS_SERVER(dir->d_inode);
1507 struct unlink_desc *up; 1666 struct unlink_desc *up;
1508 1667
1509 up = (struct unlink_desc *) kmalloc(sizeof(*up), GFP_KERNEL); 1668 up = (struct unlink_desc *) kmalloc(sizeof(*up), GFP_KERNEL);
@@ -1512,6 +1671,9 @@ static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
1512 1671
1513 up->args.fh = NFS_FH(dir->d_inode); 1672 up->args.fh = NFS_FH(dir->d_inode);
1514 up->args.name = name; 1673 up->args.name = name;
1674 up->args.bitmask = server->attr_bitmask;
1675 up->res.server = server;
1676 up->res.dir_attr = &up->dir_attr;
1515 1677
1516 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; 1678 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
1517 msg->rpc_argp = &up->args; 1679 msg->rpc_argp = &up->args;
@@ -1526,7 +1688,8 @@ static int nfs4_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
1526 1688
1527 if (msg->rpc_resp != NULL) { 1689 if (msg->rpc_resp != NULL) {
1528 up = container_of(msg->rpc_resp, struct unlink_desc, res); 1690 up = container_of(msg->rpc_resp, struct unlink_desc, res);
1529 update_changeattr(dir->d_inode, &up->res); 1691 update_changeattr(dir->d_inode, &up->res.cinfo);
1692 nfs_post_op_update_inode(dir->d_inode, up->res.dir_attr);
1530 kfree(up); 1693 kfree(up);
1531 msg->rpc_resp = NULL; 1694 msg->rpc_resp = NULL;
1532 msg->rpc_argp = NULL; 1695 msg->rpc_argp = NULL;
@@ -1537,13 +1700,20 @@ static int nfs4_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
1537static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name, 1700static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
1538 struct inode *new_dir, struct qstr *new_name) 1701 struct inode *new_dir, struct qstr *new_name)
1539{ 1702{
1703 struct nfs_server *server = NFS_SERVER(old_dir);
1540 struct nfs4_rename_arg arg = { 1704 struct nfs4_rename_arg arg = {
1541 .old_dir = NFS_FH(old_dir), 1705 .old_dir = NFS_FH(old_dir),
1542 .new_dir = NFS_FH(new_dir), 1706 .new_dir = NFS_FH(new_dir),
1543 .old_name = old_name, 1707 .old_name = old_name,
1544 .new_name = new_name, 1708 .new_name = new_name,
1709 .bitmask = server->attr_bitmask,
1710 };
1711 struct nfs_fattr old_fattr, new_fattr;
1712 struct nfs4_rename_res res = {
1713 .server = server,
1714 .old_fattr = &old_fattr,
1715 .new_fattr = &new_fattr,
1545 }; 1716 };
1546 struct nfs4_rename_res res = { };
1547 struct rpc_message msg = { 1717 struct rpc_message msg = {
1548 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], 1718 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME],
1549 .rpc_argp = &arg, 1719 .rpc_argp = &arg,
@@ -1551,11 +1721,15 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
1551 }; 1721 };
1552 int status; 1722 int status;
1553 1723
1554 status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); 1724 nfs_fattr_init(res.old_fattr);
1725 nfs_fattr_init(res.new_fattr);
1726 status = rpc_call_sync(server->client, &msg, 0);
1555 1727
1556 if (!status) { 1728 if (!status) {
1557 update_changeattr(old_dir, &res.old_cinfo); 1729 update_changeattr(old_dir, &res.old_cinfo);
1730 nfs_post_op_update_inode(old_dir, res.old_fattr);
1558 update_changeattr(new_dir, &res.new_cinfo); 1731 update_changeattr(new_dir, &res.new_cinfo);
1732 nfs_post_op_update_inode(new_dir, res.new_fattr);
1559 } 1733 }
1560 return status; 1734 return status;
1561} 1735}
@@ -1576,22 +1750,34 @@ static int nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
1576 1750
1577static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) 1751static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
1578{ 1752{
1753 struct nfs_server *server = NFS_SERVER(inode);
1579 struct nfs4_link_arg arg = { 1754 struct nfs4_link_arg arg = {
1580 .fh = NFS_FH(inode), 1755 .fh = NFS_FH(inode),
1581 .dir_fh = NFS_FH(dir), 1756 .dir_fh = NFS_FH(dir),
1582 .name = name, 1757 .name = name,
1758 .bitmask = server->attr_bitmask,
1759 };
1760 struct nfs_fattr fattr, dir_attr;
1761 struct nfs4_link_res res = {
1762 .server = server,
1763 .fattr = &fattr,
1764 .dir_attr = &dir_attr,
1583 }; 1765 };
1584 struct nfs4_change_info cinfo = { };
1585 struct rpc_message msg = { 1766 struct rpc_message msg = {
1586 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], 1767 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK],
1587 .rpc_argp = &arg, 1768 .rpc_argp = &arg,
1588 .rpc_resp = &cinfo, 1769 .rpc_resp = &res,
1589 }; 1770 };
1590 int status; 1771 int status;
1591 1772
1592 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); 1773 nfs_fattr_init(res.fattr);
1593 if (!status) 1774 nfs_fattr_init(res.dir_attr);
1594 update_changeattr(dir, &cinfo); 1775 status = rpc_call_sync(server->client, &msg, 0);
1776 if (!status) {
1777 update_changeattr(dir, &res.cinfo);
1778 nfs_post_op_update_inode(dir, res.dir_attr);
1779 nfs_refresh_inode(inode, res.fattr);
1780 }
1595 1781
1596 return status; 1782 return status;
1597} 1783}
@@ -1613,6 +1799,7 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name,
1613 struct nfs_fattr *fattr) 1799 struct nfs_fattr *fattr)
1614{ 1800{
1615 struct nfs_server *server = NFS_SERVER(dir); 1801 struct nfs_server *server = NFS_SERVER(dir);
1802 struct nfs_fattr dir_fattr;
1616 struct nfs4_create_arg arg = { 1803 struct nfs4_create_arg arg = {
1617 .dir_fh = NFS_FH(dir), 1804 .dir_fh = NFS_FH(dir),
1618 .server = server, 1805 .server = server,
@@ -1625,6 +1812,7 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name,
1625 .server = server, 1812 .server = server,
1626 .fh = fhandle, 1813 .fh = fhandle,
1627 .fattr = fattr, 1814 .fattr = fattr,
1815 .dir_fattr = &dir_fattr,
1628 }; 1816 };
1629 struct rpc_message msg = { 1817 struct rpc_message msg = {
1630 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK], 1818 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK],
@@ -1636,11 +1824,13 @@ static int _nfs4_proc_symlink(struct inode *dir, struct qstr *name,
1636 if (path->len > NFS4_MAXPATHLEN) 1824 if (path->len > NFS4_MAXPATHLEN)
1637 return -ENAMETOOLONG; 1825 return -ENAMETOOLONG;
1638 arg.u.symlink = path; 1826 arg.u.symlink = path;
1639 fattr->valid = 0; 1827 nfs_fattr_init(fattr);
1828 nfs_fattr_init(&dir_fattr);
1640 1829
1641 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 1830 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
1642 if (!status) 1831 if (!status)
1643 update_changeattr(dir, &res.dir_cinfo); 1832 update_changeattr(dir, &res.dir_cinfo);
1833 nfs_post_op_update_inode(dir, res.dir_fattr);
1644 return status; 1834 return status;
1645} 1835}
1646 1836
@@ -1664,7 +1854,7 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
1664{ 1854{
1665 struct nfs_server *server = NFS_SERVER(dir); 1855 struct nfs_server *server = NFS_SERVER(dir);
1666 struct nfs_fh fhandle; 1856 struct nfs_fh fhandle;
1667 struct nfs_fattr fattr; 1857 struct nfs_fattr fattr, dir_fattr;
1668 struct nfs4_create_arg arg = { 1858 struct nfs4_create_arg arg = {
1669 .dir_fh = NFS_FH(dir), 1859 .dir_fh = NFS_FH(dir),
1670 .server = server, 1860 .server = server,
@@ -1677,6 +1867,7 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
1677 .server = server, 1867 .server = server,
1678 .fh = &fhandle, 1868 .fh = &fhandle,
1679 .fattr = &fattr, 1869 .fattr = &fattr,
1870 .dir_fattr = &dir_fattr,
1680 }; 1871 };
1681 struct rpc_message msg = { 1872 struct rpc_message msg = {
1682 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], 1873 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE],
@@ -1685,11 +1876,13 @@ static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry,
1685 }; 1876 };
1686 int status; 1877 int status;
1687 1878
1688 fattr.valid = 0; 1879 nfs_fattr_init(&fattr);
1880 nfs_fattr_init(&dir_fattr);
1689 1881
1690 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 1882 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
1691 if (!status) { 1883 if (!status) {
1692 update_changeattr(dir, &res.dir_cinfo); 1884 update_changeattr(dir, &res.dir_cinfo);
1885 nfs_post_op_update_inode(dir, res.dir_fattr);
1693 status = nfs_instantiate(dentry, &fhandle, &fattr); 1886 status = nfs_instantiate(dentry, &fhandle, &fattr);
1694 } 1887 }
1695 return status; 1888 return status;
@@ -1762,7 +1955,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
1762{ 1955{
1763 struct nfs_server *server = NFS_SERVER(dir); 1956 struct nfs_server *server = NFS_SERVER(dir);
1764 struct nfs_fh fh; 1957 struct nfs_fh fh;
1765 struct nfs_fattr fattr; 1958 struct nfs_fattr fattr, dir_fattr;
1766 struct nfs4_create_arg arg = { 1959 struct nfs4_create_arg arg = {
1767 .dir_fh = NFS_FH(dir), 1960 .dir_fh = NFS_FH(dir),
1768 .server = server, 1961 .server = server,
@@ -1774,6 +1967,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
1774 .server = server, 1967 .server = server,
1775 .fh = &fh, 1968 .fh = &fh,
1776 .fattr = &fattr, 1969 .fattr = &fattr,
1970 .dir_fattr = &dir_fattr,
1777 }; 1971 };
1778 struct rpc_message msg = { 1972 struct rpc_message msg = {
1779 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], 1973 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE],
@@ -1783,7 +1977,8 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
1783 int status; 1977 int status;
1784 int mode = sattr->ia_mode; 1978 int mode = sattr->ia_mode;
1785 1979
1786 fattr.valid = 0; 1980 nfs_fattr_init(&fattr);
1981 nfs_fattr_init(&dir_fattr);
1787 1982
1788 BUG_ON(!(sattr->ia_valid & ATTR_MODE)); 1983 BUG_ON(!(sattr->ia_valid & ATTR_MODE));
1789 BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); 1984 BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode));
@@ -1805,6 +2000,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry,
1805 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 2000 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
1806 if (status == 0) { 2001 if (status == 0) {
1807 update_changeattr(dir, &res.dir_cinfo); 2002 update_changeattr(dir, &res.dir_cinfo);
2003 nfs_post_op_update_inode(dir, res.dir_fattr);
1808 status = nfs_instantiate(dentry, &fh, &fattr); 2004 status = nfs_instantiate(dentry, &fh, &fattr);
1809 } 2005 }
1810 return status; 2006 return status;
@@ -1836,7 +2032,7 @@ static int _nfs4_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
1836 .rpc_resp = fsstat, 2032 .rpc_resp = fsstat,
1837 }; 2033 };
1838 2034
1839 fsstat->fattr->valid = 0; 2035 nfs_fattr_init(fsstat->fattr);
1840 return rpc_call_sync(server->client, &msg, 0); 2036 return rpc_call_sync(server->client, &msg, 0);
1841} 2037}
1842 2038
@@ -1883,7 +2079,7 @@ static int nfs4_do_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, str
1883 2079
1884static int nfs4_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *fsinfo) 2080static int nfs4_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *fsinfo)
1885{ 2081{
1886 fsinfo->fattr->valid = 0; 2082 nfs_fattr_init(fsinfo->fattr);
1887 return nfs4_do_fsinfo(server, fhandle, fsinfo); 2083 return nfs4_do_fsinfo(server, fhandle, fsinfo);
1888} 2084}
1889 2085
@@ -1906,7 +2102,7 @@ static int _nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle
1906 return 0; 2102 return 0;
1907 } 2103 }
1908 2104
1909 pathconf->fattr->valid = 0; 2105 nfs_fattr_init(pathconf->fattr);
1910 return rpc_call_sync(server->client, &msg, 0); 2106 return rpc_call_sync(server->client, &msg, 0);
1911} 2107}
1912 2108
@@ -1973,8 +2169,10 @@ nfs4_write_done(struct rpc_task *task)
1973 rpc_restart_call(task); 2169 rpc_restart_call(task);
1974 return; 2170 return;
1975 } 2171 }
1976 if (task->tk_status >= 0) 2172 if (task->tk_status >= 0) {
1977 renew_lease(NFS_SERVER(inode), data->timestamp); 2173 renew_lease(NFS_SERVER(inode), data->timestamp);
2174 nfs_post_op_update_inode(inode, data->res.fattr);
2175 }
1978 /* Call back common NFS writeback processing */ 2176 /* Call back common NFS writeback processing */
1979 nfs_writeback_done(task); 2177 nfs_writeback_done(task);
1980} 2178}
@@ -1990,6 +2188,7 @@ nfs4_proc_write_setup(struct nfs_write_data *data, int how)
1990 .rpc_cred = data->cred, 2188 .rpc_cred = data->cred,
1991 }; 2189 };
1992 struct inode *inode = data->inode; 2190 struct inode *inode = data->inode;
2191 struct nfs_server *server = NFS_SERVER(inode);
1993 int stable; 2192 int stable;
1994 int flags; 2193 int flags;
1995 2194
@@ -2001,6 +2200,8 @@ nfs4_proc_write_setup(struct nfs_write_data *data, int how)
2001 } else 2200 } else
2002 stable = NFS_UNSTABLE; 2201 stable = NFS_UNSTABLE;
2003 data->args.stable = stable; 2202 data->args.stable = stable;
2203 data->args.bitmask = server->attr_bitmask;
2204 data->res.server = server;
2004 2205
2005 data->timestamp = jiffies; 2206 data->timestamp = jiffies;
2006 2207
@@ -2022,6 +2223,8 @@ nfs4_commit_done(struct rpc_task *task)
2022 rpc_restart_call(task); 2223 rpc_restart_call(task);
2023 return; 2224 return;
2024 } 2225 }
2226 if (task->tk_status >= 0)
2227 nfs_post_op_update_inode(inode, data->res.fattr);
2025 /* Call back common NFS writeback processing */ 2228 /* Call back common NFS writeback processing */
2026 nfs_commit_done(task); 2229 nfs_commit_done(task);
2027} 2230}
@@ -2037,8 +2240,12 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, int how)
2037 .rpc_cred = data->cred, 2240 .rpc_cred = data->cred,
2038 }; 2241 };
2039 struct inode *inode = data->inode; 2242 struct inode *inode = data->inode;
2243 struct nfs_server *server = NFS_SERVER(inode);
2040 int flags; 2244 int flags;
2041 2245
2246 data->args.bitmask = server->attr_bitmask;
2247 data->res.server = server;
2248
2042 /* Set the initial flags for the task. */ 2249 /* Set the initial flags for the task. */
2043 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; 2250 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
2044 2251
@@ -2106,65 +2313,6 @@ nfs4_proc_renew(struct nfs4_client *clp)
2106 return 0; 2313 return 0;
2107} 2314}
2108 2315
2109/*
2110 * We will need to arrange for the VFS layer to provide an atomic open.
2111 * Until then, this open method is prone to inefficiency and race conditions
2112 * due to the lookup, potential create, and open VFS calls from sys_open()
2113 * placed on the wire.
2114 */
2115static int
2116nfs4_proc_file_open(struct inode *inode, struct file *filp)
2117{
2118 struct dentry *dentry = filp->f_dentry;
2119 struct nfs_open_context *ctx;
2120 struct nfs4_state *state = NULL;
2121 struct rpc_cred *cred;
2122 int status = -ENOMEM;
2123
2124 dprintk("nfs4_proc_file_open: starting on (%.*s/%.*s)\n",
2125 (int)dentry->d_parent->d_name.len,
2126 dentry->d_parent->d_name.name,
2127 (int)dentry->d_name.len, dentry->d_name.name);
2128
2129
2130 /* Find our open stateid */
2131 cred = rpcauth_lookupcred(NFS_SERVER(inode)->client->cl_auth, 0);
2132 if (IS_ERR(cred))
2133 return PTR_ERR(cred);
2134 ctx = alloc_nfs_open_context(dentry, cred);
2135 put_rpccred(cred);
2136 if (unlikely(ctx == NULL))
2137 return -ENOMEM;
2138 status = -EIO; /* ERACE actually */
2139 state = nfs4_find_state(inode, cred, filp->f_mode);
2140 if (unlikely(state == NULL))
2141 goto no_state;
2142 ctx->state = state;
2143 nfs4_close_state(state, filp->f_mode);
2144 ctx->mode = filp->f_mode;
2145 nfs_file_set_open_context(filp, ctx);
2146 put_nfs_open_context(ctx);
2147 if (filp->f_mode & FMODE_WRITE)
2148 nfs_begin_data_update(inode);
2149 return 0;
2150no_state:
2151 printk(KERN_WARNING "NFS: v4 raced in function %s\n", __FUNCTION__);
2152 put_nfs_open_context(ctx);
2153 return status;
2154}
2155
2156/*
2157 * Release our state
2158 */
2159static int
2160nfs4_proc_file_release(struct inode *inode, struct file *filp)
2161{
2162 if (filp->f_mode & FMODE_WRITE)
2163 nfs_end_data_update(inode);
2164 nfs_file_clear_open_context(filp);
2165 return 0;
2166}
2167
2168static inline int nfs4_server_supports_acls(struct nfs_server *server) 2316static inline int nfs4_server_supports_acls(struct nfs_server *server)
2169{ 2317{
2170 return (server->caps & NFS_CAP_ACLS) 2318 return (server->caps & NFS_CAP_ACLS)
@@ -2285,7 +2433,7 @@ static inline ssize_t nfs4_get_acl_uncached(struct inode *inode, void *buf, size
2285 return -ENOMEM; 2433 return -ENOMEM;
2286 args.acl_pages[0] = localpage; 2434 args.acl_pages[0] = localpage;
2287 args.acl_pgbase = 0; 2435 args.acl_pgbase = 0;
2288 args.acl_len = PAGE_SIZE; 2436 resp_len = args.acl_len = PAGE_SIZE;
2289 } else { 2437 } else {
2290 resp_buf = buf; 2438 resp_buf = buf;
2291 buf_to_pages(buf, buflen, args.acl_pages, &args.acl_pgbase); 2439 buf_to_pages(buf, buflen, args.acl_pages, &args.acl_pgbase);
@@ -2345,6 +2493,7 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen
2345 2493
2346 if (!nfs4_server_supports_acls(server)) 2494 if (!nfs4_server_supports_acls(server))
2347 return -EOPNOTSUPP; 2495 return -EOPNOTSUPP;
2496 nfs_inode_return_delegation(inode);
2348 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); 2497 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase);
2349 ret = rpc_call_sync(NFS_SERVER(inode)->client, &msg, 0); 2498 ret = rpc_call_sync(NFS_SERVER(inode)->client, &msg, 0);
2350 if (ret == 0) 2499 if (ret == 0)
@@ -2353,7 +2502,7 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen
2353} 2502}
2354 2503
2355static int 2504static int
2356nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server) 2505nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server)
2357{ 2506{
2358 struct nfs4_client *clp = server->nfs4_state; 2507 struct nfs4_client *clp = server->nfs4_state;
2359 2508
@@ -2431,7 +2580,7 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
2431/* This is the error handling routine for processes that are allowed 2580/* This is the error handling routine for processes that are allowed
2432 * to sleep. 2581 * to sleep.
2433 */ 2582 */
2434int nfs4_handle_exception(struct nfs_server *server, int errorcode, struct nfs4_exception *exception) 2583int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception)
2435{ 2584{
2436 struct nfs4_client *clp = server->nfs4_state; 2585 struct nfs4_client *clp = server->nfs4_state;
2437 int ret = errorcode; 2586 int ret = errorcode;
@@ -2632,7 +2781,6 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
2632 2781
2633 down_read(&clp->cl_sem); 2782 down_read(&clp->cl_sem);
2634 nlo.clientid = clp->cl_clientid; 2783 nlo.clientid = clp->cl_clientid;
2635 down(&state->lock_sema);
2636 status = nfs4_set_lock_state(state, request); 2784 status = nfs4_set_lock_state(state, request);
2637 if (status != 0) 2785 if (status != 0)
2638 goto out; 2786 goto out;
@@ -2659,7 +2807,6 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
2659 status = 0; 2807 status = 0;
2660 } 2808 }
2661out: 2809out:
2662 up(&state->lock_sema);
2663 up_read(&clp->cl_sem); 2810 up_read(&clp->cl_sem);
2664 return status; 2811 return status;
2665} 2812}
@@ -2696,79 +2843,149 @@ static int do_vfs_lock(struct file *file, struct file_lock *fl)
2696 return res; 2843 return res;
2697} 2844}
2698 2845
2699static int _nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) 2846struct nfs4_unlockdata {
2847 struct nfs_lockargs arg;
2848 struct nfs_locku_opargs luargs;
2849 struct nfs_lockres res;
2850 struct nfs4_lock_state *lsp;
2851 struct nfs_open_context *ctx;
2852 atomic_t refcount;
2853 struct completion completion;
2854};
2855
2856static void nfs4_locku_release_calldata(struct nfs4_unlockdata *calldata)
2700{ 2857{
2701 struct inode *inode = state->inode; 2858 if (atomic_dec_and_test(&calldata->refcount)) {
2702 struct nfs_server *server = NFS_SERVER(inode); 2859 nfs_free_seqid(calldata->luargs.seqid);
2703 struct nfs4_client *clp = server->nfs4_state; 2860 nfs4_put_lock_state(calldata->lsp);
2704 struct nfs_lockargs arg = { 2861 put_nfs_open_context(calldata->ctx);
2705 .fh = NFS_FH(inode), 2862 kfree(calldata);
2706 .type = nfs4_lck_type(cmd, request), 2863 }
2707 .offset = request->fl_start, 2864}
2708 .length = nfs4_lck_length(request), 2865
2709 }; 2866static void nfs4_locku_complete(struct nfs4_unlockdata *calldata)
2710 struct nfs_lockres res = { 2867{
2711 .server = server, 2868 complete(&calldata->completion);
2712 }; 2869 nfs4_locku_release_calldata(calldata);
2870}
2871
2872static void nfs4_locku_done(struct rpc_task *task)
2873{
2874 struct nfs4_unlockdata *calldata = (struct nfs4_unlockdata *)task->tk_calldata;
2875
2876 nfs_increment_lock_seqid(task->tk_status, calldata->luargs.seqid);
2877 switch (task->tk_status) {
2878 case 0:
2879 memcpy(calldata->lsp->ls_stateid.data,
2880 calldata->res.u.stateid.data,
2881 sizeof(calldata->lsp->ls_stateid.data));
2882 break;
2883 case -NFS4ERR_STALE_STATEID:
2884 case -NFS4ERR_EXPIRED:
2885 nfs4_schedule_state_recovery(calldata->res.server->nfs4_state);
2886 break;
2887 default:
2888 if (nfs4_async_handle_error(task, calldata->res.server) == -EAGAIN) {
2889 rpc_restart_call(task);
2890 return;
2891 }
2892 }
2893 nfs4_locku_complete(calldata);
2894}
2895
2896static void nfs4_locku_begin(struct rpc_task *task)
2897{
2898 struct nfs4_unlockdata *calldata = (struct nfs4_unlockdata *)task->tk_calldata;
2713 struct rpc_message msg = { 2899 struct rpc_message msg = {
2714 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU], 2900 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU],
2715 .rpc_argp = &arg, 2901 .rpc_argp = &calldata->arg,
2716 .rpc_resp = &res, 2902 .rpc_resp = &calldata->res,
2717 .rpc_cred = state->owner->so_cred, 2903 .rpc_cred = calldata->lsp->ls_state->owner->so_cred,
2718 }; 2904 };
2905 int status;
2906
2907 status = nfs_wait_on_sequence(calldata->luargs.seqid, task);
2908 if (status != 0)
2909 return;
2910 if ((calldata->lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) {
2911 nfs4_locku_complete(calldata);
2912 task->tk_exit = NULL;
2913 rpc_exit(task, 0);
2914 return;
2915 }
2916 rpc_call_setup(task, &msg, 0);
2917}
2918
2919static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
2920{
2921 struct nfs4_unlockdata *calldata;
2922 struct inode *inode = state->inode;
2923 struct nfs_server *server = NFS_SERVER(inode);
2719 struct nfs4_lock_state *lsp; 2924 struct nfs4_lock_state *lsp;
2720 struct nfs_locku_opargs luargs;
2721 int status; 2925 int status;
2722 2926
2723 down_read(&clp->cl_sem);
2724 down(&state->lock_sema);
2725 status = nfs4_set_lock_state(state, request); 2927 status = nfs4_set_lock_state(state, request);
2726 if (status != 0) 2928 if (status != 0)
2727 goto out; 2929 return status;
2728 lsp = request->fl_u.nfs4_fl.owner; 2930 lsp = request->fl_u.nfs4_fl.owner;
2729 /* We might have lost the locks! */ 2931 /* We might have lost the locks! */
2730 if ((lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) 2932 if ((lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0)
2731 goto out; 2933 return 0;
2732 luargs.seqid = lsp->ls_seqid; 2934 calldata = kmalloc(sizeof(*calldata), GFP_KERNEL);
2733 memcpy(&luargs.stateid, &lsp->ls_stateid, sizeof(luargs.stateid)); 2935 if (calldata == NULL)
2734 arg.u.locku = &luargs; 2936 return -ENOMEM;
2735 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 2937 calldata->luargs.seqid = nfs_alloc_seqid(&lsp->ls_seqid);
2736 nfs4_increment_lock_seqid(status, lsp); 2938 if (calldata->luargs.seqid == NULL) {
2737 2939 kfree(calldata);
2738 if (status == 0) 2940 return -ENOMEM;
2739 memcpy(&lsp->ls_stateid, &res.u.stateid, 2941 }
2740 sizeof(lsp->ls_stateid)); 2942 calldata->luargs.stateid = &lsp->ls_stateid;
2741out: 2943 calldata->arg.fh = NFS_FH(inode);
2742 up(&state->lock_sema); 2944 calldata->arg.type = nfs4_lck_type(cmd, request);
2945 calldata->arg.offset = request->fl_start;
2946 calldata->arg.length = nfs4_lck_length(request);
2947 calldata->arg.u.locku = &calldata->luargs;
2948 calldata->res.server = server;
2949 calldata->lsp = lsp;
2950 atomic_inc(&lsp->ls_count);
2951
2952 /* Ensure we don't close file until we're done freeing locks! */
2953 calldata->ctx = get_nfs_open_context((struct nfs_open_context*)request->fl_file->private_data);
2954
2955 atomic_set(&calldata->refcount, 2);
2956 init_completion(&calldata->completion);
2957
2958 status = nfs4_call_async(NFS_SERVER(inode)->client, nfs4_locku_begin,
2959 nfs4_locku_done, calldata);
2743 if (status == 0) 2960 if (status == 0)
2744 do_vfs_lock(request->fl_file, request); 2961 wait_for_completion_interruptible(&calldata->completion);
2745 up_read(&clp->cl_sem); 2962 do_vfs_lock(request->fl_file, request);
2963 nfs4_locku_release_calldata(calldata);
2746 return status; 2964 return status;
2747} 2965}
2748 2966
2749static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
2750{
2751 struct nfs4_exception exception = { };
2752 int err;
2753
2754 do {
2755 err = nfs4_handle_exception(NFS_SERVER(state->inode),
2756 _nfs4_proc_unlck(state, cmd, request),
2757 &exception);
2758 } while (exception.retry);
2759 return err;
2760}
2761
2762static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *request, int reclaim) 2967static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *request, int reclaim)
2763{ 2968{
2764 struct inode *inode = state->inode; 2969 struct inode *inode = state->inode;
2765 struct nfs_server *server = NFS_SERVER(inode); 2970 struct nfs_server *server = NFS_SERVER(inode);
2766 struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; 2971 struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner;
2972 struct nfs_lock_opargs largs = {
2973 .lock_stateid = &lsp->ls_stateid,
2974 .open_stateid = &state->stateid,
2975 .lock_owner = {
2976 .clientid = server->nfs4_state->cl_clientid,
2977 .id = lsp->ls_id,
2978 },
2979 .reclaim = reclaim,
2980 };
2767 struct nfs_lockargs arg = { 2981 struct nfs_lockargs arg = {
2768 .fh = NFS_FH(inode), 2982 .fh = NFS_FH(inode),
2769 .type = nfs4_lck_type(cmd, request), 2983 .type = nfs4_lck_type(cmd, request),
2770 .offset = request->fl_start, 2984 .offset = request->fl_start,
2771 .length = nfs4_lck_length(request), 2985 .length = nfs4_lck_length(request),
2986 .u = {
2987 .lock = &largs,
2988 },
2772 }; 2989 };
2773 struct nfs_lockres res = { 2990 struct nfs_lockres res = {
2774 .server = server, 2991 .server = server,
@@ -2779,53 +2996,39 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *r
2779 .rpc_resp = &res, 2996 .rpc_resp = &res,
2780 .rpc_cred = state->owner->so_cred, 2997 .rpc_cred = state->owner->so_cred,
2781 }; 2998 };
2782 struct nfs_lock_opargs largs = { 2999 int status = -ENOMEM;
2783 .reclaim = reclaim,
2784 .new_lock_owner = 0,
2785 };
2786 int status;
2787 3000
2788 if (!(lsp->ls_flags & NFS_LOCK_INITIALIZED)) { 3001 largs.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid);
3002 if (largs.lock_seqid == NULL)
3003 return -ENOMEM;
3004 if (!(lsp->ls_seqid.flags & NFS_SEQID_CONFIRMED)) {
2789 struct nfs4_state_owner *owner = state->owner; 3005 struct nfs4_state_owner *owner = state->owner;
2790 struct nfs_open_to_lock otl = { 3006
2791 .lock_owner = { 3007 largs.open_seqid = nfs_alloc_seqid(&owner->so_seqid);
2792 .clientid = server->nfs4_state->cl_clientid, 3008 if (largs.open_seqid == NULL)
2793 }, 3009 goto out;
2794 };
2795
2796 otl.lock_seqid = lsp->ls_seqid;
2797 otl.lock_owner.id = lsp->ls_id;
2798 memcpy(&otl.open_stateid, &state->stateid, sizeof(otl.open_stateid));
2799 largs.u.open_lock = &otl;
2800 largs.new_lock_owner = 1; 3010 largs.new_lock_owner = 1;
2801 arg.u.lock = &largs;
2802 down(&owner->so_sema);
2803 otl.open_seqid = owner->so_seqid;
2804 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 3011 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR);
2805 /* increment open_owner seqid on success, and 3012 /* increment open seqid on success, and seqid mutating errors */
2806 * seqid mutating errors */ 3013 if (largs.new_lock_owner != 0) {
2807 nfs4_increment_seqid(status, owner); 3014 nfs_increment_open_seqid(status, largs.open_seqid);
2808 up(&owner->so_sema); 3015 if (status == 0)
2809 if (status == 0) { 3016 nfs_confirm_seqid(&lsp->ls_seqid, 0);
2810 lsp->ls_flags |= NFS_LOCK_INITIALIZED;
2811 lsp->ls_seqid++;
2812 } 3017 }
2813 } else { 3018 nfs_free_seqid(largs.open_seqid);
2814 struct nfs_exist_lock el = { 3019 } else
2815 .seqid = lsp->ls_seqid,
2816 };
2817 memcpy(&el.stateid, &lsp->ls_stateid, sizeof(el.stateid));
2818 largs.u.exist_lock = &el;
2819 arg.u.lock = &largs;
2820 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); 3020 status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR);
2821 /* increment seqid on success, and * seqid mutating errors*/ 3021 /* increment lock seqid on success, and seqid mutating errors*/
2822 nfs4_increment_lock_seqid(status, lsp); 3022 nfs_increment_lock_seqid(status, largs.lock_seqid);
2823 }
2824 /* save the returned stateid. */ 3023 /* save the returned stateid. */
2825 if (status == 0) 3024 if (status == 0) {
2826 memcpy(&lsp->ls_stateid, &res.u.stateid, sizeof(nfs4_stateid)); 3025 memcpy(lsp->ls_stateid.data, res.u.stateid.data,
2827 else if (status == -NFS4ERR_DENIED) 3026 sizeof(lsp->ls_stateid.data));
3027 lsp->ls_flags |= NFS_LOCK_INITIALIZED;
3028 } else if (status == -NFS4ERR_DENIED)
2828 status = -EAGAIN; 3029 status = -EAGAIN;
3030out:
3031 nfs_free_seqid(largs.lock_seqid);
2829 return status; 3032 return status;
2830} 3033}
2831 3034
@@ -2865,11 +3068,9 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
2865 int status; 3068 int status;
2866 3069
2867 down_read(&clp->cl_sem); 3070 down_read(&clp->cl_sem);
2868 down(&state->lock_sema);
2869 status = nfs4_set_lock_state(state, request); 3071 status = nfs4_set_lock_state(state, request);
2870 if (status == 0) 3072 if (status == 0)
2871 status = _nfs4_do_setlk(state, cmd, request, 0); 3073 status = _nfs4_do_setlk(state, cmd, request, 0);
2872 up(&state->lock_sema);
2873 if (status == 0) { 3074 if (status == 0) {
2874 /* Note: we always want to sleep here! */ 3075 /* Note: we always want to sleep here! */
2875 request->fl_flags |= FL_SLEEP; 3076 request->fl_flags |= FL_SLEEP;
@@ -3024,8 +3225,8 @@ struct nfs_rpc_ops nfs_v4_clientops = {
3024 .read_setup = nfs4_proc_read_setup, 3225 .read_setup = nfs4_proc_read_setup,
3025 .write_setup = nfs4_proc_write_setup, 3226 .write_setup = nfs4_proc_write_setup,
3026 .commit_setup = nfs4_proc_commit_setup, 3227 .commit_setup = nfs4_proc_commit_setup,
3027 .file_open = nfs4_proc_file_open, 3228 .file_open = nfs_open,
3028 .file_release = nfs4_proc_file_release, 3229 .file_release = nfs_release,
3029 .lock = nfs4_proc_lock, 3230 .lock = nfs4_proc_lock,
3030 .clear_acl_cache = nfs4_zap_acl_attr, 3231 .clear_acl_cache = nfs4_zap_acl_attr,
3031}; 3232};
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index afe587d82f1e..2d5a6a2b9dec 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -264,13 +264,16 @@ nfs4_alloc_state_owner(void)
264{ 264{
265 struct nfs4_state_owner *sp; 265 struct nfs4_state_owner *sp;
266 266
267 sp = kmalloc(sizeof(*sp),GFP_KERNEL); 267 sp = kzalloc(sizeof(*sp),GFP_KERNEL);
268 if (!sp) 268 if (!sp)
269 return NULL; 269 return NULL;
270 init_MUTEX(&sp->so_sema); 270 spin_lock_init(&sp->so_lock);
271 sp->so_seqid = 0; /* arbitrary */
272 INIT_LIST_HEAD(&sp->so_states); 271 INIT_LIST_HEAD(&sp->so_states);
273 INIT_LIST_HEAD(&sp->so_delegations); 272 INIT_LIST_HEAD(&sp->so_delegations);
273 rpc_init_wait_queue(&sp->so_sequence.wait, "Seqid_waitqueue");
274 sp->so_seqid.sequence = &sp->so_sequence;
275 spin_lock_init(&sp->so_sequence.lock);
276 INIT_LIST_HEAD(&sp->so_sequence.list);
274 atomic_set(&sp->so_count, 1); 277 atomic_set(&sp->so_count, 1);
275 return sp; 278 return sp;
276} 279}
@@ -359,7 +362,6 @@ nfs4_alloc_open_state(void)
359 memset(state->stateid.data, 0, sizeof(state->stateid.data)); 362 memset(state->stateid.data, 0, sizeof(state->stateid.data));
360 atomic_set(&state->count, 1); 363 atomic_set(&state->count, 1);
361 INIT_LIST_HEAD(&state->lock_states); 364 INIT_LIST_HEAD(&state->lock_states);
362 init_MUTEX(&state->lock_sema);
363 spin_lock_init(&state->state_lock); 365 spin_lock_init(&state->state_lock);
364 return state; 366 return state;
365} 367}
@@ -437,21 +439,23 @@ nfs4_get_open_state(struct inode *inode, struct nfs4_state_owner *owner)
437 if (state) 439 if (state)
438 goto out; 440 goto out;
439 new = nfs4_alloc_open_state(); 441 new = nfs4_alloc_open_state();
442 spin_lock(&owner->so_lock);
440 spin_lock(&inode->i_lock); 443 spin_lock(&inode->i_lock);
441 state = __nfs4_find_state_byowner(inode, owner); 444 state = __nfs4_find_state_byowner(inode, owner);
442 if (state == NULL && new != NULL) { 445 if (state == NULL && new != NULL) {
443 state = new; 446 state = new;
444 /* Caller *must* be holding owner->so_sem */
445 /* Note: The reclaim code dictates that we add stateless
446 * and read-only stateids to the end of the list */
447 list_add_tail(&state->open_states, &owner->so_states);
448 state->owner = owner; 447 state->owner = owner;
449 atomic_inc(&owner->so_count); 448 atomic_inc(&owner->so_count);
450 list_add(&state->inode_states, &nfsi->open_states); 449 list_add(&state->inode_states, &nfsi->open_states);
451 state->inode = igrab(inode); 450 state->inode = igrab(inode);
452 spin_unlock(&inode->i_lock); 451 spin_unlock(&inode->i_lock);
452 /* Note: The reclaim code dictates that we add stateless
453 * and read-only stateids to the end of the list */
454 list_add_tail(&state->open_states, &owner->so_states);
455 spin_unlock(&owner->so_lock);
453 } else { 456 } else {
454 spin_unlock(&inode->i_lock); 457 spin_unlock(&inode->i_lock);
458 spin_unlock(&owner->so_lock);
455 if (new) 459 if (new)
456 nfs4_free_open_state(new); 460 nfs4_free_open_state(new);
457 } 461 }
@@ -461,19 +465,21 @@ out:
461 465
462/* 466/*
463 * Beware! Caller must be holding exactly one 467 * Beware! Caller must be holding exactly one
464 * reference to clp->cl_sem and owner->so_sema! 468 * reference to clp->cl_sem!
465 */ 469 */
466void nfs4_put_open_state(struct nfs4_state *state) 470void nfs4_put_open_state(struct nfs4_state *state)
467{ 471{
468 struct inode *inode = state->inode; 472 struct inode *inode = state->inode;
469 struct nfs4_state_owner *owner = state->owner; 473 struct nfs4_state_owner *owner = state->owner;
470 474
471 if (!atomic_dec_and_lock(&state->count, &inode->i_lock)) 475 if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
472 return; 476 return;
477 spin_lock(&inode->i_lock);
473 if (!list_empty(&state->inode_states)) 478 if (!list_empty(&state->inode_states))
474 list_del(&state->inode_states); 479 list_del(&state->inode_states);
475 spin_unlock(&inode->i_lock);
476 list_del(&state->open_states); 480 list_del(&state->open_states);
481 spin_unlock(&inode->i_lock);
482 spin_unlock(&owner->so_lock);
477 iput(inode); 483 iput(inode);
478 BUG_ON (state->state != 0); 484 BUG_ON (state->state != 0);
479 nfs4_free_open_state(state); 485 nfs4_free_open_state(state);
@@ -481,20 +487,17 @@ void nfs4_put_open_state(struct nfs4_state *state)
481} 487}
482 488
483/* 489/*
484 * Beware! Caller must be holding no references to clp->cl_sem! 490 * Close the current file.
485 * of owner->so_sema!
486 */ 491 */
487void nfs4_close_state(struct nfs4_state *state, mode_t mode) 492void nfs4_close_state(struct nfs4_state *state, mode_t mode)
488{ 493{
489 struct inode *inode = state->inode; 494 struct inode *inode = state->inode;
490 struct nfs4_state_owner *owner = state->owner; 495 struct nfs4_state_owner *owner = state->owner;
491 struct nfs4_client *clp = owner->so_client;
492 int newstate; 496 int newstate;
493 497
494 atomic_inc(&owner->so_count); 498 atomic_inc(&owner->so_count);
495 down_read(&clp->cl_sem);
496 down(&owner->so_sema);
497 /* Protect against nfs4_find_state() */ 499 /* Protect against nfs4_find_state() */
500 spin_lock(&owner->so_lock);
498 spin_lock(&inode->i_lock); 501 spin_lock(&inode->i_lock);
499 if (mode & FMODE_READ) 502 if (mode & FMODE_READ)
500 state->nreaders--; 503 state->nreaders--;
@@ -507,6 +510,7 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode)
507 list_move_tail(&state->open_states, &owner->so_states); 510 list_move_tail(&state->open_states, &owner->so_states);
508 } 511 }
509 spin_unlock(&inode->i_lock); 512 spin_unlock(&inode->i_lock);
513 spin_unlock(&owner->so_lock);
510 newstate = 0; 514 newstate = 0;
511 if (state->state != 0) { 515 if (state->state != 0) {
512 if (state->nreaders) 516 if (state->nreaders)
@@ -515,14 +519,16 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode)
515 newstate |= FMODE_WRITE; 519 newstate |= FMODE_WRITE;
516 if (state->state == newstate) 520 if (state->state == newstate)
517 goto out; 521 goto out;
518 if (nfs4_do_close(inode, state, newstate) == -EINPROGRESS) 522 if (test_bit(NFS_DELEGATED_STATE, &state->flags)) {
523 state->state = newstate;
524 goto out;
525 }
526 if (nfs4_do_close(inode, state, newstate) == 0)
519 return; 527 return;
520 } 528 }
521out: 529out:
522 nfs4_put_open_state(state); 530 nfs4_put_open_state(state);
523 up(&owner->so_sema);
524 nfs4_put_state_owner(owner); 531 nfs4_put_state_owner(owner);
525 up_read(&clp->cl_sem);
526} 532}
527 533
528/* 534/*
@@ -546,19 +552,16 @@ __nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)
546 * Return a compatible lock_state. If no initialized lock_state structure 552 * Return a compatible lock_state. If no initialized lock_state structure
547 * exists, return an uninitialized one. 553 * exists, return an uninitialized one.
548 * 554 *
549 * The caller must be holding state->lock_sema
550 */ 555 */
551static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner) 556static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, fl_owner_t fl_owner)
552{ 557{
553 struct nfs4_lock_state *lsp; 558 struct nfs4_lock_state *lsp;
554 struct nfs4_client *clp = state->owner->so_client; 559 struct nfs4_client *clp = state->owner->so_client;
555 560
556 lsp = kmalloc(sizeof(*lsp), GFP_KERNEL); 561 lsp = kzalloc(sizeof(*lsp), GFP_KERNEL);
557 if (lsp == NULL) 562 if (lsp == NULL)
558 return NULL; 563 return NULL;
559 lsp->ls_flags = 0; 564 lsp->ls_seqid.sequence = &state->owner->so_sequence;
560 lsp->ls_seqid = 0; /* arbitrary */
561 memset(lsp->ls_stateid.data, 0, sizeof(lsp->ls_stateid.data));
562 atomic_set(&lsp->ls_count, 1); 565 atomic_set(&lsp->ls_count, 1);
563 lsp->ls_owner = fl_owner; 566 lsp->ls_owner = fl_owner;
564 spin_lock(&clp->cl_lock); 567 spin_lock(&clp->cl_lock);
@@ -572,7 +575,7 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f
572 * Return a compatible lock_state. If no initialized lock_state structure 575 * Return a compatible lock_state. If no initialized lock_state structure
573 * exists, return an uninitialized one. 576 * exists, return an uninitialized one.
574 * 577 *
575 * The caller must be holding state->lock_sema and clp->cl_sem 578 * The caller must be holding clp->cl_sem
576 */ 579 */
577static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner) 580static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t owner)
578{ 581{
@@ -605,7 +608,7 @@ static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_
605 * Release reference to lock_state, and free it if we see that 608 * Release reference to lock_state, and free it if we see that
606 * it is no longer in use 609 * it is no longer in use
607 */ 610 */
608static void nfs4_put_lock_state(struct nfs4_lock_state *lsp) 611void nfs4_put_lock_state(struct nfs4_lock_state *lsp)
609{ 612{
610 struct nfs4_state *state; 613 struct nfs4_state *state;
611 614
@@ -673,29 +676,94 @@ void nfs4_copy_stateid(nfs4_stateid *dst, struct nfs4_state *state, fl_owner_t f
673 nfs4_put_lock_state(lsp); 676 nfs4_put_lock_state(lsp);
674} 677}
675 678
676/* 679struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter)
677* Called with state->lock_sema and clp->cl_sem held.
678*/
679void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *lsp)
680{ 680{
681 if (status == NFS_OK || seqid_mutating_err(-status)) 681 struct nfs_seqid *new;
682 lsp->ls_seqid++; 682
683 new = kmalloc(sizeof(*new), GFP_KERNEL);
684 if (new != NULL) {
685 new->sequence = counter;
686 INIT_LIST_HEAD(&new->list);
687 }
688 return new;
689}
690
691void nfs_free_seqid(struct nfs_seqid *seqid)
692{
693 struct rpc_sequence *sequence = seqid->sequence->sequence;
694
695 if (!list_empty(&seqid->list)) {
696 spin_lock(&sequence->lock);
697 list_del(&seqid->list);
698 spin_unlock(&sequence->lock);
699 }
700 rpc_wake_up_next(&sequence->wait);
701 kfree(seqid);
683} 702}
684 703
685/* 704/*
686* Called with sp->so_sema and clp->cl_sem held. 705 * Increment the seqid if the OPEN/OPEN_DOWNGRADE/CLOSE succeeded, or
687* 706 * failed with a seqid incrementing error -
688* Increment the seqid if the OPEN/OPEN_DOWNGRADE/CLOSE succeeded, or 707 * see comments nfs_fs.h:seqid_mutating_error()
689* failed with a seqid incrementing error - 708 */
690* see comments nfs_fs.h:seqid_mutating_error() 709static inline void nfs_increment_seqid(int status, struct nfs_seqid *seqid)
691*/ 710{
692void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp) 711 switch (status) {
693{ 712 case 0:
694 if (status == NFS_OK || seqid_mutating_err(-status)) 713 break;
695 sp->so_seqid++; 714 case -NFS4ERR_BAD_SEQID:
696 /* If the server returns BAD_SEQID, unhash state_owner here */ 715 case -NFS4ERR_STALE_CLIENTID:
697 if (status == -NFS4ERR_BAD_SEQID) 716 case -NFS4ERR_STALE_STATEID:
717 case -NFS4ERR_BAD_STATEID:
718 case -NFS4ERR_BADXDR:
719 case -NFS4ERR_RESOURCE:
720 case -NFS4ERR_NOFILEHANDLE:
721 /* Non-seqid mutating errors */
722 return;
723 };
724 /*
725 * Note: no locking needed as we are guaranteed to be first
726 * on the sequence list
727 */
728 seqid->sequence->counter++;
729}
730
731void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid)
732{
733 if (status == -NFS4ERR_BAD_SEQID) {
734 struct nfs4_state_owner *sp = container_of(seqid->sequence,
735 struct nfs4_state_owner, so_seqid);
698 nfs4_drop_state_owner(sp); 736 nfs4_drop_state_owner(sp);
737 }
738 return nfs_increment_seqid(status, seqid);
739}
740
741/*
742 * Increment the seqid if the LOCK/LOCKU succeeded, or
743 * failed with a seqid incrementing error -
744 * see comments nfs_fs.h:seqid_mutating_error()
745 */
746void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid)
747{
748 return nfs_increment_seqid(status, seqid);
749}
750
751int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task)
752{
753 struct rpc_sequence *sequence = seqid->sequence->sequence;
754 int status = 0;
755
756 if (sequence->list.next == &seqid->list)
757 goto out;
758 spin_lock(&sequence->lock);
759 if (!list_empty(&sequence->list)) {
760 rpc_sleep_on(&sequence->wait, task, NULL, NULL);
761 status = -EAGAIN;
762 } else
763 list_add(&seqid->list, &sequence->list);
764 spin_unlock(&sequence->lock);
765out:
766 return status;
699} 767}
700 768
701static int reclaimer(void *); 769static int reclaimer(void *);
@@ -791,8 +859,6 @@ static int nfs4_reclaim_open_state(struct nfs4_state_recovery_ops *ops, struct n
791 if (state->state == 0) 859 if (state->state == 0)
792 continue; 860 continue;
793 status = ops->recover_open(sp, state); 861 status = ops->recover_open(sp, state);
794 list_for_each_entry(lock, &state->lock_states, ls_locks)
795 lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
796 if (status >= 0) { 862 if (status >= 0) {
797 status = nfs4_reclaim_locks(ops, state); 863 status = nfs4_reclaim_locks(ops, state);
798 if (status < 0) 864 if (status < 0)
@@ -831,6 +897,28 @@ out_err:
831 return status; 897 return status;
832} 898}
833 899
900static void nfs4_state_mark_reclaim(struct nfs4_client *clp)
901{
902 struct nfs4_state_owner *sp;
903 struct nfs4_state *state;
904 struct nfs4_lock_state *lock;
905
906 /* Reset all sequence ids to zero */
907 list_for_each_entry(sp, &clp->cl_state_owners, so_list) {
908 sp->so_seqid.counter = 0;
909 sp->so_seqid.flags = 0;
910 spin_lock(&sp->so_lock);
911 list_for_each_entry(state, &sp->so_states, open_states) {
912 list_for_each_entry(lock, &state->lock_states, ls_locks) {
913 lock->ls_seqid.counter = 0;
914 lock->ls_seqid.flags = 0;
915 lock->ls_flags &= ~NFS_LOCK_INITIALIZED;
916 }
917 }
918 spin_unlock(&sp->so_lock);
919 }
920}
921
834static int reclaimer(void *ptr) 922static int reclaimer(void *ptr)
835{ 923{
836 struct reclaimer_args *args = (struct reclaimer_args *)ptr; 924 struct reclaimer_args *args = (struct reclaimer_args *)ptr;
@@ -864,6 +952,7 @@ restart_loop:
864 default: 952 default:
865 ops = &nfs4_network_partition_recovery_ops; 953 ops = &nfs4_network_partition_recovery_ops;
866 }; 954 };
955 nfs4_state_mark_reclaim(clp);
867 status = __nfs4_init_client(clp); 956 status = __nfs4_init_client(clp);
868 if (status) 957 if (status)
869 goto out_error; 958 goto out_error;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 6c564ef9489e..fbbace8a30c4 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -95,6 +95,8 @@ static int nfs_stat_to_errno(int);
95#define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) 95#define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
96#define encode_savefh_maxsz (op_encode_hdr_maxsz) 96#define encode_savefh_maxsz (op_encode_hdr_maxsz)
97#define decode_savefh_maxsz (op_decode_hdr_maxsz) 97#define decode_savefh_maxsz (op_decode_hdr_maxsz)
98#define encode_restorefh_maxsz (op_encode_hdr_maxsz)
99#define decode_restorefh_maxsz (op_decode_hdr_maxsz)
98#define encode_fsinfo_maxsz (op_encode_hdr_maxsz + 2) 100#define encode_fsinfo_maxsz (op_encode_hdr_maxsz + 2)
99#define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) 101#define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11)
100#define encode_renew_maxsz (op_encode_hdr_maxsz + 3) 102#define encode_renew_maxsz (op_encode_hdr_maxsz + 3)
@@ -157,16 +159,20 @@ static int nfs_stat_to_errno(int);
157 op_decode_hdr_maxsz + 2) 159 op_decode_hdr_maxsz + 2)
158#define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ 160#define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
159 encode_putfh_maxsz + \ 161 encode_putfh_maxsz + \
160 op_encode_hdr_maxsz + 8) 162 op_encode_hdr_maxsz + 8 + \
163 encode_getattr_maxsz)
161#define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ 164#define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
162 decode_putfh_maxsz + \ 165 decode_putfh_maxsz + \
163 op_decode_hdr_maxsz + 4) 166 op_decode_hdr_maxsz + 4 + \
167 decode_getattr_maxsz)
164#define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ 168#define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
165 encode_putfh_maxsz + \ 169 encode_putfh_maxsz + \
166 op_encode_hdr_maxsz + 3) 170 op_encode_hdr_maxsz + 3 + \
171 encode_getattr_maxsz)
167#define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ 172#define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
168 decode_putfh_maxsz + \ 173 decode_putfh_maxsz + \
169 op_decode_hdr_maxsz + 2) 174 op_decode_hdr_maxsz + 2 + \
175 decode_getattr_maxsz)
170#define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ 176#define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
171 encode_putfh_maxsz + \ 177 encode_putfh_maxsz + \
172 op_encode_hdr_maxsz + \ 178 op_encode_hdr_maxsz + \
@@ -196,17 +202,21 @@ static int nfs_stat_to_errno(int);
196#define NFS4_enc_open_downgrade_sz \ 202#define NFS4_enc_open_downgrade_sz \
197 (compound_encode_hdr_maxsz + \ 203 (compound_encode_hdr_maxsz + \
198 encode_putfh_maxsz + \ 204 encode_putfh_maxsz + \
199 op_encode_hdr_maxsz + 7) 205 op_encode_hdr_maxsz + 7 + \
206 encode_getattr_maxsz)
200#define NFS4_dec_open_downgrade_sz \ 207#define NFS4_dec_open_downgrade_sz \
201 (compound_decode_hdr_maxsz + \ 208 (compound_decode_hdr_maxsz + \
202 decode_putfh_maxsz + \ 209 decode_putfh_maxsz + \
203 op_decode_hdr_maxsz + 4) 210 op_decode_hdr_maxsz + 4 + \
211 decode_getattr_maxsz)
204#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ 212#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
205 encode_putfh_maxsz + \ 213 encode_putfh_maxsz + \
206 op_encode_hdr_maxsz + 5) 214 op_encode_hdr_maxsz + 5 + \
215 encode_getattr_maxsz)
207#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ 216#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
208 decode_putfh_maxsz + \ 217 decode_putfh_maxsz + \
209 op_decode_hdr_maxsz + 4) 218 op_decode_hdr_maxsz + 4 + \
219 decode_getattr_maxsz)
210#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ 220#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
211 encode_putfh_maxsz + \ 221 encode_putfh_maxsz + \
212 op_encode_hdr_maxsz + 4 + \ 222 op_encode_hdr_maxsz + 4 + \
@@ -300,30 +310,44 @@ static int nfs_stat_to_errno(int);
300 decode_getfh_maxsz) 310 decode_getfh_maxsz)
301#define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ 311#define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
302 encode_putfh_maxsz + \ 312 encode_putfh_maxsz + \
303 encode_remove_maxsz) 313 encode_remove_maxsz + \
314 encode_getattr_maxsz)
304#define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ 315#define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
305 decode_putfh_maxsz + \ 316 decode_putfh_maxsz + \
306 op_decode_hdr_maxsz + 5) 317 op_decode_hdr_maxsz + 5 + \
318 decode_getattr_maxsz)
307#define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ 319#define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
308 encode_putfh_maxsz + \ 320 encode_putfh_maxsz + \
309 encode_savefh_maxsz + \ 321 encode_savefh_maxsz + \
310 encode_putfh_maxsz + \ 322 encode_putfh_maxsz + \
311 encode_rename_maxsz) 323 encode_rename_maxsz + \
324 encode_getattr_maxsz + \
325 encode_restorefh_maxsz + \
326 encode_getattr_maxsz)
312#define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ 327#define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
313 decode_putfh_maxsz + \ 328 decode_putfh_maxsz + \
314 decode_savefh_maxsz + \ 329 decode_savefh_maxsz + \
315 decode_putfh_maxsz + \ 330 decode_putfh_maxsz + \
316 decode_rename_maxsz) 331 decode_rename_maxsz + \
332 decode_getattr_maxsz + \
333 decode_restorefh_maxsz + \
334 decode_getattr_maxsz)
317#define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ 335#define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
318 encode_putfh_maxsz + \ 336 encode_putfh_maxsz + \
319 encode_savefh_maxsz + \ 337 encode_savefh_maxsz + \
320 encode_putfh_maxsz + \ 338 encode_putfh_maxsz + \
321 encode_link_maxsz) 339 encode_link_maxsz + \
340 decode_getattr_maxsz + \
341 encode_restorefh_maxsz + \
342 decode_getattr_maxsz)
322#define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ 343#define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
323 decode_putfh_maxsz + \ 344 decode_putfh_maxsz + \
324 decode_savefh_maxsz + \ 345 decode_savefh_maxsz + \
325 decode_putfh_maxsz + \ 346 decode_putfh_maxsz + \
326 decode_link_maxsz) 347 decode_link_maxsz + \
348 decode_getattr_maxsz + \
349 decode_restorefh_maxsz + \
350 decode_getattr_maxsz)
327#define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ 351#define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
328 encode_putfh_maxsz + \ 352 encode_putfh_maxsz + \
329 encode_symlink_maxsz + \ 353 encode_symlink_maxsz + \
@@ -336,14 +360,20 @@ static int nfs_stat_to_errno(int);
336 decode_getfh_maxsz) 360 decode_getfh_maxsz)
337#define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \ 361#define NFS4_enc_create_sz (compound_encode_hdr_maxsz + \
338 encode_putfh_maxsz + \ 362 encode_putfh_maxsz + \
363 encode_savefh_maxsz + \
339 encode_create_maxsz + \ 364 encode_create_maxsz + \
365 encode_getfh_maxsz + \
340 encode_getattr_maxsz + \ 366 encode_getattr_maxsz + \
341 encode_getfh_maxsz) 367 encode_restorefh_maxsz + \
368 encode_getattr_maxsz)
342#define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \ 369#define NFS4_dec_create_sz (compound_decode_hdr_maxsz + \
343 decode_putfh_maxsz + \ 370 decode_putfh_maxsz + \
371 decode_savefh_maxsz + \
344 decode_create_maxsz + \ 372 decode_create_maxsz + \
373 decode_getfh_maxsz + \
345 decode_getattr_maxsz + \ 374 decode_getattr_maxsz + \
346 decode_getfh_maxsz) 375 decode_restorefh_maxsz + \
376 decode_getattr_maxsz)
347#define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \ 377#define NFS4_enc_pathconf_sz (compound_encode_hdr_maxsz + \
348 encode_putfh_maxsz + \ 378 encode_putfh_maxsz + \
349 encode_getattr_maxsz) 379 encode_getattr_maxsz)
@@ -602,10 +632,10 @@ static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
602{ 632{
603 uint32_t *p; 633 uint32_t *p;
604 634
605 RESERVE_SPACE(8+sizeof(arg->stateid.data)); 635 RESERVE_SPACE(8+sizeof(arg->stateid->data));
606 WRITE32(OP_CLOSE); 636 WRITE32(OP_CLOSE);
607 WRITE32(arg->seqid); 637 WRITE32(arg->seqid->sequence->counter);
608 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); 638 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data));
609 639
610 return 0; 640 return 0;
611} 641}
@@ -729,22 +759,18 @@ static int encode_lock(struct xdr_stream *xdr, const struct nfs_lockargs *arg)
729 WRITE64(arg->length); 759 WRITE64(arg->length);
730 WRITE32(opargs->new_lock_owner); 760 WRITE32(opargs->new_lock_owner);
731 if (opargs->new_lock_owner){ 761 if (opargs->new_lock_owner){
732 struct nfs_open_to_lock *ol = opargs->u.open_lock;
733
734 RESERVE_SPACE(40); 762 RESERVE_SPACE(40);
735 WRITE32(ol->open_seqid); 763 WRITE32(opargs->open_seqid->sequence->counter);
736 WRITEMEM(&ol->open_stateid, sizeof(ol->open_stateid)); 764 WRITEMEM(opargs->open_stateid->data, sizeof(opargs->open_stateid->data));
737 WRITE32(ol->lock_seqid); 765 WRITE32(opargs->lock_seqid->sequence->counter);
738 WRITE64(ol->lock_owner.clientid); 766 WRITE64(opargs->lock_owner.clientid);
739 WRITE32(4); 767 WRITE32(4);
740 WRITE32(ol->lock_owner.id); 768 WRITE32(opargs->lock_owner.id);
741 } 769 }
742 else { 770 else {
743 struct nfs_exist_lock *el = opargs->u.exist_lock;
744
745 RESERVE_SPACE(20); 771 RESERVE_SPACE(20);
746 WRITEMEM(&el->stateid, sizeof(el->stateid)); 772 WRITEMEM(opargs->lock_stateid->data, sizeof(opargs->lock_stateid->data));
747 WRITE32(el->seqid); 773 WRITE32(opargs->lock_seqid->sequence->counter);
748 } 774 }
749 775
750 return 0; 776 return 0;
@@ -775,8 +801,8 @@ static int encode_locku(struct xdr_stream *xdr, const struct nfs_lockargs *arg)
775 RESERVE_SPACE(44); 801 RESERVE_SPACE(44);
776 WRITE32(OP_LOCKU); 802 WRITE32(OP_LOCKU);
777 WRITE32(arg->type); 803 WRITE32(arg->type);
778 WRITE32(opargs->seqid); 804 WRITE32(opargs->seqid->sequence->counter);
779 WRITEMEM(&opargs->stateid, sizeof(opargs->stateid)); 805 WRITEMEM(opargs->stateid->data, sizeof(opargs->stateid->data));
780 WRITE64(arg->offset); 806 WRITE64(arg->offset);
781 WRITE64(arg->length); 807 WRITE64(arg->length);
782 808
@@ -826,7 +852,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
826 */ 852 */
827 RESERVE_SPACE(8); 853 RESERVE_SPACE(8);
828 WRITE32(OP_OPEN); 854 WRITE32(OP_OPEN);
829 WRITE32(arg->seqid); 855 WRITE32(arg->seqid->sequence->counter);
830 encode_share_access(xdr, arg->open_flags); 856 encode_share_access(xdr, arg->open_flags);
831 RESERVE_SPACE(16); 857 RESERVE_SPACE(16);
832 WRITE64(arg->clientid); 858 WRITE64(arg->clientid);
@@ -941,7 +967,7 @@ static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_con
941 RESERVE_SPACE(8+sizeof(arg->stateid.data)); 967 RESERVE_SPACE(8+sizeof(arg->stateid.data));
942 WRITE32(OP_OPEN_CONFIRM); 968 WRITE32(OP_OPEN_CONFIRM);
943 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); 969 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data));
944 WRITE32(arg->seqid); 970 WRITE32(arg->seqid->sequence->counter);
945 971
946 return 0; 972 return 0;
947} 973}
@@ -950,10 +976,10 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea
950{ 976{
951 uint32_t *p; 977 uint32_t *p;
952 978
953 RESERVE_SPACE(8+sizeof(arg->stateid.data)); 979 RESERVE_SPACE(8+sizeof(arg->stateid->data));
954 WRITE32(OP_OPEN_DOWNGRADE); 980 WRITE32(OP_OPEN_DOWNGRADE);
955 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); 981 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data));
956 WRITE32(arg->seqid); 982 WRITE32(arg->seqid->sequence->counter);
957 encode_share_access(xdr, arg->open_flags); 983 encode_share_access(xdr, arg->open_flags);
958 return 0; 984 return 0;
959} 985}
@@ -1117,6 +1143,17 @@ static int encode_renew(struct xdr_stream *xdr, const struct nfs4_client *client
1117} 1143}
1118 1144
1119static int 1145static int
1146encode_restorefh(struct xdr_stream *xdr)
1147{
1148 uint32_t *p;
1149
1150 RESERVE_SPACE(4);
1151 WRITE32(OP_RESTOREFH);
1152
1153 return 0;
1154}
1155
1156static int
1120encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg) 1157encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1121{ 1158{
1122 uint32_t *p; 1159 uint32_t *p;
@@ -1296,14 +1333,18 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, uint32_t *p, const struct n
1296{ 1333{
1297 struct xdr_stream xdr; 1334 struct xdr_stream xdr;
1298 struct compound_hdr hdr = { 1335 struct compound_hdr hdr = {
1299 .nops = 2, 1336 .nops = 3,
1300 }; 1337 };
1301 int status; 1338 int status;
1302 1339
1303 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1340 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1304 encode_compound_hdr(&xdr, &hdr); 1341 encode_compound_hdr(&xdr, &hdr);
1305 if ((status = encode_putfh(&xdr, args->fh)) == 0) 1342 if ((status = encode_putfh(&xdr, args->fh)) != 0)
1306 status = encode_remove(&xdr, args->name); 1343 goto out;
1344 if ((status = encode_remove(&xdr, args->name)) != 0)
1345 goto out;
1346 status = encode_getfattr(&xdr, args->bitmask);
1347out:
1307 return status; 1348 return status;
1308} 1349}
1309 1350
@@ -1314,7 +1355,7 @@ static int nfs4_xdr_enc_rename(struct rpc_rqst *req, uint32_t *p, const struct n
1314{ 1355{
1315 struct xdr_stream xdr; 1356 struct xdr_stream xdr;
1316 struct compound_hdr hdr = { 1357 struct compound_hdr hdr = {
1317 .nops = 4, 1358 .nops = 7,
1318 }; 1359 };
1319 int status; 1360 int status;
1320 1361
@@ -1326,7 +1367,13 @@ static int nfs4_xdr_enc_rename(struct rpc_rqst *req, uint32_t *p, const struct n
1326 goto out; 1367 goto out;
1327 if ((status = encode_putfh(&xdr, args->new_dir)) != 0) 1368 if ((status = encode_putfh(&xdr, args->new_dir)) != 0)
1328 goto out; 1369 goto out;
1329 status = encode_rename(&xdr, args->old_name, args->new_name); 1370 if ((status = encode_rename(&xdr, args->old_name, args->new_name)) != 0)
1371 goto out;
1372 if ((status = encode_getfattr(&xdr, args->bitmask)) != 0)
1373 goto out;
1374 if ((status = encode_restorefh(&xdr)) != 0)
1375 goto out;
1376 status = encode_getfattr(&xdr, args->bitmask);
1330out: 1377out:
1331 return status; 1378 return status;
1332} 1379}
@@ -1338,7 +1385,7 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs
1338{ 1385{
1339 struct xdr_stream xdr; 1386 struct xdr_stream xdr;
1340 struct compound_hdr hdr = { 1387 struct compound_hdr hdr = {
1341 .nops = 4, 1388 .nops = 7,
1342 }; 1389 };
1343 int status; 1390 int status;
1344 1391
@@ -1350,7 +1397,13 @@ static int nfs4_xdr_enc_link(struct rpc_rqst *req, uint32_t *p, const struct nfs
1350 goto out; 1397 goto out;
1351 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0) 1398 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
1352 goto out; 1399 goto out;
1353 status = encode_link(&xdr, args->name); 1400 if ((status = encode_link(&xdr, args->name)) != 0)
1401 goto out;
1402 if ((status = encode_getfattr(&xdr, args->bitmask)) != 0)
1403 goto out;
1404 if ((status = encode_restorefh(&xdr)) != 0)
1405 goto out;
1406 status = encode_getfattr(&xdr, args->bitmask);
1354out: 1407out:
1355 return status; 1408 return status;
1356} 1409}
@@ -1362,7 +1415,7 @@ static int nfs4_xdr_enc_create(struct rpc_rqst *req, uint32_t *p, const struct n
1362{ 1415{
1363 struct xdr_stream xdr; 1416 struct xdr_stream xdr;
1364 struct compound_hdr hdr = { 1417 struct compound_hdr hdr = {
1365 .nops = 4, 1418 .nops = 7,
1366 }; 1419 };
1367 int status; 1420 int status;
1368 1421
@@ -1370,10 +1423,16 @@ static int nfs4_xdr_enc_create(struct rpc_rqst *req, uint32_t *p, const struct n
1370 encode_compound_hdr(&xdr, &hdr); 1423 encode_compound_hdr(&xdr, &hdr);
1371 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0) 1424 if ((status = encode_putfh(&xdr, args->dir_fh)) != 0)
1372 goto out; 1425 goto out;
1426 if ((status = encode_savefh(&xdr)) != 0)
1427 goto out;
1373 if ((status = encode_create(&xdr, args)) != 0) 1428 if ((status = encode_create(&xdr, args)) != 0)
1374 goto out; 1429 goto out;
1375 if ((status = encode_getfh(&xdr)) != 0) 1430 if ((status = encode_getfh(&xdr)) != 0)
1376 goto out; 1431 goto out;
1432 if ((status = encode_getfattr(&xdr, args->bitmask)) != 0)
1433 goto out;
1434 if ((status = encode_restorefh(&xdr)) != 0)
1435 goto out;
1377 status = encode_getfattr(&xdr, args->bitmask); 1436 status = encode_getfattr(&xdr, args->bitmask);
1378out: 1437out:
1379 return status; 1438 return status;
@@ -1412,7 +1471,7 @@ static int nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_clos
1412{ 1471{
1413 struct xdr_stream xdr; 1472 struct xdr_stream xdr;
1414 struct compound_hdr hdr = { 1473 struct compound_hdr hdr = {
1415 .nops = 2, 1474 .nops = 3,
1416 }; 1475 };
1417 int status; 1476 int status;
1418 1477
@@ -1422,6 +1481,9 @@ static int nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_clos
1422 if(status) 1481 if(status)
1423 goto out; 1482 goto out;
1424 status = encode_close(&xdr, args); 1483 status = encode_close(&xdr, args);
1484 if (status != 0)
1485 goto out;
1486 status = encode_getfattr(&xdr, args->bitmask);
1425out: 1487out:
1426 return status; 1488 return status;
1427} 1489}
@@ -1433,15 +1495,21 @@ static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_opena
1433{ 1495{
1434 struct xdr_stream xdr; 1496 struct xdr_stream xdr;
1435 struct compound_hdr hdr = { 1497 struct compound_hdr hdr = {
1436 .nops = 4, 1498 .nops = 7,
1437 }; 1499 };
1438 int status; 1500 int status;
1439 1501
1502 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1503 if (status != 0)
1504 goto out;
1440 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1505 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1441 encode_compound_hdr(&xdr, &hdr); 1506 encode_compound_hdr(&xdr, &hdr);
1442 status = encode_putfh(&xdr, args->fh); 1507 status = encode_putfh(&xdr, args->fh);
1443 if (status) 1508 if (status)
1444 goto out; 1509 goto out;
1510 status = encode_savefh(&xdr);
1511 if (status)
1512 goto out;
1445 status = encode_open(&xdr, args); 1513 status = encode_open(&xdr, args);
1446 if (status) 1514 if (status)
1447 goto out; 1515 goto out;
@@ -1449,6 +1517,12 @@ static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_opena
1449 if (status) 1517 if (status)
1450 goto out; 1518 goto out;
1451 status = encode_getfattr(&xdr, args->bitmask); 1519 status = encode_getfattr(&xdr, args->bitmask);
1520 if (status)
1521 goto out;
1522 status = encode_restorefh(&xdr);
1523 if (status)
1524 goto out;
1525 status = encode_getfattr(&xdr, args->bitmask);
1452out: 1526out:
1453 return status; 1527 return status;
1454} 1528}
@@ -1464,6 +1538,9 @@ static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct n
1464 }; 1538 };
1465 int status; 1539 int status;
1466 1540
1541 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1542 if (status != 0)
1543 goto out;
1467 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1544 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1468 encode_compound_hdr(&xdr, &hdr); 1545 encode_compound_hdr(&xdr, &hdr);
1469 status = encode_putfh(&xdr, args->fh); 1546 status = encode_putfh(&xdr, args->fh);
@@ -1485,6 +1562,9 @@ static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, uint32_t *p, struct nf
1485 }; 1562 };
1486 int status; 1563 int status;
1487 1564
1565 status = nfs_wait_on_sequence(args->seqid, req->rq_task);
1566 if (status != 0)
1567 goto out;
1488 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1568 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1489 encode_compound_hdr(&xdr, &hdr); 1569 encode_compound_hdr(&xdr, &hdr);
1490 status = encode_putfh(&xdr, args->fh); 1570 status = encode_putfh(&xdr, args->fh);
@@ -1502,7 +1582,7 @@ static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct
1502{ 1582{
1503 struct xdr_stream xdr; 1583 struct xdr_stream xdr;
1504 struct compound_hdr hdr = { 1584 struct compound_hdr hdr = {
1505 .nops = 2, 1585 .nops = 3,
1506 }; 1586 };
1507 int status; 1587 int status;
1508 1588
@@ -1512,6 +1592,9 @@ static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct
1512 if (status) 1592 if (status)
1513 goto out; 1593 goto out;
1514 status = encode_open_downgrade(&xdr, args); 1594 status = encode_open_downgrade(&xdr, args);
1595 if (status != 0)
1596 goto out;
1597 status = encode_getfattr(&xdr, args->bitmask);
1515out: 1598out:
1516 return status; 1599 return status;
1517} 1600}
@@ -1525,8 +1608,15 @@ static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_locka
1525 struct compound_hdr hdr = { 1608 struct compound_hdr hdr = {
1526 .nops = 2, 1609 .nops = 2,
1527 }; 1610 };
1611 struct nfs_lock_opargs *opargs = args->u.lock;
1528 int status; 1612 int status;
1529 1613
1614 status = nfs_wait_on_sequence(opargs->lock_seqid, req->rq_task);
1615 if (status != 0)
1616 goto out;
1617 /* Do we need to do an open_to_lock_owner? */
1618 if (opargs->lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)
1619 opargs->new_lock_owner = 0;
1530 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1620 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1531 encode_compound_hdr(&xdr, &hdr); 1621 encode_compound_hdr(&xdr, &hdr);
1532 status = encode_putfh(&xdr, args->fh); 1622 status = encode_putfh(&xdr, args->fh);
@@ -1713,7 +1803,7 @@ static int nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writ
1713{ 1803{
1714 struct xdr_stream xdr; 1804 struct xdr_stream xdr;
1715 struct compound_hdr hdr = { 1805 struct compound_hdr hdr = {
1716 .nops = 2, 1806 .nops = 3,
1717 }; 1807 };
1718 int status; 1808 int status;
1719 1809
@@ -1723,6 +1813,9 @@ static int nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writ
1723 if (status) 1813 if (status)
1724 goto out; 1814 goto out;
1725 status = encode_write(&xdr, args); 1815 status = encode_write(&xdr, args);
1816 if (status)
1817 goto out;
1818 status = encode_getfattr(&xdr, args->bitmask);
1726out: 1819out:
1727 return status; 1820 return status;
1728} 1821}
@@ -1734,7 +1827,7 @@ static int nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_wri
1734{ 1827{
1735 struct xdr_stream xdr; 1828 struct xdr_stream xdr;
1736 struct compound_hdr hdr = { 1829 struct compound_hdr hdr = {
1737 .nops = 2, 1830 .nops = 3,
1738 }; 1831 };
1739 int status; 1832 int status;
1740 1833
@@ -1744,6 +1837,9 @@ static int nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_wri
1744 if (status) 1837 if (status)
1745 goto out; 1838 goto out;
1746 status = encode_commit(&xdr, args); 1839 status = encode_commit(&xdr, args);
1840 if (status)
1841 goto out;
1842 status = encode_getfattr(&xdr, args->bitmask);
1747out: 1843out:
1748 return status; 1844 return status;
1749} 1845}
@@ -2670,8 +2766,7 @@ static int decode_server_caps(struct xdr_stream *xdr, struct nfs4_server_caps_re
2670 goto xdr_error; 2766 goto xdr_error;
2671 status = verify_attr_len(xdr, savep, attrlen); 2767 status = verify_attr_len(xdr, savep, attrlen);
2672xdr_error: 2768xdr_error:
2673 if (status != 0) 2769 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status);
2674 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2675 return status; 2770 return status;
2676} 2771}
2677 2772
@@ -2704,8 +2799,7 @@ static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat)
2704 2799
2705 status = verify_attr_len(xdr, savep, attrlen); 2800 status = verify_attr_len(xdr, savep, attrlen);
2706xdr_error: 2801xdr_error:
2707 if (status != 0) 2802 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status);
2708 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2709 return status; 2803 return status;
2710} 2804}
2711 2805
@@ -2730,8 +2824,7 @@ static int decode_pathconf(struct xdr_stream *xdr, struct nfs_pathconf *pathconf
2730 2824
2731 status = verify_attr_len(xdr, savep, attrlen); 2825 status = verify_attr_len(xdr, savep, attrlen);
2732xdr_error: 2826xdr_error:
2733 if (status != 0) 2827 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status);
2734 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2735 return status; 2828 return status;
2736} 2829}
2737 2830
@@ -2787,13 +2880,10 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons
2787 goto xdr_error; 2880 goto xdr_error;
2788 if ((status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime)) != 0) 2881 if ((status = decode_attr_time_modify(xdr, bitmap, &fattr->mtime)) != 0)
2789 goto xdr_error; 2882 goto xdr_error;
2790 if ((status = verify_attr_len(xdr, savep, attrlen)) == 0) { 2883 if ((status = verify_attr_len(xdr, savep, attrlen)) == 0)
2791 fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4; 2884 fattr->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4;
2792 fattr->timestamp = jiffies;
2793 }
2794xdr_error: 2885xdr_error:
2795 if (status != 0) 2886 dprintk("%s: xdr returned %d\n", __FUNCTION__, -status);
2796 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2797 return status; 2887 return status;
2798} 2888}
2799 2889
@@ -2826,8 +2916,7 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
2826 2916
2827 status = verify_attr_len(xdr, savep, attrlen); 2917 status = verify_attr_len(xdr, savep, attrlen);
2828xdr_error: 2918xdr_error:
2829 if (status != 0) 2919 dprintk("%s: xdr returned %d!\n", __FUNCTION__, -status);
2830 printk(KERN_NOTICE "%s: xdr error %d!\n", __FUNCTION__, -status);
2831 return status; 2920 return status;
2832} 2921}
2833 2922
@@ -2890,8 +2979,8 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lockres *res)
2890 2979
2891 status = decode_op_hdr(xdr, OP_LOCK); 2980 status = decode_op_hdr(xdr, OP_LOCK);
2892 if (status == 0) { 2981 if (status == 0) {
2893 READ_BUF(sizeof(nfs4_stateid)); 2982 READ_BUF(sizeof(res->u.stateid.data));
2894 COPYMEM(&res->u.stateid, sizeof(res->u.stateid)); 2983 COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data));
2895 } else if (status == -NFS4ERR_DENIED) 2984 } else if (status == -NFS4ERR_DENIED)
2896 return decode_lock_denied(xdr, &res->u.denied); 2985 return decode_lock_denied(xdr, &res->u.denied);
2897 return status; 2986 return status;
@@ -2913,8 +3002,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_lockres *res)
2913 3002
2914 status = decode_op_hdr(xdr, OP_LOCKU); 3003 status = decode_op_hdr(xdr, OP_LOCKU);
2915 if (status == 0) { 3004 if (status == 0) {
2916 READ_BUF(sizeof(nfs4_stateid)); 3005 READ_BUF(sizeof(res->u.stateid.data));
2917 COPYMEM(&res->u.stateid, sizeof(res->u.stateid)); 3006 COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data));
2918 } 3007 }
2919 return status; 3008 return status;
2920} 3009}
@@ -2994,7 +3083,7 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
2994 p += bmlen; 3083 p += bmlen;
2995 return decode_delegation(xdr, res); 3084 return decode_delegation(xdr, res);
2996xdr_error: 3085xdr_error:
2997 printk(KERN_NOTICE "%s: xdr error!\n", __FUNCTION__); 3086 dprintk("%s: Bitmap too large! Length = %u\n", __FUNCTION__, bmlen);
2998 return -EIO; 3087 return -EIO;
2999} 3088}
3000 3089
@@ -3208,6 +3297,12 @@ static int decode_renew(struct xdr_stream *xdr)
3208 return decode_op_hdr(xdr, OP_RENEW); 3297 return decode_op_hdr(xdr, OP_RENEW);
3209} 3298}
3210 3299
3300static int
3301decode_restorefh(struct xdr_stream *xdr)
3302{
3303 return decode_op_hdr(xdr, OP_RESTOREFH);
3304}
3305
3211static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, 3306static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
3212 size_t *acl_len) 3307 size_t *acl_len)
3213{ 3308{
@@ -3243,7 +3338,8 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req,
3243 if (attrlen <= *acl_len) 3338 if (attrlen <= *acl_len)
3244 xdr_read_pages(xdr, attrlen); 3339 xdr_read_pages(xdr, attrlen);
3245 *acl_len = attrlen; 3340 *acl_len = attrlen;
3246 } 3341 } else
3342 status = -EOPNOTSUPP;
3247 3343
3248out: 3344out:
3249 return status; 3345 return status;
@@ -3352,6 +3448,9 @@ static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, uint32_t *p, stru
3352 if (status) 3448 if (status)
3353 goto out; 3449 goto out;
3354 status = decode_open_downgrade(&xdr, res); 3450 status = decode_open_downgrade(&xdr, res);
3451 if (status != 0)
3452 goto out;
3453 decode_getfattr(&xdr, res->fattr, res->server);
3355out: 3454out:
3356 return status; 3455 return status;
3357} 3456}
@@ -3424,7 +3523,7 @@ out:
3424/* 3523/*
3425 * Decode REMOVE response 3524 * Decode REMOVE response
3426 */ 3525 */
3427static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_change_info *cinfo) 3526static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_remove_res *res)
3428{ 3527{
3429 struct xdr_stream xdr; 3528 struct xdr_stream xdr;
3430 struct compound_hdr hdr; 3529 struct compound_hdr hdr;
@@ -3433,8 +3532,11 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_
3433 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); 3532 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3434 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0) 3533 if ((status = decode_compound_hdr(&xdr, &hdr)) != 0)
3435 goto out; 3534 goto out;
3436 if ((status = decode_putfh(&xdr)) == 0) 3535 if ((status = decode_putfh(&xdr)) != 0)
3437 status = decode_remove(&xdr, cinfo); 3536 goto out;
3537 if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
3538 goto out;
3539 decode_getfattr(&xdr, res->dir_attr, res->server);
3438out: 3540out:
3439 return status; 3541 return status;
3440} 3542}
@@ -3457,7 +3559,14 @@ static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_
3457 goto out; 3559 goto out;
3458 if ((status = decode_putfh(&xdr)) != 0) 3560 if ((status = decode_putfh(&xdr)) != 0)
3459 goto out; 3561 goto out;
3460 status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo); 3562 if ((status = decode_rename(&xdr, &res->old_cinfo, &res->new_cinfo)) != 0)
3563 goto out;
3564 /* Current FH is target directory */
3565 if (decode_getfattr(&xdr, res->new_fattr, res->server) != 0)
3566 goto out;
3567 if ((status = decode_restorefh(&xdr)) != 0)
3568 goto out;
3569 decode_getfattr(&xdr, res->old_fattr, res->server);
3461out: 3570out:
3462 return status; 3571 return status;
3463} 3572}
@@ -3465,7 +3574,7 @@ out:
3465/* 3574/*
3466 * Decode LINK response 3575 * Decode LINK response
3467 */ 3576 */
3468static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_change_info *cinfo) 3577static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_link_res *res)
3469{ 3578{
3470 struct xdr_stream xdr; 3579 struct xdr_stream xdr;
3471 struct compound_hdr hdr; 3580 struct compound_hdr hdr;
@@ -3480,7 +3589,17 @@ static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_ch
3480 goto out; 3589 goto out;
3481 if ((status = decode_putfh(&xdr)) != 0) 3590 if ((status = decode_putfh(&xdr)) != 0)
3482 goto out; 3591 goto out;
3483 status = decode_link(&xdr, cinfo); 3592 if ((status = decode_link(&xdr, &res->cinfo)) != 0)
3593 goto out;
3594 /*
3595 * Note order: OP_LINK leaves the directory as the current
3596 * filehandle.
3597 */
3598 if (decode_getfattr(&xdr, res->dir_attr, res->server) != 0)
3599 goto out;
3600 if ((status = decode_restorefh(&xdr)) != 0)
3601 goto out;
3602 decode_getfattr(&xdr, res->fattr, res->server);
3484out: 3603out:
3485 return status; 3604 return status;
3486} 3605}
@@ -3499,13 +3618,17 @@ static int nfs4_xdr_dec_create(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_
3499 goto out; 3618 goto out;
3500 if ((status = decode_putfh(&xdr)) != 0) 3619 if ((status = decode_putfh(&xdr)) != 0)
3501 goto out; 3620 goto out;
3621 if ((status = decode_savefh(&xdr)) != 0)
3622 goto out;
3502 if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0) 3623 if ((status = decode_create(&xdr,&res->dir_cinfo)) != 0)
3503 goto out; 3624 goto out;
3504 if ((status = decode_getfh(&xdr, res->fh)) != 0) 3625 if ((status = decode_getfh(&xdr, res->fh)) != 0)
3505 goto out; 3626 goto out;
3506 status = decode_getfattr(&xdr, res->fattr, res->server); 3627 if (decode_getfattr(&xdr, res->fattr, res->server) != 0)
3507 if (status == NFS4ERR_DELAY) 3628 goto out;
3508 status = 0; 3629 if ((status = decode_restorefh(&xdr)) != 0)
3630 goto out;
3631 decode_getfattr(&xdr, res->dir_fattr, res->server);
3509out: 3632out:
3510 return status; 3633 return status;
3511} 3634}
@@ -3623,6 +3746,15 @@ static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_cl
3623 if (status) 3746 if (status)
3624 goto out; 3747 goto out;
3625 status = decode_close(&xdr, res); 3748 status = decode_close(&xdr, res);
3749 if (status != 0)
3750 goto out;
3751 /*
3752 * Note: Server may do delete on close for this file
3753 * in which case the getattr call will fail with
3754 * an ESTALE error. Shouldn't be a problem,
3755 * though, since fattr->valid will remain unset.
3756 */
3757 decode_getfattr(&xdr, res->fattr, res->server);
3626out: 3758out:
3627 return status; 3759 return status;
3628} 3760}
@@ -3643,15 +3775,20 @@ static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_ope
3643 status = decode_putfh(&xdr); 3775 status = decode_putfh(&xdr);
3644 if (status) 3776 if (status)
3645 goto out; 3777 goto out;
3778 status = decode_savefh(&xdr);
3779 if (status)
3780 goto out;
3646 status = decode_open(&xdr, res); 3781 status = decode_open(&xdr, res);
3647 if (status) 3782 if (status)
3648 goto out; 3783 goto out;
3649 status = decode_getfh(&xdr, &res->fh); 3784 status = decode_getfh(&xdr, &res->fh);
3650 if (status) 3785 if (status)
3651 goto out; 3786 goto out;
3652 status = decode_getfattr(&xdr, res->f_attr, res->server); 3787 if (decode_getfattr(&xdr, res->f_attr, res->server) != 0)
3653 if (status == NFS4ERR_DELAY) 3788 goto out;
3654 status = 0; 3789 if ((status = decode_restorefh(&xdr)) != 0)
3790 goto out;
3791 decode_getfattr(&xdr, res->dir_attr, res->server);
3655out: 3792out:
3656 return status; 3793 return status;
3657} 3794}
@@ -3869,6 +4006,9 @@ static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_wr
3869 if (status) 4006 if (status)
3870 goto out; 4007 goto out;
3871 status = decode_write(&xdr, res); 4008 status = decode_write(&xdr, res);
4009 if (status)
4010 goto out;
4011 decode_getfattr(&xdr, res->fattr, res->server);
3872 if (!status) 4012 if (!status)
3873 status = res->count; 4013 status = res->count;
3874out: 4014out:
@@ -3892,6 +4032,9 @@ static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_w
3892 if (status) 4032 if (status)
3893 goto out; 4033 goto out;
3894 status = decode_commit(&xdr, res); 4034 status = decode_commit(&xdr, res);
4035 if (status)
4036 goto out;
4037 decode_getfattr(&xdr, res->fattr, res->server);
3895out: 4038out:
3896 return status; 4039 return status;
3897} 4040}
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index be23c3fb9260..a48a003242c0 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -61,7 +61,7 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
61 int status; 61 int status;
62 62
63 dprintk("%s: call getattr\n", __FUNCTION__); 63 dprintk("%s: call getattr\n", __FUNCTION__);
64 fattr->valid = 0; 64 nfs_fattr_init(fattr);
65 status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0); 65 status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);
66 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); 66 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
67 if (status) 67 if (status)
@@ -93,7 +93,7 @@ nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
93 int status; 93 int status;
94 94
95 dprintk("NFS call getattr\n"); 95 dprintk("NFS call getattr\n");
96 fattr->valid = 0; 96 nfs_fattr_init(fattr);
97 status = rpc_call(server->client, NFSPROC_GETATTR, 97 status = rpc_call(server->client, NFSPROC_GETATTR,
98 fhandle, fattr, 0); 98 fhandle, fattr, 0);
99 dprintk("NFS reply getattr: %d\n", status); 99 dprintk("NFS reply getattr: %d\n", status);
@@ -112,7 +112,7 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
112 int status; 112 int status;
113 113
114 dprintk("NFS call setattr\n"); 114 dprintk("NFS call setattr\n");
115 fattr->valid = 0; 115 nfs_fattr_init(fattr);
116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0); 116 status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);
117 if (status == 0) 117 if (status == 0)
118 nfs_setattr_update_inode(inode, sattr); 118 nfs_setattr_update_inode(inode, sattr);
@@ -136,7 +136,7 @@ nfs_proc_lookup(struct inode *dir, struct qstr *name,
136 int status; 136 int status;
137 137
138 dprintk("NFS call lookup %s\n", name->name); 138 dprintk("NFS call lookup %s\n", name->name);
139 fattr->valid = 0; 139 nfs_fattr_init(fattr);
140 status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0); 140 status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0);
141 dprintk("NFS reply lookup: %d\n", status); 141 dprintk("NFS reply lookup: %d\n", status);
142 return status; 142 return status;
@@ -174,7 +174,7 @@ static int nfs_proc_read(struct nfs_read_data *rdata)
174 174
175 dprintk("NFS call read %d @ %Ld\n", rdata->args.count, 175 dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
176 (long long) rdata->args.offset); 176 (long long) rdata->args.offset);
177 fattr->valid = 0; 177 nfs_fattr_init(fattr);
178 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags); 178 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
179 if (status >= 0) { 179 if (status >= 0) {
180 nfs_refresh_inode(inode, fattr); 180 nfs_refresh_inode(inode, fattr);
@@ -203,10 +203,10 @@ static int nfs_proc_write(struct nfs_write_data *wdata)
203 203
204 dprintk("NFS call write %d @ %Ld\n", wdata->args.count, 204 dprintk("NFS call write %d @ %Ld\n", wdata->args.count,
205 (long long) wdata->args.offset); 205 (long long) wdata->args.offset);
206 fattr->valid = 0; 206 nfs_fattr_init(fattr);
207 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags); 207 status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
208 if (status >= 0) { 208 if (status >= 0) {
209 nfs_refresh_inode(inode, fattr); 209 nfs_post_op_update_inode(inode, fattr);
210 wdata->res.count = wdata->args.count; 210 wdata->res.count = wdata->args.count;
211 wdata->verf.committed = NFS_FILE_SYNC; 211 wdata->verf.committed = NFS_FILE_SYNC;
212 } 212 }
@@ -216,7 +216,7 @@ static int nfs_proc_write(struct nfs_write_data *wdata)
216 216
217static int 217static int
218nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 218nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
219 int flags) 219 int flags, struct nameidata *nd)
220{ 220{
221 struct nfs_fh fhandle; 221 struct nfs_fh fhandle;
222 struct nfs_fattr fattr; 222 struct nfs_fattr fattr;
@@ -232,7 +232,7 @@ nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
232 }; 232 };
233 int status; 233 int status;
234 234
235 fattr.valid = 0; 235 nfs_fattr_init(&fattr);
236 dprintk("NFS call create %s\n", dentry->d_name.name); 236 dprintk("NFS call create %s\n", dentry->d_name.name);
237 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); 237 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
238 if (status == 0) 238 if (status == 0)
@@ -273,12 +273,13 @@ nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
273 sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */ 273 sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
274 } 274 }
275 275
276 fattr.valid = 0; 276 nfs_fattr_init(&fattr);
277 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); 277 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
278 nfs_mark_for_revalidate(dir);
278 279
279 if (status == -EINVAL && S_ISFIFO(mode)) { 280 if (status == -EINVAL && S_ISFIFO(mode)) {
280 sattr->ia_mode = mode; 281 sattr->ia_mode = mode;
281 fattr.valid = 0; 282 nfs_fattr_init(&fattr);
282 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); 283 status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
283 } 284 }
284 if (status == 0) 285 if (status == 0)
@@ -305,6 +306,7 @@ nfs_proc_remove(struct inode *dir, struct qstr *name)
305 306
306 dprintk("NFS call remove %s\n", name->name); 307 dprintk("NFS call remove %s\n", name->name);
307 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); 308 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
309 nfs_mark_for_revalidate(dir);
308 310
309 dprintk("NFS reply remove: %d\n", status); 311 dprintk("NFS reply remove: %d\n", status);
310 return status; 312 return status;
@@ -331,8 +333,10 @@ nfs_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
331{ 333{
332 struct rpc_message *msg = &task->tk_msg; 334 struct rpc_message *msg = &task->tk_msg;
333 335
334 if (msg->rpc_argp) 336 if (msg->rpc_argp) {
337 nfs_mark_for_revalidate(dir->d_inode);
335 kfree(msg->rpc_argp); 338 kfree(msg->rpc_argp);
339 }
336 return 0; 340 return 0;
337} 341}
338 342
@@ -352,6 +356,8 @@ nfs_proc_rename(struct inode *old_dir, struct qstr *old_name,
352 356
353 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); 357 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
354 status = rpc_call(NFS_CLIENT(old_dir), NFSPROC_RENAME, &arg, NULL, 0); 358 status = rpc_call(NFS_CLIENT(old_dir), NFSPROC_RENAME, &arg, NULL, 0);
359 nfs_mark_for_revalidate(old_dir);
360 nfs_mark_for_revalidate(new_dir);
355 dprintk("NFS reply rename: %d\n", status); 361 dprintk("NFS reply rename: %d\n", status);
356 return status; 362 return status;
357} 363}
@@ -369,6 +375,7 @@ nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
369 375
370 dprintk("NFS call link %s\n", name->name); 376 dprintk("NFS call link %s\n", name->name);
371 status = rpc_call(NFS_CLIENT(inode), NFSPROC_LINK, &arg, NULL, 0); 377 status = rpc_call(NFS_CLIENT(inode), NFSPROC_LINK, &arg, NULL, 0);
378 nfs_mark_for_revalidate(dir);
372 dprintk("NFS reply link: %d\n", status); 379 dprintk("NFS reply link: %d\n", status);
373 return status; 380 return status;
374} 381}
@@ -391,9 +398,10 @@ nfs_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
391 if (path->len > NFS2_MAXPATHLEN) 398 if (path->len > NFS2_MAXPATHLEN)
392 return -ENAMETOOLONG; 399 return -ENAMETOOLONG;
393 dprintk("NFS call symlink %s -> %s\n", name->name, path->name); 400 dprintk("NFS call symlink %s -> %s\n", name->name, path->name);
394 fattr->valid = 0; 401 nfs_fattr_init(fattr);
395 fhandle->size = 0; 402 fhandle->size = 0;
396 status = rpc_call(NFS_CLIENT(dir), NFSPROC_SYMLINK, &arg, NULL, 0); 403 status = rpc_call(NFS_CLIENT(dir), NFSPROC_SYMLINK, &arg, NULL, 0);
404 nfs_mark_for_revalidate(dir);
397 dprintk("NFS reply symlink: %d\n", status); 405 dprintk("NFS reply symlink: %d\n", status);
398 return status; 406 return status;
399} 407}
@@ -416,8 +424,9 @@ nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
416 int status; 424 int status;
417 425
418 dprintk("NFS call mkdir %s\n", dentry->d_name.name); 426 dprintk("NFS call mkdir %s\n", dentry->d_name.name);
419 fattr.valid = 0; 427 nfs_fattr_init(&fattr);
420 status = rpc_call(NFS_CLIENT(dir), NFSPROC_MKDIR, &arg, &res, 0); 428 status = rpc_call(NFS_CLIENT(dir), NFSPROC_MKDIR, &arg, &res, 0);
429 nfs_mark_for_revalidate(dir);
421 if (status == 0) 430 if (status == 0)
422 status = nfs_instantiate(dentry, &fhandle, &fattr); 431 status = nfs_instantiate(dentry, &fhandle, &fattr);
423 dprintk("NFS reply mkdir: %d\n", status); 432 dprintk("NFS reply mkdir: %d\n", status);
@@ -436,6 +445,7 @@ nfs_proc_rmdir(struct inode *dir, struct qstr *name)
436 445
437 dprintk("NFS call rmdir %s\n", name->name); 446 dprintk("NFS call rmdir %s\n", name->name);
438 status = rpc_call(NFS_CLIENT(dir), NFSPROC_RMDIR, &arg, NULL, 0); 447 status = rpc_call(NFS_CLIENT(dir), NFSPROC_RMDIR, &arg, NULL, 0);
448 nfs_mark_for_revalidate(dir);
439 dprintk("NFS reply rmdir: %d\n", status); 449 dprintk("NFS reply rmdir: %d\n", status);
440 return status; 450 return status;
441} 451}
@@ -484,7 +494,7 @@ nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
484 int status; 494 int status;
485 495
486 dprintk("NFS call statfs\n"); 496 dprintk("NFS call statfs\n");
487 stat->fattr->valid = 0; 497 nfs_fattr_init(stat->fattr);
488 status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0); 498 status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
489 dprintk("NFS reply statfs: %d\n", status); 499 dprintk("NFS reply statfs: %d\n", status);
490 if (status) 500 if (status)
@@ -507,7 +517,7 @@ nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
507 int status; 517 int status;
508 518
509 dprintk("NFS call fsinfo\n"); 519 dprintk("NFS call fsinfo\n");
510 info->fattr->valid = 0; 520 nfs_fattr_init(info->fattr);
511 status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0); 521 status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
512 dprintk("NFS reply fsinfo: %d\n", status); 522 dprintk("NFS reply fsinfo: %d\n", status);
513 if (status) 523 if (status)
@@ -579,7 +589,7 @@ nfs_write_done(struct rpc_task *task)
579 struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; 589 struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata;
580 590
581 if (task->tk_status >= 0) 591 if (task->tk_status >= 0)
582 nfs_refresh_inode(data->inode, data->res.fattr); 592 nfs_post_op_update_inode(data->inode, data->res.fattr);
583 nfs_writeback_done(task); 593 nfs_writeback_done(task);
584} 594}
585 595
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 9758ebd49905..43b03b19731b 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -215,6 +215,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
215 data->res.fattr = &data->fattr; 215 data->res.fattr = &data->fattr;
216 data->res.count = count; 216 data->res.count = count;
217 data->res.eof = 0; 217 data->res.eof = 0;
218 nfs_fattr_init(&data->fattr);
218 219
219 NFS_PROTO(inode)->read_setup(data); 220 NFS_PROTO(inode)->read_setup(data);
220 221
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 5130eda231d7..819a65f5071f 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -870,6 +870,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
870 data->res.fattr = &data->fattr; 870 data->res.fattr = &data->fattr;
871 data->res.count = count; 871 data->res.count = count;
872 data->res.verf = &data->verf; 872 data->res.verf = &data->verf;
873 nfs_fattr_init(&data->fattr);
873 874
874 NFS_PROTO(inode)->write_setup(data, how); 875 NFS_PROTO(inode)->write_setup(data, how);
875 876
@@ -1237,6 +1238,7 @@ static void nfs_commit_rpcsetup(struct list_head *head,
1237 data->res.count = 0; 1238 data->res.count = 0;
1238 data->res.fattr = &data->fattr; 1239 data->res.fattr = &data->fattr;
1239 data->res.verf = &data->verf; 1240 data->res.verf = &data->verf;
1241 nfs_fattr_init(&data->fattr);
1240 1242
1241 NFS_PROTO(inode)->commit_setup(data, how); 1243 NFS_PROTO(inode)->commit_setup(data, how);
1242 1244
diff --git a/fs/open.c b/fs/open.c
index f0d90cf0495c..8d06ec911fd9 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -739,7 +739,8 @@ asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
739} 739}
740 740
741static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, 741static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
742 int flags, struct file *f) 742 int flags, struct file *f,
743 int (*open)(struct inode *, struct file *))
743{ 744{
744 struct inode *inode; 745 struct inode *inode;
745 int error; 746 int error;
@@ -761,11 +762,14 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
761 f->f_op = fops_get(inode->i_fop); 762 f->f_op = fops_get(inode->i_fop);
762 file_move(f, &inode->i_sb->s_files); 763 file_move(f, &inode->i_sb->s_files);
763 764
764 if (f->f_op && f->f_op->open) { 765 if (!open && f->f_op)
765 error = f->f_op->open(inode,f); 766 open = f->f_op->open;
767 if (open) {
768 error = open(inode, f);
766 if (error) 769 if (error)
767 goto cleanup_all; 770 goto cleanup_all;
768 } 771 }
772
769 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); 773 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
770 774
771 file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); 775 file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
@@ -814,28 +818,75 @@ struct file *filp_open(const char * filename, int flags, int mode)
814{ 818{
815 int namei_flags, error; 819 int namei_flags, error;
816 struct nameidata nd; 820 struct nameidata nd;
817 struct file *f;
818 821
819 namei_flags = flags; 822 namei_flags = flags;
820 if ((namei_flags+1) & O_ACCMODE) 823 if ((namei_flags+1) & O_ACCMODE)
821 namei_flags++; 824 namei_flags++;
822 if (namei_flags & O_TRUNC)
823 namei_flags |= 2;
824
825 error = -ENFILE;
826 f = get_empty_filp();
827 if (f == NULL)
828 return ERR_PTR(error);
829 825
830 error = open_namei(filename, namei_flags, mode, &nd); 826 error = open_namei(filename, namei_flags, mode, &nd);
831 if (!error) 827 if (!error)
832 return __dentry_open(nd.dentry, nd.mnt, flags, f); 828 return nameidata_to_filp(&nd, flags);
833 829
834 put_filp(f);
835 return ERR_PTR(error); 830 return ERR_PTR(error);
836} 831}
837EXPORT_SYMBOL(filp_open); 832EXPORT_SYMBOL(filp_open);
838 833
834/**
835 * lookup_instantiate_filp - instantiates the open intent filp
836 * @nd: pointer to nameidata
837 * @dentry: pointer to dentry
838 * @open: open callback
839 *
840 * Helper for filesystems that want to use lookup open intents and pass back
841 * a fully instantiated struct file to the caller.
842 * This function is meant to be called from within a filesystem's
843 * lookup method.
844 * Note that in case of error, nd->intent.open.file is destroyed, but the
845 * path information remains valid.
846 * If the open callback is set to NULL, then the standard f_op->open()
847 * filesystem callback is substituted.
848 */
849struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
850 int (*open)(struct inode *, struct file *))
851{
852 if (IS_ERR(nd->intent.open.file))
853 goto out;
854 if (IS_ERR(dentry))
855 goto out_err;
856 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt),
857 nd->intent.open.flags - 1,
858 nd->intent.open.file,
859 open);
860out:
861 return nd->intent.open.file;
862out_err:
863 release_open_intent(nd);
864 nd->intent.open.file = (struct file *)dentry;
865 goto out;
866}
867EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
868
869/**
870 * nameidata_to_filp - convert a nameidata to an open filp.
871 * @nd: pointer to nameidata
872 * @flags: open flags
873 *
874 * Note that this function destroys the original nameidata
875 */
876struct file *nameidata_to_filp(struct nameidata *nd, int flags)
877{
878 struct file *filp;
879
880 /* Pick up the filp from the open intent */
881 filp = nd->intent.open.file;
882 /* Has the filesystem initialised the file for us? */
883 if (filp->f_dentry == NULL)
884 filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);
885 else
886 path_release(nd);
887 return filp;
888}
889
839struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) 890struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
840{ 891{
841 int error; 892 int error;
@@ -846,7 +897,7 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
846 if (f == NULL) 897 if (f == NULL)
847 return ERR_PTR(error); 898 return ERR_PTR(error);
848 899
849 return __dentry_open(dentry, mnt, flags, f); 900 return __dentry_open(dentry, mnt, flags, f, NULL);
850} 901}
851EXPORT_SYMBOL(dentry_open); 902EXPORT_SYMBOL(dentry_open);
852 903
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 77e178f13162..9c06c5434ec4 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -192,6 +192,7 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
192struct part_attribute { 192struct part_attribute {
193 struct attribute attr; 193 struct attribute attr;
194 ssize_t (*show)(struct hd_struct *,char *); 194 ssize_t (*show)(struct hd_struct *,char *);
195 ssize_t (*store)(struct hd_struct *,const char *, size_t);
195}; 196};
196 197
197static ssize_t 198static ssize_t
@@ -201,14 +202,33 @@ part_attr_show(struct kobject * kobj, struct attribute * attr, char * page)
201 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr); 202 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
202 ssize_t ret = 0; 203 ssize_t ret = 0;
203 if (part_attr->show) 204 if (part_attr->show)
204 ret = part_attr->show(p,page); 205 ret = part_attr->show(p, page);
206 return ret;
207}
208static ssize_t
209part_attr_store(struct kobject * kobj, struct attribute * attr,
210 const char *page, size_t count)
211{
212 struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
213 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
214 ssize_t ret = 0;
215
216 if (part_attr->store)
217 ret = part_attr->store(p, page, count);
205 return ret; 218 return ret;
206} 219}
207 220
208static struct sysfs_ops part_sysfs_ops = { 221static struct sysfs_ops part_sysfs_ops = {
209 .show = part_attr_show, 222 .show = part_attr_show,
223 .store = part_attr_store,
210}; 224};
211 225
226static ssize_t part_uevent_store(struct hd_struct * p,
227 const char *page, size_t count)
228{
229 kobject_hotplug(&p->kobj, KOBJ_ADD);
230 return count;
231}
212static ssize_t part_dev_read(struct hd_struct * p, char *page) 232static ssize_t part_dev_read(struct hd_struct * p, char *page)
213{ 233{
214 struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj); 234 struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj);
@@ -229,6 +249,10 @@ static ssize_t part_stat_read(struct hd_struct * p, char *page)
229 p->reads, (unsigned long long)p->read_sectors, 249 p->reads, (unsigned long long)p->read_sectors,
230 p->writes, (unsigned long long)p->write_sectors); 250 p->writes, (unsigned long long)p->write_sectors);
231} 251}
252static struct part_attribute part_attr_uevent = {
253 .attr = {.name = "uevent", .mode = S_IWUSR },
254 .store = part_uevent_store
255};
232static struct part_attribute part_attr_dev = { 256static struct part_attribute part_attr_dev = {
233 .attr = {.name = "dev", .mode = S_IRUGO }, 257 .attr = {.name = "dev", .mode = S_IRUGO },
234 .show = part_dev_read 258 .show = part_dev_read
@@ -247,6 +271,7 @@ static struct part_attribute part_attr_stat = {
247}; 271};
248 272
249static struct attribute * default_attrs[] = { 273static struct attribute * default_attrs[] = {
274 &part_attr_uevent.attr,
250 &part_attr_dev.attr, 275 &part_attr_dev.attr,
251 &part_attr_start.attr, 276 &part_attr_start.attr,
252 &part_attr_size.attr, 277 &part_attr_size.attr,
@@ -430,7 +455,7 @@ void del_gendisk(struct gendisk *disk)
430 disk->flags &= ~GENHD_FL_UP; 455 disk->flags &= ~GENHD_FL_UP;
431 unlink_gendisk(disk); 456 unlink_gendisk(disk);
432 disk_stat_set_all(disk, 0); 457 disk_stat_set_all(disk, 0);
433 disk->stamp = disk->stamp_idle = 0; 458 disk->stamp = 0;
434 459
435 devfs_remove_disk(disk); 460 devfs_remove_disk(disk);
436 461
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index 2706e2adffab..45829889dcdc 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
@@ -2022,7 +2022,7 @@ static int get_neighbors(struct tree_balance *p_s_tb, int n_h)
2022} 2022}
2023 2023
2024#ifdef CONFIG_REISERFS_CHECK 2024#ifdef CONFIG_REISERFS_CHECK
2025void *reiserfs_kmalloc(size_t size, int flags, struct super_block *s) 2025void *reiserfs_kmalloc(size_t size, gfp_t flags, struct super_block *s)
2026{ 2026{
2027 void *vp; 2027 void *vp;
2028 static size_t malloced; 2028 static size_t malloced;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index d76ee6c4f9b8..5f82352b97e1 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2842,7 +2842,7 @@ static int reiserfs_set_page_dirty(struct page *page)
2842 * even in -o notail mode, we can't be sure an old mount without -o notail 2842 * even in -o notail mode, we can't be sure an old mount without -o notail
2843 * didn't create files with tails. 2843 * didn't create files with tails.
2844 */ 2844 */
2845static int reiserfs_releasepage(struct page *page, int unused_gfp_flags) 2845static int reiserfs_releasepage(struct page *page, gfp_t unused_gfp_flags)
2846{ 2846{
2847 struct inode *inode = page->mapping->host; 2847 struct inode *inode = page->mapping->host;
2848 struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb); 2848 struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 87ac9dc8b381..72e120798677 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -453,7 +453,7 @@ static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
453 struct page *page; 453 struct page *page;
454 /* We can deadlock if we try to free dentries, 454 /* We can deadlock if we try to free dentries,
455 and an unlink/rmdir has just occured - GFP_NOFS avoids this */ 455 and an unlink/rmdir has just occured - GFP_NOFS avoids this */
456 mapping->flags = (mapping->flags & ~__GFP_BITS_MASK) | GFP_NOFS; 456 mapping_set_gfp_mask(mapping, GFP_NOFS);
457 page = read_cache_page(mapping, n, 457 page = read_cache_page(mapping, n,
458 (filler_t *) mapping->a_ops->readpage, NULL); 458 (filler_t *) mapping->a_ops->readpage, NULL);
459 if (!IS_ERR(page)) { 459 if (!IS_ERR(page)) {
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index d2653b589b1c..3c92162dc728 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -45,11 +45,11 @@
45 45
46 46
47void * 47void *
48kmem_alloc(size_t size, gfp_t flags) 48kmem_alloc(size_t size, unsigned int __nocast flags)
49{ 49{
50 int retries = 0; 50 int retries = 0;
51 unsigned int lflags = kmem_flags_convert(flags); 51 gfp_t lflags = kmem_flags_convert(flags);
52 void *ptr; 52 void *ptr;
53 53
54 do { 54 do {
55 if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS) 55 if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS)
@@ -67,7 +67,7 @@ kmem_alloc(size_t size, gfp_t flags)
67} 67}
68 68
69void * 69void *
70kmem_zalloc(size_t size, gfp_t flags) 70kmem_zalloc(size_t size, unsigned int __nocast flags)
71{ 71{
72 void *ptr; 72 void *ptr;
73 73
@@ -90,7 +90,7 @@ kmem_free(void *ptr, size_t size)
90 90
91void * 91void *
92kmem_realloc(void *ptr, size_t newsize, size_t oldsize, 92kmem_realloc(void *ptr, size_t newsize, size_t oldsize,
93 gfp_t flags) 93 unsigned int __nocast flags)
94{ 94{
95 void *new; 95 void *new;
96 96
@@ -105,11 +105,11 @@ kmem_realloc(void *ptr, size_t newsize, size_t oldsize,
105} 105}
106 106
107void * 107void *
108kmem_zone_alloc(kmem_zone_t *zone, gfp_t flags) 108kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
109{ 109{
110 int retries = 0; 110 int retries = 0;
111 unsigned int lflags = kmem_flags_convert(flags); 111 gfp_t lflags = kmem_flags_convert(flags);
112 void *ptr; 112 void *ptr;
113 113
114 do { 114 do {
115 ptr = kmem_cache_alloc(zone, lflags); 115 ptr = kmem_cache_alloc(zone, lflags);
@@ -124,7 +124,7 @@ kmem_zone_alloc(kmem_zone_t *zone, gfp_t flags)
124} 124}
125 125
126void * 126void *
127kmem_zone_zalloc(kmem_zone_t *zone, gfp_t flags) 127kmem_zone_zalloc(kmem_zone_t *zone, unsigned int __nocast flags)
128{ 128{
129 void *ptr; 129 void *ptr;
130 130
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index ee7010f085bc..f4bb78c268c0 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -81,9 +81,9 @@ typedef unsigned long xfs_pflags_t;
81 *(NSTATEP) = *(OSTATEP); \ 81 *(NSTATEP) = *(OSTATEP); \
82} while (0) 82} while (0)
83 83
84static __inline unsigned int kmem_flags_convert(gfp_t flags) 84static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
85{ 85{
86 unsigned int lflags = __GFP_NOWARN; /* we'll report problems, if need be */ 86 gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */
87 87
88#ifdef DEBUG 88#ifdef DEBUG
89 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { 89 if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
@@ -125,16 +125,16 @@ kmem_zone_destroy(kmem_zone_t *zone)
125 BUG(); 125 BUG();
126} 126}
127 127
128extern void *kmem_zone_zalloc(kmem_zone_t *, gfp_t); 128extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
129extern void *kmem_zone_alloc(kmem_zone_t *, gfp_t); 129extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
130 130
131extern void *kmem_alloc(size_t, gfp_t); 131extern void *kmem_alloc(size_t, unsigned int __nocast);
132extern void *kmem_realloc(void *, size_t, size_t, gfp_t); 132extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
133extern void *kmem_zalloc(size_t, gfp_t); 133extern void *kmem_zalloc(size_t, unsigned int __nocast);
134extern void kmem_free(void *, size_t); 134extern void kmem_free(void *, size_t);
135 135
136typedef struct shrinker *kmem_shaker_t; 136typedef struct shrinker *kmem_shaker_t;
137typedef int (*kmem_shake_func_t)(int, unsigned int); 137typedef int (*kmem_shake_func_t)(int, gfp_t);
138 138
139static __inline kmem_shaker_t 139static __inline kmem_shaker_t
140kmem_shake_register(kmem_shake_func_t sfunc) 140kmem_shake_register(kmem_shake_func_t sfunc)
@@ -149,7 +149,7 @@ kmem_shake_deregister(kmem_shaker_t shrinker)
149} 149}
150 150
151static __inline int 151static __inline int
152kmem_shake_allow(unsigned int gfp_mask) 152kmem_shake_allow(gfp_t gfp_mask)
153{ 153{
154 return (gfp_mask & __GFP_WAIT); 154 return (gfp_mask & __GFP_WAIT);
155} 155}
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index c6c077978fe3..7aa398724706 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -1296,7 +1296,7 @@ linvfs_invalidate_page(
1296STATIC int 1296STATIC int
1297linvfs_release_page( 1297linvfs_release_page(
1298 struct page *page, 1298 struct page *page,
1299 int gfp_mask) 1299 gfp_t gfp_mask)
1300{ 1300{
1301 struct inode *inode = page->mapping->host; 1301 struct inode *inode = page->mapping->host;
1302 int dirty, delalloc, unmapped, unwritten; 1302 int dirty, delalloc, unmapped, unwritten;
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index e82cf72ac599..ba4767c04adf 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -64,7 +64,7 @@
64 64
65STATIC kmem_cache_t *pagebuf_zone; 65STATIC kmem_cache_t *pagebuf_zone;
66STATIC kmem_shaker_t pagebuf_shake; 66STATIC kmem_shaker_t pagebuf_shake;
67STATIC int xfsbufd_wakeup(int, unsigned int); 67STATIC int xfsbufd_wakeup(int, gfp_t);
68STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); 68STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
69 69
70STATIC struct workqueue_struct *xfslogd_workqueue; 70STATIC struct workqueue_struct *xfslogd_workqueue;
@@ -383,7 +383,7 @@ _pagebuf_lookup_pages(
383 size_t blocksize = bp->pb_target->pbr_bsize; 383 size_t blocksize = bp->pb_target->pbr_bsize;
384 size_t size = bp->pb_count_desired; 384 size_t size = bp->pb_count_desired;
385 size_t nbytes, offset; 385 size_t nbytes, offset;
386 int gfp_mask = pb_to_gfp(flags); 386 gfp_t gfp_mask = pb_to_gfp(flags);
387 unsigned short page_count, i; 387 unsigned short page_count, i;
388 pgoff_t first; 388 pgoff_t first;
389 loff_t end; 389 loff_t end;
@@ -1749,8 +1749,8 @@ STATIC int xfsbufd_force_sleep;
1749 1749
1750STATIC int 1750STATIC int
1751xfsbufd_wakeup( 1751xfsbufd_wakeup(
1752 int priority, 1752 int priority,
1753 unsigned int mask) 1753 gfp_t mask)
1754{ 1754{
1755 if (xfsbufd_force_sleep) 1755 if (xfsbufd_force_sleep)
1756 return 0; 1756 return 0;
diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h
index c675f282d6ad..680f7ecbb28f 100644
--- a/include/asm-alpha/dma-mapping.h
+++ b/include/asm-alpha/dma-mapping.h
@@ -31,7 +31,7 @@
31#else /* no PCI - no IOMMU. */ 31#else /* no PCI - no IOMMU. */
32 32
33void *dma_alloc_coherent(struct device *dev, size_t size, 33void *dma_alloc_coherent(struct device *dev, size_t size,
34 dma_addr_t *dma_handle, int gfp); 34 dma_addr_t *dma_handle, gfp_t gfp);
35int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 35int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
36 enum dma_data_direction direction); 36 enum dma_data_direction direction);
37 37
diff --git a/include/asm-arm/arch-aaec2000/aaec2000.h b/include/asm-arm/arch-aaec2000/aaec2000.h
index 0e9b7e18af05..002227924b9f 100644
--- a/include/asm-arm/arch-aaec2000/aaec2000.h
+++ b/include/asm-arm/arch-aaec2000/aaec2000.h
@@ -17,6 +17,16 @@
17#error You must include hardware.h not this file 17#error You must include hardware.h not this file
18#endif /* __ASM_ARCH_HARDWARE_H */ 18#endif /* __ASM_ARCH_HARDWARE_H */
19 19
20/* Chip selects */
21#define AAEC_CS0 0x00000000
22#define AAEC_CS1 0x10000000
23#define AAEC_CS2 0x20000000
24#define AAEC_CS3 0x30000000
25
26/* Flash */
27#define AAEC_FLASH_BASE AAEC_CS0
28#define AAEC_FLASH_SIZE SZ_64M
29
20/* Interrupt controller */ 30/* Interrupt controller */
21#define IRQ_BASE __REG(0x80000500) 31#define IRQ_BASE __REG(0x80000500)
22#define IRQ_INTSR __REG(0x80000500) /* Int Status Register */ 32#define IRQ_INTSR __REG(0x80000500) /* Int Status Register */
@@ -148,4 +158,50 @@
148#define POWER_STFCLR __REG(0x8000041c) /* NbFlg, RSTFlg, PFFlg, CLDFlg Clear */ 158#define POWER_STFCLR __REG(0x8000041c) /* NbFlg, RSTFlg, PFFlg, CLDFlg Clear */
149#define POWER_CLKSET __REG(0x80000420) /* Clock Speed Control */ 159#define POWER_CLKSET __REG(0x80000420) /* Clock Speed Control */
150 160
161/* GPIO Registers */
162#define AAEC_GPIO_PHYS 0x80000e00
163
164#define AAEC_GPIO_PADR __REG(AAEC_GPIO_PHYS + 0x00)
165#define AAEC_GPIO_PBDR __REG(AAEC_GPIO_PHYS + 0x04)
166#define AAEC_GPIO_PCDR __REG(AAEC_GPIO_PHYS + 0x08)
167#define AAEC_GPIO_PDDR __REG(AAEC_GPIO_PHYS + 0x0c)
168#define AAEC_GPIO_PADDR __REG(AAEC_GPIO_PHYS + 0x10)
169#define AAEC_GPIO_PBDDR __REG(AAEC_GPIO_PHYS + 0x14)
170#define AAEC_GPIO_PCDDR __REG(AAEC_GPIO_PHYS + 0x18)
171#define AAEC_GPIO_PDDDR __REG(AAEC_GPIO_PHYS + 0x1c)
172#define AAEC_GPIO_PEDR __REG(AAEC_GPIO_PHYS + 0x20)
173#define AAEC_GPIO_PEDDR __REG(AAEC_GPIO_PHYS + 0x24)
174#define AAEC_GPIO_KSCAN __REG(AAEC_GPIO_PHYS + 0x28)
175#define AAEC_GPIO_PINMUX __REG(AAEC_GPIO_PHYS + 0x2c)
176#define AAEC_GPIO_PFDR __REG(AAEC_GPIO_PHYS + 0x30)
177#define AAEC_GPIO_PFDDR __REG(AAEC_GPIO_PHYS + 0x34)
178#define AAEC_GPIO_PGDR __REG(AAEC_GPIO_PHYS + 0x38)
179#define AAEC_GPIO_PGDDR __REG(AAEC_GPIO_PHYS + 0x3c)
180#define AAEC_GPIO_PHDR __REG(AAEC_GPIO_PHYS + 0x40)
181#define AAEC_GPIO_PHDDR __REG(AAEC_GPIO_PHYS + 0x44)
182#define AAEC_GPIO_RAZ __REG(AAEC_GPIO_PHYS + 0x48)
183#define AAEC_GPIO_INTTYPE1 __REG(AAEC_GPIO_PHYS + 0x4c)
184#define AAEC_GPIO_INTTYPE2 __REG(AAEC_GPIO_PHYS + 0x50)
185#define AAEC_GPIO_FEOI __REG(AAEC_GPIO_PHYS + 0x54)
186#define AAEC_GPIO_INTEN __REG(AAEC_GPIO_PHYS + 0x58)
187#define AAEC_GPIO_INTSTATUS __REG(AAEC_GPIO_PHYS + 0x5c)
188#define AAEC_GPIO_RAWINTSTATUS __REG(AAEC_GPIO_PHYS + 0x60)
189#define AAEC_GPIO_DB __REG(AAEC_GPIO_PHYS + 0x64)
190#define AAEC_GPIO_PAPINDR __REG(AAEC_GPIO_PHYS + 0x68)
191#define AAEC_GPIO_PBPINDR __REG(AAEC_GPIO_PHYS + 0x6c)
192#define AAEC_GPIO_PCPINDR __REG(AAEC_GPIO_PHYS + 0x70)
193#define AAEC_GPIO_PDPINDR __REG(AAEC_GPIO_PHYS + 0x74)
194#define AAEC_GPIO_PEPINDR __REG(AAEC_GPIO_PHYS + 0x78)
195#define AAEC_GPIO_PFPINDR __REG(AAEC_GPIO_PHYS + 0x7c)
196#define AAEC_GPIO_PGPINDR __REG(AAEC_GPIO_PHYS + 0x80)
197#define AAEC_GPIO_PHPINDR __REG(AAEC_GPIO_PHYS + 0x84)
198
199#define AAEC_GPIO_PINMUX_PE0CON (1 << 0)
200#define AAEC_GPIO_PINMUX_PD0CON (1 << 1)
201#define AAEC_GPIO_PINMUX_CODECON (1 << 2)
202#define AAEC_GPIO_PINMUX_UART3CON (1 << 3)
203
204/* LCD Controller */
205#define AAEC_CLCD_PHYS 0x80003000
206
151#endif /* __ARM_ARCH_AAEC2000_H */ 207#endif /* __ARM_ARCH_AAEC2000_H */
diff --git a/include/asm-arm/arch-aaec2000/aaed2000.h b/include/asm-arm/arch-aaec2000/aaed2000.h
new file mode 100644
index 000000000000..bc76d2badb91
--- /dev/null
+++ b/include/asm-arm/arch-aaec2000/aaed2000.h
@@ -0,0 +1,40 @@
1/*
2 * linux/include/asm-arm/arch-aaec2000/aaed2000.h
3 *
4 * AAED-2000 specific bits definition
5 *
6 * Copyright (c) 2005 Nicolas Bellido Y Ortega
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __ASM_ARCH_AAED2000_H
14#define __ASM_ARCH_AAED2000_H
15
16/* External GPIOs. */
17
18#define EXT_GPIO_PBASE AAEC_CS3
19#define EXT_GPIO_VBASE 0xf8100000
20#define EXT_GPIO_LENGTH 0x00001000
21
22#define __ext_gpio_p2v(x) ((x) - EXT_GPIO_PBASE + EXT_GPIO_VBASE)
23#define __ext_gpio_v2p(x) ((x) + EXT_GPIO_PBASE - EXT_GPIO_VBASE)
24
25#define __EXT_GPIO_REG(x) (*((volatile u32 *)__ext_gpio_p2v(x)))
26#define __EXT_GPIO_PREG(x) (__ext_gpio_v2p((u32)&(x)))
27
28#define AAED_EXT_GPIO __EXT_GPIO_REG(EXT_GPIO_PBASE)
29
30#define AAED_EGPIO_KBD_SCAN 0x00003fff /* Keyboard scan data */
31#define AAED_EGPIO_PWR_INT 0x00008fff /* Smart battery charger interrupt */
32#define AAED_EGPIO_SWITCHED 0x000f0000 /* DIP Switches */
33#define AAED_EGPIO_USB_VBUS 0x00400000 /* USB Vbus sense */
34#define AAED_EGPIO_LCD_PWR_EN 0x02000000 /* LCD and backlight PWR enable */
35#define AAED_EGPIO_nLED0 0x20000000 /* LED 0 */
36#define AAED_EGPIO_nLED1 0x20000000 /* LED 1 */
37#define AAED_EGPIO_nLED2 0x20000000 /* LED 2 */
38
39
40#endif /* __ARM_ARCH_AAED2000_H */
diff --git a/include/asm-arm/arch-aaec2000/hardware.h b/include/asm-arm/arch-aaec2000/hardware.h
index 4c37219e030e..153506fd06ed 100644
--- a/include/asm-arm/arch-aaec2000/hardware.h
+++ b/include/asm-arm/arch-aaec2000/hardware.h
@@ -11,7 +11,8 @@
11#ifndef __ASM_ARCH_HARDWARE_H 11#ifndef __ASM_ARCH_HARDWARE_H
12#define __ASM_ARCH_HARDWARE_H 12#define __ASM_ARCH_HARDWARE_H
13 13
14#include <linux/config.h> 14#include <asm/sizes.h>
15#include <asm/arch/aaec2000.h>
15 16
16/* The kernel is loaded at physical address 0xf8000000. 17/* The kernel is loaded at physical address 0xf8000000.
17 * We map the IO space a bit after 18 * We map the IO space a bit after
diff --git a/include/asm-arm/arch-aaec2000/io.h b/include/asm-arm/arch-aaec2000/io.h
index c58a8d10425a..8d67907fd4f0 100644
--- a/include/asm-arm/arch-aaec2000/io.h
+++ b/include/asm-arm/arch-aaec2000/io.h
@@ -6,6 +6,8 @@
6#ifndef __ASM_ARM_ARCH_IO_H 6#ifndef __ASM_ARM_ARCH_IO_H
7#define __ASM_ARM_ARCH_IO_H 7#define __ASM_ARM_ARCH_IO_H
8 8
9#include <asm/hardware.h>
10
9#define IO_SPACE_LIMIT 0xffffffff 11#define IO_SPACE_LIMIT 0xffffffff
10 12
11/* 13/*
diff --git a/include/asm-arm/arch-cl7500/io.h b/include/asm-arm/arch-cl7500/io.h
index f0113bc75630..89a33287f4fe 100644
--- a/include/asm-arm/arch-cl7500/io.h
+++ b/include/asm-arm/arch-cl7500/io.h
@@ -10,6 +10,8 @@
10#ifndef __ASM_ARM_ARCH_IO_H 10#ifndef __ASM_ARM_ARCH_IO_H
11#define __ASM_ARM_ARCH_IO_H 11#define __ASM_ARM_ARCH_IO_H
12 12
13#include <asm/hardware.h>
14
13#define IO_SPACE_LIMIT 0xffffffff 15#define IO_SPACE_LIMIT 0xffffffff
14 16
15/* 17/*
diff --git a/include/asm-arm/arch-clps711x/hardware.h b/include/asm-arm/arch-clps711x/hardware.h
index 1386871e1a5a..f864c367c934 100644
--- a/include/asm-arm/arch-clps711x/hardware.h
+++ b/include/asm-arm/arch-clps711x/hardware.h
@@ -235,4 +235,121 @@
235#define CEIVA_PB0_BLK_BTN (1<<0) 235#define CEIVA_PB0_BLK_BTN (1<<0)
236#endif // #if defined (CONFIG_ARCH_CEIVA) 236#endif // #if defined (CONFIG_ARCH_CEIVA)
237 237
238#if defined (CONFIG_MACH_MP1000)
239/* NOR FLASH */
240#define MP1000_NIO_BASE 0xf9000000 /* virtual */
241#define MP1000_NIO_START CS0_PHYS_BASE /* physical */
242#define MP1000_NIO_SIZE 0x00400000
243
244/* DSP Interface */
245#define MP1000_DSP_BASE 0xfa000000 /* virtual */
246#define MP1000_DSP_START CS1_PHYS_BASE /* physical */
247#define MP1000_DSP_SIZE 0x00100000
248
249/* LCD, DAA/DSP, RTC, DAA RW Reg all in CS2 */
250#define MP1000_LIO_BASE 0xfb000000 /* virtual */
251#define MP1000_LIO_START CS2_PHYS_BASE /* physical */
252#define MP1000_LIO_SIZE 0x00100000
253
254/* NAND FLASH */
255#define MP1000_FIO_BASE 0xfc000000 /* virtual */
256#define MP1000_FIO_START CS3_PHYS_BASE /* physical */
257#define MP1000_FIO_SIZE 0x00800000
258
259/* Ethernet */
260#define MP1000_EIO_BASE 0xfd000000 /* virtual */
261#define MP1000_EIO_START CS4_PHYS_BASE /* physical */
262#define MP1000_EIO_SIZE 0x00100000
263
264#define MP1000_LCD_OFFSET 0x00000000 /* LCD offset in CS2 */
265#define MP1000_DDD_OFFSET 0x00001000 /* DAA/DAI/DSP sft reset offst*/
266#define MP1000_RTC_OFFSET 0x00002000 /* RTC offset in CS2 */
267#define MP1000_DAA_OFFSET 0x00003000 /* DAA RW reg offset in CS2 */
268
269/* IDE */
270#define MP1000_IDE_BASE 0xfe000000 /* virtual */
271#define MP1000_IDE_START CS5_PHYS_BASE /* physical */
272#define MP1000_IDE_SIZE 0x00100000 /* actually it's only 0x1000 */
273
274#define IRQ_HARDDISK IRQ_EINT2
275
276/*
277 * IDE registers definition
278 */
279
280#define IDE_CONTROL_BASE (MP1000_IDE_BASE + 0x1000)
281#define IDE_BASE_OFF (MP1000_IDE_BASE)
282
283#define IDE_WRITE_DEVICE_DATA (IDE_BASE_OFF + 0x0)
284#define IDE_FEATURES_REGISTER (IDE_BASE_OFF + 0x2)
285#define IDE_SECTOR_COUNT_REGISTER (IDE_BASE_OFF + 0x4)
286#define IDE_SECTOR_NUMBER_REGISTER (IDE_BASE_OFF + 0x6)
287#define IDE_CYLINDER_LOW_REGISTER (IDE_BASE_OFF + 0x8)
288#define IDE_CYLINDER_HIGH_REGISTER (IDE_BASE_OFF + 0xa)
289#define IDE_DEVICE_HEAD_REGISTER (IDE_BASE_OFF + 0xc)
290#define IDE_COMMAND_DATA_REGISTER (IDE_BASE_OFF + 0xe)
291#define IDE_DEVICE_CONTROL_REGISTER (IDE_CONTROL_BASE + 0xc)
292
293#define IDE_IRQ IRQ_EINT2
294
295
296#define RTC_PORT(x) (MP1000_LIO_BASE+0x2000 + (x*2))
297#define RTC_ALWAYS_BCD 0
298
299/*
300// Definitions of the bit fields in the HwPortA register for the
301// MP1000 board.
302*/
303#define HwPortAKeyboardRow1 0x00000001
304#define HwPortAKeyboardRow2 0x00000002
305#define HwPortAKeyboardRow3 0x00000004
306#define HwPortAKeyboardRow4 0x00000008
307#define HwPortAKeyboardRow5 0x00000010
308#define HwPortAKeyboardRow6 0x00000020
309#define HwPortALCDEnable 0x00000040
310#define HwPortAOffhook 0x00000080
311
312/*
313// Definitions of the bit fields in the HwPortB register for the
314// MP1000 board.
315*/
316#define HwPortBL3Mode 0x00000001
317#define HwPortBL3Clk 0x00000002
318#define HwPortBSClk 0x00000001
319#define HwPortBSData 0x00000002
320#define HwPortBL3Data 0x00000004
321#define HwPortBMute 0x00000008
322#define HwPortBQD0 0x00000010
323#define HwPortBQD1 0x00000020
324#define HwPortBQD2 0x00000040
325#define HwPortBQD3 0x00000080
326
327/*
328// Definitions of the bit fields in the HwPortD register for the
329// MP1000 board.
330*/
331#define HwPortDLED1 0x00000001
332#define HwPortDLED2 0x00000002
333#define HwPortDLED3 0x00000004
334#define HwPortDLED4 0x00000008
335#define HwPortDLED5 0x00000010
336#define HwPortDEECS 0x00000020
337#define HwPortBRTS 0x00000040
338#define HwPortBRI 0x00000080
339
340
341/*
342// Definitions of the bit fields in the HwPortE register for the
343// MP1000 board.
344*/
345
346#define HwPortECLE 0x00000001
347#define HwPortESepromDOut 0x00000001
348#define HwPortEALE 0x00000002
349#define HwPortESepromDIn 0x00000002
350#define HwPortENANDCS 0x00000004
351#define HwPortESepromCLK 0x00000004
352
353#endif // #if defined (CONFIG_MACH_MP1000)
354
238#endif 355#endif
diff --git a/include/asm-arm/arch-clps711x/io.h b/include/asm-arm/arch-clps711x/io.h
index 14d7e8da5453..62613b0e2d96 100644
--- a/include/asm-arm/arch-clps711x/io.h
+++ b/include/asm-arm/arch-clps711x/io.h
@@ -20,6 +20,8 @@
20#ifndef __ASM_ARM_ARCH_IO_H 20#ifndef __ASM_ARM_ARCH_IO_H
21#define __ASM_ARM_ARCH_IO_H 21#define __ASM_ARM_ARCH_IO_H
22 22
23#include <asm/hardware.h>
24
23#define IO_SPACE_LIMIT 0xffffffff 25#define IO_SPACE_LIMIT 0xffffffff
24 26
25#define __io(a) ((void __iomem *)(a)) 27#define __io(a) ((void __iomem *)(a))
diff --git a/include/asm-arm/arch-clps711x/mp1000-seprom.h b/include/asm-arm/arch-clps711x/mp1000-seprom.h
new file mode 100644
index 000000000000..3e5566cf9666
--- /dev/null
+++ b/include/asm-arm/arch-clps711x/mp1000-seprom.h
@@ -0,0 +1,77 @@
1#ifndef MP1000_SEPROM_H
2#define MP1000_SEPROM_H
3
4/*
5 * mp1000-seprom.h
6 *
7 *
8 * This file contains the Serial EEPROM definitions for the MP1000 board
9 *
10 * Copyright (C) 2005 Comdial Corporation
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28#define COMMAND_ERASE (0x1C0)
29#define COMMAND_ERASE_ALL (0x120)
30#define COMMAND_WRITE_DISABLE (0x100)
31#define COMMAND_WRITE_ENABLE (0x130)
32#define COMMAND_READ (0x180)
33#define COMMAND_WRITE (0x140)
34#define COMMAND_WRITE_ALL (0x110)
35
36//
37// Serial EEPROM data format
38//
39
40#define PACKED __attribute__ ((packed))
41
42typedef struct _EEPROM {
43 union {
44 unsigned char eprom_byte_data[128];
45 unsigned short eprom_short_data[64];
46 struct {
47 unsigned char version PACKED; // EEPROM Version "1" for now
48 unsigned char box_id PACKED; // Box ID (Standalone, SOHO, embedded, etc)
49 unsigned char major_hw_version PACKED; // Major Hardware version (Hex)
50 unsigned char minor_hw_version PACKED; // Minor Hardware Version (Hex)
51 unsigned char mfg_id[3] PACKED; // Manufacturer ID (3 character Alphabetic)
52 unsigned char mfg_serial_number[10] PACKED; // Manufacturer Serial number
53 unsigned char mfg_date[3] PACKED; // Date of Mfg (Formatted YY:MM:DD)
54 unsigned char country PACKED; // Country of deployment
55 unsigned char mac_Address[6] PACKED; // MAC Address
56 unsigned char oem_string[20] PACKED; // OEM ID string
57 unsigned short feature_bits1 PACKED; // Feature Bits 1
58 unsigned short feature_bits2 PACKED; // Feature Bits 2
59 unsigned char filler[75] PACKED; // Unused/Undefined “0” initialized
60 unsigned short checksum PACKED; // byte accumulated short checksum
61 } eprom_struct;
62 } variant;
63} eeprom_struct;
64
65/* These settings must be mutually exclusive */
66#define FEATURE_BITS1_DRAMSIZE_16MEG 0x0001 /* 0 signifies 4 MEG system */
67#define FEATURE_BITS1_DRAMSIZE_8MEG 0x0002 /* 1 in bit 1 = 8MEG system */
68#define FEATURE_BITS1_DRAMSIZE_64MEG 0x0004 /* 1 in bit 2 = 64MEG system */
69
70#define FEATURE_BITS1_CPUIS90MEG 0x0010
71
72extern void seprom_init(void);
73extern eeprom_struct* get_seprom_ptr(void);
74extern unsigned char* get_eeprom_mac_address(void);
75
76#endif /* MP1000_SEPROM_H */
77
diff --git a/include/asm-arm/arch-ebsa285/io.h b/include/asm-arm/arch-ebsa285/io.h
index 70576b17f922..776f9d377057 100644
--- a/include/asm-arm/arch-ebsa285/io.h
+++ b/include/asm-arm/arch-ebsa285/io.h
@@ -14,6 +14,8 @@
14#ifndef __ASM_ARM_ARCH_IO_H 14#ifndef __ASM_ARM_ARCH_IO_H
15#define __ASM_ARM_ARCH_IO_H 15#define __ASM_ARM_ARCH_IO_H
16 16
17#include <asm/hardware.h>
18
17#define IO_SPACE_LIMIT 0xffff 19#define IO_SPACE_LIMIT 0xffff
18 20
19/* 21/*
diff --git a/include/asm-arm/arch-epxa10db/io.h b/include/asm-arm/arch-epxa10db/io.h
index 1f0afa257621..9fe100c9d6be 100644
--- a/include/asm-arm/arch-epxa10db/io.h
+++ b/include/asm-arm/arch-epxa10db/io.h
@@ -20,6 +20,8 @@
20#ifndef __ASM_ARM_ARCH_IO_H 20#ifndef __ASM_ARM_ARCH_IO_H
21#define __ASM_ARM_ARCH_IO_H 21#define __ASM_ARM_ARCH_IO_H
22 22
23#include <asm/hardware.h>
24
23#define IO_SPACE_LIMIT 0xffff 25#define IO_SPACE_LIMIT 0xffff
24 26
25 27
diff --git a/include/asm-arm/arch-h720x/io.h b/include/asm-arm/arch-h720x/io.h
index 68814828c9a7..d3ccfd8172b7 100644
--- a/include/asm-arm/arch-h720x/io.h
+++ b/include/asm-arm/arch-h720x/io.h
@@ -14,7 +14,7 @@
14#ifndef __ASM_ARM_ARCH_IO_H 14#ifndef __ASM_ARM_ARCH_IO_H
15#define __ASM_ARM_ARCH_IO_H 15#define __ASM_ARM_ARCH_IO_H
16 16
17#include <asm/arch/hardware.h> 17#include <asm/hardware.h>
18 18
19#define IO_SPACE_LIMIT 0xffffffff 19#define IO_SPACE_LIMIT 0xffffffff
20 20
diff --git a/include/asm-arm/arch-imx/io.h b/include/asm-arm/arch-imx/io.h
index 28a4cca6a4cb..b191cdd05576 100644
--- a/include/asm-arm/arch-imx/io.h
+++ b/include/asm-arm/arch-imx/io.h
@@ -20,6 +20,8 @@
20#ifndef __ASM_ARM_ARCH_IO_H 20#ifndef __ASM_ARM_ARCH_IO_H
21#define __ASM_ARM_ARCH_IO_H 21#define __ASM_ARM_ARCH_IO_H
22 22
23#include <asm/hardware.h>
24
23#define IO_SPACE_LIMIT 0xffffffff 25#define IO_SPACE_LIMIT 0xffffffff
24 26
25#define __io(a) ((void __iomem *)(a)) 27#define __io(a) ((void __iomem *)(a))
diff --git a/include/asm-arm/arch-integrator/hardware.h b/include/asm-arm/arch-integrator/hardware.h
index be2716eeaa02..6f0947bc500d 100644
--- a/include/asm-arm/arch-integrator/hardware.h
+++ b/include/asm-arm/arch-integrator/hardware.h
@@ -33,15 +33,6 @@
33#define IO_SIZE 0x0B000000 // How much? 33#define IO_SIZE 0x0B000000 // How much?
34#define IO_START INTEGRATOR_HDR_BASE // PA of IO 34#define IO_START INTEGRATOR_HDR_BASE // PA of IO
35 35
36/*
37 * Similar to above, but for PCI addresses (memory, IO, Config and the
38 * V3 chip itself). WARNING: this has to mirror definitions in platform.h
39 */
40#define PCI_MEMORY_VADDR 0xe8000000
41#define PCI_CONFIG_VADDR 0xec000000
42#define PCI_V3_VADDR 0xed000000
43#define PCI_IO_VADDR 0xee000000
44
45#define PCIO_BASE PCI_IO_VADDR 36#define PCIO_BASE PCI_IO_VADDR
46#define PCIMEM_BASE PCI_MEMORY_VADDR 37#define PCIMEM_BASE PCI_MEMORY_VADDR
47 38
diff --git a/include/asm-arm/arch-integrator/io.h b/include/asm-arm/arch-integrator/io.h
index fbea8be67d26..31f2deab51b0 100644
--- a/include/asm-arm/arch-integrator/io.h
+++ b/include/asm-arm/arch-integrator/io.h
@@ -22,6 +22,14 @@
22 22
23#define IO_SPACE_LIMIT 0xffff 23#define IO_SPACE_LIMIT 0xffff
24 24
25/*
26 * WARNING: this has to mirror definitions in platform.h
27 */
28#define PCI_MEMORY_VADDR 0xe8000000
29#define PCI_CONFIG_VADDR 0xec000000
30#define PCI_V3_VADDR 0xed000000
31#define PCI_IO_VADDR 0xee000000
32
25#define __io(a) ((void __iomem *)(PCI_IO_VADDR + (a))) 33#define __io(a) ((void __iomem *)(PCI_IO_VADDR + (a)))
26#define __mem_pci(a) (a) 34#define __mem_pci(a) (a)
27#define __mem_isa(a) ((a) + PCI_MEMORY_VADDR) 35#define __mem_isa(a) ((a) + PCI_MEMORY_VADDR)
diff --git a/include/asm-arm/arch-iop3xx/io.h b/include/asm-arm/arch-iop3xx/io.h
index 2761dfd8694d..f39046a6ab14 100644
--- a/include/asm-arm/arch-iop3xx/io.h
+++ b/include/asm-arm/arch-iop3xx/io.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_ARM_ARCH_IO_H 11#ifndef __ASM_ARM_ARCH_IO_H
12#define __ASM_ARM_ARCH_IO_H 12#define __ASM_ARM_ARCH_IO_H
13 13
14#include <asm/hardware.h>
15
14#define IO_SPACE_LIMIT 0xffffffff 16#define IO_SPACE_LIMIT 0xffffffff
15 17
16#define __io(p) ((void __iomem *)(p)) 18#define __io(p) ((void __iomem *)(p))
diff --git a/include/asm-arm/arch-ixp2000/io.h b/include/asm-arm/arch-ixp2000/io.h
index 3241cd6f0778..7fbcdf9931ee 100644
--- a/include/asm-arm/arch-ixp2000/io.h
+++ b/include/asm-arm/arch-ixp2000/io.h
@@ -15,6 +15,8 @@
15#ifndef __ASM_ARM_ARCH_IO_H 15#ifndef __ASM_ARM_ARCH_IO_H
16#define __ASM_ARM_ARCH_IO_H 16#define __ASM_ARM_ARCH_IO_H
17 17
18#include <asm/hardware.h>
19
18#define IO_SPACE_LIMIT 0xffffffff 20#define IO_SPACE_LIMIT 0xffffffff
19#define __mem_pci(a) (a) 21#define __mem_pci(a) (a)
20 22
diff --git a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
index 32aece069869..def089d693d2 100644
--- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h
+++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
@@ -392,4 +392,47 @@
392#define WDT_RESET_ENABLE 0x01000000 392#define WDT_RESET_ENABLE 0x01000000
393 393
394 394
395/*
396 * MSF registers. The IXP2400 and IXP2800 have somewhat different MSF
397 * units, but the registers that differ between the two don't overlap,
398 * so we can have one register list for both.
399 */
400#define IXP2000_MSF_REG(x) ((volatile unsigned long*)(IXP2000_MSF_VIRT_BASE + (x)))
401#define IXP2000_MSF_RX_CONTROL IXP2000_MSF_REG(0x0000)
402#define IXP2000_MSF_TX_CONTROL IXP2000_MSF_REG(0x0004)
403#define IXP2000_MSF_INTERRUPT_STATUS IXP2000_MSF_REG(0x0008)
404#define IXP2000_MSF_INTERRUPT_ENABLE IXP2000_MSF_REG(0x000c)
405#define IXP2000_MSF_CSIX_TYPE_MAP IXP2000_MSF_REG(0x0010)
406#define IXP2000_MSF_FC_EGRESS_STATUS IXP2000_MSF_REG(0x0014)
407#define IXP2000_MSF_FC_INGRESS_STATUS IXP2000_MSF_REG(0x0018)
408#define IXP2000_MSF_HWM_CONTROL IXP2000_MSF_REG(0x0024)
409#define IXP2000_MSF_FC_STATUS_OVERRIDE IXP2000_MSF_REG(0x0028)
410#define IXP2000_MSF_CLOCK_CONTROL IXP2000_MSF_REG(0x002c)
411#define IXP2000_MSF_RX_PORT_MAP IXP2000_MSF_REG(0x0040)
412#define IXP2000_MSF_RBUF_ELEMENT_DONE IXP2000_MSF_REG(0x0044)
413#define IXP2000_MSF_RX_MPHY_POLL_LIMIT IXP2000_MSF_REG(0x0048)
414#define IXP2000_MSF_RX_CALENDAR_LENGTH IXP2000_MSF_REG(0x0048)
415#define IXP2000_MSF_RX_THREAD_FREELIST_TIMEOUT_0 IXP2000_MSF_REG(0x0050)
416#define IXP2000_MSF_RX_THREAD_FREELIST_TIMEOUT_1 IXP2000_MSF_REG(0x0054)
417#define IXP2000_MSF_RX_THREAD_FREELIST_TIMEOUT_2 IXP2000_MSF_REG(0x0058)
418#define IXP2000_MSF_TX_SEQUENCE_0 IXP2000_MSF_REG(0x0060)
419#define IXP2000_MSF_TX_SEQUENCE_1 IXP2000_MSF_REG(0x0064)
420#define IXP2000_MSF_TX_SEQUENCE_2 IXP2000_MSF_REG(0x0068)
421#define IXP2000_MSF_TX_MPHY_POLL_LIMIT IXP2000_MSF_REG(0x0070)
422#define IXP2000_MSF_TX_CALENDAR_LENGTH IXP2000_MSF_REG(0x0070)
423#define IXP2000_MSF_RX_UP_CONTROL_0 IXP2000_MSF_REG(0x0080)
424#define IXP2000_MSF_RX_UP_CONTROL_1 IXP2000_MSF_REG(0x0084)
425#define IXP2000_MSF_RX_UP_CONTROL_2 IXP2000_MSF_REG(0x0088)
426#define IXP2000_MSF_RX_UP_CONTROL_3 IXP2000_MSF_REG(0x008c)
427#define IXP2000_MSF_TX_UP_CONTROL_0 IXP2000_MSF_REG(0x0090)
428#define IXP2000_MSF_TX_UP_CONTROL_1 IXP2000_MSF_REG(0x0094)
429#define IXP2000_MSF_TX_UP_CONTROL_2 IXP2000_MSF_REG(0x0098)
430#define IXP2000_MSF_TX_UP_CONTROL_3 IXP2000_MSF_REG(0x009c)
431#define IXP2000_MSF_TRAIN_DATA IXP2000_MSF_REG(0x00a0)
432#define IXP2000_MSF_TRAIN_CALENDAR IXP2000_MSF_REG(0x00a4)
433#define IXP2000_MSF_TRAIN_FLOW_CONTROL IXP2000_MSF_REG(0x00a8)
434#define IXP2000_MSF_TX_CALENDAR_0 IXP2000_MSF_REG(0x1000)
435#define IXP2000_MSF_RX_PORT_CALENDAR_STATUS IXP2000_MSF_REG(0x1400)
436
437
395#endif /* _IXP2000_H_ */ 438#endif /* _IXP2000_H_ */
diff --git a/include/asm-arm/arch-l7200/io.h b/include/asm-arm/arch-l7200/io.h
index fc012a39e2cb..cab8ad0adf09 100644
--- a/include/asm-arm/arch-l7200/io.h
+++ b/include/asm-arm/arch-l7200/io.h
@@ -10,7 +10,7 @@
10#ifndef __ASM_ARM_ARCH_IO_H 10#ifndef __ASM_ARM_ARCH_IO_H
11#define __ASM_ARM_ARCH_IO_H 11#define __ASM_ARM_ARCH_IO_H
12 12
13#include <asm/arch/hardware.h> 13#include <asm/hardware.h>
14 14
15#define IO_SPACE_LIMIT 0xffffffff 15#define IO_SPACE_LIMIT 0xffffffff
16 16
diff --git a/include/asm-arm/arch-lh7a40x/io.h b/include/asm-arm/arch-lh7a40x/io.h
index c13bdd9add92..bbcd4335f441 100644
--- a/include/asm-arm/arch-lh7a40x/io.h
+++ b/include/asm-arm/arch-lh7a40x/io.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_ARCH_IO_H 11#ifndef __ASM_ARCH_IO_H
12#define __ASM_ARCH_IO_H 12#define __ASM_ARCH_IO_H
13 13
14#include <asm/hardware.h>
15
14#define IO_SPACE_LIMIT 0xffffffff 16#define IO_SPACE_LIMIT 0xffffffff
15 17
16/* No ISA or PCI bus on this machine. */ 18/* No ISA or PCI bus on this machine. */
diff --git a/include/asm-arm/arch-omap/io.h b/include/asm-arm/arch-omap/io.h
index 11fbf629bf75..3d5bcd545082 100644
--- a/include/asm-arm/arch-omap/io.h
+++ b/include/asm-arm/arch-omap/io.h
@@ -34,6 +34,8 @@
34#ifndef __ASM_ARM_ARCH_IO_H 34#ifndef __ASM_ARM_ARCH_IO_H
35#define __ASM_ARM_ARCH_IO_H 35#define __ASM_ARM_ARCH_IO_H
36 36
37#include <asm/hardware.h>
38
37#define IO_SPACE_LIMIT 0xffffffff 39#define IO_SPACE_LIMIT 0xffffffff
38 40
39/* 41/*
diff --git a/include/asm-arm/arch-pxa/hardware.h b/include/asm-arm/arch-pxa/hardware.h
index cf35721cfa45..3e70bd95472c 100644
--- a/include/asm-arm/arch-pxa/hardware.h
+++ b/include/asm-arm/arch-pxa/hardware.h
@@ -44,12 +44,12 @@
44 44
45#ifndef __ASSEMBLY__ 45#ifndef __ASSEMBLY__
46 46
47# define __REG(x) (*((volatile unsigned long *)io_p2v(x))) 47# define __REG(x) (*((volatile u32 *)io_p2v(x)))
48 48
49/* With indexed regs we don't want to feed the index through io_p2v() 49/* With indexed regs we don't want to feed the index through io_p2v()
50 especially if it is a variable, otherwise horrible code will result. */ 50 especially if it is a variable, otherwise horrible code will result. */
51# define __REG2(x,y) \ 51# define __REG2(x,y) \
52 (*(volatile unsigned long *)((unsigned long)&__REG(x) + (y))) 52 (*(volatile u32 *)((u32)&__REG(x) + (y)))
53 53
54# define __PREG(x) (io_v2p((u32)&(x))) 54# define __PREG(x) (io_v2p((u32)&(x)))
55 55
diff --git a/include/asm-arm/arch-pxa/io.h b/include/asm-arm/arch-pxa/io.h
index c3bdbe44e21f..eb2dd58d397f 100644
--- a/include/asm-arm/arch-pxa/io.h
+++ b/include/asm-arm/arch-pxa/io.h
@@ -6,6 +6,8 @@
6#ifndef __ASM_ARM_ARCH_IO_H 6#ifndef __ASM_ARM_ARCH_IO_H
7#define __ASM_ARM_ARCH_IO_H 7#define __ASM_ARM_ARCH_IO_H
8 8
9#include <asm/hardware.h>
10
9#define IO_SPACE_LIMIT 0xffffffff 11#define IO_SPACE_LIMIT 0xffffffff
10 12
11/* 13/*
diff --git a/include/asm-arm/arch-pxa/irda.h b/include/asm-arm/arch-pxa/irda.h
new file mode 100644
index 000000000000..748406f384c2
--- /dev/null
+++ b/include/asm-arm/arch-pxa/irda.h
@@ -0,0 +1,17 @@
1#ifndef ASMARM_ARCH_IRDA_H
2#define ASMARM_ARCH_IRDA_H
3
4/* board specific transceiver capabilities */
5
6#define IR_OFF 1
7#define IR_SIRMODE 2
8#define IR_FIRMODE 4
9
10struct pxaficp_platform_data {
11 int transceiver_cap;
12 void (*transceiver_mode)(struct device *dev, int mode);
13};
14
15extern void pxa_set_ficp_info(struct pxaficp_platform_data *info);
16
17#endif
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index 3af7165ab0d7..a75a2470f4f5 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -326,6 +326,25 @@
326#define STDLL __REG(0x40700000) /* Divisor Latch Low Register (DLAB = 1) (read/write) */ 326#define STDLL __REG(0x40700000) /* Divisor Latch Low Register (DLAB = 1) (read/write) */
327#define STDLH __REG(0x40700004) /* Divisor Latch High Register (DLAB = 1) (read/write) */ 327#define STDLH __REG(0x40700004) /* Divisor Latch High Register (DLAB = 1) (read/write) */
328 328
329/* Hardware UART (HWUART) */
330#define HWUART HWRBR
331#define HWRBR __REG(0x41600000) /* Receive Buffer Register (read only) */
332#define HWTHR __REG(0x41600000) /* Transmit Holding Register (write only) */
333#define HWIER __REG(0x41600004) /* Interrupt Enable Register (read/write) */
334#define HWIIR __REG(0x41600008) /* Interrupt ID Register (read only) */
335#define HWFCR __REG(0x41600008) /* FIFO Control Register (write only) */
336#define HWLCR __REG(0x4160000C) /* Line Control Register (read/write) */
337#define HWMCR __REG(0x41600010) /* Modem Control Register (read/write) */
338#define HWLSR __REG(0x41600014) /* Line Status Register (read only) */
339#define HWMSR __REG(0x41600018) /* Modem Status Register (read only) */
340#define HWSPR __REG(0x4160001C) /* Scratch Pad Register (read/write) */
341#define HWISR __REG(0x41600020) /* Infrared Selection Register (read/write) */
342#define HWFOR __REG(0x41600024) /* Receive FIFO Occupancy Register (read only) */
343#define HWABR __REG(0x41600028) /* Auto-Baud Control Register (read/write) */
344#define HWACR __REG(0x4160002C) /* Auto-Baud Count Register (read only) */
345#define HWDLL __REG(0x41600000) /* Divisor Latch Low Register (DLAB = 1) (read/write) */
346#define HWDLH __REG(0x41600004) /* Divisor Latch High Register (DLAB = 1) (read/write) */
347
329#define IER_DMAE (1 << 7) /* DMA Requests Enable */ 348#define IER_DMAE (1 << 7) /* DMA Requests Enable */
330#define IER_UUE (1 << 6) /* UART Unit Enable */ 349#define IER_UUE (1 << 6) /* UART Unit Enable */
331#define IER_NRZE (1 << 5) /* NRZ coding Enable */ 350#define IER_NRZE (1 << 5) /* NRZ coding Enable */
@@ -1013,14 +1032,12 @@
1013#define ICCR0_LBM (1 << 1) /* Loopback mode */ 1032#define ICCR0_LBM (1 << 1) /* Loopback mode */
1014#define ICCR0_ITR (1 << 0) /* IrDA transmission */ 1033#define ICCR0_ITR (1 << 0) /* IrDA transmission */
1015 1034
1016#ifdef CONFIG_PXA27x
1017#define ICCR2_RXP (1 << 3) /* Receive Pin Polarity select */ 1035#define ICCR2_RXP (1 << 3) /* Receive Pin Polarity select */
1018#define ICCR2_TXP (1 << 2) /* Transmit Pin Polarity select */ 1036#define ICCR2_TXP (1 << 2) /* Transmit Pin Polarity select */
1019#define ICCR2_TRIG (3 << 0) /* Receive FIFO Trigger threshold */ 1037#define ICCR2_TRIG (3 << 0) /* Receive FIFO Trigger threshold */
1020#define ICCR2_TRIG_8 (0 << 0) /* >= 8 bytes */ 1038#define ICCR2_TRIG_8 (0 << 0) /* >= 8 bytes */
1021#define ICCR2_TRIG_16 (1 << 0) /* >= 16 bytes */ 1039#define ICCR2_TRIG_16 (1 << 0) /* >= 16 bytes */
1022#define ICCR2_TRIG_32 (2 << 0) /* >= 32 bytes */ 1040#define ICCR2_TRIG_32 (2 << 0) /* >= 32 bytes */
1023#endif
1024 1041
1025#ifdef CONFIG_PXA27x 1042#ifdef CONFIG_PXA27x
1026#define ICSR0_EOC (1 << 6) /* DMA End of Descriptor Chain */ 1043#define ICSR0_EOC (1 << 6) /* DMA End of Descriptor Chain */
@@ -1250,9 +1267,13 @@
1250#define GPIO40_FFDTR 40 /* FFUART data terminal Ready */ 1267#define GPIO40_FFDTR 40 /* FFUART data terminal Ready */
1251#define GPIO41_FFRTS 41 /* FFUART request to send */ 1268#define GPIO41_FFRTS 41 /* FFUART request to send */
1252#define GPIO42_BTRXD 42 /* BTUART receive data */ 1269#define GPIO42_BTRXD 42 /* BTUART receive data */
1270#define GPIO42_HWRXD 42 /* HWUART receive data */
1253#define GPIO43_BTTXD 43 /* BTUART transmit data */ 1271#define GPIO43_BTTXD 43 /* BTUART transmit data */
1272#define GPIO43_HWTXD 43 /* HWUART transmit data */
1254#define GPIO44_BTCTS 44 /* BTUART clear to send */ 1273#define GPIO44_BTCTS 44 /* BTUART clear to send */
1274#define GPIO44_HWCTS 44 /* HWUART clear to send */
1255#define GPIO45_BTRTS 45 /* BTUART request to send */ 1275#define GPIO45_BTRTS 45 /* BTUART request to send */
1276#define GPIO45_HWRTS 45 /* HWUART request to send */
1256#define GPIO45_AC97_SYSCLK 45 /* AC97 System Clock */ 1277#define GPIO45_AC97_SYSCLK 45 /* AC97 System Clock */
1257#define GPIO46_ICPRXD 46 /* ICP receive data */ 1278#define GPIO46_ICPRXD 46 /* ICP receive data */
1258#define GPIO46_STRXD 46 /* STD_UART receive data */ 1279#define GPIO46_STRXD 46 /* STD_UART receive data */
@@ -1378,17 +1399,26 @@
1378#define GPIO40_FFDTR_MD (40 | GPIO_ALT_FN_2_OUT) 1399#define GPIO40_FFDTR_MD (40 | GPIO_ALT_FN_2_OUT)
1379#define GPIO41_FFRTS_MD (41 | GPIO_ALT_FN_2_OUT) 1400#define GPIO41_FFRTS_MD (41 | GPIO_ALT_FN_2_OUT)
1380#define GPIO42_BTRXD_MD (42 | GPIO_ALT_FN_1_IN) 1401#define GPIO42_BTRXD_MD (42 | GPIO_ALT_FN_1_IN)
1402#define GPIO42_HWRXD_MD (42 | GPIO_ALT_FN_3_IN)
1381#define GPIO43_BTTXD_MD (43 | GPIO_ALT_FN_2_OUT) 1403#define GPIO43_BTTXD_MD (43 | GPIO_ALT_FN_2_OUT)
1404#define GPIO43_HWTXD_MD (43 | GPIO_ALT_FN_3_OUT)
1382#define GPIO44_BTCTS_MD (44 | GPIO_ALT_FN_1_IN) 1405#define GPIO44_BTCTS_MD (44 | GPIO_ALT_FN_1_IN)
1406#define GPIO44_HWCTS_MD (44 | GPIO_ALT_FN_3_IN)
1383#define GPIO45_BTRTS_MD (45 | GPIO_ALT_FN_2_OUT) 1407#define GPIO45_BTRTS_MD (45 | GPIO_ALT_FN_2_OUT)
1408#define GPIO45_HWRTS_MD (45 | GPIO_ALT_FN_3_OUT)
1384#define GPIO45_SYSCLK_AC97_MD (45 | GPIO_ALT_FN_1_OUT) 1409#define GPIO45_SYSCLK_AC97_MD (45 | GPIO_ALT_FN_1_OUT)
1385#define GPIO46_ICPRXD_MD (46 | GPIO_ALT_FN_1_IN) 1410#define GPIO46_ICPRXD_MD (46 | GPIO_ALT_FN_1_IN)
1386#define GPIO46_STRXD_MD (46 | GPIO_ALT_FN_2_IN) 1411#define GPIO46_STRXD_MD (46 | GPIO_ALT_FN_2_IN)
1387#define GPIO47_ICPTXD_MD (47 | GPIO_ALT_FN_2_OUT) 1412#define GPIO47_ICPTXD_MD (47 | GPIO_ALT_FN_2_OUT)
1388#define GPIO47_STTXD_MD (47 | GPIO_ALT_FN_1_OUT) 1413#define GPIO47_STTXD_MD (47 | GPIO_ALT_FN_1_OUT)
1389#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT) 1414#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
1415#define GPIO48_HWTXD_MD (48 | GPIO_ALT_FN_1_OUT)
1416#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
1417#define GPIO49_HWRXD_MD (49 | GPIO_ALT_FN_1_IN)
1390#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT) 1418#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT)
1391#define GPIO50_nPIOR_MD (50 | GPIO_ALT_FN_2_OUT) 1419#define GPIO50_nPIOR_MD (50 | GPIO_ALT_FN_2_OUT)
1420#define GPIO50_HWCTS_MD (50 | GPIO_ALT_FN_1_IN)
1421#define GPIO51_HWRTS_MD (51 | GPIO_ALT_FN_1_OUT)
1392#define GPIO51_nPIOW_MD (51 | GPIO_ALT_FN_2_OUT) 1422#define GPIO51_nPIOW_MD (51 | GPIO_ALT_FN_2_OUT)
1393#define GPIO52_nPCE_1_MD (52 | GPIO_ALT_FN_2_OUT) 1423#define GPIO52_nPCE_1_MD (52 | GPIO_ALT_FN_2_OUT)
1394#define GPIO53_nPCE_2_MD (53 | GPIO_ALT_FN_2_OUT) 1424#define GPIO53_nPCE_2_MD (53 | GPIO_ALT_FN_2_OUT)
@@ -1763,6 +1793,7 @@
1763#define CKEN7_BTUART (1 << 7) /* BTUART Unit Clock Enable */ 1793#define CKEN7_BTUART (1 << 7) /* BTUART Unit Clock Enable */
1764#define CKEN6_FFUART (1 << 6) /* FFUART Unit Clock Enable */ 1794#define CKEN6_FFUART (1 << 6) /* FFUART Unit Clock Enable */
1765#define CKEN5_STUART (1 << 5) /* STUART Unit Clock Enable */ 1795#define CKEN5_STUART (1 << 5) /* STUART Unit Clock Enable */
1796#define CKEN4_HWUART (1 << 4) /* HWUART Unit Clock Enable */
1766#define CKEN4_SSP3 (1 << 4) /* SSP3 Unit Clock Enable */ 1797#define CKEN4_SSP3 (1 << 4) /* SSP3 Unit Clock Enable */
1767#define CKEN3_SSP (1 << 3) /* SSP Unit Clock Enable */ 1798#define CKEN3_SSP (1 << 3) /* SSP Unit Clock Enable */
1768#define CKEN3_SSP2 (1 << 3) /* SSP2 Unit Clock Enable */ 1799#define CKEN3_SSP2 (1 << 3) /* SSP2 Unit Clock Enable */
@@ -2282,4 +2313,11 @@
2282 2313
2283#endif 2314#endif
2284 2315
2316/* PWRMODE register M field values */
2317
2318#define PWRMODE_IDLE 0x1
2319#define PWRMODE_STANDBY 0x2
2320#define PWRMODE_SLEEP 0x3
2321#define PWRMODE_DEEPSLEEP 0x7
2322
2285#endif 2323#endif
diff --git a/include/asm-arm/arch-pxa/uncompress.h b/include/asm-arm/arch-pxa/uncompress.h
index 4428d3eb7432..fe38090444e0 100644
--- a/include/asm-arm/arch-pxa/uncompress.h
+++ b/include/asm-arm/arch-pxa/uncompress.h
@@ -12,6 +12,7 @@
12#define FFUART ((volatile unsigned long *)0x40100000) 12#define FFUART ((volatile unsigned long *)0x40100000)
13#define BTUART ((volatile unsigned long *)0x40200000) 13#define BTUART ((volatile unsigned long *)0x40200000)
14#define STUART ((volatile unsigned long *)0x40700000) 14#define STUART ((volatile unsigned long *)0x40700000)
15#define HWUART ((volatile unsigned long *)0x41600000)
15 16
16#define UART FFUART 17#define UART FFUART
17 18
diff --git a/include/asm-arm/arch-rpc/io.h b/include/asm-arm/arch-rpc/io.h
index 24453c405a87..b4da08d7a336 100644
--- a/include/asm-arm/arch-rpc/io.h
+++ b/include/asm-arm/arch-rpc/io.h
@@ -13,6 +13,8 @@
13#ifndef __ASM_ARM_ARCH_IO_H 13#ifndef __ASM_ARM_ARCH_IO_H
14#define __ASM_ARM_ARCH_IO_H 14#define __ASM_ARM_ARCH_IO_H
15 15
16#include <asm/hardware.h>
17
16#define IO_SPACE_LIMIT 0xffffffff 18#define IO_SPACE_LIMIT 0xffffffff
17 19
18/* 20/*
diff --git a/include/asm-arm/arch-s3c2410/fb.h b/include/asm-arm/arch-s3c2410/fb.h
index ac57bc887d82..4790491ba9d0 100644
--- a/include/asm-arm/arch-s3c2410/fb.h
+++ b/include/asm-arm/arch-s3c2410/fb.h
@@ -13,6 +13,7 @@
13 * 07-Sep-2004 RTP Created file 13 * 07-Sep-2004 RTP Created file
14 * 03-Nov-2004 BJD Updated and minor cleanups 14 * 03-Nov-2004 BJD Updated and minor cleanups
15 * 03-Aug-2005 RTP Renamed to fb.h 15 * 03-Aug-2005 RTP Renamed to fb.h
16 * 26-Oct-2005 BJD Changed name of platdata init
16*/ 17*/
17 18
18#ifndef __ASM_ARM_FB_H 19#ifndef __ASM_ARM_FB_H
@@ -64,6 +65,6 @@ struct s3c2410fb_mach_info {
64 unsigned long lpcsel; 65 unsigned long lpcsel;
65}; 66};
66 67
67void __init set_s3c2410fb_info(struct s3c2410fb_mach_info *hard_s3c2410fb_info); 68extern void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *);
68 69
69#endif /* __ASM_ARM_FB_H */ 70#endif /* __ASM_ARM_FB_H */
diff --git a/include/asm-arm/arch-s3c2410/io.h b/include/asm-arm/arch-s3c2410/io.h
index 4bf272ed9add..16fbc8afffd9 100644
--- a/include/asm-arm/arch-s3c2410/io.h
+++ b/include/asm-arm/arch-s3c2410/io.h
@@ -15,6 +15,8 @@
15#ifndef __ASM_ARM_ARCH_IO_H 15#ifndef __ASM_ARM_ARCH_IO_H
16#define __ASM_ARM_ARCH_IO_H 16#define __ASM_ARM_ARCH_IO_H
17 17
18#include <asm/hardware.h>
19
18#define IO_SPACE_LIMIT 0xffffffff 20#define IO_SPACE_LIMIT 0xffffffff
19 21
20/* 22/*
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index 2053cbacffc3..cb33d57c146c 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -20,6 +20,7 @@
20 * 18-11-2004 BJD Added S3C2440 AC97 controls 20 * 18-11-2004 BJD Added S3C2440 AC97 controls
21 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA 21 * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
22 * 28-Mar-2005 LCVR Fixed definition of GPB10 22 * 28-Mar-2005 LCVR Fixed definition of GPB10
23 * 26-Oct-2005 BJD Added generic configuration types
23*/ 24*/
24 25
25 26
@@ -43,6 +44,11 @@
43/* general configuration options */ 44/* general configuration options */
44 45
45#define S3C2410_GPIO_LEAVE (0xFFFFFFFF) 46#define S3C2410_GPIO_LEAVE (0xFFFFFFFF)
47#define S3C2410_GPIO_INPUT (0xFFFFFFF0)
48#define S3C2410_GPIO_OUTPUT (0xFFFFFFF1)
49#define S3C2410_GPIO_IRQ (0xFFFFFFF2) /* not available for all */
50#define S3C2410_GPIO_SFN2 (0xFFFFFFF2) /* not available on A */
51#define S3C2410_GPIO_SFN3 (0xFFFFFFF3) /* not available on A */
46 52
47/* configure GPIO ports A..G */ 53/* configure GPIO ports A..G */
48 54
diff --git a/include/asm-arm/arch-sa1100/hardware.h b/include/asm-arm/arch-sa1100/hardware.h
index 19c3b1e186bb..28711aaa4968 100644
--- a/include/asm-arm/arch-sa1100/hardware.h
+++ b/include/asm-arm/arch-sa1100/hardware.h
@@ -22,13 +22,6 @@
22 22
23 23
24/* 24/*
25 * We requires absolute addresses i.e. (PCMCIA_IO_0_BASE + 0x3f8) for
26 * in*()/out*() macros to be usable for all cases.
27 */
28#define PCIO_BASE 0
29
30
31/*
32 * SA1100 internal I/O mappings 25 * SA1100 internal I/O mappings
33 * 26 *
34 * We have the following mapping: 27 * We have the following mapping:
diff --git a/include/asm-arm/arch-sa1100/io.h b/include/asm-arm/arch-sa1100/io.h
index 7d969ffbd3bb..9d4fe6cf205b 100644
--- a/include/asm-arm/arch-sa1100/io.h
+++ b/include/asm-arm/arch-sa1100/io.h
@@ -10,13 +10,19 @@
10#ifndef __ASM_ARM_ARCH_IO_H 10#ifndef __ASM_ARM_ARCH_IO_H
11#define __ASM_ARM_ARCH_IO_H 11#define __ASM_ARM_ARCH_IO_H
12 12
13#include <asm/hardware.h>
14
13#define IO_SPACE_LIMIT 0xffffffff 15#define IO_SPACE_LIMIT 0xffffffff
14 16
15/* 17/*
16 * We don't actually have real ISA nor PCI buses, but there is so many 18 * We don't actually have real ISA nor PCI buses, but there is so many
17 * drivers out there that might just work if we fake them... 19 * drivers out there that might just work if we fake them...
18 */ 20 */
19#define __io(a) ((void __iomem *)(PCIO_BASE + (a))) 21static inline void __iomem *__io(unsigned long addr)
22{
23 return (void __iomem *)addr;
24}
25#define __io(a) __io(a)
20#define __mem_pci(a) (a) 26#define __mem_pci(a) (a)
21#define __mem_isa(a) (a) 27#define __mem_isa(a) (a)
22 28
diff --git a/include/asm-arm/arch-sa1100/system.h b/include/asm-arm/arch-sa1100/system.h
index 6f52118ba1a4..0f0612f79b2b 100644
--- a/include/asm-arm/arch-sa1100/system.h
+++ b/include/asm-arm/arch-sa1100/system.h
@@ -4,6 +4,7 @@
4 * Copyright (c) 1999 Nicolas Pitre <nico@cam.org> 4 * Copyright (c) 1999 Nicolas Pitre <nico@cam.org>
5 */ 5 */
6#include <linux/config.h> 6#include <linux/config.h>
7#include <asm/hardware.h>
7 8
8static inline void arch_idle(void) 9static inline void arch_idle(void)
9{ 10{
diff --git a/include/asm-arm/arch-shark/io.h b/include/asm-arm/arch-shark/io.h
index 5e6ed0038b2b..87ffa27f2962 100644
--- a/include/asm-arm/arch-shark/io.h
+++ b/include/asm-arm/arch-shark/io.h
@@ -11,6 +11,8 @@
11#ifndef __ASM_ARM_ARCH_IO_H 11#ifndef __ASM_ARM_ARCH_IO_H
12#define __ASM_ARM_ARCH_IO_H 12#define __ASM_ARM_ARCH_IO_H
13 13
14#include <asm/hardware.h>
15
14#define IO_SPACE_LIMIT 0xffffffff 16#define IO_SPACE_LIMIT 0xffffffff
15 17
16/* 18/*
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index d62ade4e4cbb..e3e8541ee63b 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -70,7 +70,7 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
70 * device-viewed address. 70 * device-viewed address.
71 */ 71 */
72extern void * 72extern void *
73dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, int gfp); 73dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp);
74 74
75/** 75/**
76 * dma_free_coherent - free memory allocated by dma_alloc_coherent 76 * dma_free_coherent - free memory allocated by dma_alloc_coherent
@@ -117,7 +117,7 @@ int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma,
117 * device-viewed address. 117 * device-viewed address.
118 */ 118 */
119extern void * 119extern void *
120dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, int gfp); 120dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp);
121 121
122#define dma_free_writecombine(dev,size,cpu_addr,handle) \ 122#define dma_free_writecombine(dev,size,cpu_addr,handle) \
123 dma_free_coherent(dev,size,cpu_addr,handle) 123 dma_free_coherent(dev,size,cpu_addr,handle)
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index 5c4ae8f5dbb0..2e6799632f12 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -26,7 +26,6 @@
26#include <linux/types.h> 26#include <linux/types.h>
27#include <asm/byteorder.h> 27#include <asm/byteorder.h>
28#include <asm/memory.h> 28#include <asm/memory.h>
29#include <asm/arch/hardware.h>
30 29
31/* 30/*
32 * ISA I/O bus memory addresses are 1:1 with the physical address. 31 * ISA I/O bus memory addresses are 1:1 with the physical address.
diff --git a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
index 4fa95084a8c0..7273c6fd95b5 100644
--- a/include/asm-arm/mach/arch.h
+++ b/include/asm-arm/mach/arch.h
@@ -48,10 +48,10 @@ struct machine_desc {
48 * Set of macros to define architecture features. This is built into 48 * Set of macros to define architecture features. This is built into
49 * a table by the linker. 49 * a table by the linker.
50 */ 50 */
51#define MACHINE_START(_type,_name) \ 51#define MACHINE_START(_type,_name) \
52const struct machine_desc __mach_desc_##_type \ 52static const struct machine_desc __mach_desc_##_type \
53 __attribute__((__section__(".arch.info.init"))) = { \ 53 __attribute__((__section__(".arch.info.init"))) = { \
54 .nr = MACH_TYPE_##_type, \ 54 .nr = MACH_TYPE_##_type, \
55 .name = _name, 55 .name = _name,
56 56
57#define MACHINE_END \ 57#define MACHINE_END \
diff --git a/include/asm-arm/mach/map.h b/include/asm-arm/mach/map.h
index 9ac47cf8d2e4..0619522bd926 100644
--- a/include/asm-arm/mach/map.h
+++ b/include/asm-arm/mach/map.h
@@ -11,7 +11,7 @@
11 */ 11 */
12struct map_desc { 12struct map_desc {
13 unsigned long virtual; 13 unsigned long virtual;
14 unsigned long physical; 14 unsigned long pfn;
15 unsigned long length; 15 unsigned long length;
16 unsigned int type; 16 unsigned int type;
17}; 17};
@@ -27,6 +27,9 @@ struct meminfo;
27#define MT_ROM 6 27#define MT_ROM 6
28#define MT_IXP2000_DEVICE 7 28#define MT_IXP2000_DEVICE 7
29 29
30#define __phys_to_pfn(paddr) (paddr >> PAGE_SHIFT)
31#define __pfn_to_phys(pfn) (pfn << PAGE_SHIFT)
32
30extern void create_memmap_holes(struct meminfo *); 33extern void create_memmap_holes(struct meminfo *);
31extern void memtable_init(struct meminfo *); 34extern void memtable_init(struct meminfo *);
32extern void iotable_init(struct map_desc *, int); 35extern void iotable_init(struct map_desc *, int);
diff --git a/include/asm-cris/dma-mapping.h b/include/asm-cris/dma-mapping.h
index 0b5c3fdaefe1..8eff51349ae7 100644
--- a/include/asm-cris/dma-mapping.h
+++ b/include/asm-cris/dma-mapping.h
@@ -15,14 +15,14 @@
15 15
16#ifdef CONFIG_PCI 16#ifdef CONFIG_PCI
17void *dma_alloc_coherent(struct device *dev, size_t size, 17void *dma_alloc_coherent(struct device *dev, size_t size,
18 dma_addr_t *dma_handle, int flag); 18 dma_addr_t *dma_handle, gfp_t flag);
19 19
20void dma_free_coherent(struct device *dev, size_t size, 20void dma_free_coherent(struct device *dev, size_t size,
21 void *vaddr, dma_addr_t dma_handle); 21 void *vaddr, dma_addr_t dma_handle);
22#else 22#else
23static inline void * 23static inline void *
24dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 24dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
25 int flag) 25 gfp_t flag)
26{ 26{
27 BUG(); 27 BUG();
28 return NULL; 28 return NULL;
diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h
index 0206ab35eae0..5003e017fd1e 100644
--- a/include/asm-frv/dma-mapping.h
+++ b/include/asm-frv/dma-mapping.h
@@ -13,7 +13,7 @@
13extern unsigned long __nongprelbss dma_coherent_mem_start; 13extern unsigned long __nongprelbss dma_coherent_mem_start;
14extern unsigned long __nongprelbss dma_coherent_mem_end; 14extern unsigned long __nongprelbss dma_coherent_mem_end;
15 15
16void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, int gfp); 16void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp);
17void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle); 17void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle);
18 18
19/* 19/*
diff --git a/include/asm-frv/pci.h b/include/asm-frv/pci.h
index b4efe5e3591a..1168451c275f 100644
--- a/include/asm-frv/pci.h
+++ b/include/asm-frv/pci.h
@@ -32,7 +32,7 @@ extern void pcibios_set_master(struct pci_dev *dev);
32extern void pcibios_penalize_isa_irq(int irq); 32extern void pcibios_penalize_isa_irq(int irq);
33 33
34#ifdef CONFIG_MMU 34#ifdef CONFIG_MMU
35extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle); 35extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle);
36extern void consistent_free(void *vaddr); 36extern void consistent_free(void *vaddr);
37extern void consistent_sync(void *vaddr, size_t size, int direction); 37extern void consistent_sync(void *vaddr, size_t size, int direction);
38extern void consistent_sync_page(struct page *page, unsigned long offset, 38extern void consistent_sync_page(struct page *page, unsigned long offset,
diff --git a/include/asm-generic/dma-mapping-broken.h b/include/asm-generic/dma-mapping-broken.h
index fd9de9502dff..a7f1a55ce6b0 100644
--- a/include/asm-generic/dma-mapping-broken.h
+++ b/include/asm-generic/dma-mapping-broken.h
@@ -6,7 +6,7 @@
6 6
7static inline void * 7static inline void *
8dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 8dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
9 int flag) 9 gfp_t flag)
10{ 10{
11 BUG(); 11 BUG();
12 return NULL; 12 return NULL;
diff --git a/include/asm-i386/mach-summit/mach_mpparse.h b/include/asm-i386/mach-summit/mach_mpparse.h
index 2b9e6d55bef1..1cce2b924a80 100644
--- a/include/asm-i386/mach-summit/mach_mpparse.h
+++ b/include/asm-i386/mach-summit/mach_mpparse.h
@@ -22,7 +22,6 @@ static inline void mpc_oem_pci_bus(struct mpc_config_bus *m,
22{ 22{
23} 23}
24 24
25extern int usb_early_handoff;
26static inline int mps_oem_check(struct mp_config_table *mpc, char *oem, 25static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
27 char *productid) 26 char *productid)
28{ 27{
@@ -32,7 +31,6 @@ static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
32 || !strncmp(productid, "RUTHLESS SMP", 12))){ 31 || !strncmp(productid, "RUTHLESS SMP", 12))){
33 use_cyclone = 1; /*enable cyclone-timer*/ 32 use_cyclone = 1; /*enable cyclone-timer*/
34 setup_summit(); 33 setup_summit();
35 usb_early_handoff = 1;
36 return 1; 34 return 1;
37 } 35 }
38 return 0; 36 return 0;
@@ -46,7 +44,6 @@ static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
46 || !strncmp(oem_table_id, "EXA", 3))){ 44 || !strncmp(oem_table_id, "EXA", 3))){
47 use_cyclone = 1; /*enable cyclone-timer*/ 45 use_cyclone = 1; /*enable cyclone-timer*/
48 setup_summit(); 46 setup_summit();
49 usb_early_handoff = 1;
50 return 1; 47 return 1;
51 } 48 }
52 return 0; 49 return 0;
diff --git a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
index 522c7f5ba8ce..ca5ea994d688 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
@@ -37,7 +37,7 @@ typedef int ia64_mv_pci_legacy_write_t (struct pci_bus *, u16 port, u32 val,
37 37
38/* DMA-mapping interface: */ 38/* DMA-mapping interface: */
39typedef void ia64_mv_dma_init (void); 39typedef void ia64_mv_dma_init (void);
40typedef void *ia64_mv_dma_alloc_coherent (struct device *, size_t, dma_addr_t *, int); 40typedef void *ia64_mv_dma_alloc_coherent (struct device *, size_t, dma_addr_t *, gfp_t);
41typedef void ia64_mv_dma_free_coherent (struct device *, size_t, void *, dma_addr_t); 41typedef void ia64_mv_dma_free_coherent (struct device *, size_t, void *, dma_addr_t);
42typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, int); 42typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, int);
43typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, int); 43typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, int);
diff --git a/include/asm-m32r/dma-mapping.h b/include/asm-m32r/dma-mapping.h
index 3a2db28834b6..a7fa0302bda7 100644
--- a/include/asm-m32r/dma-mapping.h
+++ b/include/asm-m32r/dma-mapping.h
@@ -8,7 +8,7 @@
8 8
9static inline void * 9static inline void *
10dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 10dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
11 int flag) 11 gfp_t flag)
12{ 12{
13 return (void *)NULL; 13 return (void *)NULL;
14} 14}
diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index af28dc88930b..43288634c38a 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -5,13 +5,13 @@
5#include <asm/cache.h> 5#include <asm/cache.h>
6 6
7void *dma_alloc_noncoherent(struct device *dev, size_t size, 7void *dma_alloc_noncoherent(struct device *dev, size_t size,
8 dma_addr_t *dma_handle, int flag); 8 dma_addr_t *dma_handle, gfp_t flag);
9 9
10void dma_free_noncoherent(struct device *dev, size_t size, 10void dma_free_noncoherent(struct device *dev, size_t size,
11 void *vaddr, dma_addr_t dma_handle); 11 void *vaddr, dma_addr_t dma_handle);
12 12
13void *dma_alloc_coherent(struct device *dev, size_t size, 13void *dma_alloc_coherent(struct device *dev, size_t size,
14 dma_addr_t *dma_handle, int flag); 14 dma_addr_t *dma_handle, gfp_t flag);
15 15
16void dma_free_coherent(struct device *dev, size_t size, 16void dma_free_coherent(struct device *dev, size_t size,
17 void *vaddr, dma_addr_t dma_handle); 17 void *vaddr, dma_addr_t dma_handle);
diff --git a/include/asm-mips/sgi/hpc3.h b/include/asm-mips/sgi/hpc3.h
index ac3dfc7af5b0..fcec52bafb25 100644
--- a/include/asm-mips/sgi/hpc3.h
+++ b/include/asm-mips/sgi/hpc3.h
@@ -128,26 +128,26 @@ struct hpc3_ethregs {
128 volatile u32 rx_gfptr; /* current GIO fifo ptr */ 128 volatile u32 rx_gfptr; /* current GIO fifo ptr */
129 volatile u32 rx_dfptr; /* current device fifo ptr */ 129 volatile u32 rx_dfptr; /* current device fifo ptr */
130 u32 _unused1; /* padding */ 130 u32 _unused1; /* padding */
131 volatile u32 rx_reset; /* reset register */ 131 volatile u32 reset; /* reset register */
132#define HPC3_ERXRST_CRESET 0x1 /* Reset dma channel and external controller */ 132#define HPC3_ERST_CRESET 0x1 /* Reset dma channel and external controller */
133#define HPC3_ERXRST_CLRIRQ 0x2 /* Clear channel interrupt */ 133#define HPC3_ERST_CLRIRQ 0x2 /* Clear channel interrupt */
134#define HPC3_ERXRST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */ 134#define HPC3_ERST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */
135 135
136 volatile u32 rx_dconfig; /* DMA configuration register */ 136 volatile u32 dconfig; /* DMA configuration register */
137#define HPC3_ERXDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */ 137#define HPC3_EDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */
138#define HPC3_ERXDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */ 138#define HPC3_EDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */
139#define HPC3_ERXDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */ 139#define HPC3_EDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */
140#define HPC3_ERXDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */ 140#define HPC3_EDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */
141#define HPC3_ERXDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */ 141#define HPC3_EDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */
142#define HPC3_ERXDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */ 142#define HPC3_EDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */
143#define HPC3_ERXDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */ 143#define HPC3_EDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */
144#define HPC3_ERXDCFG_PTO 0x30000 /* Programmed timeout value for above two */ 144#define HPC3_EDCFG_PTO 0x30000 /* Programmed timeout value for above two */
145 145
146 volatile u32 rx_pconfig; /* PIO configuration register */ 146 volatile u32 pconfig; /* PIO configuration register */
147#define HPC3_ERXPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */ 147#define HPC3_EPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */
148#define HPC3_ERXPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */ 148#define HPC3_EPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */
149#define HPC3_ERXPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */ 149#define HPC3_EPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */
150#define HPC3_ERXPCFG_TST 0x1000 /* Diagnistic ram test feature bit */ 150#define HPC3_EPCFG_TST 0x1000 /* Diagnistic ram test feature bit */
151 151
152 u32 _unused2[0x1000/4 - 8]; /* padding */ 152 u32 _unused2[0x1000/4 - 8]; /* padding */
153 153
diff --git a/include/asm-parisc/assembly.h b/include/asm-parisc/assembly.h
index 30b023411fef..3ce3440d1b0c 100644
--- a/include/asm-parisc/assembly.h
+++ b/include/asm-parisc/assembly.h
@@ -21,7 +21,9 @@
21#ifndef _PARISC_ASSEMBLY_H 21#ifndef _PARISC_ASSEMBLY_H
22#define _PARISC_ASSEMBLY_H 22#define _PARISC_ASSEMBLY_H
23 23
24#ifdef __LP64__ 24#define CALLEE_FLOAT_FRAME_SIZE 80
25
26#ifdef CONFIG_64BIT
25#define LDREG ldd 27#define LDREG ldd
26#define STREG std 28#define STREG std
27#define LDREGX ldd,s 29#define LDREGX ldd,s
@@ -30,8 +32,8 @@
30#define SHRREG shrd 32#define SHRREG shrd
31#define RP_OFFSET 16 33#define RP_OFFSET 16
32#define FRAME_SIZE 128 34#define FRAME_SIZE 128
33#define CALLEE_SAVE_FRAME_SIZE 144 35#define CALLEE_REG_FRAME_SIZE 144
34#else 36#else /* CONFIG_64BIT */
35#define LDREG ldw 37#define LDREG ldw
36#define STREG stw 38#define STREG stw
37#define LDREGX ldwx,s 39#define LDREGX ldwx,s
@@ -40,9 +42,11 @@
40#define SHRREG shr 42#define SHRREG shr
41#define RP_OFFSET 20 43#define RP_OFFSET 20
42#define FRAME_SIZE 64 44#define FRAME_SIZE 64
43#define CALLEE_SAVE_FRAME_SIZE 128 45#define CALLEE_REG_FRAME_SIZE 128
44#endif 46#endif
45 47
48#define CALLEE_SAVE_FRAME_SIZE (CALLEE_REG_FRAME_SIZE + CALLEE_FLOAT_FRAME_SIZE)
49
46#ifdef CONFIG_PA20 50#ifdef CONFIG_PA20
47#define BL b,l 51#define BL b,l
48# ifdef CONFIG_64BIT 52# ifdef CONFIG_64BIT
@@ -300,9 +304,35 @@
300 fldd,mb -8(\regs), %fr0 304 fldd,mb -8(\regs), %fr0
301 .endm 305 .endm
302 306
307 .macro callee_save_float
308 fstd,ma %fr12, 8(%r30)
309 fstd,ma %fr13, 8(%r30)
310 fstd,ma %fr14, 8(%r30)
311 fstd,ma %fr15, 8(%r30)
312 fstd,ma %fr16, 8(%r30)
313 fstd,ma %fr17, 8(%r30)
314 fstd,ma %fr18, 8(%r30)
315 fstd,ma %fr19, 8(%r30)
316 fstd,ma %fr20, 8(%r30)
317 fstd,ma %fr21, 8(%r30)
318 .endm
319
320 .macro callee_rest_float
321 fldd,mb -8(%r30), %fr21
322 fldd,mb -8(%r30), %fr20
323 fldd,mb -8(%r30), %fr19
324 fldd,mb -8(%r30), %fr18
325 fldd,mb -8(%r30), %fr17
326 fldd,mb -8(%r30), %fr16
327 fldd,mb -8(%r30), %fr15
328 fldd,mb -8(%r30), %fr14
329 fldd,mb -8(%r30), %fr13
330 fldd,mb -8(%r30), %fr12
331 .endm
332
303#ifdef __LP64__ 333#ifdef __LP64__
304 .macro callee_save 334 .macro callee_save
305 std,ma %r3, CALLEE_SAVE_FRAME_SIZE(%r30) 335 std,ma %r3, CALLEE_REG_FRAME_SIZE(%r30)
306 mfctl %cr27, %r3 336 mfctl %cr27, %r3
307 std %r4, -136(%r30) 337 std %r4, -136(%r30)
308 std %r5, -128(%r30) 338 std %r5, -128(%r30)
@@ -340,13 +370,13 @@
340 ldd -128(%r30), %r5 370 ldd -128(%r30), %r5
341 ldd -136(%r30), %r4 371 ldd -136(%r30), %r4
342 mtctl %r3, %cr27 372 mtctl %r3, %cr27
343 ldd,mb -CALLEE_SAVE_FRAME_SIZE(%r30), %r3 373 ldd,mb -CALLEE_REG_FRAME_SIZE(%r30), %r3
344 .endm 374 .endm
345 375
346#else /* ! __LP64__ */ 376#else /* ! __LP64__ */
347 377
348 .macro callee_save 378 .macro callee_save
349 stw,ma %r3, CALLEE_SAVE_FRAME_SIZE(%r30) 379 stw,ma %r3, CALLEE_REG_FRAME_SIZE(%r30)
350 mfctl %cr27, %r3 380 mfctl %cr27, %r3
351 stw %r4, -124(%r30) 381 stw %r4, -124(%r30)
352 stw %r5, -120(%r30) 382 stw %r5, -120(%r30)
@@ -384,7 +414,7 @@
384 ldw -120(%r30), %r5 414 ldw -120(%r30), %r5
385 ldw -124(%r30), %r4 415 ldw -124(%r30), %r4
386 mtctl %r3, %cr27 416 mtctl %r3, %cr27
387 ldw,mb -CALLEE_SAVE_FRAME_SIZE(%r30), %r3 417 ldw,mb -CALLEE_REG_FRAME_SIZE(%r30), %r3
388 .endm 418 .endm
389#endif /* ! __LP64__ */ 419#endif /* ! __LP64__ */
390 420
@@ -450,5 +480,30 @@
450 REST_CR (%cr22, PT_PSW (\regs)) 480 REST_CR (%cr22, PT_PSW (\regs))
451 .endm 481 .endm
452 482
483
484 /* First step to create a "relied upon translation"
485 * See PA 2.0 Arch. page F-4 and F-5.
486 *
487 * The ssm was originally necessary due to a "PCxT bug".
488 * But someone decided it needed to be added to the architecture
489 * and this "feature" went into rev3 of PA-RISC 1.1 Arch Manual.
490 * It's been carried forward into PA 2.0 Arch as well. :^(
491 *
492 * "ssm 0,%r0" is a NOP with side effects (prefetch barrier).
493 * rsm/ssm prevents the ifetch unit from speculatively fetching
494 * instructions past this line in the code stream.
495 * PA 2.0 processor will single step all insn in the same QUAD (4 insn).
496 */
497 .macro pcxt_ssm_bug
498 rsm PSW_SM_I,%r0
499 nop /* 1 */
500 nop /* 2 */
501 nop /* 3 */
502 nop /* 4 */
503 nop /* 5 */
504 nop /* 6 */
505 nop /* 7 */
506 .endm
507
453#endif /* __ASSEMBLY__ */ 508#endif /* __ASSEMBLY__ */
454#endif 509#endif
diff --git a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h
index af7db694b22d..55b98c67fd82 100644
--- a/include/asm-parisc/bitops.h
+++ b/include/asm-parisc/bitops.h
@@ -2,7 +2,7 @@
2#define _PARISC_BITOPS_H 2#define _PARISC_BITOPS_H
3 3
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <asm/spinlock.h> 5#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */
6#include <asm/byteorder.h> 6#include <asm/byteorder.h>
7#include <asm/atomic.h> 7#include <asm/atomic.h>
8 8
@@ -12,193 +12,157 @@
12 * to include/asm-i386/bitops.h or kerneldoc 12 * to include/asm-i386/bitops.h or kerneldoc
13 */ 13 */
14 14
15#ifdef __LP64__ 15#define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
16# define SHIFT_PER_LONG 6
17#ifndef BITS_PER_LONG
18# define BITS_PER_LONG 64
19#endif
20#else
21# define SHIFT_PER_LONG 5
22#ifndef BITS_PER_LONG
23# define BITS_PER_LONG 32
24#endif
25#endif
26
27#define CHOP_SHIFTCOUNT(x) ((x) & (BITS_PER_LONG - 1))
28 16
29 17
30#define smp_mb__before_clear_bit() smp_mb() 18#define smp_mb__before_clear_bit() smp_mb()
31#define smp_mb__after_clear_bit() smp_mb() 19#define smp_mb__after_clear_bit() smp_mb()
32 20
33static __inline__ void set_bit(int nr, volatile unsigned long * address) 21/* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion
22 * on use of volatile and __*_bit() (set/clear/change):
23 * *_bit() want use of volatile.
24 * __*_bit() are "relaxed" and don't use spinlock or volatile.
25 */
26
27static __inline__ void set_bit(int nr, volatile unsigned long * addr)
34{ 28{
35 unsigned long mask; 29 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
36 unsigned long *addr = (unsigned long *) address;
37 unsigned long flags; 30 unsigned long flags;
38 31
39 addr += (nr >> SHIFT_PER_LONG); 32 addr += (nr >> SHIFT_PER_LONG);
40 mask = 1L << CHOP_SHIFTCOUNT(nr);
41 _atomic_spin_lock_irqsave(addr, flags); 33 _atomic_spin_lock_irqsave(addr, flags);
42 *addr |= mask; 34 *addr |= mask;
43 _atomic_spin_unlock_irqrestore(addr, flags); 35 _atomic_spin_unlock_irqrestore(addr, flags);
44} 36}
45 37
46static __inline__ void __set_bit(int nr, volatile unsigned long * address) 38static __inline__ void __set_bit(unsigned long nr, volatile unsigned long * addr)
47{ 39{
48 unsigned long mask; 40 unsigned long *m = (unsigned long *) addr + (nr >> SHIFT_PER_LONG);
49 unsigned long *addr = (unsigned long *) address;
50 41
51 addr += (nr >> SHIFT_PER_LONG); 42 *m |= 1UL << CHOP_SHIFTCOUNT(nr);
52 mask = 1L << CHOP_SHIFTCOUNT(nr);
53 *addr |= mask;
54} 43}
55 44
56static __inline__ void clear_bit(int nr, volatile unsigned long * address) 45static __inline__ void clear_bit(int nr, volatile unsigned long * addr)
57{ 46{
58 unsigned long mask; 47 unsigned long mask = ~(1UL << CHOP_SHIFTCOUNT(nr));
59 unsigned long *addr = (unsigned long *) address;
60 unsigned long flags; 48 unsigned long flags;
61 49
62 addr += (nr >> SHIFT_PER_LONG); 50 addr += (nr >> SHIFT_PER_LONG);
63 mask = 1L << CHOP_SHIFTCOUNT(nr);
64 _atomic_spin_lock_irqsave(addr, flags); 51 _atomic_spin_lock_irqsave(addr, flags);
65 *addr &= ~mask; 52 *addr &= mask;
66 _atomic_spin_unlock_irqrestore(addr, flags); 53 _atomic_spin_unlock_irqrestore(addr, flags);
67} 54}
68 55
69static __inline__ void __clear_bit(unsigned long nr, volatile unsigned long * address) 56static __inline__ void __clear_bit(unsigned long nr, volatile unsigned long * addr)
70{ 57{
71 unsigned long mask; 58 unsigned long *m = (unsigned long *) addr + (nr >> SHIFT_PER_LONG);
72 unsigned long *addr = (unsigned long *) address;
73 59
74 addr += (nr >> SHIFT_PER_LONG); 60 *m &= ~(1UL << CHOP_SHIFTCOUNT(nr));
75 mask = 1L << CHOP_SHIFTCOUNT(nr);
76 *addr &= ~mask;
77} 61}
78 62
79static __inline__ void change_bit(int nr, volatile unsigned long * address) 63static __inline__ void change_bit(int nr, volatile unsigned long * addr)
80{ 64{
81 unsigned long mask; 65 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
82 unsigned long *addr = (unsigned long *) address;
83 unsigned long flags; 66 unsigned long flags;
84 67
85 addr += (nr >> SHIFT_PER_LONG); 68 addr += (nr >> SHIFT_PER_LONG);
86 mask = 1L << CHOP_SHIFTCOUNT(nr);
87 _atomic_spin_lock_irqsave(addr, flags); 69 _atomic_spin_lock_irqsave(addr, flags);
88 *addr ^= mask; 70 *addr ^= mask;
89 _atomic_spin_unlock_irqrestore(addr, flags); 71 _atomic_spin_unlock_irqrestore(addr, flags);
90} 72}
91 73
92static __inline__ void __change_bit(int nr, volatile unsigned long * address) 74static __inline__ void __change_bit(unsigned long nr, volatile unsigned long * addr)
93{ 75{
94 unsigned long mask; 76 unsigned long *m = (unsigned long *) addr + (nr >> SHIFT_PER_LONG);
95 unsigned long *addr = (unsigned long *) address;
96 77
97 addr += (nr >> SHIFT_PER_LONG); 78 *m ^= 1UL << CHOP_SHIFTCOUNT(nr);
98 mask = 1L << CHOP_SHIFTCOUNT(nr);
99 *addr ^= mask;
100} 79}
101 80
102static __inline__ int test_and_set_bit(int nr, volatile unsigned long * address) 81static __inline__ int test_and_set_bit(int nr, volatile unsigned long * addr)
103{ 82{
104 unsigned long mask; 83 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
105 unsigned long *addr = (unsigned long *) address; 84 unsigned long oldbit;
106 int oldbit;
107 unsigned long flags; 85 unsigned long flags;
108 86
109 addr += (nr >> SHIFT_PER_LONG); 87 addr += (nr >> SHIFT_PER_LONG);
110 mask = 1L << CHOP_SHIFTCOUNT(nr);
111 _atomic_spin_lock_irqsave(addr, flags); 88 _atomic_spin_lock_irqsave(addr, flags);
112 oldbit = (*addr & mask) ? 1 : 0; 89 oldbit = *addr;
113 *addr |= mask; 90 *addr = oldbit | mask;
114 _atomic_spin_unlock_irqrestore(addr, flags); 91 _atomic_spin_unlock_irqrestore(addr, flags);
115 92
116 return oldbit; 93 return (oldbit & mask) ? 1 : 0;
117} 94}
118 95
119static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * address) 96static __inline__ int __test_and_set_bit(int nr, volatile unsigned long * address)
120{ 97{
121 unsigned long mask; 98 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
122 unsigned long *addr = (unsigned long *) address; 99 unsigned long oldbit;
123 int oldbit; 100 unsigned long *addr = (unsigned long *)address + (nr >> SHIFT_PER_LONG);
124 101
125 addr += (nr >> SHIFT_PER_LONG); 102 oldbit = *addr;
126 mask = 1L << CHOP_SHIFTCOUNT(nr); 103 *addr = oldbit | mask;
127 oldbit = (*addr & mask) ? 1 : 0;
128 *addr |= mask;
129 104
130 return oldbit; 105 return (oldbit & mask) ? 1 : 0;
131} 106}
132 107
133static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * address) 108static __inline__ int test_and_clear_bit(int nr, volatile unsigned long * addr)
134{ 109{
135 unsigned long mask; 110 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
136 unsigned long *addr = (unsigned long *) address; 111 unsigned long oldbit;
137 int oldbit;
138 unsigned long flags; 112 unsigned long flags;
139 113
140 addr += (nr >> SHIFT_PER_LONG); 114 addr += (nr >> SHIFT_PER_LONG);
141 mask = 1L << CHOP_SHIFTCOUNT(nr);
142 _atomic_spin_lock_irqsave(addr, flags); 115 _atomic_spin_lock_irqsave(addr, flags);
143 oldbit = (*addr & mask) ? 1 : 0; 116 oldbit = *addr;
144 *addr &= ~mask; 117 *addr = oldbit & ~mask;
145 _atomic_spin_unlock_irqrestore(addr, flags); 118 _atomic_spin_unlock_irqrestore(addr, flags);
146 119
147 return oldbit; 120 return (oldbit & mask) ? 1 : 0;
148} 121}
149 122
150static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long * address) 123static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long * address)
151{ 124{
152 unsigned long mask; 125 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
153 unsigned long *addr = (unsigned long *) address; 126 unsigned long *addr = (unsigned long *)address + (nr >> SHIFT_PER_LONG);
154 int oldbit; 127 unsigned long oldbit;
155 128
156 addr += (nr >> SHIFT_PER_LONG); 129 oldbit = *addr;
157 mask = 1L << CHOP_SHIFTCOUNT(nr); 130 *addr = oldbit & ~mask;
158 oldbit = (*addr & mask) ? 1 : 0;
159 *addr &= ~mask;
160 131
161 return oldbit; 132 return (oldbit & mask) ? 1 : 0;
162} 133}
163 134
164static __inline__ int test_and_change_bit(int nr, volatile unsigned long * address) 135static __inline__ int test_and_change_bit(int nr, volatile unsigned long * addr)
165{ 136{
166 unsigned long mask; 137 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
167 unsigned long *addr = (unsigned long *) address; 138 unsigned long oldbit;
168 int oldbit;
169 unsigned long flags; 139 unsigned long flags;
170 140
171 addr += (nr >> SHIFT_PER_LONG); 141 addr += (nr >> SHIFT_PER_LONG);
172 mask = 1L << CHOP_SHIFTCOUNT(nr);
173 _atomic_spin_lock_irqsave(addr, flags); 142 _atomic_spin_lock_irqsave(addr, flags);
174 oldbit = (*addr & mask) ? 1 : 0; 143 oldbit = *addr;
175 *addr ^= mask; 144 *addr = oldbit ^ mask;
176 _atomic_spin_unlock_irqrestore(addr, flags); 145 _atomic_spin_unlock_irqrestore(addr, flags);
177 146
178 return oldbit; 147 return (oldbit & mask) ? 1 : 0;
179} 148}
180 149
181static __inline__ int __test_and_change_bit(int nr, volatile unsigned long * address) 150static __inline__ int __test_and_change_bit(int nr, volatile unsigned long * address)
182{ 151{
183 unsigned long mask; 152 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
184 unsigned long *addr = (unsigned long *) address; 153 unsigned long *addr = (unsigned long *)address + (nr >> SHIFT_PER_LONG);
185 int oldbit; 154 unsigned long oldbit;
186 155
187 addr += (nr >> SHIFT_PER_LONG); 156 oldbit = *addr;
188 mask = 1L << CHOP_SHIFTCOUNT(nr); 157 *addr = oldbit ^ mask;
189 oldbit = (*addr & mask) ? 1 : 0;
190 *addr ^= mask;
191 158
192 return oldbit; 159 return (oldbit & mask) ? 1 : 0;
193} 160}
194 161
195static __inline__ int test_bit(int nr, const volatile unsigned long *address) 162static __inline__ int test_bit(int nr, const volatile unsigned long *address)
196{ 163{
197 unsigned long mask; 164 unsigned long mask = 1UL << CHOP_SHIFTCOUNT(nr);
198 const unsigned long *addr = (const unsigned long *)address; 165 const unsigned long *addr = (const unsigned long *)address + (nr >> SHIFT_PER_LONG);
199
200 addr += (nr >> SHIFT_PER_LONG);
201 mask = 1L << CHOP_SHIFTCOUNT(nr);
202 166
203 return !!(*addr & mask); 167 return !!(*addr & mask);
204} 168}
@@ -229,7 +193,7 @@ static __inline__ unsigned long __ffs(unsigned long x)
229 unsigned long ret; 193 unsigned long ret;
230 194
231 __asm__( 195 __asm__(
232#if BITS_PER_LONG > 32 196#ifdef __LP64__
233 " ldi 63,%1\n" 197 " ldi 63,%1\n"
234 " extrd,u,*<> %0,63,32,%%r0\n" 198 " extrd,u,*<> %0,63,32,%%r0\n"
235 " extrd,u,*TR %0,31,32,%0\n" /* move top 32-bits down */ 199 " extrd,u,*TR %0,31,32,%0\n" /* move top 32-bits down */
@@ -304,14 +268,7 @@ static __inline__ int fls(int x)
304 * hweightN: returns the hamming weight (i.e. the number 268 * hweightN: returns the hamming weight (i.e. the number
305 * of bits set) of a N-bit word 269 * of bits set) of a N-bit word
306 */ 270 */
307#define hweight64(x) \ 271#define hweight64(x) generic_hweight64(x)
308({ \
309 unsigned long __x = (x); \
310 unsigned int __w; \
311 __w = generic_hweight32((unsigned int) __x); \
312 __w += generic_hweight32((unsigned int) (__x>>32)); \
313 __w; \
314})
315#define hweight32(x) generic_hweight32(x) 272#define hweight32(x) generic_hweight32(x)
316#define hweight16(x) generic_hweight16(x) 273#define hweight16(x) generic_hweight16(x)
317#define hweight8(x) generic_hweight8(x) 274#define hweight8(x) generic_hweight8(x)
@@ -324,7 +281,13 @@ static __inline__ int fls(int x)
324 */ 281 */
325static inline int sched_find_first_bit(const unsigned long *b) 282static inline int sched_find_first_bit(const unsigned long *b)
326{ 283{
327#ifndef __LP64__ 284#ifdef __LP64__
285 if (unlikely(b[0]))
286 return __ffs(b[0]);
287 if (unlikely(b[1]))
288 return __ffs(b[1]) + 64;
289 return __ffs(b[2]) + 128;
290#else
328 if (unlikely(b[0])) 291 if (unlikely(b[0]))
329 return __ffs(b[0]); 292 return __ffs(b[0]);
330 if (unlikely(b[1])) 293 if (unlikely(b[1]))
@@ -334,14 +297,6 @@ static inline int sched_find_first_bit(const unsigned long *b)
334 if (b[3]) 297 if (b[3])
335 return __ffs(b[3]) + 96; 298 return __ffs(b[3]) + 96;
336 return __ffs(b[4]) + 128; 299 return __ffs(b[4]) + 128;
337#else
338 if (unlikely(b[0]))
339 return __ffs(b[0]);
340 if (unlikely(((unsigned int)b[1])))
341 return __ffs(b[1]) + 64;
342 if (b[1] >> 32)
343 return __ffs(b[1] >> 32) + 96;
344 return __ffs(b[2]) + 128;
345#endif 300#endif
346} 301}
347 302
@@ -391,7 +346,7 @@ found_middle:
391 346
392static __inline__ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) 347static __inline__ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset)
393{ 348{
394 const unsigned long *p = addr + (offset >> 6); 349 const unsigned long *p = addr + (offset >> SHIFT_PER_LONG);
395 unsigned long result = offset & ~(BITS_PER_LONG-1); 350 unsigned long result = offset & ~(BITS_PER_LONG-1);
396 unsigned long tmp; 351 unsigned long tmp;
397 352
@@ -445,71 +400,90 @@ found_middle:
445 * test_and_{set,clear}_bit guarantee atomicity without 400 * test_and_{set,clear}_bit guarantee atomicity without
446 * disabling interrupts. 401 * disabling interrupts.
447 */ 402 */
448#ifdef __LP64__
449#define ext2_set_bit(nr, addr) __test_and_set_bit((nr) ^ 0x38, (unsigned long *)addr)
450#define ext2_set_bit_atomic(l,nr,addr) test_and_set_bit((nr) ^ 0x38, (unsigned long *)addr)
451#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 0x38, (unsigned long *)addr)
452#define ext2_clear_bit_atomic(l,nr,addr) test_and_clear_bit((nr) ^ 0x38, (unsigned long *)addr)
453#else
454#define ext2_set_bit(nr, addr) __test_and_set_bit((nr) ^ 0x18, (unsigned long *)addr)
455#define ext2_set_bit_atomic(l,nr,addr) test_and_set_bit((nr) ^ 0x18, (unsigned long *)addr)
456#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 0x18, (unsigned long *)addr)
457#define ext2_clear_bit_atomic(l,nr,addr) test_and_clear_bit((nr) ^ 0x18, (unsigned long *)addr)
458#endif
459 403
460#endif /* __KERNEL__ */ 404/* '3' is bits per byte */
405#define LE_BYTE_ADDR ((sizeof(unsigned long) - 1) << 3)
461 406
462static __inline__ int ext2_test_bit(int nr, __const__ void * addr) 407#define ext2_test_bit(nr, addr) \
463{ 408 test_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
464 __const__ unsigned char *ADDR = (__const__ unsigned char *) addr; 409#define ext2_set_bit(nr, addr) \
410 __test_and_set_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
411#define ext2_clear_bit(nr, addr) \
412 __test_and_clear_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
465 413
466 return (ADDR[nr >> 3] >> (nr & 7)) & 1; 414#define ext2_set_bit_atomic(l,nr,addr) \
467} 415 test_and_set_bit((nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
416#define ext2_clear_bit_atomic(l,nr,addr) \
417 test_and_clear_bit( (nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
418
419#endif /* __KERNEL__ */
468 420
469/*
470 * This implementation of ext2_find_{first,next}_zero_bit was stolen from
471 * Linus' asm-alpha/bitops.h and modified for a big-endian machine.
472 */
473 421
474#define ext2_find_first_zero_bit(addr, size) \ 422#define ext2_find_first_zero_bit(addr, size) \
475 ext2_find_next_zero_bit((addr), (size), 0) 423 ext2_find_next_zero_bit((addr), (size), 0)
476 424
477extern __inline__ unsigned long ext2_find_next_zero_bit(void *addr, 425/* include/linux/byteorder does not support "unsigned long" type */
478 unsigned long size, unsigned long offset) 426static inline unsigned long ext2_swabp(unsigned long * x)
479{ 427{
480 unsigned int *p = ((unsigned int *) addr) + (offset >> 5); 428#ifdef __LP64__
481 unsigned int result = offset & ~31UL; 429 return (unsigned long) __swab64p((u64 *) x);
482 unsigned int tmp; 430#else
431 return (unsigned long) __swab32p((u32 *) x);
432#endif
433}
434
435/* include/linux/byteorder doesn't support "unsigned long" type */
436static inline unsigned long ext2_swab(unsigned long y)
437{
438#ifdef __LP64__
439 return (unsigned long) __swab64((u64) y);
440#else
441 return (unsigned long) __swab32((u32) y);
442#endif
443}
444
445static __inline__ unsigned long ext2_find_next_zero_bit(void *addr, unsigned long size, unsigned long offset)
446{
447 unsigned long *p = (unsigned long *) addr + (offset >> SHIFT_PER_LONG);
448 unsigned long result = offset & ~(BITS_PER_LONG - 1);
449 unsigned long tmp;
483 450
484 if (offset >= size) 451 if (offset >= size)
485 return size; 452 return size;
486 size -= result; 453 size -= result;
487 offset &= 31UL; 454 offset &= (BITS_PER_LONG - 1UL);
488 if (offset) { 455 if (offset) {
489 tmp = cpu_to_le32p(p++); 456 tmp = ext2_swabp(p++);
490 tmp |= ~0UL >> (32-offset); 457 tmp |= (~0UL >> (BITS_PER_LONG - offset));
491 if (size < 32) 458 if (size < BITS_PER_LONG)
492 goto found_first; 459 goto found_first;
493 if (tmp != ~0U) 460 if (~tmp)
494 goto found_middle; 461 goto found_middle;
495 size -= 32; 462 size -= BITS_PER_LONG;
496 result += 32; 463 result += BITS_PER_LONG;
497 } 464 }
498 while (size >= 32) { 465
499 if ((tmp = cpu_to_le32p(p++)) != ~0U) 466 while (size & ~(BITS_PER_LONG - 1)) {
500 goto found_middle; 467 if (~(tmp = *(p++)))
501 result += 32; 468 goto found_middle_swap;
502 size -= 32; 469 result += BITS_PER_LONG;
470 size -= BITS_PER_LONG;
503 } 471 }
504 if (!size) 472 if (!size)
505 return result; 473 return result;
506 tmp = cpu_to_le32p(p); 474 tmp = ext2_swabp(p);
507found_first: 475found_first:
508 tmp |= ~0U << size; 476 tmp |= ~0UL << size;
477 if (tmp == ~0UL) /* Are any bits zero? */
478 return result + size; /* Nope. Skip ffz */
509found_middle: 479found_middle:
510 return result + ffz(tmp); 480 return result + ffz(tmp);
481
482found_middle_swap:
483 return result + ffz(ext2_swab(tmp));
511} 484}
512 485
486
513/* Bitmap functions for the minix filesystem. */ 487/* Bitmap functions for the minix filesystem. */
514#define minix_test_and_set_bit(nr,addr) ext2_set_bit(nr,addr) 488#define minix_test_and_set_bit(nr,addr) ext2_set_bit(nr,addr)
515#define minix_set_bit(nr,addr) ((void)ext2_set_bit(nr,addr)) 489#define minix_set_bit(nr,addr) ((void)ext2_set_bit(nr,addr))
diff --git a/include/asm-parisc/dma-mapping.h b/include/asm-parisc/dma-mapping.h
index 4db84f969e9e..74d4ac6f2151 100644
--- a/include/asm-parisc/dma-mapping.h
+++ b/include/asm-parisc/dma-mapping.h
@@ -9,8 +9,8 @@
9/* See Documentation/DMA-mapping.txt */ 9/* See Documentation/DMA-mapping.txt */
10struct hppa_dma_ops { 10struct hppa_dma_ops {
11 int (*dma_supported)(struct device *dev, u64 mask); 11 int (*dma_supported)(struct device *dev, u64 mask);
12 void *(*alloc_consistent)(struct device *dev, size_t size, dma_addr_t *iova, int flag); 12 void *(*alloc_consistent)(struct device *dev, size_t size, dma_addr_t *iova, gfp_t flag);
13 void *(*alloc_noncoherent)(struct device *dev, size_t size, dma_addr_t *iova, int flag); 13 void *(*alloc_noncoherent)(struct device *dev, size_t size, dma_addr_t *iova, gfp_t flag);
14 void (*free_consistent)(struct device *dev, size_t size, void *vaddr, dma_addr_t iova); 14 void (*free_consistent)(struct device *dev, size_t size, void *vaddr, dma_addr_t iova);
15 dma_addr_t (*map_single)(struct device *dev, void *addr, size_t size, enum dma_data_direction direction); 15 dma_addr_t (*map_single)(struct device *dev, void *addr, size_t size, enum dma_data_direction direction);
16 void (*unmap_single)(struct device *dev, dma_addr_t iova, size_t size, enum dma_data_direction direction); 16 void (*unmap_single)(struct device *dev, dma_addr_t iova, size_t size, enum dma_data_direction direction);
@@ -49,14 +49,14 @@ extern struct hppa_dma_ops *hppa_dma_ops;
49 49
50static inline void * 50static inline void *
51dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 51dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
52 int flag) 52 gfp_t flag)
53{ 53{
54 return hppa_dma_ops->alloc_consistent(dev, size, dma_handle, flag); 54 return hppa_dma_ops->alloc_consistent(dev, size, dma_handle, flag);
55} 55}
56 56
57static inline void * 57static inline void *
58dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 58dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
59 int flag) 59 gfp_t flag)
60{ 60{
61 return hppa_dma_ops->alloc_noncoherent(dev, size, dma_handle, flag); 61 return hppa_dma_ops->alloc_noncoherent(dev, size, dma_handle, flag);
62} 62}
diff --git a/include/asm-parisc/errno.h b/include/asm-parisc/errno.h
index 08464c405471..e2f3ddc796be 100644
--- a/include/asm-parisc/errno.h
+++ b/include/asm-parisc/errno.h
@@ -114,6 +114,7 @@
114 114
115#define ENOTSUP 252 /* Function not implemented (POSIX.4 / HPUX) */ 115#define ENOTSUP 252 /* Function not implemented (POSIX.4 / HPUX) */
116#define ECANCELLED 253 /* aio request was canceled before complete (POSIX.4 / HPUX) */ 116#define ECANCELLED 253 /* aio request was canceled before complete (POSIX.4 / HPUX) */
117#define ECANCELED ECANCELLED /* SuSv3 and Solaris wants one 'L' */
117 118
118/* for robust mutexes */ 119/* for robust mutexes */
119#define EOWNERDEAD 254 /* Owner died */ 120#define EOWNERDEAD 254 /* Owner died */
diff --git a/include/asm-parisc/grfioctl.h b/include/asm-parisc/grfioctl.h
index d3cfc0168fb1..6a910311b56b 100644
--- a/include/asm-parisc/grfioctl.h
+++ b/include/asm-parisc/grfioctl.h
@@ -69,6 +69,8 @@
69#define CRT_ID_TVRX S9000_ID_98765 /* TVRX (gto/falcon) */ 69#define CRT_ID_TVRX S9000_ID_98765 /* TVRX (gto/falcon) */
70#define CRT_ID_ARTIST S9000_ID_ARTIST /* Artist */ 70#define CRT_ID_ARTIST S9000_ID_ARTIST /* Artist */
71#define CRT_ID_SUMMIT 0x2FC1066B /* Summit FX2, FX4, FX6 ... */ 71#define CRT_ID_SUMMIT 0x2FC1066B /* Summit FX2, FX4, FX6 ... */
72#define CRT_ID_LEGO 0x35ACDA30 /* Lego FX5, FX10 ... */
73#define CRT_ID_PINNACLE 0x35ACDA16 /* Pinnacle FXe */
72 74
73/* structure for ioctl(GCDESCRIBE) */ 75/* structure for ioctl(GCDESCRIBE) */
74 76
diff --git a/include/asm-parisc/led.h b/include/asm-parisc/led.h
index 1ac8ab6c580d..efadfd543ec6 100644
--- a/include/asm-parisc/led.h
+++ b/include/asm-parisc/led.h
@@ -23,9 +23,6 @@
23 23
24#define LED_CMD_REG_NONE 0 /* NULL == no addr for the cmd register */ 24#define LED_CMD_REG_NONE 0 /* NULL == no addr for the cmd register */
25 25
26/* led tasklet struct */
27extern struct tasklet_struct led_tasklet;
28
29/* register_led_driver() */ 26/* register_led_driver() */
30int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long data_reg); 27int __init register_led_driver(int model, unsigned long cmd_reg, unsigned long data_reg);
31 28
diff --git a/include/asm-parisc/parisc-device.h b/include/asm-parisc/parisc-device.h
index ef69ab4b17a9..1d247e32a608 100644
--- a/include/asm-parisc/parisc-device.h
+++ b/include/asm-parisc/parisc-device.h
@@ -1,7 +1,7 @@
1#include <linux/device.h> 1#include <linux/device.h>
2 2
3struct parisc_device { 3struct parisc_device {
4 unsigned long hpa; /* Hard Physical Address */ 4 struct resource hpa; /* Hard Physical Address */
5 struct parisc_device_id id; 5 struct parisc_device_id id;
6 struct parisc_driver *driver; /* Driver for this device */ 6 struct parisc_driver *driver; /* Driver for this device */
7 char name[80]; /* The hardware description */ 7 char name[80]; /* The hardware description */
@@ -39,6 +39,11 @@ struct parisc_driver {
39#define to_parisc_driver(d) container_of(d, struct parisc_driver, drv) 39#define to_parisc_driver(d) container_of(d, struct parisc_driver, drv)
40#define parisc_parent(d) to_parisc_device(d->dev.parent) 40#define parisc_parent(d) to_parisc_device(d->dev.parent)
41 41
42static inline char *parisc_pathname(struct parisc_device *d)
43{
44 return d->dev.bus_id;
45}
46
42static inline void 47static inline void
43parisc_set_drvdata(struct parisc_device *d, void *p) 48parisc_set_drvdata(struct parisc_device *d, void *p)
44{ 49{
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h
index d0b761f690b5..fa39d07d49e9 100644
--- a/include/asm-parisc/pci.h
+++ b/include/asm-parisc/pci.h
@@ -69,7 +69,7 @@ struct pci_hba_data {
69#define PCI_PORT_HBA(a) ((a) >> HBA_PORT_SPACE_BITS) 69#define PCI_PORT_HBA(a) ((a) >> HBA_PORT_SPACE_BITS)
70#define PCI_PORT_ADDR(a) ((a) & (HBA_PORT_SPACE_SIZE - 1)) 70#define PCI_PORT_ADDR(a) ((a) & (HBA_PORT_SPACE_SIZE - 1))
71 71
72#if CONFIG_64BIT 72#ifdef CONFIG_64BIT
73#define PCI_F_EXTEND 0xffffffff00000000UL 73#define PCI_F_EXTEND 0xffffffff00000000UL
74#define PCI_IS_LMMIO(hba,a) pci_is_lmmio(hba,a) 74#define PCI_IS_LMMIO(hba,a) pci_is_lmmio(hba,a)
75 75
diff --git a/include/asm-parisc/pgtable.h b/include/asm-parisc/pgtable.h
index 820c6e712cd7..c28fb6f48c6c 100644
--- a/include/asm-parisc/pgtable.h
+++ b/include/asm-parisc/pgtable.h
@@ -501,6 +501,8 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
501#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 501#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
502 remap_pfn_range(vma, vaddr, pfn, size, prot) 502 remap_pfn_range(vma, vaddr, pfn, size, prot)
503 503
504#define pgprot_noncached(prot) __pgprot(pgprot_val(prot) | _PAGE_NO_CACHE)
505
504#define MK_IOSPACE_PFN(space, pfn) (pfn) 506#define MK_IOSPACE_PFN(space, pfn) (pfn)
505#define GET_IOSPACE(pfn) 0 507#define GET_IOSPACE(pfn) 0
506#define GET_PFN(pfn) (pfn) 508#define GET_PFN(pfn) (pfn)
diff --git a/include/asm-parisc/processor.h b/include/asm-parisc/processor.h
index a9dfadd05658..aae40e8c3aa8 100644
--- a/include/asm-parisc/processor.h
+++ b/include/asm-parisc/processor.h
@@ -122,8 +122,27 @@ struct thread_struct {
122}; 122};
123 123
124/* Thread struct flags. */ 124/* Thread struct flags. */
125#define PARISC_UAC_NOPRINT (1UL << 0) /* see prctl and unaligned.c */
126#define PARISC_UAC_SIGBUS (1UL << 1)
125#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */ 127#define PARISC_KERNEL_DEATH (1UL << 31) /* see die_if_kernel()... */
126 128
129#define PARISC_UAC_SHIFT 0
130#define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS)
131
132#define SET_UNALIGN_CTL(task,value) \
133 ({ \
134 (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \
135 | (((value) << PARISC_UAC_SHIFT) & \
136 PARISC_UAC_MASK)); \
137 0; \
138 })
139
140#define GET_UNALIGN_CTL(task,addr) \
141 ({ \
142 put_user(((task)->thread.flags & PARISC_UAC_MASK) \
143 >> PARISC_UAC_SHIFT, (int __user *) (addr)); \
144 })
145
127#define INIT_THREAD { \ 146#define INIT_THREAD { \
128 regs: { gr: { 0, }, \ 147 regs: { gr: { 0, }, \
129 fr: { 0, }, \ 148 fr: { 0, }, \
diff --git a/include/asm-parisc/psw.h b/include/asm-parisc/psw.h
index 51323029f377..4334d6ca2add 100644
--- a/include/asm-parisc/psw.h
+++ b/include/asm-parisc/psw.h
@@ -1,4 +1,7 @@
1#ifndef _PARISC_PSW_H 1#ifndef _PARISC_PSW_H
2
3#include <linux/config.h>
4
2#define PSW_I 0x00000001 5#define PSW_I 0x00000001
3#define PSW_D 0x00000002 6#define PSW_D 0x00000002
4#define PSW_P 0x00000004 7#define PSW_P 0x00000004
@@ -9,6 +12,16 @@
9#define PSW_G 0x00000040 /* PA1.x only */ 12#define PSW_G 0x00000040 /* PA1.x only */
10#define PSW_O 0x00000080 /* PA2.0 only */ 13#define PSW_O 0x00000080 /* PA2.0 only */
11 14
15/* ssm/rsm instructions number PSW_W and PSW_E differently */
16#define PSW_SM_I PSW_I /* Enable External Interrupts */
17#define PSW_SM_D PSW_D
18#define PSW_SM_P PSW_P
19#define PSW_SM_Q PSW_Q /* Enable Interrupt State Collection */
20#define PSW_SM_R PSW_R /* Enable Recover Counter Trap */
21#define PSW_SM_W 0x200 /* PA2.0 only : Enable Wide Mode */
22
23#define PSW_SM_QUIET PSW_SM_R+PSW_SM_Q+PSW_SM_P+PSW_SM_D+PSW_SM_I
24
12#define PSW_CB 0x0000ff00 25#define PSW_CB 0x0000ff00
13 26
14#define PSW_M 0x00010000 27#define PSW_M 0x00010000
@@ -30,33 +43,21 @@
30#define PSW_Z 0x40000000 /* PA1.x only */ 43#define PSW_Z 0x40000000 /* PA1.x only */
31#define PSW_Y 0x80000000 /* PA1.x only */ 44#define PSW_Y 0x80000000 /* PA1.x only */
32 45
33#ifdef __LP64__ 46#ifdef CONFIG_64BIT
34#define PSW_HI_CB 0x000000ff /* PA2.0 only */ 47# define PSW_HI_CB 0x000000ff /* PA2.0 only */
35#endif 48#endif
36 49
37/* PSW bits to be used with ssm/rsm */ 50#ifdef CONFIG_64BIT
38#define PSW_SM_I 0x1 51# define USER_PSW_HI_MASK PSW_HI_CB
39#define PSW_SM_D 0x2 52# define WIDE_PSW PSW_W
40#define PSW_SM_P 0x4 53#else
41#define PSW_SM_Q 0x8 54# define WIDE_PSW 0
42#define PSW_SM_R 0x10
43#define PSW_SM_F 0x20
44#define PSW_SM_G 0x40
45#define PSW_SM_O 0x80
46#define PSW_SM_E 0x100
47#define PSW_SM_W 0x200
48
49#ifdef __LP64__
50# define USER_PSW (PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I)
51# define KERNEL_PSW (PSW_W | PSW_C | PSW_Q | PSW_P | PSW_D)
52# define REAL_MODE_PSW (PSW_W | PSW_Q)
53# define USER_PSW_MASK (PSW_W | PSW_T | PSW_N | PSW_X | PSW_B | PSW_V | PSW_CB)
54# define USER_PSW_HI_MASK (PSW_HI_CB)
55#else
56# define USER_PSW (PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I)
57# define KERNEL_PSW (PSW_C | PSW_Q | PSW_P | PSW_D)
58# define REAL_MODE_PSW (PSW_Q)
59# define USER_PSW_MASK (PSW_T | PSW_N | PSW_X | PSW_B | PSW_V | PSW_CB)
60#endif 55#endif
61 56
57/* Used when setting up for rfi */
58#define KERNEL_PSW (WIDE_PSW | PSW_C | PSW_Q | PSW_P | PSW_D)
59#define REAL_MODE_PSW (WIDE_PSW | PSW_Q)
60#define USER_PSW_MASK (WIDE_PSW | PSW_T | PSW_N | PSW_X | PSW_B | PSW_V | PSW_CB)
61#define USER_PSW (PSW_C | PSW_Q | PSW_P | PSW_D | PSW_I)
62
62#endif 63#endif
diff --git a/include/asm-parisc/ptrace.h b/include/asm-parisc/ptrace.h
index 3f428aa371a4..93f990e418f1 100644
--- a/include/asm-parisc/ptrace.h
+++ b/include/asm-parisc/ptrace.h
@@ -49,7 +49,7 @@ struct pt_regs {
49#define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0) 49#define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0)
50#define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0) 50#define user_space(regs) (((regs)->iasq[1] != 0) ? 1 : 0)
51#define instruction_pointer(regs) ((regs)->iaoq[0] & ~3) 51#define instruction_pointer(regs) ((regs)->iaoq[0] & ~3)
52#define profile_pc(regs) instruction_pointer(regs) 52unsigned long profile_pc(struct pt_regs *);
53extern void show_regs(struct pt_regs *); 53extern void show_regs(struct pt_regs *);
54#endif 54#endif
55 55
diff --git a/include/asm-parisc/spinlock.h b/include/asm-parisc/spinlock.h
index 43eaa6e742e0..7c3f406a746a 100644
--- a/include/asm-parisc/spinlock.h
+++ b/include/asm-parisc/spinlock.h
@@ -5,11 +5,6 @@
5#include <asm/processor.h> 5#include <asm/processor.h>
6#include <asm/spinlock_types.h> 6#include <asm/spinlock_types.h>
7 7
8/* Note that PA-RISC has to use `1' to mean unlocked and `0' to mean locked
9 * since it only has load-and-zero. Moreover, at least on some PA processors,
10 * the semaphore address has to be 16-byte aligned.
11 */
12
13static inline int __raw_spin_is_locked(raw_spinlock_t *x) 8static inline int __raw_spin_is_locked(raw_spinlock_t *x)
14{ 9{
15 volatile unsigned int *a = __ldcw_align(x); 10 volatile unsigned int *a = __ldcw_align(x);
diff --git a/include/asm-parisc/spinlock_types.h b/include/asm-parisc/spinlock_types.h
index 785bba822fbf..d6b479bdb886 100644
--- a/include/asm-parisc/spinlock_types.h
+++ b/include/asm-parisc/spinlock_types.h
@@ -6,11 +6,15 @@
6#endif 6#endif
7 7
8typedef struct { 8typedef struct {
9#ifdef CONFIG_PA20
10 volatile unsigned int slock;
11# define __RAW_SPIN_LOCK_UNLOCKED { 1 }
12#else
9 volatile unsigned int lock[4]; 13 volatile unsigned int lock[4];
14# define __RAW_SPIN_LOCK_UNLOCKED { { 1, 1, 1, 1 } }
15#endif
10} raw_spinlock_t; 16} raw_spinlock_t;
11 17
12#define __RAW_SPIN_LOCK_UNLOCKED { { 1, 1, 1, 1 } }
13
14typedef struct { 18typedef struct {
15 raw_spinlock_t lock; 19 raw_spinlock_t lock;
16 volatile int counter; 20 volatile int counter;
diff --git a/include/asm-parisc/system.h b/include/asm-parisc/system.h
index 26ff844a21c1..f3928d3a80cb 100644
--- a/include/asm-parisc/system.h
+++ b/include/asm-parisc/system.h
@@ -138,13 +138,7 @@ static inline void set_eiem(unsigned long val)
138#define set_wmb(var, value) do { var = value; wmb(); } while (0) 138#define set_wmb(var, value) do { var = value; wmb(); } while (0)
139 139
140 140
141/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */ 141#ifndef CONFIG_PA20
142#define __ldcw(a) ({ \
143 unsigned __ret; \
144 __asm__ __volatile__("ldcw 0(%1),%0" : "=r" (__ret) : "r" (a)); \
145 __ret; \
146})
147
148/* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data, 142/* Because kmalloc only guarantees 8-byte alignment for kmalloc'd data,
149 and GCC only guarantees 8-byte alignment for stack locals, we can't 143 and GCC only guarantees 8-byte alignment for stack locals, we can't
150 be assured of 16-byte alignment for atomic lock data even if we 144 be assured of 16-byte alignment for atomic lock data even if we
@@ -152,37 +146,41 @@ static inline void set_eiem(unsigned long val)
152 we use a struct containing an array of four ints for the atomic lock 146 we use a struct containing an array of four ints for the atomic lock
153 type and dynamically select the 16-byte aligned int from the array 147 type and dynamically select the 16-byte aligned int from the array
154 for the semaphore. */ 148 for the semaphore. */
149
155#define __PA_LDCW_ALIGNMENT 16 150#define __PA_LDCW_ALIGNMENT 16
156#define __ldcw_align(a) ({ \ 151#define __ldcw_align(a) ({ \
157 unsigned long __ret = (unsigned long) &(a)->lock[0]; \ 152 unsigned long __ret = (unsigned long) &(a)->lock[0]; \
158 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \ 153 __ret = (__ret + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1); \
159 (volatile unsigned int *) __ret; \ 154 (volatile unsigned int *) __ret; \
160}) 155})
156#define LDCW "ldcw"
161 157
162#ifdef CONFIG_SMP 158#else /*CONFIG_PA20*/
163# define __lock_aligned __attribute__((__section__(".data.lock_aligned"))) 159/* From: "Jim Hull" <jim.hull of hp.com>
164#endif 160 I've attached a summary of the change, but basically, for PA 2.0, as
161 long as the ",CO" (coherent operation) completer is specified, then the
162 16-byte alignment requirement for ldcw and ldcd is relaxed, and instead
163 they only require "natural" alignment (4-byte for ldcw, 8-byte for
164 ldcd). */
165 165
166#define KERNEL_START (0x10100000 - 0x1000) 166#define __PA_LDCW_ALIGNMENT 4
167#define __ldcw_align(a) ((volatile unsigned int *)a)
168#define LDCW "ldcw,co"
167 169
168/* This is for the serialisation of PxTLB broadcasts. At least on the 170#endif /*!CONFIG_PA20*/
169 * N class systems, only one PxTLB inter processor broadcast can be
170 * active at any one time on the Merced bus. This tlb purge
171 * synchronisation is fairly lightweight and harmless so we activate
172 * it on all SMP systems not just the N class. */
173#ifdef CONFIG_SMP
174extern spinlock_t pa_tlb_lock;
175 171
176#define purge_tlb_start(x) spin_lock(&pa_tlb_lock) 172/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
177#define purge_tlb_end(x) spin_unlock(&pa_tlb_lock) 173#define __ldcw(a) ({ \
178 174 unsigned __ret; \
179#else 175 __asm__ __volatile__(LDCW " 0(%1),%0" : "=r" (__ret) : "r" (a)); \
180 176 __ret; \
181#define purge_tlb_start(x) do { } while(0) 177})
182#define purge_tlb_end(x) do { } while (0)
183 178
179#ifdef CONFIG_SMP
180# define __lock_aligned __attribute__((__section__(".data.lock_aligned")))
184#endif 181#endif
185 182
183#define KERNEL_START (0x10100000 - 0x1000)
186#define arch_align_stack(x) (x) 184#define arch_align_stack(x) (x)
187 185
188#endif 186#endif
diff --git a/include/asm-parisc/tlbflush.h b/include/asm-parisc/tlbflush.h
index eb27b78930e8..84af4ab1fe51 100644
--- a/include/asm-parisc/tlbflush.h
+++ b/include/asm-parisc/tlbflush.h
@@ -7,6 +7,26 @@
7#include <linux/mm.h> 7#include <linux/mm.h>
8#include <asm/mmu_context.h> 8#include <asm/mmu_context.h>
9 9
10
11/* This is for the serialisation of PxTLB broadcasts. At least on the
12 * N class systems, only one PxTLB inter processor broadcast can be
13 * active at any one time on the Merced bus. This tlb purge
14 * synchronisation is fairly lightweight and harmless so we activate
15 * it on all SMP systems not just the N class. */
16#ifdef CONFIG_SMP
17extern spinlock_t pa_tlb_lock;
18
19#define purge_tlb_start(x) spin_lock(&pa_tlb_lock)
20#define purge_tlb_end(x) spin_unlock(&pa_tlb_lock)
21
22#else
23
24#define purge_tlb_start(x) do { } while(0)
25#define purge_tlb_end(x) do { } while (0)
26
27#endif
28
29
10extern void flush_tlb_all(void); 30extern void flush_tlb_all(void);
11 31
12/* 32/*
@@ -64,29 +84,26 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
64{ 84{
65 unsigned long npages; 85 unsigned long npages;
66 86
67
68 npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT; 87 npages = ((end - (start & PAGE_MASK)) + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
69 if (npages >= 512) /* XXX arbitrary, should be tuned */ 88 if (npages >= 512) /* 2MB of space: arbitrary, should be tuned */
70 flush_tlb_all(); 89 flush_tlb_all();
71 else { 90 else {
72 91
73 mtsp(vma->vm_mm->context,1); 92 mtsp(vma->vm_mm->context,1);
93 purge_tlb_start();
74 if (split_tlb) { 94 if (split_tlb) {
75 purge_tlb_start();
76 while (npages--) { 95 while (npages--) {
77 pdtlb(start); 96 pdtlb(start);
78 pitlb(start); 97 pitlb(start);
79 start += PAGE_SIZE; 98 start += PAGE_SIZE;
80 } 99 }
81 purge_tlb_end();
82 } else { 100 } else {
83 purge_tlb_start();
84 while (npages--) { 101 while (npages--) {
85 pdtlb(start); 102 pdtlb(start);
86 start += PAGE_SIZE; 103 start += PAGE_SIZE;
87 } 104 }
88 purge_tlb_end();
89 } 105 }
106 purge_tlb_end();
90 } 107 }
91} 108}
92 109
diff --git a/include/asm-parisc/types.h b/include/asm-parisc/types.h
index d21b9d0d63ea..34fdce361a5a 100644
--- a/include/asm-parisc/types.h
+++ b/include/asm-parisc/types.h
@@ -33,8 +33,10 @@ typedef unsigned long long __u64;
33 33
34#ifdef __LP64__ 34#ifdef __LP64__
35#define BITS_PER_LONG 64 35#define BITS_PER_LONG 64
36#define SHIFT_PER_LONG 6
36#else 37#else
37#define BITS_PER_LONG 32 38#define BITS_PER_LONG 32
39#define SHIFT_PER_LONG 5
38#endif 40#endif
39 41
40#ifndef __ASSEMBLY__ 42#ifndef __ASSEMBLY__
diff --git a/include/asm-parisc/unistd.h b/include/asm-parisc/unistd.h
index 6a9f0cadff58..e7a620c5c5e6 100644
--- a/include/asm-parisc/unistd.h
+++ b/include/asm-parisc/unistd.h
@@ -687,8 +687,8 @@
687#define __NR_shmget (__NR_Linux + 194) 687#define __NR_shmget (__NR_Linux + 194)
688#define __NR_shmctl (__NR_Linux + 195) 688#define __NR_shmctl (__NR_Linux + 195)
689 689
690#define __NR_getpmsg (__NR_Linux + 196) /* some people actually want streams */ 690#define __NR_getpmsg (__NR_Linux + 196) /* Somebody *wants* streams? */
691#define __NR_putpmsg (__NR_Linux + 197) /* some people actually want streams */ 691#define __NR_putpmsg (__NR_Linux + 197)
692 692
693#define __NR_lstat64 (__NR_Linux + 198) 693#define __NR_lstat64 (__NR_Linux + 198)
694#define __NR_truncate64 (__NR_Linux + 199) 694#define __NR_truncate64 (__NR_Linux + 199)
@@ -755,8 +755,14 @@
755#define __NR_mbind (__NR_Linux + 260) 755#define __NR_mbind (__NR_Linux + 260)
756#define __NR_get_mempolicy (__NR_Linux + 261) 756#define __NR_get_mempolicy (__NR_Linux + 261)
757#define __NR_set_mempolicy (__NR_Linux + 262) 757#define __NR_set_mempolicy (__NR_Linux + 262)
758#define __NR_vserver (__NR_Linux + 263)
759#define __NR_add_key (__NR_Linux + 264)
760#define __NR_request_key (__NR_Linux + 265)
761#define __NR_keyctl (__NR_Linux + 266)
762#define __NR_ioprio_set (__NR_Linux + 267)
763#define __NR_ioprio_get (__NR_Linux + 268)
758 764
759#define __NR_Linux_syscalls 263 765#define __NR_Linux_syscalls 269
760 766
761#define HPUX_GATEWAY_ADDR 0xC0000004 767#define HPUX_GATEWAY_ADDR 0xC0000004
762#define LINUX_GATEWAY_ADDR 0x100 768#define LINUX_GATEWAY_ADDR 0x100
@@ -807,10 +813,10 @@
807#define K_INLINE_SYSCALL(name, nr, args...) ({ \ 813#define K_INLINE_SYSCALL(name, nr, args...) ({ \
808 long __sys_res; \ 814 long __sys_res; \
809 { \ 815 { \
810 register unsigned long __res asm("r28"); \ 816 register unsigned long __res __asm__("r28"); \
811 K_LOAD_ARGS_##nr(args) \ 817 K_LOAD_ARGS_##nr(args) \
812 /* FIXME: HACK stw/ldw r19 around syscall */ \ 818 /* FIXME: HACK stw/ldw r19 around syscall */ \
813 asm volatile( \ 819 __asm__ volatile( \
814 K_STW_ASM_PIC \ 820 K_STW_ASM_PIC \
815 " ble 0x100(%%sr2, %%r0)\n" \ 821 " ble 0x100(%%sr2, %%r0)\n" \
816 " ldi %1, %%r20\n" \ 822 " ldi %1, %%r20\n" \
diff --git a/include/asm-ppc/dma-mapping.h b/include/asm-ppc/dma-mapping.h
index 061bfcac1bf1..6e9635114433 100644
--- a/include/asm-ppc/dma-mapping.h
+++ b/include/asm-ppc/dma-mapping.h
@@ -19,7 +19,7 @@
19 * allocate the space "normally" and use the cache management functions 19 * allocate the space "normally" and use the cache management functions
20 * to ensure it is consistent. 20 * to ensure it is consistent.
21 */ 21 */
22extern void *__dma_alloc_coherent(size_t size, dma_addr_t *handle, int gfp); 22extern void *__dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp);
23extern void __dma_free_coherent(size_t size, void *vaddr); 23extern void __dma_free_coherent(size_t size, void *vaddr);
24extern void __dma_sync(void *vaddr, size_t size, int direction); 24extern void __dma_sync(void *vaddr, size_t size, int direction);
25extern void __dma_sync_page(struct page *page, unsigned long offset, 25extern void __dma_sync_page(struct page *page, unsigned long offset,
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index 80d164c1529e..d3fa5c2b889d 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -9,7 +9,7 @@
9extern struct bus_type pci_bus_type; 9extern struct bus_type pci_bus_type;
10 10
11/* arch/sh/mm/consistent.c */ 11/* arch/sh/mm/consistent.c */
12extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle); 12extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle);
13extern void consistent_free(void *vaddr, size_t size); 13extern void consistent_free(void *vaddr, size_t size);
14extern void consistent_sync(void *vaddr, size_t size, int direction); 14extern void consistent_sync(void *vaddr, size_t size, int direction);
15 15
@@ -26,7 +26,7 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
26} 26}
27 27
28static inline void *dma_alloc_coherent(struct device *dev, size_t size, 28static inline void *dma_alloc_coherent(struct device *dev, size_t size,
29 dma_addr_t *dma_handle, int flag) 29 dma_addr_t *dma_handle, gfp_t flag)
30{ 30{
31 if (sh_mv.mv_consistent_alloc) { 31 if (sh_mv.mv_consistent_alloc) {
32 void *ret; 32 void *ret;
diff --git a/include/asm-sh/machvec.h b/include/asm-sh/machvec.h
index 5771f4baa478..3f18aa180516 100644
--- a/include/asm-sh/machvec.h
+++ b/include/asm-sh/machvec.h
@@ -64,7 +64,7 @@ struct sh_machine_vector
64 64
65 void (*mv_heartbeat)(void); 65 void (*mv_heartbeat)(void);
66 66
67 void *(*mv_consistent_alloc)(struct device *, size_t, dma_addr_t *, int); 67 void *(*mv_consistent_alloc)(struct device *, size_t, dma_addr_t *, gfp_t);
68 int (*mv_consistent_free)(struct device *, size_t, void *, dma_addr_t); 68 int (*mv_consistent_free)(struct device *, size_t, void *, dma_addr_t);
69}; 69};
70 70
diff --git a/include/asm-sh64/dma-mapping.h b/include/asm-sh64/dma-mapping.h
index b8d26fe677f4..cc9a2e86f5b4 100644
--- a/include/asm-sh64/dma-mapping.h
+++ b/include/asm-sh64/dma-mapping.h
@@ -25,7 +25,7 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
25} 25}
26 26
27static inline void *dma_alloc_coherent(struct device *dev, size_t size, 27static inline void *dma_alloc_coherent(struct device *dev, size_t size,
28 dma_addr_t *dma_handle, int flag) 28 dma_addr_t *dma_handle, gfp_t flag)
29{ 29{
30 return consistent_alloc(NULL, size, dma_handle); 30 return consistent_alloc(NULL, size, dma_handle);
31} 31}
diff --git a/include/asm-sparc/dma-mapping.h b/include/asm-sparc/dma-mapping.h
index 2dc5bb8effa6..d7c3b0f0a901 100644
--- a/include/asm-sparc/dma-mapping.h
+++ b/include/asm-sparc/dma-mapping.h
@@ -8,7 +8,7 @@
8#else 8#else
9 9
10static inline void *dma_alloc_coherent(struct device *dev, size_t size, 10static inline void *dma_alloc_coherent(struct device *dev, size_t size,
11 dma_addr_t *dma_handle, int flag) 11 dma_addr_t *dma_handle, gfp_t flag)
12{ 12{
13 BUG(); 13 BUG();
14 return NULL; 14 return NULL;
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index 1c5da41653a4..c7d5804ba76d 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -10,7 +10,7 @@
10struct device; 10struct device;
11 11
12static inline void *dma_alloc_coherent(struct device *dev, size_t size, 12static inline void *dma_alloc_coherent(struct device *dev, size_t size,
13 dma_addr_t *dma_handle, int flag) 13 dma_addr_t *dma_handle, gfp_t flag)
14{ 14{
15 BUG(); 15 BUG();
16 return NULL; 16 return NULL;
diff --git a/include/asm-um/dma-mapping.h b/include/asm-um/dma-mapping.h
index 13e6291f7151..babd29895114 100644
--- a/include/asm-um/dma-mapping.h
+++ b/include/asm-um/dma-mapping.h
@@ -19,7 +19,7 @@ dma_set_mask(struct device *dev, u64 dma_mask)
19 19
20static inline void * 20static inline void *
21dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 21dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
22 int flag) 22 gfp_t flag)
23{ 23{
24 BUG(); 24 BUG();
25 return((void *) 0); 25 return((void *) 0);
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
index 2c192abe9aeb..0229814af31e 100644
--- a/include/asm-um/page.h
+++ b/include/asm-um/page.h
@@ -115,7 +115,7 @@ extern unsigned long uml_physmem;
115#define pfn_valid(pfn) ((pfn) < max_mapnr) 115#define pfn_valid(pfn) ((pfn) < max_mapnr)
116#define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v))) 116#define virt_addr_valid(v) pfn_valid(phys_to_pfn(__pa(v)))
117 117
118extern struct page *arch_validate(struct page *page, int mask, int order); 118extern struct page *arch_validate(struct page *page, gfp_t mask, int order);
119#define HAVE_ARCH_VALIDATE 119#define HAVE_ARCH_VALIDATE
120 120
121extern void arch_free_page(struct page *page, int order); 121extern void arch_free_page(struct page *page, int order);
diff --git a/include/asm-x86_64/dma-mapping.h b/include/asm-x86_64/dma-mapping.h
index e784fdc524f1..54a380efed41 100644
--- a/include/asm-x86_64/dma-mapping.h
+++ b/include/asm-x86_64/dma-mapping.h
@@ -17,7 +17,7 @@ extern dma_addr_t bad_dma_address;
17 (swiotlb ? swiotlb_dma_mapping_error(x) : ((x) == bad_dma_address)) 17 (swiotlb ? swiotlb_dma_mapping_error(x) : ((x) == bad_dma_address))
18 18
19void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 19void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
20 unsigned gfp); 20 gfp_t gfp);
21void dma_free_coherent(struct device *dev, size_t size, void *vaddr, 21void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
22 dma_addr_t dma_handle); 22 dma_addr_t dma_handle);
23 23
diff --git a/include/asm-x86_64/swiotlb.h b/include/asm-x86_64/swiotlb.h
index 36293061f4ed..7cbfd10ecc3c 100644
--- a/include/asm-x86_64/swiotlb.h
+++ b/include/asm-x86_64/swiotlb.h
@@ -27,7 +27,7 @@ extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
27 int nents, int direction); 27 int nents, int direction);
28extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr); 28extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
29extern void *swiotlb_alloc_coherent (struct device *hwdev, size_t size, 29extern void *swiotlb_alloc_coherent (struct device *hwdev, size_t size,
30 dma_addr_t *dma_handle, int flags); 30 dma_addr_t *dma_handle, gfp_t flags);
31extern void swiotlb_free_coherent (struct device *hwdev, size_t size, 31extern void swiotlb_free_coherent (struct device *hwdev, size_t size,
32 void *vaddr, dma_addr_t dma_handle); 32 void *vaddr, dma_addr_t dma_handle);
33 33
diff --git a/include/asm-xtensa/dma-mapping.h b/include/asm-xtensa/dma-mapping.h
index e86a206f1209..c425f10d086a 100644
--- a/include/asm-xtensa/dma-mapping.h
+++ b/include/asm-xtensa/dma-mapping.h
@@ -28,7 +28,7 @@ extern void consistent_sync(void*, size_t, int);
28#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 28#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
29 29
30void *dma_alloc_coherent(struct device *dev, size_t size, 30void *dma_alloc_coherent(struct device *dev, size_t size,
31 dma_addr_t *dma_handle, int flag); 31 dma_addr_t *dma_handle, gfp_t flag);
32 32
33void dma_free_coherent(struct device *dev, size_t size, 33void dma_free_coherent(struct device *dev, size_t size,
34 void *vaddr, dma_addr_t dma_handle); 34 void *vaddr, dma_addr_t dma_handle);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index a5b74efab067..d2873b732bb1 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -42,13 +42,18 @@ enum {
42 ATA_SECT_SIZE = 512, 42 ATA_SECT_SIZE = 512,
43 43
44 ATA_ID_WORDS = 256, 44 ATA_ID_WORDS = 256,
45 ATA_ID_PROD_OFS = 27,
46 ATA_ID_FW_REV_OFS = 23,
47 ATA_ID_SERNO_OFS = 10, 45 ATA_ID_SERNO_OFS = 10,
48 ATA_ID_MAJOR_VER = 80, 46 ATA_ID_FW_REV_OFS = 23,
49 ATA_ID_PIO_MODES = 64, 47 ATA_ID_PROD_OFS = 27,
48 ATA_ID_OLD_PIO_MODES = 51,
49 ATA_ID_FIELD_VALID = 53,
50 ATA_ID_MWDMA_MODES = 63, 50 ATA_ID_MWDMA_MODES = 63,
51 ATA_ID_PIO_MODES = 64,
52 ATA_ID_EIDE_DMA_MIN = 65,
53 ATA_ID_EIDE_PIO = 67,
54 ATA_ID_EIDE_PIO_IORDY = 68,
51 ATA_ID_UDMA_MODES = 88, 55 ATA_ID_UDMA_MODES = 88,
56 ATA_ID_MAJOR_VER = 80,
52 ATA_ID_PIO4 = (1 << 1), 57 ATA_ID_PIO4 = (1 << 1),
53 58
54 ATA_PCI_CTL_OFS = 2, 59 ATA_PCI_CTL_OFS = 2,
@@ -128,10 +133,15 @@ enum {
128 ATA_CMD_PIO_READ_EXT = 0x24, 133 ATA_CMD_PIO_READ_EXT = 0x24,
129 ATA_CMD_PIO_WRITE = 0x30, 134 ATA_CMD_PIO_WRITE = 0x30,
130 ATA_CMD_PIO_WRITE_EXT = 0x34, 135 ATA_CMD_PIO_WRITE_EXT = 0x34,
136 ATA_CMD_READ_MULTI = 0xC4,
137 ATA_CMD_READ_MULTI_EXT = 0x29,
138 ATA_CMD_WRITE_MULTI = 0xC5,
139 ATA_CMD_WRITE_MULTI_EXT = 0x39,
131 ATA_CMD_SET_FEATURES = 0xEF, 140 ATA_CMD_SET_FEATURES = 0xEF,
132 ATA_CMD_PACKET = 0xA0, 141 ATA_CMD_PACKET = 0xA0,
133 ATA_CMD_VERIFY = 0x40, 142 ATA_CMD_VERIFY = 0x40,
134 ATA_CMD_VERIFY_EXT = 0x42, 143 ATA_CMD_VERIFY_EXT = 0x42,
144 ATA_CMD_INIT_DEV_PARAMS = 0x91,
135 145
136 /* SETFEATURES stuff */ 146 /* SETFEATURES stuff */
137 SETFEATURES_XFER = 0x03, 147 SETFEATURES_XFER = 0x03,
@@ -146,14 +156,14 @@ enum {
146 XFER_MW_DMA_2 = 0x22, 156 XFER_MW_DMA_2 = 0x22,
147 XFER_MW_DMA_1 = 0x21, 157 XFER_MW_DMA_1 = 0x21,
148 XFER_MW_DMA_0 = 0x20, 158 XFER_MW_DMA_0 = 0x20,
159 XFER_SW_DMA_2 = 0x12,
160 XFER_SW_DMA_1 = 0x11,
161 XFER_SW_DMA_0 = 0x10,
149 XFER_PIO_4 = 0x0C, 162 XFER_PIO_4 = 0x0C,
150 XFER_PIO_3 = 0x0B, 163 XFER_PIO_3 = 0x0B,
151 XFER_PIO_2 = 0x0A, 164 XFER_PIO_2 = 0x0A,
152 XFER_PIO_1 = 0x09, 165 XFER_PIO_1 = 0x09,
153 XFER_PIO_0 = 0x08, 166 XFER_PIO_0 = 0x08,
154 XFER_SW_DMA_2 = 0x12,
155 XFER_SW_DMA_1 = 0x11,
156 XFER_SW_DMA_0 = 0x10,
157 XFER_PIO_SLOW = 0x00, 167 XFER_PIO_SLOW = 0x00,
158 168
159 /* ATAPI stuff */ 169 /* ATAPI stuff */
@@ -181,6 +191,7 @@ enum {
181 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ 191 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
182 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */ 192 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */
183 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ 193 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */
194 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
184}; 195};
185 196
186enum ata_tf_protocols { 197enum ata_tf_protocols {
@@ -250,7 +261,19 @@ struct ata_taskfile {
250 ((u64) (id)[(n) + 1] << 16) | \ 261 ((u64) (id)[(n) + 1] << 16) | \
251 ((u64) (id)[(n) + 0]) ) 262 ((u64) (id)[(n) + 0]) )
252 263
253static inline int atapi_cdb_len(u16 *dev_id) 264static inline int ata_id_current_chs_valid(const u16 *id)
265{
266 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
267 has not been issued to the device then the values of
268 id[54] to id[56] are vendor specific. */
269 return (id[53] & 0x01) && /* Current translation valid */
270 id[54] && /* cylinders in current translation */
271 id[55] && /* heads in current translation */
272 id[55] <= 16 &&
273 id[56]; /* sectors in current translation */
274}
275
276static inline int atapi_cdb_len(const u16 *dev_id)
254{ 277{
255 u16 tmp = dev_id[0] & 0x3; 278 u16 tmp = dev_id[0] & 0x3;
256 switch (tmp) { 279 switch (tmp) {
@@ -260,7 +283,7 @@ static inline int atapi_cdb_len(u16 *dev_id)
260 } 283 }
261} 284}
262 285
263static inline int is_atapi_taskfile(struct ata_taskfile *tf) 286static inline int is_atapi_taskfile(const struct ata_taskfile *tf)
264{ 287{
265 return (tf->protocol == ATA_PROT_ATAPI) || 288 return (tf->protocol == ATA_PROT_ATAPI) ||
266 (tf->protocol == ATA_PROT_ATAPI_NODATA) || 289 (tf->protocol == ATA_PROT_ATAPI_NODATA) ||
diff --git a/include/linux/audit.h b/include/linux/audit.h
index b2a2509bd7ea..da3c01955f3d 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -260,11 +260,11 @@ extern int audit_filter_user(struct netlink_skb_parms *cb, int type);
260#ifdef CONFIG_AUDIT 260#ifdef CONFIG_AUDIT
261/* These are defined in audit.c */ 261/* These are defined in audit.c */
262 /* Public API */ 262 /* Public API */
263extern void audit_log(struct audit_context *ctx, int gfp_mask, 263extern void audit_log(struct audit_context *ctx, gfp_t gfp_mask,
264 int type, const char *fmt, ...) 264 int type, const char *fmt, ...)
265 __attribute__((format(printf,4,5))); 265 __attribute__((format(printf,4,5)));
266 266
267extern struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, int type); 267extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type);
268extern void audit_log_format(struct audit_buffer *ab, 268extern void audit_log_format(struct audit_buffer *ab,
269 const char *fmt, ...) 269 const char *fmt, ...)
270 __attribute__((format(printf,2,3))); 270 __attribute__((format(printf,2,3)));
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 3344b4e8e43a..685fd3720df5 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -301,7 +301,7 @@ extern struct bio *bio_map_user_iov(struct request_queue *,
301 struct sg_iovec *, int, int); 301 struct sg_iovec *, int, int);
302extern void bio_unmap_user(struct bio *); 302extern void bio_unmap_user(struct bio *);
303extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, 303extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
304 unsigned int); 304 gfp_t);
305extern void bio_set_pages_dirty(struct bio *bio); 305extern void bio_set_pages_dirty(struct bio *bio);
306extern void bio_check_pages_dirty(struct bio *bio); 306extern void bio_check_pages_dirty(struct bio *bio);
307extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); 307extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index efdc9b5bc05c..025a7f084dbd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -96,8 +96,8 @@ struct io_context {
96 96
97void put_io_context(struct io_context *ioc); 97void put_io_context(struct io_context *ioc);
98void exit_io_context(void); 98void exit_io_context(void);
99struct io_context *current_io_context(int gfp_flags); 99struct io_context *current_io_context(gfp_t gfp_flags);
100struct io_context *get_io_context(int gfp_flags); 100struct io_context *get_io_context(gfp_t gfp_flags);
101void copy_io_context(struct io_context **pdst, struct io_context **psrc); 101void copy_io_context(struct io_context **pdst, struct io_context **psrc);
102void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); 102void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
103 103
@@ -107,9 +107,9 @@ typedef void (rq_end_io_fn)(struct request *);
107struct request_list { 107struct request_list {
108 int count[2]; 108 int count[2];
109 int starved[2]; 109 int starved[2];
110 int elvpriv;
110 mempool_t *rq_pool; 111 mempool_t *rq_pool;
111 wait_queue_head_t wait[2]; 112 wait_queue_head_t wait[2];
112 wait_queue_head_t drain;
113}; 113};
114 114
115#define BLK_MAX_CDB 16 115#define BLK_MAX_CDB 16
@@ -203,6 +203,7 @@ struct request {
203enum rq_flag_bits { 203enum rq_flag_bits {
204 __REQ_RW, /* not set, read. set, write */ 204 __REQ_RW, /* not set, read. set, write */
205 __REQ_FAILFAST, /* no low level driver retries */ 205 __REQ_FAILFAST, /* no low level driver retries */
206 __REQ_SORTED, /* elevator knows about this request */
206 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ 207 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
207 __REQ_HARDBARRIER, /* may not be passed by drive either */ 208 __REQ_HARDBARRIER, /* may not be passed by drive either */
208 __REQ_CMD, /* is a regular fs rw request */ 209 __REQ_CMD, /* is a regular fs rw request */
@@ -210,6 +211,7 @@ enum rq_flag_bits {
210 __REQ_STARTED, /* drive already may have started this one */ 211 __REQ_STARTED, /* drive already may have started this one */
211 __REQ_DONTPREP, /* don't call prep for this one */ 212 __REQ_DONTPREP, /* don't call prep for this one */
212 __REQ_QUEUED, /* uses queueing */ 213 __REQ_QUEUED, /* uses queueing */
214 __REQ_ELVPRIV, /* elevator private data attached */
213 /* 215 /*
214 * for ATA/ATAPI devices 216 * for ATA/ATAPI devices
215 */ 217 */
@@ -235,6 +237,7 @@ enum rq_flag_bits {
235 237
236#define REQ_RW (1 << __REQ_RW) 238#define REQ_RW (1 << __REQ_RW)
237#define REQ_FAILFAST (1 << __REQ_FAILFAST) 239#define REQ_FAILFAST (1 << __REQ_FAILFAST)
240#define REQ_SORTED (1 << __REQ_SORTED)
238#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) 241#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
239#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) 242#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
240#define REQ_CMD (1 << __REQ_CMD) 243#define REQ_CMD (1 << __REQ_CMD)
@@ -242,6 +245,7 @@ enum rq_flag_bits {
242#define REQ_STARTED (1 << __REQ_STARTED) 245#define REQ_STARTED (1 << __REQ_STARTED)
243#define REQ_DONTPREP (1 << __REQ_DONTPREP) 246#define REQ_DONTPREP (1 << __REQ_DONTPREP)
244#define REQ_QUEUED (1 << __REQ_QUEUED) 247#define REQ_QUEUED (1 << __REQ_QUEUED)
248#define REQ_ELVPRIV (1 << __REQ_ELVPRIV)
245#define REQ_PC (1 << __REQ_PC) 249#define REQ_PC (1 << __REQ_PC)
246#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) 250#define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC)
247#define REQ_SENSE (1 << __REQ_SENSE) 251#define REQ_SENSE (1 << __REQ_SENSE)
@@ -333,6 +337,12 @@ struct request_queue
333 end_flush_fn *end_flush_fn; 337 end_flush_fn *end_flush_fn;
334 338
335 /* 339 /*
340 * Dispatch queue sorting
341 */
342 sector_t end_sector;
343 struct request *boundary_rq;
344
345 /*
336 * Auto-unplugging state 346 * Auto-unplugging state
337 */ 347 */
338 struct timer_list unplug_timer; 348 struct timer_list unplug_timer;
@@ -354,7 +364,7 @@ struct request_queue
354 * queue needs bounce pages for pages above this limit 364 * queue needs bounce pages for pages above this limit
355 */ 365 */
356 unsigned long bounce_pfn; 366 unsigned long bounce_pfn;
357 unsigned int bounce_gfp; 367 gfp_t bounce_gfp;
358 368
359 /* 369 /*
360 * various queue flags, see QUEUE_* below 370 * various queue flags, see QUEUE_* below
@@ -405,8 +415,6 @@ struct request_queue
405 unsigned int sg_reserved_size; 415 unsigned int sg_reserved_size;
406 int node; 416 int node;
407 417
408 struct list_head drain_list;
409
410 /* 418 /*
411 * reserved for flush operations 419 * reserved for flush operations
412 */ 420 */
@@ -434,7 +442,7 @@ enum {
434#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ 442#define QUEUE_FLAG_DEAD 5 /* queue being torn down */
435#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ 443#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */
436#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 444#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */
437#define QUEUE_FLAG_DRAIN 8 /* draining queue for sched switch */ 445#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */
438#define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ 446#define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */
439 447
440#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) 448#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
@@ -454,6 +462,7 @@ enum {
454#define blk_pm_request(rq) \ 462#define blk_pm_request(rq) \
455 ((rq)->flags & (REQ_PM_SUSPEND | REQ_PM_RESUME)) 463 ((rq)->flags & (REQ_PM_SUSPEND | REQ_PM_RESUME))
456 464
465#define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED)
457#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) 466#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER)
458#define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH) 467#define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH)
459#define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH) 468#define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH)
@@ -550,7 +559,7 @@ extern void generic_make_request(struct bio *bio);
550extern void blk_put_request(struct request *); 559extern void blk_put_request(struct request *);
551extern void blk_end_sync_rq(struct request *rq); 560extern void blk_end_sync_rq(struct request *rq);
552extern void blk_attempt_remerge(request_queue_t *, struct request *); 561extern void blk_attempt_remerge(request_queue_t *, struct request *);
553extern struct request *blk_get_request(request_queue_t *, int, int); 562extern struct request *blk_get_request(request_queue_t *, int, gfp_t);
554extern void blk_insert_request(request_queue_t *, struct request *, int, void *); 563extern void blk_insert_request(request_queue_t *, struct request *, int, void *);
555extern void blk_requeue_request(request_queue_t *, struct request *); 564extern void blk_requeue_request(request_queue_t *, struct request *);
556extern void blk_plug_device(request_queue_t *); 565extern void blk_plug_device(request_queue_t *);
@@ -565,7 +574,7 @@ extern void blk_run_queue(request_queue_t *);
565extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *); 574extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
566extern int blk_rq_map_user(request_queue_t *, struct request *, void __user *, unsigned int); 575extern int blk_rq_map_user(request_queue_t *, struct request *, void __user *, unsigned int);
567extern int blk_rq_unmap_user(struct bio *, unsigned int); 576extern int blk_rq_unmap_user(struct bio *, unsigned int);
568extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned int, unsigned int); 577extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned int, gfp_t);
569extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int); 578extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int);
570extern int blk_execute_rq(request_queue_t *, struct gendisk *, 579extern int blk_execute_rq(request_queue_t *, struct gendisk *,
571 struct request *, int); 580 struct request *, int);
@@ -611,12 +620,21 @@ extern void end_request(struct request *req, int uptodate);
611 620
612static inline void blkdev_dequeue_request(struct request *req) 621static inline void blkdev_dequeue_request(struct request *req)
613{ 622{
614 BUG_ON(list_empty(&req->queuelist)); 623 elv_dequeue_request(req->q, req);
624}
615 625
616 list_del_init(&req->queuelist); 626/*
627 * This should be in elevator.h, but that requires pulling in rq and q
628 */
629static inline void elv_dispatch_add_tail(struct request_queue *q,
630 struct request *rq)
631{
632 if (q->last_merge == rq)
633 q->last_merge = NULL;
617 634
618 if (req->rl) 635 q->end_sector = rq_end_sector(rq);
619 elv_remove_request(req->q, req); 636 q->boundary_rq = rq;
637 list_add_tail(&rq->queuelist, &q->queue_head);
620} 638}
621 639
622/* 640/*
@@ -650,12 +668,10 @@ extern void blk_dump_rq_flags(struct request *, char *);
650extern void generic_unplug_device(request_queue_t *); 668extern void generic_unplug_device(request_queue_t *);
651extern void __generic_unplug_device(request_queue_t *); 669extern void __generic_unplug_device(request_queue_t *);
652extern long nr_blockdev_pages(void); 670extern long nr_blockdev_pages(void);
653extern void blk_wait_queue_drained(request_queue_t *, int);
654extern void blk_finish_queue_drain(request_queue_t *);
655 671
656int blk_get_queue(request_queue_t *); 672int blk_get_queue(request_queue_t *);
657request_queue_t *blk_alloc_queue(int gfp_mask); 673request_queue_t *blk_alloc_queue(gfp_t);
658request_queue_t *blk_alloc_queue_node(int,int); 674request_queue_t *blk_alloc_queue_node(gfp_t, int);
659#define blk_put_queue(q) blk_cleanup_queue((q)) 675#define blk_put_queue(q) blk_cleanup_queue((q))
660 676
661/* 677/*
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 6a1d154c0825..88af42f5e04a 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -188,7 +188,7 @@ extern int buffer_heads_over_limit;
188 * Generic address_space_operations implementations for buffer_head-backed 188 * Generic address_space_operations implementations for buffer_head-backed
189 * address_spaces. 189 * address_spaces.
190 */ 190 */
191int try_to_release_page(struct page * page, int gfp_mask); 191int try_to_release_page(struct page * page, gfp_t gfp_mask);
192int block_invalidatepage(struct page *page, unsigned long offset); 192int block_invalidatepage(struct page *page, unsigned long offset);
193int block_write_full_page(struct page *page, get_block_t *get_block, 193int block_write_full_page(struct page *page, get_block_t *get_block,
194 struct writeback_control *wbc); 194 struct writeback_control *wbc);
diff --git a/include/linux/cyclomx.h b/include/linux/cyclomx.h
index 04fa7dff079c..300d704bdb9a 100644
--- a/include/linux/cyclomx.h
+++ b/include/linux/cyclomx.h
@@ -37,8 +37,6 @@
37#include <linux/cycx_x25.h> 37#include <linux/cycx_x25.h>
38#endif 38#endif
39 39
40#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
41
42/* Adapter Data Space. 40/* Adapter Data Space.
43 * This structure is needed because we handle multiple cards, otherwise 41 * This structure is needed because we handle multiple cards, otherwise
44 * static data would do it. 42 * static data would do it.
diff --git a/include/linux/cycx_drv.h b/include/linux/cycx_drv.h
index 6621df86a748..12fe6b0bfcff 100644
--- a/include/linux/cycx_drv.h
+++ b/include/linux/cycx_drv.h
@@ -60,6 +60,5 @@ extern int cycx_peek(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
60extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len); 60extern int cycx_poke(struct cycx_hw *hw, u32 addr, void *buf, u32 len);
61extern int cycx_exec(void __iomem *addr); 61extern int cycx_exec(void __iomem *addr);
62 62
63extern void cycx_inten(struct cycx_hw *hw);
64extern void cycx_intr(struct cycx_hw *hw); 63extern void cycx_intr(struct cycx_hw *hw);
65#endif /* _CYCX_DRV_H */ 64#endif /* _CYCX_DRV_H */
diff --git a/include/linux/device.h b/include/linux/device.h
index 95d607a48f06..a9e72ac3fb9f 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -28,19 +28,6 @@
28#define BUS_ID_SIZE KOBJ_NAME_LEN 28#define BUS_ID_SIZE KOBJ_NAME_LEN
29 29
30 30
31enum {
32 SUSPEND_NOTIFY,
33 SUSPEND_SAVE_STATE,
34 SUSPEND_DISABLE,
35 SUSPEND_POWER_DOWN,
36};
37
38enum {
39 RESUME_POWER_ON,
40 RESUME_RESTORE_STATE,
41 RESUME_ENABLE,
42};
43
44struct device; 31struct device;
45struct device_driver; 32struct device_driver;
46struct class; 33struct class;
@@ -115,8 +102,8 @@ struct device_driver {
115 int (*probe) (struct device * dev); 102 int (*probe) (struct device * dev);
116 int (*remove) (struct device * dev); 103 int (*remove) (struct device * dev);
117 void (*shutdown) (struct device * dev); 104 void (*shutdown) (struct device * dev);
118 int (*suspend) (struct device * dev, pm_message_t state, u32 level); 105 int (*suspend) (struct device * dev, pm_message_t state);
119 int (*resume) (struct device * dev, u32 level); 106 int (*resume) (struct device * dev);
120}; 107};
121 108
122 109
@@ -190,7 +177,43 @@ struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
190extern int class_create_file(struct class *, const struct class_attribute *); 177extern int class_create_file(struct class *, const struct class_attribute *);
191extern void class_remove_file(struct class *, const struct class_attribute *); 178extern void class_remove_file(struct class *, const struct class_attribute *);
192 179
180struct class_device_attribute {
181 struct attribute attr;
182 ssize_t (*show)(struct class_device *, char * buf);
183 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
184};
185
186#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
187struct class_device_attribute class_device_attr_##_name = \
188 __ATTR(_name,_mode,_show,_store)
189
190extern int class_device_create_file(struct class_device *,
191 const struct class_device_attribute *);
193 192
193/**
194 * struct class_device - class devices
195 * @class: pointer to the parent class for this class device. This is required.
196 * @devt: for internal use by the driver core only.
197 * @node: for internal use by the driver core only.
198 * @kobj: for internal use by the driver core only.
199 * @devt_attr: for internal use by the driver core only.
200 * @dev: if set, a symlink to the struct device is created in the sysfs
201 * directory for this struct class device.
202 * @class_data: pointer to whatever you want to store here for this struct
203 * class_device. Use class_get_devdata() and class_set_devdata() to get and
204 * set this pointer.
205 * @parent: pointer to a struct class_device that is the parent of this struct
206 * class_device. If NULL, this class_device will show up at the root of the
207 * struct class in sysfs (which is probably what you want to have happen.)
208 * @release: pointer to a release function for this struct class_device. If
209 * set, this will be called instead of the class specific release function.
210 * Only use this if you want to override the default release function, like
211 * when you are nesting class_device structures.
212 * @hotplug: pointer to a hotplug function for this struct class_device. If
213 * set, this will be called instead of the class specific hotplug function.
214 * Only use this if you want to override the default hotplug function, like
215 * when you are nesting class_device structures.
216 */
194struct class_device { 217struct class_device {
195 struct list_head node; 218 struct list_head node;
196 219
@@ -198,9 +221,14 @@ struct class_device {
198 struct class * class; /* required */ 221 struct class * class; /* required */
199 dev_t devt; /* dev_t, creates the sysfs "dev" */ 222 dev_t devt; /* dev_t, creates the sysfs "dev" */
200 struct class_device_attribute *devt_attr; 223 struct class_device_attribute *devt_attr;
224 struct class_device_attribute uevent_attr;
201 struct device * dev; /* not necessary, but nice to have */ 225 struct device * dev; /* not necessary, but nice to have */
202 void * class_data; /* class-specific data */ 226 void * class_data; /* class-specific data */
227 struct class_device *parent; /* parent of this child device, if there is one */
203 228
229 void (*release)(struct class_device *dev);
230 int (*hotplug)(struct class_device *dev, char **envp,
231 int num_envp, char *buffer, int buffer_size);
204 char class_id[BUS_ID_SIZE]; /* unique to this class */ 232 char class_id[BUS_ID_SIZE]; /* unique to this class */
205}; 233};
206 234
@@ -228,18 +256,6 @@ extern int class_device_rename(struct class_device *, char *);
228extern struct class_device * class_device_get(struct class_device *); 256extern struct class_device * class_device_get(struct class_device *);
229extern void class_device_put(struct class_device *); 257extern void class_device_put(struct class_device *);
230 258
231struct class_device_attribute {
232 struct attribute attr;
233 ssize_t (*show)(struct class_device *, char * buf);
234 ssize_t (*store)(struct class_device *, const char * buf, size_t count);
235};
236
237#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
238struct class_device_attribute class_device_attr_##_name = \
239 __ATTR(_name,_mode,_show,_store)
240
241extern int class_device_create_file(struct class_device *,
242 const struct class_device_attribute *);
243extern void class_device_remove_file(struct class_device *, 259extern void class_device_remove_file(struct class_device *,
244 const struct class_device_attribute *); 260 const struct class_device_attribute *);
245extern int class_device_create_bin_file(struct class_device *, 261extern int class_device_create_bin_file(struct class_device *,
@@ -251,8 +267,8 @@ struct class_interface {
251 struct list_head node; 267 struct list_head node;
252 struct class *class; 268 struct class *class;
253 269
254 int (*add) (struct class_device *); 270 int (*add) (struct class_device *, struct class_interface *);
255 void (*remove) (struct class_device *); 271 void (*remove) (struct class_device *, struct class_interface *);
256}; 272};
257 273
258extern int class_interface_register(struct class_interface *); 274extern int class_interface_register(struct class_interface *);
@@ -260,12 +276,29 @@ extern void class_interface_unregister(struct class_interface *);
260 276
261extern struct class *class_create(struct module *owner, char *name); 277extern struct class *class_create(struct module *owner, char *name);
262extern void class_destroy(struct class *cls); 278extern void class_destroy(struct class *cls);
263extern struct class_device *class_device_create(struct class *cls, dev_t devt, 279extern struct class_device *class_device_create(struct class *cls,
264 struct device *device, char *fmt, ...) 280 struct class_device *parent,
265 __attribute__((format(printf,4,5))); 281 dev_t devt,
282 struct device *device,
283 char *fmt, ...)
284 __attribute__((format(printf,5,6)));
266extern void class_device_destroy(struct class *cls, dev_t devt); 285extern void class_device_destroy(struct class *cls, dev_t devt);
267 286
268 287
288/* interface for exporting device attributes */
289struct device_attribute {
290 struct attribute attr;
291 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
292 char *buf);
293 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
294 const char *buf, size_t count);
295};
296
297#define DEVICE_ATTR(_name,_mode,_show,_store) \
298struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
299
300extern int device_create_file(struct device *device, struct device_attribute * entry);
301extern void device_remove_file(struct device * dev, struct device_attribute * attr);
269struct device { 302struct device {
270 struct klist klist_children; 303 struct klist klist_children;
271 struct klist_node knode_parent; /* node in sibling list */ 304 struct klist_node knode_parent; /* node in sibling list */
@@ -275,6 +308,7 @@ struct device {
275 308
276 struct kobject kobj; 309 struct kobject kobj;
277 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 310 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
311 struct device_attribute uevent_attr;
278 312
279 struct semaphore sem; /* semaphore to synchronize calls to 313 struct semaphore sem; /* semaphore to synchronize calls to
280 * its driver. 314 * its driver.
@@ -343,23 +377,6 @@ extern int device_attach(struct device * dev);
343extern void driver_attach(struct device_driver * drv); 377extern void driver_attach(struct device_driver * drv);
344 378
345 379
346/* driverfs interface for exporting device attributes */
347
348struct device_attribute {
349 struct attribute attr;
350 ssize_t (*show)(struct device *dev, struct device_attribute *attr,
351 char *buf);
352 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
353 const char *buf, size_t count);
354};
355
356#define DEVICE_ATTR(_name,_mode,_show,_store) \
357struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
358
359
360extern int device_create_file(struct device *device, struct device_attribute * entry);
361extern void device_remove_file(struct device * dev, struct device_attribute * attr);
362
363/* 380/*
364 * Platform "fixup" functions - allow the platform to have their say 381 * Platform "fixup" functions - allow the platform to have their say
365 * about devices and actions that the general device layer doesn't 382 * about devices and actions that the general device layer doesn't
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index ea6bbc2d7407..a74c27e460ba 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -8,18 +8,17 @@ typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struc
8 8
9typedef void (elevator_merged_fn) (request_queue_t *, struct request *); 9typedef void (elevator_merged_fn) (request_queue_t *, struct request *);
10 10
11typedef struct request *(elevator_next_req_fn) (request_queue_t *); 11typedef int (elevator_dispatch_fn) (request_queue_t *, int);
12 12
13typedef void (elevator_add_req_fn) (request_queue_t *, struct request *, int); 13typedef void (elevator_add_req_fn) (request_queue_t *, struct request *);
14typedef int (elevator_queue_empty_fn) (request_queue_t *); 14typedef int (elevator_queue_empty_fn) (request_queue_t *);
15typedef void (elevator_remove_req_fn) (request_queue_t *, struct request *);
16typedef void (elevator_requeue_req_fn) (request_queue_t *, struct request *);
17typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); 15typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
18typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); 16typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
19typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *); 17typedef int (elevator_may_queue_fn) (request_queue_t *, int, struct bio *);
20 18
21typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, int); 19typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, struct bio *, gfp_t);
22typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); 20typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
21typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *);
23typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); 22typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *);
24 23
25typedef int (elevator_init_fn) (request_queue_t *, elevator_t *); 24typedef int (elevator_init_fn) (request_queue_t *, elevator_t *);
@@ -31,10 +30,9 @@ struct elevator_ops
31 elevator_merged_fn *elevator_merged_fn; 30 elevator_merged_fn *elevator_merged_fn;
32 elevator_merge_req_fn *elevator_merge_req_fn; 31 elevator_merge_req_fn *elevator_merge_req_fn;
33 32
34 elevator_next_req_fn *elevator_next_req_fn; 33 elevator_dispatch_fn *elevator_dispatch_fn;
35 elevator_add_req_fn *elevator_add_req_fn; 34 elevator_add_req_fn *elevator_add_req_fn;
36 elevator_remove_req_fn *elevator_remove_req_fn; 35 elevator_activate_req_fn *elevator_activate_req_fn;
37 elevator_requeue_req_fn *elevator_requeue_req_fn;
38 elevator_deactivate_req_fn *elevator_deactivate_req_fn; 36 elevator_deactivate_req_fn *elevator_deactivate_req_fn;
39 37
40 elevator_queue_empty_fn *elevator_queue_empty_fn; 38 elevator_queue_empty_fn *elevator_queue_empty_fn;
@@ -81,15 +79,15 @@ struct elevator_queue
81/* 79/*
82 * block elevator interface 80 * block elevator interface
83 */ 81 */
82extern void elv_dispatch_sort(request_queue_t *, struct request *);
84extern void elv_add_request(request_queue_t *, struct request *, int, int); 83extern void elv_add_request(request_queue_t *, struct request *, int, int);
85extern void __elv_add_request(request_queue_t *, struct request *, int, int); 84extern void __elv_add_request(request_queue_t *, struct request *, int, int);
86extern int elv_merge(request_queue_t *, struct request **, struct bio *); 85extern int elv_merge(request_queue_t *, struct request **, struct bio *);
87extern void elv_merge_requests(request_queue_t *, struct request *, 86extern void elv_merge_requests(request_queue_t *, struct request *,
88 struct request *); 87 struct request *);
89extern void elv_merged_request(request_queue_t *, struct request *); 88extern void elv_merged_request(request_queue_t *, struct request *);
90extern void elv_remove_request(request_queue_t *, struct request *); 89extern void elv_dequeue_request(request_queue_t *, struct request *);
91extern void elv_requeue_request(request_queue_t *, struct request *); 90extern void elv_requeue_request(request_queue_t *, struct request *);
92extern void elv_deactivate_request(request_queue_t *, struct request *);
93extern int elv_queue_empty(request_queue_t *); 91extern int elv_queue_empty(request_queue_t *);
94extern struct request *elv_next_request(struct request_queue *q); 92extern struct request *elv_next_request(struct request_queue *q);
95extern struct request *elv_former_request(request_queue_t *, struct request *); 93extern struct request *elv_former_request(request_queue_t *, struct request *);
@@ -98,7 +96,7 @@ extern int elv_register_queue(request_queue_t *q);
98extern void elv_unregister_queue(request_queue_t *q); 96extern void elv_unregister_queue(request_queue_t *q);
99extern int elv_may_queue(request_queue_t *, int, struct bio *); 97extern int elv_may_queue(request_queue_t *, int, struct bio *);
100extern void elv_completed_request(request_queue_t *, struct request *); 98extern void elv_completed_request(request_queue_t *, struct request *);
101extern int elv_set_request(request_queue_t *, struct request *, struct bio *, int); 99extern int elv_set_request(request_queue_t *, struct request *, struct bio *, gfp_t);
102extern void elv_put_request(request_queue_t *, struct request *); 100extern void elv_put_request(request_queue_t *, struct request *);
103 101
104/* 102/*
@@ -142,4 +140,6 @@ enum {
142 ELV_MQUEUE_MUST, 140 ELV_MQUEUE_MUST,
143}; 141};
144 142
143#define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors)
144
145#endif 145#endif
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index ed1440ea4c91..d2c390eff1b2 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -269,6 +269,8 @@ u32 ethtool_op_get_tso(struct net_device *dev);
269int ethtool_op_set_tso(struct net_device *dev, u32 data); 269int ethtool_op_set_tso(struct net_device *dev, u32 data);
270int ethtool_op_get_perm_addr(struct net_device *dev, 270int ethtool_op_get_perm_addr(struct net_device *dev,
271 struct ethtool_perm_addr *addr, u8 *data); 271 struct ethtool_perm_addr *addr, u8 *data);
272u32 ethtool_op_get_ufo(struct net_device *dev);
273int ethtool_op_set_ufo(struct net_device *dev, u32 data);
272 274
273/** 275/**
274 * &ethtool_ops - Alter and report network device settings 276 * &ethtool_ops - Alter and report network device settings
@@ -298,6 +300,8 @@ int ethtool_op_get_perm_addr(struct net_device *dev,
298 * set_sg: Turn scatter-gather on or off 300 * set_sg: Turn scatter-gather on or off
299 * get_tso: Report whether TCP segmentation offload is enabled 301 * get_tso: Report whether TCP segmentation offload is enabled
300 * set_tso: Turn TCP segmentation offload on or off 302 * set_tso: Turn TCP segmentation offload on or off
303 * get_ufo: Report whether UDP fragmentation offload is enabled
304 * set_ufo: Turn UDP fragmentation offload on or off
301 * self_test: Run specified self-tests 305 * self_test: Run specified self-tests
302 * get_strings: Return a set of strings that describe the requested objects 306 * get_strings: Return a set of strings that describe the requested objects
303 * phys_id: Identify the device 307 * phys_id: Identify the device
@@ -364,6 +368,8 @@ struct ethtool_ops {
364 int (*get_perm_addr)(struct net_device *, struct ethtool_perm_addr *, u8 *); 368 int (*get_perm_addr)(struct net_device *, struct ethtool_perm_addr *, u8 *);
365 int (*begin)(struct net_device *); 369 int (*begin)(struct net_device *);
366 void (*complete)(struct net_device *); 370 void (*complete)(struct net_device *);
371 u32 (*get_ufo)(struct net_device *);
372 int (*set_ufo)(struct net_device *, u32);
367}; 373};
368 374
369/* CMDs currently supported */ 375/* CMDs currently supported */
@@ -400,6 +406,8 @@ struct ethtool_ops {
400#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */ 406#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
401#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */ 407#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
402#define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */ 408#define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */
409#define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (ethtool_value) */
410#define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (ethtool_value) */
403 411
404/* compatibility with older code */ 412/* compatibility with older code */
405#define SPARC_ETH_GSET ETHTOOL_GSET 413#define SPARC_ETH_GSET ETHTOOL_GSET
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e0b77c5af9a0..f83d997c5582 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -320,7 +320,7 @@ struct address_space_operations {
320 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ 320 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
321 sector_t (*bmap)(struct address_space *, sector_t); 321 sector_t (*bmap)(struct address_space *, sector_t);
322 int (*invalidatepage) (struct page *, unsigned long); 322 int (*invalidatepage) (struct page *, unsigned long);
323 int (*releasepage) (struct page *, int); 323 int (*releasepage) (struct page *, gfp_t);
324 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 324 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
325 loff_t offset, unsigned long nr_segs); 325 loff_t offset, unsigned long nr_segs);
326 struct page* (*get_xip_page)(struct address_space *, sector_t, 326 struct page* (*get_xip_page)(struct address_space *, sector_t,
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 01796c41c951..eabdb5cce357 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -119,7 +119,7 @@ struct gendisk {
119 int policy; 119 int policy;
120 120
121 atomic_t sync_io; /* RAID */ 121 atomic_t sync_io; /* RAID */
122 unsigned long stamp, stamp_idle; 122 unsigned long stamp;
123 int in_flight; 123 int in_flight;
124#ifdef CONFIG_SMP 124#ifdef CONFIG_SMP
125 struct disk_stats *dkstats; 125 struct disk_stats *dkstats;
@@ -132,6 +132,7 @@ struct gendisk {
132struct disk_attribute { 132struct disk_attribute {
133 struct attribute attr; 133 struct attribute attr;
134 ssize_t (*show)(struct gendisk *, char *); 134 ssize_t (*show)(struct gendisk *, char *);
135 ssize_t (*store)(struct gendisk *, const char *, size_t);
135}; 136};
136 137
137/* 138/*
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 3010e172394d..c3779432a723 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -12,8 +12,8 @@ struct vm_area_struct;
12 * GFP bitmasks.. 12 * GFP bitmasks..
13 */ 13 */
14/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */ 14/* Zone modifiers in GFP_ZONEMASK (see linux/mmzone.h - low two bits) */
15#define __GFP_DMA 0x01u 15#define __GFP_DMA ((__force gfp_t)0x01u)
16#define __GFP_HIGHMEM 0x02u 16#define __GFP_HIGHMEM ((__force gfp_t)0x02u)
17 17
18/* 18/*
19 * Action modifiers - doesn't change the zoning 19 * Action modifiers - doesn't change the zoning
@@ -26,24 +26,24 @@ struct vm_area_struct;
26 * 26 *
27 * __GFP_NORETRY: The VM implementation must not retry indefinitely. 27 * __GFP_NORETRY: The VM implementation must not retry indefinitely.
28 */ 28 */
29#define __GFP_WAIT 0x10u /* Can wait and reschedule? */ 29#define __GFP_WAIT ((__force gfp_t)0x10u) /* Can wait and reschedule? */
30#define __GFP_HIGH 0x20u /* Should access emergency pools? */ 30#define __GFP_HIGH ((__force gfp_t)0x20u) /* Should access emergency pools? */
31#define __GFP_IO 0x40u /* Can start physical IO? */ 31#define __GFP_IO ((__force gfp_t)0x40u) /* Can start physical IO? */
32#define __GFP_FS 0x80u /* Can call down to low-level FS? */ 32#define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */
33#define __GFP_COLD 0x100u /* Cache-cold page required */ 33#define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */
34#define __GFP_NOWARN 0x200u /* Suppress page allocation failure warning */ 34#define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */
35#define __GFP_REPEAT 0x400u /* Retry the allocation. Might fail */ 35#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */
36#define __GFP_NOFAIL 0x800u /* Retry for ever. Cannot fail */ 36#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */
37#define __GFP_NORETRY 0x1000u /* Do not retry. Might fail */ 37#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */
38#define __GFP_NO_GROW 0x2000u /* Slab internal usage */ 38#define __GFP_NO_GROW ((__force gfp_t)0x2000u)/* Slab internal usage */
39#define __GFP_COMP 0x4000u /* Add compound page metadata */ 39#define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */
40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */ 40#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */
41#define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */ 41#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
42#define __GFP_NORECLAIM 0x20000u /* No realy zone reclaim during allocation */ 42#define __GFP_NORECLAIM ((__force gfp_t)0x20000u) /* No realy zone reclaim during allocation */
43#define __GFP_HARDWALL 0x40000u /* Enforce hardwall cpuset memory allocs */ 43#define __GFP_HARDWALL ((__force gfp_t)0x40000u) /* Enforce hardwall cpuset memory allocs */
44 44
45#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ 45#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
46#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) 46#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
47 47
48/* if you forget to add the bitmask here kernel will crash, period */ 48/* if you forget to add the bitmask here kernel will crash, period */
49#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ 49#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
@@ -64,6 +64,7 @@ struct vm_area_struct;
64 64
65#define GFP_DMA __GFP_DMA 65#define GFP_DMA __GFP_DMA
66 66
67#define gfp_zone(mask) ((__force int)((mask) & (__force gfp_t)GFP_ZONEMASK))
67 68
68/* 69/*
69 * There is only one page-allocator function, and two main namespaces to 70 * There is only one page-allocator function, and two main namespaces to
@@ -94,7 +95,7 @@ static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask,
94 return NULL; 95 return NULL;
95 96
96 return __alloc_pages(gfp_mask, order, 97 return __alloc_pages(gfp_mask, order,
97 NODE_DATA(nid)->node_zonelists + (gfp_mask & GFP_ZONEMASK)); 98 NODE_DATA(nid)->node_zonelists + gfp_zone(gfp_mask));
98} 99}
99 100
100#ifdef CONFIG_NUMA 101#ifdef CONFIG_NUMA
diff --git a/include/linux/hil.h b/include/linux/hil.h
new file mode 100644
index 000000000000..13352d7d0caf
--- /dev/null
+++ b/include/linux/hil.h
@@ -0,0 +1,483 @@
1#ifndef _HIL_H_
2#define _HIL_H_
3
4/*
5 * Hewlett Packard Human Interface Loop (HP-HIL) Protocol -- header.
6 *
7 * Copyright (c) 2001 Brian S. Julin
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions, and the following disclaimer,
15 * without modification.
16 * 2. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * Alternatively, this software may be distributed under the terms of the
20 * GNU General Public License ("GPL").
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 *
32 * References:
33 * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A
34 *
35 * A note of thanks to HP for providing and shipping reference materials
36 * free of charge to help in the development of HIL support for Linux.
37 *
38 */
39
40#include <asm/types.h>
41
42/* Physical constants relevant to raw loop/device timing.
43 */
44
45#define HIL_CLOCK 8MHZ
46#define HIL_EK1_CLOCK 30HZ
47#define HIL_EK2_CLOCK 60HZ
48
49#define HIL_TIMEOUT_DEV 5 /* ms */
50#define HIL_TIMEOUT_DEVS 10 /* ms */
51#define HIL_TIMEOUT_NORESP 10 /* ms */
52#define HIL_TIMEOUT_DEVS_DATA 16 /* ms */
53#define HIL_TIMEOUT_SELFTEST 200 /* ms */
54
55
56/* Actual wire line coding. These will only be useful if someone is
57 * implementing a software MLC to run HIL devices on a non-parisc machine.
58 */
59
60#define HIL_WIRE_PACKET_LEN 15
61enum hil_wire_bitpos {
62 HIL_WIRE_START = 0,
63 HIL_WIRE_ADDR2,
64 HIL_WIRE_ADDR1,
65 HIL_WIRE_ADDR0,
66 HIL_WIRE_COMMAND,
67 HIL_WIRE_DATA7,
68 HIL_WIRE_DATA6,
69 HIL_WIRE_DATA5,
70 HIL_WIRE_DATA4,
71 HIL_WIRE_DATA3,
72 HIL_WIRE_DATA2,
73 HIL_WIRE_DATA1,
74 HIL_WIRE_DATA0,
75 HIL_WIRE_PARITY,
76 HIL_WIRE_STOP
77};
78
79/* HP documentation uses these bit positions to refer to commands;
80 * we will call these "packets".
81 */
82enum hil_pkt_bitpos {
83 HIL_PKT_CMD = 0x00000800,
84 HIL_PKT_ADDR2 = 0x00000400,
85 HIL_PKT_ADDR1 = 0x00000200,
86 HIL_PKT_ADDR0 = 0x00000100,
87 HIL_PKT_ADDR_MASK = 0x00000700,
88 HIL_PKT_ADDR_SHIFT = 8,
89 HIL_PKT_DATA7 = 0x00000080,
90 HIL_PKT_DATA6 = 0x00000040,
91 HIL_PKT_DATA5 = 0x00000020,
92 HIL_PKT_DATA4 = 0x00000010,
93 HIL_PKT_DATA3 = 0x00000008,
94 HIL_PKT_DATA2 = 0x00000004,
95 HIL_PKT_DATA1 = 0x00000002,
96 HIL_PKT_DATA0 = 0x00000001,
97 HIL_PKT_DATA_MASK = 0x000000FF,
98 HIL_PKT_DATA_SHIFT = 0
99};
100
101/* The HIL MLC also has several error/status/control bits. We extend the
102 * "packet" to include these when direct access to the MLC is available,
103 * or emulate them in cases where they are not available.
104 *
105 * This way the device driver knows that the underlying MLC driver
106 * has had to deal with loop errors.
107 */
108enum hil_error_bitpos {
109 HIL_ERR_OB = 0x00000800, /* MLC is busy sending an auto-poll,
110 or we have filled up the output
111 buffer and must wait. */
112 HIL_ERR_INT = 0x00010000, /* A normal interrupt has occurred. */
113 HIL_ERR_NMI = 0x00020000, /* An NMI has occurred. */
114 HIL_ERR_LERR = 0x00040000, /* A poll didn't come back. */
115 HIL_ERR_PERR = 0x01000000, /* There was a Parity Error. */
116 HIL_ERR_FERR = 0x02000000, /* There was a Framing Error. */
117 HIL_ERR_FOF = 0x04000000 /* Input FIFO Overflowed. */
118};
119
120enum hil_control_bitpos {
121 HIL_CTRL_TEST = 0x00010000,
122 HIL_CTRL_IPF = 0x00040000,
123 HIL_CTRL_APE = 0x02000000
124};
125
126/* Bits 30,31 are unused, we use them to control write behavior. */
127#define HIL_DO_ALTER_CTRL 0x40000000 /* Write MSW of packet to control
128 before writing LSW to loop */
129#define HIL_CTRL_ONLY 0xc0000000 /* *Only* alter the control registers */
130
131/* This gives us a 32-bit "packet"
132 */
133typedef u32 hil_packet;
134
135
136/* HIL Loop commands
137 */
138enum hil_command {
139 HIL_CMD_IFC = 0x00, /* Interface Clear */
140 HIL_CMD_EPT = 0x01, /* Enter Pass-Thru Mode */
141 HIL_CMD_ELB = 0x02, /* Enter Loop-Back Mode */
142 HIL_CMD_IDD = 0x03, /* Identify and Describe */
143 HIL_CMD_DSR = 0x04, /* Device Soft Reset */
144 HIL_CMD_PST = 0x05, /* Perform Self Test */
145 HIL_CMD_RRG = 0x06, /* Read Register */
146 HIL_CMD_WRG = 0x07, /* Write Register */
147 HIL_CMD_ACF = 0x08, /* Auto Configure */
148 HIL_CMDID_ACF = 0x07, /* Auto Configure bits with incremented ID */
149 HIL_CMD_POL = 0x10, /* Poll */
150 HIL_CMDCT_POL = 0x0f, /* Poll command bits with item count */
151 HIL_CMD_RPL = 0x20, /* RePoll */
152 HIL_CMDCT_RPL = 0x0f, /* RePoll command bits with item count */
153 HIL_CMD_RNM = 0x30, /* Report Name */
154 HIL_CMD_RST = 0x31, /* Report Status */
155 HIL_CMD_EXD = 0x32, /* Extended Describe */
156 HIL_CMD_RSC = 0x33, /* Report Security Code */
157
158 /* 0x34 to 0x3c reserved for future use */
159
160 HIL_CMD_DKA = 0x3d, /* Disable Keyswitch Autorepeat */
161 HIL_CMD_EK1 = 0x3e, /* Enable Keyswitch Autorepeat 1 */
162 HIL_CMD_EK2 = 0x3f, /* Enable Keyswitch Autorepeat 2 */
163 HIL_CMD_PR1 = 0x40, /* Prompt1 */
164 HIL_CMD_PR2 = 0x41, /* Prompt2 */
165 HIL_CMD_PR3 = 0x42, /* Prompt3 */
166 HIL_CMD_PR4 = 0x43, /* Prompt4 */
167 HIL_CMD_PR5 = 0x44, /* Prompt5 */
168 HIL_CMD_PR6 = 0x45, /* Prompt6 */
169 HIL_CMD_PR7 = 0x46, /* Prompt7 */
170 HIL_CMD_PRM = 0x47, /* Prompt (General Purpose) */
171 HIL_CMD_AK1 = 0x48, /* Acknowlege1 */
172 HIL_CMD_AK2 = 0x49, /* Acknowlege2 */
173 HIL_CMD_AK3 = 0x4a, /* Acknowlege3 */
174 HIL_CMD_AK4 = 0x4b, /* Acknowlege4 */
175 HIL_CMD_AK5 = 0x4c, /* Acknowlege5 */
176 HIL_CMD_AK6 = 0x4d, /* Acknowlege6 */
177 HIL_CMD_AK7 = 0x4e, /* Acknowlege7 */
178 HIL_CMD_ACK = 0x4f, /* Acknowlege (General Purpose) */
179
180 /* 0x50 to 0x78 reserved for future use */
181 /* 0x80 to 0xEF device-specific commands */
182 /* 0xf0 to 0xf9 reserved for future use */
183
184 HIL_CMD_RIO = 0xfa, /* Register I/O Error */
185 HIL_CMD_SHR = 0xfb, /* System Hard Reset */
186 HIL_CMD_TER = 0xfc, /* Transmission Error */
187 HIL_CMD_CAE = 0xfd, /* Configuration Address Error */
188 HIL_CMD_DHR = 0xfe, /* Device Hard Reset */
189
190 /* 0xff is prohibited from use. */
191};
192
193
194/*
195 * Response "records" to HIL commands
196 */
197
198/* Device ID byte
199 */
200#define HIL_IDD_DID_TYPE_MASK 0xe0 /* Primary type bits */
201#define HIL_IDD_DID_TYPE_KB_INTEGRAL 0xa0 /* Integral keyboard */
202#define HIL_IDD_DID_TYPE_KB_ITF 0xc0 /* ITD keyboard */
203#define HIL_IDD_DID_TYPE_KB_RSVD 0xe0 /* Reserved keyboard type */
204#define HIL_IDD_DID_TYPE_KB_LANG_MASK 0x1f /* Keyboard locale bits */
205#define HIL_IDD_DID_KBLANG_USE_ESD 0x00 /* Use ESD Locale instead */
206#define HIL_IDD_DID_TYPE_ABS 0x80 /* Absolute Positioners */
207#define HIL_IDD_DID_ABS_RSVD1_MASK 0xf8 /* Reserved */
208#define HIL_IDD_DID_ABS_RSVD1 0x98
209#define HIL_IDD_DID_ABS_TABLET_MASK 0xf8 /* Tablets and digitizers */
210#define HIL_IDD_DID_ABS_TABLET 0x90
211#define HIL_IDD_DID_ABS_TSCREEN_MASK 0xfc /* Touch screens */
212#define HIL_IDD_DID_ABS_TSCREEN 0x8c
213#define HIL_IDD_DID_ABS_RSVD2_MASK 0xfc /* Reserved */
214#define HIL_IDD_DID_ABS_RSVD2 0x88
215#define HIL_IDD_DID_ABS_RSVD3_MASK 0xfc /* Reserved */
216#define HIL_IDD_DID_ABS_RSVD3 0x80
217#define HIL_IDD_DID_TYPE_REL 0x60 /* Relative Positioners */
218#define HIL_IDD_DID_REL_RSVD1_MASK 0xf0 /* Reserved */
219#define HIL_IDD_DID_REL_RSVD1 0x70
220#define HIL_IDD_DID_REL_RSVD2_MASK 0xfc /* Reserved */
221#define HIL_IDD_DID_REL_RSVD2 0x6c
222#define HIL_IDD_DID_REL_MOUSE_MASK 0xfc /* Mouse */
223#define HIL_IDD_DID_REL_MOUSE 0x68
224#define HIL_IDD_DID_REL_QUAD_MASK 0xf8 /* Other Quadrature Devices */
225#define HIL_IDD_DID_REL_QUAD 0x60
226#define HIL_IDD_DID_TYPE_CHAR 0x40 /* Character Entry */
227#define HIL_IDD_DID_CHAR_BARCODE_MASK 0xfc /* Barcode Reader */
228#define HIL_IDD_DID_CHAR_BARCODE 0x5c
229#define HIL_IDD_DID_CHAR_RSVD1_MASK 0xfc /* Reserved */
230#define HIL_IDD_DID_CHAR_RSVD1 0x58
231#define HIL_IDD_DID_CHAR_RSVD2_MASK 0xf8 /* Reserved */
232#define HIL_IDD_DID_CHAR_RSVD2 0x50
233#define HIL_IDD_DID_CHAR_RSVD3_MASK 0xf0 /* Reserved */
234#define HIL_IDD_DID_CHAR_RSVD3 0x40
235#define HIL_IDD_DID_TYPE_OTHER 0x20 /* Miscellaneous */
236#define HIL_IDD_DID_OTHER_RSVD1_MASK 0xf0 /* Reserved */
237#define HIL_IDD_DID_OTHER_RSVD1 0x30
238#define HIL_IDD_DID_OTHER_BARCODE_MASK 0xfc /* Tone Generator */
239#define HIL_IDD_DID_OTHER_BARCODE 0x2c
240#define HIL_IDD_DID_OTHER_RSVD2_MASK 0xfc /* Reserved */
241#define HIL_IDD_DID_OTHER_RSVD2 0x28
242#define HIL_IDD_DID_OTHER_RSVD3_MASK 0xf8 /* Reserved */
243#define HIL_IDD_DID_OTHER_RSVD3 0x20
244#define HIL_IDD_DID_TYPE_KEYPAD 0x00 /* Vectra Keyboard */
245
246/* IDD record header
247 */
248#define HIL_IDD_HEADER_AXSET_MASK 0x03 /* Number of axis in a set */
249#define HIL_IDD_HEADER_RSC 0x04 /* Supports RSC command */
250#define HIL_IDD_HEADER_EXD 0x08 /* Supports EXD command */
251#define HIL_IDD_HEADER_IOD 0x10 /* IOD byte to follow */
252#define HIL_IDD_HEADER_16BIT 0x20 /* 16 (vs. 8) bit resolution */
253#define HIL_IDD_HEADER_ABS 0x40 /* Reports Absolute Position */
254#define HIL_IDD_HEADER_2X_AXIS 0x80 /* Two sets of 1-3 axis */
255
256/* I/O Descriptor
257 */
258#define HIL_IDD_IOD_NBUTTON_MASK 0x07 /* Number of buttons */
259#define HIL_IDD_IOD_PROXIMITY 0x08 /* Proximity in/out events */
260#define HIL_IDD_IOD_PROMPT_MASK 0x70 /* Number of prompts/acks */
261#define HIL_IDD_IOD_PROMPT_SHIFT 4
262#define HIL_IDD_IOD_PROMPT 0x80 /* Generic prompt/ack */
263
264#define HIL_IDD_NUM_AXES_PER_SET(header_packet) \
265((header_packet) & HIL_IDD_HEADER_AXSET_MASK)
266
267#define HIL_IDD_NUM_AXSETS(header_packet) \
268(2 - !((header_packet) & HIL_IDD_HEADER_2X_AXIS))
269
270#define HIL_IDD_LEN(header_packet) \
271((4 - !(header_packet & HIL_IDD_HEADER_IOD) - \
272 2 * !(HIL_IDD_NUM_AXES_PER_SET(header_packet))) + \
273 2 * HIL_IDD_NUM_AXES_PER_SET(header_packet) * \
274 !!((header_packet) & HIL_IDD_HEADER_ABS))
275
276/* The following HIL_IDD_* macros assume you have an array of
277 * packets and/or unpacked 8-bit data in the order that they
278 * were received.
279 */
280
281#define HIL_IDD_AXIS_COUNTS_PER_M(header_ptr) \
282(!(HIL_IDD_NUM_AXSETS(*(header_ptr))) ? -1 : \
283(((*(header_ptr + 1) & HIL_PKT_DATA_MASK) + \
284 ((*(header_ptr + 2) & HIL_PKT_DATA_MASK)) << 8) \
285* ((*(header_ptr) & HIL_IDD_HEADER_16BIT) ? 100 : 1)))
286
287#define HIL_IDD_AXIS_MAX(header_ptr, __axnum) \
288((!(*(header_ptr) & HIL_IDD_HEADER_ABS) || \
289 (HIL_IDD_NUM_AXES_PER_SET(*(header_ptr)) <= __axnum)) ? 0 : \
290 ((HIL_PKT_DATA_MASK & *((header_ptr) + 3 + 2 * __axnum)) + \
291 ((HIL_PKT_DATA_MASK & *((header_ptr) + 4 + 2 * __axnum)) << 8)))
292
293#define HIL_IDD_IOD(header_ptr) \
294(*(header_ptr + HIL_IDD_LEN((*header_ptr)) - 1))
295
296#define HIL_IDD_HAS_GEN_PROMPT(header_ptr) \
297((*header_ptr & HIL_IDD_HEADER_IOD) && \
298 (HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_PROMPT))
299
300#define HIL_IDD_HAS_GEN_PROXIMITY(header_ptr) \
301((*header_ptr & HIL_IDD_HEADER_IOD) && \
302 (HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_PROXIMITY))
303
304#define HIL_IDD_NUM_BUTTONS(header_ptr) \
305((*header_ptr & HIL_IDD_HEADER_IOD) ? \
306 (HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_NBUTTON_MASK) : 0)
307
308#define HIL_IDD_NUM_PROMPTS(header_ptr) \
309((*header_ptr & HIL_IDD_HEADER_IOD) ? \
310 ((HIL_IDD_IOD(header_ptr) & HIL_IDD_IOD_NPROMPT_MASK) \
311 >> HIL_IDD_IOD_PROMPT_SHIFT) : 0)
312
313/* The response to HIL EXD commands -- the "extended describe record" */
314#define HIL_EXD_HEADER_WRG 0x03 /* Supports type2 WRG */
315#define HIL_EXD_HEADER_WRG_TYPE1 0x01 /* Supports type1 WRG */
316#define HIL_EXD_HEADER_WRG_TYPE2 0x02 /* Supports type2 WRG */
317#define HIL_EXD_HEADER_RRG 0x04 /* Supports RRG command */
318#define HIL_EXD_HEADER_RNM 0x10 /* Supports RNM command */
319#define HIL_EXD_HEADER_RST 0x20 /* Supports RST command */
320#define HIL_EXD_HEADER_LOCALE 0x40 /* Contains locale code */
321
322#define HIL_EXD_NUM_RRG(header_ptr) \
323((*header_ptr & HIL_EXD_HEADER_RRG) ? \
324 (*(header_ptr + 1) & HIL_PKT_DATA_MASK) : 0)
325
326#define HIL_EXD_NUM_WWG(header_ptr) \
327((*header_ptr & HIL_EXD_HEADER_WRG) ? \
328 (*(header_ptr + 2 - !(*header_ptr & HIL_EXD_HEADER_RRG)) & \
329 HIL_PKT_DATA_MASK) : 0)
330
331#define HIL_EXD_LEN(header_ptr) \
332(!!(*header_ptr & HIL_EXD_HEADER_RRG) + \
333 !!(*header_ptr & HIL_EXD_HEADER_WRG) + \
334 !!(*header_ptr & HIL_EXD_HEADER_LOCALE) + \
335 2 * !!(*header_ptr & HIL_EXD_HEADER_WRG_TYPE2) + 1)
336
337#define HIL_EXD_LOCALE(header_ptr) \
338(!(*header_ptr & HIL_EXD_HEADER_LOCALE) ? -1 : \
339 (*(header_ptr + HIL_EXD_LEN(header_ptr) - 1) & HIL_PKT_DATA_MASK))
340
341#define HIL_EXD_WRG_TYPE2_LEN(header_ptr) \
342(!(*header_ptr & HIL_EXD_HEADER_WRG_TYPE2) ? -1 : \
343 (*(header_ptr + HIL_EXD_LEN(header_ptr) - 2 - \
344 !!(*header_ptr & HIL_EXD_HEADER_LOCALE)) & HIL_PKT_DATA_MASK) + \
345 ((*(header_ptr + HIL_EXD_LEN(header_ptr) - 1 - \
346 !!(*header_ptr & HIL_EXD_HEADER_LOCALE)) & HIL_PKT_DATA_MASK) << 8))
347
348/* Device locale codes. */
349
350/* Last defined locale code. Everything above this is "Reserved",
351 and note that this same table applies to the Device ID Byte where
352 keyboards may have a nationality code which is only 5 bits. */
353#define HIL_LOCALE_MAX 0x1f
354
355/* Map to hopefully useful strings. I was trying to make these look
356 like locale.aliases strings do; maybe that isn't the right table to
357 emulate. In either case, I didn't have much to work on. */
358#define HIL_LOCALE_MAP \
359"", /* 0x00 Reserved */ \
360"", /* 0x01 Reserved */ \
361"", /* 0x02 Reserved */ \
362"swiss.french", /* 0x03 Swiss/French */ \
363"portuguese", /* 0x04 Portuguese */ \
364"arabic", /* 0x05 Arabic */ \
365"hebrew", /* 0x06 Hebrew */ \
366"english.canadian", /* 0x07 Canadian English */ \
367"turkish", /* 0x08 Turkish */ \
368"greek", /* 0x09 Greek */ \
369"thai", /* 0x0a Thai (Thailand) */ \
370"italian", /* 0x0b Italian */ \
371"korean", /* 0x0c Hangul (Korea) */ \
372"dutch", /* 0x0d Dutch */ \
373"swedish", /* 0x0e Swedish */ \
374"german", /* 0x0f German */ \
375"chinese", /* 0x10 Chinese-PRC */ \
376"chinese", /* 0x11 Chinese-ROC */ \
377"swiss.french", /* 0x12 Swiss/French II */ \
378"spanish", /* 0x13 Spanish */ \
379"swiss.german", /* 0x14 Swiss/German II */ \
380"flemish", /* 0x15 Belgian (Flemish) */ \
381"finnish", /* 0x16 Finnish */ \
382"english.uk", /* 0x17 United Kingdom */ \
383"french.canadian", /* 0x18 French/Canadian */ \
384"swiss.german", /* 0x19 Swiss/German */ \
385"norwegian", /* 0x1a Norwegian */ \
386"french", /* 0x1b French */ \
387"danish", /* 0x1c Danish */ \
388"japanese", /* 0x1d Katakana */ \
389"spanish", /* 0x1e Latin American/Spanish*/\
390"english.us" /* 0x1f United States */ \
391
392
393/* HIL keycodes */
394#define HIL_KEYCODES_SET1_TBLSIZE 128
395#define HIL_KEYCODES_SET1 \
396 KEY_5, KEY_RESERVED, KEY_RIGHTALT, KEY_LEFTALT, \
397 KEY_RIGHTSHIFT, KEY_LEFTSHIFT, KEY_LEFTCTRL, KEY_SYSRQ, \
398 KEY_KP4, KEY_KP8, KEY_KP5, KEY_KP9, \
399 KEY_KP6, KEY_KP7, KEY_KPCOMMA, KEY_KPENTER, \
400 KEY_KP1, KEY_KPSLASH, KEY_KP2, KEY_KPPLUS, \
401 KEY_KP3, KEY_KPASTERISK, KEY_KP0, KEY_KPMINUS, \
402 KEY_B, KEY_V, KEY_C, KEY_X, \
403 KEY_Z, KEY_RESERVED, KEY_RESERVED, KEY_ESC, \
404 KEY_6, KEY_F10, KEY_3, KEY_F11, \
405 KEY_KPDOT, KEY_F9, KEY_TAB /*KP*/, KEY_F12, \
406 KEY_H, KEY_G, KEY_F, KEY_D, \
407 KEY_S, KEY_A, KEY_RESERVED, KEY_CAPSLOCK, \
408 KEY_U, KEY_Y, KEY_T, KEY_R, \
409 KEY_E, KEY_W, KEY_Q, KEY_TAB, \
410 KEY_7, KEY_6, KEY_5, KEY_4, \
411 KEY_3, KEY_2, KEY_1, KEY_GRAVE, \
412 KEY_F13, KEY_F14, KEY_F15, KEY_F16, \
413 KEY_F17, KEY_F18, KEY_F19, KEY_F20, \
414 KEY_MENU, KEY_F4, KEY_F3, KEY_F2, \
415 KEY_F1, KEY_VOLUMEUP, KEY_STOP, KEY_SENDFILE, \
416 KEY_SYSRQ, KEY_F5, KEY_F6, KEY_F7, \
417 KEY_F8, KEY_VOLUMEDOWN, KEY_DEL_EOL, KEY_DEL_EOS, \
418 KEY_8, KEY_9, KEY_0, KEY_MINUS, \
419 KEY_EQUAL, KEY_BACKSPACE, KEY_INS_LINE, KEY_DEL_LINE, \
420 KEY_I, KEY_O, KEY_P, KEY_LEFTBRACE, \
421 KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_INSERT, KEY_DELETE, \
422 KEY_J, KEY_K, KEY_L, KEY_SEMICOLON, \
423 KEY_APOSTROPHE, KEY_ENTER, KEY_HOME, KEY_PAGEUP, \
424 KEY_M, KEY_COMMA, KEY_DOT, KEY_SLASH, \
425 KEY_BACKSLASH, KEY_SELECT, KEY_102ND, KEY_PAGEDOWN, \
426 KEY_N, KEY_SPACE, KEY_NEXT, KEY_RESERVED, \
427 KEY_LEFT, KEY_DOWN, KEY_UP, KEY_RIGHT
428
429
430#define HIL_KEYCODES_SET3_TBLSIZE 128
431#define HIL_KEYCODES_SET3 \
432 KEY_RESERVED, KEY_ESC, KEY_1, KEY_2, \
433 KEY_3, KEY_4, KEY_5, KEY_6, \
434 KEY_7, KEY_8, KEY_9, KEY_0, \
435 KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_TAB, \
436 KEY_Q, KEY_W, KEY_E, KEY_R, \
437 KEY_T, KEY_Y, KEY_U, KEY_I, \
438 KEY_O, KEY_P, KEY_LEFTBRACE, KEY_RIGHTBRACE, \
439 KEY_ENTER, KEY_LEFTCTRL, KEY_A, KEY_S, \
440 KEY_D, KEY_F, KEY_G, KEY_H, \
441 KEY_J, KEY_K, KEY_L, KEY_SEMICOLON, \
442 KEY_APOSTROPHE,KEY_GRAVE, KEY_LEFTSHIFT, KEY_BACKSLASH, \
443 KEY_Z, KEY_X, KEY_C, KEY_V, \
444 KEY_B, KEY_N, KEY_M, KEY_COMMA, \
445 KEY_DOT, KEY_SLASH, KEY_RIGHTSHIFT, KEY_KPASTERISK, \
446 KEY_LEFTALT, KEY_SPACE, KEY_CAPSLOCK, KEY_F1, \
447 KEY_F2, KEY_F3, KEY_F4, KEY_F5, \
448 KEY_F6, KEY_F7, KEY_F8, KEY_F9, \
449 KEY_F10, KEY_NUMLOCK, KEY_SCROLLLOCK, KEY_KP7, \
450 KEY_KP8, KEY_KP9, KEY_KPMINUS, KEY_KP4, \
451 KEY_KP5, KEY_KP6, KEY_KPPLUS, KEY_KP1, \
452 KEY_KP2, KEY_KP3, KEY_KP0, KEY_KPDOT, \
453 KEY_SYSRQ, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, \
454 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, \
455 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, \
456 KEY_UP, KEY_LEFT, KEY_DOWN, KEY_RIGHT, \
457 KEY_HOME, KEY_PAGEUP, KEY_END, KEY_PAGEDOWN, \
458 KEY_INSERT, KEY_DELETE, KEY_102ND, KEY_RESERVED, \
459 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, \
460 KEY_F1, KEY_F2, KEY_F3, KEY_F4, \
461 KEY_F5, KEY_F6, KEY_F7, KEY_F8, \
462 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, \
463 KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED
464
465
466/* Response to POL command, the "poll record header" */
467
468#define HIL_POL_NUM_AXES_MASK 0x03 /* Number of axis reported */
469#define HIL_POL_CTS 0x04 /* Device ready to receive data */
470#define HIL_POL_STATUS_PENDING 0x08 /* Device has status to report */
471#define HIL_POL_CHARTYPE_MASK 0x70 /* Type of character data to follow */
472#define HIL_POL_CHARTYPE_NONE 0x00 /* No character data to follow */
473#define HIL_POL_CHARTYPE_RSVD1 0x10 /* Reserved Set 1 */
474#define HIL_POL_CHARTYPE_ASCII 0x20 /* U.S. ASCII */
475#define HIL_POL_CHARTYPE_BINARY 0x30 /* Binary data */
476#define HIL_POL_CHARTYPE_SET1 0x40 /* Keycode Set 1 */
477#define HIL_POL_CHARTYPE_RSVD2 0x50 /* Reserved Set 2 */
478#define HIL_POL_CHARTYPE_SET2 0x60 /* Keycode Set 2 */
479#define HIL_POL_CHARTYPE_SET3 0x70 /* Keycode Set 3 */
480#define HIL_POL_AXIS_ALT 0x80 /* Data is from axis set 2 */
481
482
483#endif /* _HIL_H_ */
diff --git a/include/linux/hil_mlc.h b/include/linux/hil_mlc.h
new file mode 100644
index 000000000000..8df29ca48a13
--- /dev/null
+++ b/include/linux/hil_mlc.h
@@ -0,0 +1,168 @@
1/*
2 * HP Human Interface Loop Master Link Controller driver.
3 *
4 * Copyright (c) 2001 Brian S. Julin
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * Alternatively, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL").
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 *
29 * References:
30 * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A
31 *
32 */
33
34#include <linux/hil.h>
35#include <linux/time.h>
36#include <linux/interrupt.h>
37#include <asm/semaphore.h>
38#include <linux/serio.h>
39#include <linux/list.h>
40
41typedef struct hil_mlc hil_mlc;
42
43/* The HIL has a complicated state engine.
44 * We define the structure of nodes in the state engine here.
45 */
46enum hilse_act {
47 /* HILSE_OUT prepares to receive input if the next node
48 * is an IN or EXPECT, and then sends the given packet.
49 */
50 HILSE_OUT = 0,
51
52 /* HILSE_CTS checks if the loop is busy. */
53 HILSE_CTS,
54
55 /* HILSE_OUT_LAST sends the given command packet to
56 * the last configured/running device on the loop.
57 */
58 HILSE_OUT_LAST,
59
60 /* HILSE_OUT_DISC sends the given command packet to
61 * the next device past the last configured/running one.
62 */
63 HILSE_OUT_DISC,
64
65 /* HILSE_FUNC runs a callback function with given arguments.
66 * a positive return value causes the "ugly" branch to be taken.
67 */
68 HILSE_FUNC,
69
70 /* HILSE_IN simply expects any non-errored packet to arrive
71 * within arg usecs.
72 */
73 HILSE_IN = 0x100,
74
75 /* HILSE_EXPECT expects a particular packet to arrive
76 * within arg usecs, any other packet is considered an error.
77 */
78 HILSE_EXPECT,
79
80 /* HILSE_EXPECT_LAST as above but dev field should be last
81 * discovered/operational device.
82 */
83 HILSE_EXPECT_LAST,
84
85 /* HILSE_EXPECT_LAST as above but dev field should be first
86 * undiscovered/inoperational device.
87 */
88 HILSE_EXPECT_DISC
89};
90
91typedef int (hilse_func) (hil_mlc *mlc, int arg);
92struct hilse_node {
93 enum hilse_act act; /* How to process this node */
94 union {
95 hilse_func *func; /* Function to call if HILSE_FUNC */
96 hil_packet packet; /* Packet to send or to compare */
97 } object;
98 int arg; /* Timeout in usec or parm for func */
99 int good; /* Node to jump to on success */
100 int bad; /* Node to jump to on error */
101 int ugly; /* Node to jump to on timeout */
102};
103
104/* Methods for back-end drivers, e.g. hp_sdc_mlc */
105typedef int (hil_mlc_cts) (hil_mlc *mlc);
106typedef void (hil_mlc_out) (hil_mlc *mlc);
107typedef int (hil_mlc_in) (hil_mlc *mlc, suseconds_t timeout);
108
109struct hil_mlc_devinfo {
110 uint8_t idd[16]; /* Device ID Byte and Describe Record */
111 uint8_t rsc[16]; /* Security Code Header and Record */
112 uint8_t exd[16]; /* Extended Describe Record */
113 uint8_t rnm[16]; /* Device name as returned by RNM command */
114};
115
116struct hil_mlc_serio_map {
117 hil_mlc *mlc;
118 int di_revmap;
119 int didx;
120};
121
122/* How many (possibly old/detached) devices the we try to keep track of */
123#define HIL_MLC_DEVMEM 16
124
125struct hil_mlc {
126 struct list_head list; /* hil_mlc is organized as linked list */
127
128 rwlock_t lock;
129
130 void *priv; /* Data specific to a particular type of MLC */
131
132 int seidx; /* Current node in state engine */
133 int istarted, ostarted;
134
135 hil_mlc_cts *cts;
136 struct semaphore csem; /* Raised when loop idle */
137
138 hil_mlc_out *out;
139 struct semaphore osem; /* Raised when outpacket dispatched */
140 hil_packet opacket;
141
142 hil_mlc_in *in;
143 struct semaphore isem; /* Raised when a packet arrives */
144 hil_packet ipacket[16];
145 hil_packet imatch;
146 int icount;
147 struct timeval instart;
148 suseconds_t intimeout;
149
150 int ddi; /* Last operational device id */
151 int lcv; /* LCV to throttle loops */
152 struct timeval lcv_tv; /* Time loop was started */
153
154 int di_map[7]; /* Maps below items to live devs */
155 struct hil_mlc_devinfo di[HIL_MLC_DEVMEM];
156 struct serio *serio[HIL_MLC_DEVMEM];
157 struct hil_mlc_serio_map serio_map[HIL_MLC_DEVMEM];
158 hil_packet serio_opacket[HIL_MLC_DEVMEM];
159 int serio_oidx[HIL_MLC_DEVMEM];
160 struct hil_mlc_devinfo di_scratch; /* Temporary area */
161
162 int opercnt;
163
164 struct tasklet_struct *tasklet;
165};
166
167int hil_mlc_register(hil_mlc *mlc);
168int hil_mlc_unregister(hil_mlc *mlc);
diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h
new file mode 100644
index 000000000000..debd71515312
--- /dev/null
+++ b/include/linux/hp_sdc.h
@@ -0,0 +1,300 @@
1/*
2 * HP i8042 System Device Controller -- header
3 *
4 * Copyright (c) 2001 Brian S. Julin
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * Alternatively, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL").
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 *
29 * References:
30 *
31 * HP-HIL Technical Reference Manual. Hewlett Packard Product No. 45918A
32 *
33 * System Device Controller Microprocessor Firmware Theory of Operation
34 * for Part Number 1820-4784 Revision B. Dwg No. A-1820-4784-2
35 *
36 */
37
38#ifndef _LINUX_HP_SDC_H
39#define _LINUX_HP_SDC_H
40
41#include <linux/interrupt.h>
42#include <linux/types.h>
43#include <linux/time.h>
44#include <linux/timer.h>
45#if defined(__hppa__)
46#include <asm/hardware.h>
47#endif
48
49
50/* No 4X status reads take longer than this (in usec).
51 */
52#define HP_SDC_MAX_REG_DELAY 20000
53
54typedef void (hp_sdc_irqhook) (int irq, void *dev_id,
55 uint8_t status, uint8_t data);
56
57int hp_sdc_request_timer_irq(hp_sdc_irqhook *callback);
58int hp_sdc_request_hil_irq(hp_sdc_irqhook *callback);
59int hp_sdc_request_cooked_irq(hp_sdc_irqhook *callback);
60int hp_sdc_release_timer_irq(hp_sdc_irqhook *callback);
61int hp_sdc_release_hil_irq(hp_sdc_irqhook *callback);
62int hp_sdc_release_cooked_irq(hp_sdc_irqhook *callback);
63
64typedef struct {
65 int actidx; /* Start of act. Acts are atomic WRT I/O to SDC */
66 int idx; /* Index within the act */
67 int endidx; /* transaction is over and done if idx == endidx */
68 uint8_t *seq; /* commands/data for the transaction */
69 union {
70 hp_sdc_irqhook *irqhook; /* Callback, isr or tasklet context */
71 struct semaphore *semaphore; /* Semaphore to sleep on. */
72 } act;
73} hp_sdc_transaction;
74int hp_sdc_enqueue_transaction(hp_sdc_transaction *this);
75int hp_sdc_dequeue_transaction(hp_sdc_transaction *this);
76
77/* The HP_SDC_ACT* values are peculiar to this driver.
78 * Nuance: never HP_SDC_ACT_DATAIN | HP_SDC_ACT_DEALLOC, use another
79 * act to perform the dealloc.
80 */
81#define HP_SDC_ACT_PRECMD 0x01 /* Send a command first */
82#define HP_SDC_ACT_DATAREG 0x02 /* Set data registers */
83#define HP_SDC_ACT_DATAOUT 0x04 /* Send data bytes */
84#define HP_SDC_ACT_POSTCMD 0x08 /* Send command after */
85#define HP_SDC_ACT_DATAIN 0x10 /* Collect data after */
86#define HP_SDC_ACT_DURING 0x1f
87#define HP_SDC_ACT_SEMAPHORE 0x20 /* Raise semaphore after */
88#define HP_SDC_ACT_CALLBACK 0x40 /* Pass data to IRQ handler */
89#define HP_SDC_ACT_DEALLOC 0x80 /* Destroy transaction after */
90#define HP_SDC_ACT_AFTER 0xe0
91#define HP_SDC_ACT_DEAD 0x60 /* Act timed out. */
92
93/* Rest of the flags are straightforward representation of the SDC interface */
94#define HP_SDC_STATUS_IBF 0x02 /* Input buffer full */
95
96#define HP_SDC_STATUS_IRQMASK 0xf0 /* Bits containing "level 1" irq */
97#define HP_SDC_STATUS_PERIODIC 0x10 /* Periodic 10ms timer */
98#define HP_SDC_STATUS_USERTIMER 0x20 /* "Special purpose" timer */
99#define HP_SDC_STATUS_TIMER 0x30 /* Both PERIODIC and USERTIMER */
100#define HP_SDC_STATUS_REG 0x40 /* Data from an i8042 register */
101#define HP_SDC_STATUS_HILCMD 0x50 /* Command from HIL MLC */
102#define HP_SDC_STATUS_HILDATA 0x60 /* Data from HIL MLC */
103#define HP_SDC_STATUS_PUP 0x70 /* Sucessful power-up self test */
104#define HP_SDC_STATUS_KCOOKED 0x80 /* Key from cooked kbd */
105#define HP_SDC_STATUS_KRPG 0xc0 /* Key from Repeat Gen */
106#define HP_SDC_STATUS_KMOD_SUP 0x10 /* Shift key is up */
107#define HP_SDC_STATUS_KMOD_CUP 0x20 /* Control key is up */
108
109#define HP_SDC_NMISTATUS_FHS 0x40 /* NMI is a fast handshake irq */
110
111/* Internal i8042 registers (there are more, but they are not too useful). */
112
113#define HP_SDC_USE 0x02 /* Resource usage (including OB bit) */
114#define HP_SDC_IM 0x04 /* Interrupt mask */
115#define HP_SDC_CFG 0x11 /* Configuration register */
116#define HP_SDC_KBLANGUAGE 0x12 /* Keyboard language */
117
118#define HP_SDC_D0 0x70 /* General purpose data buffer 0 */
119#define HP_SDC_D1 0x71 /* General purpose data buffer 1 */
120#define HP_SDC_D2 0x72 /* General purpose data buffer 2 */
121#define HP_SDC_D3 0x73 /* General purpose data buffer 3 */
122#define HP_SDC_VT1 0x74 /* Timer for voice 1 */
123#define HP_SDC_VT2 0x75 /* Timer for voice 2 */
124#define HP_SDC_VT3 0x76 /* Timer for voice 3 */
125#define HP_SDC_VT4 0x77 /* Timer for voice 4 */
126#define HP_SDC_KBN 0x78 /* Which HIL devs are Nimitz */
127#define HP_SDC_KBC 0x79 /* Which HIL devs are cooked kbds */
128#define HP_SDC_LPS 0x7a /* i8042's view of HIL status */
129#define HP_SDC_LPC 0x7b /* i8042's view of HIL "control" */
130#define HP_SDC_RSV 0x7c /* Reserved "for testing" */
131#define HP_SDC_LPR 0x7d /* i8042 count of HIL reconfigs */
132#define HP_SDC_XTD 0x7e /* "Extended Configuration" register */
133#define HP_SDC_STR 0x7f /* i8042 self-test result */
134
135/* Bitfields for above registers */
136#define HP_SDC_USE_LOOP 0x04 /* Command is currently on the loop. */
137
138#define HP_SDC_IM_MASK 0x1f /* these bits not part of cmd/status */
139#define HP_SDC_IM_FH 0x10 /* Mask the fast handshake irq */
140#define HP_SDC_IM_PT 0x08 /* Mask the periodic timer irq */
141#define HP_SDC_IM_TIMERS 0x04 /* Mask the MT/DT/CT irq */
142#define HP_SDC_IM_RESET 0x02 /* Mask the reset key irq */
143#define HP_SDC_IM_HIL 0x01 /* Mask the HIL MLC irq */
144
145#define HP_SDC_CFG_ROLLOVER 0x08 /* WTF is "N-key rollover"? */
146#define HP_SDC_CFG_KBD 0x10 /* There is a keyboard */
147#define HP_SDC_CFG_NEW 0x20 /* Supports/uses HIL MLC */
148#define HP_SDC_CFG_KBD_OLD 0x03 /* keyboard code for non-HIL */
149#define HP_SDC_CFG_KBD_NEW 0x07 /* keyboard code from HIL autoconfig */
150#define HP_SDC_CFG_REV 0x40 /* Code revision bit */
151#define HP_SDC_CFG_IDPROM 0x80 /* IDPROM present in kbd (not HIL) */
152
153#define HP_SDC_LPS_NDEV 0x07 /* # devices autoconfigured on HIL */
154#define HP_SDC_LPS_ACSUCC 0x08 /* loop autoconfigured successfully */
155#define HP_SDC_LPS_ACFAIL 0x80 /* last loop autoconfigure failed */
156
157#define HP_SDC_LPC_APE_IPF 0x01 /* HIL MLC APE/IPF (autopoll) set */
158#define HP_SDC_LPC_ARCONERR 0x02 /* i8042 autoreconfigs loop on err */
159#define HP_SDC_LPC_ARCQUIET 0x03 /* i8042 doesn't report autoreconfigs*/
160#define HP_SDC_LPC_COOK 0x10 /* i8042 cooks devices in _KBN */
161#define HP_SDC_LPC_RC 0x80 /* causes autoreconfig */
162
163#define HP_SDC_XTD_REV 0x07 /* contains revision code */
164#define HP_SDC_XTD_REV_STRINGS(val, str) \
165switch (val) { \
166 case 0x1: str = "1820-3712"; break; \
167 case 0x2: str = "1820-4379"; break; \
168 case 0x3: str = "1820-4784"; break; \
169 default: str = "unknown"; \
170};
171#define HP_SDC_XTD_BEEPER 0x08 /* TI SN76494 beeper available */
172#define HP_SDC_XTD_BBRTC 0x20 /* OKI MSM-58321 BBRTC present */
173
174#define HP_SDC_CMD_LOAD_RT 0x31 /* Load real time (from 8042) */
175#define HP_SDC_CMD_LOAD_FHS 0x36 /* Load the fast handshake timer */
176#define HP_SDC_CMD_LOAD_MT 0x38 /* Load the match timer */
177#define HP_SDC_CMD_LOAD_DT 0x3B /* Load the delay timer */
178#define HP_SDC_CMD_LOAD_CT 0x3E /* Load the cycle timer */
179
180#define HP_SDC_CMD_SET_IM 0x40 /* 010xxxxx == set irq mask */
181
182/* The documents provided do not explicitly state that all registers betweem
183 * 0x01 and 0x1f inclusive can be read by sending their register index as a
184 * command, but this is implied and appears to be the case.
185 */
186#define HP_SDC_CMD_READ_RAM 0x00 /* Load from i8042 RAM (autoinc) */
187#define HP_SDC_CMD_READ_USE 0x02 /* Undocumented! Load from usage reg */
188#define HP_SDC_CMD_READ_IM 0x04 /* Load current interrupt mask */
189#define HP_SDC_CMD_READ_KCC 0x11 /* Load primary kbd config code */
190#define HP_SDC_CMD_READ_KLC 0x12 /* Load primary kbd language code */
191#define HP_SDC_CMD_READ_T1 0x13 /* Load timer output buffer byte 1 */
192#define HP_SDC_CMD_READ_T2 0x14 /* Load timer output buffer byte 1 */
193#define HP_SDC_CMD_READ_T3 0x15 /* Load timer output buffer byte 1 */
194#define HP_SDC_CMD_READ_T4 0x16 /* Load timer output buffer byte 1 */
195#define HP_SDC_CMD_READ_T5 0x17 /* Load timer output buffer byte 1 */
196#define HP_SDC_CMD_READ_D0 0xf0 /* Load from i8042 RAM location 0x70 */
197#define HP_SDC_CMD_READ_D1 0xf1 /* Load from i8042 RAM location 0x71 */
198#define HP_SDC_CMD_READ_D2 0xf2 /* Load from i8042 RAM location 0x72 */
199#define HP_SDC_CMD_READ_D3 0xf3 /* Load from i8042 RAM location 0x73 */
200#define HP_SDC_CMD_READ_VT1 0xf4 /* Load from i8042 RAM location 0x74 */
201#define HP_SDC_CMD_READ_VT2 0xf5 /* Load from i8042 RAM location 0x75 */
202#define HP_SDC_CMD_READ_VT3 0xf6 /* Load from i8042 RAM location 0x76 */
203#define HP_SDC_CMD_READ_VT4 0xf7 /* Load from i8042 RAM location 0x77 */
204#define HP_SDC_CMD_READ_KBN 0xf8 /* Load from i8042 RAM location 0x78 */
205#define HP_SDC_CMD_READ_KBC 0xf9 /* Load from i8042 RAM location 0x79 */
206#define HP_SDC_CMD_READ_LPS 0xfa /* Load from i8042 RAM location 0x7a */
207#define HP_SDC_CMD_READ_LPC 0xfb /* Load from i8042 RAM location 0x7b */
208#define HP_SDC_CMD_READ_RSV 0xfc /* Load from i8042 RAM location 0x7c */
209#define HP_SDC_CMD_READ_LPR 0xfd /* Load from i8042 RAM location 0x7d */
210#define HP_SDC_CMD_READ_XTD 0xfe /* Load from i8042 RAM location 0x7e */
211#define HP_SDC_CMD_READ_STR 0xff /* Load from i8042 RAM location 0x7f */
212
213#define HP_SDC_CMD_SET_ARD 0xA0 /* Set emulated autorepeat delay */
214#define HP_SDC_CMD_SET_ARR 0xA2 /* Set emulated autorepeat rate */
215#define HP_SDC_CMD_SET_BELL 0xA3 /* Set voice 3 params for "beep" cmd */
216#define HP_SDC_CMD_SET_RPGR 0xA6 /* Set "RPG" irq rate (doesn't work) */
217#define HP_SDC_CMD_SET_RTMS 0xAD /* Set the RTC time (milliseconds) */
218#define HP_SDC_CMD_SET_RTD 0xAF /* Set the RTC time (days) */
219#define HP_SDC_CMD_SET_FHS 0xB2 /* Set fast handshake timer */
220#define HP_SDC_CMD_SET_MT 0xB4 /* Set match timer */
221#define HP_SDC_CMD_SET_DT 0xB7 /* Set delay timer */
222#define HP_SDC_CMD_SET_CT 0xBA /* Set cycle timer */
223#define HP_SDC_CMD_SET_RAMP 0xC1 /* Reset READ_RAM autoinc counter */
224#define HP_SDC_CMD_SET_D0 0xe0 /* Load to i8042 RAM location 0x70 */
225#define HP_SDC_CMD_SET_D1 0xe1 /* Load to i8042 RAM location 0x71 */
226#define HP_SDC_CMD_SET_D2 0xe2 /* Load to i8042 RAM location 0x72 */
227#define HP_SDC_CMD_SET_D3 0xe3 /* Load to i8042 RAM location 0x73 */
228#define HP_SDC_CMD_SET_VT1 0xe4 /* Load to i8042 RAM location 0x74 */
229#define HP_SDC_CMD_SET_VT2 0xe5 /* Load to i8042 RAM location 0x75 */
230#define HP_SDC_CMD_SET_VT3 0xe6 /* Load to i8042 RAM location 0x76 */
231#define HP_SDC_CMD_SET_VT4 0xe7 /* Load to i8042 RAM location 0x77 */
232#define HP_SDC_CMD_SET_KBN 0xe8 /* Load to i8042 RAM location 0x78 */
233#define HP_SDC_CMD_SET_KBC 0xe9 /* Load to i8042 RAM location 0x79 */
234#define HP_SDC_CMD_SET_LPS 0xea /* Load to i8042 RAM location 0x7a */
235#define HP_SDC_CMD_SET_LPC 0xeb /* Load to i8042 RAM location 0x7b */
236#define HP_SDC_CMD_SET_RSV 0xec /* Load to i8042 RAM location 0x7c */
237#define HP_SDC_CMD_SET_LPR 0xed /* Load to i8042 RAM location 0x7d */
238#define HP_SDC_CMD_SET_XTD 0xee /* Load to i8042 RAM location 0x7e */
239#define HP_SDC_CMD_SET_STR 0xef /* Load to i8042 RAM location 0x7f */
240
241#define HP_SDC_CMD_DO_RTCW 0xc2 /* i8042 RAM 0x70 --> RTC */
242#define HP_SDC_CMD_DO_RTCR 0xc3 /* RTC[0x70 0:3] --> irq/status/data */
243#define HP_SDC_CMD_DO_BEEP 0xc4 /* i8042 RAM 0x70-74 --> beeper,VT3 */
244#define HP_SDC_CMD_DO_HIL 0xc5 /* i8042 RAM 0x70-73 -->
245 HIL MLC R0,R1 i8042 HIL watchdog */
246
247/* Values used to (de)mangle input/output to/from the HIL MLC */
248#define HP_SDC_DATA 0x40 /* Data from an 8042 register */
249#define HP_SDC_HIL_CMD 0x50 /* Data from HIL MLC R1/8042 */
250#define HP_SDC_HIL_R1MASK 0x0f /* Contents of HIL MLC R1 0:3 */
251#define HP_SDC_HIL_AUTO 0x10 /* Set if POL results from i8042 */
252#define HP_SDC_HIL_ISERR 0x80 /* Has meaning as in next 4 values */
253#define HP_SDC_HIL_RC_DONE 0x80 /* i8042 auto-configured loop */
254#define HP_SDC_HIL_ERR 0x81 /* HIL MLC R2 had a bit set */
255#define HP_SDC_HIL_TO 0x82 /* i8042 HIL watchdog expired */
256#define HP_SDC_HIL_RC 0x84 /* i8042 is auto-configuring loop */
257#define HP_SDC_HIL_DAT 0x60 /* Data from HIL MLC R0 */
258
259
260typedef struct {
261 rwlock_t ibf_lock;
262 rwlock_t lock; /* user/tasklet lock */
263 rwlock_t rtq_lock; /* isr/tasklet lock */
264 rwlock_t hook_lock; /* isr/user lock for handler add/del */
265
266 unsigned int irq, nmi; /* Our IRQ lines */
267 unsigned long base_io, status_io, data_io; /* Our IO ports */
268
269 uint8_t im; /* Interrupt mask */
270 int set_im; /* Interrupt mask needs to be set. */
271
272 int ibf; /* Last known status of IBF flag */
273 uint8_t wi; /* current i8042 write index */
274 uint8_t r7[4]; /* current i8042[0x70 - 0x74] values */
275 uint8_t r11, r7e; /* Values from version/revision regs */
276
277 hp_sdc_irqhook *timer, *reg, *hil, *pup, *cooked;
278
279#define HP_SDC_QUEUE_LEN 16
280 hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */
281
282 int rcurr, rqty; /* Current read transact in process */
283 struct timeval rtv; /* Time when current read started */
284 int wcurr; /* Current write transact in process */
285
286 int dev_err; /* carries status from registration */
287#if defined(__hppa__)
288 struct parisc_device *dev;
289#elif defined(__mc68000__)
290 void *dev;
291#else
292#error No support for device registration on this arch yet.
293#endif
294
295 struct timer_list kicker; /* Keeps below task alive */
296 struct tasklet_struct task;
297
298} hp_i8042_sdc;
299
300#endif /* _LINUX_HP_SDC_H */
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index 110904481238..c0e7fab28ce3 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -21,8 +21,6 @@
21/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 21/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
22 Frodo Looijaard <frodol@dds.nl> */ 22 Frodo Looijaard <frodol@dds.nl> */
23 23
24/* $Id: i2c-algo-bit.h,v 1.10 2003/01/21 08:08:16 kmalkki Exp $ */
25
26#ifndef _LINUX_I2C_ALGO_BIT_H 24#ifndef _LINUX_I2C_ALGO_BIT_H
27#define _LINUX_I2C_ALGO_BIT_H 25#define _LINUX_I2C_ALGO_BIT_H
28 26
@@ -46,8 +44,6 @@ struct i2c_algo_bit_data {
46 int timeout; /* in jiffies */ 44 int timeout; /* in jiffies */
47}; 45};
48 46
49#define I2C_BIT_ADAP_MAX 16
50
51int i2c_bit_add_bus(struct i2c_adapter *); 47int i2c_bit_add_bus(struct i2c_adapter *);
52int i2c_bit_del_bus(struct i2c_adapter *); 48int i2c_bit_del_bus(struct i2c_adapter *);
53 49
diff --git a/include/linux/i2c-algo-pca.h b/include/linux/i2c-algo-pca.h
index 941b786c5732..226693e0d88b 100644
--- a/include/linux/i2c-algo-pca.h
+++ b/include/linux/i2c-algo-pca.h
@@ -9,8 +9,6 @@ struct i2c_algo_pca_data {
9 int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap); 9 int (*wait_for_interrupt) (struct i2c_algo_pca_data *adap);
10}; 10};
11 11
12#define I2C_PCA_ADAP_MAX 16
13
14int i2c_pca_add_bus(struct i2c_adapter *); 12int i2c_pca_add_bus(struct i2c_adapter *);
15int i2c_pca_del_bus(struct i2c_adapter *); 13int i2c_pca_del_bus(struct i2c_adapter *);
16 14
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 2a508562255f..18b0adf57a3d 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -22,8 +22,6 @@
22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl> */ 23 Frodo Looijaard <frodol@dds.nl> */
24 24
25/* $Id: i2c-algo-pcf.h,v 1.8 2003/01/21 08:08:16 kmalkki Exp $ */
26
27#ifndef _LINUX_I2C_ALGO_PCF_H 25#ifndef _LINUX_I2C_ALGO_PCF_H
28#define _LINUX_I2C_ALGO_PCF_H 26#define _LINUX_I2C_ALGO_PCF_H
29 27
@@ -41,8 +39,6 @@ struct i2c_algo_pcf_data {
41 int timeout; 39 int timeout;
42}; 40};
43 41
44#define I2C_PCF_ADAP_MAX 16
45
46int i2c_pcf_add_bus(struct i2c_adapter *); 42int i2c_pcf_add_bus(struct i2c_adapter *);
47int i2c_pcf_del_bus(struct i2c_adapter *); 43int i2c_pcf_del_bus(struct i2c_adapter *);
48 44
diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h
index 541695679762..81c229a0fbca 100644
--- a/include/linux/i2c-dev.h
+++ b/include/linux/i2c-dev.h
@@ -19,8 +19,6 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22/* $Id: i2c-dev.h,v 1.13 2003/01/21 08:08:16 kmalkki Exp $ */
23
24#ifndef _LINUX_I2C_DEV_H 22#ifndef _LINUX_I2C_DEV_H
25#define _LINUX_I2C_DEV_H 23#define _LINUX_I2C_DEV_H
26 24
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 44f30876a1c9..1ce4b54caa21 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -164,10 +164,7 @@
164 164
165/* --- Bit algorithm adapters */ 165/* --- Bit algorithm adapters */
166#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ 166#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
167#define I2C_HW_B_LPC 0x010001 /* Parallel port control reg. */
168#define I2C_HW_B_SER 0x010002 /* Serial line interface */ 167#define I2C_HW_B_SER 0x010002 /* Serial line interface */
169#define I2C_HW_B_ELV 0x010003 /* ELV Card */
170#define I2C_HW_B_VELLE 0x010004 /* Vellemann K8000 */
171#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ 168#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
172#define I2C_HW_B_WNV 0x010006 /* Winnov Videums */ 169#define I2C_HW_B_WNV 0x010006 /* Winnov Videums */
173#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ 170#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 3d49a305bf88..f88577ca3b3a 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -23,14 +23,13 @@
23/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and 23/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
24 Frodo Looijaard <frodol@dds.nl> */ 24 Frodo Looijaard <frodol@dds.nl> */
25 25
26/* $Id: i2c.h,v 1.68 2003/01/21 08:08:16 kmalkki Exp $ */
27
28#ifndef _LINUX_I2C_H 26#ifndef _LINUX_I2C_H
29#define _LINUX_I2C_H 27#define _LINUX_I2C_H
30 28
31#include <linux/module.h> 29#include <linux/module.h>
32#include <linux/types.h> 30#include <linux/types.h>
33#include <linux/i2c-id.h> 31#include <linux/i2c-id.h>
32#include <linux/mod_devicetable.h>
34#include <linux/device.h> /* for struct device */ 33#include <linux/device.h> /* for struct device */
35#include <asm/semaphore.h> 34#include <asm/semaphore.h>
36 35
@@ -94,10 +93,10 @@ extern s32 i2c_smbus_write_byte_data(struct i2c_client * client,
94extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 93extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
95extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 94extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
96 u8 command, u16 value); 95 u8 command, u16 value);
97/* Returns the number of bytes transferred */
98extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 96extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
99 u8 command, u8 length, 97 u8 command, u8 length,
100 u8 *values); 98 u8 *values);
99/* Returns the number of read bytes */
101extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 100extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
102 u8 command, u8 *values); 101 u8 command, u8 *values);
103 102
@@ -391,10 +390,6 @@ struct i2c_msg {
391#define I2C_FUNC_10BIT_ADDR 0x00000002 390#define I2C_FUNC_10BIT_ADDR 0x00000002
392#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 391#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
393#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ 392#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
394#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */
395#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */
396#define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */
397#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
398#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 393#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
399#define I2C_FUNC_SMBUS_QUICK 0x00010000 394#define I2C_FUNC_SMBUS_QUICK 0x00010000
400#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 395#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
@@ -410,8 +405,6 @@ struct i2c_msg {
410#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 405#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
411#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ 406#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
412#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ 407#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
413#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */
414#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */
415 408
416#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 409#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
417 I2C_FUNC_SMBUS_WRITE_BYTE) 410 I2C_FUNC_SMBUS_WRITE_BYTE)
@@ -425,17 +418,6 @@ struct i2c_msg {
425 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 418 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
426#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ 419#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
427 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2) 420 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
428#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC (I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
429 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC)
430#define I2C_FUNC_SMBUS_WORD_DATA_PEC (I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
431 I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC)
432
433#define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA
434#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA
435#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA
436#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA
437#define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA
438#define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA
439 421
440#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 422#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
441 I2C_FUNC_SMBUS_BYTE | \ 423 I2C_FUNC_SMBUS_BYTE | \
@@ -443,20 +425,17 @@ struct i2c_msg {
443 I2C_FUNC_SMBUS_WORD_DATA | \ 425 I2C_FUNC_SMBUS_WORD_DATA | \
444 I2C_FUNC_SMBUS_PROC_CALL | \ 426 I2C_FUNC_SMBUS_PROC_CALL | \
445 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \ 427 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
446 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC | \
447 I2C_FUNC_SMBUS_I2C_BLOCK) 428 I2C_FUNC_SMBUS_I2C_BLOCK)
448 429
449/* 430/*
450 * Data for SMBus Messages 431 * Data for SMBus Messages
451 */ 432 */
452#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ 433#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
453#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
454union i2c_smbus_data { 434union i2c_smbus_data {
455 __u8 byte; 435 __u8 byte;
456 __u16 word; 436 __u16 word;
457 __u8 block[I2C_SMBUS_BLOCK_MAX + 3]; /* block[0] is used for length */ 437 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
458 /* one more for read length in block process call */ 438 /* and one more for user-space compatibility */
459 /* and one more for PEC */
460}; 439};
461 440
462/* smbus_access read or write markers */ 441/* smbus_access read or write markers */
@@ -473,10 +452,6 @@ union i2c_smbus_data {
473#define I2C_SMBUS_BLOCK_DATA 5 452#define I2C_SMBUS_BLOCK_DATA 5
474#define I2C_SMBUS_I2C_BLOCK_DATA 6 453#define I2C_SMBUS_I2C_BLOCK_DATA 6
475#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ 454#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
476#define I2C_SMBUS_BLOCK_DATA_PEC 8 /* SMBus 2.0 */
477#define I2C_SMBUS_PROC_CALL_PEC 9 /* SMBus 2.0 */
478#define I2C_SMBUS_BLOCK_PROC_CALL_PEC 10 /* SMBus 2.0 */
479#define I2C_SMBUS_WORD_DATA_PEC 11 /* SMBus 2.0 */
480 455
481 456
482/* ----- commands for the ioctl like i2c_command call: 457/* ----- commands for the ioctl like i2c_command call:
@@ -506,11 +481,6 @@ union i2c_smbus_data {
506 481
507#define I2C_SMBUS 0x0720 /* SMBus-level access */ 482#define I2C_SMBUS 0x0720 /* SMBus-level access */
508 483
509/* ... algo-bit.c recognizes */
510#define I2C_UDELAY 0x0705 /* set delay in microsecs between each */
511 /* written byte (except address) */
512#define I2C_MDELAY 0x0706 /* millisec delay between written bytes */
513
514/* ----- I2C-DEV: char device interface stuff ------------------------- */ 484/* ----- I2C-DEV: char device interface stuff ------------------------- */
515 485
516#define I2C_MAJOR 89 /* Device major number */ 486#define I2C_MAJOR 89 /* Device major number */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index bdc286ec947c..92300325dbcd 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -66,8 +66,6 @@ struct i2o_device {
66 struct device device; 66 struct device device;
67 67
68 struct semaphore lock; /* device lock */ 68 struct semaphore lock; /* device lock */
69
70 struct class_device classdev; /* i2o device class */
71}; 69};
72 70
73/* 71/*
@@ -194,7 +192,7 @@ struct i2o_controller {
194 struct resource mem_resource; /* Mem resource allocated to the IOP */ 192 struct resource mem_resource; /* Mem resource allocated to the IOP */
195 193
196 struct device device; 194 struct device device;
197 struct class_device classdev; /* I2O controller class */ 195 struct class_device *classdev; /* I2O controller class device */
198 struct i2o_device *exec; /* Executive */ 196 struct i2o_device *exec; /* Executive */
199#if BITS_PER_LONG == 64 197#if BITS_PER_LONG == 64
200 spinlock_t context_list_lock; /* lock for context_list */ 198 spinlock_t context_list_lock; /* lock for context_list */
@@ -492,7 +490,7 @@ static inline int i2o_dma_map_sg(struct i2o_controller *c,
492 * Returns 0 on success or -ENOMEM on failure. 490 * Returns 0 on success or -ENOMEM on failure.
493 */ 491 */
494static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, 492static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr,
495 size_t len, unsigned int gfp_mask) 493 size_t len, gfp_t gfp_mask)
496{ 494{
497 struct pci_dev *pdev = to_pci_dev(dev); 495 struct pci_dev *pdev = to_pci_dev(dev);
498 int dma_64 = 0; 496 int dma_64 = 0;
@@ -551,7 +549,7 @@ static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
551 * Returns the 0 on success or negative error code on failure. 549 * Returns the 0 on success or negative error code on failure.
552 */ 550 */
553static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, 551static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
554 size_t len, unsigned int gfp_mask) 552 size_t len, gfp_t gfp_mask)
555{ 553{
556 i2o_dma_free(dev, addr); 554 i2o_dma_free(dev, addr);
557 555
diff --git a/include/linux/ibmtr.h b/include/linux/ibmtr.h
index 2ef0b21517fb..1c7a0dd5536a 100644
--- a/include/linux/ibmtr.h
+++ b/include/linux/ibmtr.h
@@ -7,8 +7,8 @@
7/* ported to the Alpha architecture 02/20/96 (just used the HZ macro) */ 7/* ported to the Alpha architecture 02/20/96 (just used the HZ macro) */
8 8
9#define TR_RETRY_INTERVAL (30*HZ) /* 500 on PC = 5 s */ 9#define TR_RETRY_INTERVAL (30*HZ) /* 500 on PC = 5 s */
10#define TR_RST_TIME (HZ/20) /* 5 on PC = 50 ms */ 10#define TR_RST_TIME (msecs_to_jiffies(50)) /* 5 on PC = 50 ms */
11#define TR_BUSY_INTERVAL (HZ/5) /* 5 on PC = 200 ms */ 11#define TR_BUSY_INTERVAL (msecs_to_jiffies(200)) /* 5 on PC = 200 ms */
12#define TR_SPIN_INTERVAL (3*HZ) /* 3 seconds before init timeout */ 12#define TR_SPIN_INTERVAL (3*HZ) /* 3 seconds before init timeout */
13 13
14#define TR_ISA 1 14#define TR_ISA 1
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 3d5de45f961b..7fb3ff9c7b0e 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -71,7 +71,7 @@ struct idr {
71 */ 71 */
72 72
73void *idr_find(struct idr *idp, int id); 73void *idr_find(struct idr *idp, int id);
74int idr_pre_get(struct idr *idp, unsigned gfp_mask); 74int idr_pre_get(struct idr *idp, gfp_t gfp_mask);
75int idr_get_new(struct idr *idp, void *ptr, int *id); 75int idr_get_new(struct idr *idp, void *ptr, int *id);
76int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); 76int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
77void idr_remove(struct idr *idp, int id); 77void idr_remove(struct idr *idp, int id);
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 0856548a2a08..a8b1a2071838 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -84,6 +84,7 @@
84#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */ 84#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */
85#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */ 85#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
86#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */ 86#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */
87#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header */
87 88
88#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */ 89#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */
89#define ARPHRD_NONE 0xFFFE /* zero header length */ 90#define ARPHRD_NONE 0xFFFE /* zero header length */
diff --git a/include/linux/input.h b/include/linux/input.h
index e8c296ff6257..f623c745c21c 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -12,6 +12,7 @@
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13#include <linux/time.h> 13#include <linux/time.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/device.h>
15#else 16#else
16#include <sys/time.h> 17#include <sys/time.h>
17#include <sys/ioctl.h> 18#include <sys/ioctl.h>
@@ -644,6 +645,7 @@ struct input_absinfo {
644#define BUS_ADB 0x17 645#define BUS_ADB 0x17
645#define BUS_I2C 0x18 646#define BUS_I2C 0x18
646#define BUS_HOST 0x19 647#define BUS_HOST 0x19
648#define BUS_GSC 0x1A
647 649
648/* 650/*
649 * Values describing the status of an effect 651 * Values describing the status of an effect
@@ -889,11 +891,15 @@ struct input_dev {
889 struct semaphore sem; /* serializes open and close operations */ 891 struct semaphore sem; /* serializes open and close operations */
890 unsigned int users; 892 unsigned int users;
891 893
892 struct device *dev; 894 struct class_device cdev;
895 struct device *dev; /* will be removed soon */
896
897 int dynalloc; /* temporarily */
893 898
894 struct list_head h_list; 899 struct list_head h_list;
895 struct list_head node; 900 struct list_head node;
896}; 901};
902#define to_input_dev(d) container_of(d, struct input_dev, cdev)
897 903
898/* 904/*
899 * Structure for hotplug & device<->driver matching. 905 * Structure for hotplug & device<->driver matching.
@@ -984,6 +990,23 @@ static inline void init_input_dev(struct input_dev *dev)
984 INIT_LIST_HEAD(&dev->node); 990 INIT_LIST_HEAD(&dev->node);
985} 991}
986 992
993struct input_dev *input_allocate_device(void);
994
995static inline void input_free_device(struct input_dev *dev)
996{
997 kfree(dev);
998}
999
1000static inline struct input_dev *input_get_device(struct input_dev *dev)
1001{
1002 return to_input_dev(class_device_get(&dev->cdev));
1003}
1004
1005static inline void input_put_device(struct input_dev *dev)
1006{
1007 class_device_put(&dev->cdev);
1008}
1009
987void input_register_device(struct input_dev *); 1010void input_register_device(struct input_dev *);
988void input_unregister_device(struct input_dev *); 1011void input_unregister_device(struct input_dev *);
989 1012
@@ -1052,7 +1075,7 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
1052 dev->absbit[LONG(axis)] |= BIT(axis); 1075 dev->absbit[LONG(axis)] |= BIT(axis);
1053} 1076}
1054 1077
1055extern struct class *input_class; 1078extern struct class input_class;
1056 1079
1057#endif 1080#endif
1058#endif 1081#endif
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index ff853b3173c6..be197eb90077 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -69,7 +69,7 @@ extern int journal_enable_debug;
69#define jbd_debug(f, a...) /**/ 69#define jbd_debug(f, a...) /**/
70#endif 70#endif
71 71
72extern void * __jbd_kmalloc (const char *where, size_t size, int flags, int retry); 72extern void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry);
73#define jbd_kmalloc(size, flags) \ 73#define jbd_kmalloc(size, flags) \
74 __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) 74 __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
75#define jbd_rep_kmalloc(size, flags) \ 75#define jbd_rep_kmalloc(size, flags) \
@@ -890,7 +890,7 @@ extern int journal_forget (handle_t *, struct buffer_head *);
890extern void journal_sync_buffer (struct buffer_head *); 890extern void journal_sync_buffer (struct buffer_head *);
891extern int journal_invalidatepage(journal_t *, 891extern int journal_invalidatepage(journal_t *,
892 struct page *, unsigned long); 892 struct page *, unsigned long);
893extern int journal_try_to_free_buffers(journal_t *, struct page *, int); 893extern int journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
894extern int journal_stop(handle_t *); 894extern int journal_stop(handle_t *);
895extern int journal_flush (journal_t *); 895extern int journal_flush (journal_t *);
896extern void journal_lock_updates (journal_t *); 896extern void journal_lock_updates (journal_t *);
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 3b22304f12fd..7f7403aa4a41 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -65,7 +65,7 @@ extern void kobject_unregister(struct kobject *);
65extern struct kobject * kobject_get(struct kobject *); 65extern struct kobject * kobject_get(struct kobject *);
66extern void kobject_put(struct kobject *); 66extern void kobject_put(struct kobject *);
67 67
68extern char * kobject_get_path(struct kobject *, int); 68extern char * kobject_get_path(struct kobject *, gfp_t);
69 69
70struct kobj_type { 70struct kobj_type {
71 void (*release)(struct kobject *); 71 void (*release)(struct kobject *);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ceee1fc42c60..00a8a5738858 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -91,12 +91,13 @@ enum {
91 ATA_SHT_EMULATED = 1, 91 ATA_SHT_EMULATED = 1,
92 ATA_SHT_CMD_PER_LUN = 1, 92 ATA_SHT_CMD_PER_LUN = 1,
93 ATA_SHT_THIS_ID = -1, 93 ATA_SHT_THIS_ID = -1,
94 ATA_SHT_USE_CLUSTERING = 0, 94 ATA_SHT_USE_CLUSTERING = 1,
95 95
96 /* struct ata_device stuff */ 96 /* struct ata_device stuff */
97 ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ 97 ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */
98 ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ 98 ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */
99 ATA_DFLAG_LOCK_SECTORS = (1 << 2), /* don't adjust max_sectors */ 99 ATA_DFLAG_LOCK_SECTORS = (1 << 2), /* don't adjust max_sectors */
100 ATA_DFLAG_LBA = (1 << 3), /* device supports LBA */
100 101
101 ATA_DEV_UNKNOWN = 0, /* unknown device */ 102 ATA_DEV_UNKNOWN = 0, /* unknown device */
102 ATA_DEV_ATA = 1, /* ATA device */ 103 ATA_DEV_ATA = 1, /* ATA device */
@@ -154,17 +155,21 @@ enum {
154 ATA_SHIFT_UDMA = 0, 155 ATA_SHIFT_UDMA = 0,
155 ATA_SHIFT_MWDMA = 8, 156 ATA_SHIFT_MWDMA = 8,
156 ATA_SHIFT_PIO = 11, 157 ATA_SHIFT_PIO = 11,
158
159 /* Masks for port functions */
160 ATA_PORT_PRIMARY = (1 << 0),
161 ATA_PORT_SECONDARY = (1 << 1),
157}; 162};
158 163
159enum pio_task_states { 164enum hsm_task_states {
160 PIO_ST_UNKNOWN, 165 HSM_ST_UNKNOWN,
161 PIO_ST_IDLE, 166 HSM_ST_IDLE,
162 PIO_ST_POLL, 167 HSM_ST_POLL,
163 PIO_ST_TMOUT, 168 HSM_ST_TMOUT,
164 PIO_ST, 169 HSM_ST,
165 PIO_ST_LAST, 170 HSM_ST_LAST,
166 PIO_ST_LAST_POLL, 171 HSM_ST_LAST_POLL,
167 PIO_ST_ERR, 172 HSM_ST_ERR,
168}; 173};
169 174
170/* forward declarations */ 175/* forward declarations */
@@ -197,7 +202,7 @@ struct ata_ioports {
197struct ata_probe_ent { 202struct ata_probe_ent {
198 struct list_head node; 203 struct list_head node;
199 struct device *dev; 204 struct device *dev;
200 struct ata_port_operations *port_ops; 205 const struct ata_port_operations *port_ops;
201 Scsi_Host_Template *sht; 206 Scsi_Host_Template *sht;
202 struct ata_ioports port[ATA_MAX_PORTS]; 207 struct ata_ioports port[ATA_MAX_PORTS];
203 unsigned int n_ports; 208 unsigned int n_ports;
@@ -220,7 +225,7 @@ struct ata_host_set {
220 void __iomem *mmio_base; 225 void __iomem *mmio_base;
221 unsigned int n_ports; 226 unsigned int n_ports;
222 void *private_data; 227 void *private_data;
223 struct ata_port_operations *ops; 228 const struct ata_port_operations *ops;
224 struct ata_port * ports[0]; 229 struct ata_port * ports[0];
225}; 230};
226 231
@@ -278,15 +283,18 @@ struct ata_device {
278 u8 xfer_mode; 283 u8 xfer_mode;
279 unsigned int xfer_shift; /* ATA_SHIFT_xxx */ 284 unsigned int xfer_shift; /* ATA_SHIFT_xxx */
280 285
281 /* cache info about current transfer mode */ 286 unsigned int multi_count; /* sectors count for
282 u8 xfer_protocol; /* taskfile xfer protocol */ 287 READ/WRITE MULTIPLE */
283 u8 read_cmd; /* opcode to use on read */ 288
284 u8 write_cmd; /* opcode to use on write */ 289 /* for CHS addressing */
290 u16 cylinders; /* Number of cylinders */
291 u16 heads; /* Number of heads */
292 u16 sectors; /* Number of sectors per track */
285}; 293};
286 294
287struct ata_port { 295struct ata_port {
288 struct Scsi_Host *host; /* our co-allocated scsi host */ 296 struct Scsi_Host *host; /* our co-allocated scsi host */
289 struct ata_port_operations *ops; 297 const struct ata_port_operations *ops;
290 unsigned long flags; /* ATA_FLAG_xxx */ 298 unsigned long flags; /* ATA_FLAG_xxx */
291 unsigned int id; /* unique id req'd by scsi midlyr */ 299 unsigned int id; /* unique id req'd by scsi midlyr */
292 unsigned int port_no; /* unique port #; from zero */ 300 unsigned int port_no; /* unique port #; from zero */
@@ -319,7 +327,7 @@ struct ata_port {
319 struct work_struct packet_task; 327 struct work_struct packet_task;
320 328
321 struct work_struct pio_task; 329 struct work_struct pio_task;
322 unsigned int pio_task_state; 330 unsigned int hsm_task_state;
323 unsigned long pio_task_timeout; 331 unsigned long pio_task_timeout;
324 332
325 void *private_data; 333 void *private_data;
@@ -333,10 +341,10 @@ struct ata_port_operations {
333 void (*set_piomode) (struct ata_port *, struct ata_device *); 341 void (*set_piomode) (struct ata_port *, struct ata_device *);
334 void (*set_dmamode) (struct ata_port *, struct ata_device *); 342 void (*set_dmamode) (struct ata_port *, struct ata_device *);
335 343
336 void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf); 344 void (*tf_load) (struct ata_port *ap, const struct ata_taskfile *tf);
337 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf); 345 void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
338 346
339 void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf); 347 void (*exec_command)(struct ata_port *ap, const struct ata_taskfile *tf);
340 u8 (*check_status)(struct ata_port *ap); 348 u8 (*check_status)(struct ata_port *ap);
341 u8 (*check_altstatus)(struct ata_port *ap); 349 u8 (*check_altstatus)(struct ata_port *ap);
342 u8 (*check_err)(struct ata_port *ap); 350 u8 (*check_err)(struct ata_port *ap);
@@ -377,9 +385,22 @@ struct ata_port_info {
377 unsigned long pio_mask; 385 unsigned long pio_mask;
378 unsigned long mwdma_mask; 386 unsigned long mwdma_mask;
379 unsigned long udma_mask; 387 unsigned long udma_mask;
380 struct ata_port_operations *port_ops; 388 const struct ata_port_operations *port_ops;
389};
390
391struct ata_timing {
392 unsigned short mode; /* ATA mode */
393 unsigned short setup; /* t1 */
394 unsigned short act8b; /* t2 for 8-bit I/O */
395 unsigned short rec8b; /* t2i for 8-bit I/O */
396 unsigned short cyc8b; /* t0 for 8-bit I/O */
397 unsigned short active; /* t2 or tD */
398 unsigned short recover; /* t2i or tK */
399 unsigned short cycle; /* t0 */
400 unsigned short udma; /* t2CYCTYP/2 */
381}; 401};
382 402
403#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin)
383 404
384extern void ata_port_probe(struct ata_port *); 405extern void ata_port_probe(struct ata_port *);
385extern void __sata_phy_reset(struct ata_port *ap); 406extern void __sata_phy_reset(struct ata_port *ap);
@@ -392,7 +413,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
392 unsigned int n_ports); 413 unsigned int n_ports);
393extern void ata_pci_remove_one (struct pci_dev *pdev); 414extern void ata_pci_remove_one (struct pci_dev *pdev);
394#endif /* CONFIG_PCI */ 415#endif /* CONFIG_PCI */
395extern int ata_device_add(struct ata_probe_ent *ent); 416extern int ata_device_add(const struct ata_probe_ent *ent);
396extern void ata_host_set_remove(struct ata_host_set *host_set); 417extern void ata_host_set_remove(struct ata_host_set *host_set);
397extern int ata_scsi_detect(Scsi_Host_Template *sht); 418extern int ata_scsi_detect(Scsi_Host_Template *sht);
398extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 419extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
@@ -400,19 +421,21 @@ extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmn
400extern int ata_scsi_error(struct Scsi_Host *host); 421extern int ata_scsi_error(struct Scsi_Host *host);
401extern int ata_scsi_release(struct Scsi_Host *host); 422extern int ata_scsi_release(struct Scsi_Host *host);
402extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); 423extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
424extern int ata_ratelimit(void);
425
403/* 426/*
404 * Default driver ops implementations 427 * Default driver ops implementations
405 */ 428 */
406extern void ata_tf_load(struct ata_port *ap, struct ata_taskfile *tf); 429extern void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf);
407extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf); 430extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
408extern void ata_tf_to_fis(struct ata_taskfile *tf, u8 *fis, u8 pmp); 431extern void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp);
409extern void ata_tf_from_fis(u8 *fis, struct ata_taskfile *tf); 432extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
410extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device); 433extern void ata_noop_dev_select (struct ata_port *ap, unsigned int device);
411extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); 434extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
412extern u8 ata_check_status(struct ata_port *ap); 435extern u8 ata_check_status(struct ata_port *ap);
413extern u8 ata_altstatus(struct ata_port *ap); 436extern u8 ata_altstatus(struct ata_port *ap);
414extern u8 ata_chk_err(struct ata_port *ap); 437extern u8 ata_chk_err(struct ata_port *ap);
415extern void ata_exec_command(struct ata_port *ap, struct ata_taskfile *tf); 438extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
416extern int ata_port_start (struct ata_port *ap); 439extern int ata_port_start (struct ata_port *ap);
417extern void ata_port_stop (struct ata_port *ap); 440extern void ata_port_stop (struct ata_port *ap);
418extern void ata_host_stop (struct ata_host_set *host_set); 441extern void ata_host_stop (struct ata_host_set *host_set);
@@ -423,8 +446,8 @@ extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
423 unsigned int buflen); 446 unsigned int buflen);
424extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 447extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
425 unsigned int n_elem); 448 unsigned int n_elem);
426extern unsigned int ata_dev_classify(struct ata_taskfile *tf); 449extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
427extern void ata_dev_id_string(u16 *id, unsigned char *s, 450extern void ata_dev_id_string(const u16 *id, unsigned char *s,
428 unsigned int ofs, unsigned int len); 451 unsigned int ofs, unsigned int len);
429extern void ata_dev_config(struct ata_port *ap, unsigned int i); 452extern void ata_dev_config(struct ata_port *ap, unsigned int i);
430extern void ata_bmdma_setup (struct ata_queued_cmd *qc); 453extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
@@ -441,6 +464,32 @@ extern int ata_std_bios_param(struct scsi_device *sdev,
441 sector_t capacity, int geom[]); 464 sector_t capacity, int geom[]);
442extern int ata_scsi_slave_config(struct scsi_device *sdev); 465extern int ata_scsi_slave_config(struct scsi_device *sdev);
443 466
467/*
468 * Timing helpers
469 */
470extern int ata_timing_compute(struct ata_device *, unsigned short,
471 struct ata_timing *, int, int);
472extern void ata_timing_merge(const struct ata_timing *,
473 const struct ata_timing *, struct ata_timing *,
474 unsigned int);
475
476enum {
477 ATA_TIMING_SETUP = (1 << 0),
478 ATA_TIMING_ACT8B = (1 << 1),
479 ATA_TIMING_REC8B = (1 << 2),
480 ATA_TIMING_CYC8B = (1 << 3),
481 ATA_TIMING_8BIT = ATA_TIMING_ACT8B | ATA_TIMING_REC8B |
482 ATA_TIMING_CYC8B,
483 ATA_TIMING_ACTIVE = (1 << 4),
484 ATA_TIMING_RECOVER = (1 << 5),
485 ATA_TIMING_CYCLE = (1 << 6),
486 ATA_TIMING_UDMA = (1 << 7),
487 ATA_TIMING_ALL = ATA_TIMING_SETUP | ATA_TIMING_ACT8B |
488 ATA_TIMING_REC8B | ATA_TIMING_CYC8B |
489 ATA_TIMING_ACTIVE | ATA_TIMING_RECOVER |
490 ATA_TIMING_CYCLE | ATA_TIMING_UDMA,
491};
492
444 493
445#ifdef CONFIG_PCI 494#ifdef CONFIG_PCI
446struct pci_bits { 495struct pci_bits {
@@ -452,8 +501,8 @@ struct pci_bits {
452 501
453extern void ata_pci_host_stop (struct ata_host_set *host_set); 502extern void ata_pci_host_stop (struct ata_host_set *host_set);
454extern struct ata_probe_ent * 503extern struct ata_probe_ent *
455ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port); 504ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
456extern int pci_test_config_bits(struct pci_dev *pdev, struct pci_bits *bits); 505extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
457 506
458#endif /* CONFIG_PCI */ 507#endif /* CONFIG_PCI */
459 508
@@ -463,7 +512,7 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
463 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 512 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
464} 513}
465 514
466static inline unsigned int ata_dev_present(struct ata_device *dev) 515static inline unsigned int ata_dev_present(const struct ata_device *dev)
467{ 516{
468 return ((dev->class == ATA_DEV_ATA) || 517 return ((dev->class == ATA_DEV_ATA) ||
469 (dev->class == ATA_DEV_ATAPI)); 518 (dev->class == ATA_DEV_ATAPI));
@@ -662,7 +711,7 @@ static inline unsigned int sata_dev_present(struct ata_port *ap)
662 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; 711 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0;
663} 712}
664 713
665static inline int ata_try_flush_cache(struct ata_device *dev) 714static inline int ata_try_flush_cache(const struct ata_device *dev)
666{ 715{
667 return ata_id_wcache_enabled(dev->id) || 716 return ata_id_wcache_enabled(dev->id) ||
668 ata_id_has_flush(dev->id) || 717 ata_id_has_flush(dev->id) ||
diff --git a/include/linux/loop.h b/include/linux/loop.h
index 53fa51595443..40f63c9879d2 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -52,7 +52,7 @@ struct loop_device {
52 unsigned lo_blocksize; 52 unsigned lo_blocksize;
53 void *key_data; 53 void *key_data;
54 54
55 int old_gfp_mask; 55 gfp_t old_gfp_mask;
56 56
57 spinlock_t lo_lock; 57 spinlock_t lo_lock;
58 struct bio *lo_bio; 58 struct bio *lo_bio;
diff --git a/include/linux/mbcache.h b/include/linux/mbcache.h
index 9263d2db2d67..99e044b4efc6 100644
--- a/include/linux/mbcache.h
+++ b/include/linux/mbcache.h
@@ -22,7 +22,7 @@ struct mb_cache_entry {
22}; 22};
23 23
24struct mb_cache_op { 24struct mb_cache_op {
25 int (*free)(struct mb_cache_entry *, int); 25 int (*free)(struct mb_cache_entry *, gfp_t);
26}; 26};
27 27
28/* Functions on caches */ 28/* Functions on caches */
diff --git a/include/linux/mii.h b/include/linux/mii.h
index 9b8d0476988a..68f5a0f392dd 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -158,6 +158,7 @@ extern int mii_link_ok (struct mii_if_info *mii);
158extern int mii_nway_restart (struct mii_if_info *mii); 158extern int mii_nway_restart (struct mii_if_info *mii);
159extern int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd); 159extern int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
160extern int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd); 160extern int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd);
161extern int mii_check_gmii_support(struct mii_if_info *mii);
161extern void mii_check_link (struct mii_if_info *mii); 162extern void mii_check_link (struct mii_if_info *mii);
162extern unsigned int mii_check_media (struct mii_if_info *mii, 163extern unsigned int mii_check_media (struct mii_if_info *mii,
163 unsigned int ok_to_print, 164 unsigned int ok_to_print,
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 097b3a3c693d..e1649578fb0c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -747,7 +747,7 @@ extern unsigned long do_mremap(unsigned long addr,
747 * The callback will be passed nr_to_scan == 0 when the VM is querying the 747 * The callback will be passed nr_to_scan == 0 when the VM is querying the
748 * cache size, so a fastpath for that case is appropriate. 748 * cache size, so a fastpath for that case is appropriate.
749 */ 749 */
750typedef int (*shrinker_t)(int nr_to_scan, unsigned int gfp_mask); 750typedef int (*shrinker_t)(int nr_to_scan, gfp_t gfp_mask);
751 751
752/* 752/*
753 * Add an aging callback. The int is the number of 'seeks' it takes 753 * Add an aging callback. The int is the number of 'seeks' it takes
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 1ab78e8d6c53..aef6042f8f0b 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -50,7 +50,7 @@ struct mmc_command {
50#define MMC_ERR_INVALID 5 50#define MMC_ERR_INVALID 5
51 51
52 struct mmc_data *data; /* data segment associated with cmd */ 52 struct mmc_data *data; /* data segment associated with cmd */
53 struct mmc_request *mrq; /* assoicated request */ 53 struct mmc_request *mrq; /* associated request */
54}; 54};
55 55
56struct mmc_data { 56struct mmc_data {
@@ -68,7 +68,7 @@ struct mmc_data {
68 unsigned int bytes_xfered; 68 unsigned int bytes_xfered;
69 69
70 struct mmc_command *stop; /* stop command */ 70 struct mmc_command *stop; /* stop command */
71 struct mmc_request *mrq; /* assoicated request */ 71 struct mmc_request *mrq; /* associated request */
72 72
73 unsigned int sg_len; /* size of scatter list */ 73 unsigned int sg_len; /* size of scatter list */
74 struct scatterlist *sg; /* I/O scatter list */ 74 struct scatterlist *sg; /* I/O scatter list */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 5ed471b58f4f..7519eb4191e7 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -302,7 +302,7 @@ void get_zone_counts(unsigned long *active, unsigned long *inactive,
302void build_all_zonelists(void); 302void build_all_zonelists(void);
303void wakeup_kswapd(struct zone *zone, int order); 303void wakeup_kswapd(struct zone *zone, int order);
304int zone_watermark_ok(struct zone *z, int order, unsigned long mark, 304int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
305 int alloc_type, int can_try_harder, int gfp_high); 305 int alloc_type, int can_try_harder, gfp_t gfp_high);
306 306
307#ifdef CONFIG_HAVE_MEMORY_PRESENT 307#ifdef CONFIG_HAVE_MEMORY_PRESENT
308void memory_present(int nid, unsigned long start, unsigned long end); 308void memory_present(int nid, unsigned long start, unsigned long end);
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 2f0299a448f6..7b08c11ec4cc 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -244,4 +244,9 @@ struct pcmcia_device_id {
244#define PCMCIA_DEV_ID_MATCH_FAKE_CIS 0x0200 244#define PCMCIA_DEV_ID_MATCH_FAKE_CIS 0x0200
245#define PCMCIA_DEV_ID_MATCH_ANONYMOUS 0x0400 245#define PCMCIA_DEV_ID_MATCH_ANONYMOUS 0x0400
246 246
247/* I2C */
248struct i2c_device_id {
249 __u16 id;
250};
251
247#endif /* LINUX_MOD_DEVICETABLE_H */ 252#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 7db67b008cac..1c975d0d9e94 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -8,6 +8,7 @@ struct vfsmount;
8struct open_intent { 8struct open_intent {
9 int flags; 9 int flags;
10 int create_mode; 10 int create_mode;
11 struct file *file;
11}; 12};
12 13
13enum { MAX_NESTED_LINKS = 5 }; 14enum { MAX_NESTED_LINKS = 5 };
@@ -65,6 +66,13 @@ extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
65extern void path_release(struct nameidata *); 66extern void path_release(struct nameidata *);
66extern void path_release_on_umount(struct nameidata *); 67extern void path_release_on_umount(struct nameidata *);
67 68
69extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
70extern int path_lookup_open(const char *, unsigned lookup_flags, struct nameidata *, int open_flags);
71extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
72 int (*open)(struct inode *, struct file *));
73extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
74extern void release_open_intent(struct nameidata *);
75
68extern struct dentry * lookup_one_len(const char *, struct dentry *, int); 76extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
69extern struct dentry * lookup_hash(struct qstr *, struct dentry *); 77extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
70 78
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 368e4c825ff1..c6efce4a04a4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -308,6 +308,7 @@ struct net_device
308#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ 308#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
309#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */ 309#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
310#define NETIF_F_LLTX 4096 /* LockLess TX */ 310#define NETIF_F_LLTX 4096 /* LockLess TX */
311#define NETIF_F_UFO 8192 /* Can offload UDP Large Send*/
311 312
312 struct net_device *next_sched; 313 struct net_device *next_sched;
313 314
@@ -873,11 +874,9 @@ static inline void netif_rx_complete(struct net_device *dev)
873 874
874static inline void netif_poll_disable(struct net_device *dev) 875static inline void netif_poll_disable(struct net_device *dev)
875{ 876{
876 while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) { 877 while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state))
877 /* No hurry. */ 878 /* No hurry. */
878 current->state = TASK_INTERRUPTIBLE; 879 schedule_timeout_interruptible(1);
879 schedule_timeout(1);
880 }
881} 880}
882 881
883static inline void netif_poll_enable(struct net_device *dev) 882static inline void netif_poll_enable(struct net_device *dev)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 9a6047ff1b25..325fe7ae49bb 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -41,6 +41,10 @@
41#define NFS_MAX_FILE_IO_BUFFER_SIZE 32768 41#define NFS_MAX_FILE_IO_BUFFER_SIZE 32768
42#define NFS_DEF_FILE_IO_BUFFER_SIZE 4096 42#define NFS_DEF_FILE_IO_BUFFER_SIZE 4096
43 43
44/* Default timeout values */
45#define NFS_MAX_UDP_TIMEOUT (60*HZ)
46#define NFS_MAX_TCP_TIMEOUT (600*HZ)
47
44/* 48/*
45 * superblock magic number for NFS 49 * superblock magic number for NFS
46 */ 50 */
@@ -137,6 +141,7 @@ struct nfs_inode {
137 unsigned long attrtimeo_timestamp; 141 unsigned long attrtimeo_timestamp;
138 __u64 change_attr; /* v4 only */ 142 __u64 change_attr; /* v4 only */
139 143
144 unsigned long last_updated;
140 /* "Generation counter" for the attribute cache. This is 145 /* "Generation counter" for the attribute cache. This is
141 * bumped whenever we update the metadata on the 146 * bumped whenever we update the metadata on the
142 * server. 147 * server.
@@ -236,13 +241,17 @@ static inline int nfs_caches_unstable(struct inode *inode)
236 return atomic_read(&NFS_I(inode)->data_updates) != 0; 241 return atomic_read(&NFS_I(inode)->data_updates) != 0;
237} 242}
238 243
244static inline void nfs_mark_for_revalidate(struct inode *inode)
245{
246 spin_lock(&inode->i_lock);
247 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS;
248 spin_unlock(&inode->i_lock);
249}
250
239static inline void NFS_CACHEINV(struct inode *inode) 251static inline void NFS_CACHEINV(struct inode *inode)
240{ 252{
241 if (!nfs_caches_unstable(inode)) { 253 if (!nfs_caches_unstable(inode))
242 spin_lock(&inode->i_lock); 254 nfs_mark_for_revalidate(inode);
243 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS;
244 spin_unlock(&inode->i_lock);
245 }
246} 255}
247 256
248static inline int nfs_server_capable(struct inode *inode, int cap) 257static inline int nfs_server_capable(struct inode *inode, int cap)
@@ -276,7 +285,7 @@ static inline long nfs_save_change_attribute(struct inode *inode)
276static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr) 285static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr)
277{ 286{
278 return !nfs_caches_unstable(inode) 287 return !nfs_caches_unstable(inode)
279 && chattr == NFS_I(inode)->cache_change_attribute; 288 && time_after_eq(chattr, NFS_I(inode)->cache_change_attribute);
280} 289}
281 290
282/* 291/*
@@ -286,6 +295,7 @@ extern void nfs_zap_caches(struct inode *);
286extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *, 295extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
287 struct nfs_fattr *); 296 struct nfs_fattr *);
288extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *); 297extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
298extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
289extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 299extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
290extern int nfs_permission(struct inode *, int, struct nameidata *); 300extern int nfs_permission(struct inode *, int, struct nameidata *);
291extern int nfs_access_get_cached(struct inode *, struct rpc_cred *, struct nfs_access_entry *); 301extern int nfs_access_get_cached(struct inode *, struct rpc_cred *, struct nfs_access_entry *);
@@ -312,6 +322,12 @@ extern void nfs_file_clear_open_context(struct file *filp);
312/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 322/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
313extern u32 root_nfs_parse_addr(char *name); /*__init*/ 323extern u32 root_nfs_parse_addr(char *name); /*__init*/
314 324
325static inline void nfs_fattr_init(struct nfs_fattr *fattr)
326{
327 fattr->valid = 0;
328 fattr->time_start = jiffies;
329}
330
315/* 331/*
316 * linux/fs/nfs/file.c 332 * linux/fs/nfs/file.c
317 */ 333 */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index a2bf6914ff1b..40718669b9c8 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -41,7 +41,7 @@ struct nfs_fattr {
41 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */ 41 __u32 bitmap[2]; /* NFSv4 returned attribute bitmap */
42 __u64 change_attr; /* NFSv4 change attribute */ 42 __u64 change_attr; /* NFSv4 change attribute */
43 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ 43 __u64 pre_change_attr;/* pre-op NFSv4 change attribute */
44 unsigned long timestamp; 44 unsigned long time_start;
45}; 45};
46 46
47#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */ 47#define NFS_ATTR_WCC 0x0001 /* pre-op WCC data */
@@ -96,12 +96,13 @@ struct nfs4_change_info {
96 u64 after; 96 u64 after;
97}; 97};
98 98
99struct nfs_seqid;
99/* 100/*
100 * Arguments to the open call. 101 * Arguments to the open call.
101 */ 102 */
102struct nfs_openargs { 103struct nfs_openargs {
103 const struct nfs_fh * fh; 104 const struct nfs_fh * fh;
104 __u32 seqid; 105 struct nfs_seqid * seqid;
105 int open_flags; 106 int open_flags;
106 __u64 clientid; 107 __u64 clientid;
107 __u32 id; 108 __u32 id;
@@ -123,6 +124,7 @@ struct nfs_openres {
123 struct nfs4_change_info cinfo; 124 struct nfs4_change_info cinfo;
124 __u32 rflags; 125 __u32 rflags;
125 struct nfs_fattr * f_attr; 126 struct nfs_fattr * f_attr;
127 struct nfs_fattr * dir_attr;
126 const struct nfs_server *server; 128 const struct nfs_server *server;
127 int delegation_type; 129 int delegation_type;
128 nfs4_stateid delegation; 130 nfs4_stateid delegation;
@@ -136,7 +138,7 @@ struct nfs_openres {
136struct nfs_open_confirmargs { 138struct nfs_open_confirmargs {
137 const struct nfs_fh * fh; 139 const struct nfs_fh * fh;
138 nfs4_stateid stateid; 140 nfs4_stateid stateid;
139 __u32 seqid; 141 struct nfs_seqid * seqid;
140}; 142};
141 143
142struct nfs_open_confirmres { 144struct nfs_open_confirmres {
@@ -148,13 +150,16 @@ struct nfs_open_confirmres {
148 */ 150 */
149struct nfs_closeargs { 151struct nfs_closeargs {
150 struct nfs_fh * fh; 152 struct nfs_fh * fh;
151 nfs4_stateid stateid; 153 nfs4_stateid * stateid;
152 __u32 seqid; 154 struct nfs_seqid * seqid;
153 int open_flags; 155 int open_flags;
156 const u32 * bitmask;
154}; 157};
155 158
156struct nfs_closeres { 159struct nfs_closeres {
157 nfs4_stateid stateid; 160 nfs4_stateid stateid;
161 struct nfs_fattr * fattr;
162 const struct nfs_server *server;
158}; 163};
159/* 164/*
160 * * Arguments to the lock,lockt, and locku call. 165 * * Arguments to the lock,lockt, and locku call.
@@ -164,30 +169,19 @@ struct nfs_lowner {
164 u32 id; 169 u32 id;
165}; 170};
166 171
167struct nfs_open_to_lock {
168 __u32 open_seqid;
169 nfs4_stateid open_stateid;
170 __u32 lock_seqid;
171 struct nfs_lowner lock_owner;
172};
173
174struct nfs_exist_lock {
175 nfs4_stateid stateid;
176 __u32 seqid;
177};
178
179struct nfs_lock_opargs { 172struct nfs_lock_opargs {
173 struct nfs_seqid * lock_seqid;
174 nfs4_stateid * lock_stateid;
175 struct nfs_seqid * open_seqid;
176 nfs4_stateid * open_stateid;
177 struct nfs_lowner lock_owner;
180 __u32 reclaim; 178 __u32 reclaim;
181 __u32 new_lock_owner; 179 __u32 new_lock_owner;
182 union {
183 struct nfs_open_to_lock *open_lock;
184 struct nfs_exist_lock *exist_lock;
185 } u;
186}; 180};
187 181
188struct nfs_locku_opargs { 182struct nfs_locku_opargs {
189 __u32 seqid; 183 struct nfs_seqid * seqid;
190 nfs4_stateid stateid; 184 nfs4_stateid * stateid;
191}; 185};
192 186
193struct nfs_lockargs { 187struct nfs_lockargs {
@@ -262,6 +256,7 @@ struct nfs_writeargs {
262 enum nfs3_stable_how stable; 256 enum nfs3_stable_how stable;
263 unsigned int pgbase; 257 unsigned int pgbase;
264 struct page ** pages; 258 struct page ** pages;
259 const u32 * bitmask;
265}; 260};
266 261
267struct nfs_writeverf { 262struct nfs_writeverf {
@@ -273,6 +268,7 @@ struct nfs_writeres {
273 struct nfs_fattr * fattr; 268 struct nfs_fattr * fattr;
274 struct nfs_writeverf * verf; 269 struct nfs_writeverf * verf;
275 __u32 count; 270 __u32 count;
271 const struct nfs_server *server;
276}; 272};
277 273
278/* 274/*
@@ -550,6 +546,7 @@ struct nfs4_create_res {
550 struct nfs_fh * fh; 546 struct nfs_fh * fh;
551 struct nfs_fattr * fattr; 547 struct nfs_fattr * fattr;
552 struct nfs4_change_info dir_cinfo; 548 struct nfs4_change_info dir_cinfo;
549 struct nfs_fattr * dir_fattr;
553}; 550};
554 551
555struct nfs4_fsinfo_arg { 552struct nfs4_fsinfo_arg {
@@ -571,8 +568,17 @@ struct nfs4_link_arg {
571 const struct nfs_fh * fh; 568 const struct nfs_fh * fh;
572 const struct nfs_fh * dir_fh; 569 const struct nfs_fh * dir_fh;
573 const struct qstr * name; 570 const struct qstr * name;
571 const u32 * bitmask;
572};
573
574struct nfs4_link_res {
575 const struct nfs_server * server;
576 struct nfs_fattr * fattr;
577 struct nfs4_change_info cinfo;
578 struct nfs_fattr * dir_attr;
574}; 579};
575 580
581
576struct nfs4_lookup_arg { 582struct nfs4_lookup_arg {
577 const struct nfs_fh * dir_fh; 583 const struct nfs_fh * dir_fh;
578 const struct qstr * name; 584 const struct qstr * name;
@@ -619,6 +625,13 @@ struct nfs4_readlink {
619struct nfs4_remove_arg { 625struct nfs4_remove_arg {
620 const struct nfs_fh * fh; 626 const struct nfs_fh * fh;
621 const struct qstr * name; 627 const struct qstr * name;
628 const u32 * bitmask;
629};
630
631struct nfs4_remove_res {
632 const struct nfs_server * server;
633 struct nfs4_change_info cinfo;
634 struct nfs_fattr * dir_attr;
622}; 635};
623 636
624struct nfs4_rename_arg { 637struct nfs4_rename_arg {
@@ -626,11 +639,15 @@ struct nfs4_rename_arg {
626 const struct nfs_fh * new_dir; 639 const struct nfs_fh * new_dir;
627 const struct qstr * old_name; 640 const struct qstr * old_name;
628 const struct qstr * new_name; 641 const struct qstr * new_name;
642 const u32 * bitmask;
629}; 643};
630 644
631struct nfs4_rename_res { 645struct nfs4_rename_res {
646 const struct nfs_server * server;
632 struct nfs4_change_info old_cinfo; 647 struct nfs4_change_info old_cinfo;
648 struct nfs_fattr * old_fattr;
633 struct nfs4_change_info new_cinfo; 649 struct nfs4_change_info new_cinfo;
650 struct nfs_fattr * new_fattr;
634}; 651};
635 652
636struct nfs4_setclientid { 653struct nfs4_setclientid {
@@ -722,7 +739,7 @@ struct nfs_rpc_ops {
722 int (*write) (struct nfs_write_data *); 739 int (*write) (struct nfs_write_data *);
723 int (*commit) (struct nfs_write_data *); 740 int (*commit) (struct nfs_write_data *);
724 int (*create) (struct inode *, struct dentry *, 741 int (*create) (struct inode *, struct dentry *,
725 struct iattr *, int); 742 struct iattr *, int, struct nameidata *);
726 int (*remove) (struct inode *, struct qstr *); 743 int (*remove) (struct inode *, struct qstr *);
727 int (*unlink_setup) (struct rpc_message *, 744 int (*unlink_setup) (struct rpc_message *,
728 struct dentry *, struct qstr *); 745 struct dentry *, struct qstr *);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index acbf31c154f8..ba6c310a055f 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -21,16 +21,17 @@
21 21
22static inline gfp_t mapping_gfp_mask(struct address_space * mapping) 22static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
23{ 23{
24 return mapping->flags & __GFP_BITS_MASK; 24 return (__force gfp_t)mapping->flags & __GFP_BITS_MASK;
25} 25}
26 26
27/* 27/*
28 * This is non-atomic. Only to be used before the mapping is activated. 28 * This is non-atomic. Only to be used before the mapping is activated.
29 * Probably needs a barrier... 29 * Probably needs a barrier...
30 */ 30 */
31static inline void mapping_set_gfp_mask(struct address_space *m, int mask) 31static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
32{ 32{
33 m->flags = (m->flags & ~__GFP_BITS_MASK) | mask; 33 m->flags = (m->flags & ~(__force unsigned long)__GFP_BITS_MASK) |
34 (__force unsigned long)mask;
34} 35}
35 36
36/* 37/*
@@ -69,7 +70,7 @@ extern struct page * find_lock_page(struct address_space *mapping,
69extern struct page * find_trylock_page(struct address_space *mapping, 70extern struct page * find_trylock_page(struct address_space *mapping,
70 unsigned long index); 71 unsigned long index);
71extern struct page * find_or_create_page(struct address_space *mapping, 72extern struct page * find_or_create_page(struct address_space *mapping,
72 unsigned long index, unsigned int gfp_mask); 73 unsigned long index, gfp_t gfp_mask);
73unsigned find_get_pages(struct address_space *mapping, pgoff_t start, 74unsigned find_get_pages(struct address_space *mapping, pgoff_t start,
74 unsigned int nr_pages, struct page **pages); 75 unsigned int nr_pages, struct page **pages);
75unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index, 76unsigned find_get_pages_tag(struct address_space *mapping, pgoff_t *index,
@@ -92,9 +93,9 @@ extern int read_cache_pages(struct address_space *mapping,
92 struct list_head *pages, filler_t *filler, void *data); 93 struct list_head *pages, filler_t *filler, void *data);
93 94
94int add_to_page_cache(struct page *page, struct address_space *mapping, 95int add_to_page_cache(struct page *page, struct address_space *mapping,
95 unsigned long index, int gfp_mask); 96 unsigned long index, gfp_t gfp_mask);
96int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 97int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
97 unsigned long index, int gfp_mask); 98 unsigned long index, gfp_t gfp_mask);
98extern void remove_from_page_cache(struct page *page); 99extern void remove_from_page_cache(struct page *page);
99extern void __remove_from_page_cache(struct page *page); 100extern void __remove_from_page_cache(struct page *page);
100 101
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7349058ed778..3596ac94ecff 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -132,6 +132,7 @@ struct pci_dev {
132 unsigned int is_enabled:1; /* pci_enable_device has been called */ 132 unsigned int is_enabled:1; /* pci_enable_device has been called */
133 unsigned int is_busmaster:1; /* device is busmaster */ 133 unsigned int is_busmaster:1; /* device is busmaster */
134 unsigned int no_msi:1; /* device may not use msi */ 134 unsigned int no_msi:1; /* device may not use msi */
135 unsigned int block_ucfg_access:1; /* userspace config space access is blocked */
135 136
136 u32 saved_config_space[16]; /* config space saved at suspend time */ 137 u32 saved_config_space[16]; /* config space saved at suspend time */
137 struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */ 138 struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
@@ -490,6 +491,9 @@ extern void pci_disable_msix(struct pci_dev *dev);
490extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 491extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
491#endif 492#endif
492 493
494extern void pci_block_user_cfg_access(struct pci_dev *dev);
495extern void pci_unblock_user_cfg_access(struct pci_dev *dev);
496
493/* 497/*
494 * PCI domain support. Sometimes called PCI segment (eg by ACPI), 498 * PCI domain support. Sometimes called PCI segment (eg by ACPI),
495 * a PCI domain is defined to be a set of PCI busses which share 499 * a PCI domain is defined to be a set of PCI busses which share
@@ -560,6 +564,9 @@ static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int en
560 564
561#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) 565#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
562 566
567static inline void pci_block_user_cfg_access(struct pci_dev *dev) { }
568static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { }
569
563#endif /* CONFIG_PCI */ 570#endif /* CONFIG_PCI */
564 571
565/* Include architecture-dependent settings and functions */ 572/* Include architecture-dependent settings and functions */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 71834f05504f..467a096c3b81 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -96,6 +96,9 @@
96#define PCI_CLASS_SERIAL_ACCESS 0x0c01 96#define PCI_CLASS_SERIAL_ACCESS 0x0c01
97#define PCI_CLASS_SERIAL_SSA 0x0c02 97#define PCI_CLASS_SERIAL_SSA 0x0c02
98#define PCI_CLASS_SERIAL_USB 0x0c03 98#define PCI_CLASS_SERIAL_USB 0x0c03
99#define PCI_CLASS_SERIAL_USB_UHCI 0x0c0300
100#define PCI_CLASS_SERIAL_USB_OHCI 0x0c0310
101#define PCI_CLASS_SERIAL_USB_EHCI 0x0c0320
99#define PCI_CLASS_SERIAL_FIBER 0x0c04 102#define PCI_CLASS_SERIAL_FIBER 0x0c04
100#define PCI_CLASS_SERIAL_SMBUS 0x0c05 103#define PCI_CLASS_SERIAL_SMBUS 0x0c05
101 104
@@ -132,9 +135,6 @@
132 135
133#define PCI_VENDOR_ID_COMPAQ 0x0e11 136#define PCI_VENDOR_ID_COMPAQ 0x0e11
134#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508 137#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508
135#define PCI_DEVICE_ID_COMPAQ_1280 0x3033
136#define PCI_DEVICE_ID_COMPAQ_TRIFLEX 0x4000
137#define PCI_DEVICE_ID_COMPAQ_6010 0x6010
138#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc 138#define PCI_DEVICE_ID_COMPAQ_TACHYON 0xa0fc
139#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10 139#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10
140#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32 140#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32
@@ -274,7 +274,6 @@
274#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050 274#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050
275#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051 275#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051
276#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052 276#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052
277#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
278#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053 277#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053
279#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054 278#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054
280#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055 279#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055
@@ -282,8 +281,6 @@
282#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057 281#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057
283#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058 282#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058
284/* Rage128 M4 */ 283/* Rage128 M4 */
285#define PCI_DEVICE_ID_ATI_RADEON_LE 0x4d45
286#define PCI_DEVICE_ID_ATI_RADEON_LF 0x4d46
287/* Radeon R100 */ 284/* Radeon R100 */
288#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144 285#define PCI_DEVICE_ID_ATI_RADEON_QD 0x5144
289#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145 286#define PCI_DEVICE_ID_ATI_RADEON_QE 0x5145
@@ -304,32 +301,22 @@
304#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157 301#define PCI_DEVICE_ID_ATI_RADEON_QW 0x5157
305#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158 302#define PCI_DEVICE_ID_ATI_RADEON_QX 0x5158
306/* Radeon NV-100 */ 303/* Radeon NV-100 */
307#define PCI_DEVICE_ID_ATI_RADEON_N1 0x5159
308#define PCI_DEVICE_ID_ATI_RADEON_N2 0x515a
309/* Radeon RV250 (9000) */ 304/* Radeon RV250 (9000) */
310#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964 305#define PCI_DEVICE_ID_ATI_RADEON_Id 0x4964
311#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965 306#define PCI_DEVICE_ID_ATI_RADEON_Ie 0x4965
312#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966 307#define PCI_DEVICE_ID_ATI_RADEON_If 0x4966
313#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967 308#define PCI_DEVICE_ID_ATI_RADEON_Ig 0x4967
314/* Radeon RV280 (9200) */ 309/* Radeon RV280 (9200) */
315#define PCI_DEVICE_ID_ATI_RADEON_Y_ 0x5960
316#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961 310#define PCI_DEVICE_ID_ATI_RADEON_Ya 0x5961
317#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964 311#define PCI_DEVICE_ID_ATI_RADEON_Yd 0x5964
318/* Radeon R300 (9500) */ 312/* Radeon R300 (9500) */
319#define PCI_DEVICE_ID_ATI_RADEON_AD 0x4144
320/* Radeon R300 (9700) */ 313/* Radeon R300 (9700) */
321#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44 314#define PCI_DEVICE_ID_ATI_RADEON_ND 0x4e44
322#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45 315#define PCI_DEVICE_ID_ATI_RADEON_NE 0x4e45
323#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46 316#define PCI_DEVICE_ID_ATI_RADEON_NF 0x4e46
324#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47 317#define PCI_DEVICE_ID_ATI_RADEON_NG 0x4e47
325#define PCI_DEVICE_ID_ATI_RADEON_AE 0x4145
326#define PCI_DEVICE_ID_ATI_RADEON_AF 0x4146
327/* Radeon R350 (9800) */ 318/* Radeon R350 (9800) */
328#define PCI_DEVICE_ID_ATI_RADEON_NH 0x4e48
329#define PCI_DEVICE_ID_ATI_RADEON_NI 0x4e49
330/* Radeon RV350 (9600) */ 319/* Radeon RV350 (9600) */
331#define PCI_DEVICE_ID_ATI_RADEON_AP 0x4150
332#define PCI_DEVICE_ID_ATI_RADEON_AR 0x4152
333/* Radeon M6 */ 320/* Radeon M6 */
334#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59 321#define PCI_DEVICE_ID_ATI_RADEON_LY 0x4c59
335#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a 322#define PCI_DEVICE_ID_ATI_RADEON_LZ 0x4c5a
@@ -342,10 +329,6 @@
342#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66 329#define PCI_DEVICE_ID_ATI_RADEON_Lf 0x4c66
343#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67 330#define PCI_DEVICE_ID_ATI_RADEON_Lg 0x4c67
344/* Radeon */ 331/* Radeon */
345#define PCI_DEVICE_ID_ATI_RADEON_RA 0x5144
346#define PCI_DEVICE_ID_ATI_RADEON_RB 0x5145
347#define PCI_DEVICE_ID_ATI_RADEON_RC 0x5146
348#define PCI_DEVICE_ID_ATI_RADEON_RD 0x5147
349/* RadeonIGP */ 332/* RadeonIGP */
350#define PCI_DEVICE_ID_ATI_RS100 0xcab0 333#define PCI_DEVICE_ID_ATI_RS100 0xcab0
351#define PCI_DEVICE_ID_ATI_RS200 0xcab2 334#define PCI_DEVICE_ID_ATI_RS200 0xcab2
@@ -446,45 +429,28 @@
446#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6 429#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6
447#define PCI_DEVICE_ID_CIRRUS_6729 0x1100 430#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
448#define PCI_DEVICE_ID_CIRRUS_6832 0x1110 431#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
449#define PCI_DEVICE_ID_CIRRUS_7542 0x1200
450#define PCI_DEVICE_ID_CIRRUS_7543 0x1202 432#define PCI_DEVICE_ID_CIRRUS_7543 0x1202
451#define PCI_DEVICE_ID_CIRRUS_7541 0x1204
452#define PCI_DEVICE_ID_CIRRUS_4610 0x6001 433#define PCI_DEVICE_ID_CIRRUS_4610 0x6001
453#define PCI_DEVICE_ID_CIRRUS_4612 0x6003 434#define PCI_DEVICE_ID_CIRRUS_4612 0x6003
454#define PCI_DEVICE_ID_CIRRUS_4615 0x6004 435#define PCI_DEVICE_ID_CIRRUS_4615 0x6004
455#define PCI_DEVICE_ID_CIRRUS_4281 0x6005
456 436
457#define PCI_VENDOR_ID_IBM 0x1014 437#define PCI_VENDOR_ID_IBM 0x1014
458#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a
459#define PCI_DEVICE_ID_IBM_TR 0x0018 438#define PCI_DEVICE_ID_IBM_TR 0x0018
460#define PCI_DEVICE_ID_IBM_82G2675 0x001d
461#define PCI_DEVICE_ID_IBM_MCA 0x0020
462#define PCI_DEVICE_ID_IBM_82351 0x0022
463#define PCI_DEVICE_ID_IBM_PYTHON 0x002d
464#define PCI_DEVICE_ID_IBM_SERVERAID 0x002e
465#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e 439#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e
466#define PCI_DEVICE_ID_IBM_MPIC 0x0046
467#define PCI_DEVICE_ID_IBM_3780IDSP 0x007d
468#define PCI_DEVICE_ID_IBM_CHUKAR 0x0096
469#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc 440#define PCI_DEVICE_ID_IBM_CPC710_PCI64 0x00fc
470#define PCI_DEVICE_ID_IBM_CPC710_PCI32 0x0105
471#define PCI_DEVICE_ID_IBM_405GP 0x0156
472#define PCI_DEVICE_ID_IBM_SNIPE 0x0180 441#define PCI_DEVICE_ID_IBM_SNIPE 0x0180
473#define PCI_DEVICE_ID_IBM_SERVERAIDI960 0x01bd
474#define PCI_DEVICE_ID_IBM_CITRINE 0x028C 442#define PCI_DEVICE_ID_IBM_CITRINE 0x028C
475#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166 443#define PCI_DEVICE_ID_IBM_GEMSTONE 0xB166
476#define PCI_DEVICE_ID_IBM_MPIC_2 0xffff
477#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031 444#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_1 0x0031
478#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219 445#define PCI_DEVICE_ID_IBM_ICOM_DEV_ID_2 0x0219
479#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A 446#define PCI_DEVICE_ID_IBM_ICOM_V2_TWO_PORTS_RVX 0x021A
480#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251 447#define PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM 0x0251
481#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252 448#define PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL 0x252
482 449
483#define PCI_VENDOR_ID_COMPEX2 0x101a // pci.ids says "AT&T GIS (NCR)" 450#define PCI_VENDOR_ID_COMPEX2 0x101a /* pci.ids says "AT&T GIS (NCR)" */
484#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005 451#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
485 452
486#define PCI_VENDOR_ID_WD 0x101c 453#define PCI_VENDOR_ID_WD 0x101c
487#define PCI_DEVICE_ID_WD_7197 0x3296
488#define PCI_DEVICE_ID_WD_90C 0xc24a 454#define PCI_DEVICE_ID_WD_90C 0xc24a
489 455
490#define PCI_VENDOR_ID_AMI 0x101e 456#define PCI_VENDOR_ID_AMI 0x101e
@@ -501,33 +467,18 @@
501#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006 467#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006
502#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007 468#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007
503#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C 469#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C
504#define PCI_DEVICE_ID_AMD_FE_GATE_700D 0x700D
505#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E 470#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E
506#define PCI_DEVICE_ID_AMD_FE_GATE_700F 0x700F
507#define PCI_DEVICE_ID_AMD_COBRA_7400 0x7400
508#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401 471#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401
509#define PCI_DEVICE_ID_AMD_COBRA_7403 0x7403
510#define PCI_DEVICE_ID_AMD_COBRA_7404 0x7404
511#define PCI_DEVICE_ID_AMD_VIPER_7408 0x7408
512#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409 472#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409
513#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B 473#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B
514#define PCI_DEVICE_ID_AMD_VIPER_740C 0x740C
515#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410 474#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410
516#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411 475#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411
517#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413 476#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413
518#define PCI_DEVICE_ID_AMD_VIPER_7414 0x7414 477#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440
519#define PCI_DEVICE_ID_AMD_OPUS_7440 0x7440
520# define PCI_DEVICE_ID_AMD_VIPER_7440 PCI_DEVICE_ID_AMD_OPUS_7440
521#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441 478#define PCI_DEVICE_ID_AMD_OPUS_7441 0x7441
522# define PCI_DEVICE_ID_AMD_VIPER_7441 PCI_DEVICE_ID_AMD_OPUS_7441
523#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 479#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443
524# define PCI_DEVICE_ID_AMD_VIPER_7443 PCI_DEVICE_ID_AMD_OPUS_7443 480#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
525#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 481#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445
526#define PCI_DEVICE_ID_AMD_OPUS_7448 0x7448
527# define PCI_DEVICE_ID_AMD_VIPER_7448 PCI_DEVICE_ID_AMD_OPUS_7448
528#define PCI_DEVICE_ID_AMD_OPUS_7449 0x7449
529# define PCI_DEVICE_ID_AMD_VIPER_7449 PCI_DEVICE_ID_AMD_OPUS_7449
530#define PCI_DEVICE_ID_AMD_8111_LAN 0x7462
531#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 482#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468
532#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 483#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469
533#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a 484#define PCI_DEVICE_ID_AMD_8111_SMBUS2 0x746a
@@ -585,7 +536,6 @@
585#define PCI_DEVICE_ID_CT_65550 0x00e0 536#define PCI_DEVICE_ID_CT_65550 0x00e0
586#define PCI_DEVICE_ID_CT_65554 0x00e4 537#define PCI_DEVICE_ID_CT_65554 0x00e4
587#define PCI_DEVICE_ID_CT_65555 0x00e5 538#define PCI_DEVICE_ID_CT_65555 0x00e5
588#define PCI_DEVICE_ID_CT_69000 0x00c0
589 539
590#define PCI_VENDOR_ID_MIRO 0x1031 540#define PCI_VENDOR_ID_MIRO 0x1031
591#define PCI_DEVICE_ID_MIRO_36050 0x5601 541#define PCI_DEVICE_ID_MIRO_36050 0x5601
@@ -639,7 +589,6 @@
639#define PCI_DEVICE_ID_SI_550 0x0550 589#define PCI_DEVICE_ID_SI_550 0x0550
640#define PCI_DEVICE_ID_SI_540_VGA 0x5300 590#define PCI_DEVICE_ID_SI_540_VGA 0x5300
641#define PCI_DEVICE_ID_SI_550_VGA 0x5315 591#define PCI_DEVICE_ID_SI_550_VGA 0x5315
642#define PCI_DEVICE_ID_SI_601 0x0601
643#define PCI_DEVICE_ID_SI_620 0x0620 592#define PCI_DEVICE_ID_SI_620 0x0620
644#define PCI_DEVICE_ID_SI_630 0x0630 593#define PCI_DEVICE_ID_SI_630 0x0630
645#define PCI_DEVICE_ID_SI_633 0x0633 594#define PCI_DEVICE_ID_SI_633 0x0633
@@ -650,30 +599,22 @@
650#define PCI_DEVICE_ID_SI_648 0x0648 599#define PCI_DEVICE_ID_SI_648 0x0648
651#define PCI_DEVICE_ID_SI_650 0x0650 600#define PCI_DEVICE_ID_SI_650 0x0650
652#define PCI_DEVICE_ID_SI_651 0x0651 601#define PCI_DEVICE_ID_SI_651 0x0651
653#define PCI_DEVICE_ID_SI_652 0x0652
654#define PCI_DEVICE_ID_SI_655 0x0655 602#define PCI_DEVICE_ID_SI_655 0x0655
655#define PCI_DEVICE_ID_SI_661 0x0661 603#define PCI_DEVICE_ID_SI_661 0x0661
656#define PCI_DEVICE_ID_SI_730 0x0730 604#define PCI_DEVICE_ID_SI_730 0x0730
657#define PCI_DEVICE_ID_SI_733 0x0733 605#define PCI_DEVICE_ID_SI_733 0x0733
658#define PCI_DEVICE_ID_SI_630_VGA 0x6300 606#define PCI_DEVICE_ID_SI_630_VGA 0x6300
659#define PCI_DEVICE_ID_SI_730_VGA 0x7300
660#define PCI_DEVICE_ID_SI_735 0x0735 607#define PCI_DEVICE_ID_SI_735 0x0735
661#define PCI_DEVICE_ID_SI_740 0x0740 608#define PCI_DEVICE_ID_SI_740 0x0740
662#define PCI_DEVICE_ID_SI_741 0x0741 609#define PCI_DEVICE_ID_SI_741 0x0741
663#define PCI_DEVICE_ID_SI_745 0x0745 610#define PCI_DEVICE_ID_SI_745 0x0745
664#define PCI_DEVICE_ID_SI_746 0x0746 611#define PCI_DEVICE_ID_SI_746 0x0746
665#define PCI_DEVICE_ID_SI_748 0x0748
666#define PCI_DEVICE_ID_SI_750 0x0750
667#define PCI_DEVICE_ID_SI_751 0x0751
668#define PCI_DEVICE_ID_SI_752 0x0752
669#define PCI_DEVICE_ID_SI_755 0x0755 612#define PCI_DEVICE_ID_SI_755 0x0755
670#define PCI_DEVICE_ID_SI_760 0x0760 613#define PCI_DEVICE_ID_SI_760 0x0760
671#define PCI_DEVICE_ID_SI_900 0x0900 614#define PCI_DEVICE_ID_SI_900 0x0900
672#define PCI_DEVICE_ID_SI_961 0x0961 615#define PCI_DEVICE_ID_SI_961 0x0961
673#define PCI_DEVICE_ID_SI_962 0x0962 616#define PCI_DEVICE_ID_SI_962 0x0962
674#define PCI_DEVICE_ID_SI_963 0x0963 617#define PCI_DEVICE_ID_SI_963 0x0963
675#define PCI_DEVICE_ID_SI_5107 0x5107
676#define PCI_DEVICE_ID_SI_5300 0x5300
677#define PCI_DEVICE_ID_SI_5511 0x5511 618#define PCI_DEVICE_ID_SI_5511 0x5511
678#define PCI_DEVICE_ID_SI_5513 0x5513 619#define PCI_DEVICE_ID_SI_5513 0x5513
679#define PCI_DEVICE_ID_SI_5518 0x5518 620#define PCI_DEVICE_ID_SI_5518 0x5518
@@ -685,10 +626,6 @@
685#define PCI_DEVICE_ID_SI_5597 0x5597 626#define PCI_DEVICE_ID_SI_5597 0x5597
686#define PCI_DEVICE_ID_SI_5598 0x5598 627#define PCI_DEVICE_ID_SI_5598 0x5598
687#define PCI_DEVICE_ID_SI_5600 0x5600 628#define PCI_DEVICE_ID_SI_5600 0x5600
688#define PCI_DEVICE_ID_SI_6300 0x6300
689#define PCI_DEVICE_ID_SI_6306 0x6306
690#define PCI_DEVICE_ID_SI_6326 0x6326
691#define PCI_DEVICE_ID_SI_7001 0x7001
692#define PCI_DEVICE_ID_SI_7012 0x7012 629#define PCI_DEVICE_ID_SI_7012 0x7012
693#define PCI_DEVICE_ID_SI_7013 0x7013 630#define PCI_DEVICE_ID_SI_7013 0x7013
694#define PCI_DEVICE_ID_SI_7016 0x7016 631#define PCI_DEVICE_ID_SI_7016 0x7016
@@ -709,14 +646,11 @@
709#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049 646#define PCI_DEVICE_ID_HP_DIVA_TOSCA1 0x1049
710#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A 647#define PCI_DEVICE_ID_HP_DIVA_TOSCA2 0x104A
711#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B 648#define PCI_DEVICE_ID_HP_DIVA_MAESTRO 0x104B
712#define PCI_DEVICE_ID_HP_PCI_LBA 0x1054
713#define PCI_DEVICE_ID_HP_REO_SBA 0x10f0
714#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1 649#define PCI_DEVICE_ID_HP_REO_IOC 0x10f1
715#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b 650#define PCI_DEVICE_ID_HP_VISUALIZE_FXE 0x108b
716#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223 651#define PCI_DEVICE_ID_HP_DIVA_HALFDOME 0x1223
717#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226 652#define PCI_DEVICE_ID_HP_DIVA_KEYSTONE 0x1226
718#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227 653#define PCI_DEVICE_ID_HP_DIVA_POWERBAR 0x1227
719#define PCI_DEVICE_ID_HP_ZX1_SBA 0x1229
720#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a 654#define PCI_DEVICE_ID_HP_ZX1_IOC 0x122a
721#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e 655#define PCI_DEVICE_ID_HP_PCIX_LBA 0x122e
722#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c 656#define PCI_DEVICE_ID_HP_SX1000_IOC 0x127c
@@ -724,9 +658,7 @@
724#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290 658#define PCI_DEVICE_ID_HP_DIVA_AUX 0x1290
725#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301 659#define PCI_DEVICE_ID_HP_DIVA_RMP3 0x1301
726#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a 660#define PCI_DEVICE_ID_HP_DIVA_HURRICANE 0x132a
727#define PCI_DEVICE_ID_HP_CISS 0x3210
728#define PCI_DEVICE_ID_HP_CISSA 0x3220 661#define PCI_DEVICE_ID_HP_CISSA 0x3220
729#define PCI_DEVICE_ID_HP_CISSB 0x3222
730#define PCI_DEVICE_ID_HP_CISSC 0x3230 662#define PCI_DEVICE_ID_HP_CISSC 0x3230
731#define PCI_DEVICE_ID_HP_CISSD 0x3238 663#define PCI_DEVICE_ID_HP_CISSD 0x3238
732#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031 664#define PCI_DEVICE_ID_HP_ZX2_IOC 0x4031
@@ -734,8 +666,6 @@
734#define PCI_VENDOR_ID_PCTECH 0x1042 666#define PCI_VENDOR_ID_PCTECH 0x1042
735#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000 667#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000
736#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001 668#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001
737#define PCI_DEVICE_ID_PCTECH_SAMURAI_0 0x3000
738#define PCI_DEVICE_ID_PCTECH_SAMURAI_1 0x3010
739#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020 669#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020
740 670
741#define PCI_VENDOR_ID_ASUSTEK 0x1043 671#define PCI_VENDOR_ID_ASUSTEK 0x1043
@@ -745,24 +675,15 @@
745#define PCI_DEVICE_ID_DPT 0xa400 675#define PCI_DEVICE_ID_DPT 0xa400
746 676
747#define PCI_VENDOR_ID_OPTI 0x1045 677#define PCI_VENDOR_ID_OPTI 0x1045
748#define PCI_DEVICE_ID_OPTI_92C178 0xc178
749#define PCI_DEVICE_ID_OPTI_82C557 0xc557
750#define PCI_DEVICE_ID_OPTI_82C558 0xc558 678#define PCI_DEVICE_ID_OPTI_82C558 0xc558
751#define PCI_DEVICE_ID_OPTI_82C621 0xc621 679#define PCI_DEVICE_ID_OPTI_82C621 0xc621
752#define PCI_DEVICE_ID_OPTI_82C700 0xc700 680#define PCI_DEVICE_ID_OPTI_82C700 0xc700
753#define PCI_DEVICE_ID_OPTI_82C701 0xc701
754#define PCI_DEVICE_ID_OPTI_82C814 0xc814
755#define PCI_DEVICE_ID_OPTI_82C822 0xc822
756#define PCI_DEVICE_ID_OPTI_82C861 0xc861
757#define PCI_DEVICE_ID_OPTI_82C825 0xd568 681#define PCI_DEVICE_ID_OPTI_82C825 0xd568
758 682
759#define PCI_VENDOR_ID_ELSA 0x1048 683#define PCI_VENDOR_ID_ELSA 0x1048
760#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000 684#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
761#define PCI_DEVICE_ID_ELSA_QS3000 0x3000 685#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
762 686
763#define PCI_VENDOR_ID_SGS 0x104a
764#define PCI_DEVICE_ID_SGS_2000 0x0008
765#define PCI_DEVICE_ID_SGS_1764 0x0009
766 687
767#define PCI_VENDOR_ID_BUSLOGIC 0x104B 688#define PCI_VENDOR_ID_BUSLOGIC 0x104B
768#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140 689#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140
@@ -770,7 +691,6 @@
770#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130 691#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130
771 692
772#define PCI_VENDOR_ID_TI 0x104c 693#define PCI_VENDOR_ID_TI 0x104c
773#define PCI_DEVICE_ID_TI_TVP4010 0x3d04
774#define PCI_DEVICE_ID_TI_TVP4020 0x3d07 694#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
775#define PCI_DEVICE_ID_TI_4450 0x8011 695#define PCI_DEVICE_ID_TI_4450 0x8011
776#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031 696#define PCI_DEVICE_ID_TI_XX21_XX11 0x8031
@@ -804,14 +724,10 @@
804#define PCI_DEVICE_ID_TI_X420 0xac8e 724#define PCI_DEVICE_ID_TI_X420 0xac8e
805 725
806#define PCI_VENDOR_ID_SONY 0x104d 726#define PCI_VENDOR_ID_SONY 0x104d
807#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
808 727
809#define PCI_VENDOR_ID_OAK 0x104e
810#define PCI_DEVICE_ID_OAK_OTI107 0x0107
811 728
812/* Winbond have two vendor IDs! See 0x10ad as well */ 729/* Winbond have two vendor IDs! See 0x10ad as well */
813#define PCI_VENDOR_ID_WINBOND2 0x1050 730#define PCI_VENDOR_ID_WINBOND2 0x1050
814#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
815#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a 731#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a
816#define PCI_DEVICE_ID_WINBOND2_6692 0x6692 732#define PCI_DEVICE_ID_WINBOND2_6692 0x6692
817 733
@@ -820,19 +736,15 @@
820 736
821#define PCI_VENDOR_ID_EFAR 0x1055 737#define PCI_VENDOR_ID_EFAR 0x1055
822#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130 738#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130
823#define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460
824#define PCI_DEVICE_ID_EFAR_SLC90E66_2 0x9462
825#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463 739#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463
826 740
827#define PCI_VENDOR_ID_MOTOROLA 0x1057 741#define PCI_VENDOR_ID_MOTOROLA 0x1057
828#define PCI_VENDOR_ID_MOTOROLA_OOPS 0x1507
829#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001 742#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001
830#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002 743#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002
831#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004 744#define PCI_DEVICE_ID_MOTOROLA_MPC107 0x0004
832#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801 745#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801
833#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802 746#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802
834#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803 747#define PCI_DEVICE_ID_MOTOROLA_HAWK 0x4803
835#define PCI_DEVICE_ID_MOTOROLA_CPX8216 0x4806
836#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b 748#define PCI_DEVICE_ID_MOTOROLA_HARRIER 0x480b
837#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803 749#define PCI_DEVICE_ID_MOTOROLA_MPC5200 0x5803
838 750
@@ -843,33 +755,19 @@
843#define PCI_DEVICE_ID_PROMISE_20262 0x4d38 755#define PCI_DEVICE_ID_PROMISE_20262 0x4d38
844#define PCI_DEVICE_ID_PROMISE_20263 0x0D38 756#define PCI_DEVICE_ID_PROMISE_20263 0x0D38
845#define PCI_DEVICE_ID_PROMISE_20268 0x4d68 757#define PCI_DEVICE_ID_PROMISE_20268 0x4d68
846#define PCI_DEVICE_ID_PROMISE_20268R 0x6268
847#define PCI_DEVICE_ID_PROMISE_20269 0x4d69 758#define PCI_DEVICE_ID_PROMISE_20269 0x4d69
848#define PCI_DEVICE_ID_PROMISE_20270 0x6268 759#define PCI_DEVICE_ID_PROMISE_20270 0x6268
849#define PCI_DEVICE_ID_PROMISE_20271 0x6269 760#define PCI_DEVICE_ID_PROMISE_20271 0x6269
850#define PCI_DEVICE_ID_PROMISE_20275 0x1275 761#define PCI_DEVICE_ID_PROMISE_20275 0x1275
851#define PCI_DEVICE_ID_PROMISE_20276 0x5275 762#define PCI_DEVICE_ID_PROMISE_20276 0x5275
852#define PCI_DEVICE_ID_PROMISE_20277 0x7275 763#define PCI_DEVICE_ID_PROMISE_20277 0x7275
853#define PCI_DEVICE_ID_PROMISE_5300 0x5300
854 764
855#define PCI_VENDOR_ID_N9 0x105d
856#define PCI_DEVICE_ID_N9_I128 0x2309
857#define PCI_DEVICE_ID_N9_I128_2 0x2339
858#define PCI_DEVICE_ID_N9_I128_T2R 0x493d
859 765
860#define PCI_VENDOR_ID_UMC 0x1060 766#define PCI_VENDOR_ID_UMC 0x1060
861#define PCI_DEVICE_ID_UMC_UM8673F 0x0101 767#define PCI_DEVICE_ID_UMC_UM8673F 0x0101
862#define PCI_DEVICE_ID_UMC_UM8891A 0x0891
863#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a 768#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a
864#define PCI_DEVICE_ID_UMC_UM8886A 0x886a 769#define PCI_DEVICE_ID_UMC_UM8886A 0x886a
865#define PCI_DEVICE_ID_UMC_UM8881F 0x8881
866#define PCI_DEVICE_ID_UMC_UM8886F 0x8886
867#define PCI_DEVICE_ID_UMC_UM9017F 0x9017
868#define PCI_DEVICE_ID_UMC_UM8886N 0xe886
869#define PCI_DEVICE_ID_UMC_UM8891N 0xe891
870 770
871#define PCI_VENDOR_ID_X 0x1061
872#define PCI_DEVICE_ID_X_AGX016 0x0001
873 771
874#define PCI_VENDOR_ID_MYLEX 0x1069 772#define PCI_VENDOR_ID_MYLEX 0x1069
875#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001 773#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001
@@ -880,37 +778,26 @@
880#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56 778#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56
881#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166 779#define PCI_DEVICE_ID_MYLEX_DAC960_GEM 0xB166
882 780
883#define PCI_VENDOR_ID_PICOP 0x1066
884#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001
885#define PCI_DEVICE_ID_PICOP_PT80C524 0x8002
886 781
887#define PCI_VENDOR_ID_APPLE 0x106b 782#define PCI_VENDOR_ID_APPLE 0x106b
888#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001 783#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001
889#define PCI_DEVICE_ID_APPLE_GC 0x0002
890#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e 784#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e
891#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018 785#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018
892#define PCI_DEVICE_ID_APPLE_KL_USB 0x0019
893#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020 786#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020
894#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021 787#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021
895#define PCI_DEVICE_ID_APPLE_KEYLARGO 0x0022
896#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024 788#define PCI_DEVICE_ID_APPLE_UNI_N_GMACP 0x0024
897#define PCI_DEVICE_ID_APPLE_KEYLARGO_P 0x0025
898#define PCI_DEVICE_ID_APPLE_KL_USB_P 0x0026
899#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027 789#define PCI_DEVICE_ID_APPLE_UNI_N_AGP_P 0x0027
900#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d 790#define PCI_DEVICE_ID_APPLE_UNI_N_AGP15 0x002d
901#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e 791#define PCI_DEVICE_ID_APPLE_UNI_N_PCI15 0x002e
902#define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030
903#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032 792#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC2 0x0032
904#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033 793#define PCI_DEVICE_ID_APPLE_UNI_N_ATA 0x0033
905#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034 794#define PCI_DEVICE_ID_APPLE_UNI_N_AGP2 0x0034
906#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b 795#define PCI_DEVICE_ID_APPLE_IPID_ATA100 0x003b
907#define PCI_DEVICE_ID_APPLE_KEYLARGO_I 0x003e
908#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043 796#define PCI_DEVICE_ID_APPLE_K2_ATA100 0x0043
909#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b 797#define PCI_DEVICE_ID_APPLE_U3_AGP 0x004b
910#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c 798#define PCI_DEVICE_ID_APPLE_K2_GMAC 0x004c
911#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050 799#define PCI_DEVICE_ID_APPLE_SH_ATA 0x0050
912#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 800#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051
913#define PCI_DEVICE_ID_APPLE_SH_FW 0x0052
914#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 801#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058
915#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 802#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059
916#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645 803#define PCI_DEVICE_ID_APPLE_TIGON3 0x1645
@@ -923,12 +810,9 @@
923#define PCI_DEVICE_ID_YAMAHA_744 0x0010 810#define PCI_DEVICE_ID_YAMAHA_744 0x0010
924#define PCI_DEVICE_ID_YAMAHA_754 0x0012 811#define PCI_DEVICE_ID_YAMAHA_754 0x0012
925 812
926#define PCI_VENDOR_ID_NEXGEN 0x1074
927#define PCI_DEVICE_ID_NEXGEN_82C501 0x4e78
928 813
929#define PCI_VENDOR_ID_QLOGIC 0x1077 814#define PCI_VENDOR_ID_QLOGIC 0x1077
930#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020 815#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020
931#define PCI_DEVICE_ID_QLOGIC_ISP1022 0x1022
932#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100 816#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100
933#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200 817#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200
934#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300 818#define PCI_DEVICE_ID_QLOGIC_ISP2300 0x2300
@@ -946,32 +830,20 @@
946#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001 830#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001
947#define PCI_DEVICE_ID_CYRIX_5520 0x0002 831#define PCI_DEVICE_ID_CYRIX_5520 0x0002
948#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100 832#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100
949#define PCI_DEVICE_ID_CYRIX_5530_SMI 0x0101
950#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102 833#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102
951#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103 834#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103
952#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104 835#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104
953 836
954#define PCI_VENDOR_ID_LEADTEK 0x107d
955#define PCI_DEVICE_ID_LEADTEK_805 0x0000
956 837
957#define PCI_VENDOR_ID_INTERPHASE 0x107e
958#define PCI_DEVICE_ID_INTERPHASE_5526 0x0004
959#define PCI_DEVICE_ID_INTERPHASE_55x6 0x0005
960#define PCI_DEVICE_ID_INTERPHASE_5575 0x0008
961 838
962#define PCI_VENDOR_ID_CONTAQ 0x1080 839#define PCI_VENDOR_ID_CONTAQ 0x1080
963#define PCI_DEVICE_ID_CONTAQ_82C599 0x0600
964#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693 840#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693
965 841
966#define PCI_VENDOR_ID_FOREX 0x1083
967 842
968#define PCI_VENDOR_ID_OLICOM 0x108d 843#define PCI_VENDOR_ID_OLICOM 0x108d
969#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
970#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
971#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012 844#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
972#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013 845#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
973#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 846#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
974#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
975 847
976#define PCI_VENDOR_ID_SUN 0x108e 848#define PCI_VENDOR_ID_SUN 0x108e
977#define PCI_DEVICE_ID_SUN_EBUS 0x1000 849#define PCI_DEVICE_ID_SUN_EBUS 0x1000
@@ -990,49 +862,31 @@
990#define PCI_DEVICE_ID_SUN_CASSINI 0xabba 862#define PCI_DEVICE_ID_SUN_CASSINI 0xabba
991 863
992#define PCI_VENDOR_ID_CMD 0x1095 864#define PCI_VENDOR_ID_CMD 0x1095
993#define PCI_DEVICE_ID_CMD_640 0x0640
994#define PCI_DEVICE_ID_CMD_643 0x0643 865#define PCI_DEVICE_ID_CMD_643 0x0643
995#define PCI_DEVICE_ID_CMD_646 0x0646 866#define PCI_DEVICE_ID_CMD_646 0x0646
996#define PCI_DEVICE_ID_CMD_647 0x0647
997#define PCI_DEVICE_ID_CMD_648 0x0648 867#define PCI_DEVICE_ID_CMD_648 0x0648
998#define PCI_DEVICE_ID_CMD_649 0x0649 868#define PCI_DEVICE_ID_CMD_649 0x0649
999#define PCI_DEVICE_ID_CMD_670 0x0670
1000#define PCI_DEVICE_ID_CMD_680 0x0680
1001 869
1002#define PCI_DEVICE_ID_SII_680 0x0680 870#define PCI_DEVICE_ID_SII_680 0x0680
1003#define PCI_DEVICE_ID_SII_3112 0x3112 871#define PCI_DEVICE_ID_SII_3112 0x3112
1004#define PCI_DEVICE_ID_SII_1210SA 0x0240 872#define PCI_DEVICE_ID_SII_1210SA 0x0240
1005 873
1006#define PCI_VENDOR_ID_VISION 0x1098
1007#define PCI_DEVICE_ID_VISION_QD8500 0x0001
1008#define PCI_DEVICE_ID_VISION_QD8580 0x0002
1009 874
1010#define PCI_VENDOR_ID_BROOKTREE 0x109e 875#define PCI_VENDOR_ID_BROOKTREE 0x109e
1011#define PCI_DEVICE_ID_BROOKTREE_848 0x0350
1012#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351
1013#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e
1014#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 876#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
1015#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 877#define PCI_DEVICE_ID_BROOKTREE_879 0x0879
1016#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474
1017 878
1018#define PCI_VENDOR_ID_SIERRA 0x10a8
1019#define PCI_DEVICE_ID_SIERRA_STB 0x0000
1020 879
1021#define PCI_VENDOR_ID_SGI 0x10a9 880#define PCI_VENDOR_ID_SGI 0x10a9
1022#define PCI_DEVICE_ID_SGI_IOC3 0x0003 881#define PCI_DEVICE_ID_SGI_IOC3 0x0003
1023#define PCI_DEVICE_ID_SGI_IOC4 0x100a 882#define PCI_DEVICE_ID_SGI_IOC4 0x100a
1024#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002 883#define PCI_VENDOR_ID_SGI_LITHIUM 0x1002
1025 884
1026#define PCI_VENDOR_ID_ACC 0x10aa
1027#define PCI_DEVICE_ID_ACC_2056 0x0000
1028 885
1029#define PCI_VENDOR_ID_WINBOND 0x10ad 886#define PCI_VENDOR_ID_WINBOND 0x10ad
1030#define PCI_DEVICE_ID_WINBOND_83769 0x0001
1031#define PCI_DEVICE_ID_WINBOND_82C105 0x0105 887#define PCI_DEVICE_ID_WINBOND_82C105 0x0105
1032#define PCI_DEVICE_ID_WINBOND_83C553 0x0565 888#define PCI_DEVICE_ID_WINBOND_83C553 0x0565
1033 889
1034#define PCI_VENDOR_ID_DATABOOK 0x10b3
1035#define PCI_DEVICE_ID_DATABOOK_87144 0xb106
1036 890
1037#define PCI_VENDOR_ID_PLX 0x10b5 891#define PCI_VENDOR_ID_PLX 0x10b5
1038#define PCI_DEVICE_ID_PLX_R685 0x1030 892#define PCI_DEVICE_ID_PLX_R685 0x1030
@@ -1043,33 +897,19 @@
1043#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151 897#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151
1044#define PCI_DEVICE_ID_PLX_R753 0x1152 898#define PCI_DEVICE_ID_PLX_R753 0x1152
1045#define PCI_DEVICE_ID_PLX_OLITEC 0x1187 899#define PCI_DEVICE_ID_PLX_OLITEC 0x1187
1046#define PCI_DEVICE_ID_PLX_9030 0x9030
1047#define PCI_DEVICE_ID_PLX_9050 0x9050 900#define PCI_DEVICE_ID_PLX_9050 0x9050
1048#define PCI_DEVICE_ID_PLX_9060 0x9060
1049#define PCI_DEVICE_ID_PLX_9060ES 0x906E
1050#define PCI_DEVICE_ID_PLX_9060SD 0x906D
1051#define PCI_DEVICE_ID_PLX_9080 0x9080 901#define PCI_DEVICE_ID_PLX_9080 0x9080
1052#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001 902#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
1053 903
1054#define PCI_VENDOR_ID_MADGE 0x10b6 904#define PCI_VENDOR_ID_MADGE 0x10b6
1055#define PCI_DEVICE_ID_MADGE_MK2 0x0002 905#define PCI_DEVICE_ID_MADGE_MK2 0x0002
1056#define PCI_DEVICE_ID_MADGE_C155S 0x1001
1057 906
1058#define PCI_VENDOR_ID_3COM 0x10b7 907#define PCI_VENDOR_ID_3COM 0x10b7
1059#define PCI_DEVICE_ID_3COM_3C985 0x0001 908#define PCI_DEVICE_ID_3COM_3C985 0x0001
1060#define PCI_DEVICE_ID_3COM_3C940 0x1700 909#define PCI_DEVICE_ID_3COM_3C940 0x1700
1061#define PCI_DEVICE_ID_3COM_3C339 0x3390 910#define PCI_DEVICE_ID_3COM_3C339 0x3390
1062#define PCI_DEVICE_ID_3COM_3C359 0x3590 911#define PCI_DEVICE_ID_3COM_3C359 0x3590
1063#define PCI_DEVICE_ID_3COM_3C590 0x5900
1064#define PCI_DEVICE_ID_3COM_3C595TX 0x5950
1065#define PCI_DEVICE_ID_3COM_3C595T4 0x5951
1066#define PCI_DEVICE_ID_3COM_3C595MII 0x5952
1067#define PCI_DEVICE_ID_3COM_3C940B 0x80eb 912#define PCI_DEVICE_ID_3COM_3C940B 0x80eb
1068#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
1069#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
1070#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
1071#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
1072#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
1073#define PCI_DEVICE_ID_3COM_3CR990 0x9900 913#define PCI_DEVICE_ID_3COM_3CR990 0x9900
1074#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902 914#define PCI_DEVICE_ID_3COM_3CR990_TX_95 0x9902
1075#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903 915#define PCI_DEVICE_ID_3COM_3CR990_TX_97 0x9903
@@ -1079,24 +919,11 @@
1079#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909 919#define PCI_DEVICE_ID_3COM_3CR990SVR97 0x9909
1080#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a 920#define PCI_DEVICE_ID_3COM_3CR990SVR 0x990a
1081 921
1082#define PCI_VENDOR_ID_SMC 0x10b8
1083#define PCI_DEVICE_ID_SMC_EPIC100 0x0005
1084 922
1085#define PCI_VENDOR_ID_AL 0x10b9 923#define PCI_VENDOR_ID_AL 0x10b9
1086#define PCI_DEVICE_ID_AL_M1445 0x1445
1087#define PCI_DEVICE_ID_AL_M1449 0x1449
1088#define PCI_DEVICE_ID_AL_M1451 0x1451
1089#define PCI_DEVICE_ID_AL_M1461 0x1461
1090#define PCI_DEVICE_ID_AL_M1489 0x1489
1091#define PCI_DEVICE_ID_AL_M1511 0x1511
1092#define PCI_DEVICE_ID_AL_M1513 0x1513
1093#define PCI_DEVICE_ID_AL_M1521 0x1521
1094#define PCI_DEVICE_ID_AL_M1523 0x1523
1095#define PCI_DEVICE_ID_AL_M1531 0x1531
1096#define PCI_DEVICE_ID_AL_M1533 0x1533 924#define PCI_DEVICE_ID_AL_M1533 0x1533
1097#define PCI_DEVICE_ID_AL_M1535 0x1535 925#define PCI_DEVICE_ID_AL_M1535 0x1535
1098#define PCI_DEVICE_ID_AL_M1541 0x1541 926#define PCI_DEVICE_ID_AL_M1541 0x1541
1099#define PCI_DEVICE_ID_AL_M1543 0x1543
1100#define PCI_DEVICE_ID_AL_M1563 0x1563 927#define PCI_DEVICE_ID_AL_M1563 0x1563
1101#define PCI_DEVICE_ID_AL_M1621 0x1621 928#define PCI_DEVICE_ID_AL_M1621 0x1621
1102#define PCI_DEVICE_ID_AL_M1631 0x1631 929#define PCI_DEVICE_ID_AL_M1631 0x1631
@@ -1109,49 +936,23 @@
1109#define PCI_DEVICE_ID_AL_M1681 0x1681 936#define PCI_DEVICE_ID_AL_M1681 0x1681
1110#define PCI_DEVICE_ID_AL_M1683 0x1683 937#define PCI_DEVICE_ID_AL_M1683 0x1683
1111#define PCI_DEVICE_ID_AL_M1689 0x1689 938#define PCI_DEVICE_ID_AL_M1689 0x1689
1112#define PCI_DEVICE_ID_AL_M3307 0x3307
1113#define PCI_DEVICE_ID_AL_M4803 0x5215
1114#define PCI_DEVICE_ID_AL_M5219 0x5219 939#define PCI_DEVICE_ID_AL_M5219 0x5219
1115#define PCI_DEVICE_ID_AL_M5228 0x5228 940#define PCI_DEVICE_ID_AL_M5228 0x5228
1116#define PCI_DEVICE_ID_AL_M5229 0x5229 941#define PCI_DEVICE_ID_AL_M5229 0x5229
1117#define PCI_DEVICE_ID_AL_M5237 0x5237
1118#define PCI_DEVICE_ID_AL_M5243 0x5243
1119#define PCI_DEVICE_ID_AL_M5451 0x5451 942#define PCI_DEVICE_ID_AL_M5451 0x5451
1120#define PCI_DEVICE_ID_AL_M7101 0x7101 943#define PCI_DEVICE_ID_AL_M7101 0x7101
1121 944
1122#define PCI_VENDOR_ID_MITSUBISHI 0x10ba
1123 945
1124#define PCI_VENDOR_ID_SURECOM 0x10bd
1125#define PCI_DEVICE_ID_SURECOM_NE34 0x0e34
1126 946
1127#define PCI_VENDOR_ID_NEOMAGIC 0x10c8 947#define PCI_VENDOR_ID_NEOMAGIC 0x10c8
1128#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2070 0x0001
1129#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128V 0x0002
1130#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZV 0x0003
1131#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004
1132#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005
1133#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083
1134#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 948#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
1135#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006 949#define PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO 0x8006
1136#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016 950#define PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO 0x8016
1137 951
1138#define PCI_VENDOR_ID_ASP 0x10cd
1139#define PCI_DEVICE_ID_ASP_ABP940 0x1200
1140#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
1141#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
1142
1143#define PCI_VENDOR_ID_MACRONIX 0x10d9
1144#define PCI_DEVICE_ID_MACRONIX_MX98713 0x0512
1145#define PCI_DEVICE_ID_MACRONIX_MX987x5 0x0531
1146 952
1147#define PCI_VENDOR_ID_TCONRAD 0x10da 953#define PCI_VENDOR_ID_TCONRAD 0x10da
1148#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508 954#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508
1149 955
1150#define PCI_VENDOR_ID_CERN 0x10dc
1151#define PCI_DEVICE_ID_CERN_SPSB_PMC 0x0001
1152#define PCI_DEVICE_ID_CERN_SPSB_PCI 0x0002
1153#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021
1154#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022
1155 956
1156#define PCI_VENDOR_ID_NVIDIA 0x10de 957#define PCI_VENDOR_ID_NVIDIA 0x10de
1157#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020 958#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
@@ -1197,7 +998,6 @@
1197#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc 998#define PCI_DEVICE_ID_QUADRO_FX_GO1400 0x00cc
1198#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce 999#define PCI_DEVICE_ID_QUADRO_FX_1400 0x00ce
1199#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1 1000#define PCI_DEVICE_ID_NVIDIA_NFORCE3 0x00d1
1200#define PCI_DEVICE_ID_NVIDIA_MCP3_AUDIO 0x00da
1201#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4 1001#define PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS 0x00d4
1202#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5 1002#define PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE 0x00d5
1203#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6 1003#define PCI_DEVICE_ID_NVIDIA_NVENET_3 0x00d6
@@ -1284,7 +1084,6 @@
1284#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F 1084#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SATA2 0x037F
1285#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268 1085#define PCI_DEVICE_ID_NVIDIA_NVENET_12 0x0268
1286#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269 1086#define PCI_DEVICE_ID_NVIDIA_NVENET_13 0x0269
1287#define PCI_DEVICE_ID_NVIDIA_MCP51_AUDIO 0x026B
1288#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280 1087#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800 0x0280
1289#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281 1088#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800_8X 0x0281
1290#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282 1089#define PCI_DEVICE_ID_NVIDIA_GEFORCE4_TI_4800SE 0x0282
@@ -1335,24 +1134,13 @@
1335#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 1134#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373
1336 1135
1337#define PCI_VENDOR_ID_IMS 0x10e0 1136#define PCI_VENDOR_ID_IMS 0x10e0
1338#define PCI_DEVICE_ID_IMS_8849 0x8849
1339#define PCI_DEVICE_ID_IMS_TT128 0x9128 1137#define PCI_DEVICE_ID_IMS_TT128 0x9128
1340#define PCI_DEVICE_ID_IMS_TT3D 0x9135 1138#define PCI_DEVICE_ID_IMS_TT3D 0x9135
1341 1139
1342#define PCI_VENDOR_ID_TEKRAM2 0x10e1
1343#define PCI_DEVICE_ID_TEKRAM2_690c 0x690c
1344 1140
1345#define PCI_VENDOR_ID_TUNDRA 0x10e3
1346#define PCI_DEVICE_ID_TUNDRA_CA91C042 0x0000
1347 1141
1348#define PCI_VENDOR_ID_AMCC 0x10e8
1349#define PCI_DEVICE_ID_AMCC_MYRINET 0x8043
1350#define PCI_DEVICE_ID_AMCC_PARASTATION 0x8062
1351#define PCI_DEVICE_ID_AMCC_S5933 0x807d
1352#define PCI_DEVICE_ID_AMCC_S5933_HEPC3 0x809c
1353 1142
1354#define PCI_VENDOR_ID_INTERG 0x10ea 1143#define PCI_VENDOR_ID_INTERG 0x10ea
1355#define PCI_DEVICE_ID_INTERG_1680 0x1680
1356#define PCI_DEVICE_ID_INTERG_1682 0x1682 1144#define PCI_DEVICE_ID_INTERG_1682 0x1682
1357#define PCI_DEVICE_ID_INTERG_2000 0x2000 1145#define PCI_DEVICE_ID_INTERG_2000 0x2000
1358#define PCI_DEVICE_ID_INTERG_2010 0x2010 1146#define PCI_DEVICE_ID_INTERG_2010 0x2010
@@ -1360,32 +1148,23 @@
1360#define PCI_DEVICE_ID_INTERG_5050 0x5050 1148#define PCI_DEVICE_ID_INTERG_5050 0x5050
1361 1149
1362#define PCI_VENDOR_ID_REALTEK 0x10ec 1150#define PCI_VENDOR_ID_REALTEK 0x10ec
1363#define PCI_DEVICE_ID_REALTEK_8029 0x8029
1364#define PCI_DEVICE_ID_REALTEK_8129 0x8129
1365#define PCI_DEVICE_ID_REALTEK_8139 0x8139 1151#define PCI_DEVICE_ID_REALTEK_8139 0x8139
1366#define PCI_DEVICE_ID_REALTEK_8169 0x8169
1367 1152
1368#define PCI_VENDOR_ID_XILINX 0x10ee 1153#define PCI_VENDOR_ID_XILINX 0x10ee
1369#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0 1154#define PCI_DEVICE_ID_RME_DIGI96 0x3fc0
1370#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1 1155#define PCI_DEVICE_ID_RME_DIGI96_8 0x3fc1
1371#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2 1156#define PCI_DEVICE_ID_RME_DIGI96_8_PRO 0x3fc2
1372#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3 1157#define PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST 0x3fc3
1373#define PCI_DEVICE_ID_XILINX_HAMMERFALL 0x3fc4
1374#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5 1158#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
1375#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6 1159#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
1376#define PCI_DEVICE_ID_TURBOPAM 0x4020
1377 1160
1378#define PCI_VENDOR_ID_TRUEVISION 0x10fa
1379#define PCI_DEVICE_ID_TRUEVISION_T1000 0x000c
1380 1161
1381#define PCI_VENDOR_ID_INIT 0x1101 1162#define PCI_VENDOR_ID_INIT 0x1101
1382#define PCI_DEVICE_ID_INIT_320P 0x9100
1383#define PCI_DEVICE_ID_INIT_360P 0x9500
1384 1163
1385#define PCI_VENDOR_ID_CREATIVE 0x1102 // duplicate: ECTIVA 1164#define PCI_VENDOR_ID_CREATIVE 0x1102 /* duplicate: ECTIVA */
1386#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002 1165#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
1387 1166
1388#define PCI_VENDOR_ID_ECTIVA 0x1102 // duplicate: CREATIVE 1167#define PCI_VENDOR_ID_ECTIVA 0x1102 /* duplicate: CREATIVE */
1389#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938 1168#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938
1390 1169
1391#define PCI_VENDOR_ID_TTI 0x1103 1170#define PCI_VENDOR_ID_TTI 0x1103
@@ -1395,7 +1174,7 @@
1395#define PCI_DEVICE_ID_TTI_HPT302 0x0006 1174#define PCI_DEVICE_ID_TTI_HPT302 0x0006
1396#define PCI_DEVICE_ID_TTI_HPT371 0x0007 1175#define PCI_DEVICE_ID_TTI_HPT371 0x0007
1397#define PCI_DEVICE_ID_TTI_HPT374 0x0008 1176#define PCI_DEVICE_ID_TTI_HPT374 0x0008
1398#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 // apparently a 372N variant? 1177#define PCI_DEVICE_ID_TTI_HPT372N 0x0009 /* apparently a 372N variant? */
1399 1178
1400#define PCI_VENDOR_ID_VIA 0x1106 1179#define PCI_VENDOR_ID_VIA 0x1106
1401#define PCI_DEVICE_ID_VIA_8763_0 0x0198 1180#define PCI_DEVICE_ID_VIA_8763_0 0x0198
@@ -1408,36 +1187,25 @@
1408#define PCI_DEVICE_ID_VIA_8363_0 0x0305 1187#define PCI_DEVICE_ID_VIA_8363_0 0x0305
1409#define PCI_DEVICE_ID_VIA_8371_0 0x0391 1188#define PCI_DEVICE_ID_VIA_8371_0 0x0391
1410#define PCI_DEVICE_ID_VIA_8501_0 0x0501 1189#define PCI_DEVICE_ID_VIA_8501_0 0x0501
1411#define PCI_DEVICE_ID_VIA_82C505 0x0505
1412#define PCI_DEVICE_ID_VIA_82C561 0x0561 1190#define PCI_DEVICE_ID_VIA_82C561 0x0561
1413#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 1191#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
1414#define PCI_DEVICE_ID_VIA_82C576 0x0576 1192#define PCI_DEVICE_ID_VIA_82C576 0x0576
1415#define PCI_DEVICE_ID_VIA_82C585 0x0585
1416#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 1193#define PCI_DEVICE_ID_VIA_82C586_0 0x0586
1417#define PCI_DEVICE_ID_VIA_82C595 0x0595
1418#define PCI_DEVICE_ID_VIA_82C596 0x0596 1194#define PCI_DEVICE_ID_VIA_82C596 0x0596
1419#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 1195#define PCI_DEVICE_ID_VIA_82C597_0 0x0597
1420#define PCI_DEVICE_ID_VIA_82C598_0 0x0598 1196#define PCI_DEVICE_ID_VIA_82C598_0 0x0598
1421#define PCI_DEVICE_ID_VIA_8601_0 0x0601 1197#define PCI_DEVICE_ID_VIA_8601_0 0x0601
1422#define PCI_DEVICE_ID_VIA_8605_0 0x0605 1198#define PCI_DEVICE_ID_VIA_8605_0 0x0605
1423#define PCI_DEVICE_ID_VIA_82C680 0x0680
1424#define PCI_DEVICE_ID_VIA_82C686 0x0686 1199#define PCI_DEVICE_ID_VIA_82C686 0x0686
1425#define PCI_DEVICE_ID_VIA_82C691_0 0x0691 1200#define PCI_DEVICE_ID_VIA_82C691_0 0x0691
1426#define PCI_DEVICE_ID_VIA_82C693 0x0693
1427#define PCI_DEVICE_ID_VIA_82C693_1 0x0698
1428#define PCI_DEVICE_ID_VIA_82C926 0x0926
1429#define PCI_DEVICE_ID_VIA_82C576_1 0x1571 1201#define PCI_DEVICE_ID_VIA_82C576_1 0x1571
1430#define PCI_DEVICE_ID_VIA_82C595_97 0x1595
1431#define PCI_DEVICE_ID_VIA_82C586_2 0x3038 1202#define PCI_DEVICE_ID_VIA_82C586_2 0x3038
1432#define PCI_DEVICE_ID_VIA_82C586_3 0x3040 1203#define PCI_DEVICE_ID_VIA_82C586_3 0x3040
1433#define PCI_DEVICE_ID_VIA_6305 0x3044
1434#define PCI_DEVICE_ID_VIA_82C596_3 0x3050 1204#define PCI_DEVICE_ID_VIA_82C596_3 0x3050
1435#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051 1205#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051
1436#define PCI_DEVICE_ID_VIA_82C686_4 0x3057 1206#define PCI_DEVICE_ID_VIA_82C686_4 0x3057
1437#define PCI_DEVICE_ID_VIA_82C686_5 0x3058 1207#define PCI_DEVICE_ID_VIA_82C686_5 0x3058
1438#define PCI_DEVICE_ID_VIA_8233_5 0x3059 1208#define PCI_DEVICE_ID_VIA_8233_5 0x3059
1439#define PCI_DEVICE_ID_VIA_8233_7 0x3065
1440#define PCI_DEVICE_ID_VIA_82C686_6 0x3068
1441#define PCI_DEVICE_ID_VIA_8233_0 0x3074 1209#define PCI_DEVICE_ID_VIA_8233_0 0x3074
1442#define PCI_DEVICE_ID_VIA_8633_0 0x3091 1210#define PCI_DEVICE_ID_VIA_8633_0 0x3091
1443#define PCI_DEVICE_ID_VIA_8367_0 0x3099 1211#define PCI_DEVICE_ID_VIA_8367_0 0x3099
@@ -1455,38 +1223,23 @@
1455#define PCI_DEVICE_ID_VIA_XN266 0x3156 1223#define PCI_DEVICE_ID_VIA_XN266 0x3156
1456#define PCI_DEVICE_ID_VIA_8754C_0 0x3168 1224#define PCI_DEVICE_ID_VIA_8754C_0 0x3168
1457#define PCI_DEVICE_ID_VIA_8235 0x3177 1225#define PCI_DEVICE_ID_VIA_8235 0x3177
1458#define PCI_DEVICE_ID_VIA_P4N333 0x3178
1459#define PCI_DEVICE_ID_VIA_8385_0 0x3188 1226#define PCI_DEVICE_ID_VIA_8385_0 0x3188
1460#define PCI_DEVICE_ID_VIA_8377_0 0x3189 1227#define PCI_DEVICE_ID_VIA_8377_0 0x3189
1461#define PCI_DEVICE_ID_VIA_8378_0 0x3205 1228#define PCI_DEVICE_ID_VIA_8378_0 0x3205
1462#define PCI_DEVICE_ID_VIA_8783_0 0x3208 1229#define PCI_DEVICE_ID_VIA_8783_0 0x3208
1463#define PCI_DEVICE_ID_VIA_P4M400 0x3209
1464#define PCI_DEVICE_ID_VIA_8237 0x3227 1230#define PCI_DEVICE_ID_VIA_8237 0x3227
1465#define PCI_DEVICE_ID_VIA_3296_0 0x0296 1231#define PCI_DEVICE_ID_VIA_3296_0 0x0296
1466#define PCI_DEVICE_ID_VIA_86C100A 0x6100
1467#define PCI_DEVICE_ID_VIA_8231 0x8231 1232#define PCI_DEVICE_ID_VIA_8231 0x8231
1468#define PCI_DEVICE_ID_VIA_8231_4 0x8235 1233#define PCI_DEVICE_ID_VIA_8231_4 0x8235
1469#define PCI_DEVICE_ID_VIA_8365_1 0x8305 1234#define PCI_DEVICE_ID_VIA_8365_1 0x8305
1470#define PCI_DEVICE_ID_VIA_8371_1 0x8391 1235#define PCI_DEVICE_ID_VIA_8371_1 0x8391
1471#define PCI_DEVICE_ID_VIA_8501_1 0x8501
1472#define PCI_DEVICE_ID_VIA_82C597_1 0x8597
1473#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 1236#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
1474#define PCI_DEVICE_ID_VIA_8601_1 0x8601
1475#define PCI_DEVICE_ID_VIA_8505_1 0x8605
1476#define PCI_DEVICE_ID_VIA_8633_1 0xB091
1477#define PCI_DEVICE_ID_VIA_8367_1 0xB099
1478#define PCI_DEVICE_ID_VIA_P4X266_1 0xB101
1479#define PCI_DEVICE_ID_VIA_8615_1 0xB103
1480#define PCI_DEVICE_ID_VIA_8361_1 0xB112
1481#define PCI_DEVICE_ID_VIA_8235_1 0xB168
1482#define PCI_DEVICE_ID_VIA_838X_1 0xB188 1237#define PCI_DEVICE_ID_VIA_838X_1 0xB188
1483#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198 1238#define PCI_DEVICE_ID_VIA_83_87XX_1 0xB198
1484 1239
1485#define PCI_VENDOR_ID_SIEMENS 0x110A 1240#define PCI_VENDOR_ID_SIEMENS 0x110A
1486#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102 1241#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102
1487 1242
1488#define PCI_VENDOR_ID_SMC2 0x1113
1489#define PCI_DEVICE_ID_SMC2_1211TX 0x1211
1490 1243
1491#define PCI_VENDOR_ID_VORTEX 0x1119 1244#define PCI_VENDOR_ID_VORTEX 0x1119
1492#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000 1245#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000
@@ -1509,18 +1262,6 @@
1509#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103 1262#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103
1510#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104 1263#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104
1511#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105 1264#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105
1512#define PCI_DEVICE_ID_VORTEX_GDT6x17RP1 0x0110
1513#define PCI_DEVICE_ID_VORTEX_GDT6x27RP1 0x0111
1514#define PCI_DEVICE_ID_VORTEX_GDT6537RP1 0x0112
1515#define PCI_DEVICE_ID_VORTEX_GDT6557RP1 0x0113
1516#define PCI_DEVICE_ID_VORTEX_GDT6x11RP1 0x0114
1517#define PCI_DEVICE_ID_VORTEX_GDT6x21RP1 0x0115
1518#define PCI_DEVICE_ID_VORTEX_GDT6x17RP2 0x0120
1519#define PCI_DEVICE_ID_VORTEX_GDT6x27RP2 0x0121
1520#define PCI_DEVICE_ID_VORTEX_GDT6537RP2 0x0122
1521#define PCI_DEVICE_ID_VORTEX_GDT6557RP2 0x0123
1522#define PCI_DEVICE_ID_VORTEX_GDT6x11RP2 0x0124
1523#define PCI_DEVICE_ID_VORTEX_GDT6x21RP2 0x0125
1524 1265
1525#define PCI_VENDOR_ID_EF 0x111a 1266#define PCI_VENDOR_ID_EF 0x111a
1526#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000 1267#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000
@@ -1532,21 +1273,15 @@
1532#define PCI_DEVICE_ID_IDT_IDT77201 0x0001 1273#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
1533 1274
1534#define PCI_VENDOR_ID_FORE 0x1127 1275#define PCI_VENDOR_ID_FORE 0x1127
1535#define PCI_DEVICE_ID_FORE_PCA200PC 0x0210
1536#define PCI_DEVICE_ID_FORE_PCA200E 0x0300 1276#define PCI_DEVICE_ID_FORE_PCA200E 0x0300
1537 1277
1538#define PCI_VENDOR_ID_IMAGINGTECH 0x112f
1539#define PCI_DEVICE_ID_IMAGINGTECH_ICPCI 0x0000
1540 1278
1541#define PCI_VENDOR_ID_PHILIPS 0x1131 1279#define PCI_VENDOR_ID_PHILIPS 0x1131
1542#define PCI_DEVICE_ID_PHILIPS_SAA7145 0x7145
1543#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146 1280#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146
1544#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730 1281#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730
1545 1282
1546#define PCI_VENDOR_ID_EICON 0x1133 1283#define PCI_VENDOR_ID_EICON 0x1133
1547#define PCI_DEVICE_ID_EICON_DIVA20PRO 0xe001
1548#define PCI_DEVICE_ID_EICON_DIVA20 0xe002 1284#define PCI_DEVICE_ID_EICON_DIVA20 0xe002
1549#define PCI_DEVICE_ID_EICON_DIVA20PRO_U 0xe003
1550#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004 1285#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004
1551#define PCI_DEVICE_ID_EICON_DIVA201 0xe005 1286#define PCI_DEVICE_ID_EICON_DIVA201 0xe005
1552#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b 1287#define PCI_DEVICE_ID_EICON_DIVA202 0xe00b
@@ -1558,35 +1293,17 @@
1558#define PCI_VENDOR_ID_ZIATECH 0x1138 1293#define PCI_VENDOR_ID_ZIATECH 0x1138
1559#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550 1294#define PCI_DEVICE_ID_ZIATECH_5550_HC 0x5550
1560 1295
1561#define PCI_VENDOR_ID_CYCLONE 0x113c
1562#define PCI_DEVICE_ID_CYCLONE_SDK 0x0001
1563 1296
1564#define PCI_VENDOR_ID_ALLIANCE 0x1142
1565#define PCI_DEVICE_ID_ALLIANCE_PROMOTIO 0x3210
1566#define PCI_DEVICE_ID_ALLIANCE_PROVIDEO 0x6422
1567#define PCI_DEVICE_ID_ALLIANCE_AT24 0x6424
1568#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
1569 1297
1570#define PCI_VENDOR_ID_SYSKONNECT 0x1148 1298#define PCI_VENDOR_ID_SYSKONNECT 0x1148
1571#define PCI_DEVICE_ID_SYSKONNECT_FP 0x4000
1572#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200 1299#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
1573#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300 1300#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300
1574#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320 1301#define PCI_DEVICE_ID_SYSKONNECT_YU 0x4320
1575#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400 1302#define PCI_DEVICE_ID_SYSKONNECT_9DXX 0x4400
1576#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500 1303#define PCI_DEVICE_ID_SYSKONNECT_9MXX 0x4500
1577 1304
1578#define PCI_VENDOR_ID_VMIC 0x114a
1579#define PCI_DEVICE_ID_VMIC_VME 0x7587
1580 1305
1581#define PCI_VENDOR_ID_DIGI 0x114f 1306#define PCI_VENDOR_ID_DIGI 0x114f
1582#define PCI_DEVICE_ID_DIGI_EPC 0x0002
1583#define PCI_DEVICE_ID_DIGI_RIGHTSWITCH 0x0003
1584#define PCI_DEVICE_ID_DIGI_XEM 0x0004
1585#define PCI_DEVICE_ID_DIGI_XR 0x0005
1586#define PCI_DEVICE_ID_DIGI_CX 0x0006
1587#define PCI_DEVICE_ID_DIGI_XRJ 0x0009
1588#define PCI_DEVICE_ID_DIGI_EPCJ 0x000a
1589#define PCI_DEVICE_ID_DIGI_XR_920 0x0027
1590#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070 1307#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070
1591#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071 1308#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
1592#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072 1309#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
@@ -1596,23 +1313,15 @@
1596#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA 1313#define PCI_DEVICE_ID_NEO_2RJ45 0x00CA
1597#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB 1314#define PCI_DEVICE_ID_NEO_2RJ45PRI 0x00CB
1598 1315
1599#define PCI_VENDOR_ID_MUTECH 0x1159
1600#define PCI_DEVICE_ID_MUTECH_MV1000 0x0001
1601 1316
1602#define PCI_VENDOR_ID_XIRCOM 0x115d 1317#define PCI_VENDOR_ID_XIRCOM 0x115d
1603#define PCI_DEVICE_ID_XIRCOM_X3201_ETH 0x0003
1604#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101 1318#define PCI_DEVICE_ID_XIRCOM_RBM56G 0x0101
1605#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103 1319#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103
1606 1320
1607#define PCI_VENDOR_ID_RENDITION 0x1163
1608#define PCI_DEVICE_ID_RENDITION_VERITE 0x0001
1609#define PCI_DEVICE_ID_RENDITION_VERITE2100 0x2000
1610 1321
1611#define PCI_VENDOR_ID_SERVERWORKS 0x1166 1322#define PCI_VENDOR_ID_SERVERWORKS 0x1166
1612#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 1323#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008
1613#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 1324#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
1614#define PCI_DEVICE_ID_SERVERWORKS_CIOB30 0x0010
1615#define PCI_DEVICE_ID_SERVERWORKS_CMIC_HE 0x0011
1616#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 1325#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017
1617#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 1326#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
1618#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 1327#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
@@ -1622,13 +1331,7 @@
1622#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213 1331#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213
1623#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214 1332#define PCI_DEVICE_ID_SERVERWORKS_HT1000IDE 0x0214
1624#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217 1333#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2 0x0217
1625#define PCI_DEVICE_ID_SERVERWORKS_OSB4USB 0x0220
1626#define PCI_DEVICE_ID_SERVERWORKS_CSB5USB PCI_DEVICE_ID_SERVERWORKS_OSB4USB
1627#define PCI_DEVICE_ID_SERVERWORKS_CSB6USB 0x0221
1628#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227 1334#define PCI_DEVICE_ID_SERVERWORKS_CSB6LPC 0x0227
1629#define PCI_DEVICE_ID_SERVERWORKS_GCLE 0x0225
1630#define PCI_DEVICE_ID_SERVERWORKS_GCLE2 0x0227
1631#define PCI_DEVICE_ID_SERVERWORKS_CSB5ISA 0x0230
1632 1335
1633#define PCI_VENDOR_ID_SBE 0x1176 1336#define PCI_VENDOR_ID_SBE 0x1176
1634#define PCI_DEVICE_ID_SBE_WANXL100 0x0301 1337#define PCI_DEVICE_ID_SBE_WANXL100 0x0301
@@ -1639,17 +1342,12 @@
1639#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102 1342#define PCI_DEVICE_ID_TOSHIBA_PICCOLO 0x0102
1640#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103 1343#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_1 0x0103
1641#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105 1344#define PCI_DEVICE_ID_TOSHIBA_PICCOLO_2 0x0105
1642#define PCI_DEVICE_ID_TOSHIBA_601 0x0601
1643#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a 1345#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a
1644#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_A 0x0603
1645#define PCI_DEVICE_ID_TOSHIBA_TOPIC95_B 0x060a
1646#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f 1346#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f
1647#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617 1347#define PCI_DEVICE_ID_TOSHIBA_TOPIC100 0x0617
1648 1348
1649#define PCI_VENDOR_ID_TOSHIBA_2 0x102f 1349#define PCI_VENDOR_ID_TOSHIBA_2 0x102f
1650#define PCI_DEVICE_ID_TOSHIBA_TX3927 0x000a
1651#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030 1350#define PCI_DEVICE_ID_TOSHIBA_TC35815CF 0x0030
1652#define PCI_DEVICE_ID_TOSHIBA_TX4927 0x0180
1653#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108 1351#define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC 0x0108
1654#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3 1352#define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3
1655 1353
@@ -1664,7 +1362,6 @@
1664#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00 1362#define PCI_DEVICE_ID_DLINK_DGE510T 0x4c00
1665 1363
1666#define PCI_VENDOR_ID_ARTOP 0x1191 1364#define PCI_VENDOR_ID_ARTOP 0x1191
1667#define PCI_DEVICE_ID_ARTOP_ATP8400 0x0004
1668#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005 1365#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005
1669#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006 1366#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006
1670#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007 1367#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007
@@ -1677,16 +1374,11 @@
1677#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040 1374#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040
1678#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050 1375#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050
1679#define PCI_DEVICE_ID_ARTOP_8060 0x8060 1376#define PCI_DEVICE_ID_ARTOP_8060 0x8060
1680#define PCI_DEVICE_ID_ARTOP_AEC67160 0x8080
1681#define PCI_DEVICE_ID_ARTOP_AEC67160_2 0x8081
1682#define PCI_DEVICE_ID_ARTOP_AEC67162 0x808a
1683 1377
1684#define PCI_VENDOR_ID_ZEITNET 0x1193 1378#define PCI_VENDOR_ID_ZEITNET 0x1193
1685#define PCI_DEVICE_ID_ZEITNET_1221 0x0001 1379#define PCI_DEVICE_ID_ZEITNET_1221 0x0001
1686#define PCI_DEVICE_ID_ZEITNET_1225 0x0002 1380#define PCI_DEVICE_ID_ZEITNET_1225 0x0002
1687 1381
1688#define PCI_VENDOR_ID_OMEGA 0x119b
1689#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221
1690 1382
1691#define PCI_VENDOR_ID_FUJITSU_ME 0x119e 1383#define PCI_VENDOR_ID_FUJITSU_ME 0x119e
1692#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001 1384#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001
@@ -1696,61 +1388,41 @@
1696#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334 1388#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334
1697 1389
1698#define PCI_VENDOR_ID_MARVELL 0x11ab 1390#define PCI_VENDOR_ID_MARVELL 0x11ab
1699#define PCI_DEVICE_ID_MARVELL_GT64011 0x4146
1700#define PCI_DEVICE_ID_MARVELL_GT64111 0x4146
1701#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 1391#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430
1702#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 1392#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460
1703#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 1393#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480
1704#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652 1394#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652
1705#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653 1395#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653
1706 1396
1707#define PCI_VENDOR_ID_LITEON 0x11ad
1708#define PCI_DEVICE_ID_LITEON_LNE100TX 0x0002
1709 1397
1710#define PCI_VENDOR_ID_V3 0x11b0 1398#define PCI_VENDOR_ID_V3 0x11b0
1711#define PCI_DEVICE_ID_V3_V960 0x0001 1399#define PCI_DEVICE_ID_V3_V960 0x0001
1712#define PCI_DEVICE_ID_V3_V350 0x0001
1713#define PCI_DEVICE_ID_V3_V961 0x0002
1714#define PCI_DEVICE_ID_V3_V351 0x0002 1400#define PCI_DEVICE_ID_V3_V351 0x0002
1715 1401
1716#define PCI_VENDOR_ID_NP 0x11bc
1717#define PCI_DEVICE_ID_NP_PCI_FDDI 0x0001
1718 1402
1719#define PCI_VENDOR_ID_ATT 0x11c1 1403#define PCI_VENDOR_ID_ATT 0x11c1
1720#define PCI_DEVICE_ID_ATT_L56XMF 0x0440
1721#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480 1404#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480
1722 1405
1723#define PCI_VENDOR_ID_NEC2 0x11c3 /* NEC (2nd) */
1724 1406
1725#define PCI_VENDOR_ID_SPECIALIX 0x11cb 1407#define PCI_VENDOR_ID_SPECIALIX 0x11cb
1726#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000 1408#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000
1727#define PCI_DEVICE_ID_SPECIALIX_XIO 0x4000
1728#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000 1409#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000
1729#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004 1410#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004
1730 1411
1731#define PCI_VENDOR_ID_AURAVISION 0x11d1
1732#define PCI_DEVICE_ID_AURAVISION_VXP524 0x01f7
1733 1412
1734#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4 1413#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4
1735#define PCI_DEVICE_ID_AD1889JS 0x1889 1414#define PCI_DEVICE_ID_AD1889JS 0x1889
1736 1415
1737#define PCI_VENDOR_ID_IKON 0x11d5
1738#define PCI_DEVICE_ID_IKON_10115 0x0115
1739#define PCI_DEVICE_ID_IKON_10117 0x0117
1740 1416
1741#define PCI_VENDOR_ID_SEGA 0x11db
1742#define PCI_DEVICE_ID_SEGA_BBA 0x1234 1417#define PCI_DEVICE_ID_SEGA_BBA 0x1234
1743 1418
1744#define PCI_VENDOR_ID_ZORAN 0x11de 1419#define PCI_VENDOR_ID_ZORAN 0x11de
1745#define PCI_DEVICE_ID_ZORAN_36057 0x6057 1420#define PCI_DEVICE_ID_ZORAN_36057 0x6057
1746#define PCI_DEVICE_ID_ZORAN_36120 0x6120 1421#define PCI_DEVICE_ID_ZORAN_36120 0x6120
1747 1422
1748#define PCI_VENDOR_ID_KINETIC 0x11f4
1749#define PCI_DEVICE_ID_KINETIC_2915 0x2915
1750 1423
1751#define PCI_VENDOR_ID_COMPEX 0x11f6 1424#define PCI_VENDOR_ID_COMPEX 0x11f6
1752#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112 1425#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112
1753#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
1754 1426
1755#define PCI_VENDOR_ID_RP 0x11fe 1427#define PCI_VENDOR_ID_RP 0x11fe
1756#define PCI_DEVICE_ID_RP32INTF 0x0001 1428#define PCI_DEVICE_ID_RP32INTF 0x0001
@@ -1764,7 +1436,6 @@
1764#define PCI_DEVICE_ID_RP16SNI 0x0009 1436#define PCI_DEVICE_ID_RP16SNI 0x0009
1765#define PCI_DEVICE_ID_RPP4 0x000A 1437#define PCI_DEVICE_ID_RPP4 0x000A
1766#define PCI_DEVICE_ID_RPP8 0x000B 1438#define PCI_DEVICE_ID_RPP8 0x000B
1767#define PCI_DEVICE_ID_RP8M 0x000C
1768#define PCI_DEVICE_ID_RP4M 0x000D 1439#define PCI_DEVICE_ID_RP4M 0x000D
1769#define PCI_DEVICE_ID_RP2_232 0x000E 1440#define PCI_DEVICE_ID_RP2_232 0x000E
1770#define PCI_DEVICE_ID_RP2_422 0x000F 1441#define PCI_DEVICE_ID_RP2_422 0x000F
@@ -1792,10 +1463,6 @@
1792#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320 1463#define PCI_DEVICE_ID_PC300_TE_M_2 0x0320
1793#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321 1464#define PCI_DEVICE_ID_PC300_TE_M_1 0x0321
1794 1465
1795/* Allied Telesyn */
1796#define PCI_VENDOR_ID_AT 0x1259
1797#define PCI_SUBDEVICE_ID_AT_2701FX 0x2703
1798
1799#define PCI_VENDOR_ID_ESSENTIAL 0x120f 1466#define PCI_VENDOR_ID_ESSENTIAL 0x120f
1800#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001 1467#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001
1801 1468
@@ -1812,10 +1479,7 @@
1812#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005 1479#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005
1813#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009 1480#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
1814 1481
1815#define PCI_VENDOR_ID_SIGMADES 0x1236
1816#define PCI_DEVICE_ID_SIGMADES_6425 0x6401
1817 1482
1818#define PCI_VENDOR_ID_CCUBE 0x123f
1819 1483
1820#define PCI_VENDOR_ID_AVM 0x1244 1484#define PCI_VENDOR_ID_AVM 0x1244
1821#define PCI_DEVICE_ID_AVM_B1 0x0700 1485#define PCI_DEVICE_ID_AVM_B1 0x0700
@@ -1825,19 +1489,8 @@
1825#define PCI_DEVICE_ID_AVM_C2 0x1100 1489#define PCI_DEVICE_ID_AVM_C2 0x1100
1826#define PCI_DEVICE_ID_AVM_T1 0x1200 1490#define PCI_DEVICE_ID_AVM_T1 0x1200
1827 1491
1828#define PCI_VENDOR_ID_DIPIX 0x1246
1829 1492
1830#define PCI_VENDOR_ID_STALLION 0x124d 1493#define PCI_VENDOR_ID_STALLION 0x124d
1831#define PCI_DEVICE_ID_STALLION_ECHPCI832 0x0000
1832#define PCI_DEVICE_ID_STALLION_ECHPCI864 0x0002
1833#define PCI_DEVICE_ID_STALLION_EIOPCI 0x0003
1834
1835#define PCI_VENDOR_ID_OPTIBASE 0x1255
1836#define PCI_DEVICE_ID_OPTIBASE_FORGE 0x1110
1837#define PCI_DEVICE_ID_OPTIBASE_FUSION 0x1210
1838#define PCI_DEVICE_ID_OPTIBASE_VPLEX 0x2110
1839#define PCI_DEVICE_ID_OPTIBASE_VPLEXCC 0x2120
1840#define PCI_DEVICE_ID_OPTIBASE_VQUEST 0x2130
1841 1494
1842/* Allied Telesyn */ 1495/* Allied Telesyn */
1843#define PCI_VENDOR_ID_AT 0x1259 1496#define PCI_VENDOR_ID_AT 0x1259
@@ -1846,7 +1499,6 @@
1846 1499
1847#define PCI_VENDOR_ID_ESS 0x125d 1500#define PCI_VENDOR_ID_ESS 0x125d
1848#define PCI_DEVICE_ID_ESS_ESS1968 0x1968 1501#define PCI_DEVICE_ID_ESS_ESS1968 0x1968
1849#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969
1850#define PCI_DEVICE_ID_ESS_ESS1978 0x1978 1502#define PCI_DEVICE_ID_ESS_ESS1978 0x1978
1851#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988 1503#define PCI_DEVICE_ID_ESS_ALLEGRO_1 0x1988
1852#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989 1504#define PCI_DEVICE_ID_ESS_ALLEGRO 0x1989
@@ -1859,11 +1511,7 @@
1859 1511
1860#define PCI_VENDOR_ID_SATSAGEM 0x1267 1512#define PCI_VENDOR_ID_SATSAGEM 0x1267
1861#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016 1513#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016
1862#define PCI_DEVICE_ID_SATSAGEM_PCR2101 0x5352
1863#define PCI_DEVICE_ID_SATSAGEM_TELSATTURBO 0x5a4b
1864 1514
1865#define PCI_VENDOR_ID_HUGHES 0x1273
1866#define PCI_DEVICE_ID_HUGHES_DIRECPC 0x0002
1867 1515
1868#define PCI_VENDOR_ID_ENSONIQ 0x1274 1516#define PCI_VENDOR_ID_ENSONIQ 0x1274
1869#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880 1517#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880
@@ -1884,13 +1532,10 @@
1884#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886 1532#define PCI_DEVICE_ID_ITE_IT8330G_0 0xe886
1885 1533
1886/* formerly Platform Tech */ 1534/* formerly Platform Tech */
1887#define PCI_VENDOR_ID_ESS_OLD 0x1285
1888#define PCI_DEVICE_ID_ESS_ESS0100 0x0100 1535#define PCI_DEVICE_ID_ESS_ESS0100 0x0100
1889 1536
1890#define PCI_VENDOR_ID_ALTEON 0x12ae 1537#define PCI_VENDOR_ID_ALTEON 0x12ae
1891#define PCI_DEVICE_ID_ALTEON_ACENIC 0x0001
1892 1538
1893#define PCI_VENDOR_ID_USR 0x12B9
1894 1539
1895#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4 1540#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4
1896#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001 1541#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001
@@ -1905,8 +1550,6 @@
1905#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A 1550#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A
1906#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B 1551#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B
1907 1552
1908#define PCI_VENDOR_ID_PICTUREL 0x12c5
1909#define PCI_DEVICE_ID_PICTUREL_PCIVST 0x0081
1910 1553
1911#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 1554#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2
1912#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018 1555#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
@@ -1928,8 +1571,6 @@
1928#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8 1571#define PCI_VENDOR_ID_ELECTRONICDESIGNGMBH 0x12f8
1929#define PCI_DEVICE_ID_LML_33R10 0x8a02 1572#define PCI_DEVICE_ID_LML_33R10 0x8a02
1930 1573
1931#define PCI_VENDOR_ID_CBOARDS 0x1307
1932#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001
1933 1574
1934#define PCI_VENDOR_ID_SIIG 0x131f 1575#define PCI_VENDOR_ID_SIIG 0x131f
1935#define PCI_SUBVENDOR_ID_SIIG 0x131f 1576#define PCI_SUBVENDOR_ID_SIIG 0x131f
@@ -1973,7 +1614,6 @@
1973#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050 1614#define PCI_SUBDEVICE_ID_SIIG_QUARTET_SERIAL 0x2050
1974 1615
1975#define PCI_VENDOR_ID_RADISYS 0x1331 1616#define PCI_VENDOR_ID_RADISYS 0x1331
1976#define PCI_DEVICE_ID_RADISYS_ENP2611 0x0030
1977 1617
1978#define PCI_VENDOR_ID_DOMEX 0x134a 1618#define PCI_VENDOR_ID_DOMEX 0x134a
1979#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001 1619#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001
@@ -1981,8 +1621,6 @@
1981#define PCI_VENDOR_ID_QUATECH 0x135C 1621#define PCI_VENDOR_ID_QUATECH 0x135C
1982#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010 1622#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010
1983#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020 1623#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020
1984#define PCI_DEVICE_ID_QUATECH_DSC200 0x0030
1985#define PCI_DEVICE_ID_QUATECH_QSC200 0x0040
1986#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050 1624#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050
1987#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060 1625#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060
1988 1626
@@ -2001,7 +1639,6 @@
2001#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106 1639#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106
2002#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107 1640#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107
2003#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108 1641#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108
2004#define PCI_SUBDEVICE_ID_HYPERCOPE_PLEXUS 0x0109
2005 1642
2006#define PCI_VENDOR_ID_KAWASAKI 0x136b 1643#define PCI_VENDOR_ID_KAWASAKI 0x136b
2007#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01 1644#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01
@@ -2015,12 +1652,9 @@
2015#define PCI_DEVICE_ID_LMC_SSI 0x0005 1652#define PCI_DEVICE_ID_LMC_SSI 0x0005
2016#define PCI_DEVICE_ID_LMC_T1 0x0006 1653#define PCI_DEVICE_ID_LMC_T1 0x0006
2017 1654
2018#define PCI_VENDOR_ID_MARIAN 0x1382
2019#define PCI_DEVICE_ID_MARIAN_PRODIF_PLUS 0x2048
2020 1655
2021#define PCI_VENDOR_ID_NETGEAR 0x1385 1656#define PCI_VENDOR_ID_NETGEAR 0x1385
2022#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a 1657#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
2023#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a
2024 1658
2025#define PCI_VENDOR_ID_APPLICOM 0x1389 1659#define PCI_VENDOR_ID_APPLICOM 0x1389
2026#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001 1660#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001
@@ -2043,9 +1677,6 @@
2043#define PCI_DEVICE_ID_MOXA_CP134U 0x1340 1677#define PCI_DEVICE_ID_MOXA_CP134U 0x1340
2044#define PCI_DEVICE_ID_MOXA_C168 0x1680 1678#define PCI_DEVICE_ID_MOXA_C168 0x1680
2045#define PCI_DEVICE_ID_MOXA_CP168U 0x1681 1679#define PCI_DEVICE_ID_MOXA_CP168U 0x1681
2046#define PCI_DEVICE_ID_MOXA_CP204J 0x2040
2047#define PCI_DEVICE_ID_MOXA_C218 0x2180
2048#define PCI_DEVICE_ID_MOXA_C320 0x3200
2049 1680
2050#define PCI_VENDOR_ID_CCD 0x1397 1681#define PCI_VENDOR_ID_CCD 0x1397
2051#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0 1682#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
@@ -2066,9 +1697,7 @@
2066 1697
2067#define PCI_VENDOR_ID_MICROGATE 0x13c0 1698#define PCI_VENDOR_ID_MICROGATE 0x13c0
2068#define PCI_DEVICE_ID_MICROGATE_USC 0x0010 1699#define PCI_DEVICE_ID_MICROGATE_USC 0x0010
2069#define PCI_DEVICE_ID_MICROGATE_SCC 0x0020
2070#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030 1700#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030
2071#define PCI_DEVICE_ID_MICROGATE_USC2 0x0210
2072 1701
2073#define PCI_VENDOR_ID_3WARE 0x13C1 1702#define PCI_VENDOR_ID_3WARE 0x13C1
2074#define PCI_DEVICE_ID_3WARE_1000 0x1000 1703#define PCI_DEVICE_ID_3WARE_1000 0x1000
@@ -2119,10 +1748,6 @@
2119 1748
2120#define PCI_VENDOR_ID_SAMSUNG 0x144d 1749#define PCI_VENDOR_ID_SAMSUNG 0x144d
2121 1750
2122#define PCI_VENDOR_ID_AIRONET 0x14b9
2123#define PCI_DEVICE_ID_AIRONET_4800_1 0x0001
2124#define PCI_DEVICE_ID_AIRONET_4800 0x4500 // values switched? see
2125#define PCI_DEVICE_ID_AIRONET_4500 0x4800 // drivers/net/aironet4500_card.c
2126 1751
2127#define PCI_VENDOR_ID_TITAN 0x14D2 1752#define PCI_VENDOR_ID_TITAN 0x14D2
2128#define PCI_DEVICE_ID_TITAN_010L 0x8001 1753#define PCI_DEVICE_ID_TITAN_010L 0x8001
@@ -2141,8 +1766,6 @@
2141#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400 1766#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400
2142#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402 1767#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402
2143 1768
2144#define PCI_VENDOR_ID_SIPACKETS 0x14d9
2145#define PCI_DEVICE_ID_SP_HT 0x0010
2146 1769
2147#define PCI_VENDOR_ID_AFAVLAB 0x14db 1770#define PCI_VENDOR_ID_AFAVLAB 0x14db
2148#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180 1771#define PCI_DEVICE_ID_AFAVLAB_P028 0x2180
@@ -2207,8 +1830,6 @@
2207 1830
2208#define PCI_VENDOR_ID_CHELSIO 0x1425 1831#define PCI_VENDOR_ID_CHELSIO 0x1425
2209 1832
2210#define PCI_VENDOR_ID_MIPS 0x153f
2211#define PCI_DEVICE_ID_SOC_IT 0x0001
2212 1833
2213#define PCI_VENDOR_ID_SYBA 0x1592 1834#define PCI_VENDOR_ID_SYBA 0x1592
2214#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782 1835#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
@@ -2228,15 +1849,7 @@
2228#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 1849#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274
2229 1850
2230#define PCI_VENDOR_ID_PDC 0x15e9 1851#define PCI_VENDOR_ID_PDC 0x15e9
2231#define PCI_DEVICE_ID_PDC_1841 0x1841
2232 1852
2233#define PCI_VENDOR_ID_MACROLINK 0x15ed
2234#define PCI_DEVICE_ID_MACROLINK_MCCS8 0x1000
2235#define PCI_DEVICE_ID_MACROLINK_MCCS 0x1001
2236#define PCI_DEVICE_ID_MACROLINK_MCCS8H 0x1002
2237#define PCI_DEVICE_ID_MACROLINK_MCCSH 0x1003
2238#define PCI_DEVICE_ID_MACROLINK_MCCR8 0x2000
2239#define PCI_DEVICE_ID_MACROLINK_MCCR 0x2001
2240 1853
2241#define PCI_VENDOR_ID_FARSITE 0x1619 1854#define PCI_VENDOR_ID_FARSITE 0x1619
2242#define PCI_DEVICE_ID_FARSITE_T2P 0x0400 1855#define PCI_DEVICE_ID_FARSITE_T2P 0x0400
@@ -2254,7 +1867,6 @@
2254#define PCI_DEVICE_ID_REVOLUTION 0x0044 1867#define PCI_DEVICE_ID_REVOLUTION 0x0044
2255 1868
2256#define PCI_VENDOR_ID_LINKSYS 0x1737 1869#define PCI_VENDOR_ID_LINKSYS 0x1737
2257#define PCI_DEVICE_ID_LINKSYS_EG1032 0x1032
2258#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064 1870#define PCI_DEVICE_ID_LINKSYS_EG1064 0x1064
2259 1871
2260#define PCI_VENDOR_ID_ALTIMA 0x173b 1872#define PCI_VENDOR_ID_ALTIMA 0x173b
@@ -2269,7 +1881,6 @@
2269#define PCI_DEVICE_ID_HERC_WIN 0x5732 1881#define PCI_DEVICE_ID_HERC_WIN 0x5732
2270#define PCI_DEVICE_ID_HERC_UNI 0x5832 1882#define PCI_DEVICE_ID_HERC_UNI 0x5832
2271 1883
2272#define PCI_VENDOR_ID_INFINICON 0x1820
2273 1884
2274#define PCI_VENDOR_ID_SITECOM 0x182d 1885#define PCI_VENDOR_ID_SITECOM 0x182d
2275#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 1886#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069
@@ -2279,8 +1890,6 @@
2279#define PCI_VENDOR_ID_TDI 0x192E 1890#define PCI_VENDOR_ID_TDI 0x192E
2280#define PCI_DEVICE_ID_TDI_EHCI 0x0101 1891#define PCI_DEVICE_ID_TDI_EHCI 0x0101
2281 1892
2282#define PCI_VENDOR_ID_SYMPHONY 0x1c1c
2283#define PCI_DEVICE_ID_SYMPHONY_101 0x0001
2284 1893
2285#define PCI_VENDOR_ID_TEKRAM 0x1de1 1894#define PCI_VENDOR_ID_TEKRAM 0x1de1
2286#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 1895#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
@@ -2289,70 +1898,33 @@
2289#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013 1898#define PCI_DEVICE_ID_HINT_VXPROII_IDE 0x8013
2290 1899
2291#define PCI_VENDOR_ID_3DLABS 0x3d3d 1900#define PCI_VENDOR_ID_3DLABS 0x3d3d
2292#define PCI_DEVICE_ID_3DLABS_300SX 0x0001
2293#define PCI_DEVICE_ID_3DLABS_500TX 0x0002
2294#define PCI_DEVICE_ID_3DLABS_DELTA 0x0003
2295#define PCI_DEVICE_ID_3DLABS_PERMEDIA 0x0004
2296#define PCI_DEVICE_ID_3DLABS_MX 0x0006
2297#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007 1901#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007
2298#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
2299#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009 1902#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009
2300 1903
2301#define PCI_VENDOR_ID_AVANCE 0x4005
2302#define PCI_DEVICE_ID_AVANCE_ALG2064 0x2064
2303#define PCI_DEVICE_ID_AVANCE_2302 0x2302
2304 1904
2305#define PCI_VENDOR_ID_AKS 0x416c 1905#define PCI_VENDOR_ID_AKS 0x416c
2306#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100 1906#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100
2307#define PCI_DEVICE_ID_AKS_CPC 0x0200
2308 1907
2309#define PCI_VENDOR_ID_REDCREEK 0x4916
2310#define PCI_DEVICE_ID_RC45 0x1960
2311 1908
2312#define PCI_VENDOR_ID_NETVIN 0x4a14
2313#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
2314 1909
2315#define PCI_VENDOR_ID_S3 0x5333 1910#define PCI_VENDOR_ID_S3 0x5333
2316#define PCI_DEVICE_ID_S3_PLATO_PXS 0x0551
2317#define PCI_DEVICE_ID_S3_ViRGE 0x5631
2318#define PCI_DEVICE_ID_S3_TRIO 0x8811 1911#define PCI_DEVICE_ID_S3_TRIO 0x8811
2319#define PCI_DEVICE_ID_S3_AURORA64VP 0x8812
2320#define PCI_DEVICE_ID_S3_TRIO64UVP 0x8814
2321#define PCI_DEVICE_ID_S3_ViRGE_VX 0x883d
2322#define PCI_DEVICE_ID_S3_868 0x8880 1912#define PCI_DEVICE_ID_S3_868 0x8880
2323#define PCI_DEVICE_ID_S3_928 0x88b0
2324#define PCI_DEVICE_ID_S3_864_1 0x88c0
2325#define PCI_DEVICE_ID_S3_864_2 0x88c1
2326#define PCI_DEVICE_ID_S3_964_1 0x88d0
2327#define PCI_DEVICE_ID_S3_964_2 0x88d1
2328#define PCI_DEVICE_ID_S3_968 0x88f0 1913#define PCI_DEVICE_ID_S3_968 0x88f0
2329#define PCI_DEVICE_ID_S3_TRIO64V2 0x8901
2330#define PCI_DEVICE_ID_S3_PLATO_PXG 0x8902
2331#define PCI_DEVICE_ID_S3_ViRGE_DXGX 0x8a01
2332#define PCI_DEVICE_ID_S3_ViRGE_GX2 0x8a10
2333#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25 1914#define PCI_DEVICE_ID_S3_SAVAGE4 0x8a25
2334#define PCI_DEVICE_ID_S3_ViRGE_MX 0x8c01
2335#define PCI_DEVICE_ID_S3_ViRGE_MXP 0x8c02
2336#define PCI_DEVICE_ID_S3_ViRGE_MXPMV 0x8c03
2337#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04 1915#define PCI_DEVICE_ID_S3_PROSAVAGE8 0x8d04
2338#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00 1916#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00
2339 1917
2340#define PCI_VENDOR_ID_DUNORD 0x5544 1918#define PCI_VENDOR_ID_DUNORD 0x5544
2341#define PCI_DEVICE_ID_DUNORD_I3000 0x0001 1919#define PCI_DEVICE_ID_DUNORD_I3000 0x0001
2342 1920
1921
2343#define PCI_VENDOR_ID_DCI 0x6666 1922#define PCI_VENDOR_ID_DCI 0x6666
2344#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001 1923#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001
2345#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002 1924#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002
2346 1925
2347#define PCI_VENDOR_ID_DUNORD 0x5544
2348#define PCI_DEVICE_ID_DUNORD_I3000 0x0001
2349
2350#define PCI_VENDOR_ID_GENROCO 0x5555
2351#define PCI_DEVICE_ID_GENROCO_HFP832 0x0003
2352
2353#define PCI_VENDOR_ID_INTEL 0x8086 1926#define PCI_VENDOR_ID_INTEL 0x8086
2354#define PCI_DEVICE_ID_INTEL_EESSC 0x0008 1927#define PCI_DEVICE_ID_INTEL_EESSC 0x0008
2355#define PCI_DEVICE_ID_INTEL_21145 0x0039
2356#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320 1928#define PCI_DEVICE_ID_INTEL_PXHD_0 0x0320
2357#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321 1929#define PCI_DEVICE_ID_INTEL_PXHD_1 0x0321
2358#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329 1930#define PCI_DEVICE_ID_INTEL_PXH_0 0x0329
@@ -2361,30 +1933,17 @@
2361#define PCI_DEVICE_ID_INTEL_82375 0x0482 1933#define PCI_DEVICE_ID_INTEL_82375 0x0482
2362#define PCI_DEVICE_ID_INTEL_82424 0x0483 1934#define PCI_DEVICE_ID_INTEL_82424 0x0483
2363#define PCI_DEVICE_ID_INTEL_82378 0x0484 1935#define PCI_DEVICE_ID_INTEL_82378 0x0484
2364#define PCI_DEVICE_ID_INTEL_82430 0x0486
2365#define PCI_DEVICE_ID_INTEL_82434 0x04a3
2366#define PCI_DEVICE_ID_INTEL_I960 0x0960 1936#define PCI_DEVICE_ID_INTEL_I960 0x0960
2367#define PCI_DEVICE_ID_INTEL_I960RM 0x0962 1937#define PCI_DEVICE_ID_INTEL_I960RM 0x0962
2368#define PCI_DEVICE_ID_INTEL_82562ET 0x1031
2369#define PCI_DEVICE_ID_INTEL_82801CAM 0x1038
2370#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130 1938#define PCI_DEVICE_ID_INTEL_82815_MC 0x1130
2371#define PCI_DEVICE_ID_INTEL_82815_AB 0x1131
2372#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132 1939#define PCI_DEVICE_ID_INTEL_82815_CGC 0x1132
2373#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
2374#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221 1940#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
2375#define PCI_DEVICE_ID_INTEL_82092AA_1 0x1222
2376#define PCI_DEVICE_ID_INTEL_7116 0x1223
2377#define PCI_DEVICE_ID_INTEL_7505_0 0x2550 1941#define PCI_DEVICE_ID_INTEL_7505_0 0x2550
2378#define PCI_DEVICE_ID_INTEL_7505_1 0x2552
2379#define PCI_DEVICE_ID_INTEL_7205_0 0x255d 1942#define PCI_DEVICE_ID_INTEL_7205_0 0x255d
2380#define PCI_DEVICE_ID_INTEL_82596 0x1226
2381#define PCI_DEVICE_ID_INTEL_82865 0x1227
2382#define PCI_DEVICE_ID_INTEL_82557 0x1229
2383#define PCI_DEVICE_ID_INTEL_82437 0x122d 1943#define PCI_DEVICE_ID_INTEL_82437 0x122d
2384#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e 1944#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e
2385#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230 1945#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230
2386#define PCI_DEVICE_ID_INTEL_82371MX 0x1234 1946#define PCI_DEVICE_ID_INTEL_82371MX 0x1234
2387#define PCI_DEVICE_ID_INTEL_82437MX 0x1235
2388#define PCI_DEVICE_ID_INTEL_82441 0x1237 1947#define PCI_DEVICE_ID_INTEL_82441 0x1237
2389#define PCI_DEVICE_ID_INTEL_82380FB 0x124b 1948#define PCI_DEVICE_ID_INTEL_82380FB 0x124b
2390#define PCI_DEVICE_ID_INTEL_82439 0x1250 1949#define PCI_DEVICE_ID_INTEL_82439 0x1250
@@ -2393,83 +1952,53 @@
2393#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30 1952#define PCI_DEVICE_ID_INTEL_82845_HB 0x1a30
2394#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410 1953#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
2395#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411 1954#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
2396#define PCI_DEVICE_ID_INTEL_82801AA_2 0x2412
2397#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413 1955#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
2398#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415 1956#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415
2399#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416 1957#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416
2400#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418 1958#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418
2401#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420 1959#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420
2402#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421 1960#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421
2403#define PCI_DEVICE_ID_INTEL_82801AB_2 0x2422
2404#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423 1961#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423
2405#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425 1962#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425
2406#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426 1963#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426
2407#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428 1964#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428
2408#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440 1965#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440
2409#define PCI_DEVICE_ID_INTEL_82801BA_1 0x2442
2410#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443 1966#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443
2411#define PCI_DEVICE_ID_INTEL_82801BA_3 0x2444
2412#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445 1967#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445
2413#define PCI_DEVICE_ID_INTEL_82801BA_5 0x2446
2414#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448 1968#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448
2415#define PCI_DEVICE_ID_INTEL_82801BA_7 0x2449
2416#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a 1969#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a
2417#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b 1970#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b
2418#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c 1971#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c
2419#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e 1972#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e
2420#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450 1973#define PCI_DEVICE_ID_INTEL_82801E_0 0x2450
2421#define PCI_DEVICE_ID_INTEL_82801E_2 0x2452
2422#define PCI_DEVICE_ID_INTEL_82801E_3 0x2453
2423#define PCI_DEVICE_ID_INTEL_82801E_9 0x2459
2424#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b 1974#define PCI_DEVICE_ID_INTEL_82801E_11 0x245b
2425#define PCI_DEVICE_ID_INTEL_82801E_13 0x245d
2426#define PCI_DEVICE_ID_INTEL_82801E_14 0x245e
2427#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480 1975#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480
2428#define PCI_DEVICE_ID_INTEL_82801CA_2 0x2482
2429#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483 1976#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483
2430#define PCI_DEVICE_ID_INTEL_82801CA_4 0x2484
2431#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485 1977#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485
2432#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486 1978#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486
2433#define PCI_DEVICE_ID_INTEL_82801CA_7 0x2487
2434#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a 1979#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a
2435#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b 1980#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b
2436#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c 1981#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c
2437#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0 1982#define PCI_DEVICE_ID_INTEL_82801DB_0 0x24c0
2438#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1 1983#define PCI_DEVICE_ID_INTEL_82801DB_1 0x24c1
2439#define PCI_DEVICE_ID_INTEL_82801DB_2 0x24c2
2440#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3 1984#define PCI_DEVICE_ID_INTEL_82801DB_3 0x24c3
2441#define PCI_DEVICE_ID_INTEL_82801DB_4 0x24c4
2442#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5 1985#define PCI_DEVICE_ID_INTEL_82801DB_5 0x24c5
2443#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6 1986#define PCI_DEVICE_ID_INTEL_82801DB_6 0x24c6
2444#define PCI_DEVICE_ID_INTEL_82801DB_7 0x24c7
2445#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9 1987#define PCI_DEVICE_ID_INTEL_82801DB_9 0x24c9
2446#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca 1988#define PCI_DEVICE_ID_INTEL_82801DB_10 0x24ca
2447#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb 1989#define PCI_DEVICE_ID_INTEL_82801DB_11 0x24cb
2448#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc 1990#define PCI_DEVICE_ID_INTEL_82801DB_12 0x24cc
2449#define PCI_DEVICE_ID_INTEL_82801DB_13 0x24cd
2450#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0 1991#define PCI_DEVICE_ID_INTEL_82801EB_0 0x24d0
2451#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1 1992#define PCI_DEVICE_ID_INTEL_82801EB_1 0x24d1
2452#define PCI_DEVICE_ID_INTEL_82801EB_2 0x24d2
2453#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3 1993#define PCI_DEVICE_ID_INTEL_82801EB_3 0x24d3
2454#define PCI_DEVICE_ID_INTEL_82801EB_4 0x24d4
2455#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5 1994#define PCI_DEVICE_ID_INTEL_82801EB_5 0x24d5
2456#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6 1995#define PCI_DEVICE_ID_INTEL_82801EB_6 0x24d6
2457#define PCI_DEVICE_ID_INTEL_82801EB_7 0x24d7
2458#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db 1996#define PCI_DEVICE_ID_INTEL_82801EB_11 0x24db
2459#define PCI_DEVICE_ID_INTEL_82801EB_13 0x24dd
2460#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1 1997#define PCI_DEVICE_ID_INTEL_ESB_1 0x25a1
2461#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2 1998#define PCI_DEVICE_ID_INTEL_ESB_2 0x25a2
2462#define PCI_DEVICE_ID_INTEL_ESB_3 0x25a3
2463#define PCI_DEVICE_ID_INTEL_ESB_31 0x25b0
2464#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4 1999#define PCI_DEVICE_ID_INTEL_ESB_4 0x25a4
2465#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6 2000#define PCI_DEVICE_ID_INTEL_ESB_5 0x25a6
2466#define PCI_DEVICE_ID_INTEL_ESB_6 0x25a7
2467#define PCI_DEVICE_ID_INTEL_ESB_7 0x25a9
2468#define PCI_DEVICE_ID_INTEL_ESB_8 0x25aa
2469#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab 2001#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab
2470#define PCI_DEVICE_ID_INTEL_ESB_11 0x25ac
2471#define PCI_DEVICE_ID_INTEL_ESB_12 0x25ad
2472#define PCI_DEVICE_ID_INTEL_ESB_13 0x25ae
2473#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500 2002#define PCI_DEVICE_ID_INTEL_82820_HB 0x2500
2474#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501 2003#define PCI_DEVICE_ID_INTEL_82820_UP_HB 0x2501
2475#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530 2004#define PCI_DEVICE_ID_INTEL_82850_HB 0x2530
@@ -2479,7 +2008,6 @@
2479#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570 2008#define PCI_DEVICE_ID_INTEL_82865_HB 0x2570
2480#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572 2009#define PCI_DEVICE_ID_INTEL_82865_IG 0x2572
2481#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578 2010#define PCI_DEVICE_ID_INTEL_82875_HB 0x2578
2482#define PCI_DEVICE_ID_INTEL_82875_IG 0x257b
2483#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580 2011#define PCI_DEVICE_ID_INTEL_82915G_HB 0x2580
2484#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 2012#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582
2485#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 2013#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590
@@ -2489,80 +2017,23 @@
2489#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640 2017#define PCI_DEVICE_ID_INTEL_ICH6_0 0x2640
2490#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641 2018#define PCI_DEVICE_ID_INTEL_ICH6_1 0x2641
2491#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642 2019#define PCI_DEVICE_ID_INTEL_ICH6_2 0x2642
2492#define PCI_DEVICE_ID_INTEL_ICH6_3 0x2651
2493#define PCI_DEVICE_ID_INTEL_ICH6_4 0x2652
2494#define PCI_DEVICE_ID_INTEL_ICH6_5 0x2653
2495#define PCI_DEVICE_ID_INTEL_ICH6_6 0x2658
2496#define PCI_DEVICE_ID_INTEL_ICH6_7 0x2659
2497#define PCI_DEVICE_ID_INTEL_ICH6_8 0x265a
2498#define PCI_DEVICE_ID_INTEL_ICH6_9 0x265b
2499#define PCI_DEVICE_ID_INTEL_ICH6_10 0x265c
2500#define PCI_DEVICE_ID_INTEL_ICH6_11 0x2660
2501#define PCI_DEVICE_ID_INTEL_ICH6_12 0x2662
2502#define PCI_DEVICE_ID_INTEL_ICH6_13 0x2664
2503#define PCI_DEVICE_ID_INTEL_ICH6_14 0x2666
2504#define PCI_DEVICE_ID_INTEL_ICH6_15 0x2668
2505#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a 2020#define PCI_DEVICE_ID_INTEL_ICH6_16 0x266a
2506#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d 2021#define PCI_DEVICE_ID_INTEL_ICH6_17 0x266d
2507#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e 2022#define PCI_DEVICE_ID_INTEL_ICH6_18 0x266e
2508#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f 2023#define PCI_DEVICE_ID_INTEL_ICH6_19 0x266f
2509#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670 2024#define PCI_DEVICE_ID_INTEL_ESB2_0 0x2670
2510#define PCI_DEVICE_ID_INTEL_ESB2_1 0x2680
2511#define PCI_DEVICE_ID_INTEL_ESB2_2 0x2681
2512#define PCI_DEVICE_ID_INTEL_ESB2_3 0x2682
2513#define PCI_DEVICE_ID_INTEL_ESB2_4 0x2683
2514#define PCI_DEVICE_ID_INTEL_ESB2_5 0x2688
2515#define PCI_DEVICE_ID_INTEL_ESB2_6 0x2689
2516#define PCI_DEVICE_ID_INTEL_ESB2_7 0x268a
2517#define PCI_DEVICE_ID_INTEL_ESB2_8 0x268b
2518#define PCI_DEVICE_ID_INTEL_ESB2_9 0x268c
2519#define PCI_DEVICE_ID_INTEL_ESB2_10 0x2690
2520#define PCI_DEVICE_ID_INTEL_ESB2_11 0x2692
2521#define PCI_DEVICE_ID_INTEL_ESB2_12 0x2694
2522#define PCI_DEVICE_ID_INTEL_ESB2_13 0x2696
2523#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698 2025#define PCI_DEVICE_ID_INTEL_ESB2_14 0x2698
2524#define PCI_DEVICE_ID_INTEL_ESB2_15 0x2699
2525#define PCI_DEVICE_ID_INTEL_ESB2_16 0x269a
2526#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b 2026#define PCI_DEVICE_ID_INTEL_ESB2_17 0x269b
2527#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e 2027#define PCI_DEVICE_ID_INTEL_ESB2_18 0x269e
2528#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8 2028#define PCI_DEVICE_ID_INTEL_ICH7_0 0x27b8
2529#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9 2029#define PCI_DEVICE_ID_INTEL_ICH7_1 0x27b9
2530#define PCI_DEVICE_ID_INTEL_ICH7_2 0x27c0
2531#define PCI_DEVICE_ID_INTEL_ICH7_3 0x27c1
2532#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0 2030#define PCI_DEVICE_ID_INTEL_ICH7_30 0x27b0
2533#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd 2031#define PCI_DEVICE_ID_INTEL_ICH7_31 0x27bd
2534#define PCI_DEVICE_ID_INTEL_ICH7_5 0x27c4
2535#define PCI_DEVICE_ID_INTEL_ICH7_6 0x27c5
2536#define PCI_DEVICE_ID_INTEL_ICH7_7 0x27c8
2537#define PCI_DEVICE_ID_INTEL_ICH7_8 0x27c9
2538#define PCI_DEVICE_ID_INTEL_ICH7_9 0x27ca
2539#define PCI_DEVICE_ID_INTEL_ICH7_10 0x27cb
2540#define PCI_DEVICE_ID_INTEL_ICH7_11 0x27cc
2541#define PCI_DEVICE_ID_INTEL_ICH7_12 0x27d0
2542#define PCI_DEVICE_ID_INTEL_ICH7_13 0x27d2
2543#define PCI_DEVICE_ID_INTEL_ICH7_14 0x27d4
2544#define PCI_DEVICE_ID_INTEL_ICH7_15 0x27d6
2545#define PCI_DEVICE_ID_INTEL_ICH7_16 0x27d8
2546#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da 2032#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da
2547#define PCI_DEVICE_ID_INTEL_ICH7_18 0x27dc
2548#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd 2033#define PCI_DEVICE_ID_INTEL_ICH7_19 0x27dd
2549#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de 2034#define PCI_DEVICE_ID_INTEL_ICH7_20 0x27de
2550#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df 2035#define PCI_DEVICE_ID_INTEL_ICH7_21 0x27df
2551#define PCI_DEVICE_ID_INTEL_ICH7_22 0x27e0
2552#define PCI_DEVICE_ID_INTEL_ICH7_23 0x27e2
2553#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2036#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2554#define PCI_DEVICE_ID_INTEL_ESB2_19 0x3500
2555#define PCI_DEVICE_ID_INTEL_ESB2_20 0x3501
2556#define PCI_DEVICE_ID_INTEL_ESB2_21 0x3504
2557#define PCI_DEVICE_ID_INTEL_ESB2_22 0x3505
2558#define PCI_DEVICE_ID_INTEL_ESB2_23 0x350c
2559#define PCI_DEVICE_ID_INTEL_ESB2_24 0x350d
2560#define PCI_DEVICE_ID_INTEL_ESB2_25 0x3510
2561#define PCI_DEVICE_ID_INTEL_ESB2_26 0x3511
2562#define PCI_DEVICE_ID_INTEL_ESB2_27 0x3514
2563#define PCI_DEVICE_ID_INTEL_ESB2_28 0x3515
2564#define PCI_DEVICE_ID_INTEL_ESB2_29 0x3518
2565#define PCI_DEVICE_ID_INTEL_ESB2_30 0x3519
2566#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2037#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2567#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2038#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
2568#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580 2039#define PCI_DEVICE_ID_INTEL_82855GM_HB 0x3580
@@ -2576,7 +2047,6 @@
2576#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599 2047#define PCI_DEVICE_ID_INTEL_MCH_PC 0x3599
2577#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a 2048#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a
2578#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e 2049#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e
2579#define PCI_DEVICE_ID_INTEL_80310 0x530d
2580#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000 2050#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000
2581#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010 2051#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010
2582#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020 2052#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
@@ -2601,22 +2071,15 @@
2601#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196 2071#define PCI_DEVICE_ID_INTEL_440MX_6 0x7196
2602#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198 2072#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198
2603#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199 2073#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199
2604#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a
2605#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b 2074#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b
2606#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 2075#define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0
2607#define PCI_DEVICE_ID_INTEL_82443GX_1 0x71a1
2608#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 2076#define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2
2609#define PCI_DEVICE_ID_INTEL_82372FB_0 0x7600
2610#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 2077#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
2611#define PCI_DEVICE_ID_INTEL_82372FB_2 0x7602
2612#define PCI_DEVICE_ID_INTEL_82372FB_3 0x7603
2613#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 2078#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
2614#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
2615#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca 2079#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
2616#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb 2080#define PCI_DEVICE_ID_INTEL_82454NX 0x84cb
2617#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea 2081#define PCI_DEVICE_ID_INTEL_84460GX 0x84ea
2618#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500 2082#define PCI_DEVICE_ID_INTEL_IXP4XX 0x8500
2619#define PCI_DEVICE_ID_INTEL_IXP2400 0x9001
2620#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004 2083#define PCI_DEVICE_ID_INTEL_IXP2800 0x9004
2621#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 2084#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152
2622 2085
@@ -2629,7 +2092,6 @@
2629#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003 2092#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003
2630 2093
2631#define PCI_VENDOR_ID_KTI 0x8e2e 2094#define PCI_VENDOR_ID_KTI 0x8e2e
2632#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
2633 2095
2634#define PCI_VENDOR_ID_ADAPTEC 0x9004 2096#define PCI_VENDOR_ID_ADAPTEC 0x9004
2635#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078 2097#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078
@@ -2637,7 +2099,6 @@
2637#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860 2099#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860
2638#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078 2100#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078
2639#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578 2101#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578
2640#define PCI_DEVICE_ID_ADAPTEC_5800 0x5800
2641#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038 2102#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038
2642#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075 2103#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075
2643#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078 2104#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078
@@ -2657,7 +2118,6 @@
2657#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678 2118#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678
2658#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778 2119#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778
2659#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878 2120#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878
2660#define PCI_DEVICE_ID_ADAPTEC_1030 0x8b78
2661 2121
2662#define PCI_VENDOR_ID_ADAPTEC2 0x9005 2122#define PCI_VENDOR_ID_ADAPTEC2 0x9005
2663#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010 2123#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010
@@ -2677,8 +2137,6 @@
2677#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf 2137#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf
2678#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503 2138#define PCI_DEVICE_ID_ADAPTEC2_SCAMP 0x0503
2679 2139
2680#define PCI_VENDOR_ID_ATRONICS 0x907f
2681#define PCI_DEVICE_ID_ATRONICS_2015 0x2015
2682 2140
2683#define PCI_VENDOR_ID_HOLTEK 0x9412 2141#define PCI_VENDOR_ID_HOLTEK 0x9412
2684#define PCI_DEVICE_ID_HOLTEK_6565 0x6565 2142#define PCI_DEVICE_ID_HOLTEK_6565 0x6565
@@ -2711,7 +2169,3 @@
2711#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897 2169#define PCI_DEVICE_ID_RME_DIGI32_PRO 0x9897
2712#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898 2170#define PCI_DEVICE_ID_RME_DIGI32_8 0x9898
2713 2171
2714#define PCI_VENDOR_ID_ARK 0xedd8
2715#define PCI_DEVICE_ID_ARK_STING 0xa091
2716#define PCI_DEVICE_ID_ARK_STINGARK 0xa099
2717#define PCI_DEVICE_ID_ARK_2000MT 0xa0a1
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 5cfb07648eca..c61d5de837ef 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -219,10 +219,11 @@ typedef struct pm_message {
219 219
220struct dev_pm_info { 220struct dev_pm_info {
221 pm_message_t power_state; 221 pm_message_t power_state;
222 unsigned can_wakeup:1;
222#ifdef CONFIG_PM 223#ifdef CONFIG_PM
224 unsigned should_wakeup:1;
223 pm_message_t prev_state; 225 pm_message_t prev_state;
224 void * saved_state; 226 void * saved_state;
225 atomic_t pm_users;
226 struct device * pm_parent; 227 struct device * pm_parent;
227 struct list_head entry; 228 struct list_head entry;
228#endif 229#endif
@@ -236,13 +237,48 @@ extern void device_resume(void);
236 237
237#ifdef CONFIG_PM 238#ifdef CONFIG_PM
238extern int device_suspend(pm_message_t state); 239extern int device_suspend(pm_message_t state);
239#else 240
241#define device_set_wakeup_enable(dev,val) \
242 ((dev)->power.should_wakeup = !!(val))
243#define device_may_wakeup(dev) \
244 (device_can_wakeup(dev) && (dev)->power.should_wakeup)
245
246extern int dpm_runtime_suspend(struct device *, pm_message_t);
247extern void dpm_runtime_resume(struct device *);
248
249#else /* !CONFIG_PM */
250
240static inline int device_suspend(pm_message_t state) 251static inline int device_suspend(pm_message_t state)
241{ 252{
242 return 0; 253 return 0;
243} 254}
255
256#define device_set_wakeup_enable(dev,val) do{}while(0)
257#define device_may_wakeup(dev) (0)
258
259static inline int dpm_runtime_suspend(struct device * dev, pm_message_t state)
260{
261 return 0;
262}
263
264static inline void dpm_runtime_resume(struct device * dev)
265{
266
267}
268
244#endif 269#endif
245 270
271/* changes to device_may_wakeup take effect on the next pm state change.
272 * by default, devices should wakeup if they can.
273 */
274#define device_can_wakeup(dev) \
275 ((dev)->power.can_wakeup)
276#define device_init_wakeup(dev,val) \
277 do { \
278 device_can_wakeup(dev) = !!(val); \
279 device_set_wakeup_enable(dev,val); \
280 } while(0)
281
246#endif /* __KERNEL__ */ 282#endif /* __KERNEL__ */
247 283
248#endif /* _LINUX_PM_H */ 284#endif /* _LINUX_PM_H */
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 045d4761febc..9f0f9281f42a 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -24,7 +24,7 @@
24 24
25struct radix_tree_root { 25struct radix_tree_root {
26 unsigned int height; 26 unsigned int height;
27 unsigned int gfp_mask; 27 gfp_t gfp_mask;
28 struct radix_tree_node *rnode; 28 struct radix_tree_node *rnode;
29}; 29};
30 30
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index af00b10294cd..001ab82df051 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1972,7 +1972,7 @@ extern struct address_space_operations reiserfs_address_space_operations;
1972 1972
1973/* fix_nodes.c */ 1973/* fix_nodes.c */
1974#ifdef CONFIG_REISERFS_CHECK 1974#ifdef CONFIG_REISERFS_CHECK
1975void *reiserfs_kmalloc(size_t size, int flags, struct super_block *s); 1975void *reiserfs_kmalloc(size_t size, gfp_t flags, struct super_block *s);
1976void reiserfs_kfree(const void *vp, size_t size, struct super_block *s); 1976void reiserfs_kfree(const void *vp, size_t size, struct super_block *s);
1977#else 1977#else
1978static inline void *reiserfs_kmalloc(size_t size, int flags, 1978static inline void *reiserfs_kmalloc(size_t size, int flags,
diff --git a/include/linux/sdladrv.h b/include/linux/sdladrv.h
index 78f634007fc6..c85e103d5e7b 100644
--- a/include/linux/sdladrv.h
+++ b/include/linux/sdladrv.h
@@ -52,12 +52,8 @@ typedef struct sdlahw
52 52
53extern int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len); 53extern int sdla_setup (sdlahw_t* hw, void* sfm, unsigned len);
54extern int sdla_down (sdlahw_t* hw); 54extern int sdla_down (sdlahw_t* hw);
55extern int sdla_inten (sdlahw_t* hw);
56extern int sdla_intde (sdlahw_t* hw);
57extern int sdla_intack (sdlahw_t* hw);
58extern void S514_intack (sdlahw_t* hw, u32 int_status); 55extern void S514_intack (sdlahw_t* hw, u32 int_status);
59extern void read_S514_int_stat (sdlahw_t* hw, u32* int_status); 56extern void read_S514_int_stat (sdlahw_t* hw, u32* int_status);
60extern int sdla_intr (sdlahw_t* hw);
61extern int sdla_mapmem (sdlahw_t* hw, unsigned long addr); 57extern int sdla_mapmem (sdlahw_t* hw, unsigned long addr);
62extern int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf, 58extern int sdla_peek (sdlahw_t* hw, unsigned long addr, void* buf,
63 unsigned len); 59 unsigned len);
diff --git a/include/linux/security.h b/include/linux/security.h
index 627382e74057..dac956ed98f0 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1210,7 +1210,7 @@ struct security_operations {
1210 int (*socket_shutdown) (struct socket * sock, int how); 1210 int (*socket_shutdown) (struct socket * sock, int how);
1211 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb); 1211 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1212 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len); 1212 int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1213 int (*sk_alloc_security) (struct sock *sk, int family, int priority); 1213 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1214 void (*sk_free_security) (struct sock *sk); 1214 void (*sk_free_security) (struct sock *sk);
1215#endif /* CONFIG_SECURITY_NETWORK */ 1215#endif /* CONFIG_SECURITY_NETWORK */
1216}; 1216};
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8f5d9e7f8734..4286d832166f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -137,6 +137,8 @@ struct skb_shared_info {
137 unsigned int nr_frags; 137 unsigned int nr_frags;
138 unsigned short tso_size; 138 unsigned short tso_size;
139 unsigned short tso_segs; 139 unsigned short tso_segs;
140 unsigned short ufo_size;
141 unsigned int ip6_frag_id;
140 struct sk_buff *frag_list; 142 struct sk_buff *frag_list;
141 skb_frag_t frags[MAX_SKB_FRAGS]; 143 skb_frag_t frags[MAX_SKB_FRAGS];
142}; 144};
@@ -171,7 +173,6 @@ enum {
171 * struct sk_buff - socket buffer 173 * struct sk_buff - socket buffer
172 * @next: Next buffer in list 174 * @next: Next buffer in list
173 * @prev: Previous buffer in list 175 * @prev: Previous buffer in list
174 * @list: List we are on
175 * @sk: Socket we are owned by 176 * @sk: Socket we are owned by
176 * @tstamp: Time we arrived 177 * @tstamp: Time we arrived
177 * @dev: Device we arrived on/are leaving by 178 * @dev: Device we arrived on/are leaving by
@@ -190,6 +191,7 @@ enum {
190 * @cloned: Head may be cloned (check refcnt to be sure) 191 * @cloned: Head may be cloned (check refcnt to be sure)
191 * @nohdr: Payload reference only, must not modify header 192 * @nohdr: Payload reference only, must not modify header
192 * @pkt_type: Packet class 193 * @pkt_type: Packet class
194 * @fclone: skbuff clone status
193 * @ip_summed: Driver fed us an IP checksum 195 * @ip_summed: Driver fed us an IP checksum
194 * @priority: Packet queueing priority 196 * @priority: Packet queueing priority
195 * @users: User count - see {datagram,tcp}.c 197 * @users: User count - see {datagram,tcp}.c
@@ -202,6 +204,7 @@ enum {
202 * @destructor: Destruct function 204 * @destructor: Destruct function
203 * @nfmark: Can be used for communication between hooks 205 * @nfmark: Can be used for communication between hooks
204 * @nfct: Associated connection, if any 206 * @nfct: Associated connection, if any
207 * @ipvs_property: skbuff is owned by ipvs
205 * @nfctinfo: Relationship of this skb to the connection 208 * @nfctinfo: Relationship of this skb to the connection
206 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 209 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
207 * @tc_index: Traffic control index 210 * @tc_index: Traffic control index
@@ -340,6 +343,11 @@ extern void skb_over_panic(struct sk_buff *skb, int len,
340extern void skb_under_panic(struct sk_buff *skb, int len, 343extern void skb_under_panic(struct sk_buff *skb, int len,
341 void *here); 344 void *here);
342 345
346extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
347 int getfrag(void *from, char *to, int offset,
348 int len,int odd, struct sk_buff *skb),
349 void *from, int length);
350
343struct skb_seq_state 351struct skb_seq_state
344{ 352{
345 __u32 lower_offset; 353 __u32 lower_offset;
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 5fc04a16ecb0..09b9aa60063d 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -121,7 +121,7 @@ extern unsigned int ksize(const void *);
121extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node); 121extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node);
122extern void *kmalloc_node(size_t size, gfp_t flags, int node); 122extern void *kmalloc_node(size_t size, gfp_t flags, int node);
123#else 123#else
124static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int flags, int node) 124static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node)
125{ 125{
126 return kmem_cache_alloc(cachep, flags); 126 return kmem_cache_alloc(cachep, flags);
127} 127}
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index 04ebc24db348..b68c11a2d6dd 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -66,7 +66,12 @@ struct rpc_cred_cache {
66 66
67struct rpc_auth { 67struct rpc_auth {
68 unsigned int au_cslack; /* call cred size estimate */ 68 unsigned int au_cslack; /* call cred size estimate */
69 unsigned int au_rslack; /* reply verf size guess */ 69 /* guess at number of u32's auth adds before
70 * reply data; normally the verifier size: */
71 unsigned int au_rslack;
72 /* for gss, used to calculate au_rslack: */
73 unsigned int au_verfsize;
74
70 unsigned int au_flags; /* various flags */ 75 unsigned int au_flags; /* various flags */
71 struct rpc_authops * au_ops; /* operations */ 76 struct rpc_authops * au_ops; /* operations */
72 rpc_authflavor_t au_flavor; /* pseudoflavor (note may 77 rpc_authflavor_t au_flavor; /* pseudoflavor (note may
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index eadb31e3c198..1a42d902bc11 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -32,6 +32,7 @@
32#define RPCDBG_AUTH 0x0010 32#define RPCDBG_AUTH 0x0010
33#define RPCDBG_PMAP 0x0020 33#define RPCDBG_PMAP 0x0020
34#define RPCDBG_SCHED 0x0040 34#define RPCDBG_SCHED 0x0040
35#define RPCDBG_TRANS 0x0080
35#define RPCDBG_SVCSOCK 0x0100 36#define RPCDBG_SVCSOCK 0x0100
36#define RPCDBG_SVCDSP 0x0200 37#define RPCDBG_SVCDSP 0x0200
37#define RPCDBG_MISC 0x0400 38#define RPCDBG_MISC 0x0400
@@ -94,6 +95,8 @@ enum {
94 CTL_NLMDEBUG, 95 CTL_NLMDEBUG,
95 CTL_SLOTTABLE_UDP, 96 CTL_SLOTTABLE_UDP,
96 CTL_SLOTTABLE_TCP, 97 CTL_SLOTTABLE_TCP,
98 CTL_MIN_RESVPORT,
99 CTL_MAX_RESVPORT,
97}; 100};
98 101
99#endif /* _LINUX_SUNRPC_DEBUG_H_ */ 102#endif /* _LINUX_SUNRPC_DEBUG_H_ */
diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h
index 689262f63059..9b8bcf125c18 100644
--- a/include/linux/sunrpc/gss_api.h
+++ b/include/linux/sunrpc/gss_api.h
@@ -40,14 +40,21 @@ int gss_import_sec_context(
40 struct gss_ctx **ctx_id); 40 struct gss_ctx **ctx_id);
41u32 gss_get_mic( 41u32 gss_get_mic(
42 struct gss_ctx *ctx_id, 42 struct gss_ctx *ctx_id,
43 u32 qop,
44 struct xdr_buf *message, 43 struct xdr_buf *message,
45 struct xdr_netobj *mic_token); 44 struct xdr_netobj *mic_token);
46u32 gss_verify_mic( 45u32 gss_verify_mic(
47 struct gss_ctx *ctx_id, 46 struct gss_ctx *ctx_id,
48 struct xdr_buf *message, 47 struct xdr_buf *message,
49 struct xdr_netobj *mic_token, 48 struct xdr_netobj *mic_token);
50 u32 *qstate); 49u32 gss_wrap(
50 struct gss_ctx *ctx_id,
51 int offset,
52 struct xdr_buf *outbuf,
53 struct page **inpages);
54u32 gss_unwrap(
55 struct gss_ctx *ctx_id,
56 int offset,
57 struct xdr_buf *inbuf);
51u32 gss_delete_sec_context( 58u32 gss_delete_sec_context(
52 struct gss_ctx **ctx_id); 59 struct gss_ctx **ctx_id);
53 60
@@ -56,7 +63,6 @@ char *gss_service_to_auth_domain_name(struct gss_api_mech *, u32 service);
56 63
57struct pf_desc { 64struct pf_desc {
58 u32 pseudoflavor; 65 u32 pseudoflavor;
59 u32 qop;
60 u32 service; 66 u32 service;
61 char *name; 67 char *name;
62 char *auth_domain_name; 68 char *auth_domain_name;
@@ -85,14 +91,21 @@ struct gss_api_ops {
85 struct gss_ctx *ctx_id); 91 struct gss_ctx *ctx_id);
86 u32 (*gss_get_mic)( 92 u32 (*gss_get_mic)(
87 struct gss_ctx *ctx_id, 93 struct gss_ctx *ctx_id,
88 u32 qop,
89 struct xdr_buf *message, 94 struct xdr_buf *message,
90 struct xdr_netobj *mic_token); 95 struct xdr_netobj *mic_token);
91 u32 (*gss_verify_mic)( 96 u32 (*gss_verify_mic)(
92 struct gss_ctx *ctx_id, 97 struct gss_ctx *ctx_id,
93 struct xdr_buf *message, 98 struct xdr_buf *message,
94 struct xdr_netobj *mic_token, 99 struct xdr_netobj *mic_token);
95 u32 *qstate); 100 u32 (*gss_wrap)(
101 struct gss_ctx *ctx_id,
102 int offset,
103 struct xdr_buf *outbuf,
104 struct page **inpages);
105 u32 (*gss_unwrap)(
106 struct gss_ctx *ctx_id,
107 int offset,
108 struct xdr_buf *buf);
96 void (*gss_delete_sec_context)( 109 void (*gss_delete_sec_context)(
97 void *internal_ctx_id); 110 void *internal_ctx_id);
98}; 111};
diff --git a/include/linux/sunrpc/gss_err.h b/include/linux/sunrpc/gss_err.h
index 92608a2e574c..a6807867bd21 100644
--- a/include/linux/sunrpc/gss_err.h
+++ b/include/linux/sunrpc/gss_err.h
@@ -66,16 +66,6 @@ typedef unsigned int OM_uint32;
66 66
67 67
68/* 68/*
69 * Define the default Quality of Protection for per-message services. Note
70 * that an implementation that offers multiple levels of QOP may either reserve
71 * a value (for example zero, as assumed here) to mean "default protection", or
72 * alternatively may simply equate GSS_C_QOP_DEFAULT to a specific explicit
73 * QOP value. However a value of 0 should always be interpreted by a GSSAPI
74 * implementation as a request for the default protection level.
75 */
76#define GSS_C_QOP_DEFAULT 0
77
78/*
79 * Expiration time of 2^32-1 seconds means infinite lifetime for a 69 * Expiration time of 2^32-1 seconds means infinite lifetime for a
80 * credential or security context 70 * credential or security context
81 */ 71 */
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
index ffe31d2eb9ec..2c3601d31045 100644
--- a/include/linux/sunrpc/gss_krb5.h
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -116,18 +116,22 @@ enum seal_alg {
116 116
117s32 117s32
118make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body, 118make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
119 struct xdr_netobj *cksum); 119 int body_offset, struct xdr_netobj *cksum);
120
121u32 gss_get_mic_kerberos(struct gss_ctx *, struct xdr_buf *,
122 struct xdr_netobj *);
123
124u32 gss_verify_mic_kerberos(struct gss_ctx *, struct xdr_buf *,
125 struct xdr_netobj *);
120 126
121u32 127u32
122krb5_make_token(struct krb5_ctx *context_handle, int qop_req, 128gss_wrap_kerberos(struct gss_ctx *ctx_id, int offset,
123 struct xdr_buf *input_message_buffer, 129 struct xdr_buf *outbuf, struct page **pages);
124 struct xdr_netobj *output_message_buffer, int toktype);
125 130
126u32 131u32
127krb5_read_token(struct krb5_ctx *context_handle, 132gss_unwrap_kerberos(struct gss_ctx *ctx_id, int offset,
128 struct xdr_netobj *input_token_buffer, 133 struct xdr_buf *buf);
129 struct xdr_buf *message_buffer, 134
130 int *qop_state, int toktype);
131 135
132u32 136u32
133krb5_encrypt(struct crypto_tfm * key, 137krb5_encrypt(struct crypto_tfm * key,
@@ -137,6 +141,13 @@ u32
137krb5_decrypt(struct crypto_tfm * key, 141krb5_decrypt(struct crypto_tfm * key,
138 void *iv, void *in, void *out, int length); 142 void *iv, void *in, void *out, int length);
139 143
144int
145gss_encrypt_xdr_buf(struct crypto_tfm *tfm, struct xdr_buf *outbuf, int offset,
146 struct page **pages);
147
148int
149gss_decrypt_xdr_buf(struct crypto_tfm *tfm, struct xdr_buf *inbuf, int offset);
150
140s32 151s32
141krb5_make_seq_num(struct crypto_tfm * key, 152krb5_make_seq_num(struct crypto_tfm * key,
142 int direction, 153 int direction,
diff --git a/include/linux/sunrpc/gss_spkm3.h b/include/linux/sunrpc/gss_spkm3.h
index b5c9968c3c17..0beb2cf00a84 100644
--- a/include/linux/sunrpc/gss_spkm3.h
+++ b/include/linux/sunrpc/gss_spkm3.h
@@ -41,9 +41,9 @@ struct spkm3_ctx {
41#define SPKM_WRAP_TOK 5 41#define SPKM_WRAP_TOK 5
42#define SPKM_DEL_TOK 6 42#define SPKM_DEL_TOK 6
43 43
44u32 spkm3_make_token(struct spkm3_ctx *ctx, int qop_req, struct xdr_buf * text, struct xdr_netobj * token, int toktype); 44u32 spkm3_make_token(struct spkm3_ctx *ctx, struct xdr_buf * text, struct xdr_netobj * token, int toktype);
45 45
46u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struct xdr_buf *message_buffer, int *qop_state, int toktype); 46u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struct xdr_buf *message_buffer, int toktype);
47 47
48#define CKSUMTYPE_RSA_MD5 0x0007 48#define CKSUMTYPE_RSA_MD5 0x0007
49 49
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index 15f115332389..f43f237360ae 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -76,5 +76,30 @@ enum rpc_auth_stat {
76 76
77#define RPC_MAXNETNAMELEN 256 77#define RPC_MAXNETNAMELEN 256
78 78
79/*
80 * From RFC 1831:
81 *
82 * "A record is composed of one or more record fragments. A record
83 * fragment is a four-byte header followed by 0 to (2**31) - 1 bytes of
84 * fragment data. The bytes encode an unsigned binary number; as with
85 * XDR integers, the byte order is from highest to lowest. The number
86 * encodes two values -- a boolean which indicates whether the fragment
87 * is the last fragment of the record (bit value 1 implies the fragment
88 * is the last fragment) and a 31-bit unsigned binary value which is the
89 * length in bytes of the fragment's data. The boolean value is the
90 * highest-order bit of the header; the length is the 31 low-order bits.
91 * (Note that this record specification is NOT in XDR standard form!)"
92 *
93 * The Linux RPC client always sends its requests in a single record
94 * fragment, limiting the maximum payload size for stream transports to
95 * 2GB.
96 */
97
98typedef u32 rpc_fraghdr;
99
100#define RPC_LAST_STREAM_FRAGMENT (1U << 31)
101#define RPC_FRAGMENT_SIZE_MASK (~RPC_LAST_STREAM_FRAGMENT)
102#define RPC_MAX_FRAGMENT_SIZE ((1U << 31) - 1)
103
79#endif /* __KERNEL__ */ 104#endif /* __KERNEL__ */
80#endif /* _LINUX_SUNRPC_MSGPROT_H_ */ 105#endif /* _LINUX_SUNRPC_MSGPROT_H_ */
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 23448d0fb5bc..5da968729cf8 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -161,14 +161,10 @@ typedef struct {
161 161
162typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len); 162typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len);
163 163
164extern int csum_partial_copy_to_xdr(struct xdr_buf *, struct sk_buff *);
164extern ssize_t xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int, 165extern ssize_t xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
165 skb_reader_t *, skb_read_actor_t); 166 skb_reader_t *, skb_read_actor_t);
166 167
167struct socket;
168struct sockaddr;
169extern int xdr_sendpages(struct socket *, struct sockaddr *, int,
170 struct xdr_buf *, unsigned int, int);
171
172extern int xdr_encode_word(struct xdr_buf *, int, u32); 168extern int xdr_encode_word(struct xdr_buf *, int, u32);
173extern int xdr_decode_word(struct xdr_buf *, int, u32 *); 169extern int xdr_decode_word(struct xdr_buf *, int, u32 *);
174 170
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index e618c1649814..3b8b6e823c70 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/linux/sunrpc/clnt_xprt.h 2 * linux/include/linux/sunrpc/xprt.h
3 * 3 *
4 * Declarations for the RPC transport interface. 4 * Declarations for the RPC transport interface.
5 * 5 *
@@ -15,20 +15,6 @@
15#include <linux/sunrpc/sched.h> 15#include <linux/sunrpc/sched.h>
16#include <linux/sunrpc/xdr.h> 16#include <linux/sunrpc/xdr.h>
17 17
18/*
19 * The transport code maintains an estimate on the maximum number of out-
20 * standing RPC requests, using a smoothed version of the congestion
21 * avoidance implemented in 44BSD. This is basically the Van Jacobson
22 * congestion algorithm: If a retransmit occurs, the congestion window is
23 * halved; otherwise, it is incremented by 1/cwnd when
24 *
25 * - a reply is received and
26 * - a full number of requests are outstanding and
27 * - the congestion window hasn't been updated recently.
28 *
29 * Upper procedures may check whether a request would block waiting for
30 * a free RPC slot by using the RPC_CONGESTED() macro.
31 */
32extern unsigned int xprt_udp_slot_table_entries; 18extern unsigned int xprt_udp_slot_table_entries;
33extern unsigned int xprt_tcp_slot_table_entries; 19extern unsigned int xprt_tcp_slot_table_entries;
34 20
@@ -36,34 +22,23 @@ extern unsigned int xprt_tcp_slot_table_entries;
36#define RPC_DEF_SLOT_TABLE (16U) 22#define RPC_DEF_SLOT_TABLE (16U)
37#define RPC_MAX_SLOT_TABLE (128U) 23#define RPC_MAX_SLOT_TABLE (128U)
38 24
39#define RPC_CWNDSHIFT (8U)
40#define RPC_CWNDSCALE (1U << RPC_CWNDSHIFT)
41#define RPC_INITCWND RPC_CWNDSCALE
42#define RPC_MAXCWND(xprt) ((xprt)->max_reqs << RPC_CWNDSHIFT)
43#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
44
45/* Default timeout values */
46#define RPC_MAX_UDP_TIMEOUT (60*HZ)
47#define RPC_MAX_TCP_TIMEOUT (600*HZ)
48
49/* 25/*
50 * Wait duration for an RPC TCP connection to be established. Solaris 26 * RPC call and reply header size as number of 32bit words (verifier
51 * NFS over TCP uses 60 seconds, for example, which is in line with how 27 * size computed separately)
52 * long a server takes to reboot.
53 */ 28 */
54#define RPC_CONNECT_TIMEOUT (60*HZ) 29#define RPC_CALLHDRSIZE 6
30#define RPC_REPHDRSIZE 4
55 31
56/* 32/*
57 * Delay an arbitrary number of seconds before attempting to reconnect 33 * Parameters for choosing a free port
58 * after an error.
59 */ 34 */
60#define RPC_REESTABLISH_TIMEOUT (15*HZ) 35extern unsigned int xprt_min_resvport;
36extern unsigned int xprt_max_resvport;
61 37
62/* RPC call and reply header size as number of 32bit words (verifier 38#define RPC_MIN_RESVPORT (1U)
63 * size computed separately) 39#define RPC_MAX_RESVPORT (65535U)
64 */ 40#define RPC_DEF_MIN_RESVPORT (650U)
65#define RPC_CALLHDRSIZE 6 41#define RPC_DEF_MAX_RESVPORT (1023U)
66#define RPC_REPHDRSIZE 4
67 42
68/* 43/*
69 * This describes a timeout strategy 44 * This describes a timeout strategy
@@ -76,6 +51,9 @@ struct rpc_timeout {
76 unsigned char to_exponential; 51 unsigned char to_exponential;
77}; 52};
78 53
54struct rpc_task;
55struct rpc_xprt;
56
79/* 57/*
80 * This describes a complete RPC request 58 * This describes a complete RPC request
81 */ 59 */
@@ -95,7 +73,10 @@ struct rpc_rqst {
95 int rq_cong; /* has incremented xprt->cong */ 73 int rq_cong; /* has incremented xprt->cong */
96 int rq_received; /* receive completed */ 74 int rq_received; /* receive completed */
97 u32 rq_seqno; /* gss seq no. used on req. */ 75 u32 rq_seqno; /* gss seq no. used on req. */
98 76 int rq_enc_pages_num;
77 struct page **rq_enc_pages; /* scratch pages for use by
78 gss privacy code */
79 void (*rq_release_snd_buf)(struct rpc_rqst *); /* release rq_enc_pages */
99 struct list_head rq_list; 80 struct list_head rq_list;
100 81
101 struct xdr_buf rq_private_buf; /* The receive buffer 82 struct xdr_buf rq_private_buf; /* The receive buffer
@@ -121,12 +102,21 @@ struct rpc_rqst {
121#define rq_svec rq_snd_buf.head 102#define rq_svec rq_snd_buf.head
122#define rq_slen rq_snd_buf.len 103#define rq_slen rq_snd_buf.len
123 104
124#define XPRT_LAST_FRAG (1 << 0) 105struct rpc_xprt_ops {
125#define XPRT_COPY_RECM (1 << 1) 106 void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize);
126#define XPRT_COPY_XID (1 << 2) 107 int (*reserve_xprt)(struct rpc_task *task);
127#define XPRT_COPY_DATA (1 << 3) 108 void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
109 void (*connect)(struct rpc_task *task);
110 int (*send_request)(struct rpc_task *task);
111 void (*set_retrans_timeout)(struct rpc_task *task);
112 void (*timer)(struct rpc_task *task);
113 void (*release_request)(struct rpc_task *task);
114 void (*close)(struct rpc_xprt *xprt);
115 void (*destroy)(struct rpc_xprt *xprt);
116};
128 117
129struct rpc_xprt { 118struct rpc_xprt {
119 struct rpc_xprt_ops * ops; /* transport methods */
130 struct socket * sock; /* BSD socket layer */ 120 struct socket * sock; /* BSD socket layer */
131 struct sock * inet; /* INET layer */ 121 struct sock * inet; /* INET layer */
132 122
@@ -137,11 +127,13 @@ struct rpc_xprt {
137 unsigned long cong; /* current congestion */ 127 unsigned long cong; /* current congestion */
138 unsigned long cwnd; /* congestion window */ 128 unsigned long cwnd; /* congestion window */
139 129
140 unsigned int rcvsize, /* socket receive buffer size */ 130 size_t rcvsize, /* transport rcv buffer size */
141 sndsize; /* socket send buffer size */ 131 sndsize; /* transport send buffer size */
142 132
143 size_t max_payload; /* largest RPC payload size, 133 size_t max_payload; /* largest RPC payload size,
144 in bytes */ 134 in bytes */
135 unsigned int tsh_size; /* size of transport specific
136 header */
145 137
146 struct rpc_wait_queue sending; /* requests waiting to send */ 138 struct rpc_wait_queue sending; /* requests waiting to send */
147 struct rpc_wait_queue resend; /* requests waiting to resend */ 139 struct rpc_wait_queue resend; /* requests waiting to resend */
@@ -150,11 +142,9 @@ struct rpc_xprt {
150 struct list_head free; /* free slots */ 142 struct list_head free; /* free slots */
151 struct rpc_rqst * slot; /* slot table storage */ 143 struct rpc_rqst * slot; /* slot table storage */
152 unsigned int max_reqs; /* total slots */ 144 unsigned int max_reqs; /* total slots */
153 unsigned long sockstate; /* Socket state */ 145 unsigned long state; /* transport state */
154 unsigned char shutdown : 1, /* being shut down */ 146 unsigned char shutdown : 1, /* being shut down */
155 nocong : 1, /* no congestion control */ 147 resvport : 1; /* use a reserved port */
156 resvport : 1, /* use a reserved port */
157 stream : 1; /* TCP */
158 148
159 /* 149 /*
160 * XID 150 * XID
@@ -171,22 +161,27 @@ struct rpc_xprt {
171 unsigned long tcp_copied, /* copied to request */ 161 unsigned long tcp_copied, /* copied to request */
172 tcp_flags; 162 tcp_flags;
173 /* 163 /*
174 * Connection of sockets 164 * Connection of transports
175 */ 165 */
176 struct work_struct sock_connect; 166 unsigned long connect_timeout,
167 bind_timeout,
168 reestablish_timeout;
169 struct work_struct connect_worker;
177 unsigned short port; 170 unsigned short port;
171
178 /* 172 /*
179 * Disconnection of idle sockets 173 * Disconnection of idle transports
180 */ 174 */
181 struct work_struct task_cleanup; 175 struct work_struct task_cleanup;
182 struct timer_list timer; 176 struct timer_list timer;
183 unsigned long last_used; 177 unsigned long last_used,
178 idle_timeout;
184 179
185 /* 180 /*
186 * Send stuff 181 * Send stuff
187 */ 182 */
188 spinlock_t sock_lock; /* lock socket info */ 183 spinlock_t transport_lock; /* lock transport info */
189 spinlock_t xprt_lock; /* lock xprt info */ 184 spinlock_t reserve_lock; /* lock slot table */
190 struct rpc_task * snd_task; /* Task blocked in send */ 185 struct rpc_task * snd_task; /* Task blocked in send */
191 186
192 struct list_head recv; 187 struct list_head recv;
@@ -195,37 +190,111 @@ struct rpc_xprt {
195 void (*old_data_ready)(struct sock *, int); 190 void (*old_data_ready)(struct sock *, int);
196 void (*old_state_change)(struct sock *); 191 void (*old_state_change)(struct sock *);
197 void (*old_write_space)(struct sock *); 192 void (*old_write_space)(struct sock *);
198
199 wait_queue_head_t cong_wait;
200}; 193};
201 194
195#define XPRT_LAST_FRAG (1 << 0)
196#define XPRT_COPY_RECM (1 << 1)
197#define XPRT_COPY_XID (1 << 2)
198#define XPRT_COPY_DATA (1 << 3)
199
202#ifdef __KERNEL__ 200#ifdef __KERNEL__
203 201
204struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, 202/*
205 struct rpc_timeout *toparms); 203 * Transport operations used by ULPs
206int xprt_destroy(struct rpc_xprt *); 204 */
207void xprt_set_timeout(struct rpc_timeout *, unsigned int, 205struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, struct rpc_timeout *to);
208 unsigned long); 206void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr);
209 207
210void xprt_reserve(struct rpc_task *); 208/*
211int xprt_prepare_transmit(struct rpc_task *); 209 * Generic internal transport functions
212void xprt_transmit(struct rpc_task *); 210 */
213void xprt_receive(struct rpc_task *); 211void xprt_connect(struct rpc_task *task);
212void xprt_reserve(struct rpc_task *task);
213int xprt_reserve_xprt(struct rpc_task *task);
214int xprt_reserve_xprt_cong(struct rpc_task *task);
215int xprt_prepare_transmit(struct rpc_task *task);
216void xprt_transmit(struct rpc_task *task);
217void xprt_abort_transmit(struct rpc_task *task);
214int xprt_adjust_timeout(struct rpc_rqst *req); 218int xprt_adjust_timeout(struct rpc_rqst *req);
215void xprt_release(struct rpc_task *); 219void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
216void xprt_connect(struct rpc_task *); 220void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
217void xprt_sock_setbufsize(struct rpc_xprt *); 221void xprt_release(struct rpc_task *task);
218 222int xprt_destroy(struct rpc_xprt *xprt);
219#define XPRT_LOCKED 0 223
220#define XPRT_CONNECT 1 224static inline u32 *xprt_skip_transport_header(struct rpc_xprt *xprt, u32 *p)
221#define XPRT_CONNECTING 2 225{
222 226 return p + xprt->tsh_size;
223#define xprt_connected(xp) (test_bit(XPRT_CONNECT, &(xp)->sockstate)) 227}
224#define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate)) 228
225#define xprt_test_and_set_connected(xp) (test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate)) 229/*
226#define xprt_test_and_clear_connected(xp) \ 230 * Transport switch helper functions
227 (test_and_clear_bit(XPRT_CONNECT, &(xp)->sockstate)) 231 */
228#define xprt_clear_connected(xp) (clear_bit(XPRT_CONNECT, &(xp)->sockstate)) 232void xprt_set_retrans_timeout_def(struct rpc_task *task);
233void xprt_set_retrans_timeout_rtt(struct rpc_task *task);
234void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status);
235void xprt_wait_for_buffer_space(struct rpc_task *task);
236void xprt_write_space(struct rpc_xprt *xprt);
237void xprt_update_rtt(struct rpc_task *task);
238void xprt_adjust_cwnd(struct rpc_task *task, int result);
239struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid);
240void xprt_complete_rqst(struct rpc_task *task, int copied);
241void xprt_release_rqst_cong(struct rpc_task *task);
242void xprt_disconnect(struct rpc_xprt *xprt);
243
244/*
245 * Socket transport setup operations
246 */
247int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to);
248int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to);
249
250/*
251 * Reserved bit positions in xprt->state
252 */
253#define XPRT_LOCKED (0)
254#define XPRT_CONNECTED (1)
255#define XPRT_CONNECTING (2)
256
257static inline void xprt_set_connected(struct rpc_xprt *xprt)
258{
259 set_bit(XPRT_CONNECTED, &xprt->state);
260}
261
262static inline void xprt_clear_connected(struct rpc_xprt *xprt)
263{
264 clear_bit(XPRT_CONNECTED, &xprt->state);
265}
266
267static inline int xprt_connected(struct rpc_xprt *xprt)
268{
269 return test_bit(XPRT_CONNECTED, &xprt->state);
270}
271
272static inline int xprt_test_and_set_connected(struct rpc_xprt *xprt)
273{
274 return test_and_set_bit(XPRT_CONNECTED, &xprt->state);
275}
276
277static inline int xprt_test_and_clear_connected(struct rpc_xprt *xprt)
278{
279 return test_and_clear_bit(XPRT_CONNECTED, &xprt->state);
280}
281
282static inline void xprt_clear_connecting(struct rpc_xprt *xprt)
283{
284 smp_mb__before_clear_bit();
285 clear_bit(XPRT_CONNECTING, &xprt->state);
286 smp_mb__after_clear_bit();
287}
288
289static inline int xprt_connecting(struct rpc_xprt *xprt)
290{
291 return test_bit(XPRT_CONNECTING, &xprt->state);
292}
293
294static inline int xprt_test_and_set_connecting(struct rpc_xprt *xprt)
295{
296 return test_and_set_bit(XPRT_CONNECTING, &xprt->state);
297}
229 298
230#endif /* __KERNEL__*/ 299#endif /* __KERNEL__*/
231 300
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index ad15a54806d8..ba448c760168 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -71,7 +71,7 @@ void restore_processor_state(void);
71struct saved_context; 71struct saved_context;
72void __save_processor_state(struct saved_context *ctxt); 72void __save_processor_state(struct saved_context *ctxt);
73void __restore_processor_state(struct saved_context *ctxt); 73void __restore_processor_state(struct saved_context *ctxt);
74extern unsigned long get_usable_page(unsigned gfp_mask); 74extern unsigned long get_usable_page(gfp_t gfp_mask);
75extern void free_eaten_memory(void); 75extern void free_eaten_memory(void);
76 76
77#endif /* _LINUX_SWSUSP_H */ 77#endif /* _LINUX_SWSUSP_H */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index a7bf1a3b1496..20c975642cab 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -171,8 +171,8 @@ extern int rotate_reclaimable_page(struct page *page);
171extern void swap_setup(void); 171extern void swap_setup(void);
172 172
173/* linux/mm/vmscan.c */ 173/* linux/mm/vmscan.c */
174extern int try_to_free_pages(struct zone **, unsigned int); 174extern int try_to_free_pages(struct zone **, gfp_t);
175extern int zone_reclaim(struct zone *, unsigned int, unsigned int); 175extern int zone_reclaim(struct zone *, gfp_t, unsigned int);
176extern int shrink_all_memory(int); 176extern int shrink_all_memory(int);
177extern int vm_swappiness; 177extern int vm_swappiness;
178 178
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 515046d1b2f4..fc5bb4e91a58 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -40,7 +40,7 @@ struct ts_state
40struct ts_ops 40struct ts_ops
41{ 41{
42 const char *name; 42 const char *name;
43 struct ts_config * (*init)(const void *, unsigned int, int); 43 struct ts_config * (*init)(const void *, unsigned int, gfp_t);
44 unsigned int (*find)(struct ts_config *, 44 unsigned int (*find)(struct ts_config *,
45 struct ts_state *); 45 struct ts_state *);
46 void (*destroy)(struct ts_config *); 46 void (*destroy)(struct ts_config *);
@@ -148,7 +148,7 @@ static inline unsigned int textsearch_get_pattern_len(struct ts_config *conf)
148extern int textsearch_register(struct ts_ops *); 148extern int textsearch_register(struct ts_ops *);
149extern int textsearch_unregister(struct ts_ops *); 149extern int textsearch_unregister(struct ts_ops *);
150extern struct ts_config *textsearch_prepare(const char *, const void *, 150extern struct ts_config *textsearch_prepare(const char *, const void *,
151 unsigned int, int, int); 151 unsigned int, gfp_t, int);
152extern void textsearch_destroy(struct ts_config *conf); 152extern void textsearch_destroy(struct ts_config *conf);
153extern unsigned int textsearch_find_continuous(struct ts_config *, 153extern unsigned int textsearch_find_continuous(struct ts_config *,
154 struct ts_state *, 154 struct ts_state *,
diff --git a/include/linux/types.h b/include/linux/types.h
index 0aee34f9da9f..21b9ce803644 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -151,7 +151,12 @@ typedef unsigned long sector_t;
151 */ 151 */
152 152
153#ifdef __CHECKER__ 153#ifdef __CHECKER__
154#define __bitwise __attribute__((bitwise)) 154#define __bitwise__ __attribute__((bitwise))
155#else
156#define __bitwise__
157#endif
158#ifdef __CHECK_ENDIAN__
159#define __bitwise __bitwise__
155#else 160#else
156#define __bitwise 161#define __bitwise
157#endif 162#endif
@@ -166,7 +171,7 @@ typedef __u64 __bitwise __be64;
166#endif 171#endif
167 172
168#ifdef __KERNEL__ 173#ifdef __KERNEL__
169typedef unsigned __nocast gfp_t; 174typedef unsigned __bitwise__ gfp_t;
170#endif 175#endif
171 176
172struct ustat { 177struct ustat {
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 4dbe580f9335..748d04385256 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -57,6 +57,7 @@ struct usb_host_endpoint {
57 struct usb_endpoint_descriptor desc; 57 struct usb_endpoint_descriptor desc;
58 struct list_head urb_list; 58 struct list_head urb_list;
59 void *hcpriv; 59 void *hcpriv;
60 struct kobject *kobj; /* For sysfs info */
60 61
61 unsigned char *extra; /* Extra descriptors */ 62 unsigned char *extra; /* Extra descriptors */
62 int extralen; 63 int extralen;
@@ -136,7 +137,8 @@ struct usb_interface {
136 * active alternate setting */ 137 * active alternate setting */
137 unsigned num_altsetting; /* number of alternate settings */ 138 unsigned num_altsetting; /* number of alternate settings */
138 139
139 int minor; /* minor number this interface is bound to */ 140 int minor; /* minor number this interface is
141 * bound to */
140 enum usb_interface_condition condition; /* state of binding */ 142 enum usb_interface_condition condition; /* state of binding */
141 struct device dev; /* interface specific device info */ 143 struct device dev; /* interface specific device info */
142 struct class_device *class_dev; 144 struct class_device *class_dev;
@@ -229,7 +231,7 @@ struct usb_interface_cache {
229struct usb_host_config { 231struct usb_host_config {
230 struct usb_config_descriptor desc; 232 struct usb_config_descriptor desc;
231 233
232 char *string; 234 char *string; /* iConfiguration string, if present */
233 /* the interfaces associated with this configuration, 235 /* the interfaces associated with this configuration,
234 * stored in no particular order */ 236 * stored in no particular order */
235 struct usb_interface *interface[USB_MAXINTERFACES]; 237 struct usb_interface *interface[USB_MAXINTERFACES];
@@ -248,7 +250,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
248 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 250 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\
249 type,(void**)ptr) 251 type,(void**)ptr)
250 252
251/* -------------------------------------------------------------------------- */ 253/* ----------------------------------------------------------------------- */
252 254
253struct usb_operations; 255struct usb_operations;
254 256
@@ -268,7 +270,8 @@ struct usb_bus {
268 unsigned is_b_host:1; /* true during some HNP roleswitches */ 270 unsigned is_b_host:1; /* true during some HNP roleswitches */
269 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 271 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
270 272
271 int devnum_next; /* Next open device number in round-robin allocation */ 273 int devnum_next; /* Next open device number in
274 * round-robin allocation */
272 275
273 struct usb_devmap devmap; /* device address allocation map */ 276 struct usb_devmap devmap; /* device address allocation map */
274 struct usb_operations *op; /* Operations (specific to the HC) */ 277 struct usb_operations *op; /* Operations (specific to the HC) */
@@ -289,15 +292,16 @@ struct usb_bus {
289 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 292 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
290 293
291 struct class_device *class_dev; /* class device for this bus */ 294 struct class_device *class_dev; /* class device for this bus */
292 struct kref kref; /* handles reference counting this bus */ 295 struct kref kref; /* reference counting for this bus */
293 void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */ 296 void (*release)(struct usb_bus *bus);
297
294#if defined(CONFIG_USB_MON) 298#if defined(CONFIG_USB_MON)
295 struct mon_bus *mon_bus; /* non-null when associated */ 299 struct mon_bus *mon_bus; /* non-null when associated */
296 int monitored; /* non-zero when monitored */ 300 int monitored; /* non-zero when monitored */
297#endif 301#endif
298}; 302};
299 303
300/* -------------------------------------------------------------------------- */ 304/* ----------------------------------------------------------------------- */
301 305
302/* This is arbitrary. 306/* This is arbitrary.
303 * From USB 2.0 spec Table 11-13, offset 7, a hub can 307 * From USB 2.0 spec Table 11-13, offset 7, a hub can
@@ -326,7 +330,8 @@ struct usb_device {
326 330
327 struct semaphore serialize; 331 struct semaphore serialize;
328 332
329 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ 333 unsigned int toggle[2]; /* one bit for each endpoint
334 * ([0] = IN, [1] = OUT) */
330 335
331 struct usb_device *parent; /* our hub, unless we're the root */ 336 struct usb_device *parent; /* our hub, unless we're the root */
332 struct usb_bus *bus; /* Bus we're part of */ 337 struct usb_bus *bus; /* Bus we're part of */
@@ -343,12 +348,14 @@ struct usb_device {
343 348
344 char **rawdescriptors; /* Raw descriptors for each config */ 349 char **rawdescriptors; /* Raw descriptors for each config */
345 350
346 int have_langid; /* whether string_langid is valid yet */ 351 int have_langid; /* whether string_langid is valid */
347 int string_langid; /* language ID for strings */ 352 int string_langid; /* language ID for strings */
348 353
349 char *product; 354 /* static strings from the device */
350 char *manufacturer; 355 char *product; /* iProduct string, if present */
351 char *serial; /* static strings from the device */ 356 char *manufacturer; /* iManufacturer string, if present */
357 char *serial; /* iSerialNumber string, if present */
358
352 struct list_head filelist; 359 struct list_head filelist;
353 struct class_device *class_dev; 360 struct class_device *class_dev;
354 struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */ 361 struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */
@@ -440,22 +447,31 @@ extern struct usb_host_interface *usb_altnum_to_altsetting(
440 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 447 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
441 * high speed, and a different one if they are full or low speed. 448 * high speed, and a different one if they are full or low speed.
442 */ 449 */
443static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size) 450static inline int usb_make_path (struct usb_device *dev, char *buf,
451 size_t size)
444{ 452{
445 int actual; 453 int actual;
446 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath); 454 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name,
455 dev->devpath);
447 return (actual >= (int)size) ? -1 : actual; 456 return (actual >= (int)size) ? -1 : actual;
448} 457}
449 458
450/*-------------------------------------------------------------------------*/ 459/*-------------------------------------------------------------------------*/
451 460
452#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) 461#define USB_DEVICE_ID_MATCH_DEVICE \
453#define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI) 462 (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
454#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE) 463#define USB_DEVICE_ID_MATCH_DEV_RANGE \
464 (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
465#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
466 (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
455#define USB_DEVICE_ID_MATCH_DEV_INFO \ 467#define USB_DEVICE_ID_MATCH_DEV_INFO \
456 (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL) 468 (USB_DEVICE_ID_MATCH_DEV_CLASS | \
469 USB_DEVICE_ID_MATCH_DEV_SUBCLASS | \
470 USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
457#define USB_DEVICE_ID_MATCH_INT_INFO \ 471#define USB_DEVICE_ID_MATCH_INT_INFO \
458 (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL) 472 (USB_DEVICE_ID_MATCH_INT_CLASS | \
473 USB_DEVICE_ID_MATCH_INT_SUBCLASS | \
474 USB_DEVICE_ID_MATCH_INT_PROTOCOL)
459 475
460/** 476/**
461 * USB_DEVICE - macro used to describe a specific usb device 477 * USB_DEVICE - macro used to describe a specific usb device
@@ -466,9 +482,11 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
466 * specific device. 482 * specific device.
467 */ 483 */
468#define USB_DEVICE(vend,prod) \ 484#define USB_DEVICE(vend,prod) \
469 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod) 485 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \
486 .idProduct = (prod)
470/** 487/**
471 * USB_DEVICE_VER - macro used to describe a specific usb device with a version range 488 * USB_DEVICE_VER - macro used to describe a specific usb device with a
489 * version range
472 * @vend: the 16 bit USB Vendor ID 490 * @vend: the 16 bit USB Vendor ID
473 * @prod: the 16 bit USB Product ID 491 * @prod: the 16 bit USB Product ID
474 * @lo: the bcdDevice_lo value 492 * @lo: the bcdDevice_lo value
@@ -478,7 +496,9 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
478 * specific device, with a version range. 496 * specific device, with a version range.
479 */ 497 */
480#define USB_DEVICE_VER(vend,prod,lo,hi) \ 498#define USB_DEVICE_VER(vend,prod,lo,hi) \
481 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, .idVendor = (vend), .idProduct = (prod), .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 499 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
500 .idVendor = (vend), .idProduct = (prod), \
501 .bcdDevice_lo = (lo), .bcdDevice_hi = (hi)
482 502
483/** 503/**
484 * USB_DEVICE_INFO - macro used to describe a class of usb devices 504 * USB_DEVICE_INFO - macro used to describe a class of usb devices
@@ -490,7 +510,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
490 * specific class of devices. 510 * specific class of devices.
491 */ 511 */
492#define USB_DEVICE_INFO(cl,sc,pr) \ 512#define USB_DEVICE_INFO(cl,sc,pr) \
493 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 513 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \
514 .bDeviceSubClass = (sc), .bDeviceProtocol = (pr)
494 515
495/** 516/**
496 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 517 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
@@ -502,9 +523,10 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
502 * specific class of interfaces. 523 * specific class of interfaces.
503 */ 524 */
504#define USB_INTERFACE_INFO(cl,sc,pr) \ 525#define USB_INTERFACE_INFO(cl,sc,pr) \
505 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 526 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \
527 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr)
506 528
507/* -------------------------------------------------------------------------- */ 529/* ----------------------------------------------------------------------- */
508 530
509/** 531/**
510 * struct usb_driver - identifies USB driver to usbcore 532 * struct usb_driver - identifies USB driver to usbcore
@@ -557,7 +579,8 @@ struct usb_driver {
557 579
558 void (*disconnect) (struct usb_interface *intf); 580 void (*disconnect) (struct usb_interface *intf);
559 581
560 int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); 582 int (*ioctl) (struct usb_interface *intf, unsigned int code,
583 void *buf);
561 584
562 int (*suspend) (struct usb_interface *intf, pm_message_t message); 585 int (*suspend) (struct usb_interface *intf, pm_message_t message);
563 int (*resume) (struct usb_interface *intf); 586 int (*resume) (struct usb_interface *intf);
@@ -572,10 +595,8 @@ extern struct bus_type usb_bus_type;
572 595
573/** 596/**
574 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number 597 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
575 * @name: devfs name for this driver. Will also be used by the driver 598 * @name: the usb class device name for this driver. Will show up in sysfs.
576 * class code to create a usb class device.
577 * @fops: pointer to the struct file_operations of this driver. 599 * @fops: pointer to the struct file_operations of this driver.
578 * @mode: the mode for the devfs file to be created for this driver.
579 * @minor_base: the start of the minor range for this driver. 600 * @minor_base: the start of the minor range for this driver.
580 * 601 *
581 * This structure is used for the usb_register_dev() and 602 * This structure is used for the usb_register_dev() and
@@ -585,8 +606,7 @@ extern struct bus_type usb_bus_type;
585struct usb_class_driver { 606struct usb_class_driver {
586 char *name; 607 char *name;
587 struct file_operations *fops; 608 struct file_operations *fops;
588 mode_t mode; 609 int minor_base;
589 int minor_base;
590}; 610};
591 611
592/* 612/*
@@ -603,7 +623,7 @@ extern void usb_deregister_dev(struct usb_interface *intf,
603 623
604extern int usb_disabled(void); 624extern int usb_disabled(void);
605 625
606/* -------------------------------------------------------------------------- */ 626/* ----------------------------------------------------------------------- */
607 627
608/* 628/*
609 * URB support, for asynchronous request completions 629 * URB support, for asynchronous request completions
@@ -613,12 +633,14 @@ extern int usb_disabled(void);
613 * urb->transfer_flags: 633 * urb->transfer_flags:
614 */ 634 */
615#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ 635#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
616#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */ 636#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
637 * ignored */
617#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ 638#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
618#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */ 639#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */
619#define URB_NO_FSBR 0x0020 /* UHCI-specific */ 640#define URB_NO_FSBR 0x0020 /* UHCI-specific */
620#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */ 641#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
621#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ 642#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
643 * needed */
622 644
623struct usb_iso_packet_descriptor { 645struct usb_iso_packet_descriptor {
624 unsigned int offset; 646 unsigned int offset;
@@ -806,7 +828,8 @@ struct urb
806 u8 reject; /* submissions will fail */ 828 u8 reject; /* submissions will fail */
807 829
808 /* public, documented fields in the urb that can be used by drivers */ 830 /* public, documented fields in the urb that can be used by drivers */
809 struct list_head urb_list; /* list head for use by the urb owner */ 831 struct list_head urb_list; /* list head for use by the urb's
832 * current owner */
810 struct usb_device *dev; /* (in) pointer to associated device */ 833 struct usb_device *dev; /* (in) pointer to associated device */
811 unsigned int pipe; /* (in) pipe information */ 834 unsigned int pipe; /* (in) pipe information */
812 int status; /* (return) non-ISO status */ 835 int status; /* (return) non-ISO status */
@@ -819,14 +842,16 @@ struct urb
819 dma_addr_t setup_dma; /* (in) dma addr for setup_packet */ 842 dma_addr_t setup_dma; /* (in) dma addr for setup_packet */
820 int start_frame; /* (modify) start frame (ISO) */ 843 int start_frame; /* (modify) start frame (ISO) */
821 int number_of_packets; /* (in) number of ISO packets */ 844 int number_of_packets; /* (in) number of ISO packets */
822 int interval; /* (modify) transfer interval (INT/ISO) */ 845 int interval; /* (modify) transfer interval
846 * (INT/ISO) */
823 int error_count; /* (return) number of ISO errors */ 847 int error_count; /* (return) number of ISO errors */
824 void *context; /* (in) context for completion */ 848 void *context; /* (in) context for completion */
825 usb_complete_t complete; /* (in) completion routine */ 849 usb_complete_t complete; /* (in) completion routine */
826 struct usb_iso_packet_descriptor iso_frame_desc[0]; /* (in) ISO ONLY */ 850 struct usb_iso_packet_descriptor iso_frame_desc[0];
851 /* (in) ISO ONLY */
827}; 852};
828 853
829/* -------------------------------------------------------------------------- */ 854/* ----------------------------------------------------------------------- */
830 855
831/** 856/**
832 * usb_fill_control_urb - initializes a control urb 857 * usb_fill_control_urb - initializes a control urb
@@ -933,17 +958,17 @@ static inline void usb_fill_int_urb (struct urb *urb,
933} 958}
934 959
935extern void usb_init_urb(struct urb *urb); 960extern void usb_init_urb(struct urb *urb);
936extern struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags); 961extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
937extern void usb_free_urb(struct urb *urb); 962extern void usb_free_urb(struct urb *urb);
938#define usb_put_urb usb_free_urb 963#define usb_put_urb usb_free_urb
939extern struct urb *usb_get_urb(struct urb *urb); 964extern struct urb *usb_get_urb(struct urb *urb);
940extern int usb_submit_urb(struct urb *urb, unsigned mem_flags); 965extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
941extern int usb_unlink_urb(struct urb *urb); 966extern int usb_unlink_urb(struct urb *urb);
942extern void usb_kill_urb(struct urb *urb); 967extern void usb_kill_urb(struct urb *urb);
943 968
944#define HAVE_USB_BUFFERS 969#define HAVE_USB_BUFFERS
945void *usb_buffer_alloc (struct usb_device *dev, size_t size, 970void *usb_buffer_alloc (struct usb_device *dev, size_t size,
946 unsigned mem_flags, dma_addr_t *dma); 971 gfp_t mem_flags, dma_addr_t *dma);
947void usb_buffer_free (struct usb_device *dev, size_t size, 972void usb_buffer_free (struct usb_device *dev, size_t size,
948 void *addr, dma_addr_t dma); 973 void *addr, dma_addr_t dma);
949 974
@@ -974,11 +999,6 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
974 void *data, int len, int *actual_length, 999 void *data, int len, int *actual_length,
975 int timeout); 1000 int timeout);
976 1001
977/* selective suspend/resume */
978extern int usb_suspend_device(struct usb_device *dev, pm_message_t message);
979extern int usb_resume_device(struct usb_device *dev);
980
981
982/* wrappers around usb_control_msg() for the most common standard requests */ 1002/* wrappers around usb_control_msg() for the most common standard requests */
983extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, 1003extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
984 unsigned char descindex, void *buf, int size); 1004 unsigned char descindex, void *buf, int size);
@@ -1050,13 +1070,13 @@ int usb_sg_init (
1050 struct scatterlist *sg, 1070 struct scatterlist *sg,
1051 int nents, 1071 int nents,
1052 size_t length, 1072 size_t length,
1053 unsigned mem_flags 1073 gfp_t mem_flags
1054); 1074);
1055void usb_sg_cancel (struct usb_sg_request *io); 1075void usb_sg_cancel (struct usb_sg_request *io);
1056void usb_sg_wait (struct usb_sg_request *io); 1076void usb_sg_wait (struct usb_sg_request *io);
1057 1077
1058 1078
1059/* -------------------------------------------------------------------------- */ 1079/* ----------------------------------------------------------------------- */
1060 1080
1061/* 1081/*
1062 * For various legacy reasons, Linux has a small cookie that's paired with 1082 * For various legacy reasons, Linux has a small cookie that's paired with
@@ -1097,23 +1117,34 @@ void usb_sg_wait (struct usb_sg_request *io);
1097/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ 1117/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
1098#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) 1118#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
1099#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) 1119#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
1100#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep))) 1120#define usb_settoggle(dev, ep, out, bit) \
1121 ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \
1122 ((bit) << (ep)))
1101 1123
1102 1124
1103static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint) 1125static inline unsigned int __create_pipe(struct usb_device *dev,
1126 unsigned int endpoint)
1104{ 1127{
1105 return (dev->devnum << 8) | (endpoint << 15); 1128 return (dev->devnum << 8) | (endpoint << 15);
1106} 1129}
1107 1130
1108/* Create various pipes... */ 1131/* Create various pipes... */
1109#define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1132#define usb_sndctrlpipe(dev,endpoint) \
1110#define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1133 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint))
1111#define usb_sndisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1134#define usb_rcvctrlpipe(dev,endpoint) \
1112#define usb_rcvisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1135 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1113#define usb_sndbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1136#define usb_sndisocpipe(dev,endpoint) \
1114#define usb_rcvbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1137 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint))
1115#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1138#define usb_rcvisocpipe(dev,endpoint) \
1116#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1139 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1140#define usb_sndbulkpipe(dev,endpoint) \
1141 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint))
1142#define usb_rcvbulkpipe(dev,endpoint) \
1143 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1144#define usb_sndintpipe(dev,endpoint) \
1145 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint))
1146#define usb_rcvintpipe(dev,endpoint) \
1147 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1117 1148
1118/*-------------------------------------------------------------------------*/ 1149/*-------------------------------------------------------------------------*/
1119 1150
@@ -1137,17 +1168,29 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
1137 return le16_to_cpu(ep->desc.wMaxPacketSize); 1168 return le16_to_cpu(ep->desc.wMaxPacketSize);
1138} 1169}
1139 1170
1140/* -------------------------------------------------------------------------- */ 1171/* ----------------------------------------------------------------------- */
1172
1173/* Events from the usb core */
1174#define USB_DEVICE_ADD 0x0001
1175#define USB_DEVICE_REMOVE 0x0002
1176#define USB_BUS_ADD 0x0003
1177#define USB_BUS_REMOVE 0x0004
1178extern void usb_register_notify(struct notifier_block *nb);
1179extern void usb_unregister_notify(struct notifier_block *nb);
1141 1180
1142#ifdef DEBUG 1181#ifdef DEBUG
1143#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg) 1182#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \
1183 __FILE__ , ## arg)
1144#else 1184#else
1145#define dbg(format, arg...) do {} while (0) 1185#define dbg(format, arg...) do {} while (0)
1146#endif 1186#endif
1147 1187
1148#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg) 1188#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
1149#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg) 1189 __FILE__ , ## arg)
1150#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg) 1190#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \
1191 __FILE__ , ## arg)
1192#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \
1193 __FILE__ , ## arg)
1151 1194
1152 1195
1153#endif /* __KERNEL__ */ 1196#endif /* __KERNEL__ */
diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
index 71e608607324..ff81117eb733 100644
--- a/include/linux/usb_gadget.h
+++ b/include/linux/usb_gadget.h
@@ -107,18 +107,18 @@ struct usb_ep_ops {
107 int (*disable) (struct usb_ep *ep); 107 int (*disable) (struct usb_ep *ep);
108 108
109 struct usb_request *(*alloc_request) (struct usb_ep *ep, 109 struct usb_request *(*alloc_request) (struct usb_ep *ep,
110 unsigned gfp_flags); 110 gfp_t gfp_flags);
111 void (*free_request) (struct usb_ep *ep, struct usb_request *req); 111 void (*free_request) (struct usb_ep *ep, struct usb_request *req);
112 112
113 void *(*alloc_buffer) (struct usb_ep *ep, unsigned bytes, 113 void *(*alloc_buffer) (struct usb_ep *ep, unsigned bytes,
114 dma_addr_t *dma, unsigned gfp_flags); 114 dma_addr_t *dma, gfp_t gfp_flags);
115 void (*free_buffer) (struct usb_ep *ep, void *buf, dma_addr_t dma, 115 void (*free_buffer) (struct usb_ep *ep, void *buf, dma_addr_t dma,
116 unsigned bytes); 116 unsigned bytes);
117 // NOTE: on 2.6, drivers may also use dma_map() and 117 // NOTE: on 2.6, drivers may also use dma_map() and
118 // dma_sync_single_*() to directly manage dma overhead. 118 // dma_sync_single_*() to directly manage dma overhead.
119 119
120 int (*queue) (struct usb_ep *ep, struct usb_request *req, 120 int (*queue) (struct usb_ep *ep, struct usb_request *req,
121 unsigned gfp_flags); 121 gfp_t gfp_flags);
122 int (*dequeue) (struct usb_ep *ep, struct usb_request *req); 122 int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
123 123
124 int (*set_halt) (struct usb_ep *ep, int value); 124 int (*set_halt) (struct usb_ep *ep, int value);
@@ -214,7 +214,7 @@ usb_ep_disable (struct usb_ep *ep)
214 * Returns the request, or null if one could not be allocated. 214 * Returns the request, or null if one could not be allocated.
215 */ 215 */
216static inline struct usb_request * 216static inline struct usb_request *
217usb_ep_alloc_request (struct usb_ep *ep, unsigned gfp_flags) 217usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
218{ 218{
219 return ep->ops->alloc_request (ep, gfp_flags); 219 return ep->ops->alloc_request (ep, gfp_flags);
220} 220}
@@ -254,7 +254,7 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
254 */ 254 */
255static inline void * 255static inline void *
256usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma, 256usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma,
257 unsigned gfp_flags) 257 gfp_t gfp_flags)
258{ 258{
259 return ep->ops->alloc_buffer (ep, len, dma, gfp_flags); 259 return ep->ops->alloc_buffer (ep, len, dma, gfp_flags);
260} 260}
@@ -330,7 +330,7 @@ usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len)
330 * reported when the usb peripheral is disconnected. 330 * reported when the usb peripheral is disconnected.
331 */ 331 */
332static inline int 332static inline int
333usb_ep_queue (struct usb_ep *ep, struct usb_request *req, unsigned gfp_flags) 333usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
334{ 334{
335 return ep->ops->queue (ep, req, gfp_flags); 335 return ep->ops->queue (ep, req, gfp_flags);
336} 336}
diff --git a/include/linux/usb_otg.h b/include/linux/usb_otg.h
index c6683146e9b0..f827f6e203c2 100644
--- a/include/linux/usb_otg.h
+++ b/include/linux/usb_otg.h
@@ -63,6 +63,10 @@ struct otg_transceiver {
63 int (*set_power)(struct otg_transceiver *otg, 63 int (*set_power)(struct otg_transceiver *otg,
64 unsigned mA); 64 unsigned mA);
65 65
66 /* for non-OTG B devices: set transceiver into suspend mode */
67 int (*set_suspend)(struct otg_transceiver *otg,
68 int suspend);
69
66 /* for B devices only: start session with A-Host */ 70 /* for B devices only: start session with A-Host */
67 int (*start_srp)(struct otg_transceiver *otg); 71 int (*start_srp)(struct otg_transceiver *otg);
68 72
@@ -108,6 +112,15 @@ otg_set_power(struct otg_transceiver *otg, unsigned mA)
108} 112}
109 113
110static inline int 114static inline int
115otg_set_suspend(struct otg_transceiver *otg, int suspend)
116{
117 if (otg->set_suspend != NULL)
118 return otg->set_suspend(otg, suspend);
119 else
120 return 0;
121}
122
123static inline int
111otg_start_srp(struct otg_transceiver *otg) 124otg_start_srp(struct otg_transceiver *otg)
112{ 125{
113 return otg->start_srp(otg); 126 return otg->start_srp(otg);
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 9facf733800c..8859f0b41543 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -140,6 +140,12 @@ struct usbdevfs_urb32 {
140 compat_caddr_t usercontext; /* unused */ 140 compat_caddr_t usercontext; /* unused */
141 struct usbdevfs_iso_packet_desc iso_frame_desc[0]; 141 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
142}; 142};
143
144struct usbdevfs_ioctl32 {
145 s32 ifno;
146 s32 ioctl_code;
147 compat_caddr_t data;
148};
143#endif 149#endif
144 150
145#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer) 151#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
@@ -160,6 +166,7 @@ struct usbdevfs_urb32 {
160#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int) 166#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
161#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo) 167#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
162#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl) 168#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
169#define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
163#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo) 170#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
164#define USBDEVFS_RESET _IO('U', 20) 171#define USBDEVFS_RESET _IO('U', 20)
165#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int) 172#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
diff --git a/include/linux/wanpipe.h b/include/linux/wanpipe.h
index 167d956c492b..dae9860091dd 100644
--- a/include/linux/wanpipe.h
+++ b/include/linux/wanpipe.h
@@ -265,15 +265,6 @@ typedef struct {
265#include <linux/tty_driver.h> 265#include <linux/tty_driver.h>
266#include <linux/tty_flip.h> 266#include <linux/tty_flip.h>
267 267
268
269#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
270#define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
271 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
272#define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
273 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
274 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
275
276
277/****** Data Structures *****************************************************/ 268/****** Data Structures *****************************************************/
278 269
279/* Adapter Data Space. 270/* Adapter Data Space.
diff --git a/include/linux/x1205.h b/include/linux/x1205.h
new file mode 100644
index 000000000000..64fd3af894a5
--- /dev/null
+++ b/include/linux/x1205.h
@@ -0,0 +1,31 @@
1/*
2 * x1205.h - defines for drivers/i2c/chips/x1205.c
3 * Copyright 2004 Karen Spearel
4 * Copyright 2005 Alessandro Zummo
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __LINUX_X1205_H__
13#define __LINUX_X1205_H__
14
15/* commands */
16
17#define X1205_CMD_GETDATETIME 0
18#define X1205_CMD_SETTIME 1
19#define X1205_CMD_SETDATETIME 2
20#define X1205_CMD_GETALARM 3
21#define X1205_CMD_SETALARM 4
22#define X1205_CMD_GETDTRIM 5
23#define X1205_CMD_SETDTRIM 6
24#define X1205_CMD_GETATRIM 7
25#define X1205_CMD_SETATRIM 8
26
27extern int x1205_do_command(unsigned int cmd, void *arg);
28extern int x1205_direct_attach(int adapter_id,
29 struct i2c_client_address_data *address_data);
30
31#endif /* __LINUX_X1205_H__ */
diff --git a/include/media/ovcamchip.h b/include/media/ovcamchip.h
index cb7c0aa96f22..8138983adced 100644
--- a/include/media/ovcamchip.h
+++ b/include/media/ovcamchip.h
@@ -17,20 +17,6 @@
17#include <linux/videodev.h> 17#include <linux/videodev.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19 19
20/* Remove these once they are officially defined */
21#ifndef I2C_DRIVERID_OVCAMCHIP
22 #define I2C_DRIVERID_OVCAMCHIP 0xf00f
23#endif
24#ifndef I2C_HW_SMBUS_OV511
25 #define I2C_HW_SMBUS_OV511 0xfe
26#endif
27#ifndef I2C_HW_SMBUS_OV518
28 #define I2C_HW_SMBUS_OV518 0xff
29#endif
30#ifndef I2C_HW_SMBUS_OVFX2
31 #define I2C_HW_SMBUS_OVFX2 0xfd
32#endif
33
34/* --------------------------------- */ 20/* --------------------------------- */
35/* ENUMERATIONS */ 21/* ENUMERATIONS */
36/* --------------------------------- */ 22/* --------------------------------- */
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 210458624840..e42d728b1620 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -171,4 +171,10 @@ static inline int skb_frags_no(struct sk_buff *skb)
171 171
172int bt_err(__u16 code); 172int bt_err(__u16 code);
173 173
174extern int hci_sock_init(void);
175extern int hci_sock_cleanup(void);
176
177extern int bt_sysfs_init(void);
178extern void bt_sysfs_cleanup(void);
179
174#endif /* __BLUETOOTH_H */ 180#endif /* __BLUETOOTH_H */
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index fbe557f7ea1d..e656be7c001a 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -275,9 +275,6 @@ static inline void rfcomm_session_hold(struct rfcomm_session *s)
275 atomic_inc(&s->refcnt); 275 atomic_inc(&s->refcnt);
276} 276}
277 277
278/* ---- RFCOMM chechsum ---- */
279extern u8 rfcomm_crc_table[];
280
281/* ---- RFCOMM sockets ---- */ 278/* ---- RFCOMM sockets ---- */
282struct sockaddr_rc { 279struct sockaddr_rc {
283 sa_family_t rc_family; 280 sa_family_t rc_family;
diff --git a/include/net/dst.h b/include/net/dst.h
index 4a056a682435..6c196a5baf24 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -94,7 +94,6 @@ struct dst_ops
94 struct dst_entry * (*negative_advice)(struct dst_entry *); 94 struct dst_entry * (*negative_advice)(struct dst_entry *);
95 void (*link_failure)(struct sk_buff *); 95 void (*link_failure)(struct sk_buff *);
96 void (*update_pmtu)(struct dst_entry *dst, u32 mtu); 96 void (*update_pmtu)(struct dst_entry *dst, u32 mtu);
97 int (*get_mss)(struct dst_entry *dst, u32 mtu);
98 int entry_size; 97 int entry_size;
99 98
100 atomic_t entries; 99 atomic_t entries;
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index dc36b1be6745..5e38dca1d082 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -11,19 +11,26 @@
11 * 11 *
12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos 12 * Adaption to a generic IEEE 802.11 stack by James Ketrenos
13 * <jketreno@linux.intel.com> 13 * <jketreno@linux.intel.com>
14 * Copyright (c) 2004, Intel Corporation 14 * Copyright (c) 2004-2005, Intel Corporation
15 * 15 *
16 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as 17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation. See README and COPYING for 18 * published by the Free Software Foundation. See README and COPYING for
19 * more details. 19 * more details.
20 *
21 * API Version History
22 * 1.0.x -- Initial version
23 * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs,
24 * various structure changes, and crypto API init method
20 */ 25 */
21#ifndef IEEE80211_H 26#ifndef IEEE80211_H
22#define IEEE80211_H 27#define IEEE80211_H
23#include <linux/if_ether.h> /* ETH_ALEN */ 28#include <linux/if_ether.h> /* ETH_ALEN */
24#include <linux/kernel.h> /* ARRAY_SIZE */ 29#include <linux/kernel.h> /* ARRAY_SIZE */
25#include <linux/wireless.h> 30#include <linux/wireless.h>
26 31
32#define IEEE80211_VERSION "git-1.1.6"
33
27#define IEEE80211_DATA_LEN 2304 34#define IEEE80211_DATA_LEN 2304
28/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 35/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
29 6.2.1.1.2. 36 6.2.1.1.2.
@@ -33,34 +40,13 @@
33 represents the 2304 bytes of real data, plus a possible 8 bytes of 40 represents the 2304 bytes of real data, plus a possible 8 bytes of
34 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 41 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
35 42
36
37#define IEEE80211_HLEN 30
38#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
39
40struct ieee80211_hdr {
41 __le16 frame_ctl;
42 __le16 duration_id;
43 u8 addr1[ETH_ALEN];
44 u8 addr2[ETH_ALEN];
45 u8 addr3[ETH_ALEN];
46 __le16 seq_ctl;
47 u8 addr4[ETH_ALEN];
48} __attribute__ ((packed));
49
50struct ieee80211_hdr_3addr {
51 __le16 frame_ctl;
52 __le16 duration_id;
53 u8 addr1[ETH_ALEN];
54 u8 addr2[ETH_ALEN];
55 u8 addr3[ETH_ALEN];
56 __le16 seq_ctl;
57} __attribute__ ((packed));
58
59#define IEEE80211_1ADDR_LEN 10 43#define IEEE80211_1ADDR_LEN 10
60#define IEEE80211_2ADDR_LEN 16 44#define IEEE80211_2ADDR_LEN 16
61#define IEEE80211_3ADDR_LEN 24 45#define IEEE80211_3ADDR_LEN 24
62#define IEEE80211_4ADDR_LEN 30 46#define IEEE80211_4ADDR_LEN 30
63#define IEEE80211_FCS_LEN 4 47#define IEEE80211_FCS_LEN 4
48#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
49#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
64 50
65#define MIN_FRAG_THRESHOLD 256U 51#define MIN_FRAG_THRESHOLD 256U
66#define MAX_FRAG_THRESHOLD 2346U 52#define MAX_FRAG_THRESHOLD 2346U
@@ -113,11 +99,11 @@ struct ieee80211_hdr_3addr {
113#define IEEE80211_STYPE_CFACK 0x0050 99#define IEEE80211_STYPE_CFACK 0x0050
114#define IEEE80211_STYPE_CFPOLL 0x0060 100#define IEEE80211_STYPE_CFPOLL 0x0060
115#define IEEE80211_STYPE_CFACKPOLL 0x0070 101#define IEEE80211_STYPE_CFACKPOLL 0x0070
102#define IEEE80211_STYPE_QOS_DATA 0x0080
116 103
117#define IEEE80211_SCTL_FRAG 0x000F 104#define IEEE80211_SCTL_FRAG 0x000F
118#define IEEE80211_SCTL_SEQ 0xFFF0 105#define IEEE80211_SCTL_SEQ 0xFFF0
119 106
120
121/* debug macros */ 107/* debug macros */
122 108
123#ifdef CONFIG_IEEE80211_DEBUG 109#ifdef CONFIG_IEEE80211_DEBUG
@@ -128,8 +114,7 @@ do { if (ieee80211_debug_level & (level)) \
128 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 114 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
129#else 115#else
130#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 116#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
131#endif /* CONFIG_IEEE80211_DEBUG */ 117#endif /* CONFIG_IEEE80211_DEBUG */
132
133 118
134/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ 119/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
135 120
@@ -140,7 +125,6 @@ do { if (ieee80211_debug_level & (level)) \
140 * messages. It should never be used for passing essid to user space. */ 125 * messages. It should never be used for passing essid to user space. */
141const char *escape_essid(const char *essid, u8 essid_len); 126const char *escape_essid(const char *essid, u8 essid_len);
142 127
143
144/* 128/*
145 * To use the debug system: 129 * To use the debug system:
146 * 130 *
@@ -177,6 +161,7 @@ const char *escape_essid(const char *essid, u8 essid_len);
177 161
178#define IEEE80211_DL_TX (1<<8) 162#define IEEE80211_DL_TX (1<<8)
179#define IEEE80211_DL_RX (1<<9) 163#define IEEE80211_DL_RX (1<<9)
164#define IEEE80211_DL_QOS (1<<31)
180 165
181#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) 166#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
182#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) 167#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
@@ -190,9 +175,10 @@ const char *escape_essid(const char *essid, u8 essid_len);
190#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) 175#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
191#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) 176#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
192#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) 177#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
178#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
193#include <linux/netdevice.h> 179#include <linux/netdevice.h>
194#include <linux/wireless.h> 180#include <linux/wireless.h>
195#include <linux/if_arp.h> /* ARPHRD_ETHER */ 181#include <linux/if_arp.h> /* ARPHRD_ETHER */
196 182
197#ifndef WIRELESS_SPY 183#ifndef WIRELESS_SPY
198#define WIRELESS_SPY /* enable iwspy support */ 184#define WIRELESS_SPY /* enable iwspy support */
@@ -200,10 +186,10 @@ const char *escape_essid(const char *essid, u8 essid_len);
200#include <net/iw_handler.h> /* new driver API */ 186#include <net/iw_handler.h> /* new driver API */
201 187
202#ifndef ETH_P_PAE 188#ifndef ETH_P_PAE
203#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ 189#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
204#endif /* ETH_P_PAE */ 190#endif /* ETH_P_PAE */
205 191
206#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ 192#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
207 193
208#ifndef ETH_P_80211_RAW 194#ifndef ETH_P_80211_RAW
209#define ETH_P_80211_RAW (ETH_P_ECONET + 1) 195#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
@@ -215,10 +201,10 @@ const char *escape_essid(const char *essid, u8 essid_len);
215 201
216struct ieee80211_snap_hdr { 202struct ieee80211_snap_hdr {
217 203
218 u8 dsap; /* always 0xAA */ 204 u8 dsap; /* always 0xAA */
219 u8 ssap; /* always 0xAA */ 205 u8 ssap; /* always 0xAA */
220 u8 ctrl; /* always 0x03 */ 206 u8 ctrl; /* always 0x03 */
221 u8 oui[P80211_OUI_LEN]; /* organizational universal id */ 207 u8 oui[P80211_OUI_LEN]; /* organizational universal id */
222 208
223} __attribute__ ((packed)); 209} __attribute__ ((packed));
224 210
@@ -246,8 +232,9 @@ struct ieee80211_snap_hdr {
246#define WLAN_CAPABILITY_PBCC (1<<6) 232#define WLAN_CAPABILITY_PBCC (1<<6)
247#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) 233#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
248#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) 234#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
235#define WLAN_CAPABILITY_QOS (1<<9)
249#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) 236#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
250#define WLAN_CAPABILITY_OSSS_OFDM (1<<13) 237#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
251 238
252/* Status codes */ 239/* Status codes */
253enum ieee80211_statuscode { 240enum ieee80211_statuscode {
@@ -312,14 +299,12 @@ enum ieee80211_reasoncode {
312 WLAN_REASON_CIPHER_SUITE_REJECTED = 24, 299 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
313}; 300};
314 301
315
316#define IEEE80211_STATMASK_SIGNAL (1<<0) 302#define IEEE80211_STATMASK_SIGNAL (1<<0)
317#define IEEE80211_STATMASK_RSSI (1<<1) 303#define IEEE80211_STATMASK_RSSI (1<<1)
318#define IEEE80211_STATMASK_NOISE (1<<2) 304#define IEEE80211_STATMASK_NOISE (1<<2)
319#define IEEE80211_STATMASK_RATE (1<<3) 305#define IEEE80211_STATMASK_RATE (1<<3)
320#define IEEE80211_STATMASK_WEMASK 0x7 306#define IEEE80211_STATMASK_WEMASK 0x7
321 307
322
323#define IEEE80211_CCK_MODULATION (1<<0) 308#define IEEE80211_CCK_MODULATION (1<<0)
324#define IEEE80211_OFDM_MODULATION (1<<1) 309#define IEEE80211_OFDM_MODULATION (1<<1)
325 310
@@ -377,9 +362,6 @@ enum ieee80211_reasoncode {
377#define IEEE80211_NUM_CCK_RATES 4 362#define IEEE80211_NUM_CCK_RATES 4
378#define IEEE80211_OFDM_SHIFT_MASK_A 4 363#define IEEE80211_OFDM_SHIFT_MASK_A 4
379 364
380
381
382
383/* NOTE: This data is for statistical purposes; not all hardware provides this 365/* NOTE: This data is for statistical purposes; not all hardware provides this
384 * information for frames received. Not setting these will not cause 366 * information for frames received. Not setting these will not cause
385 * any adverse affects. */ 367 * any adverse affects. */
@@ -388,7 +370,7 @@ struct ieee80211_rx_stats {
388 s8 rssi; 370 s8 rssi;
389 u8 signal; 371 u8 signal;
390 u8 noise; 372 u8 noise;
391 u16 rate; /* in 100 kbps */ 373 u16 rate; /* in 100 kbps */
392 u8 received_channel; 374 u8 received_channel;
393 u8 control; 375 u8 control;
394 u8 mask; 376 u8 mask;
@@ -439,38 +421,44 @@ struct ieee80211_device;
439 421
440#include "ieee80211_crypt.h" 422#include "ieee80211_crypt.h"
441 423
442#define SEC_KEY_1 (1<<0) 424#define SEC_KEY_1 (1<<0)
443#define SEC_KEY_2 (1<<1) 425#define SEC_KEY_2 (1<<1)
444#define SEC_KEY_3 (1<<2) 426#define SEC_KEY_3 (1<<2)
445#define SEC_KEY_4 (1<<3) 427#define SEC_KEY_4 (1<<3)
446#define SEC_ACTIVE_KEY (1<<4) 428#define SEC_ACTIVE_KEY (1<<4)
447#define SEC_AUTH_MODE (1<<5) 429#define SEC_AUTH_MODE (1<<5)
448#define SEC_UNICAST_GROUP (1<<6) 430#define SEC_UNICAST_GROUP (1<<6)
449#define SEC_LEVEL (1<<7) 431#define SEC_LEVEL (1<<7)
450#define SEC_ENABLED (1<<8) 432#define SEC_ENABLED (1<<8)
451 433#define SEC_ENCRYPT (1<<9)
452#define SEC_LEVEL_0 0 /* None */ 434
453#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ 435#define SEC_LEVEL_0 0 /* None */
454#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ 436#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
455#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ 437#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
456#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ 438#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
457 439#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
458#define WEP_KEYS 4 440
459#define WEP_KEY_LEN 13 441#define SEC_ALG_NONE 0
442#define SEC_ALG_WEP 1
443#define SEC_ALG_TKIP 2
444#define SEC_ALG_CCMP 3
445
446#define WEP_KEYS 4
447#define WEP_KEY_LEN 13
448#define SCM_KEY_LEN 32
449#define SCM_TEMPORAL_KEY_LENGTH 16
460 450
461struct ieee80211_security { 451struct ieee80211_security {
462 u16 active_key:2, 452 u16 active_key:2,
463 enabled:1, 453 enabled:1,
464 auth_mode:2, 454 auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1;
465 auth_algo:4, 455 u8 encode_alg[WEP_KEYS];
466 unicast_uses_group:1;
467 u8 key_sizes[WEP_KEYS]; 456 u8 key_sizes[WEP_KEYS];
468 u8 keys[WEP_KEYS][WEP_KEY_LEN]; 457 u8 keys[WEP_KEYS][SCM_KEY_LEN];
469 u8 level; 458 u8 level;
470 u16 flags; 459 u16 flags;
471} __attribute__ ((packed)); 460} __attribute__ ((packed));
472 461
473
474/* 462/*
475 463
476 802.11 data frame from AP 464 802.11 data frame from AP
@@ -494,7 +482,7 @@ enum ieee80211_mfie {
494 MFIE_TYPE_RATES = 1, 482 MFIE_TYPE_RATES = 1,
495 MFIE_TYPE_FH_SET = 2, 483 MFIE_TYPE_FH_SET = 2,
496 MFIE_TYPE_DS_SET = 3, 484 MFIE_TYPE_DS_SET = 3,
497 MFIE_TYPE_CF_SET = 4, 485 MFIE_TYPE_CF_SET = 4,
498 MFIE_TYPE_TIM = 5, 486 MFIE_TYPE_TIM = 5,
499 MFIE_TYPE_IBSS_SET = 6, 487 MFIE_TYPE_IBSS_SET = 6,
500 MFIE_TYPE_COUNTRY = 7, 488 MFIE_TYPE_COUNTRY = 7,
@@ -516,11 +504,75 @@ enum ieee80211_mfie {
516 MFIE_TYPE_RSN = 48, 504 MFIE_TYPE_RSN = 48,
517 MFIE_TYPE_RATES_EX = 50, 505 MFIE_TYPE_RATES_EX = 50,
518 MFIE_TYPE_GENERIC = 221, 506 MFIE_TYPE_GENERIC = 221,
507 MFIE_TYPE_QOS_PARAMETER = 222,
519}; 508};
520 509
521struct ieee80211_info_element_hdr { 510/* Minimal header; can be used for passing 802.11 frames with sufficient
522 u8 id; 511 * information to determine what type of underlying data type is actually
523 u8 len; 512 * stored in the data. */
513struct ieee80211_hdr {
514 __le16 frame_ctl;
515 __le16 duration_id;
516 u8 payload[0];
517} __attribute__ ((packed));
518
519struct ieee80211_hdr_1addr {
520 __le16 frame_ctl;
521 __le16 duration_id;
522 u8 addr1[ETH_ALEN];
523 u8 payload[0];
524} __attribute__ ((packed));
525
526struct ieee80211_hdr_2addr {
527 __le16 frame_ctl;
528 __le16 duration_id;
529 u8 addr1[ETH_ALEN];
530 u8 addr2[ETH_ALEN];
531 u8 payload[0];
532} __attribute__ ((packed));
533
534struct ieee80211_hdr_3addr {
535 __le16 frame_ctl;
536 __le16 duration_id;
537 u8 addr1[ETH_ALEN];
538 u8 addr2[ETH_ALEN];
539 u8 addr3[ETH_ALEN];
540 __le16 seq_ctl;
541 u8 payload[0];
542} __attribute__ ((packed));
543
544struct ieee80211_hdr_4addr {
545 __le16 frame_ctl;
546 __le16 duration_id;
547 u8 addr1[ETH_ALEN];
548 u8 addr2[ETH_ALEN];
549 u8 addr3[ETH_ALEN];
550 __le16 seq_ctl;
551 u8 addr4[ETH_ALEN];
552 u8 payload[0];
553} __attribute__ ((packed));
554
555struct ieee80211_hdr_3addrqos {
556 __le16 frame_ctl;
557 __le16 duration_id;
558 u8 addr1[ETH_ALEN];
559 u8 addr2[ETH_ALEN];
560 u8 addr3[ETH_ALEN];
561 __le16 seq_ctl;
562 u8 payload[0];
563 __le16 qos_ctl;
564} __attribute__ ((packed));
565
566struct ieee80211_hdr_4addrqos {
567 __le16 frame_ctl;
568 __le16 duration_id;
569 u8 addr1[ETH_ALEN];
570 u8 addr2[ETH_ALEN];
571 u8 addr3[ETH_ALEN];
572 __le16 seq_ctl;
573 u8 addr4[ETH_ALEN];
574 u8 payload[0];
575 __le16 qos_ctl;
524} __attribute__ ((packed)); 576} __attribute__ ((packed));
525 577
526struct ieee80211_info_element { 578struct ieee80211_info_element {
@@ -546,49 +598,77 @@ struct ieee80211_info_element {
546 u16 status; 598 u16 status;
547*/ 599*/
548 600
549struct ieee80211_authentication { 601struct ieee80211_auth {
550 struct ieee80211_hdr_3addr header; 602 struct ieee80211_hdr_3addr header;
551 __le16 algorithm; 603 __le16 algorithm;
552 __le16 transaction; 604 __le16 transaction;
553 __le16 status; 605 __le16 status;
554 struct ieee80211_info_element info_element; 606 /* challenge */
607 struct ieee80211_info_element info_element[0];
555} __attribute__ ((packed)); 608} __attribute__ ((packed));
556 609
610struct ieee80211_disassoc {
611 struct ieee80211_hdr_3addr header;
612 __le16 reason;
613} __attribute__ ((packed));
614
615/* Alias deauth for disassoc */
616#define ieee80211_deauth ieee80211_disassoc
617
618struct ieee80211_probe_request {
619 struct ieee80211_hdr_3addr header;
620 /* SSID, supported rates */
621 struct ieee80211_info_element info_element[0];
622} __attribute__ ((packed));
557 623
558struct ieee80211_probe_response { 624struct ieee80211_probe_response {
559 struct ieee80211_hdr_3addr header; 625 struct ieee80211_hdr_3addr header;
560 u32 time_stamp[2]; 626 u32 time_stamp[2];
561 __le16 beacon_interval; 627 __le16 beacon_interval;
562 __le16 capability; 628 __le16 capability;
563 struct ieee80211_info_element info_element; 629 /* SSID, supported rates, FH params, DS params,
630 * CF params, IBSS params, TIM (if beacon), RSN */
631 struct ieee80211_info_element info_element[0];
564} __attribute__ ((packed)); 632} __attribute__ ((packed));
565 633
566struct ieee80211_assoc_request_frame { 634/* Alias beacon for probe_response */
635#define ieee80211_beacon ieee80211_probe_response
636
637struct ieee80211_assoc_request {
638 struct ieee80211_hdr_3addr header;
639 __le16 capability;
640 __le16 listen_interval;
641 /* SSID, supported rates, RSN */
642 struct ieee80211_info_element info_element[0];
643} __attribute__ ((packed));
644
645struct ieee80211_reassoc_request {
646 struct ieee80211_hdr_3addr header;
567 __le16 capability; 647 __le16 capability;
568 __le16 listen_interval; 648 __le16 listen_interval;
569 u8 current_ap[ETH_ALEN]; 649 u8 current_ap[ETH_ALEN];
570 struct ieee80211_info_element info_element; 650 struct ieee80211_info_element info_element[0];
571} __attribute__ ((packed)); 651} __attribute__ ((packed));
572 652
573struct ieee80211_assoc_response_frame { 653struct ieee80211_assoc_response {
574 struct ieee80211_hdr_3addr header; 654 struct ieee80211_hdr_3addr header;
575 __le16 capability; 655 __le16 capability;
576 __le16 status; 656 __le16 status;
577 __le16 aid; 657 __le16 aid;
578 struct ieee80211_info_element info_element; /* supported rates */ 658 /* supported rates */
659 struct ieee80211_info_element info_element[0];
579} __attribute__ ((packed)); 660} __attribute__ ((packed));
580 661
581
582struct ieee80211_txb { 662struct ieee80211_txb {
583 u8 nr_frags; 663 u8 nr_frags;
584 u8 encrypted; 664 u8 encrypted;
585 u16 reserved; 665 u8 rts_included;
586 u16 frag_size; 666 u8 reserved;
587 u16 payload_size; 667 __le16 frag_size;
668 __le16 payload_size;
588 struct sk_buff *fragments[0]; 669 struct sk_buff *fragments[0];
589}; 670};
590 671
591
592/* SWEEP TABLE ENTRIES NUMBER */ 672/* SWEEP TABLE ENTRIES NUMBER */
593#define MAX_SWEEP_TAB_ENTRIES 42 673#define MAX_SWEEP_TAB_ENTRIES 42
594#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 674#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
@@ -604,9 +684,68 @@ struct ieee80211_txb {
604 684
605#define MAX_WPA_IE_LEN 64 685#define MAX_WPA_IE_LEN 64
606 686
607#define NETWORK_EMPTY_ESSID (1<<0) 687#define NETWORK_EMPTY_ESSID (1<<0)
608#define NETWORK_HAS_OFDM (1<<1) 688#define NETWORK_HAS_OFDM (1<<1)
609#define NETWORK_HAS_CCK (1<<2) 689#define NETWORK_HAS_CCK (1<<2)
690
691/* QoS structure */
692#define NETWORK_HAS_QOS_PARAMETERS (1<<3)
693#define NETWORK_HAS_QOS_INFORMATION (1<<4)
694#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | NETWORK_HAS_QOS_INFORMATION)
695
696#define QOS_QUEUE_NUM 4
697#define QOS_OUI_LEN 3
698#define QOS_OUI_TYPE 2
699#define QOS_ELEMENT_ID 221
700#define QOS_OUI_INFO_SUB_TYPE 0
701#define QOS_OUI_PARAM_SUB_TYPE 1
702#define QOS_VERSION_1 1
703#define QOS_AIFSN_MIN_VALUE 2
704
705struct ieee80211_qos_information_element {
706 u8 elementID;
707 u8 length;
708 u8 qui[QOS_OUI_LEN];
709 u8 qui_type;
710 u8 qui_subtype;
711 u8 version;
712 u8 ac_info;
713} __attribute__ ((packed));
714
715struct ieee80211_qos_ac_parameter {
716 u8 aci_aifsn;
717 u8 ecw_min_max;
718 __le16 tx_op_limit;
719} __attribute__ ((packed));
720
721struct ieee80211_qos_parameter_info {
722 struct ieee80211_qos_information_element info_element;
723 u8 reserved;
724 struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
725} __attribute__ ((packed));
726
727struct ieee80211_qos_parameters {
728 __le16 cw_min[QOS_QUEUE_NUM];
729 __le16 cw_max[QOS_QUEUE_NUM];
730 u8 aifs[QOS_QUEUE_NUM];
731 u8 flag[QOS_QUEUE_NUM];
732 __le16 tx_op_limit[QOS_QUEUE_NUM];
733} __attribute__ ((packed));
734
735struct ieee80211_qos_data {
736 struct ieee80211_qos_parameters parameters;
737 int active;
738 int supported;
739 u8 param_count;
740 u8 old_param_count;
741};
742
743struct ieee80211_tim_parameters {
744 u8 tim_count;
745 u8 tim_period;
746} __attribute__ ((packed));
747
748/*******************************************************/
610 749
611struct ieee80211_network { 750struct ieee80211_network {
612 /* These entries are used to identify a unique network */ 751 /* These entries are used to identify a unique network */
@@ -616,6 +755,8 @@ struct ieee80211_network {
616 u8 ssid[IW_ESSID_MAX_SIZE + 1]; 755 u8 ssid[IW_ESSID_MAX_SIZE + 1];
617 u8 ssid_len; 756 u8 ssid_len;
618 757
758 struct ieee80211_qos_data qos_data;
759
619 /* These are network statistics */ 760 /* These are network statistics */
620 struct ieee80211_rx_stats stats; 761 struct ieee80211_rx_stats stats;
621 u16 capability; 762 u16 capability;
@@ -631,10 +772,12 @@ struct ieee80211_network {
631 u16 beacon_interval; 772 u16 beacon_interval;
632 u16 listen_interval; 773 u16 listen_interval;
633 u16 atim_window; 774 u16 atim_window;
775 u8 erp_value;
634 u8 wpa_ie[MAX_WPA_IE_LEN]; 776 u8 wpa_ie[MAX_WPA_IE_LEN];
635 size_t wpa_ie_len; 777 size_t wpa_ie_len;
636 u8 rsn_ie[MAX_WPA_IE_LEN]; 778 u8 rsn_ie[MAX_WPA_IE_LEN];
637 size_t rsn_ie_len; 779 size_t rsn_ie_len;
780 struct ieee80211_tim_parameters tim;
638 struct list_head list; 781 struct list_head list;
639}; 782};
640 783
@@ -651,17 +794,52 @@ enum ieee80211_state {
651#define DEFAULT_MAX_SCAN_AGE (15 * HZ) 794#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
652#define DEFAULT_FTS 2346 795#define DEFAULT_FTS 2346
653 796
654
655#define CFG_IEEE80211_RESERVE_FCS (1<<0) 797#define CFG_IEEE80211_RESERVE_FCS (1<<0)
656#define CFG_IEEE80211_COMPUTE_FCS (1<<1) 798#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
799#define CFG_IEEE80211_RTS (1<<2)
800
801#define IEEE80211_24GHZ_MIN_CHANNEL 1
802#define IEEE80211_24GHZ_MAX_CHANNEL 14
803#define IEEE80211_24GHZ_CHANNELS 14
804
805#define IEEE80211_52GHZ_MIN_CHANNEL 36
806#define IEEE80211_52GHZ_MAX_CHANNEL 165
807#define IEEE80211_52GHZ_CHANNELS 32
808
809enum {
810 IEEE80211_CH_PASSIVE_ONLY = (1 << 0),
811 IEEE80211_CH_B_ONLY = (1 << 2),
812 IEEE80211_CH_NO_IBSS = (1 << 3),
813 IEEE80211_CH_UNIFORM_SPREADING = (1 << 4),
814 IEEE80211_CH_RADAR_DETECT = (1 << 5),
815 IEEE80211_CH_INVALID = (1 << 6),
816};
817
818struct ieee80211_channel {
819 u32 freq;
820 u8 channel;
821 u8 flags;
822 u8 max_power;
823};
824
825struct ieee80211_geo {
826 u8 name[4];
827 u8 bg_channels;
828 u8 a_channels;
829 struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS];
830 struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS];
831};
657 832
658struct ieee80211_device { 833struct ieee80211_device {
659 struct net_device *dev; 834 struct net_device *dev;
835 struct ieee80211_security sec;
660 836
661 /* Bookkeeping structures */ 837 /* Bookkeeping structures */
662 struct net_device_stats stats; 838 struct net_device_stats stats;
663 struct ieee80211_stats ieee_stats; 839 struct ieee80211_stats ieee_stats;
664 840
841 struct ieee80211_geo geo;
842
665 /* Probe / Beacon management */ 843 /* Probe / Beacon management */
666 struct list_head network_free_list; 844 struct list_head network_free_list;
667 struct list_head network_list; 845 struct list_head network_list;
@@ -669,62 +847,102 @@ struct ieee80211_device {
669 int scans; 847 int scans;
670 int scan_age; 848 int scan_age;
671 849
672 int iw_mode; /* operating mode (IW_MODE_*) */ 850 int iw_mode; /* operating mode (IW_MODE_*) */
851 struct iw_spy_data spy_data; /* iwspy support */
673 852
674 spinlock_t lock; 853 spinlock_t lock;
675 854
676 int tx_headroom; /* Set to size of any additional room needed at front 855 int tx_headroom; /* Set to size of any additional room needed at front
677 * of allocated Tx SKBs */ 856 * of allocated Tx SKBs */
678 u32 config; 857 u32 config;
679 858
680 /* WEP and other encryption related settings at the device level */ 859 /* WEP and other encryption related settings at the device level */
681 int open_wep; /* Set to 1 to allow unencrypted frames */ 860 int open_wep; /* Set to 1 to allow unencrypted frames */
682 861
683 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on 862 int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
684 * WEP key changes */ 863 * WEP key changes */
685 864
686 /* If the host performs {en,de}cryption, then set to 1 */ 865 /* If the host performs {en,de}cryption, then set to 1 */
687 int host_encrypt; 866 int host_encrypt;
867 int host_encrypt_msdu;
688 int host_decrypt; 868 int host_decrypt;
689 int ieee802_1x; /* is IEEE 802.1X used */ 869 /* host performs multicast decryption */
870 int host_mc_decrypt;
871
872 int host_open_frag;
873 int host_build_iv;
874 int ieee802_1x; /* is IEEE 802.1X used */
690 875
691 /* WPA data */ 876 /* WPA data */
692 int wpa_enabled; 877 int wpa_enabled;
693 int drop_unencrypted; 878 int drop_unencrypted;
694 int tkip_countermeasures;
695 int privacy_invoked; 879 int privacy_invoked;
696 size_t wpa_ie_len; 880 size_t wpa_ie_len;
697 u8 *wpa_ie; 881 u8 *wpa_ie;
698 882
699 struct list_head crypt_deinit_list; 883 struct list_head crypt_deinit_list;
700 struct ieee80211_crypt_data *crypt[WEP_KEYS]; 884 struct ieee80211_crypt_data *crypt[WEP_KEYS];
701 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ 885 int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
702 struct timer_list crypt_deinit_timer; 886 struct timer_list crypt_deinit_timer;
887 int crypt_quiesced;
703 888
704 int bcrx_sta_key; /* use individual keys to override default keys even 889 int bcrx_sta_key; /* use individual keys to override default keys even
705 * with RX of broad/multicast frames */ 890 * with RX of broad/multicast frames */
706 891
707 /* Fragmentation structures */ 892 /* Fragmentation structures */
708 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; 893 struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
709 unsigned int frag_next_idx; 894 unsigned int frag_next_idx;
710 u16 fts; /* Fragmentation Threshold */ 895 u16 fts; /* Fragmentation Threshold */
896 u16 rts; /* RTS threshold */
711 897
712 /* Association info */ 898 /* Association info */
713 u8 bssid[ETH_ALEN]; 899 u8 bssid[ETH_ALEN];
714 900
715 enum ieee80211_state state; 901 enum ieee80211_state state;
716 902
717 int mode; /* A, B, G */ 903 int mode; /* A, B, G */
718 int modulation; /* CCK, OFDM */ 904 int modulation; /* CCK, OFDM */
719 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ 905 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
720 int abg_ture; /* ABG flag */ 906 int abg_true; /* ABG flag */
907
908 int perfect_rssi;
909 int worst_rssi;
721 910
722 /* Callback functions */ 911 /* Callback functions */
723 void (*set_security)(struct net_device *dev, 912 void (*set_security) (struct net_device * dev,
724 struct ieee80211_security *sec); 913 struct ieee80211_security * sec);
725 int (*hard_start_xmit)(struct ieee80211_txb *txb, 914 int (*hard_start_xmit) (struct ieee80211_txb * txb,
726 struct net_device *dev); 915 struct net_device * dev, int pri);
727 int (*reset_port)(struct net_device *dev); 916 int (*reset_port) (struct net_device * dev);
917 int (*is_queue_full) (struct net_device * dev, int pri);
918
919 int (*handle_management) (struct net_device * dev,
920 struct ieee80211_network * network, u16 type);
921
922 /* Typical STA methods */
923 int (*handle_auth) (struct net_device * dev,
924 struct ieee80211_auth * auth);
925 int (*handle_deauth) (struct net_device * dev,
926 struct ieee80211_auth * auth);
927 int (*handle_disassoc) (struct net_device * dev,
928 struct ieee80211_disassoc * assoc);
929 int (*handle_beacon) (struct net_device * dev,
930 struct ieee80211_beacon * beacon,
931 struct ieee80211_network * network);
932 int (*handle_probe_response) (struct net_device * dev,
933 struct ieee80211_probe_response * resp,
934 struct ieee80211_network * network);
935 int (*handle_probe_request) (struct net_device * dev,
936 struct ieee80211_probe_request * req,
937 struct ieee80211_rx_stats * stats);
938 int (*handle_assoc_response) (struct net_device * dev,
939 struct ieee80211_assoc_response * resp,
940 struct ieee80211_network * network);
941
942 /* Typical AP methods */
943 int (*handle_assoc_request) (struct net_device * dev);
944 int (*handle_reassoc_request) (struct net_device * dev,
945 struct ieee80211_reassoc_request * req);
728 946
729 /* This must be the last item so that it points to the data 947 /* This must be the last item so that it points to the data
730 * allocated beyond this structure by alloc_ieee80211 */ 948 * allocated beyond this structure by alloc_ieee80211 */
@@ -736,12 +954,12 @@ struct ieee80211_device {
736#define IEEE_G (1<<2) 954#define IEEE_G (1<<2)
737#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) 955#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
738 956
739extern inline void *ieee80211_priv(struct net_device *dev) 957static inline void *ieee80211_priv(struct net_device *dev)
740{ 958{
741 return ((struct ieee80211_device *)netdev_priv(dev))->priv; 959 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
742} 960}
743 961
744extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) 962static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
745{ 963{
746 /* Single white space is for Linksys APs */ 964 /* Single white space is for Linksys APs */
747 if (essid_len == 1 && essid[0] == ' ') 965 if (essid_len == 1 && essid[0] == ' ')
@@ -757,7 +975,8 @@ extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
757 return 1; 975 return 1;
758} 976}
759 977
760extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) 978static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee,
979 int mode)
761{ 980{
762 /* 981 /*
763 * It is possible for both access points and our device to support 982 * It is possible for both access points and our device to support
@@ -783,14 +1002,17 @@ extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mod
783 return 0; 1002 return 0;
784} 1003}
785 1004
786extern inline int ieee80211_get_hdrlen(u16 fc) 1005static inline int ieee80211_get_hdrlen(u16 fc)
787{ 1006{
788 int hdrlen = IEEE80211_3ADDR_LEN; 1007 int hdrlen = IEEE80211_3ADDR_LEN;
1008 u16 stype = WLAN_FC_GET_STYPE(fc);
789 1009
790 switch (WLAN_FC_GET_TYPE(fc)) { 1010 switch (WLAN_FC_GET_TYPE(fc)) {
791 case IEEE80211_FTYPE_DATA: 1011 case IEEE80211_FTYPE_DATA:
792 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) 1012 if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
793 hdrlen = IEEE80211_4ADDR_LEN; 1013 hdrlen = IEEE80211_4ADDR_LEN;
1014 if (stype & IEEE80211_STYPE_QOS_DATA)
1015 hdrlen += 2;
794 break; 1016 break;
795 case IEEE80211_FTYPE_CTL: 1017 case IEEE80211_FTYPE_CTL:
796 switch (WLAN_FC_GET_STYPE(fc)) { 1018 switch (WLAN_FC_GET_STYPE(fc)) {
@@ -808,7 +1030,48 @@ extern inline int ieee80211_get_hdrlen(u16 fc)
808 return hdrlen; 1030 return hdrlen;
809} 1031}
810 1032
1033static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
1034{
1035 switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
1036 case IEEE80211_1ADDR_LEN:
1037 return ((struct ieee80211_hdr_1addr *)hdr)->payload;
1038 case IEEE80211_2ADDR_LEN:
1039 return ((struct ieee80211_hdr_2addr *)hdr)->payload;
1040 case IEEE80211_3ADDR_LEN:
1041 return ((struct ieee80211_hdr_3addr *)hdr)->payload;
1042 case IEEE80211_4ADDR_LEN:
1043 return ((struct ieee80211_hdr_4addr *)hdr)->payload;
1044 }
1045
1046}
1047
1048static inline int ieee80211_is_ofdm_rate(u8 rate)
1049{
1050 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1051 case IEEE80211_OFDM_RATE_6MB:
1052 case IEEE80211_OFDM_RATE_9MB:
1053 case IEEE80211_OFDM_RATE_12MB:
1054 case IEEE80211_OFDM_RATE_18MB:
1055 case IEEE80211_OFDM_RATE_24MB:
1056 case IEEE80211_OFDM_RATE_36MB:
1057 case IEEE80211_OFDM_RATE_48MB:
1058 case IEEE80211_OFDM_RATE_54MB:
1059 return 1;
1060 }
1061 return 0;
1062}
811 1063
1064static inline int ieee80211_is_cck_rate(u8 rate)
1065{
1066 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
1067 case IEEE80211_CCK_RATE_1MB:
1068 case IEEE80211_CCK_RATE_2MB:
1069 case IEEE80211_CCK_RATE_5MB:
1070 case IEEE80211_CCK_RATE_11MB:
1071 return 1;
1072 }
1073 return 0;
1074}
812 1075
813/* ieee80211.c */ 1076/* ieee80211.c */
814extern void free_ieee80211(struct net_device *dev); 1077extern void free_ieee80211(struct net_device *dev);
@@ -817,18 +1080,30 @@ extern struct net_device *alloc_ieee80211(int sizeof_priv);
817extern int ieee80211_set_encryption(struct ieee80211_device *ieee); 1080extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
818 1081
819/* ieee80211_tx.c */ 1082/* ieee80211_tx.c */
820extern int ieee80211_xmit(struct sk_buff *skb, 1083extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev);
821 struct net_device *dev);
822extern void ieee80211_txb_free(struct ieee80211_txb *); 1084extern void ieee80211_txb_free(struct ieee80211_txb *);
823 1085extern int ieee80211_tx_frame(struct ieee80211_device *ieee,
1086 struct ieee80211_hdr *frame, int len);
824 1087
825/* ieee80211_rx.c */ 1088/* ieee80211_rx.c */
826extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, 1089extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
827 struct ieee80211_rx_stats *rx_stats); 1090 struct ieee80211_rx_stats *rx_stats);
828extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, 1091extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
829 struct ieee80211_hdr *header, 1092 struct ieee80211_hdr_4addr *header,
830 struct ieee80211_rx_stats *stats); 1093 struct ieee80211_rx_stats *stats);
831 1094
1095/* ieee80211_geo.c */
1096extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device
1097 *ieee);
1098extern int ieee80211_set_geo(struct ieee80211_device *ieee,
1099 const struct ieee80211_geo *geo);
1100
1101extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee,
1102 u8 channel);
1103extern int ieee80211_channel_to_index(struct ieee80211_device *ieee,
1104 u8 channel);
1105extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq);
1106
832/* ieee80211_wx.c */ 1107/* ieee80211_wx.c */
833extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, 1108extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
834 struct iw_request_info *info, 1109 struct iw_request_info *info,
@@ -839,17 +1114,21 @@ extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
839extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, 1114extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
840 struct iw_request_info *info, 1115 struct iw_request_info *info,
841 union iwreq_data *wrqu, char *key); 1116 union iwreq_data *wrqu, char *key);
842 1117extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
843 1118 struct iw_request_info *info,
844extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) 1119 union iwreq_data *wrqu, char *extra);
1120extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
1121 struct iw_request_info *info,
1122 union iwreq_data *wrqu, char *extra);
1123
1124static inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
845{ 1125{
846 ieee->scans++; 1126 ieee->scans++;
847} 1127}
848 1128
849extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) 1129static inline int ieee80211_get_scans(struct ieee80211_device *ieee)
850{ 1130{
851 return ieee->scans; 1131 return ieee->scans;
852} 1132}
853 1133
854 1134#endif /* IEEE80211_H */
855#endif /* IEEE80211_H */
diff --git a/include/net/ieee80211_crypt.h b/include/net/ieee80211_crypt.h
index b58a3bcc0dc0..0a1c2d82ca4b 100644
--- a/include/net/ieee80211_crypt.h
+++ b/include/net/ieee80211_crypt.h
@@ -25,16 +25,22 @@
25 25
26#include <linux/skbuff.h> 26#include <linux/skbuff.h>
27 27
28enum {
29 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
30};
31
28struct ieee80211_crypto_ops { 32struct ieee80211_crypto_ops {
29 const char *name; 33 const char *name;
30 34
31 /* init new crypto context (e.g., allocate private data space, 35 /* init new crypto context (e.g., allocate private data space,
32 * select IV, etc.); returns NULL on failure or pointer to allocated 36 * select IV, etc.); returns NULL on failure or pointer to allocated
33 * private data on success */ 37 * private data on success */
34 void * (*init)(int keyidx); 38 void *(*init) (int keyidx);
35 39
36 /* deinitialize crypto context and free allocated private data */ 40 /* deinitialize crypto context and free allocated private data */
37 void (*deinit)(void *priv); 41 void (*deinit) (void *priv);
42
43 int (*build_iv) (struct sk_buff * skb, int hdr_len, void *priv);
38 44
39 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return 45 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
40 * value from decrypt_mpdu is passed as the keyidx value for 46 * value from decrypt_mpdu is passed as the keyidx value for
@@ -42,34 +48,39 @@ struct ieee80211_crypto_ops {
42 * encryption; if not, error will be returned; these functions are 48 * encryption; if not, error will be returned; these functions are
43 * called for all MPDUs (i.e., fragments). 49 * called for all MPDUs (i.e., fragments).
44 */ 50 */
45 int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); 51 int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
46 int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); 52 int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
47 53
48 /* These functions are called for full MSDUs, i.e. full frames. 54 /* These functions are called for full MSDUs, i.e. full frames.
49 * These can be NULL if full MSDU operations are not needed. */ 55 * These can be NULL if full MSDU operations are not needed. */
50 int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv); 56 int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
51 int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len, 57 int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
52 void *priv); 58 void *priv);
53 59
54 int (*set_key)(void *key, int len, u8 *seq, void *priv); 60 int (*set_key) (void *key, int len, u8 * seq, void *priv);
55 int (*get_key)(void *key, int len, u8 *seq, void *priv); 61 int (*get_key) (void *key, int len, u8 * seq, void *priv);
56 62
57 /* procfs handler for printing out key information and possible 63 /* procfs handler for printing out key information and possible
58 * statistics */ 64 * statistics */
59 char * (*print_stats)(char *p, void *priv); 65 char *(*print_stats) (char *p, void *priv);
66
67 /* Crypto specific flag get/set for configuration settings */
68 unsigned long (*get_flags) (void *priv);
69 unsigned long (*set_flags) (unsigned long flags, void *priv);
60 70
61 /* maximum number of bytes added by encryption; encrypt buf is 71 /* maximum number of bytes added by encryption; encrypt buf is
62 * allocated with extra_prefix_len bytes, copy of in_buf, and 72 * allocated with extra_prefix_len bytes, copy of in_buf, and
63 * extra_postfix_len; encrypt need not use all this space, but 73 * extra_postfix_len; encrypt need not use all this space, but
64 * the result must start at the beginning of the buffer and correct 74 * the result must start at the beginning of the buffer and correct
65 * length must be returned */ 75 * length must be returned */
66 int extra_prefix_len, extra_postfix_len; 76 int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
77 int extra_msdu_prefix_len, extra_msdu_postfix_len;
67 78
68 struct module *owner; 79 struct module *owner;
69}; 80};
70 81
71struct ieee80211_crypt_data { 82struct ieee80211_crypt_data {
72 struct list_head list; /* delayed deletion list */ 83 struct list_head list; /* delayed deletion list */
73 struct ieee80211_crypto_ops *ops; 84 struct ieee80211_crypto_ops *ops;
74 void *priv; 85 void *priv;
75 atomic_t refcnt; 86 atomic_t refcnt;
@@ -77,10 +88,11 @@ struct ieee80211_crypt_data {
77 88
78int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); 89int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
79int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); 90int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
80struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); 91struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
81void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); 92void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
82void ieee80211_crypt_deinit_handler(unsigned long); 93void ieee80211_crypt_deinit_handler(unsigned long);
83void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, 94void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
84 struct ieee80211_crypt_data **crypt); 95 struct ieee80211_crypt_data **crypt);
96void ieee80211_crypt_quiescing(struct ieee80211_device *ieee);
85 97
86#endif 98#endif
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
new file mode 100644
index 000000000000..429b73892a5f
--- /dev/null
+++ b/include/net/ieee80211_radiotap.h
@@ -0,0 +1,231 @@
1/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
2/* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */
3
4/*-
5 * Copyright (c) 2003, 2004 David Young. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of David Young may not be used to endorse or promote
16 * products derived from this software without specific prior
17 * written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
23 * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 * OF SUCH DAMAGE.
31 */
32
33/*
34 * Modifications to fit into the linux IEEE 802.11 stack,
35 * Mike Kershaw (dragorn@kismetwireless.net)
36 */
37
38#ifndef IEEE80211RADIOTAP_H
39#define IEEE80211RADIOTAP_H
40
41#include <linux/if_ether.h>
42#include <linux/kernel.h>
43
44/* Radiotap header version (from official NetBSD feed) */
45#define IEEE80211RADIOTAP_VERSION "1.5"
46/* Base version of the radiotap packet header data */
47#define PKTHDR_RADIOTAP_VERSION 0
48
49/* A generic radio capture format is desirable. There is one for
50 * Linux, but it is neither rigidly defined (there were not even
51 * units given for some fields) nor easily extensible.
52 *
53 * I suggest the following extensible radio capture format. It is
54 * based on a bitmap indicating which fields are present.
55 *
56 * I am trying to describe precisely what the application programmer
57 * should expect in the following, and for that reason I tell the
58 * units and origin of each measurement (where it applies), or else I
59 * use sufficiently weaselly language ("is a monotonically nondecreasing
60 * function of...") that I cannot set false expectations for lawyerly
61 * readers.
62 */
63
64/* XXX tcpdump/libpcap do not tolerate variable-length headers,
65 * yet, so we pad every radiotap header to 64 bytes. Ugh.
66 */
67#define IEEE80211_RADIOTAP_HDRLEN 64
68
69/* The radio capture header precedes the 802.11 header. */
70struct ieee80211_radiotap_header {
71 u8 it_version; /* Version 0. Only increases
72 * for drastic changes,
73 * introduction of compatible
74 * new fields does not count.
75 */
76 u8 it_pad;
77 u16 it_len; /* length of the whole
78 * header in bytes, including
79 * it_version, it_pad,
80 * it_len, and data fields.
81 */
82 u32 it_present; /* A bitmap telling which
83 * fields are present. Set bit 31
84 * (0x80000000) to extend the
85 * bitmap by another 32 bits.
86 * Additional extensions are made
87 * by setting bit 31.
88 */
89};
90
91/* Name Data type Units
92 * ---- --------- -----
93 *
94 * IEEE80211_RADIOTAP_TSFT u64 microseconds
95 *
96 * Value in microseconds of the MAC's 64-bit 802.11 Time
97 * Synchronization Function timer when the first bit of the
98 * MPDU arrived at the MAC. For received frames, only.
99 *
100 * IEEE80211_RADIOTAP_CHANNEL 2 x u16 MHz, bitmap
101 *
102 * Tx/Rx frequency in MHz, followed by flags (see below).
103 *
104 * IEEE80211_RADIOTAP_FHSS u16 see below
105 *
106 * For frequency-hopping radios, the hop set (first byte)
107 * and pattern (second byte).
108 *
109 * IEEE80211_RADIOTAP_RATE u8 500kb/s
110 *
111 * Tx/Rx data rate
112 *
113 * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
114 * one milliwatt (dBm)
115 *
116 * RF signal power at the antenna, decibel difference from
117 * one milliwatt.
118 *
119 * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
120 * one milliwatt (dBm)
121 *
122 * RF noise power at the antenna, decibel difference from one
123 * milliwatt.
124 *
125 * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB)
126 *
127 * RF signal power at the antenna, decibel difference from an
128 * arbitrary, fixed reference.
129 *
130 * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB)
131 *
132 * RF noise power at the antenna, decibel difference from an
133 * arbitrary, fixed reference point.
134 *
135 * IEEE80211_RADIOTAP_LOCK_QUALITY u16 unitless
136 *
137 * Quality of Barker code lock. Unitless. Monotonically
138 * nondecreasing with "better" lock strength. Called "Signal
139 * Quality" in datasheets. (Is there a standard way to measure
140 * this?)
141 *
142 * IEEE80211_RADIOTAP_TX_ATTENUATION u16 unitless
143 *
144 * Transmit power expressed as unitless distance from max
145 * power set at factory calibration. 0 is max power.
146 * Monotonically nondecreasing with lower power levels.
147 *
148 * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u16 decibels (dB)
149 *
150 * Transmit power expressed as decibel distance from max power
151 * set at factory calibration. 0 is max power. Monotonically
152 * nondecreasing with lower power levels.
153 *
154 * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
155 * one milliwatt (dBm)
156 *
157 * Transmit power expressed as dBm (decibels from a 1 milliwatt
158 * reference). This is the absolute power level measured at
159 * the antenna port.
160 *
161 * IEEE80211_RADIOTAP_FLAGS u8 bitmap
162 *
163 * Properties of transmitted and received frames. See flags
164 * defined below.
165 *
166 * IEEE80211_RADIOTAP_ANTENNA u8 antenna index
167 *
168 * Unitless indication of the Rx/Tx antenna for this packet.
169 * The first antenna is antenna 0.
170 *
171 * IEEE80211_RADIOTAP_FCS u32 data
172 *
173 * FCS from frame in network byte order.
174 */
175enum ieee80211_radiotap_type {
176 IEEE80211_RADIOTAP_TSFT = 0,
177 IEEE80211_RADIOTAP_FLAGS = 1,
178 IEEE80211_RADIOTAP_RATE = 2,
179 IEEE80211_RADIOTAP_CHANNEL = 3,
180 IEEE80211_RADIOTAP_FHSS = 4,
181 IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
182 IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
183 IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
184 IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
185 IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
186 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
187 IEEE80211_RADIOTAP_ANTENNA = 11,
188 IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
189 IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
190 IEEE80211_RADIOTAP_EXT = 31,
191};
192
193/* Channel flags. */
194#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
195#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
196#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
197#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
198#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
199#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
200#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
201#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
202
203/* For IEEE80211_RADIOTAP_FLAGS */
204#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
205 * during CFP
206 */
207#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
208 * with short
209 * preamble
210 */
211#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
212 * with WEP encryption
213 */
214#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
215 * with fragmentation
216 */
217#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
218#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
219 * 802.11 header and payload
220 * (to 32-bit boundary)
221 */
222
223/* Ugly macro to convert literal channel numbers into their mhz equivalents
224 * There are certianly some conditions that will break this (like feeding it '30')
225 * but they shouldn't arise since nothing talks on channel 30. */
226#define ieee80211chan2mhz(x) \
227 (((x) <= 14) ? \
228 (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \
229 ((x) + 1000) * 5)
230
231#endif /* IEEE80211_RADIOTAP_H */
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 1c5f19f995ad..f1c3bc54526a 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -171,10 +171,10 @@ struct sctp_sndrcvinfo {
171 */ 171 */
172 172
173enum sctp_sinfo_flags { 173enum sctp_sinfo_flags {
174 MSG_UNORDERED = 1, /* Send/receive message unordered. */ 174 SCTP_UNORDERED = 1, /* Send/receive message unordered. */
175 MSG_ADDR_OVER = 2, /* Override the primary destination. */ 175 SCTP_ADDR_OVER = 2, /* Override the primary destination. */
176 MSG_ABORT=4, /* Send an ABORT message to the peer. */ 176 SCTP_ABORT=4, /* Send an ABORT message to the peer. */
177 /* MSG_EOF is already defined per socket.h */ 177 SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
178}; 178};
179 179
180 180
diff --git a/include/net/sock.h b/include/net/sock.h
index ecb75526cba0..e0498bd36004 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -207,7 +207,7 @@ struct sock {
207 struct sk_buff_head sk_write_queue; 207 struct sk_buff_head sk_write_queue;
208 int sk_wmem_queued; 208 int sk_wmem_queued;
209 int sk_forward_alloc; 209 int sk_forward_alloc;
210 unsigned int sk_allocation; 210 gfp_t sk_allocation;
211 int sk_sndbuf; 211 int sk_sndbuf;
212 int sk_route_caps; 212 int sk_route_caps;
213 unsigned long sk_flags; 213 unsigned long sk_flags;
diff --git a/include/net/syncppp.h b/include/net/syncppp.h
index 614cb6ba564e..877efa434700 100644
--- a/include/net/syncppp.h
+++ b/include/net/syncppp.h
@@ -86,7 +86,6 @@ static inline struct sppp *sppp_of(struct net_device *dev)
86 86
87void sppp_attach (struct ppp_device *pd); 87void sppp_attach (struct ppp_device *pd);
88void sppp_detach (struct net_device *dev); 88void sppp_detach (struct net_device *dev);
89void sppp_input (struct net_device *dev, struct sk_buff *m);
90int sppp_do_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd); 89int sppp_do_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd);
91struct sk_buff *sppp_dequeue (struct net_device *dev); 90struct sk_buff *sppp_dequeue (struct net_device *dev);
92int sppp_isempty (struct net_device *dev); 91int sppp_isempty (struct net_device *dev);
diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
index 5308683c8c41..0a9fcd59eb43 100644
--- a/include/rdma/ib_cm.h
+++ b/include/rdma/ib_cm.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004 Intel Corporation. All rights reserved. 2 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
3 * Copyright (c) 2004 Topspin Corporation. All rights reserved. 3 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
4 * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 4 * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 5 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -109,7 +109,6 @@ struct ib_cm_id;
109 109
110struct ib_cm_req_event_param { 110struct ib_cm_req_event_param {
111 struct ib_cm_id *listen_id; 111 struct ib_cm_id *listen_id;
112 struct ib_device *device;
113 u8 port; 112 u8 port;
114 113
115 struct ib_sa_path_rec *primary_path; 114 struct ib_sa_path_rec *primary_path;
@@ -220,7 +219,6 @@ struct ib_cm_apr_event_param {
220 219
221struct ib_cm_sidr_req_event_param { 220struct ib_cm_sidr_req_event_param {
222 struct ib_cm_id *listen_id; 221 struct ib_cm_id *listen_id;
223 struct ib_device *device;
224 u8 port; 222 u8 port;
225 u16 pkey; 223 u16 pkey;
226}; 224};
@@ -284,6 +282,7 @@ typedef int (*ib_cm_handler)(struct ib_cm_id *cm_id,
284struct ib_cm_id { 282struct ib_cm_id {
285 ib_cm_handler cm_handler; 283 ib_cm_handler cm_handler;
286 void *context; 284 void *context;
285 struct ib_device *device;
287 __be64 service_id; 286 __be64 service_id;
288 __be64 service_mask; 287 __be64 service_mask;
289 enum ib_cm_state state; /* internal CM/debug use */ 288 enum ib_cm_state state; /* internal CM/debug use */
@@ -295,6 +294,8 @@ struct ib_cm_id {
295 294
296/** 295/**
297 * ib_create_cm_id - Allocate a communication identifier. 296 * ib_create_cm_id - Allocate a communication identifier.
297 * @device: Device associated with the cm_id. All related communication will
298 * be associated with the specified device.
298 * @cm_handler: Callback invoked to notify the user of CM events. 299 * @cm_handler: Callback invoked to notify the user of CM events.
299 * @context: User specified context associated with the communication 300 * @context: User specified context associated with the communication
300 * identifier. 301 * identifier.
@@ -302,7 +303,8 @@ struct ib_cm_id {
302 * Communication identifiers are used to track connection states, service 303 * Communication identifiers are used to track connection states, service
303 * ID resolution requests, and listen requests. 304 * ID resolution requests, and listen requests.
304 */ 305 */
305struct ib_cm_id *ib_create_cm_id(ib_cm_handler cm_handler, 306struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
307 ib_cm_handler cm_handler,
306 void *context); 308 void *context);
307 309
308/** 310/**
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 4172e6841e3d..2c133506742b 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -109,10 +109,14 @@
109#define IB_QP_SET_QKEY 0x80000000 109#define IB_QP_SET_QKEY 0x80000000
110 110
111enum { 111enum {
112 IB_MGMT_MAD_HDR = 24,
112 IB_MGMT_MAD_DATA = 232, 113 IB_MGMT_MAD_DATA = 232,
114 IB_MGMT_RMPP_HDR = 36,
113 IB_MGMT_RMPP_DATA = 220, 115 IB_MGMT_RMPP_DATA = 220,
116 IB_MGMT_VENDOR_HDR = 40,
114 IB_MGMT_VENDOR_DATA = 216, 117 IB_MGMT_VENDOR_DATA = 216,
115 IB_MGMT_SA_DATA = 200 118 IB_MGMT_SA_HDR = 56,
119 IB_MGMT_SA_DATA = 200,
116}; 120};
117 121
118struct ib_mad_hdr { 122struct ib_mad_hdr {
@@ -203,26 +207,25 @@ struct ib_class_port_info
203 207
204/** 208/**
205 * ib_mad_send_buf - MAD data buffer and work request for sends. 209 * ib_mad_send_buf - MAD data buffer and work request for sends.
206 * @mad: References an allocated MAD data buffer. The size of the data 210 * @next: A pointer used to chain together MADs for posting.
207 * buffer is specified in the @send_wr.length field. 211 * @mad: References an allocated MAD data buffer.
208 * @mapping: DMA mapping information.
209 * @mad_agent: MAD agent that allocated the buffer. 212 * @mad_agent: MAD agent that allocated the buffer.
213 * @ah: The address handle to use when sending the MAD.
210 * @context: User-controlled context fields. 214 * @context: User-controlled context fields.
211 * @send_wr: An initialized work request structure used when sending the MAD. 215 * @timeout_ms: Time to wait for a response.
212 * The wr_id field of the work request is initialized to reference this 216 * @retries: Number of times to retry a request for a response.
213 * data structure.
214 * @sge: A scatter-gather list referenced by the work request.
215 * 217 *
216 * Users are responsible for initializing the MAD buffer itself, with the 218 * Users are responsible for initializing the MAD buffer itself, with the
217 * exception of specifying the payload length field in any RMPP MAD. 219 * exception of specifying the payload length field in any RMPP MAD.
218 */ 220 */
219struct ib_mad_send_buf { 221struct ib_mad_send_buf {
220 struct ib_mad *mad; 222 struct ib_mad_send_buf *next;
221 DECLARE_PCI_UNMAP_ADDR(mapping) 223 void *mad;
222 struct ib_mad_agent *mad_agent; 224 struct ib_mad_agent *mad_agent;
225 struct ib_ah *ah;
223 void *context[2]; 226 void *context[2];
224 struct ib_send_wr send_wr; 227 int timeout_ms;
225 struct ib_sge sge; 228 int retries;
226}; 229};
227 230
228/** 231/**
@@ -287,7 +290,7 @@ typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
287 * or @mad_send_wc. 290 * or @mad_send_wc.
288 */ 291 */
289typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent, 292typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
290 struct ib_send_wr *send_wr, 293 struct ib_mad_send_buf *send_buf,
291 struct ib_mad_send_wc *mad_send_wc); 294 struct ib_mad_send_wc *mad_send_wc);
292 295
293/** 296/**
@@ -334,13 +337,13 @@ struct ib_mad_agent {
334 337
335/** 338/**
336 * ib_mad_send_wc - MAD send completion information. 339 * ib_mad_send_wc - MAD send completion information.
337 * @wr_id: Work request identifier associated with the send MAD request. 340 * @send_buf: Send MAD data buffer associated with the send MAD request.
338 * @status: Completion status. 341 * @status: Completion status.
339 * @vendor_err: Optional vendor error information returned with a failed 342 * @vendor_err: Optional vendor error information returned with a failed
340 * request. 343 * request.
341 */ 344 */
342struct ib_mad_send_wc { 345struct ib_mad_send_wc {
343 u64 wr_id; 346 struct ib_mad_send_buf *send_buf;
344 enum ib_wc_status status; 347 enum ib_wc_status status;
345 u32 vendor_err; 348 u32 vendor_err;
346}; 349};
@@ -366,7 +369,7 @@ struct ib_mad_recv_buf {
366 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. 369 * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
367 * @mad_len: The length of the received MAD, without duplicated headers. 370 * @mad_len: The length of the received MAD, without duplicated headers.
368 * 371 *
369 * For received response, the wr_id field of the wc is set to the wr_id 372 * For received response, the wr_id contains a pointer to the ib_mad_send_buf
370 * for the corresponding send request. 373 * for the corresponding send request.
371 */ 374 */
372struct ib_mad_recv_wc { 375struct ib_mad_recv_wc {
@@ -463,9 +466,9 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
463/** 466/**
464 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated 467 * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
465 * with the registered client. 468 * with the registered client.
466 * @mad_agent: Specifies the associated registration to post the send to. 469 * @send_buf: Specifies the information needed to send the MAD(s).
467 * @send_wr: Specifies the information needed to send the MAD(s). 470 * @bad_send_buf: Specifies the MAD on which an error was encountered. This
468 * @bad_send_wr: Specifies the MAD on which an error was encountered. 471 * parameter is optional if only a single MAD is posted.
469 * 472 *
470 * Sent MADs are not guaranteed to complete in the order that they were posted. 473 * Sent MADs are not guaranteed to complete in the order that they were posted.
471 * 474 *
@@ -479,9 +482,8 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent);
479 * defined data being transferred. The paylen_newwin field should be 482 * defined data being transferred. The paylen_newwin field should be
480 * specified in network-byte order. 483 * specified in network-byte order.
481 */ 484 */
482int ib_post_send_mad(struct ib_mad_agent *mad_agent, 485int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
483 struct ib_send_wr *send_wr, 486 struct ib_mad_send_buf **bad_send_buf);
484 struct ib_send_wr **bad_send_wr);
485 487
486/** 488/**
487 * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer. 489 * ib_coalesce_recv_mad - Coalesces received MAD data into a single buffer.
@@ -507,23 +509,25 @@ void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc);
507/** 509/**
508 * ib_cancel_mad - Cancels an outstanding send MAD operation. 510 * ib_cancel_mad - Cancels an outstanding send MAD operation.
509 * @mad_agent: Specifies the registration associated with sent MAD. 511 * @mad_agent: Specifies the registration associated with sent MAD.
510 * @wr_id: Indicates the work request identifier of the MAD to cancel. 512 * @send_buf: Indicates the MAD to cancel.
511 * 513 *
512 * MADs will be returned to the user through the corresponding 514 * MADs will be returned to the user through the corresponding
513 * ib_mad_send_handler. 515 * ib_mad_send_handler.
514 */ 516 */
515void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id); 517void ib_cancel_mad(struct ib_mad_agent *mad_agent,
518 struct ib_mad_send_buf *send_buf);
516 519
517/** 520/**
518 * ib_modify_mad - Modifies an outstanding send MAD operation. 521 * ib_modify_mad - Modifies an outstanding send MAD operation.
519 * @mad_agent: Specifies the registration associated with sent MAD. 522 * @mad_agent: Specifies the registration associated with sent MAD.
520 * @wr_id: Indicates the work request identifier of the MAD to modify. 523 * @send_buf: Indicates the MAD to modify.
521 * @timeout_ms: New timeout value for sent MAD. 524 * @timeout_ms: New timeout value for sent MAD.
522 * 525 *
523 * This call will reset the timeout value for a sent MAD to the specified 526 * This call will reset the timeout value for a sent MAD to the specified
524 * value. 527 * value.
525 */ 528 */
526int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms); 529int ib_modify_mad(struct ib_mad_agent *mad_agent,
530 struct ib_mad_send_buf *send_buf, u32 timeout_ms);
527 531
528/** 532/**
529 * ib_redirect_mad_qp - Registers a QP for MAD services. 533 * ib_redirect_mad_qp - Registers a QP for MAD services.
@@ -572,7 +576,6 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
572 * @remote_qpn: Specifies the QPN of the receiving node. 576 * @remote_qpn: Specifies the QPN of the receiving node.
573 * @pkey_index: Specifies which PKey the MAD will be sent using. This field 577 * @pkey_index: Specifies which PKey the MAD will be sent using. This field
574 * is valid only if the remote_qpn is QP 1. 578 * is valid only if the remote_qpn is QP 1.
575 * @ah: References the address handle used to transfer to the remote node.
576 * @rmpp_active: Indicates if the send will enable RMPP. 579 * @rmpp_active: Indicates if the send will enable RMPP.
577 * @hdr_len: Indicates the size of the data header of the MAD. This length 580 * @hdr_len: Indicates the size of the data header of the MAD. This length
578 * should include the common MAD header, RMPP header, plus any class 581 * should include the common MAD header, RMPP header, plus any class
@@ -582,11 +585,10 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
582 * additional padding that may be necessary. 585 * additional padding that may be necessary.
583 * @gfp_mask: GFP mask used for the memory allocation. 586 * @gfp_mask: GFP mask used for the memory allocation.
584 * 587 *
585 * This is a helper routine that may be used to allocate a MAD. Users are 588 * This routine allocates a MAD for sending. The returned MAD send buffer
586 * not required to allocate outbound MADs using this call. The returned 589 * will reference a data buffer usable for sending a MAD, along
587 * MAD send buffer will reference a data buffer usable for sending a MAD, along
588 * with an initialized work request structure. Users may modify the returned 590 * with an initialized work request structure. Users may modify the returned
589 * MAD data buffer or work request before posting the send. 591 * MAD data buffer before posting the send.
590 * 592 *
591 * The returned data buffer will be cleared. Users are responsible for 593 * The returned data buffer will be cleared. Users are responsible for
592 * initializing the common MAD and any class specific headers. If @rmpp_active 594 * initializing the common MAD and any class specific headers. If @rmpp_active
@@ -594,7 +596,7 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
594 */ 596 */
595struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, 597struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
596 u32 remote_qpn, u16 pkey_index, 598 u32 remote_qpn, u16 pkey_index,
597 struct ib_ah *ah, int rmpp_active, 599 int rmpp_active,
598 int hdr_len, int data_len, 600 int hdr_len, int data_len,
599 gfp_t gfp_mask); 601 gfp_t gfp_mask);
600 602
diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h
index e4d1654276ad..3037588b8464 100644
--- a/include/rdma/ib_user_cm.h
+++ b/include/rdma/ib_user_cm.h
@@ -38,7 +38,7 @@
38 38
39#include <linux/types.h> 39#include <linux/types.h>
40 40
41#define IB_USER_CM_ABI_VERSION 2 41#define IB_USER_CM_ABI_VERSION 3
42 42
43enum { 43enum {
44 IB_USER_CM_CMD_CREATE_ID, 44 IB_USER_CM_CMD_CREATE_ID,
@@ -299,8 +299,6 @@ struct ib_ucm_event_get {
299}; 299};
300 300
301struct ib_ucm_req_event_resp { 301struct ib_ucm_req_event_resp {
302 /* device */
303 /* port */
304 struct ib_ucm_path_rec primary_path; 302 struct ib_ucm_path_rec primary_path;
305 struct ib_ucm_path_rec alternate_path; 303 struct ib_ucm_path_rec alternate_path;
306 __be64 remote_ca_guid; 304 __be64 remote_ca_guid;
@@ -316,6 +314,7 @@ struct ib_ucm_req_event_resp {
316 __u8 retry_count; 314 __u8 retry_count;
317 __u8 rnr_retry_count; 315 __u8 rnr_retry_count;
318 __u8 srq; 316 __u8 srq;
317 __u8 port;
319}; 318};
320 319
321struct ib_ucm_rep_event_resp { 320struct ib_ucm_rep_event_resp {
@@ -353,10 +352,9 @@ struct ib_ucm_apr_event_resp {
353}; 352};
354 353
355struct ib_ucm_sidr_req_event_resp { 354struct ib_ucm_sidr_req_event_resp {
356 /* device */
357 /* port */
358 __u16 pkey; 355 __u16 pkey;
359 __u8 reserved[2]; 356 __u8 port;
357 __u8 reserved;
360}; 358};
361 359
362struct ib_ucm_sidr_rep_event_resp { 360struct ib_ucm_sidr_rep_event_resp {
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index fd85725391a4..072f3a2edace 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved. 2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
3 * Copyright (c) 2005 Cisco Systems. All rights reserved. 3 * Copyright (c) 2005 Cisco Systems. All rights reserved.
4 * Copyright (c) 2005 PathScale, Inc. All rights reserved.
4 * 5 *
5 * This software is available to you under a choice of one of two 6 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU 7 * licenses. You may choose to be licensed under the terms of the GNU
@@ -42,15 +43,12 @@
42 * Increment this value if any changes that break userspace ABI 43 * Increment this value if any changes that break userspace ABI
43 * compatibility are made. 44 * compatibility are made.
44 */ 45 */
45#define IB_USER_VERBS_ABI_VERSION 2 46#define IB_USER_VERBS_ABI_VERSION 3
46 47
47enum { 48enum {
48 IB_USER_VERBS_CMD_QUERY_PARAMS,
49 IB_USER_VERBS_CMD_GET_CONTEXT, 49 IB_USER_VERBS_CMD_GET_CONTEXT,
50 IB_USER_VERBS_CMD_QUERY_DEVICE, 50 IB_USER_VERBS_CMD_QUERY_DEVICE,
51 IB_USER_VERBS_CMD_QUERY_PORT, 51 IB_USER_VERBS_CMD_QUERY_PORT,
52 IB_USER_VERBS_CMD_QUERY_GID,
53 IB_USER_VERBS_CMD_QUERY_PKEY,
54 IB_USER_VERBS_CMD_ALLOC_PD, 52 IB_USER_VERBS_CMD_ALLOC_PD,
55 IB_USER_VERBS_CMD_DEALLOC_PD, 53 IB_USER_VERBS_CMD_DEALLOC_PD,
56 IB_USER_VERBS_CMD_CREATE_AH, 54 IB_USER_VERBS_CMD_CREATE_AH,
@@ -65,6 +63,7 @@ enum {
65 IB_USER_VERBS_CMD_ALLOC_MW, 63 IB_USER_VERBS_CMD_ALLOC_MW,
66 IB_USER_VERBS_CMD_BIND_MW, 64 IB_USER_VERBS_CMD_BIND_MW,
67 IB_USER_VERBS_CMD_DEALLOC_MW, 65 IB_USER_VERBS_CMD_DEALLOC_MW,
66 IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
68 IB_USER_VERBS_CMD_CREATE_CQ, 67 IB_USER_VERBS_CMD_CREATE_CQ,
69 IB_USER_VERBS_CMD_RESIZE_CQ, 68 IB_USER_VERBS_CMD_RESIZE_CQ,
70 IB_USER_VERBS_CMD_DESTROY_CQ, 69 IB_USER_VERBS_CMD_DESTROY_CQ,
@@ -90,8 +89,11 @@ enum {
90 * Make sure that all structs defined in this file remain laid out so 89 * Make sure that all structs defined in this file remain laid out so
91 * that they pack the same way on 32-bit and 64-bit architectures (to 90 * that they pack the same way on 32-bit and 64-bit architectures (to
92 * avoid incompatibility between 32-bit userspace and 64-bit kernels). 91 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
93 * In particular do not use pointer types -- pass pointers in __u64 92 * Specifically:
94 * instead. 93 * - Do not use pointer types -- pass pointers in __u64 instead.
94 * - Make sure that any structure larger than 4 bytes is padded to a
95 * multiple of 8 bytes. Otherwise the structure size will be
96 * different between 32-bit and 64-bit architectures.
95 */ 97 */
96 98
97struct ib_uverbs_async_event_desc { 99struct ib_uverbs_async_event_desc {
@@ -118,27 +120,14 @@ struct ib_uverbs_cmd_hdr {
118 __u16 out_words; 120 __u16 out_words;
119}; 121};
120 122
121/*
122 * No driver_data for "query params" command, since this is intended
123 * to be a core function with no possible device dependence.
124 */
125struct ib_uverbs_query_params {
126 __u64 response;
127};
128
129struct ib_uverbs_query_params_resp {
130 __u32 num_cq_events;
131};
132
133struct ib_uverbs_get_context { 123struct ib_uverbs_get_context {
134 __u64 response; 124 __u64 response;
135 __u64 cq_fd_tab;
136 __u64 driver_data[0]; 125 __u64 driver_data[0];
137}; 126};
138 127
139struct ib_uverbs_get_context_resp { 128struct ib_uverbs_get_context_resp {
140 __u32 async_fd; 129 __u32 async_fd;
141 __u32 reserved; 130 __u32 num_comp_vectors;
142}; 131};
143 132
144struct ib_uverbs_query_device { 133struct ib_uverbs_query_device {
@@ -220,31 +209,6 @@ struct ib_uverbs_query_port_resp {
220 __u8 reserved[3]; 209 __u8 reserved[3];
221}; 210};
222 211
223struct ib_uverbs_query_gid {
224 __u64 response;
225 __u8 port_num;
226 __u8 index;
227 __u8 reserved[6];
228 __u64 driver_data[0];
229};
230
231struct ib_uverbs_query_gid_resp {
232 __u8 gid[16];
233};
234
235struct ib_uverbs_query_pkey {
236 __u64 response;
237 __u8 port_num;
238 __u8 index;
239 __u8 reserved[6];
240 __u64 driver_data[0];
241};
242
243struct ib_uverbs_query_pkey_resp {
244 __u16 pkey;
245 __u16 reserved;
246};
247
248struct ib_uverbs_alloc_pd { 212struct ib_uverbs_alloc_pd {
249 __u64 response; 213 __u64 response;
250 __u64 driver_data[0]; 214 __u64 driver_data[0];
@@ -278,11 +242,21 @@ struct ib_uverbs_dereg_mr {
278 __u32 mr_handle; 242 __u32 mr_handle;
279}; 243};
280 244
245struct ib_uverbs_create_comp_channel {
246 __u64 response;
247};
248
249struct ib_uverbs_create_comp_channel_resp {
250 __u32 fd;
251};
252
281struct ib_uverbs_create_cq { 253struct ib_uverbs_create_cq {
282 __u64 response; 254 __u64 response;
283 __u64 user_handle; 255 __u64 user_handle;
284 __u32 cqe; 256 __u32 cqe;
285 __u32 event_handler; 257 __u32 comp_vector;
258 __s32 comp_channel;
259 __u32 reserved;
286 __u64 driver_data[0]; 260 __u64 driver_data[0];
287}; 261};
288 262
@@ -291,6 +265,41 @@ struct ib_uverbs_create_cq_resp {
291 __u32 cqe; 265 __u32 cqe;
292}; 266};
293 267
268struct ib_uverbs_poll_cq {
269 __u64 response;
270 __u32 cq_handle;
271 __u32 ne;
272};
273
274struct ib_uverbs_wc {
275 __u64 wr_id;
276 __u32 status;
277 __u32 opcode;
278 __u32 vendor_err;
279 __u32 byte_len;
280 __u32 imm_data;
281 __u32 qp_num;
282 __u32 src_qp;
283 __u32 wc_flags;
284 __u16 pkey_index;
285 __u16 slid;
286 __u8 sl;
287 __u8 dlid_path_bits;
288 __u8 port_num;
289 __u8 reserved;
290};
291
292struct ib_uverbs_poll_cq_resp {
293 __u32 count;
294 __u32 reserved;
295 struct ib_uverbs_wc wc[0];
296};
297
298struct ib_uverbs_req_notify_cq {
299 __u32 cq_handle;
300 __u32 solicited_only;
301};
302
294struct ib_uverbs_destroy_cq { 303struct ib_uverbs_destroy_cq {
295 __u64 response; 304 __u64 response;
296 __u32 cq_handle; 305 __u32 cq_handle;
@@ -388,6 +397,127 @@ struct ib_uverbs_destroy_qp_resp {
388 __u32 events_reported; 397 __u32 events_reported;
389}; 398};
390 399
400/*
401 * The ib_uverbs_sge structure isn't used anywhere, since we assume
402 * the ib_sge structure is packed the same way on 32-bit and 64-bit
403 * architectures in both kernel and user space. It's just here to
404 * document the ABI.
405 */
406struct ib_uverbs_sge {
407 __u64 addr;
408 __u32 length;
409 __u32 lkey;
410};
411
412struct ib_uverbs_send_wr {
413 __u64 wr_id;
414 __u32 num_sge;
415 __u32 opcode;
416 __u32 send_flags;
417 __u32 imm_data;
418 union {
419 struct {
420 __u64 remote_addr;
421 __u32 rkey;
422 __u32 reserved;
423 } rdma;
424 struct {
425 __u64 remote_addr;
426 __u64 compare_add;
427 __u64 swap;
428 __u32 rkey;
429 __u32 reserved;
430 } atomic;
431 struct {
432 __u32 ah;
433 __u32 remote_qpn;
434 __u32 remote_qkey;
435 __u32 reserved;
436 } ud;
437 } wr;
438};
439
440struct ib_uverbs_post_send {
441 __u64 response;
442 __u32 qp_handle;
443 __u32 wr_count;
444 __u32 sge_count;
445 __u32 wqe_size;
446 struct ib_uverbs_send_wr send_wr[0];
447};
448
449struct ib_uverbs_post_send_resp {
450 __u32 bad_wr;
451};
452
453struct ib_uverbs_recv_wr {
454 __u64 wr_id;
455 __u32 num_sge;
456 __u32 reserved;
457};
458
459struct ib_uverbs_post_recv {
460 __u64 response;
461 __u32 qp_handle;
462 __u32 wr_count;
463 __u32 sge_count;
464 __u32 wqe_size;
465 struct ib_uverbs_recv_wr recv_wr[0];
466};
467
468struct ib_uverbs_post_recv_resp {
469 __u32 bad_wr;
470};
471
472struct ib_uverbs_post_srq_recv {
473 __u64 response;
474 __u32 srq_handle;
475 __u32 wr_count;
476 __u32 sge_count;
477 __u32 wqe_size;
478 struct ib_uverbs_recv_wr recv[0];
479};
480
481struct ib_uverbs_post_srq_recv_resp {
482 __u32 bad_wr;
483};
484
485struct ib_uverbs_global_route {
486 __u8 dgid[16];
487 __u32 flow_label;
488 __u8 sgid_index;
489 __u8 hop_limit;
490 __u8 traffic_class;
491 __u8 reserved;
492};
493
494struct ib_uverbs_ah_attr {
495 struct ib_uverbs_global_route grh;
496 __u16 dlid;
497 __u8 sl;
498 __u8 src_path_bits;
499 __u8 static_rate;
500 __u8 is_global;
501 __u8 port_num;
502 __u8 reserved;
503};
504
505struct ib_uverbs_create_ah {
506 __u64 response;
507 __u64 user_handle;
508 __u32 pd_handle;
509 __u32 reserved;
510 struct ib_uverbs_ah_attr attr;
511};
512
513struct ib_uverbs_create_ah_resp {
514 __u32 ah_handle;
515};
516
517struct ib_uverbs_destroy_ah {
518 __u32 ah_handle;
519};
520
391struct ib_uverbs_attach_mcast { 521struct ib_uverbs_attach_mcast {
392 __u8 gid[16]; 522 __u8 gid[16];
393 __u32 qp_handle; 523 __u32 qp_handle;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e6f4c9e55df7..f72d46d54e0a 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -595,11 +595,8 @@ struct ib_send_wr {
595 } atomic; 595 } atomic;
596 struct { 596 struct {
597 struct ib_ah *ah; 597 struct ib_ah *ah;
598 struct ib_mad_hdr *mad_hdr;
599 u32 remote_qpn; 598 u32 remote_qpn;
600 u32 remote_qkey; 599 u32 remote_qkey;
601 int timeout_ms; /* valid for MADs only */
602 int retries; /* valid for MADs only */
603 u16 pkey_index; /* valid for GSI only */ 600 u16 pkey_index; /* valid for GSI only */
604 u8 port_num; /* valid for DR SMPs on switch only */ 601 u8 port_num; /* valid for DR SMPs on switch only */
605 } ud; 602 } ud;
@@ -951,6 +948,9 @@ struct ib_device {
951 IB_DEV_UNREGISTERED 948 IB_DEV_UNREGISTERED
952 } reg_state; 949 } reg_state;
953 950
951 u64 uverbs_cmd_mask;
952 int uverbs_abi_ver;
953
954 u8 node_type; 954 u8 node_type;
955 u8 phys_port_cnt; 955 u8 phys_port_cnt;
956}; 956};
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index bed4b7c9be99..e6b61fab66dd 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -146,7 +146,7 @@ struct scsi_cmnd {
146#define SCSI_STATE_MLQUEUE 0x100b 146#define SCSI_STATE_MLQUEUE 0x100b
147 147
148 148
149extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, int); 149extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
150extern void scsi_put_command(struct scsi_cmnd *); 150extern void scsi_put_command(struct scsi_cmnd *);
151extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); 151extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
152extern void scsi_finish_command(struct scsi_cmnd *cmd); 152extern void scsi_finish_command(struct scsi_cmnd *cmd);
diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h
index 6a140020d7cb..2539debb7993 100644
--- a/include/scsi/scsi_request.h
+++ b/include/scsi/scsi_request.h
@@ -45,7 +45,7 @@ struct scsi_request {
45 level driver) of this request */ 45 level driver) of this request */
46}; 46};
47 47
48extern struct scsi_request *scsi_allocate_request(struct scsi_device *, int); 48extern struct scsi_request *scsi_allocate_request(struct scsi_device *, gfp_t);
49extern void scsi_release_request(struct scsi_request *); 49extern void scsi_release_request(struct scsi_request *);
50extern void scsi_wait_req(struct scsi_request *, const void *cmnd, 50extern void scsi_wait_req(struct scsi_request *, const void *cmnd,
51 void *buffer, unsigned bufflen, 51 void *buffer, unsigned bufflen,
diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h
index 3a2fd2cc9f19..83489c3abbaf 100644
--- a/include/sound/memalloc.h
+++ b/include/sound/memalloc.h
@@ -111,7 +111,7 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id);
111int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id); 111int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id);
112 112
113/* basic memory allocation functions */ 113/* basic memory allocation functions */
114void *snd_malloc_pages(size_t size, unsigned int gfp_flags); 114void *snd_malloc_pages(size_t size, gfp_t gfp_flags);
115void snd_free_pages(void *ptr, size_t size); 115void snd_free_pages(void *ptr, size_t size);
116 116
117#endif /* __SOUND_MEMALLOC_H */ 117#endif /* __SOUND_MEMALLOC_H */
diff --git a/kernel/audit.c b/kernel/audit.c
index aefa73a8a586..0c56320d38dc 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -133,7 +133,7 @@ struct audit_buffer {
133 struct list_head list; 133 struct list_head list;
134 struct sk_buff *skb; /* formatted skb ready to send */ 134 struct sk_buff *skb; /* formatted skb ready to send */
135 struct audit_context *ctx; /* NULL or associated context */ 135 struct audit_context *ctx; /* NULL or associated context */
136 int gfp_mask; 136 gfp_t gfp_mask;
137}; 137};
138 138
139static void audit_set_pid(struct audit_buffer *ab, pid_t pid) 139static void audit_set_pid(struct audit_buffer *ab, pid_t pid)
@@ -647,7 +647,7 @@ static inline void audit_get_stamp(struct audit_context *ctx,
647 * will be written at syscall exit. If there is no associated task, tsk 647 * will be written at syscall exit. If there is no associated task, tsk
648 * should be NULL. */ 648 * should be NULL. */
649 649
650struct audit_buffer *audit_log_start(struct audit_context *ctx, int gfp_mask, 650struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
651 int type) 651 int type)
652{ 652{
653 struct audit_buffer *ab = NULL; 653 struct audit_buffer *ab = NULL;
@@ -879,7 +879,7 @@ void audit_log_end(struct audit_buffer *ab)
879/* Log an audit record. This is a convenience function that calls 879/* Log an audit record. This is a convenience function that calls
880 * audit_log_start, audit_log_vformat, and audit_log_end. It may be 880 * audit_log_start, audit_log_vformat, and audit_log_end. It may be
881 * called in any context. */ 881 * called in any context. */
882void audit_log(struct audit_context *ctx, int gfp_mask, int type, 882void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type,
883 const char *fmt, ...) 883 const char *fmt, ...)
884{ 884{
885 struct audit_buffer *ab; 885 struct audit_buffer *ab;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 88696f639aab..d8a68509e729 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -803,7 +803,7 @@ static void audit_log_task_info(struct audit_buffer *ab)
803 up_read(&mm->mmap_sem); 803 up_read(&mm->mmap_sem);
804} 804}
805 805
806static void audit_log_exit(struct audit_context *context, unsigned int gfp_mask) 806static void audit_log_exit(struct audit_context *context, gfp_t gfp_mask)
807{ 807{
808 int i; 808 int i;
809 struct audit_buffer *ab; 809 struct audit_buffer *ab;
diff --git a/kernel/kexec.c b/kernel/kexec.c
index cdd4dcd8fb63..36c5d9cd4cc1 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -90,7 +90,7 @@ int kexec_should_crash(struct task_struct *p)
90static int kimage_is_destination_range(struct kimage *image, 90static int kimage_is_destination_range(struct kimage *image,
91 unsigned long start, unsigned long end); 91 unsigned long start, unsigned long end);
92static struct page *kimage_alloc_page(struct kimage *image, 92static struct page *kimage_alloc_page(struct kimage *image,
93 unsigned int gfp_mask, 93 gfp_t gfp_mask,
94 unsigned long dest); 94 unsigned long dest);
95 95
96static int do_kimage_alloc(struct kimage **rimage, unsigned long entry, 96static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
@@ -326,8 +326,7 @@ static int kimage_is_destination_range(struct kimage *image,
326 return 0; 326 return 0;
327} 327}
328 328
329static struct page *kimage_alloc_pages(unsigned int gfp_mask, 329static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order)
330 unsigned int order)
331{ 330{
332 struct page *pages; 331 struct page *pages;
333 332
@@ -654,7 +653,7 @@ static kimage_entry_t *kimage_dst_used(struct kimage *image,
654} 653}
655 654
656static struct page *kimage_alloc_page(struct kimage *image, 655static struct page *kimage_alloc_page(struct kimage *image,
657 unsigned int gfp_mask, 656 gfp_t gfp_mask,
658 unsigned long destination) 657 unsigned long destination)
659{ 658{
660 /* 659 /*
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 2d5c45676442..10bc5ec496d7 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -1095,7 +1095,7 @@ static inline void eat_page(void *page)
1095 *eaten_memory = c; 1095 *eaten_memory = c;
1096} 1096}
1097 1097
1098unsigned long get_usable_page(unsigned gfp_mask) 1098unsigned long get_usable_page(gfp_t gfp_mask)
1099{ 1099{
1100 unsigned long m; 1100 unsigned long m;
1101 1101
diff --git a/lib/idr.c b/lib/idr.c
index d4df21debc4d..6414b2fb482d 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -72,7 +72,7 @@ static void free_layer(struct idr *idp, struct idr_layer *p)
72 * If the system is REALLY out of memory this function returns 0, 72 * If the system is REALLY out of memory this function returns 0,
73 * otherwise 1. 73 * otherwise 1.
74 */ 74 */
75int idr_pre_get(struct idr *idp, unsigned gfp_mask) 75int idr_pre_get(struct idr *idp, gfp_t gfp_mask)
76{ 76{
77 while (idp->id_free_cnt < IDR_FREE_MAX) { 77 while (idp->id_free_cnt < IDR_FREE_MAX) {
78 struct idr_layer *new; 78 struct idr_layer *new;
diff --git a/lib/kobject.c b/lib/kobject.c
index dd0917dd9fa9..253d3004ace9 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -100,7 +100,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
100 * @kobj: kobject in question, with which to build the path 100 * @kobj: kobject in question, with which to build the path
101 * @gfp_mask: the allocation type used to allocate the path 101 * @gfp_mask: the allocation type used to allocate the path
102 */ 102 */
103char *kobject_get_path(struct kobject *kobj, int gfp_mask) 103char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
104{ 104{
105 char *path; 105 char *path;
106 int len; 106 int len;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 04ca4429ddfa..3ab375411e38 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -54,7 +54,7 @@ static char *action_to_string(enum kobject_action action)
54static struct sock *uevent_sock; 54static struct sock *uevent_sock;
55 55
56/** 56/**
57 * send_uevent - notify userspace by sending event trough netlink socket 57 * send_uevent - notify userspace by sending event through netlink socket
58 * 58 *
59 * @signal: signal name 59 * @signal: signal name
60 * @obj: object path (kobject) 60 * @obj: object path (kobject)
@@ -62,7 +62,7 @@ static struct sock *uevent_sock;
62 * @gfp_mask: 62 * @gfp_mask:
63 */ 63 */
64static int send_uevent(const char *signal, const char *obj, 64static int send_uevent(const char *signal, const char *obj,
65 char **envp, int gfp_mask) 65 char **envp, gfp_t gfp_mask)
66{ 66{
67 struct sk_buff *skb; 67 struct sk_buff *skb;
68 char *pos; 68 char *pos;
@@ -98,7 +98,7 @@ static int send_uevent(const char *signal, const char *obj,
98} 98}
99 99
100static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action, 100static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action,
101 struct attribute *attr, int gfp_mask) 101 struct attribute *attr, gfp_t gfp_mask)
102{ 102{
103 char *path; 103 char *path;
104 char *attrpath; 104 char *attrpath;
diff --git a/lib/textsearch.c b/lib/textsearch.c
index 1e934c196f0f..6f3093efbd7b 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -254,7 +254,7 @@ unsigned int textsearch_find_continuous(struct ts_config *conf,
254 * parameters or a ERR_PTR(). 254 * parameters or a ERR_PTR().
255 */ 255 */
256struct ts_config *textsearch_prepare(const char *algo, const void *pattern, 256struct ts_config *textsearch_prepare(const char *algo, const void *pattern,
257 unsigned int len, int gfp_mask, int flags) 257 unsigned int len, gfp_t gfp_mask, int flags)
258{ 258{
259 int err = -ENOENT; 259 int err = -ENOENT;
260 struct ts_config *conf; 260 struct ts_config *conf;
diff --git a/mm/filemap.c b/mm/filemap.c
index b5346576e58d..1c31b2fd2ca5 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -377,7 +377,7 @@ int filemap_write_and_wait_range(struct address_space *mapping,
377 * This function does not add the page to the LRU. The caller must do that. 377 * This function does not add the page to the LRU. The caller must do that.
378 */ 378 */
379int add_to_page_cache(struct page *page, struct address_space *mapping, 379int add_to_page_cache(struct page *page, struct address_space *mapping,
380 pgoff_t offset, int gfp_mask) 380 pgoff_t offset, gfp_t gfp_mask)
381{ 381{
382 int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); 382 int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
383 383
@@ -401,7 +401,7 @@ int add_to_page_cache(struct page *page, struct address_space *mapping,
401EXPORT_SYMBOL(add_to_page_cache); 401EXPORT_SYMBOL(add_to_page_cache);
402 402
403int add_to_page_cache_lru(struct page *page, struct address_space *mapping, 403int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
404 pgoff_t offset, int gfp_mask) 404 pgoff_t offset, gfp_t gfp_mask)
405{ 405{
406 int ret = add_to_page_cache(page, mapping, offset, gfp_mask); 406 int ret = add_to_page_cache(page, mapping, offset, gfp_mask);
407 if (ret == 0) 407 if (ret == 0)
@@ -591,7 +591,7 @@ EXPORT_SYMBOL(find_lock_page);
591 * memory exhaustion. 591 * memory exhaustion.
592 */ 592 */
593struct page *find_or_create_page(struct address_space *mapping, 593struct page *find_or_create_page(struct address_space *mapping,
594 unsigned long index, unsigned int gfp_mask) 594 unsigned long index, gfp_t gfp_mask)
595{ 595{
596 struct page *page, *cached_page = NULL; 596 struct page *page, *cached_page = NULL;
597 int err; 597 int err;
@@ -683,7 +683,7 @@ struct page *
683grab_cache_page_nowait(struct address_space *mapping, unsigned long index) 683grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
684{ 684{
685 struct page *page = find_get_page(mapping, index); 685 struct page *page = find_get_page(mapping, index);
686 unsigned int gfp_mask; 686 gfp_t gfp_mask;
687 687
688 if (page) { 688 if (page) {
689 if (!TestSetPageLocked(page)) 689 if (!TestSetPageLocked(page))
diff --git a/mm/highmem.c b/mm/highmem.c
index 90e1861e2da0..ce2e7e8bbfa7 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -30,11 +30,9 @@
30 30
31static mempool_t *page_pool, *isa_page_pool; 31static mempool_t *page_pool, *isa_page_pool;
32 32
33static void *page_pool_alloc(gfp_t gfp_mask, void *data) 33static void *page_pool_alloc_isa(gfp_t gfp_mask, void *data)
34{ 34{
35 unsigned int gfp = gfp_mask | (unsigned int) (long) data; 35 return alloc_page(gfp_mask | GFP_DMA);
36
37 return alloc_page(gfp);
38} 36}
39 37
40static void page_pool_free(void *page, void *data) 38static void page_pool_free(void *page, void *data)
@@ -51,6 +49,12 @@ static void page_pool_free(void *page, void *data)
51 * n means that there are (n-1) current users of it. 49 * n means that there are (n-1) current users of it.
52 */ 50 */
53#ifdef CONFIG_HIGHMEM 51#ifdef CONFIG_HIGHMEM
52
53static void *page_pool_alloc(gfp_t gfp_mask, void *data)
54{
55 return alloc_page(gfp_mask);
56}
57
54static int pkmap_count[LAST_PKMAP]; 58static int pkmap_count[LAST_PKMAP];
55static unsigned int last_pkmap_nr; 59static unsigned int last_pkmap_nr;
56static __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock); 60static __cacheline_aligned_in_smp DEFINE_SPINLOCK(kmap_lock);
@@ -267,7 +271,7 @@ int init_emergency_isa_pool(void)
267 if (isa_page_pool) 271 if (isa_page_pool)
268 return 0; 272 return 0;
269 273
270 isa_page_pool = mempool_create(ISA_POOL_SIZE, page_pool_alloc, page_pool_free, (void *) __GFP_DMA); 274 isa_page_pool = mempool_create(ISA_POOL_SIZE, page_pool_alloc_isa, page_pool_free, NULL);
271 if (!isa_page_pool) 275 if (!isa_page_pool)
272 BUG(); 276 BUG();
273 277
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 37af443eb094..1d5c64df1653 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -700,7 +700,7 @@ static struct zonelist *zonelist_policy(gfp_t gfp, struct mempolicy *policy)
700 case MPOL_BIND: 700 case MPOL_BIND:
701 /* Lower zones don't get a policy applied */ 701 /* Lower zones don't get a policy applied */
702 /* Careful: current->mems_allowed might have moved */ 702 /* Careful: current->mems_allowed might have moved */
703 if ((gfp & GFP_ZONEMASK) >= policy_zone) 703 if (gfp_zone(gfp) >= policy_zone)
704 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist)) 704 if (cpuset_zonelist_valid_mems_allowed(policy->v.zonelist))
705 return policy->v.zonelist; 705 return policy->v.zonelist;
706 /*FALL THROUGH*/ 706 /*FALL THROUGH*/
@@ -712,7 +712,7 @@ static struct zonelist *zonelist_policy(gfp_t gfp, struct mempolicy *policy)
712 nd = 0; 712 nd = 0;
713 BUG(); 713 BUG();
714 } 714 }
715 return NODE_DATA(nd)->node_zonelists + (gfp & GFP_ZONEMASK); 715 return NODE_DATA(nd)->node_zonelists + gfp_zone(gfp);
716} 716}
717 717
718/* Do dynamic interleaving for a process */ 718/* Do dynamic interleaving for a process */
@@ -757,7 +757,7 @@ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order, unsigned ni
757 struct page *page; 757 struct page *page;
758 758
759 BUG_ON(!node_online(nid)); 759 BUG_ON(!node_online(nid));
760 zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK); 760 zl = NODE_DATA(nid)->node_zonelists + gfp_zone(gfp);
761 page = __alloc_pages(gfp, order, zl); 761 page = __alloc_pages(gfp, order, zl);
762 if (page && page_zone(page) == zl->zones[0]) { 762 if (page && page_zone(page) == zl->zones[0]) {
763 zone_pcp(zl->zones[0],get_cpu())->interleave_hit++; 763 zone_pcp(zl->zones[0],get_cpu())->interleave_hit++;
diff --git a/mm/mempool.c b/mm/mempool.c
index 9e377ea700b2..1a99b80480d3 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -205,7 +205,7 @@ void * mempool_alloc(mempool_t *pool, gfp_t gfp_mask)
205 void *element; 205 void *element;
206 unsigned long flags; 206 unsigned long flags;
207 wait_queue_t wait; 207 wait_queue_t wait;
208 unsigned int gfp_temp; 208 gfp_t gfp_temp;
209 209
210 might_sleep_if(gfp_mask & __GFP_WAIT); 210 might_sleep_if(gfp_mask & __GFP_WAIT);
211 211
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e1d3d77f4aee..94c864eac9c4 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -734,7 +734,7 @@ buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags)
734 * of the allocation. 734 * of the allocation.
735 */ 735 */
736int zone_watermark_ok(struct zone *z, int order, unsigned long mark, 736int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
737 int classzone_idx, int can_try_harder, int gfp_high) 737 int classzone_idx, int can_try_harder, gfp_t gfp_high)
738{ 738{
739 /* free_pages my go negative - that's OK */ 739 /* free_pages my go negative - that's OK */
740 long min = mark, free_pages = z->free_pages - (1 << order) + 1; 740 long min = mark, free_pages = z->free_pages - (1 << order) + 1;
@@ -777,7 +777,7 @@ struct page * fastcall
777__alloc_pages(gfp_t gfp_mask, unsigned int order, 777__alloc_pages(gfp_t gfp_mask, unsigned int order,
778 struct zonelist *zonelist) 778 struct zonelist *zonelist)
779{ 779{
780 const int wait = gfp_mask & __GFP_WAIT; 780 const gfp_t wait = gfp_mask & __GFP_WAIT;
781 struct zone **zones, *z; 781 struct zone **zones, *z;
782 struct page *page; 782 struct page *page;
783 struct reclaim_state reclaim_state; 783 struct reclaim_state reclaim_state;
@@ -996,7 +996,7 @@ fastcall unsigned long get_zeroed_page(gfp_t gfp_mask)
996 * get_zeroed_page() returns a 32-bit address, which cannot represent 996 * get_zeroed_page() returns a 32-bit address, which cannot represent
997 * a highmem page 997 * a highmem page
998 */ 998 */
999 BUG_ON(gfp_mask & __GFP_HIGHMEM); 999 BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
1000 1000
1001 page = alloc_pages(gfp_mask | __GFP_ZERO, 0); 1001 page = alloc_pages(gfp_mask | __GFP_ZERO, 0);
1002 if (page) 1002 if (page)
@@ -1089,7 +1089,7 @@ static unsigned int nr_free_zone_pages(int offset)
1089 */ 1089 */
1090unsigned int nr_free_buffer_pages(void) 1090unsigned int nr_free_buffer_pages(void)
1091{ 1091{
1092 return nr_free_zone_pages(GFP_USER & GFP_ZONEMASK); 1092 return nr_free_zone_pages(gfp_zone(GFP_USER));
1093} 1093}
1094 1094
1095/* 1095/*
@@ -1097,7 +1097,7 @@ unsigned int nr_free_buffer_pages(void)
1097 */ 1097 */
1098unsigned int nr_free_pagecache_pages(void) 1098unsigned int nr_free_pagecache_pages(void)
1099{ 1099{
1100 return nr_free_zone_pages(GFP_HIGHUSER & GFP_ZONEMASK); 1100 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER));
1101} 1101}
1102 1102
1103#ifdef CONFIG_HIGHMEM 1103#ifdef CONFIG_HIGHMEM
@@ -1428,6 +1428,16 @@ static int __init build_zonelists_node(pg_data_t *pgdat, struct zonelist *zoneli
1428 return j; 1428 return j;
1429} 1429}
1430 1430
1431static inline int highest_zone(int zone_bits)
1432{
1433 int res = ZONE_NORMAL;
1434 if (zone_bits & (__force int)__GFP_HIGHMEM)
1435 res = ZONE_HIGHMEM;
1436 if (zone_bits & (__force int)__GFP_DMA)
1437 res = ZONE_DMA;
1438 return res;
1439}
1440
1431#ifdef CONFIG_NUMA 1441#ifdef CONFIG_NUMA
1432#define MAX_NODE_LOAD (num_online_nodes()) 1442#define MAX_NODE_LOAD (num_online_nodes())
1433static int __initdata node_load[MAX_NUMNODES]; 1443static int __initdata node_load[MAX_NUMNODES];
@@ -1524,11 +1534,7 @@ static void __init build_zonelists(pg_data_t *pgdat)
1524 zonelist = pgdat->node_zonelists + i; 1534 zonelist = pgdat->node_zonelists + i;
1525 for (j = 0; zonelist->zones[j] != NULL; j++); 1535 for (j = 0; zonelist->zones[j] != NULL; j++);
1526 1536
1527 k = ZONE_NORMAL; 1537 k = highest_zone(i);
1528 if (i & __GFP_HIGHMEM)
1529 k = ZONE_HIGHMEM;
1530 if (i & __GFP_DMA)
1531 k = ZONE_DMA;
1532 1538
1533 j = build_zonelists_node(NODE_DATA(node), zonelist, j, k); 1539 j = build_zonelists_node(NODE_DATA(node), zonelist, j, k);
1534 zonelist->zones[j] = NULL; 1540 zonelist->zones[j] = NULL;
@@ -1549,12 +1555,7 @@ static void __init build_zonelists(pg_data_t *pgdat)
1549 zonelist = pgdat->node_zonelists + i; 1555 zonelist = pgdat->node_zonelists + i;
1550 1556
1551 j = 0; 1557 j = 0;
1552 k = ZONE_NORMAL; 1558 k = highest_zone(i);
1553 if (i & __GFP_HIGHMEM)
1554 k = ZONE_HIGHMEM;
1555 if (i & __GFP_DMA)
1556 k = ZONE_DMA;
1557
1558 j = build_zonelists_node(pgdat, zonelist, j, k); 1559 j = build_zonelists_node(pgdat, zonelist, j, k);
1559 /* 1560 /*
1560 * Now we build the zonelist so that it contains the zones 1561 * Now we build the zonelist so that it contains the zones
diff --git a/mm/shmem.c b/mm/shmem.c
index ea064d89cda9..55e04a0734c1 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -85,7 +85,7 @@ enum sgp_type {
85static int shmem_getpage(struct inode *inode, unsigned long idx, 85static int shmem_getpage(struct inode *inode, unsigned long idx,
86 struct page **pagep, enum sgp_type sgp, int *type); 86 struct page **pagep, enum sgp_type sgp, int *type);
87 87
88static inline struct page *shmem_dir_alloc(unsigned int gfp_mask) 88static inline struct page *shmem_dir_alloc(gfp_t gfp_mask)
89{ 89{
90 /* 90 /*
91 * The above definition of ENTRIES_PER_PAGE, and the use of 91 * The above definition of ENTRIES_PER_PAGE, and the use of
@@ -898,7 +898,7 @@ struct page *shmem_swapin(struct shmem_inode_info *info, swp_entry_t entry,
898} 898}
899 899
900static struct page * 900static struct page *
901shmem_alloc_page(unsigned long gfp, struct shmem_inode_info *info, 901shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info,
902 unsigned long idx) 902 unsigned long idx)
903{ 903{
904 struct vm_area_struct pvma; 904 struct vm_area_struct pvma;
diff --git a/mm/slab.c b/mm/slab.c
index d05c678bceb3..d30423f167a2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -386,7 +386,7 @@ struct kmem_cache_s {
386 unsigned int gfporder; 386 unsigned int gfporder;
387 387
388 /* force GFP flags, e.g. GFP_DMA */ 388 /* force GFP flags, e.g. GFP_DMA */
389 unsigned int gfpflags; 389 gfp_t gfpflags;
390 390
391 size_t colour; /* cache colouring range */ 391 size_t colour; /* cache colouring range */
392 unsigned int colour_off; /* colour offset */ 392 unsigned int colour_off; /* colour offset */
@@ -2117,7 +2117,7 @@ static void cache_init_objs(kmem_cache_t *cachep,
2117 slabp->free = 0; 2117 slabp->free = 0;
2118} 2118}
2119 2119
2120static void kmem_flagcheck(kmem_cache_t *cachep, unsigned int flags) 2120static void kmem_flagcheck(kmem_cache_t *cachep, gfp_t flags)
2121{ 2121{
2122 if (flags & SLAB_DMA) { 2122 if (flags & SLAB_DMA) {
2123 if (!(cachep->gfpflags & GFP_DMA)) 2123 if (!(cachep->gfpflags & GFP_DMA))
@@ -2152,7 +2152,7 @@ static int cache_grow(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2152 struct slab *slabp; 2152 struct slab *slabp;
2153 void *objp; 2153 void *objp;
2154 size_t offset; 2154 size_t offset;
2155 unsigned int local_flags; 2155 gfp_t local_flags;
2156 unsigned long ctor_flags; 2156 unsigned long ctor_flags;
2157 struct kmem_list3 *l3; 2157 struct kmem_list3 *l3;
2158 2158
@@ -2546,7 +2546,7 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, gfp_t flags)
2546/* 2546/*
2547 * A interface to enable slab creation on nodeid 2547 * A interface to enable slab creation on nodeid
2548 */ 2548 */
2549static void *__cache_alloc_node(kmem_cache_t *cachep, int flags, int nodeid) 2549static void *__cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int nodeid)
2550{ 2550{
2551 struct list_head *entry; 2551 struct list_head *entry;
2552 struct slab *slabp; 2552 struct slab *slabp;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 64f9570cff56..843c87d1e61f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -70,7 +70,7 @@ struct scan_control {
70 unsigned int priority; 70 unsigned int priority;
71 71
72 /* This context's GFP mask */ 72 /* This context's GFP mask */
73 unsigned int gfp_mask; 73 gfp_t gfp_mask;
74 74
75 int may_writepage; 75 int may_writepage;
76 76
@@ -186,7 +186,7 @@ EXPORT_SYMBOL(remove_shrinker);
186 * 186 *
187 * Returns the number of slab objects which we shrunk. 187 * Returns the number of slab objects which we shrunk.
188 */ 188 */
189static int shrink_slab(unsigned long scanned, unsigned int gfp_mask, 189static int shrink_slab(unsigned long scanned, gfp_t gfp_mask,
190 unsigned long lru_pages) 190 unsigned long lru_pages)
191{ 191{
192 struct shrinker *shrinker; 192 struct shrinker *shrinker;
@@ -926,7 +926,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc)
926 * holds filesystem locks which prevent writeout this might not work, and the 926 * holds filesystem locks which prevent writeout this might not work, and the
927 * allocation attempt will fail. 927 * allocation attempt will fail.
928 */ 928 */
929int try_to_free_pages(struct zone **zones, unsigned int gfp_mask) 929int try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
930{ 930{
931 int priority; 931 int priority;
932 int ret = 0; 932 int ret = 0;
@@ -1338,7 +1338,7 @@ module_init(kswapd_init)
1338/* 1338/*
1339 * Try to free up some pages from this zone through reclaim. 1339 * Try to free up some pages from this zone through reclaim.
1340 */ 1340 */
1341int zone_reclaim(struct zone *zone, unsigned int gfp_mask, unsigned int order) 1341int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
1342{ 1342{
1343 struct scan_control sc; 1343 struct scan_control sc;
1344 int nr_pages = 1 << order; 1344 int nr_pages = 1 << order;
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 12b43345b54f..03532062a46a 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -308,12 +308,6 @@ static struct net_proto_family bt_sock_family_ops = {
308 .create = bt_sock_create, 308 .create = bt_sock_create,
309}; 309};
310 310
311extern int hci_sock_init(void);
312extern int hci_sock_cleanup(void);
313
314extern int bt_sysfs_init(void);
315extern int bt_sysfs_cleanup(void);
316
317static int __init bt_init(void) 311static int __init bt_init(void)
318{ 312{
319 BT_INFO("Core ver %s", VERSION); 313 BT_INFO("Core ver %s", VERSION);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 55dc42eac92c..cf0df1c8c933 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -87,7 +87,7 @@ int hci_unregister_notifier(struct notifier_block *nb)
87 return notifier_chain_unregister(&hci_notifier, nb); 87 return notifier_chain_unregister(&hci_notifier, nb);
88} 88}
89 89
90void hci_notify(struct hci_dev *hdev, int event) 90static void hci_notify(struct hci_dev *hdev, int event)
91{ 91{
92 notifier_call_chain(&hci_notifier, event, hdev); 92 notifier_call_chain(&hci_notifier, event, hdev);
93} 93}
@@ -1347,7 +1347,7 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
1347 kfree_skb(skb); 1347 kfree_skb(skb);
1348} 1348}
1349 1349
1350void hci_rx_task(unsigned long arg) 1350static void hci_rx_task(unsigned long arg)
1351{ 1351{
1352 struct hci_dev *hdev = (struct hci_dev *) arg; 1352 struct hci_dev *hdev = (struct hci_dev *) arg;
1353 struct sk_buff *skb; 1353 struct sk_buff *skb;
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 32ef7975a139..799e448750ad 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -66,20 +66,20 @@ static struct hci_sec_filter hci_sec_filter = {
66 /* Packet types */ 66 /* Packet types */
67 0x10, 67 0x10,
68 /* Events */ 68 /* Events */
69 { 0x1000d9fe, 0x0000300c }, 69 { 0x1000d9fe, 0x0000b00c },
70 /* Commands */ 70 /* Commands */
71 { 71 {
72 { 0x0 }, 72 { 0x0 },
73 /* OGF_LINK_CTL */ 73 /* OGF_LINK_CTL */
74 { 0xbe000006, 0x00000001, 0x0000, 0x00 }, 74 { 0xbe000006, 0x00000001, 0x000000, 0x00 },
75 /* OGF_LINK_POLICY */ 75 /* OGF_LINK_POLICY */
76 { 0x00005200, 0x00000000, 0x0000, 0x00 }, 76 { 0x00005200, 0x00000000, 0x000000, 0x00 },
77 /* OGF_HOST_CTL */ 77 /* OGF_HOST_CTL */
78 { 0xaab00200, 0x2b402aaa, 0x0154, 0x00 }, 78 { 0xaab00200, 0x2b402aaa, 0x020154, 0x00 },
79 /* OGF_INFO_PARAM */ 79 /* OGF_INFO_PARAM */
80 { 0x000002be, 0x00000000, 0x0000, 0x00 }, 80 { 0x000002be, 0x00000000, 0x000000, 0x00 },
81 /* OGF_STATUS_PARAM */ 81 /* OGF_STATUS_PARAM */
82 { 0x000000ea, 0x00000000, 0x0000, 0x00 } 82 { 0x000000ea, 0x00000000, 0x000000, 0x00 }
83 } 83 }
84}; 84};
85 85
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index de8af5f42394..860444a7fc0f 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -520,7 +520,7 @@ static int hidp_session(void *arg)
520 520
521 if (session->input) { 521 if (session->input) {
522 input_unregister_device(session->input); 522 input_unregister_device(session->input);
523 kfree(session->input); 523 session->input = NULL;
524 } 524 }
525 525
526 up_write(&hidp_session_sem); 526 up_write(&hidp_session_sem);
@@ -536,6 +536,8 @@ static inline void hidp_setup_input(struct hidp_session *session, struct hidp_co
536 536
537 input->private = session; 537 input->private = session;
538 538
539 input->name = "Bluetooth HID Boot Protocol Device";
540
539 input->id.bustype = BUS_BLUETOOTH; 541 input->id.bustype = BUS_BLUETOOTH;
540 input->id.vendor = req->vendor; 542 input->id.vendor = req->vendor;
541 input->id.product = req->product; 543 input->id.product = req->product;
@@ -582,16 +584,15 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
582 return -ENOTUNIQ; 584 return -ENOTUNIQ;
583 585
584 session = kmalloc(sizeof(struct hidp_session), GFP_KERNEL); 586 session = kmalloc(sizeof(struct hidp_session), GFP_KERNEL);
585 if (!session) 587 if (!session)
586 return -ENOMEM; 588 return -ENOMEM;
587 memset(session, 0, sizeof(struct hidp_session)); 589 memset(session, 0, sizeof(struct hidp_session));
588 590
589 session->input = kmalloc(sizeof(struct input_dev), GFP_KERNEL); 591 session->input = input_allocate_device();
590 if (!session->input) { 592 if (!session->input) {
591 kfree(session); 593 kfree(session);
592 return -ENOMEM; 594 return -ENOMEM;
593 } 595 }
594 memset(session->input, 0, sizeof(struct input_dev));
595 596
596 down_write(&hidp_session_sem); 597 down_write(&hidp_session_sem);
597 598
@@ -651,8 +652,10 @@ unlink:
651 652
652 __hidp_unlink_session(session); 653 __hidp_unlink_session(session);
653 654
654 if (session->input) 655 if (session->input) {
655 input_unregister_device(session->input); 656 input_unregister_device(session->input);
657 session->input = NULL; /* don't try to free it here */
658 }
656 659
657failed: 660failed:
658 up_write(&hidp_session_sem); 661 up_write(&hidp_session_sem);
diff --git a/net/bluetooth/rfcomm/Makefile b/net/bluetooth/rfcomm/Makefile
index aecec45ec68d..fe07988a3705 100644
--- a/net/bluetooth/rfcomm/Makefile
+++ b/net/bluetooth/rfcomm/Makefile
@@ -4,5 +4,5 @@
4 4
5obj-$(CONFIG_BT_RFCOMM) += rfcomm.o 5obj-$(CONFIG_BT_RFCOMM) += rfcomm.o
6 6
7rfcomm-y := core.o sock.o crc.o 7rfcomm-y := core.o sock.o
8rfcomm-$(CONFIG_BT_RFCOMM_TTY) += tty.o 8rfcomm-$(CONFIG_BT_RFCOMM_TTY) += tty.o
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 35adce6482b6..c3d56ead840c 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -133,6 +133,49 @@ static inline void rfcomm_session_put(struct rfcomm_session *s)
133 133
134/* ---- RFCOMM FCS computation ---- */ 134/* ---- RFCOMM FCS computation ---- */
135 135
136/* reversed, 8-bit, poly=0x07 */
137static unsigned char rfcomm_crc_table[256] = {
138 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
139 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
140 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
141 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67,
142
143 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d,
144 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43,
145 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51,
146 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f,
147
148 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05,
149 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b,
150 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19,
151 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17,
152
153 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d,
154 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33,
155 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21,
156 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f,
157
158 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95,
159 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b,
160 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89,
161 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87,
162
163 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad,
164 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3,
165 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1,
166 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf,
167
168 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5,
169 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb,
170 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9,
171 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7,
172
173 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd,
174 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3,
175 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1,
176 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
177};
178
136/* CRC on 2 bytes */ 179/* CRC on 2 bytes */
137#define __crc(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]]) 180#define __crc(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]])
138 181
diff --git a/net/bluetooth/rfcomm/crc.c b/net/bluetooth/rfcomm/crc.c
deleted file mode 100644
index 1011bc4a8692..000000000000
--- a/net/bluetooth/rfcomm/crc.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 RFCOMM implementation for Linux Bluetooth stack (BlueZ).
3 Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation;
9
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
13 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
14 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
15 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
20 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
21 SOFTWARE IS DISCLAIMED.
22*/
23
24/*
25 * RFCOMM FCS calculation.
26 *
27 * $Id: crc.c,v 1.2 2002/09/21 09:54:32 holtmann Exp $
28 */
29
30/* reversed, 8-bit, poly=0x07 */
31unsigned char rfcomm_crc_table[256] = {
32 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
33 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
34 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
35 0x12, 0x83, 0xf1, 0x60, 0x15, 0x84, 0xf6, 0x67,
36
37 0x38, 0xa9, 0xdb, 0x4a, 0x3f, 0xae, 0xdc, 0x4d,
38 0x36, 0xa7, 0xd5, 0x44, 0x31, 0xa0, 0xd2, 0x43,
39 0x24, 0xb5, 0xc7, 0x56, 0x23, 0xb2, 0xc0, 0x51,
40 0x2a, 0xbb, 0xc9, 0x58, 0x2d, 0xbc, 0xce, 0x5f,
41
42 0x70, 0xe1, 0x93, 0x02, 0x77, 0xe6, 0x94, 0x05,
43 0x7e, 0xef, 0x9d, 0x0c, 0x79, 0xe8, 0x9a, 0x0b,
44 0x6c, 0xfd, 0x8f, 0x1e, 0x6b, 0xfa, 0x88, 0x19,
45 0x62, 0xf3, 0x81, 0x10, 0x65, 0xf4, 0x86, 0x17,
46
47 0x48, 0xd9, 0xab, 0x3a, 0x4f, 0xde, 0xac, 0x3d,
48 0x46, 0xd7, 0xa5, 0x34, 0x41, 0xd0, 0xa2, 0x33,
49 0x54, 0xc5, 0xb7, 0x26, 0x53, 0xc2, 0xb0, 0x21,
50 0x5a, 0xcb, 0xb9, 0x28, 0x5d, 0xcc, 0xbe, 0x2f,
51
52 0xe0, 0x71, 0x03, 0x92, 0xe7, 0x76, 0x04, 0x95,
53 0xee, 0x7f, 0x0d, 0x9c, 0xe9, 0x78, 0x0a, 0x9b,
54 0xfc, 0x6d, 0x1f, 0x8e, 0xfb, 0x6a, 0x18, 0x89,
55 0xf2, 0x63, 0x11, 0x80, 0xf5, 0x64, 0x16, 0x87,
56
57 0xd8, 0x49, 0x3b, 0xaa, 0xdf, 0x4e, 0x3c, 0xad,
58 0xd6, 0x47, 0x35, 0xa4, 0xd1, 0x40, 0x32, 0xa3,
59 0xc4, 0x55, 0x27, 0xb6, 0xc3, 0x52, 0x20, 0xb1,
60 0xca, 0x5b, 0x29, 0xb8, 0xcd, 0x5c, 0x2e, 0xbf,
61
62 0x90, 0x01, 0x73, 0xe2, 0x97, 0x06, 0x74, 0xe5,
63 0x9e, 0x0f, 0x7d, 0xec, 0x99, 0x08, 0x7a, 0xeb,
64 0x8c, 0x1d, 0x6f, 0xfe, 0x8b, 0x1a, 0x68, 0xf9,
65 0x82, 0x13, 0x61, 0xf0, 0x85, 0x14, 0x66, 0xf7,
66
67 0xa8, 0x39, 0x4b, 0xda, 0xaf, 0x3e, 0x4c, 0xdd,
68 0xa6, 0x37, 0x45, 0xd4, 0xa1, 0x30, 0x42, 0xd3,
69 0xb4, 0x25, 0x57, 0xc6, 0xb3, 0x22, 0x50, 0xc1,
70 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
71};
diff --git a/net/core/dev.c b/net/core/dev.c
index a44eeef24edf..8d1541595277 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2717,6 +2717,20 @@ int register_netdevice(struct net_device *dev)
2717 dev->name); 2717 dev->name);
2718 dev->features &= ~NETIF_F_TSO; 2718 dev->features &= ~NETIF_F_TSO;
2719 } 2719 }
2720 if (dev->features & NETIF_F_UFO) {
2721 if (!(dev->features & NETIF_F_HW_CSUM)) {
2722 printk(KERN_ERR "%s: Dropping NETIF_F_UFO since no "
2723 "NETIF_F_HW_CSUM feature.\n",
2724 dev->name);
2725 dev->features &= ~NETIF_F_UFO;
2726 }
2727 if (!(dev->features & NETIF_F_SG)) {
2728 printk(KERN_ERR "%s: Dropping NETIF_F_UFO since no "
2729 "NETIF_F_SG feature.\n",
2730 dev->name);
2731 dev->features &= ~NETIF_F_UFO;
2732 }
2733 }
2720 2734
2721 /* 2735 /*
2722 * nil rebuild_header routine, 2736 * nil rebuild_header routine,
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 404b761e82ce..0350586e9195 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -93,6 +93,20 @@ int ethtool_op_get_perm_addr(struct net_device *dev, struct ethtool_perm_addr *a
93} 93}
94 94
95 95
96u32 ethtool_op_get_ufo(struct net_device *dev)
97{
98 return (dev->features & NETIF_F_UFO) != 0;
99}
100
101int ethtool_op_set_ufo(struct net_device *dev, u32 data)
102{
103 if (data)
104 dev->features |= NETIF_F_UFO;
105 else
106 dev->features &= ~NETIF_F_UFO;
107 return 0;
108}
109
96/* Handlers for each ethtool command */ 110/* Handlers for each ethtool command */
97 111
98static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) 112static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
@@ -483,6 +497,11 @@ static int __ethtool_set_sg(struct net_device *dev, u32 data)
483 return err; 497 return err;
484 } 498 }
485 499
500 if (!data && dev->ethtool_ops->set_ufo) {
501 err = dev->ethtool_ops->set_ufo(dev, 0);
502 if (err)
503 return err;
504 }
486 return dev->ethtool_ops->set_sg(dev, data); 505 return dev->ethtool_ops->set_sg(dev, data);
487} 506}
488 507
@@ -569,6 +588,32 @@ static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
569 return dev->ethtool_ops->set_tso(dev, edata.data); 588 return dev->ethtool_ops->set_tso(dev, edata.data);
570} 589}
571 590
591static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
592{
593 struct ethtool_value edata = { ETHTOOL_GTSO };
594
595 if (!dev->ethtool_ops->get_ufo)
596 return -EOPNOTSUPP;
597 edata.data = dev->ethtool_ops->get_ufo(dev);
598 if (copy_to_user(useraddr, &edata, sizeof(edata)))
599 return -EFAULT;
600 return 0;
601}
602static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
603{
604 struct ethtool_value edata;
605
606 if (!dev->ethtool_ops->set_ufo)
607 return -EOPNOTSUPP;
608 if (copy_from_user(&edata, useraddr, sizeof(edata)))
609 return -EFAULT;
610 if (edata.data && !(dev->features & NETIF_F_SG))
611 return -EINVAL;
612 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
613 return -EINVAL;
614 return dev->ethtool_ops->set_ufo(dev, edata.data);
615}
616
572static int ethtool_self_test(struct net_device *dev, char __user *useraddr) 617static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
573{ 618{
574 struct ethtool_test test; 619 struct ethtool_test test;
@@ -854,6 +899,12 @@ int dev_ethtool(struct ifreq *ifr)
854 case ETHTOOL_GPERMADDR: 899 case ETHTOOL_GPERMADDR:
855 rc = ethtool_get_perm_addr(dev, useraddr); 900 rc = ethtool_get_perm_addr(dev, useraddr);
856 break; 901 break;
902 case ETHTOOL_GUFO:
903 rc = ethtool_get_ufo(dev, useraddr);
904 break;
905 case ETHTOOL_SUFO:
906 rc = ethtool_set_ufo(dev, useraddr);
907 break;
857 default: 908 default:
858 rc = -EOPNOTSUPP; 909 rc = -EOPNOTSUPP;
859 } 910 }
@@ -882,3 +933,5 @@ EXPORT_SYMBOL(ethtool_op_set_sg);
882EXPORT_SYMBOL(ethtool_op_set_tso); 933EXPORT_SYMBOL(ethtool_op_set_tso);
883EXPORT_SYMBOL(ethtool_op_set_tx_csum); 934EXPORT_SYMBOL(ethtool_op_set_tx_csum);
884EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum); 935EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
936EXPORT_SYMBOL(ethtool_op_set_ufo);
937EXPORT_SYMBOL(ethtool_op_get_ufo);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 1dcf7fa1f0fe..e68700f950a5 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1625,12 +1625,9 @@ static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb,
1625 1625
1626 memset(&ndst, 0, sizeof(ndst)); 1626 memset(&ndst, 0, sizeof(ndst));
1627 1627
1628 for (cpu = 0; cpu < NR_CPUS; cpu++) { 1628 for_each_cpu(cpu) {
1629 struct neigh_statistics *st; 1629 struct neigh_statistics *st;
1630 1630
1631 if (!cpu_possible(cpu))
1632 continue;
1633
1634 st = per_cpu_ptr(tbl->stats, cpu); 1631 st = per_cpu_ptr(tbl->stats, cpu);
1635 ndst.ndts_allocs += st->allocs; 1632 ndst.ndts_allocs += st->allocs;
1636 ndst.ndts_destroys += st->destroys; 1633 ndst.ndts_destroys += st->destroys;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 5f043d346694..7fc3e9e28c34 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -75,7 +75,7 @@
75 * By design there should only be *one* "controlling" process. In practice 75 * By design there should only be *one* "controlling" process. In practice
76 * multiple write accesses gives unpredictable result. Understood by "write" 76 * multiple write accesses gives unpredictable result. Understood by "write"
77 * to /proc gives result code thats should be read be the "writer". 77 * to /proc gives result code thats should be read be the "writer".
78 * For pratical use this should be no problem. 78 * For practical use this should be no problem.
79 * 79 *
80 * Note when adding devices to a specific CPU there good idea to also assign 80 * Note when adding devices to a specific CPU there good idea to also assign
81 * /proc/irq/XX/smp_affinity so TX-interrupts gets bound to the same CPU. 81 * /proc/irq/XX/smp_affinity so TX-interrupts gets bound to the same CPU.
@@ -96,7 +96,7 @@
96 * New xmit() return, do_div and misc clean up by Stephen Hemminger 96 * New xmit() return, do_div and misc clean up by Stephen Hemminger
97 * <shemminger@osdl.org> 040923 97 * <shemminger@osdl.org> 040923
98 * 98 *
99 * Rany Dunlap fixed u64 printk compiler waring 99 * Randy Dunlap fixed u64 printk compiler waring
100 * 100 *
101 * Remove FCS from BW calculation. Lennert Buytenhek <buytenh@wantstofly.org> 101 * Remove FCS from BW calculation. Lennert Buytenhek <buytenh@wantstofly.org>
102 * New time handling. Lennert Buytenhek <buytenh@wantstofly.org> 041213 102 * New time handling. Lennert Buytenhek <buytenh@wantstofly.org> 041213
@@ -137,6 +137,7 @@
137#include <linux/ipv6.h> 137#include <linux/ipv6.h>
138#include <linux/udp.h> 138#include <linux/udp.h>
139#include <linux/proc_fs.h> 139#include <linux/proc_fs.h>
140#include <linux/seq_file.h>
140#include <linux/wait.h> 141#include <linux/wait.h>
141#include <net/checksum.h> 142#include <net/checksum.h>
142#include <net/ipv6.h> 143#include <net/ipv6.h>
@@ -151,7 +152,7 @@
151#include <asm/timex.h> 152#include <asm/timex.h>
152 153
153 154
154#define VERSION "pktgen v2.62: Packet Generator for packet performance testing.\n" 155#define VERSION "pktgen v2.63: Packet Generator for packet performance testing.\n"
155 156
156/* #define PG_DEBUG(a) a */ 157/* #define PG_DEBUG(a) a */
157#define PG_DEBUG(a) 158#define PG_DEBUG(a)
@@ -177,8 +178,8 @@
177#define T_REMDEV (1<<3) /* Remove all devs */ 178#define T_REMDEV (1<<3) /* Remove all devs */
178 179
179/* Locks */ 180/* Locks */
180#define thread_lock() spin_lock(&_thread_lock) 181#define thread_lock() down(&pktgen_sem)
181#define thread_unlock() spin_unlock(&_thread_lock) 182#define thread_unlock() up(&pktgen_sem)
182 183
183/* If lock -- can be removed after some work */ 184/* If lock -- can be removed after some work */
184#define if_lock(t) spin_lock(&(t->if_lock)); 185#define if_lock(t) spin_lock(&(t->if_lock));
@@ -186,7 +187,9 @@
186 187
187/* Used to help with determining the pkts on receive */ 188/* Used to help with determining the pkts on receive */
188#define PKTGEN_MAGIC 0xbe9be955 189#define PKTGEN_MAGIC 0xbe9be955
189#define PG_PROC_DIR "net/pktgen" 190#define PG_PROC_DIR "pktgen"
191#define PGCTRL "pgctrl"
192static struct proc_dir_entry *pg_proc_dir = NULL;
190 193
191#define MAX_CFLOWS 65536 194#define MAX_CFLOWS 65536
192 195
@@ -202,11 +205,8 @@ struct pktgen_dev {
202 * Try to keep frequent/infrequent used vars. separated. 205 * Try to keep frequent/infrequent used vars. separated.
203 */ 206 */
204 207
205 char ifname[32]; 208 char ifname[IFNAMSIZ];
206 struct proc_dir_entry *proc_ent;
207 char result[512]; 209 char result[512];
208 /* proc file names */
209 char fname[80];
210 210
211 struct pktgen_thread* pg_thread; /* the owner */ 211 struct pktgen_thread* pg_thread; /* the owner */
212 struct pktgen_dev *next; /* Used for chaining in the thread's run-queue */ 212 struct pktgen_dev *next; /* Used for chaining in the thread's run-queue */
@@ -244,7 +244,7 @@ struct pktgen_dev {
244 __u32 seq_num; 244 __u32 seq_num;
245 245
246 int clone_skb; /* Use multiple SKBs during packet gen. If this number 246 int clone_skb; /* Use multiple SKBs during packet gen. If this number
247 * is greater than 1, then that many coppies of the same 247 * is greater than 1, then that many copies of the same
248 * packet will be sent before a new packet is allocated. 248 * packet will be sent before a new packet is allocated.
249 * For instance, if you want to send 1024 identical packets 249 * For instance, if you want to send 1024 identical packets
250 * before creating a new packet, set clone_skb to 1024. 250 * before creating a new packet, set clone_skb to 1024.
@@ -330,8 +330,6 @@ struct pktgen_thread {
330 struct pktgen_dev *if_list; /* All device here */ 330 struct pktgen_dev *if_list; /* All device here */
331 struct pktgen_thread* next; 331 struct pktgen_thread* next;
332 char name[32]; 332 char name[32];
333 char fname[128]; /* name of proc file */
334 struct proc_dir_entry *proc_ent;
335 char result[512]; 333 char result[512];
336 u32 max_before_softirq; /* We'll call do_softirq to prevent starvation. */ 334 u32 max_before_softirq; /* We'll call do_softirq to prevent starvation. */
337 335
@@ -396,7 +394,7 @@ static inline s64 divremdi3(s64 x, s64 y, int type)
396 394
397/* End of hacks to deal with 64-bit math on x86 */ 395/* End of hacks to deal with 64-bit math on x86 */
398 396
399/** Convert to miliseconds */ 397/** Convert to milliseconds */
400static inline __u64 tv_to_ms(const struct timeval* tv) 398static inline __u64 tv_to_ms(const struct timeval* tv)
401{ 399{
402 __u64 ms = tv->tv_usec / 1000; 400 __u64 ms = tv->tv_usec / 1000;
@@ -425,7 +423,7 @@ static inline __u64 pg_div64(__u64 n, __u64 base)
425{ 423{
426 __u64 tmp = n; 424 __u64 tmp = n;
427/* 425/*
428 * How do we know if the architectrure we are running on 426 * How do we know if the architecture we are running on
429 * supports division with 64 bit base? 427 * supports division with 64 bit base?
430 * 428 *
431 */ 429 */
@@ -473,16 +471,6 @@ static inline __u64 tv_diff(const struct timeval* a, const struct timeval* b)
473 471
474static char version[] __initdata = VERSION; 472static char version[] __initdata = VERSION;
475 473
476static ssize_t proc_pgctrl_read(struct file* file, char __user * buf, size_t count, loff_t *ppos);
477static ssize_t proc_pgctrl_write(struct file* file, const char __user * buf, size_t count, loff_t *ppos);
478static int proc_if_read(char *buf , char **start, off_t offset, int len, int *eof, void *data);
479
480static int proc_thread_read(char *buf , char **start, off_t offset, int len, int *eof, void *data);
481static int proc_if_write(struct file *file, const char __user *user_buffer, unsigned long count, void *data);
482static int proc_thread_write(struct file *file, const char __user *user_buffer, unsigned long count, void *data);
483static int create_proc_dir(void);
484static int remove_proc_dir(void);
485
486static int pktgen_remove_device(struct pktgen_thread* t, struct pktgen_dev *i); 474static int pktgen_remove_device(struct pktgen_thread* t, struct pktgen_dev *i);
487static int pktgen_add_device(struct pktgen_thread* t, const char* ifname); 475static int pktgen_add_device(struct pktgen_thread* t, const char* ifname);
488static struct pktgen_thread* pktgen_find_thread(const char* name); 476static struct pktgen_thread* pktgen_find_thread(const char* name);
@@ -503,83 +491,41 @@ static int pg_delay_d = 0;
503static int pg_clone_skb_d = 0; 491static int pg_clone_skb_d = 0;
504static int debug = 0; 492static int debug = 0;
505 493
506static DEFINE_SPINLOCK(_thread_lock); 494static DECLARE_MUTEX(pktgen_sem);
507static struct pktgen_thread *pktgen_threads = NULL; 495static struct pktgen_thread *pktgen_threads = NULL;
508 496
509static char module_fname[128];
510static struct proc_dir_entry *module_proc_ent = NULL;
511
512static struct notifier_block pktgen_notifier_block = { 497static struct notifier_block pktgen_notifier_block = {
513 .notifier_call = pktgen_device_event, 498 .notifier_call = pktgen_device_event,
514}; 499};
515 500
516static struct file_operations pktgen_fops = {
517 .read = proc_pgctrl_read,
518 .write = proc_pgctrl_write,
519 /* .ioctl = pktgen_ioctl, later maybe */
520};
521
522/* 501/*
523 * /proc handling functions 502 * /proc handling functions
524 * 503 *
525 */ 504 */
526 505
527static struct proc_dir_entry *pg_proc_dir = NULL; 506static int pgctrl_show(struct seq_file *seq, void *v)
528static int proc_pgctrl_read_eof=0;
529
530static ssize_t proc_pgctrl_read(struct file* file, char __user * buf,
531 size_t count, loff_t *ppos)
532{ 507{
533 char data[200]; 508 seq_puts(seq, VERSION);
534 int len = 0; 509 return 0;
535
536 if(proc_pgctrl_read_eof) {
537 proc_pgctrl_read_eof=0;
538 len = 0;
539 goto out;
540 }
541
542 sprintf(data, "%s", VERSION);
543
544 len = strlen(data);
545
546 if(len > count) {
547 len =-EFAULT;
548 goto out;
549 }
550
551 if (copy_to_user(buf, data, len)) {
552 len =-EFAULT;
553 goto out;
554 }
555
556 *ppos += len;
557 proc_pgctrl_read_eof=1; /* EOF next call */
558
559 out:
560 return len;
561} 510}
562 511
563static ssize_t proc_pgctrl_write(struct file* file,const char __user * buf, 512static ssize_t pgctrl_write(struct file* file,const char __user * buf,
564 size_t count, loff_t *ppos) 513 size_t count, loff_t *ppos)
565{ 514{
566 char *data = NULL;
567 int err = 0; 515 int err = 0;
516 char data[128];
568 517
569 if (!capable(CAP_NET_ADMIN)){ 518 if (!capable(CAP_NET_ADMIN)){
570 err = -EPERM; 519 err = -EPERM;
571 goto out; 520 goto out;
572 } 521 }
573 522
574 data = (void*)vmalloc ((unsigned int)count); 523 if (count > sizeof(data))
524 count = sizeof(data);
575 525
576 if(!data) {
577 err = -ENOMEM;
578 goto out;
579 }
580 if (copy_from_user(data, buf, count)) { 526 if (copy_from_user(data, buf, count)) {
581 err =-EFAULT; 527 err = -EFAULT;
582 goto out_free; 528 goto out;
583 } 529 }
584 data[count-1] = 0; /* Make string */ 530 data[count-1] = 0; /* Make string */
585 531
@@ -594,31 +540,40 @@ static ssize_t proc_pgctrl_write(struct file* file,const char __user * buf,
594 540
595 err = count; 541 err = count;
596 542
597 out_free:
598 vfree (data);
599 out: 543 out:
600 return err; 544 return err;
601} 545}
602 546
603static int proc_if_read(char *buf , char **start, off_t offset, 547static int pgctrl_open(struct inode *inode, struct file *file)
604 int len, int *eof, void *data) 548{
549 return single_open(file, pgctrl_show, PDE(inode)->data);
550}
551
552static struct file_operations pktgen_fops = {
553 .owner = THIS_MODULE,
554 .open = pgctrl_open,
555 .read = seq_read,
556 .llseek = seq_lseek,
557 .write = pgctrl_write,
558 .release = single_release,
559};
560
561static int pktgen_if_show(struct seq_file *seq, void *v)
605{ 562{
606 char *p;
607 int i; 563 int i;
608 struct pktgen_dev *pkt_dev = (struct pktgen_dev*)(data); 564 struct pktgen_dev *pkt_dev = seq->private;
609 __u64 sa; 565 __u64 sa;
610 __u64 stopped; 566 __u64 stopped;
611 __u64 now = getCurUs(); 567 __u64 now = getCurUs();
612 568
613 p = buf; 569 seq_printf(seq, "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n",
614 p += sprintf(p, "Params: count %llu min_pkt_size: %u max_pkt_size: %u\n", 570 (unsigned long long) pkt_dev->count,
615 (unsigned long long) pkt_dev->count, 571 pkt_dev->min_pkt_size, pkt_dev->max_pkt_size);
616 pkt_dev->min_pkt_size, pkt_dev->max_pkt_size);
617 572
618 p += sprintf(p, " frags: %d delay: %u clone_skb: %d ifname: %s\n", 573 seq_printf(seq, " frags: %d delay: %u clone_skb: %d ifname: %s\n",
619 pkt_dev->nfrags, 1000*pkt_dev->delay_us+pkt_dev->delay_ns, pkt_dev->clone_skb, pkt_dev->ifname); 574 pkt_dev->nfrags, 1000*pkt_dev->delay_us+pkt_dev->delay_ns, pkt_dev->clone_skb, pkt_dev->ifname);
620 575
621 p += sprintf(p, " flows: %u flowlen: %u\n", pkt_dev->cflows, pkt_dev->lflow); 576 seq_printf(seq, " flows: %u flowlen: %u\n", pkt_dev->cflows, pkt_dev->lflow);
622 577
623 578
624 if(pkt_dev->flags & F_IPV6) { 579 if(pkt_dev->flags & F_IPV6) {
@@ -626,19 +581,19 @@ static int proc_if_read(char *buf , char **start, off_t offset,
626 fmt_ip6(b1, pkt_dev->in6_saddr.s6_addr); 581 fmt_ip6(b1, pkt_dev->in6_saddr.s6_addr);
627 fmt_ip6(b2, pkt_dev->min_in6_saddr.s6_addr); 582 fmt_ip6(b2, pkt_dev->min_in6_saddr.s6_addr);
628 fmt_ip6(b3, pkt_dev->max_in6_saddr.s6_addr); 583 fmt_ip6(b3, pkt_dev->max_in6_saddr.s6_addr);
629 p += sprintf(p, " saddr: %s min_saddr: %s max_saddr: %s\n", b1, b2, b3); 584 seq_printf(seq, " saddr: %s min_saddr: %s max_saddr: %s\n", b1, b2, b3);
630 585
631 fmt_ip6(b1, pkt_dev->in6_daddr.s6_addr); 586 fmt_ip6(b1, pkt_dev->in6_daddr.s6_addr);
632 fmt_ip6(b2, pkt_dev->min_in6_daddr.s6_addr); 587 fmt_ip6(b2, pkt_dev->min_in6_daddr.s6_addr);
633 fmt_ip6(b3, pkt_dev->max_in6_daddr.s6_addr); 588 fmt_ip6(b3, pkt_dev->max_in6_daddr.s6_addr);
634 p += sprintf(p, " daddr: %s min_daddr: %s max_daddr: %s\n", b1, b2, b3); 589 seq_printf(seq, " daddr: %s min_daddr: %s max_daddr: %s\n", b1, b2, b3);
635 590
636 } 591 }
637 else 592 else
638 p += sprintf(p, " dst_min: %s dst_max: %s\n src_min: %s src_max: %s\n", 593 seq_printf(seq," dst_min: %s dst_max: %s\n src_min: %s src_max: %s\n",
639 pkt_dev->dst_min, pkt_dev->dst_max, pkt_dev->src_min, pkt_dev->src_max); 594 pkt_dev->dst_min, pkt_dev->dst_max, pkt_dev->src_min, pkt_dev->src_max);
640 595
641 p += sprintf(p, " src_mac: "); 596 seq_puts(seq, " src_mac: ");
642 597
643 if ((pkt_dev->src_mac[0] == 0) && 598 if ((pkt_dev->src_mac[0] == 0) &&
644 (pkt_dev->src_mac[1] == 0) && 599 (pkt_dev->src_mac[1] == 0) &&
@@ -648,89 +603,89 @@ static int proc_if_read(char *buf , char **start, off_t offset,
648 (pkt_dev->src_mac[5] == 0)) 603 (pkt_dev->src_mac[5] == 0))
649 604
650 for (i = 0; i < 6; i++) 605 for (i = 0; i < 6; i++)
651 p += sprintf(p, "%02X%s", pkt_dev->odev->dev_addr[i], i == 5 ? " " : ":"); 606 seq_printf(seq, "%02X%s", pkt_dev->odev->dev_addr[i], i == 5 ? " " : ":");
652 607
653 else 608 else
654 for (i = 0; i < 6; i++) 609 for (i = 0; i < 6; i++)
655 p += sprintf(p, "%02X%s", pkt_dev->src_mac[i], i == 5 ? " " : ":"); 610 seq_printf(seq, "%02X%s", pkt_dev->src_mac[i], i == 5 ? " " : ":");
656 611
657 p += sprintf(p, "dst_mac: "); 612 seq_printf(seq, "dst_mac: ");
658 for (i = 0; i < 6; i++) 613 for (i = 0; i < 6; i++)
659 p += sprintf(p, "%02X%s", pkt_dev->dst_mac[i], i == 5 ? "\n" : ":"); 614 seq_printf(seq, "%02X%s", pkt_dev->dst_mac[i], i == 5 ? "\n" : ":");
660 615
661 p += sprintf(p, " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n", 616 seq_printf(seq, " udp_src_min: %d udp_src_max: %d udp_dst_min: %d udp_dst_max: %d\n",
662 pkt_dev->udp_src_min, pkt_dev->udp_src_max, pkt_dev->udp_dst_min, 617 pkt_dev->udp_src_min, pkt_dev->udp_src_max, pkt_dev->udp_dst_min,
663 pkt_dev->udp_dst_max); 618 pkt_dev->udp_dst_max);
664 619
665 p += sprintf(p, " src_mac_count: %d dst_mac_count: %d \n Flags: ", 620 seq_printf(seq, " src_mac_count: %d dst_mac_count: %d \n Flags: ",
666 pkt_dev->src_mac_count, pkt_dev->dst_mac_count); 621 pkt_dev->src_mac_count, pkt_dev->dst_mac_count);
667 622
668 623
669 if (pkt_dev->flags & F_IPV6) 624 if (pkt_dev->flags & F_IPV6)
670 p += sprintf(p, "IPV6 "); 625 seq_printf(seq, "IPV6 ");
671 626
672 if (pkt_dev->flags & F_IPSRC_RND) 627 if (pkt_dev->flags & F_IPSRC_RND)
673 p += sprintf(p, "IPSRC_RND "); 628 seq_printf(seq, "IPSRC_RND ");
674 629
675 if (pkt_dev->flags & F_IPDST_RND) 630 if (pkt_dev->flags & F_IPDST_RND)
676 p += sprintf(p, "IPDST_RND "); 631 seq_printf(seq, "IPDST_RND ");
677 632
678 if (pkt_dev->flags & F_TXSIZE_RND) 633 if (pkt_dev->flags & F_TXSIZE_RND)
679 p += sprintf(p, "TXSIZE_RND "); 634 seq_printf(seq, "TXSIZE_RND ");
680 635
681 if (pkt_dev->flags & F_UDPSRC_RND) 636 if (pkt_dev->flags & F_UDPSRC_RND)
682 p += sprintf(p, "UDPSRC_RND "); 637 seq_printf(seq, "UDPSRC_RND ");
683 638
684 if (pkt_dev->flags & F_UDPDST_RND) 639 if (pkt_dev->flags & F_UDPDST_RND)
685 p += sprintf(p, "UDPDST_RND "); 640 seq_printf(seq, "UDPDST_RND ");
686 641
687 if (pkt_dev->flags & F_MACSRC_RND) 642 if (pkt_dev->flags & F_MACSRC_RND)
688 p += sprintf(p, "MACSRC_RND "); 643 seq_printf(seq, "MACSRC_RND ");
689 644
690 if (pkt_dev->flags & F_MACDST_RND) 645 if (pkt_dev->flags & F_MACDST_RND)
691 p += sprintf(p, "MACDST_RND "); 646 seq_printf(seq, "MACDST_RND ");
692 647
693 648
694 p += sprintf(p, "\n"); 649 seq_puts(seq, "\n");
695 650
696 sa = pkt_dev->started_at; 651 sa = pkt_dev->started_at;
697 stopped = pkt_dev->stopped_at; 652 stopped = pkt_dev->stopped_at;
698 if (pkt_dev->running) 653 if (pkt_dev->running)
699 stopped = now; /* not really stopped, more like last-running-at */ 654 stopped = now; /* not really stopped, more like last-running-at */
700 655
701 p += sprintf(p, "Current:\n pkts-sofar: %llu errors: %llu\n started: %lluus stopped: %lluus idle: %lluus\n", 656 seq_printf(seq, "Current:\n pkts-sofar: %llu errors: %llu\n started: %lluus stopped: %lluus idle: %lluus\n",
702 (unsigned long long) pkt_dev->sofar, 657 (unsigned long long) pkt_dev->sofar,
703 (unsigned long long) pkt_dev->errors, 658 (unsigned long long) pkt_dev->errors,
704 (unsigned long long) sa, 659 (unsigned long long) sa,
705 (unsigned long long) stopped, 660 (unsigned long long) stopped,
706 (unsigned long long) pkt_dev->idle_acc); 661 (unsigned long long) pkt_dev->idle_acc);
707 662
708 p += sprintf(p, " seq_num: %d cur_dst_mac_offset: %d cur_src_mac_offset: %d\n", 663 seq_printf(seq, " seq_num: %d cur_dst_mac_offset: %d cur_src_mac_offset: %d\n",
709 pkt_dev->seq_num, pkt_dev->cur_dst_mac_offset, pkt_dev->cur_src_mac_offset); 664 pkt_dev->seq_num, pkt_dev->cur_dst_mac_offset,
665 pkt_dev->cur_src_mac_offset);
710 666
711 if(pkt_dev->flags & F_IPV6) { 667 if(pkt_dev->flags & F_IPV6) {
712 char b1[128], b2[128]; 668 char b1[128], b2[128];
713 fmt_ip6(b1, pkt_dev->cur_in6_daddr.s6_addr); 669 fmt_ip6(b1, pkt_dev->cur_in6_daddr.s6_addr);
714 fmt_ip6(b2, pkt_dev->cur_in6_saddr.s6_addr); 670 fmt_ip6(b2, pkt_dev->cur_in6_saddr.s6_addr);
715 p += sprintf(p, " cur_saddr: %s cur_daddr: %s\n", b2, b1); 671 seq_printf(seq, " cur_saddr: %s cur_daddr: %s\n", b2, b1);
716 } 672 }
717 else 673 else
718 p += sprintf(p, " cur_saddr: 0x%x cur_daddr: 0x%x\n", 674 seq_printf(seq, " cur_saddr: 0x%x cur_daddr: 0x%x\n",
719 pkt_dev->cur_saddr, pkt_dev->cur_daddr); 675 pkt_dev->cur_saddr, pkt_dev->cur_daddr);
720 676
721 677
722 p += sprintf(p, " cur_udp_dst: %d cur_udp_src: %d\n", 678 seq_printf(seq, " cur_udp_dst: %d cur_udp_src: %d\n",
723 pkt_dev->cur_udp_dst, pkt_dev->cur_udp_src); 679 pkt_dev->cur_udp_dst, pkt_dev->cur_udp_src);
724 680
725 p += sprintf(p, " flows: %u\n", pkt_dev->nflows); 681 seq_printf(seq, " flows: %u\n", pkt_dev->nflows);
726 682
727 if (pkt_dev->result[0]) 683 if (pkt_dev->result[0])
728 p += sprintf(p, "Result: %s\n", pkt_dev->result); 684 seq_printf(seq, "Result: %s\n", pkt_dev->result);
729 else 685 else
730 p += sprintf(p, "Result: Idle\n"); 686 seq_printf(seq, "Result: Idle\n");
731 *eof = 1;
732 687
733 return p - buf; 688 return 0;
734} 689}
735 690
736 691
@@ -802,13 +757,14 @@ done_str:
802 return i; 757 return i;
803} 758}
804 759
805static int proc_if_write(struct file *file, const char __user *user_buffer, 760static ssize_t pktgen_if_write(struct file *file, const char __user *user_buffer,
806 unsigned long count, void *data) 761 size_t count, loff_t *offset)
807{ 762{
763 struct seq_file *seq = (struct seq_file *) file->private_data;
764 struct pktgen_dev *pkt_dev = seq->private;
808 int i = 0, max, len; 765 int i = 0, max, len;
809 char name[16], valstr[32]; 766 char name[16], valstr[32];
810 unsigned long value = 0; 767 unsigned long value = 0;
811 struct pktgen_dev *pkt_dev = (struct pktgen_dev*)(data);
812 char* pg_result = NULL; 768 char* pg_result = NULL;
813 int tmp = 0; 769 int tmp = 0;
814 char buf[128]; 770 char buf[128];
@@ -849,7 +805,8 @@ static int proc_if_write(struct file *file, const char __user *user_buffer,
849 if (copy_from_user(tb, user_buffer, count)) 805 if (copy_from_user(tb, user_buffer, count))
850 return -EFAULT; 806 return -EFAULT;
851 tb[count] = 0; 807 tb[count] = 0;
852 printk("pktgen: %s,%lu buffer -:%s:-\n", name, count, tb); 808 printk("pktgen: %s,%lu buffer -:%s:-\n", name,
809 (unsigned long) count, tb);
853 } 810 }
854 811
855 if (!strcmp(name, "min_pkt_size")) { 812 if (!strcmp(name, "min_pkt_size")) {
@@ -1335,92 +1292,98 @@ static int proc_if_write(struct file *file, const char __user *user_buffer,
1335 return -EINVAL; 1292 return -EINVAL;
1336} 1293}
1337 1294
1338static int proc_thread_read(char *buf , char **start, off_t offset, 1295static int pktgen_if_open(struct inode *inode, struct file *file)
1339 int len, int *eof, void *data)
1340{ 1296{
1341 char *p; 1297 return single_open(file, pktgen_if_show, PDE(inode)->data);
1342 struct pktgen_thread *t = (struct pktgen_thread*)(data); 1298}
1343 struct pktgen_dev *pkt_dev = NULL;
1344 1299
1300static struct file_operations pktgen_if_fops = {
1301 .owner = THIS_MODULE,
1302 .open = pktgen_if_open,
1303 .read = seq_read,
1304 .llseek = seq_lseek,
1305 .write = pktgen_if_write,
1306 .release = single_release,
1307};
1345 1308
1346 if (!t) { 1309static int pktgen_thread_show(struct seq_file *seq, void *v)
1347 printk("pktgen: ERROR: could not find thread in proc_thread_read\n"); 1310{
1348 return -EINVAL; 1311 struct pktgen_thread *t = seq->private;
1349 } 1312 struct pktgen_dev *pkt_dev = NULL;
1313
1314 BUG_ON(!t);
1350 1315
1351 p = buf; 1316 seq_printf(seq, "Name: %s max_before_softirq: %d\n",
1352 p += sprintf(p, "Name: %s max_before_softirq: %d\n",
1353 t->name, t->max_before_softirq); 1317 t->name, t->max_before_softirq);
1354 1318
1355 p += sprintf(p, "Running: "); 1319 seq_printf(seq, "Running: ");
1356 1320
1357 if_lock(t); 1321 if_lock(t);
1358 for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next) 1322 for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next)
1359 if(pkt_dev->running) 1323 if(pkt_dev->running)
1360 p += sprintf(p, "%s ", pkt_dev->ifname); 1324 seq_printf(seq, "%s ", pkt_dev->ifname);
1361 1325
1362 p += sprintf(p, "\nStopped: "); 1326 seq_printf(seq, "\nStopped: ");
1363 1327
1364 for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next) 1328 for(pkt_dev = t->if_list;pkt_dev; pkt_dev = pkt_dev->next)
1365 if(!pkt_dev->running) 1329 if(!pkt_dev->running)
1366 p += sprintf(p, "%s ", pkt_dev->ifname); 1330 seq_printf(seq, "%s ", pkt_dev->ifname);
1367 1331
1368 if (t->result[0]) 1332 if (t->result[0])
1369 p += sprintf(p, "\nResult: %s\n", t->result); 1333 seq_printf(seq, "\nResult: %s\n", t->result);
1370 else 1334 else
1371 p += sprintf(p, "\nResult: NA\n"); 1335 seq_printf(seq, "\nResult: NA\n");
1372
1373 *eof = 1;
1374 1336
1375 if_unlock(t); 1337 if_unlock(t);
1376 1338
1377 return p - buf; 1339 return 0;
1378} 1340}
1379 1341
1380static int proc_thread_write(struct file *file, const char __user *user_buffer, 1342static ssize_t pktgen_thread_write(struct file *file,
1381 unsigned long count, void *data) 1343 const char __user *user_buffer,
1344 size_t count, loff_t *offset)
1382{ 1345{
1346 struct seq_file *seq = (struct seq_file *) file->private_data;
1347 struct pktgen_thread *t = seq->private;
1383 int i = 0, max, len, ret; 1348 int i = 0, max, len, ret;
1384 char name[40]; 1349 char name[40];
1385 struct pktgen_thread *t;
1386 char *pg_result; 1350 char *pg_result;
1387 unsigned long value = 0; 1351 unsigned long value = 0;
1388 1352
1389 if (count < 1) { 1353 if (count < 1) {
1390 // sprintf(pg_result, "Wrong command format"); 1354 // sprintf(pg_result, "Wrong command format");
1391 return -EINVAL; 1355 return -EINVAL;
1392 } 1356 }
1393 1357
1394 max = count - i; 1358 max = count - i;
1395 len = count_trail_chars(&user_buffer[i], max); 1359 len = count_trail_chars(&user_buffer[i], max);
1396 if (len < 0) 1360 if (len < 0)
1397 return len; 1361 return len;
1398 1362
1399 i += len; 1363 i += len;
1400 1364
1401 /* Read variable name */ 1365 /* Read variable name */
1402 1366
1403 len = strn_len(&user_buffer[i], sizeof(name) - 1); 1367 len = strn_len(&user_buffer[i], sizeof(name) - 1);
1404 if (len < 0) 1368 if (len < 0)
1405 return len; 1369 return len;
1406 1370
1407 memset(name, 0, sizeof(name)); 1371 memset(name, 0, sizeof(name));
1408 if (copy_from_user(name, &user_buffer[i], len)) 1372 if (copy_from_user(name, &user_buffer[i], len))
1409 return -EFAULT; 1373 return -EFAULT;
1410 i += len; 1374 i += len;
1411 1375
1412 max = count -i; 1376 max = count -i;
1413 len = count_trail_chars(&user_buffer[i], max); 1377 len = count_trail_chars(&user_buffer[i], max);
1414 if (len < 0) 1378 if (len < 0)
1415 return len; 1379 return len;
1416 1380
1417 i += len; 1381 i += len;
1418 1382
1419 if (debug) 1383 if (debug)
1420 printk("pktgen: t=%s, count=%lu\n", name, count); 1384 printk("pktgen: t=%s, count=%lu\n", name,
1421 1385 (unsigned long) count);
1422 1386
1423 t = (struct pktgen_thread*)(data);
1424 if(!t) { 1387 if(!t) {
1425 printk("pktgen: ERROR: No thread\n"); 1388 printk("pktgen: ERROR: No thread\n");
1426 ret = -EINVAL; 1389 ret = -EINVAL;
@@ -1474,21 +1437,19 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer,
1474 return ret; 1437 return ret;
1475} 1438}
1476 1439
1477static int create_proc_dir(void) 1440static int pktgen_thread_open(struct inode *inode, struct file *file)
1478{ 1441{
1479 pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL); 1442 return single_open(file, pktgen_thread_show, PDE(inode)->data);
1480
1481 if (!pg_proc_dir)
1482 return -ENODEV;
1483
1484 return 0;
1485} 1443}
1486 1444
1487static int remove_proc_dir(void) 1445static struct file_operations pktgen_thread_fops = {
1488{ 1446 .owner = THIS_MODULE,
1489 remove_proc_entry(PG_PROC_DIR, NULL); 1447 .open = pktgen_thread_open,
1490 return 0; 1448 .read = seq_read,
1491} 1449 .llseek = seq_lseek,
1450 .write = pktgen_thread_write,
1451 .release = single_release,
1452};
1492 1453
1493/* Think find or remove for NN */ 1454/* Think find or remove for NN */
1494static struct pktgen_dev *__pktgen_NN_threads(const char* ifname, int remove) 1455static struct pktgen_dev *__pktgen_NN_threads(const char* ifname, int remove)
@@ -1702,7 +1663,7 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us)
1702 start = now = getCurUs(); 1663 start = now = getCurUs();
1703 printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now)); 1664 printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now));
1704 while (now < spin_until_us) { 1665 while (now < spin_until_us) {
1705 /* TODO: optimise sleeping behavior */ 1666 /* TODO: optimize sleeping behavior */
1706 if (spin_until_us - now > jiffies_to_usecs(1)+1) 1667 if (spin_until_us - now > jiffies_to_usecs(1)+1)
1707 schedule_timeout_interruptible(1); 1668 schedule_timeout_interruptible(1);
1708 else if (spin_until_us - now > 100) { 1669 else if (spin_until_us - now > 100) {
@@ -2361,7 +2322,7 @@ static void pktgen_stop_all_threads_ifs(void)
2361 pktgen_stop(t); 2322 pktgen_stop(t);
2362 t = t->next; 2323 t = t->next;
2363 } 2324 }
2364 thread_unlock(); 2325 thread_unlock();
2365} 2326}
2366 2327
2367static int thread_is_running(struct pktgen_thread *t ) 2328static int thread_is_running(struct pktgen_thread *t )
@@ -2552,10 +2513,9 @@ static void pktgen_rem_thread(struct pktgen_thread *t)
2552 2513
2553 struct pktgen_thread *tmp = pktgen_threads; 2514 struct pktgen_thread *tmp = pktgen_threads;
2554 2515
2555 if (strlen(t->fname)) 2516 remove_proc_entry(t->name, pg_proc_dir);
2556 remove_proc_entry(t->fname, NULL);
2557 2517
2558 thread_lock(); 2518 thread_lock();
2559 2519
2560 if (tmp == t) 2520 if (tmp == t)
2561 pktgen_threads = tmp->next; 2521 pktgen_threads = tmp->next;
@@ -2825,7 +2785,7 @@ static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, const char* i
2825 if_lock(t); 2785 if_lock(t);
2826 2786
2827 for(pkt_dev=t->if_list; pkt_dev; pkt_dev = pkt_dev->next ) { 2787 for(pkt_dev=t->if_list; pkt_dev; pkt_dev = pkt_dev->next ) {
2828 if (strcmp(pkt_dev->ifname, ifname) == 0) { 2788 if (strncmp(pkt_dev->ifname, ifname, IFNAMSIZ) == 0) {
2829 break; 2789 break;
2830 } 2790 }
2831 } 2791 }
@@ -2864,74 +2824,70 @@ static int add_dev_to_thread(struct pktgen_thread *t, struct pktgen_dev *pkt_dev
2864static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) 2824static int pktgen_add_device(struct pktgen_thread *t, const char* ifname)
2865{ 2825{
2866 struct pktgen_dev *pkt_dev; 2826 struct pktgen_dev *pkt_dev;
2827 struct proc_dir_entry *pe;
2867 2828
2868 /* We don't allow a device to be on several threads */ 2829 /* We don't allow a device to be on several threads */
2869 2830
2870 if( (pkt_dev = __pktgen_NN_threads(ifname, FIND)) == NULL) { 2831 pkt_dev = __pktgen_NN_threads(ifname, FIND);
2871 2832 if (pkt_dev) {
2872 pkt_dev = kmalloc(sizeof(struct pktgen_dev), GFP_KERNEL); 2833 printk("pktgen: ERROR: interface already used.\n");
2873 if (!pkt_dev) 2834 return -EBUSY;
2874 return -ENOMEM; 2835 }
2875 2836
2876 memset(pkt_dev, 0, sizeof(struct pktgen_dev)); 2837 pkt_dev = kzalloc(sizeof(struct pktgen_dev), GFP_KERNEL);
2838 if (!pkt_dev)
2839 return -ENOMEM;
2877 2840
2878 pkt_dev->flows = vmalloc(MAX_CFLOWS*sizeof(struct flow_state)); 2841 pkt_dev->flows = vmalloc(MAX_CFLOWS*sizeof(struct flow_state));
2879 if (pkt_dev->flows == NULL) { 2842 if (pkt_dev->flows == NULL) {
2880 kfree(pkt_dev); 2843 kfree(pkt_dev);
2881 return -ENOMEM; 2844 return -ENOMEM;
2882 } 2845 }
2883 memset(pkt_dev->flows, 0, MAX_CFLOWS*sizeof(struct flow_state)); 2846 memset(pkt_dev->flows, 0, MAX_CFLOWS*sizeof(struct flow_state));
2884
2885 pkt_dev->min_pkt_size = ETH_ZLEN;
2886 pkt_dev->max_pkt_size = ETH_ZLEN;
2887 pkt_dev->nfrags = 0;
2888 pkt_dev->clone_skb = pg_clone_skb_d;
2889 pkt_dev->delay_us = pg_delay_d / 1000;
2890 pkt_dev->delay_ns = pg_delay_d % 1000;
2891 pkt_dev->count = pg_count_d;
2892 pkt_dev->sofar = 0;
2893 pkt_dev->udp_src_min = 9; /* sink port */
2894 pkt_dev->udp_src_max = 9;
2895 pkt_dev->udp_dst_min = 9;
2896 pkt_dev->udp_dst_max = 9;
2897
2898 strncpy(pkt_dev->ifname, ifname, 31);
2899 sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname);
2900
2901 if (! pktgen_setup_dev(pkt_dev)) {
2902 printk("pktgen: ERROR: pktgen_setup_dev failed.\n");
2903 if (pkt_dev->flows)
2904 vfree(pkt_dev->flows);
2905 kfree(pkt_dev);
2906 return -ENODEV;
2907 }
2908 2847
2909 pkt_dev->proc_ent = create_proc_entry(pkt_dev->fname, 0600, NULL); 2848 pkt_dev->min_pkt_size = ETH_ZLEN;
2910 if (!pkt_dev->proc_ent) { 2849 pkt_dev->max_pkt_size = ETH_ZLEN;
2911 printk("pktgen: cannot create %s procfs entry.\n", pkt_dev->fname); 2850 pkt_dev->nfrags = 0;
2912 if (pkt_dev->flows) 2851 pkt_dev->clone_skb = pg_clone_skb_d;
2913 vfree(pkt_dev->flows); 2852 pkt_dev->delay_us = pg_delay_d / 1000;
2914 kfree(pkt_dev); 2853 pkt_dev->delay_ns = pg_delay_d % 1000;
2915 return -EINVAL; 2854 pkt_dev->count = pg_count_d;
2916 } 2855 pkt_dev->sofar = 0;
2917 pkt_dev->proc_ent->read_proc = proc_if_read; 2856 pkt_dev->udp_src_min = 9; /* sink port */
2918 pkt_dev->proc_ent->write_proc = proc_if_write; 2857 pkt_dev->udp_src_max = 9;
2919 pkt_dev->proc_ent->data = (void*)(pkt_dev); 2858 pkt_dev->udp_dst_min = 9;
2920 pkt_dev->proc_ent->owner = THIS_MODULE; 2859 pkt_dev->udp_dst_max = 9;
2860
2861 strncpy(pkt_dev->ifname, ifname, IFNAMSIZ);
2862
2863 if (! pktgen_setup_dev(pkt_dev)) {
2864 printk("pktgen: ERROR: pktgen_setup_dev failed.\n");
2865 if (pkt_dev->flows)
2866 vfree(pkt_dev->flows);
2867 kfree(pkt_dev);
2868 return -ENODEV;
2869 }
2870
2871 pe = create_proc_entry(ifname, 0600, pg_proc_dir);
2872 if (!pe) {
2873 printk("pktgen: cannot create %s/%s procfs entry.\n",
2874 PG_PROC_DIR, ifname);
2875 if (pkt_dev->flows)
2876 vfree(pkt_dev->flows);
2877 kfree(pkt_dev);
2878 return -EINVAL;
2879 }
2880 pe->proc_fops = &pktgen_if_fops;
2881 pe->data = pkt_dev;
2921 2882
2922 return add_dev_to_thread(t, pkt_dev); 2883 return add_dev_to_thread(t, pkt_dev);
2923 }
2924 else {
2925 printk("pktgen: ERROR: interface already used.\n");
2926 return -EBUSY;
2927 }
2928} 2884}
2929 2885
2930static struct pktgen_thread *pktgen_find_thread(const char* name) 2886static struct pktgen_thread *pktgen_find_thread(const char* name)
2931{ 2887{
2932 struct pktgen_thread *t = NULL; 2888 struct pktgen_thread *t = NULL;
2933 2889
2934 thread_lock(); 2890 thread_lock();
2935 2891
2936 t = pktgen_threads; 2892 t = pktgen_threads;
2937 while (t) { 2893 while (t) {
@@ -2947,6 +2903,7 @@ static struct pktgen_thread *pktgen_find_thread(const char* name)
2947static int pktgen_create_thread(const char* name, int cpu) 2903static int pktgen_create_thread(const char* name, int cpu)
2948{ 2904{
2949 struct pktgen_thread *t = NULL; 2905 struct pktgen_thread *t = NULL;
2906 struct proc_dir_entry *pe;
2950 2907
2951 if (strlen(name) > 31) { 2908 if (strlen(name) > 31) {
2952 printk("pktgen: ERROR: Thread name cannot be more than 31 characters.\n"); 2909 printk("pktgen: ERROR: Thread name cannot be more than 31 characters.\n");
@@ -2958,28 +2915,26 @@ static int pktgen_create_thread(const char* name, int cpu)
2958 return -EINVAL; 2915 return -EINVAL;
2959 } 2916 }
2960 2917
2961 t = (struct pktgen_thread*)(kmalloc(sizeof(struct pktgen_thread), GFP_KERNEL)); 2918 t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL);
2962 if (!t) { 2919 if (!t) {
2963 printk("pktgen: ERROR: out of memory, can't create new thread.\n"); 2920 printk("pktgen: ERROR: out of memory, can't create new thread.\n");
2964 return -ENOMEM; 2921 return -ENOMEM;
2965 } 2922 }
2966 2923
2967 memset(t, 0, sizeof(struct pktgen_thread));
2968 strcpy(t->name, name); 2924 strcpy(t->name, name);
2969 spin_lock_init(&t->if_lock); 2925 spin_lock_init(&t->if_lock);
2970 t->cpu = cpu; 2926 t->cpu = cpu;
2971 2927
2972 sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name); 2928 pe = create_proc_entry(t->name, 0600, pg_proc_dir);
2973 t->proc_ent = create_proc_entry(t->fname, 0600, NULL); 2929 if (!pe) {
2974 if (!t->proc_ent) { 2930 printk("pktgen: cannot create %s/%s procfs entry.\n",
2975 printk("pktgen: cannot create %s procfs entry.\n", t->fname); 2931 PG_PROC_DIR, t->name);
2976 kfree(t); 2932 kfree(t);
2977 return -EINVAL; 2933 return -EINVAL;
2978 } 2934 }
2979 t->proc_ent->read_proc = proc_thread_read; 2935
2980 t->proc_ent->write_proc = proc_thread_write; 2936 pe->proc_fops = &pktgen_thread_fops;
2981 t->proc_ent->data = (void*)(t); 2937 pe->data = t;
2982 t->proc_ent->owner = THIS_MODULE;
2983 2938
2984 t->next = pktgen_threads; 2939 t->next = pktgen_threads;
2985 pktgen_threads = t; 2940 pktgen_threads = t;
@@ -3034,8 +2989,7 @@ static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *pkt_
3034 2989
3035 /* Clean up proc file system */ 2990 /* Clean up proc file system */
3036 2991
3037 if (strlen(pkt_dev->fname)) 2992 remove_proc_entry(pkt_dev->ifname, pg_proc_dir);
3038 remove_proc_entry(pkt_dev->fname, NULL);
3039 2993
3040 if (pkt_dev->flows) 2994 if (pkt_dev->flows)
3041 vfree(pkt_dev->flows); 2995 vfree(pkt_dev->flows);
@@ -3046,31 +3000,31 @@ static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *pkt_
3046static int __init pg_init(void) 3000static int __init pg_init(void)
3047{ 3001{
3048 int cpu; 3002 int cpu;
3049 printk(version); 3003 struct proc_dir_entry *pe;
3050 3004
3051 module_fname[0] = 0; 3005 printk(version);
3052 3006
3053 create_proc_dir(); 3007 pg_proc_dir = proc_mkdir(PG_PROC_DIR, proc_net);
3008 if (!pg_proc_dir)
3009 return -ENODEV;
3010 pg_proc_dir->owner = THIS_MODULE;
3054 3011
3055 sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR); 3012 pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir);
3056 module_proc_ent = create_proc_entry(module_fname, 0600, NULL); 3013 if (pe == NULL) {
3057 if (!module_proc_ent) { 3014 printk("pktgen: ERROR: cannot create %s procfs entry.\n", PGCTRL);
3058 printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); 3015 proc_net_remove(PG_PROC_DIR);
3059 return -EINVAL; 3016 return -EINVAL;
3060 } 3017 }
3061 3018
3062 module_proc_ent->proc_fops = &pktgen_fops; 3019 pe->proc_fops = &pktgen_fops;
3063 module_proc_ent->data = NULL; 3020 pe->data = NULL;
3064 3021
3065 /* Register us to receive netdevice events */ 3022 /* Register us to receive netdevice events */
3066 register_netdevice_notifier(&pktgen_notifier_block); 3023 register_netdevice_notifier(&pktgen_notifier_block);
3067 3024
3068 for (cpu = 0; cpu < NR_CPUS ; cpu++) { 3025 for_each_online_cpu(cpu) {
3069 char buf[30]; 3026 char buf[30];
3070 3027
3071 if (!cpu_online(cpu))
3072 continue;
3073
3074 sprintf(buf, "kpktgend_%i", cpu); 3028 sprintf(buf, "kpktgend_%i", cpu);
3075 pktgen_create_thread(buf, cpu); 3029 pktgen_create_thread(buf, cpu);
3076 } 3030 }
@@ -3095,10 +3049,8 @@ static void __exit pg_cleanup(void)
3095 unregister_netdevice_notifier(&pktgen_notifier_block); 3049 unregister_netdevice_notifier(&pktgen_notifier_block);
3096 3050
3097 /* Clean up proc file system */ 3051 /* Clean up proc file system */
3098 3052 remove_proc_entry(PGCTRL, pg_proc_dir);
3099 remove_proc_entry(module_fname, NULL); 3053 proc_net_remove(PG_PROC_DIR);
3100
3101 remove_proc_dir();
3102} 3054}
3103 3055
3104 3056
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 02cd4cde2112..95501e40100e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -122,6 +122,8 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
122 * __alloc_skb - allocate a network buffer 122 * __alloc_skb - allocate a network buffer
123 * @size: size to allocate 123 * @size: size to allocate
124 * @gfp_mask: allocation mask 124 * @gfp_mask: allocation mask
125 * @fclone: allocate from fclone cache instead of head cache
126 * and allocate a cloned (child) skb
125 * 127 *
126 * Allocate a new &sk_buff. The returned buffer has no headroom and a 128 * Allocate a new &sk_buff. The returned buffer has no headroom and a
127 * tail room of size bytes. The object has a reference count of one. 129 * tail room of size bytes. The object has a reference count of one.
@@ -174,6 +176,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
174 skb_shinfo(skb)->tso_size = 0; 176 skb_shinfo(skb)->tso_size = 0;
175 skb_shinfo(skb)->tso_segs = 0; 177 skb_shinfo(skb)->tso_segs = 0;
176 skb_shinfo(skb)->frag_list = NULL; 178 skb_shinfo(skb)->frag_list = NULL;
179 skb_shinfo(skb)->ufo_size = 0;
180 skb_shinfo(skb)->ip6_frag_id = 0;
177out: 181out:
178 return skb; 182 return skb;
179nodata: 183nodata:
@@ -1694,6 +1698,78 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
1694 return textsearch_find(config, state); 1698 return textsearch_find(config, state);
1695} 1699}
1696 1700
1701/**
1702 * skb_append_datato_frags: - append the user data to a skb
1703 * @sk: sock structure
1704 * @skb: skb structure to be appened with user data.
1705 * @getfrag: call back function to be used for getting the user data
1706 * @from: pointer to user message iov
1707 * @length: length of the iov message
1708 *
1709 * Description: This procedure append the user data in the fragment part
1710 * of the skb if any page alloc fails user this procedure returns -ENOMEM
1711 */
1712int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
1713 int getfrag(void *from, char *to, int offset,
1714 int len, int odd, struct sk_buff *skb),
1715 void *from, int length)
1716{
1717 int frg_cnt = 0;
1718 skb_frag_t *frag = NULL;
1719 struct page *page = NULL;
1720 int copy, left;
1721 int offset = 0;
1722 int ret;
1723
1724 do {
1725 /* Return error if we don't have space for new frag */
1726 frg_cnt = skb_shinfo(skb)->nr_frags;
1727 if (frg_cnt >= MAX_SKB_FRAGS)
1728 return -EFAULT;
1729
1730 /* allocate a new page for next frag */
1731 page = alloc_pages(sk->sk_allocation, 0);
1732
1733 /* If alloc_page fails just return failure and caller will
1734 * free previous allocated pages by doing kfree_skb()
1735 */
1736 if (page == NULL)
1737 return -ENOMEM;
1738
1739 /* initialize the next frag */
1740 sk->sk_sndmsg_page = page;
1741 sk->sk_sndmsg_off = 0;
1742 skb_fill_page_desc(skb, frg_cnt, page, 0, 0);
1743 skb->truesize += PAGE_SIZE;
1744 atomic_add(PAGE_SIZE, &sk->sk_wmem_alloc);
1745
1746 /* get the new initialized frag */
1747 frg_cnt = skb_shinfo(skb)->nr_frags;
1748 frag = &skb_shinfo(skb)->frags[frg_cnt - 1];
1749
1750 /* copy the user data to page */
1751 left = PAGE_SIZE - frag->page_offset;
1752 copy = (length > left)? left : length;
1753
1754 ret = getfrag(from, (page_address(frag->page) +
1755 frag->page_offset + frag->size),
1756 offset, copy, 0, skb);
1757 if (ret < 0)
1758 return -EFAULT;
1759
1760 /* copy was successful so update the size parameters */
1761 sk->sk_sndmsg_off += copy;
1762 frag->size += copy;
1763 skb->len += copy;
1764 skb->data_len += copy;
1765 offset += copy;
1766 length -= copy;
1767
1768 } while (length > 0);
1769
1770 return 0;
1771}
1772
1697void __init skb_init(void) 1773void __init skb_init(void)
1698{ 1774{
1699 skbuff_head_cache = kmem_cache_create("skbuff_head_cache", 1775 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
@@ -1745,3 +1821,4 @@ EXPORT_SYMBOL(skb_prepare_seq_read);
1745EXPORT_SYMBOL(skb_seq_read); 1821EXPORT_SYMBOL(skb_seq_read);
1746EXPORT_SYMBOL(skb_abort_seq_read); 1822EXPORT_SYMBOL(skb_abort_seq_read);
1747EXPORT_SYMBOL(skb_find_text); 1823EXPORT_SYMBOL(skb_find_text);
1824EXPORT_SYMBOL(skb_append_datato_frags);
diff --git a/net/core/sock.c b/net/core/sock.c
index 1c52fe809eda..9602ceb3bac9 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -940,7 +940,7 @@ static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
940 int noblock, int *errcode) 940 int noblock, int *errcode)
941{ 941{
942 struct sk_buff *skb; 942 struct sk_buff *skb;
943 unsigned int gfp_mask; 943 gfp_t gfp_mask;
944 long timeo; 944 long timeo;
945 int err; 945 int err;
946 946
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 29250749f16f..d59f86f7ceab 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -495,7 +495,7 @@ void dccp_send_close(struct sock *sk, const int active)
495{ 495{
496 struct dccp_sock *dp = dccp_sk(sk); 496 struct dccp_sock *dp = dccp_sk(sk);
497 struct sk_buff *skb; 497 struct sk_buff *skb;
498 const unsigned int prio = active ? GFP_KERNEL : GFP_ATOMIC; 498 const gfp_t prio = active ? GFP_KERNEL : GFP_ATOMIC;
499 499
500 skb = alloc_skb(sk->sk_prot->max_header, prio); 500 skb = alloc_skb(sk->sk_prot->max_header, prio);
501 if (skb == NULL) 501 if (skb == NULL)
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 1186dc44cdff..3f25cadccddd 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -719,22 +719,9 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
719 if (saddr->sdn_flags & ~SDF_WILD) 719 if (saddr->sdn_flags & ~SDF_WILD)
720 return -EINVAL; 720 return -EINVAL;
721 721
722#if 1
723 if (!capable(CAP_NET_BIND_SERVICE) && (saddr->sdn_objnum || 722 if (!capable(CAP_NET_BIND_SERVICE) && (saddr->sdn_objnum ||
724 (saddr->sdn_flags & SDF_WILD))) 723 (saddr->sdn_flags & SDF_WILD)))
725 return -EACCES; 724 return -EACCES;
726#else
727 /*
728 * Maybe put the default actions in the default security ops for
729 * dn_prot_sock ? Would be nice if the capable call would go there
730 * too.
731 */
732 if (security_dn_prot_sock(saddr) &&
733 !capable(CAP_NET_BIND_SERVICE) ||
734 saddr->sdn_objnum || (saddr->sdn_flags & SDF_WILD))
735 return -EACCES;
736#endif
737
738 725
739 if (!(saddr->sdn_flags & SDF_WILD)) { 726 if (!(saddr->sdn_flags & SDF_WILD)) {
740 if (dn_ntohs(saddr->sdn_nodeaddrl)) { 727 if (dn_ntohs(saddr->sdn_nodeaddrl)) {
diff --git a/net/ieee80211/Makefile b/net/ieee80211/Makefile
index a6ccac5baea8..f988417121da 100644
--- a/net/ieee80211/Makefile
+++ b/net/ieee80211/Makefile
@@ -7,5 +7,6 @@ ieee80211-objs := \
7 ieee80211_module.o \ 7 ieee80211_module.o \
8 ieee80211_tx.o \ 8 ieee80211_tx.o \
9 ieee80211_rx.o \ 9 ieee80211_rx.o \
10 ieee80211_wx.o 10 ieee80211_wx.o \
11 ieee80211_geo.o
11 12
diff --git a/net/ieee80211/ieee80211_crypt.c b/net/ieee80211/ieee80211_crypt.c
index 61a9d92e455b..f3b6aa3be638 100644
--- a/net/ieee80211/ieee80211_crypt.c
+++ b/net/ieee80211/ieee80211_crypt.c
@@ -41,6 +41,12 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force)
41{ 41{
42 struct list_head *ptr, *n; 42 struct list_head *ptr, *n;
43 struct ieee80211_crypt_data *entry; 43 struct ieee80211_crypt_data *entry;
44 unsigned long flags;
45
46 spin_lock_irqsave(&ieee->lock, flags);
47
48 if (list_empty(&ieee->crypt_deinit_list))
49 goto unlock;
44 50
45 for (ptr = ieee->crypt_deinit_list.next, n = ptr->next; 51 for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
46 ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) { 52 ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
@@ -57,6 +63,18 @@ void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force)
57 } 63 }
58 kfree(entry); 64 kfree(entry);
59 } 65 }
66 unlock:
67 spin_unlock_irqrestore(&ieee->lock, flags);
68}
69
70/* After this, crypt_deinit_list won't accept new members */
71void ieee80211_crypt_quiescing(struct ieee80211_device *ieee)
72{
73 unsigned long flags;
74
75 spin_lock_irqsave(&ieee->lock, flags);
76 ieee->crypt_quiesced = 1;
77 spin_unlock_irqrestore(&ieee->lock, flags);
60} 78}
61 79
62void ieee80211_crypt_deinit_handler(unsigned long data) 80void ieee80211_crypt_deinit_handler(unsigned long data)
@@ -64,16 +82,16 @@ void ieee80211_crypt_deinit_handler(unsigned long data)
64 struct ieee80211_device *ieee = (struct ieee80211_device *)data; 82 struct ieee80211_device *ieee = (struct ieee80211_device *)data;
65 unsigned long flags; 83 unsigned long flags;
66 84
67 spin_lock_irqsave(&ieee->lock, flags);
68 ieee80211_crypt_deinit_entries(ieee, 0); 85 ieee80211_crypt_deinit_entries(ieee, 0);
69 if (!list_empty(&ieee->crypt_deinit_list)) { 86
87 spin_lock_irqsave(&ieee->lock, flags);
88 if (!list_empty(&ieee->crypt_deinit_list) && !ieee->crypt_quiesced) {
70 printk(KERN_DEBUG "%s: entries remaining in delayed crypt " 89 printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
71 "deletion list\n", ieee->dev->name); 90 "deletion list\n", ieee->dev->name);
72 ieee->crypt_deinit_timer.expires = jiffies + HZ; 91 ieee->crypt_deinit_timer.expires = jiffies + HZ;
73 add_timer(&ieee->crypt_deinit_timer); 92 add_timer(&ieee->crypt_deinit_timer);
74 } 93 }
75 spin_unlock_irqrestore(&ieee->lock, flags); 94 spin_unlock_irqrestore(&ieee->lock, flags);
76
77} 95}
78 96
79void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, 97void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
@@ -93,10 +111,12 @@ void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
93 * locking. */ 111 * locking. */
94 112
95 spin_lock_irqsave(&ieee->lock, flags); 113 spin_lock_irqsave(&ieee->lock, flags);
96 list_add(&tmp->list, &ieee->crypt_deinit_list); 114 if (!ieee->crypt_quiesced) {
97 if (!timer_pending(&ieee->crypt_deinit_timer)) { 115 list_add(&tmp->list, &ieee->crypt_deinit_list);
98 ieee->crypt_deinit_timer.expires = jiffies + HZ; 116 if (!timer_pending(&ieee->crypt_deinit_timer)) {
99 add_timer(&ieee->crypt_deinit_timer); 117 ieee->crypt_deinit_timer.expires = jiffies + HZ;
118 add_timer(&ieee->crypt_deinit_timer);
119 }
100 } 120 }
101 spin_unlock_irqrestore(&ieee->lock, flags); 121 spin_unlock_irqrestore(&ieee->lock, flags);
102} 122}
@@ -191,18 +211,18 @@ static void ieee80211_crypt_null_deinit(void *priv)
191} 211}
192 212
193static struct ieee80211_crypto_ops ieee80211_crypt_null = { 213static struct ieee80211_crypto_ops ieee80211_crypt_null = {
194 .name = "NULL", 214 .name = "NULL",
195 .init = ieee80211_crypt_null_init, 215 .init = ieee80211_crypt_null_init,
196 .deinit = ieee80211_crypt_null_deinit, 216 .deinit = ieee80211_crypt_null_deinit,
197 .encrypt_mpdu = NULL, 217 .encrypt_mpdu = NULL,
198 .decrypt_mpdu = NULL, 218 .decrypt_mpdu = NULL,
199 .encrypt_msdu = NULL, 219 .encrypt_msdu = NULL,
200 .decrypt_msdu = NULL, 220 .decrypt_msdu = NULL,
201 .set_key = NULL, 221 .set_key = NULL,
202 .get_key = NULL, 222 .get_key = NULL,
203 .extra_prefix_len = 0, 223 .extra_mpdu_prefix_len = 0,
204 .extra_postfix_len = 0, 224 .extra_mpdu_postfix_len = 0,
205 .owner = THIS_MODULE, 225 .owner = THIS_MODULE,
206}; 226};
207 227
208static int __init ieee80211_crypto_init(void) 228static int __init ieee80211_crypto_init(void)
@@ -249,6 +269,7 @@ static void __exit ieee80211_crypto_deinit(void)
249EXPORT_SYMBOL(ieee80211_crypt_deinit_entries); 269EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
250EXPORT_SYMBOL(ieee80211_crypt_deinit_handler); 270EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
251EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit); 271EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
272EXPORT_SYMBOL(ieee80211_crypt_quiescing);
252 273
253EXPORT_SYMBOL(ieee80211_register_crypto_ops); 274EXPORT_SYMBOL(ieee80211_register_crypto_ops);
254EXPORT_SYMBOL(ieee80211_unregister_crypto_ops); 275EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c
index 8fc13f45971e..05a853c13012 100644
--- a/net/ieee80211/ieee80211_crypt_ccmp.c
+++ b/net/ieee80211/ieee80211_crypt_ccmp.c
@@ -119,7 +119,7 @@ static inline void xor_block(u8 * b, u8 * a, size_t len)
119} 119}
120 120
121static void ccmp_init_blocks(struct crypto_tfm *tfm, 121static void ccmp_init_blocks(struct crypto_tfm *tfm,
122 struct ieee80211_hdr *hdr, 122 struct ieee80211_hdr_4addr *hdr,
123 u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0) 123 u8 * pn, size_t dlen, u8 * b0, u8 * auth, u8 * s0)
124{ 124{
125 u8 *pos, qc = 0; 125 u8 *pos, qc = 0;
@@ -191,26 +191,18 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
191 ieee80211_ccmp_aes_encrypt(tfm, b0, s0); 191 ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
192} 192}
193 193
194static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 194static int ieee80211_ccmp_hdr(struct sk_buff *skb, int hdr_len, void *priv)
195{ 195{
196 struct ieee80211_ccmp_data *key = priv; 196 struct ieee80211_ccmp_data *key = priv;
197 int data_len, i, blocks, last, len; 197 int i;
198 u8 *pos, *mic; 198 u8 *pos;
199 struct ieee80211_hdr *hdr;
200 u8 *b0 = key->tx_b0;
201 u8 *b = key->tx_b;
202 u8 *e = key->tx_e;
203 u8 *s0 = key->tx_s0;
204 199
205 if (skb_headroom(skb) < CCMP_HDR_LEN || 200 if (skb_headroom(skb) < CCMP_HDR_LEN || skb->len < hdr_len)
206 skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len)
207 return -1; 201 return -1;
208 202
209 data_len = skb->len - hdr_len;
210 pos = skb_push(skb, CCMP_HDR_LEN); 203 pos = skb_push(skb, CCMP_HDR_LEN);
211 memmove(pos, pos + CCMP_HDR_LEN, hdr_len); 204 memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
212 pos += hdr_len; 205 pos += hdr_len;
213 mic = skb_put(skb, CCMP_MIC_LEN);
214 206
215 i = CCMP_PN_LEN - 1; 207 i = CCMP_PN_LEN - 1;
216 while (i >= 0) { 208 while (i >= 0) {
@@ -229,7 +221,31 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
229 *pos++ = key->tx_pn[1]; 221 *pos++ = key->tx_pn[1];
230 *pos++ = key->tx_pn[0]; 222 *pos++ = key->tx_pn[0];
231 223
232 hdr = (struct ieee80211_hdr *)skb->data; 224 return CCMP_HDR_LEN;
225}
226
227static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
228{
229 struct ieee80211_ccmp_data *key = priv;
230 int data_len, i, blocks, last, len;
231 u8 *pos, *mic;
232 struct ieee80211_hdr_4addr *hdr;
233 u8 *b0 = key->tx_b0;
234 u8 *b = key->tx_b;
235 u8 *e = key->tx_e;
236 u8 *s0 = key->tx_s0;
237
238 if (skb_tailroom(skb) < CCMP_MIC_LEN || skb->len < hdr_len)
239 return -1;
240
241 data_len = skb->len - hdr_len;
242 len = ieee80211_ccmp_hdr(skb, hdr_len, priv);
243 if (len < 0)
244 return -1;
245
246 pos = skb->data + hdr_len + CCMP_HDR_LEN;
247 mic = skb_put(skb, CCMP_MIC_LEN);
248 hdr = (struct ieee80211_hdr_4addr *)skb->data;
233 ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0); 249 ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
234 250
235 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN; 251 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
@@ -258,7 +274,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
258{ 274{
259 struct ieee80211_ccmp_data *key = priv; 275 struct ieee80211_ccmp_data *key = priv;
260 u8 keyidx, *pos; 276 u8 keyidx, *pos;
261 struct ieee80211_hdr *hdr; 277 struct ieee80211_hdr_4addr *hdr;
262 u8 *b0 = key->rx_b0; 278 u8 *b0 = key->rx_b0;
263 u8 *b = key->rx_b; 279 u8 *b = key->rx_b;
264 u8 *a = key->rx_a; 280 u8 *a = key->rx_a;
@@ -272,7 +288,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
272 return -1; 288 return -1;
273 } 289 }
274 290
275 hdr = (struct ieee80211_hdr *)skb->data; 291 hdr = (struct ieee80211_hdr_4addr *)skb->data;
276 pos = skb->data + hdr_len; 292 pos = skb->data + hdr_len;
277 keyidx = pos[3]; 293 keyidx = pos[3];
278 if (!(keyidx & (1 << 5))) { 294 if (!(keyidx & (1 << 5))) {
@@ -426,19 +442,20 @@ static char *ieee80211_ccmp_print_stats(char *p, void *priv)
426} 442}
427 443
428static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { 444static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
429 .name = "CCMP", 445 .name = "CCMP",
430 .init = ieee80211_ccmp_init, 446 .init = ieee80211_ccmp_init,
431 .deinit = ieee80211_ccmp_deinit, 447 .deinit = ieee80211_ccmp_deinit,
432 .encrypt_mpdu = ieee80211_ccmp_encrypt, 448 .build_iv = ieee80211_ccmp_hdr,
433 .decrypt_mpdu = ieee80211_ccmp_decrypt, 449 .encrypt_mpdu = ieee80211_ccmp_encrypt,
434 .encrypt_msdu = NULL, 450 .decrypt_mpdu = ieee80211_ccmp_decrypt,
435 .decrypt_msdu = NULL, 451 .encrypt_msdu = NULL,
436 .set_key = ieee80211_ccmp_set_key, 452 .decrypt_msdu = NULL,
437 .get_key = ieee80211_ccmp_get_key, 453 .set_key = ieee80211_ccmp_set_key,
438 .print_stats = ieee80211_ccmp_print_stats, 454 .get_key = ieee80211_ccmp_get_key,
439 .extra_prefix_len = CCMP_HDR_LEN, 455 .print_stats = ieee80211_ccmp_print_stats,
440 .extra_postfix_len = CCMP_MIC_LEN, 456 .extra_mpdu_prefix_len = CCMP_HDR_LEN,
441 .owner = THIS_MODULE, 457 .extra_mpdu_postfix_len = CCMP_MIC_LEN,
458 .owner = THIS_MODULE,
442}; 459};
443 460
444static int __init ieee80211_crypto_ccmp_init(void) 461static int __init ieee80211_crypto_ccmp_init(void)
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index d4f9164be1a1..2e34f29b7956 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -59,8 +59,24 @@ struct ieee80211_tkip_data {
59 59
60 /* scratch buffers for virt_to_page() (crypto API) */ 60 /* scratch buffers for virt_to_page() (crypto API) */
61 u8 rx_hdr[16], tx_hdr[16]; 61 u8 rx_hdr[16], tx_hdr[16];
62
63 unsigned long flags;
62}; 64};
63 65
66static unsigned long ieee80211_tkip_set_flags(unsigned long flags, void *priv)
67{
68 struct ieee80211_tkip_data *_priv = priv;
69 unsigned long old_flags = _priv->flags;
70 _priv->flags = flags;
71 return old_flags;
72}
73
74static unsigned long ieee80211_tkip_get_flags(void *priv)
75{
76 struct ieee80211_tkip_data *_priv = priv;
77 return _priv->flags;
78}
79
64static void *ieee80211_tkip_init(int key_idx) 80static void *ieee80211_tkip_init(int key_idx)
65{ 81{
66 struct ieee80211_tkip_data *priv; 82 struct ieee80211_tkip_data *priv;
@@ -69,6 +85,7 @@ static void *ieee80211_tkip_init(int key_idx)
69 if (priv == NULL) 85 if (priv == NULL)
70 goto fail; 86 goto fail;
71 memset(priv, 0, sizeof(*priv)); 87 memset(priv, 0, sizeof(*priv));
88
72 priv->key_idx = key_idx; 89 priv->key_idx = key_idx;
73 90
74 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); 91 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
@@ -255,25 +272,27 @@ static void tkip_mixing_phase2(u8 * WEPSeed, const u8 * TK, const u16 * TTAK,
255#endif 272#endif
256} 273}
257 274
258static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) 275static u8 *ieee80211_tkip_hdr(struct sk_buff *skb, int hdr_len, void *priv)
259{ 276{
260 struct ieee80211_tkip_data *tkey = priv; 277 struct ieee80211_tkip_data *tkey = priv;
261 int len; 278 int len;
262 u8 rc4key[16], *pos, *icv; 279 u8 *rc4key, *pos, *icv;
263 struct ieee80211_hdr *hdr; 280 struct ieee80211_hdr_4addr *hdr;
264 u32 crc; 281 u32 crc;
265 struct scatterlist sg;
266 282
267 if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 || 283 hdr = (struct ieee80211_hdr_4addr *)skb->data;
268 skb->len < hdr_len) 284
269 return -1; 285 if (skb_headroom(skb) < 8 || skb->len < hdr_len)
286 return NULL;
270 287
271 hdr = (struct ieee80211_hdr *)skb->data;
272 if (!tkey->tx_phase1_done) { 288 if (!tkey->tx_phase1_done) {
273 tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, 289 tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
274 tkey->tx_iv32); 290 tkey->tx_iv32);
275 tkey->tx_phase1_done = 1; 291 tkey->tx_phase1_done = 1;
276 } 292 }
293 rc4key = kmalloc(16, GFP_ATOMIC);
294 if (!rc4key)
295 return NULL;
277 tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); 296 tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
278 297
279 len = skb->len - hdr_len; 298 len = skb->len - hdr_len;
@@ -282,9 +301,9 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
282 pos += hdr_len; 301 pos += hdr_len;
283 icv = skb_put(skb, 4); 302 icv = skb_put(skb, 4);
284 303
285 *pos++ = rc4key[0]; 304 *pos++ = *rc4key;
286 *pos++ = rc4key[1]; 305 *pos++ = *(rc4key + 1);
287 *pos++ = rc4key[2]; 306 *pos++ = *(rc4key + 2);
288 *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ; 307 *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */ ;
289 *pos++ = tkey->tx_iv32 & 0xff; 308 *pos++ = tkey->tx_iv32 & 0xff;
290 *pos++ = (tkey->tx_iv32 >> 8) & 0xff; 309 *pos++ = (tkey->tx_iv32 >> 8) & 0xff;
@@ -297,6 +316,38 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
297 icv[2] = crc >> 16; 316 icv[2] = crc >> 16;
298 icv[3] = crc >> 24; 317 icv[3] = crc >> 24;
299 318
319 return rc4key;
320}
321
322static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
323{
324 struct ieee80211_tkip_data *tkey = priv;
325 int len;
326 const u8 *rc4key;
327 u8 *pos;
328 struct scatterlist sg;
329
330 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
331 if (net_ratelimit()) {
332 struct ieee80211_hdr_4addr *hdr =
333 (struct ieee80211_hdr_4addr *)skb->data;
334 printk(KERN_DEBUG "TKIP countermeasures: dropped "
335 "TX packet to " MAC_FMT "\n",
336 MAC_ARG(hdr->addr1));
337 }
338 return -1;
339 }
340
341 if (skb_tailroom(skb) < 4 || skb->len < hdr_len)
342 return -1;
343
344 len = skb->len - hdr_len;
345 pos = skb->data + hdr_len;
346
347 rc4key = ieee80211_tkip_hdr(skb, hdr_len, priv);
348 if (!rc4key)
349 return -1;
350
300 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16); 351 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
301 sg.page = virt_to_page(pos); 352 sg.page = virt_to_page(pos);
302 sg.offset = offset_in_page(pos); 353 sg.offset = offset_in_page(pos);
@@ -319,16 +370,26 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
319 u8 keyidx, *pos; 370 u8 keyidx, *pos;
320 u32 iv32; 371 u32 iv32;
321 u16 iv16; 372 u16 iv16;
322 struct ieee80211_hdr *hdr; 373 struct ieee80211_hdr_4addr *hdr;
323 u8 icv[4]; 374 u8 icv[4];
324 u32 crc; 375 u32 crc;
325 struct scatterlist sg; 376 struct scatterlist sg;
326 int plen; 377 int plen;
327 378
379 hdr = (struct ieee80211_hdr_4addr *)skb->data;
380
381 if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
382 if (net_ratelimit()) {
383 printk(KERN_DEBUG "TKIP countermeasures: dropped "
384 "received packet from " MAC_FMT "\n",
385 MAC_ARG(hdr->addr2));
386 }
387 return -1;
388 }
389
328 if (skb->len < hdr_len + 8 + 4) 390 if (skb->len < hdr_len + 8 + 4)
329 return -1; 391 return -1;
330 392
331 hdr = (struct ieee80211_hdr *)skb->data;
332 pos = skb->data + hdr_len; 393 pos = skb->data + hdr_len;
333 keyidx = pos[3]; 394 keyidx = pos[3];
334 if (!(keyidx & (1 << 5))) { 395 if (!(keyidx & (1 << 5))) {
@@ -441,9 +502,9 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,
441 502
442static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) 503static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
443{ 504{
444 struct ieee80211_hdr *hdr11; 505 struct ieee80211_hdr_4addr *hdr11;
445 506
446 hdr11 = (struct ieee80211_hdr *)skb->data; 507 hdr11 = (struct ieee80211_hdr_4addr *)skb->data;
447 switch (le16_to_cpu(hdr11->frame_ctl) & 508 switch (le16_to_cpu(hdr11->frame_ctl) &
448 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 509 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
449 case IEEE80211_FCTL_TODS: 510 case IEEE80211_FCTL_TODS:
@@ -490,9 +551,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len,
490 return 0; 551 return 0;
491} 552}
492 553
493#if WIRELESS_EXT >= 18
494static void ieee80211_michael_mic_failure(struct net_device *dev, 554static void ieee80211_michael_mic_failure(struct net_device *dev,
495 struct ieee80211_hdr *hdr, int keyidx) 555 struct ieee80211_hdr_4addr *hdr,
556 int keyidx)
496{ 557{
497 union iwreq_data wrqu; 558 union iwreq_data wrqu;
498 struct iw_michaelmicfailure ev; 559 struct iw_michaelmicfailure ev;
@@ -510,28 +571,6 @@ static void ieee80211_michael_mic_failure(struct net_device *dev,
510 wrqu.data.length = sizeof(ev); 571 wrqu.data.length = sizeof(ev);
511 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); 572 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
512} 573}
513#elif WIRELESS_EXT >= 15
514static void ieee80211_michael_mic_failure(struct net_device *dev,
515 struct ieee80211_hdr *hdr, int keyidx)
516{
517 union iwreq_data wrqu;
518 char buf[128];
519
520 /* TODO: needed parameters: count, keyid, key type, TSC */
521 sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
522 MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
523 MAC_ARG(hdr->addr2));
524 memset(&wrqu, 0, sizeof(wrqu));
525 wrqu.data.length = strlen(buf);
526 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
527}
528#else /* WIRELESS_EXT >= 15 */
529static inline void ieee80211_michael_mic_failure(struct net_device *dev,
530 struct ieee80211_hdr *hdr,
531 int keyidx)
532{
533}
534#endif /* WIRELESS_EXT >= 15 */
535 574
536static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, 575static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
537 int hdr_len, void *priv) 576 int hdr_len, void *priv)
@@ -547,8 +586,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
547 skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) 586 skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
548 return -1; 587 return -1;
549 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { 588 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
550 struct ieee80211_hdr *hdr; 589 struct ieee80211_hdr_4addr *hdr;
551 hdr = (struct ieee80211_hdr *)skb->data; 590 hdr = (struct ieee80211_hdr_4addr *)skb->data;
552 printk(KERN_DEBUG "%s: Michael MIC verification failed for " 591 printk(KERN_DEBUG "%s: Michael MIC verification failed for "
553 "MSDU from " MAC_FMT " keyidx=%d\n", 592 "MSDU from " MAC_FMT " keyidx=%d\n",
554 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), 593 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
@@ -654,19 +693,22 @@ static char *ieee80211_tkip_print_stats(char *p, void *priv)
654} 693}
655 694
656static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { 695static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
657 .name = "TKIP", 696 .name = "TKIP",
658 .init = ieee80211_tkip_init, 697 .init = ieee80211_tkip_init,
659 .deinit = ieee80211_tkip_deinit, 698 .deinit = ieee80211_tkip_deinit,
660 .encrypt_mpdu = ieee80211_tkip_encrypt, 699 .encrypt_mpdu = ieee80211_tkip_encrypt,
661 .decrypt_mpdu = ieee80211_tkip_decrypt, 700 .decrypt_mpdu = ieee80211_tkip_decrypt,
662 .encrypt_msdu = ieee80211_michael_mic_add, 701 .encrypt_msdu = ieee80211_michael_mic_add,
663 .decrypt_msdu = ieee80211_michael_mic_verify, 702 .decrypt_msdu = ieee80211_michael_mic_verify,
664 .set_key = ieee80211_tkip_set_key, 703 .set_key = ieee80211_tkip_set_key,
665 .get_key = ieee80211_tkip_get_key, 704 .get_key = ieee80211_tkip_get_key,
666 .print_stats = ieee80211_tkip_print_stats, 705 .print_stats = ieee80211_tkip_print_stats,
667 .extra_prefix_len = 4 + 4, /* IV + ExtIV */ 706 .extra_mpdu_prefix_len = 4 + 4, /* IV + ExtIV */
668 .extra_postfix_len = 8 + 4, /* MIC + ICV */ 707 .extra_mpdu_postfix_len = 4, /* ICV */
669 .owner = THIS_MODULE, 708 .extra_msdu_postfix_len = 8, /* MIC */
709 .get_flags = ieee80211_tkip_get_flags,
710 .set_flags = ieee80211_tkip_set_flags,
711 .owner = THIS_MODULE,
670}; 712};
671 713
672static int __init ieee80211_crypto_tkip_init(void) 714static int __init ieee80211_crypto_tkip_init(void)
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index b4d2514a0902..7c08ed2f2628 100644
--- a/net/ieee80211/ieee80211_crypt_wep.c
+++ b/net/ieee80211/ieee80211_crypt_wep.c
@@ -229,19 +229,19 @@ static char *prism2_wep_print_stats(char *p, void *priv)
229} 229}
230 230
231static struct ieee80211_crypto_ops ieee80211_crypt_wep = { 231static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
232 .name = "WEP", 232 .name = "WEP",
233 .init = prism2_wep_init, 233 .init = prism2_wep_init,
234 .deinit = prism2_wep_deinit, 234 .deinit = prism2_wep_deinit,
235 .encrypt_mpdu = prism2_wep_encrypt, 235 .encrypt_mpdu = prism2_wep_encrypt,
236 .decrypt_mpdu = prism2_wep_decrypt, 236 .decrypt_mpdu = prism2_wep_decrypt,
237 .encrypt_msdu = NULL, 237 .encrypt_msdu = NULL,
238 .decrypt_msdu = NULL, 238 .decrypt_msdu = NULL,
239 .set_key = prism2_wep_set_key, 239 .set_key = prism2_wep_set_key,
240 .get_key = prism2_wep_get_key, 240 .get_key = prism2_wep_get_key,
241 .print_stats = prism2_wep_print_stats, 241 .print_stats = prism2_wep_print_stats,
242 .extra_prefix_len = 4, /* IV */ 242 .extra_mpdu_prefix_len = 4, /* IV */
243 .extra_postfix_len = 4, /* ICV */ 243 .extra_mpdu_postfix_len = 4, /* ICV */
244 .owner = THIS_MODULE, 244 .owner = THIS_MODULE,
245}; 245};
246 246
247static int __init ieee80211_crypto_wep_init(void) 247static int __init ieee80211_crypto_wep_init(void)
diff --git a/net/ieee80211/ieee80211_geo.c b/net/ieee80211/ieee80211_geo.c
new file mode 100644
index 000000000000..c4b54ef8f6d5
--- /dev/null
+++ b/net/ieee80211/ieee80211_geo.c
@@ -0,0 +1,141 @@
1/******************************************************************************
2
3 Copyright(c) 2005 Intel Corporation. All rights reserved.
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of version 2 of the GNU General Public License as
7 published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc., 59
16 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 The full GNU General Public License is included in this distribution in the
19 file called LICENSE.
20
21 Contact Information:
22 James P. Ketrenos <ipw2100-admin@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24
25******************************************************************************/
26#include <linux/compiler.h>
27#include <linux/config.h>
28#include <linux/errno.h>
29#include <linux/if_arp.h>
30#include <linux/in6.h>
31#include <linux/in.h>
32#include <linux/ip.h>
33#include <linux/kernel.h>
34#include <linux/module.h>
35#include <linux/netdevice.h>
36#include <linux/proc_fs.h>
37#include <linux/skbuff.h>
38#include <linux/slab.h>
39#include <linux/tcp.h>
40#include <linux/types.h>
41#include <linux/version.h>
42#include <linux/wireless.h>
43#include <linux/etherdevice.h>
44#include <asm/uaccess.h>
45
46#include <net/ieee80211.h>
47
48int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel)
49{
50 int i;
51
52 /* Driver needs to initialize the geography map before using
53 * these helper functions */
54 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
55
56 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
57 for (i = 0; i < ieee->geo.bg_channels; i++)
58 /* NOTE: If G mode is currently supported but
59 * this is a B only channel, we don't see it
60 * as valid. */
61 if ((ieee->geo.bg[i].channel == channel) &&
62 (!(ieee->mode & IEEE_G) ||
63 !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY)))
64 return IEEE80211_24GHZ_BAND;
65
66 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
67 for (i = 0; i < ieee->geo.a_channels; i++)
68 if (ieee->geo.a[i].channel == channel)
69 return IEEE80211_52GHZ_BAND;
70
71 return 0;
72}
73
74int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel)
75{
76 int i;
77
78 /* Driver needs to initialize the geography map before using
79 * these helper functions */
80 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
81
82 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
83 for (i = 0; i < ieee->geo.bg_channels; i++)
84 if (ieee->geo.bg[i].channel == channel)
85 return i;
86
87 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
88 for (i = 0; i < ieee->geo.a_channels; i++)
89 if (ieee->geo.a[i].channel == channel)
90 return i;
91
92 return -1;
93}
94
95u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq)
96{
97 int i;
98
99 /* Driver needs to initialize the geography map before using
100 * these helper functions */
101 BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
102
103 freq /= 100000;
104
105 if (ieee->freq_band & IEEE80211_24GHZ_BAND)
106 for (i = 0; i < ieee->geo.bg_channels; i++)
107 if (ieee->geo.bg[i].freq == freq)
108 return ieee->geo.bg[i].channel;
109
110 if (ieee->freq_band & IEEE80211_52GHZ_BAND)
111 for (i = 0; i < ieee->geo.a_channels; i++)
112 if (ieee->geo.a[i].freq == freq)
113 return ieee->geo.a[i].channel;
114
115 return 0;
116}
117
118int ieee80211_set_geo(struct ieee80211_device *ieee,
119 const struct ieee80211_geo *geo)
120{
121 memcpy(ieee->geo.name, geo->name, 3);
122 ieee->geo.name[3] = '\0';
123 ieee->geo.bg_channels = geo->bg_channels;
124 ieee->geo.a_channels = geo->a_channels;
125 memcpy(ieee->geo.bg, geo->bg, geo->bg_channels *
126 sizeof(struct ieee80211_channel));
127 memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels *
128 sizeof(struct ieee80211_channel));
129 return 0;
130}
131
132const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device *ieee)
133{
134 return &ieee->geo;
135}
136
137EXPORT_SYMBOL(ieee80211_is_valid_channel);
138EXPORT_SYMBOL(ieee80211_freq_to_channel);
139EXPORT_SYMBOL(ieee80211_channel_to_index);
140EXPORT_SYMBOL(ieee80211_set_geo);
141EXPORT_SYMBOL(ieee80211_get_geo);
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 6059e9e37123..f66d792cd204 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -1,6 +1,6 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Copyright(c) 2004 Intel Corporation. All rights reserved. 3 Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
4 4
5 Portions of this file are based on the WEP enablement code provided by the 5 Portions of this file are based on the WEP enablement code provided by the
6 Host AP project hostap-drivers v0.1.3 6 Host AP project hostap-drivers v0.1.3
@@ -53,12 +53,15 @@
53 53
54#include <net/ieee80211.h> 54#include <net/ieee80211.h>
55 55
56MODULE_DESCRIPTION("802.11 data/management/control stack"); 56#define DRV_DESCRIPTION "802.11 data/management/control stack"
57MODULE_AUTHOR 57#define DRV_NAME "ieee80211"
58 ("Copyright (C) 2004 Intel Corporation <jketreno@linux.intel.com>"); 58#define DRV_VERSION IEEE80211_VERSION
59MODULE_LICENSE("GPL"); 59#define DRV_COPYRIGHT "Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>"
60 60
61#define DRV_NAME "ieee80211" 61MODULE_VERSION(DRV_VERSION);
62MODULE_DESCRIPTION(DRV_DESCRIPTION);
63MODULE_AUTHOR(DRV_COPYRIGHT);
64MODULE_LICENSE("GPL");
62 65
63static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee) 66static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
64{ 67{
@@ -126,26 +129,34 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
126 129
127 /* Default fragmentation threshold is maximum payload size */ 130 /* Default fragmentation threshold is maximum payload size */
128 ieee->fts = DEFAULT_FTS; 131 ieee->fts = DEFAULT_FTS;
132 ieee->rts = DEFAULT_FTS;
129 ieee->scan_age = DEFAULT_MAX_SCAN_AGE; 133 ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
130 ieee->open_wep = 1; 134 ieee->open_wep = 1;
131 135
132 /* Default to enabling full open WEP with host based encrypt/decrypt */ 136 /* Default to enabling full open WEP with host based encrypt/decrypt */
133 ieee->host_encrypt = 1; 137 ieee->host_encrypt = 1;
134 ieee->host_decrypt = 1; 138 ieee->host_decrypt = 1;
139 ieee->host_mc_decrypt = 1;
140
141 /* Host fragementation in Open mode. Default is enabled.
142 * Note: host fragmentation is always enabled if host encryption
143 * is enabled. For cards can do hardware encryption, they must do
144 * hardware fragmentation as well. So we don't need a variable
145 * like host_enc_frag. */
146 ieee->host_open_frag = 1;
135 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */ 147 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
136 148
137 INIT_LIST_HEAD(&ieee->crypt_deinit_list); 149 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
138 init_timer(&ieee->crypt_deinit_timer); 150 init_timer(&ieee->crypt_deinit_timer);
139 ieee->crypt_deinit_timer.data = (unsigned long)ieee; 151 ieee->crypt_deinit_timer.data = (unsigned long)ieee;
140 ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler; 152 ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
153 ieee->crypt_quiesced = 0;
141 154
142 spin_lock_init(&ieee->lock); 155 spin_lock_init(&ieee->lock);
143 156
144 ieee->wpa_enabled = 0; 157 ieee->wpa_enabled = 0;
145 ieee->tkip_countermeasures = 0;
146 ieee->drop_unencrypted = 0; 158 ieee->drop_unencrypted = 0;
147 ieee->privacy_invoked = 0; 159 ieee->privacy_invoked = 0;
148 ieee->ieee802_1x = 1;
149 160
150 return dev; 161 return dev;
151 162
@@ -161,6 +172,7 @@ void free_ieee80211(struct net_device *dev)
161 172
162 int i; 173 int i;
163 174
175 ieee80211_crypt_quiescing(ieee);
164 del_timer_sync(&ieee->crypt_deinit_timer); 176 del_timer_sync(&ieee->crypt_deinit_timer);
165 ieee80211_crypt_deinit_entries(ieee, 1); 177 ieee80211_crypt_deinit_entries(ieee, 1);
166 178
@@ -195,38 +207,26 @@ static int show_debug_level(char *page, char **start, off_t offset,
195static int store_debug_level(struct file *file, const char __user * buffer, 207static int store_debug_level(struct file *file, const char __user * buffer,
196 unsigned long count, void *data) 208 unsigned long count, void *data)
197{ 209{
198 char buf[] = "0x00000000"; 210 char buf[] = "0x00000000\n";
199 char *p = (char *)buf; 211 unsigned long len = min((unsigned long)sizeof(buf) - 1, count);
200 unsigned long val; 212 unsigned long val;
201 213
202 if (count > sizeof(buf) - 1) 214 if (copy_from_user(buf, buffer, len))
203 count = sizeof(buf) - 1;
204
205 if (copy_from_user(buf, buffer, count))
206 return count; 215 return count;
207 buf[count] = 0; 216 buf[len] = 0;
208 /* 217 if (sscanf(buf, "%li", &val) != 1)
209 * what a FPOS... What, sscanf(buf, "%i", &val) would be too
210 * scary?
211 */
212 if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
213 p++;
214 if (p[0] == 'x' || p[0] == 'X')
215 p++;
216 val = simple_strtoul(p, &p, 16);
217 } else
218 val = simple_strtoul(p, &p, 10);
219 if (p == buf)
220 printk(KERN_INFO DRV_NAME 218 printk(KERN_INFO DRV_NAME
221 ": %s is not in hex or decimal form.\n", buf); 219 ": %s is not in hex or decimal form.\n", buf);
222 else 220 else
223 ieee80211_debug_level = val; 221 ieee80211_debug_level = val;
224 222
225 return strlen(buf); 223 return strnlen(buf, len);
226} 224}
225#endif /* CONFIG_IEEE80211_DEBUG */
227 226
228static int __init ieee80211_init(void) 227static int __init ieee80211_init(void)
229{ 228{
229#ifdef CONFIG_IEEE80211_DEBUG
230 struct proc_dir_entry *e; 230 struct proc_dir_entry *e;
231 231
232 ieee80211_debug_level = debug; 232 ieee80211_debug_level = debug;
@@ -246,26 +246,33 @@ static int __init ieee80211_init(void)
246 e->read_proc = show_debug_level; 246 e->read_proc = show_debug_level;
247 e->write_proc = store_debug_level; 247 e->write_proc = store_debug_level;
248 e->data = NULL; 248 e->data = NULL;
249#endif /* CONFIG_IEEE80211_DEBUG */
250
251 printk(KERN_INFO DRV_NAME ": " DRV_DESCRIPTION ", " DRV_VERSION "\n");
252 printk(KERN_INFO DRV_NAME ": " DRV_COPYRIGHT "\n");
249 253
250 return 0; 254 return 0;
251} 255}
252 256
253static void __exit ieee80211_exit(void) 257static void __exit ieee80211_exit(void)
254{ 258{
259#ifdef CONFIG_IEEE80211_DEBUG
255 if (ieee80211_proc) { 260 if (ieee80211_proc) {
256 remove_proc_entry("debug_level", ieee80211_proc); 261 remove_proc_entry("debug_level", ieee80211_proc);
257 remove_proc_entry(DRV_NAME, proc_net); 262 remove_proc_entry(DRV_NAME, proc_net);
258 ieee80211_proc = NULL; 263 ieee80211_proc = NULL;
259 } 264 }
265#endif /* CONFIG_IEEE80211_DEBUG */
260} 266}
261 267
268#ifdef CONFIG_IEEE80211_DEBUG
262#include <linux/moduleparam.h> 269#include <linux/moduleparam.h>
263module_param(debug, int, 0444); 270module_param(debug, int, 0444);
264MODULE_PARM_DESC(debug, "debug output mask"); 271MODULE_PARM_DESC(debug, "debug output mask");
272#endif /* CONFIG_IEEE80211_DEBUG */
265 273
266module_exit(ieee80211_exit); 274module_exit(ieee80211_exit);
267module_init(ieee80211_init); 275module_init(ieee80211_init);
268#endif
269 276
270const char *escape_essid(const char *essid, u8 essid_len) 277const char *escape_essid(const char *essid, u8 essid_len)
271{ 278{
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index f7dcd854139e..ce694cf5c160 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -5,7 +5,7 @@
5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen 5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
6 * <jkmaline@cc.hut.fi> 6 * <jkmaline@cc.hut.fi>
7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> 7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8 * Copyright (c) 2004, Intel Corporation 8 * Copyright (c) 2004-2005, Intel Corporation
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
@@ -87,7 +87,7 @@ static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct
87 87
88/* Called only as a tasklet (software IRQ) */ 88/* Called only as a tasklet (software IRQ) */
89static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee, 89static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
90 struct ieee80211_hdr *hdr) 90 struct ieee80211_hdr_4addr *hdr)
91{ 91{
92 struct sk_buff *skb = NULL; 92 struct sk_buff *skb = NULL;
93 u16 sc; 93 u16 sc;
@@ -101,7 +101,7 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
101 if (frag == 0) { 101 if (frag == 0) {
102 /* Reserve enough space to fit maximum frame length */ 102 /* Reserve enough space to fit maximum frame length */
103 skb = dev_alloc_skb(ieee->dev->mtu + 103 skb = dev_alloc_skb(ieee->dev->mtu +
104 sizeof(struct ieee80211_hdr) + 104 sizeof(struct ieee80211_hdr_4addr) +
105 8 /* LLC */ + 105 8 /* LLC */ +
106 2 /* alignment */ + 106 2 /* alignment */ +
107 8 /* WEP */ + ETH_ALEN /* WDS */ ); 107 8 /* WEP */ + ETH_ALEN /* WDS */ );
@@ -138,7 +138,7 @@ static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
138 138
139/* Called only as a tasklet (software IRQ) */ 139/* Called only as a tasklet (software IRQ) */
140static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, 140static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
141 struct ieee80211_hdr *hdr) 141 struct ieee80211_hdr_4addr *hdr)
142{ 142{
143 u16 sc; 143 u16 sc;
144 unsigned int seq; 144 unsigned int seq;
@@ -176,7 +176,7 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
176 ieee->dev->name); 176 ieee->dev->name);
177 return 0; 177 return 0;
178/* 178/*
179 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr *) 179 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
180 skb->data);*/ 180 skb->data);*/
181 } 181 }
182 182
@@ -232,13 +232,13 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
232{ 232{
233 struct net_device *dev = ieee->dev; 233 struct net_device *dev = ieee->dev;
234 u16 fc, ethertype; 234 u16 fc, ethertype;
235 struct ieee80211_hdr *hdr; 235 struct ieee80211_hdr_3addr *hdr;
236 u8 *pos; 236 u8 *pos;
237 237
238 if (skb->len < 24) 238 if (skb->len < 24)
239 return 0; 239 return 0;
240 240
241 hdr = (struct ieee80211_hdr *)skb->data; 241 hdr = (struct ieee80211_hdr_3addr *)skb->data;
242 fc = le16_to_cpu(hdr->frame_ctl); 242 fc = le16_to_cpu(hdr->frame_ctl);
243 243
244 /* check that the frame is unicast frame to us */ 244 /* check that the frame is unicast frame to us */
@@ -271,26 +271,15 @@ static inline int
271ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, 271ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
272 struct ieee80211_crypt_data *crypt) 272 struct ieee80211_crypt_data *crypt)
273{ 273{
274 struct ieee80211_hdr *hdr; 274 struct ieee80211_hdr_3addr *hdr;
275 int res, hdrlen; 275 int res, hdrlen;
276 276
277 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) 277 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
278 return 0; 278 return 0;
279 279
280 hdr = (struct ieee80211_hdr *)skb->data; 280 hdr = (struct ieee80211_hdr_3addr *)skb->data;
281 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 281 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
282 282
283#ifdef CONFIG_IEEE80211_CRYPT_TKIP
284 if (ieee->tkip_countermeasures && strcmp(crypt->ops->name, "TKIP") == 0) {
285 if (net_ratelimit()) {
286 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
287 "received packet from " MAC_FMT "\n",
288 ieee->dev->name, MAC_ARG(hdr->addr2));
289 }
290 return -1;
291 }
292#endif
293
294 atomic_inc(&crypt->refcnt); 283 atomic_inc(&crypt->refcnt);
295 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv); 284 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
296 atomic_dec(&crypt->refcnt); 285 atomic_dec(&crypt->refcnt);
@@ -314,13 +303,13 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
314 struct sk_buff *skb, int keyidx, 303 struct sk_buff *skb, int keyidx,
315 struct ieee80211_crypt_data *crypt) 304 struct ieee80211_crypt_data *crypt)
316{ 305{
317 struct ieee80211_hdr *hdr; 306 struct ieee80211_hdr_3addr *hdr;
318 int res, hdrlen; 307 int res, hdrlen;
319 308
320 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) 309 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
321 return 0; 310 return 0;
322 311
323 hdr = (struct ieee80211_hdr *)skb->data; 312 hdr = (struct ieee80211_hdr_3addr *)skb->data;
324 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 313 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
325 314
326 atomic_inc(&crypt->refcnt); 315 atomic_inc(&crypt->refcnt);
@@ -343,7 +332,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
343 struct ieee80211_rx_stats *rx_stats) 332 struct ieee80211_rx_stats *rx_stats)
344{ 333{
345 struct net_device *dev = ieee->dev; 334 struct net_device *dev = ieee->dev;
346 struct ieee80211_hdr *hdr; 335 struct ieee80211_hdr_4addr *hdr;
347 size_t hdrlen; 336 size_t hdrlen;
348 u16 fc, type, stype, sc; 337 u16 fc, type, stype, sc;
349 struct net_device_stats *stats; 338 struct net_device_stats *stats;
@@ -363,7 +352,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
363 struct ieee80211_crypt_data *crypt = NULL; 352 struct ieee80211_crypt_data *crypt = NULL;
364 int keyidx = 0; 353 int keyidx = 0;
365 354
366 hdr = (struct ieee80211_hdr *)skb->data; 355 hdr = (struct ieee80211_hdr_4addr *)skb->data;
367 stats = &ieee->stats; 356 stats = &ieee->stats;
368 357
369 if (skb->len < 10) { 358 if (skb->len < 10) {
@@ -378,35 +367,51 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
378 frag = WLAN_GET_SEQ_FRAG(sc); 367 frag = WLAN_GET_SEQ_FRAG(sc);
379 hdrlen = ieee80211_get_hdrlen(fc); 368 hdrlen = ieee80211_get_hdrlen(fc);
380 369
381#ifdef NOT_YET
382#if WIRELESS_EXT > 15
383 /* Put this code here so that we avoid duplicating it in all 370 /* Put this code here so that we avoid duplicating it in all
384 * Rx paths. - Jean II */ 371 * Rx paths. - Jean II */
385#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */ 372#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
386 /* If spy monitoring on */ 373 /* If spy monitoring on */
387 if (iface->spy_data.spy_number > 0) { 374 if (ieee->spy_data.spy_number > 0) {
388 struct iw_quality wstats; 375 struct iw_quality wstats;
389 wstats.level = rx_stats->signal; 376
390 wstats.noise = rx_stats->noise; 377 wstats.updated = 0;
391 wstats.updated = 6; /* No qual value */ 378 if (rx_stats->mask & IEEE80211_STATMASK_RSSI) {
379 wstats.level = rx_stats->rssi;
380 wstats.updated |= IW_QUAL_LEVEL_UPDATED;
381 } else
382 wstats.updated |= IW_QUAL_LEVEL_INVALID;
383
384 if (rx_stats->mask & IEEE80211_STATMASK_NOISE) {
385 wstats.noise = rx_stats->noise;
386 wstats.updated |= IW_QUAL_NOISE_UPDATED;
387 } else
388 wstats.updated |= IW_QUAL_NOISE_INVALID;
389
390 if (rx_stats->mask & IEEE80211_STATMASK_SIGNAL) {
391 wstats.qual = rx_stats->signal;
392 wstats.updated |= IW_QUAL_QUAL_UPDATED;
393 } else
394 wstats.updated |= IW_QUAL_QUAL_INVALID;
395
392 /* Update spy records */ 396 /* Update spy records */
393 wireless_spy_update(dev, hdr->addr2, &wstats); 397 wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
394 } 398 }
395#endif /* IW_WIRELESS_SPY */ 399#endif /* IW_WIRELESS_SPY */
396#endif /* WIRELESS_EXT > 15 */ 400
401#ifdef NOT_YET
397 hostap_update_rx_stats(local->ap, hdr, rx_stats); 402 hostap_update_rx_stats(local->ap, hdr, rx_stats);
398#endif 403#endif
399 404
400#if WIRELESS_EXT > 15
401 if (ieee->iw_mode == IW_MODE_MONITOR) { 405 if (ieee->iw_mode == IW_MODE_MONITOR) {
402 ieee80211_monitor_rx(ieee, skb, rx_stats); 406 ieee80211_monitor_rx(ieee, skb, rx_stats);
403 stats->rx_packets++; 407 stats->rx_packets++;
404 stats->rx_bytes += skb->len; 408 stats->rx_bytes += skb->len;
405 return 1; 409 return 1;
406 } 410 }
407#endif
408 411
409 if (ieee->host_decrypt) { 412 if ((is_multicast_ether_addr(hdr->addr1) ||
413 is_broadcast_ether_addr(hdr->addr2)) ? ieee->host_mc_decrypt :
414 ieee->host_decrypt) {
410 int idx = 0; 415 int idx = 0;
411 if (skb->len >= hdrlen + 3) 416 if (skb->len >= hdrlen + 3)
412 idx = skb->data[hdrlen + 3] >> 6; 417 idx = skb->data[hdrlen + 3] >> 6;
@@ -531,6 +536,9 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
531 536
532 /* Nullfunc frames may have PS-bit set, so they must be passed to 537 /* Nullfunc frames may have PS-bit set, so they must be passed to
533 * hostap_handle_sta_rx() before being dropped here. */ 538 * hostap_handle_sta_rx() before being dropped here. */
539
540 stype &= ~IEEE80211_STYPE_QOS_DATA;
541
534 if (stype != IEEE80211_STYPE_DATA && 542 if (stype != IEEE80211_STYPE_DATA &&
535 stype != IEEE80211_STYPE_DATA_CFACK && 543 stype != IEEE80211_STYPE_DATA_CFACK &&
536 stype != IEEE80211_STYPE_DATA_CFPOLL && 544 stype != IEEE80211_STYPE_DATA_CFPOLL &&
@@ -549,7 +557,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
549 (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0) 557 (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
550 goto rx_dropped; 558 goto rx_dropped;
551 559
552 hdr = (struct ieee80211_hdr *)skb->data; 560 hdr = (struct ieee80211_hdr_4addr *)skb->data;
553 561
554 /* skb: hdr + (possibly fragmented) plaintext payload */ 562 /* skb: hdr + (possibly fragmented) plaintext payload */
555 // PR: FIXME: hostap has additional conditions in the "if" below: 563 // PR: FIXME: hostap has additional conditions in the "if" below:
@@ -603,7 +611,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
603 /* this was the last fragment and the frame will be 611 /* this was the last fragment and the frame will be
604 * delivered, so remove skb from fragment cache */ 612 * delivered, so remove skb from fragment cache */
605 skb = frag_skb; 613 skb = frag_skb;
606 hdr = (struct ieee80211_hdr *)skb->data; 614 hdr = (struct ieee80211_hdr_4addr *)skb->data;
607 ieee80211_frag_cache_invalidate(ieee, hdr); 615 ieee80211_frag_cache_invalidate(ieee, hdr);
608 } 616 }
609 617
@@ -613,7 +621,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
613 ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) 621 ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
614 goto rx_dropped; 622 goto rx_dropped;
615 623
616 hdr = (struct ieee80211_hdr *)skb->data; 624 hdr = (struct ieee80211_hdr_4addr *)skb->data;
617 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) { 625 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
618 if ( /*ieee->ieee802_1x && */ 626 if ( /*ieee->ieee802_1x && */
619 ieee80211_is_eapol_frame(ieee, skb)) { 627 ieee80211_is_eapol_frame(ieee, skb)) {
@@ -755,69 +763,179 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
755 763
756#define MGMT_FRAME_FIXED_PART_LENGTH 0x24 764#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
757 765
758static inline int ieee80211_is_ofdm_rate(u8 rate) 766static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
767
768/*
769* Make ther structure we read from the beacon packet has
770* the right values
771*/
772static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
773 *info_element, int sub_type)
759{ 774{
760 switch (rate & ~IEEE80211_BASIC_RATE_MASK) { 775
761 case IEEE80211_OFDM_RATE_6MB: 776 if (info_element->qui_subtype != sub_type)
762 case IEEE80211_OFDM_RATE_9MB: 777 return -1;
763 case IEEE80211_OFDM_RATE_12MB: 778 if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
764 case IEEE80211_OFDM_RATE_18MB: 779 return -1;
765 case IEEE80211_OFDM_RATE_24MB: 780 if (info_element->qui_type != QOS_OUI_TYPE)
766 case IEEE80211_OFDM_RATE_36MB: 781 return -1;
767 case IEEE80211_OFDM_RATE_48MB: 782 if (info_element->version != QOS_VERSION_1)
768 case IEEE80211_OFDM_RATE_54MB: 783 return -1;
769 return 1; 784
770 }
771 return 0; 785 return 0;
772} 786}
773 787
774static inline int ieee80211_network_init(struct ieee80211_device *ieee, 788/*
775 struct ieee80211_probe_response 789 * Parse a QoS parameter element
776 *beacon, 790 */
777 struct ieee80211_network *network, 791static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
778 struct ieee80211_rx_stats *stats) 792 *element_param, struct ieee80211_info_element
793 *info_element)
779{ 794{
780#ifdef CONFIG_IEEE80211_DEBUG 795 int ret = 0;
781 char rates_str[64]; 796 u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
782 char *p;
783#endif
784 struct ieee80211_info_element *info_element;
785 u16 left;
786 u8 i;
787 797
788 /* Pull out fixed field data */ 798 if ((info_element == NULL) || (element_param == NULL))
789 memcpy(network->bssid, beacon->header.addr3, ETH_ALEN); 799 return -1;
790 network->capability = beacon->capability;
791 network->last_scanned = jiffies;
792 network->time_stamp[0] = beacon->time_stamp[0];
793 network->time_stamp[1] = beacon->time_stamp[1];
794 network->beacon_interval = beacon->beacon_interval;
795 /* Where to pull this? beacon->listen_interval; */
796 network->listen_interval = 0x0A;
797 network->rates_len = network->rates_ex_len = 0;
798 network->last_associate = 0;
799 network->ssid_len = 0;
800 network->flags = 0;
801 network->atim_window = 0;
802 800
803 if (stats->freq == IEEE80211_52GHZ_BAND) { 801 if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
804 /* for A band (No DS info) */ 802 memcpy(element_param->info_element.qui, info_element->data,
805 network->channel = stats->received_channel; 803 info_element->len);
804 element_param->info_element.elementID = info_element->id;
805 element_param->info_element.length = info_element->len;
806 } else 806 } else
807 network->flags |= NETWORK_HAS_CCK; 807 ret = -1;
808 if (ret == 0)
809 ret = ieee80211_verify_qos_info(&element_param->info_element,
810 QOS_OUI_PARAM_SUB_TYPE);
811 return ret;
812}
808 813
809 network->wpa_ie_len = 0; 814/*
810 network->rsn_ie_len = 0; 815 * Parse a QoS information element
816 */
817static int ieee80211_read_qos_info_element(struct
818 ieee80211_qos_information_element
819 *element_info, struct ieee80211_info_element
820 *info_element)
821{
822 int ret = 0;
823 u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
824
825 if (element_info == NULL)
826 return -1;
827 if (info_element == NULL)
828 return -1;
829
830 if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
831 memcpy(element_info->qui, info_element->data,
832 info_element->len);
833 element_info->elementID = info_element->id;
834 element_info->length = info_element->len;
835 } else
836 ret = -1;
837
838 if (ret == 0)
839 ret = ieee80211_verify_qos_info(element_info,
840 QOS_OUI_INFO_SUB_TYPE);
841 return ret;
842}
843
844/*
845 * Write QoS parameters from the ac parameters.
846 */
847static int ieee80211_qos_convert_ac_to_parameters(struct
848 ieee80211_qos_parameter_info
849 *param_elm, struct
850 ieee80211_qos_parameters
851 *qos_param)
852{
853 int rc = 0;
854 int i;
855 struct ieee80211_qos_ac_parameter *ac_params;
856 u32 txop;
857 u8 cw_min;
858 u8 cw_max;
859
860 for (i = 0; i < QOS_QUEUE_NUM; i++) {
861 ac_params = &(param_elm->ac_params_record[i]);
862
863 qos_param->aifs[i] = (ac_params->aci_aifsn) & 0x0F;
864 qos_param->aifs[i] -= (qos_param->aifs[i] < 2) ? 0 : 2;
865
866 cw_min = ac_params->ecw_min_max & 0x0F;
867 qos_param->cw_min[i] = (u16) ((1 << cw_min) - 1);
868
869 cw_max = (ac_params->ecw_min_max & 0xF0) >> 4;
870 qos_param->cw_max[i] = (u16) ((1 << cw_max) - 1);
871
872 qos_param->flag[i] =
873 (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
874
875 txop = le16_to_cpu(ac_params->tx_op_limit) * 32;
876 qos_param->tx_op_limit[i] = (u16) txop;
877 }
878 return rc;
879}
880
881/*
882 * we have a generic data element which it may contain QoS information or
883 * parameters element. check the information element length to decide
884 * which type to read
885 */
886static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
887 *info_element,
888 struct ieee80211_network *network)
889{
890 int rc = 0;
891 struct ieee80211_qos_parameters *qos_param = NULL;
892 struct ieee80211_qos_information_element qos_info_element;
893
894 rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
895
896 if (rc == 0) {
897 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
898 network->flags |= NETWORK_HAS_QOS_INFORMATION;
899 } else {
900 struct ieee80211_qos_parameter_info param_element;
901
902 rc = ieee80211_read_qos_param_element(&param_element,
903 info_element);
904 if (rc == 0) {
905 qos_param = &(network->qos_data.parameters);
906 ieee80211_qos_convert_ac_to_parameters(&param_element,
907 qos_param);
908 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
909 network->qos_data.param_count =
910 param_element.info_element.ac_info & 0x0F;
911 }
912 }
913
914 if (rc == 0) {
915 IEEE80211_DEBUG_QOS("QoS is supported\n");
916 network->qos_data.supported = 1;
917 }
918 return rc;
919}
920
921static int ieee80211_parse_info_param(struct ieee80211_info_element
922 *info_element, u16 length,
923 struct ieee80211_network *network)
924{
925 u8 i;
926#ifdef CONFIG_IEEE80211_DEBUG
927 char rates_str[64];
928 char *p;
929#endif
811 930
812 info_element = &beacon->info_element; 931 while (length >= sizeof(*info_element)) {
813 left = stats->len - ((void *)info_element - (void *)beacon); 932 if (sizeof(*info_element) + info_element->len > length) {
814 while (left >= sizeof(struct ieee80211_info_element_hdr)) { 933 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
815 if (sizeof(struct ieee80211_info_element_hdr) + 934 "info_element->len + 2 > left : "
816 info_element->len > left) { 935 "info_element->len+2=%zd left=%d, id=%d.\n",
817 IEEE80211_DEBUG_SCAN 936 info_element->len +
818 ("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%Zd left=%d.\n", 937 sizeof(*info_element),
819 info_element->len + 938 length, info_element->id);
820 sizeof(struct ieee80211_info_element), left);
821 return 1; 939 return 1;
822 } 940 }
823 941
@@ -837,7 +955,7 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
837 memset(network->ssid + network->ssid_len, 0, 955 memset(network->ssid + network->ssid_len, 0,
838 IW_ESSID_MAX_SIZE - network->ssid_len); 956 IW_ESSID_MAX_SIZE - network->ssid_len);
839 957
840 IEEE80211_DEBUG_SCAN("MFIE_TYPE_SSID: '%s' len=%d.\n", 958 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
841 network->ssid, network->ssid_len); 959 network->ssid, network->ssid_len);
842 break; 960 break;
843 961
@@ -845,15 +963,14 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
845#ifdef CONFIG_IEEE80211_DEBUG 963#ifdef CONFIG_IEEE80211_DEBUG
846 p = rates_str; 964 p = rates_str;
847#endif 965#endif
848 network->rates_len = 966 network->rates_len = min(info_element->len,
849 min(info_element->len, MAX_RATES_LENGTH); 967 MAX_RATES_LENGTH);
850 for (i = 0; i < network->rates_len; i++) { 968 for (i = 0; i < network->rates_len; i++) {
851 network->rates[i] = info_element->data[i]; 969 network->rates[i] = info_element->data[i];
852#ifdef CONFIG_IEEE80211_DEBUG 970#ifdef CONFIG_IEEE80211_DEBUG
853 p += snprintf(p, 971 p += snprintf(p, sizeof(rates_str) -
854 sizeof(rates_str) - (p - 972 (p - rates_str), "%02X ",
855 rates_str), 973 network->rates[i]);
856 "%02X ", network->rates[i]);
857#endif 974#endif
858 if (ieee80211_is_ofdm_rate 975 if (ieee80211_is_ofdm_rate
859 (info_element->data[i])) { 976 (info_element->data[i])) {
@@ -865,7 +982,7 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
865 } 982 }
866 } 983 }
867 984
868 IEEE80211_DEBUG_SCAN("MFIE_TYPE_RATES: '%s' (%d)\n", 985 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
869 rates_str, network->rates_len); 986 rates_str, network->rates_len);
870 break; 987 break;
871 988
@@ -873,15 +990,14 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
873#ifdef CONFIG_IEEE80211_DEBUG 990#ifdef CONFIG_IEEE80211_DEBUG
874 p = rates_str; 991 p = rates_str;
875#endif 992#endif
876 network->rates_ex_len = 993 network->rates_ex_len = min(info_element->len,
877 min(info_element->len, MAX_RATES_EX_LENGTH); 994 MAX_RATES_EX_LENGTH);
878 for (i = 0; i < network->rates_ex_len; i++) { 995 for (i = 0; i < network->rates_ex_len; i++) {
879 network->rates_ex[i] = info_element->data[i]; 996 network->rates_ex[i] = info_element->data[i];
880#ifdef CONFIG_IEEE80211_DEBUG 997#ifdef CONFIG_IEEE80211_DEBUG
881 p += snprintf(p, 998 p += snprintf(p, sizeof(rates_str) -
882 sizeof(rates_str) - (p - 999 (p - rates_str), "%02X ",
883 rates_str), 1000 network->rates[i]);
884 "%02X ", network->rates[i]);
885#endif 1001#endif
886 if (ieee80211_is_ofdm_rate 1002 if (ieee80211_is_ofdm_rate
887 (info_element->data[i])) { 1003 (info_element->data[i])) {
@@ -893,40 +1009,51 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
893 } 1009 }
894 } 1010 }
895 1011
896 IEEE80211_DEBUG_SCAN("MFIE_TYPE_RATES_EX: '%s' (%d)\n", 1012 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
897 rates_str, network->rates_ex_len); 1013 rates_str, network->rates_ex_len);
898 break; 1014 break;
899 1015
900 case MFIE_TYPE_DS_SET: 1016 case MFIE_TYPE_DS_SET:
901 IEEE80211_DEBUG_SCAN("MFIE_TYPE_DS_SET: %d\n", 1017 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
902 info_element->data[0]); 1018 info_element->data[0]);
903 if (stats->freq == IEEE80211_24GHZ_BAND) 1019 network->channel = info_element->data[0];
904 network->channel = info_element->data[0];
905 break; 1020 break;
906 1021
907 case MFIE_TYPE_FH_SET: 1022 case MFIE_TYPE_FH_SET:
908 IEEE80211_DEBUG_SCAN("MFIE_TYPE_FH_SET: ignored\n"); 1023 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
909 break; 1024 break;
910 1025
911 case MFIE_TYPE_CF_SET: 1026 case MFIE_TYPE_CF_SET:
912 IEEE80211_DEBUG_SCAN("MFIE_TYPE_CF_SET: ignored\n"); 1027 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
913 break; 1028 break;
914 1029
915 case MFIE_TYPE_TIM: 1030 case MFIE_TYPE_TIM:
916 IEEE80211_DEBUG_SCAN("MFIE_TYPE_TIM: ignored\n"); 1031 IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: ignored\n");
1032 break;
1033
1034 case MFIE_TYPE_ERP_INFO:
1035 network->erp_value = info_element->data[0];
1036 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1037 network->erp_value);
917 break; 1038 break;
918 1039
919 case MFIE_TYPE_IBSS_SET: 1040 case MFIE_TYPE_IBSS_SET:
920 IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n"); 1041 network->atim_window = info_element->data[0];
1042 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1043 network->atim_window);
921 break; 1044 break;
922 1045
923 case MFIE_TYPE_CHALLENGE: 1046 case MFIE_TYPE_CHALLENGE:
924 IEEE80211_DEBUG_SCAN("MFIE_TYPE_CHALLENGE: ignored\n"); 1047 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
925 break; 1048 break;
926 1049
927 case MFIE_TYPE_GENERIC: 1050 case MFIE_TYPE_GENERIC:
928 IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n", 1051 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
929 info_element->len); 1052 info_element->len);
1053 if (!ieee80211_parse_qos_info_param_IE(info_element,
1054 network))
1055 break;
1056
930 if (info_element->len >= 4 && 1057 if (info_element->len >= 4 &&
931 info_element->data[0] == 0x00 && 1058 info_element->data[0] == 0x00 &&
932 info_element->data[1] == 0x50 && 1059 info_element->data[1] == 0x50 &&
@@ -940,7 +1067,7 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
940 break; 1067 break;
941 1068
942 case MFIE_TYPE_RSN: 1069 case MFIE_TYPE_RSN:
943 IEEE80211_DEBUG_SCAN("MFIE_TYPE_RSN: %d bytes\n", 1070 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
944 info_element->len); 1071 info_element->len);
945 network->rsn_ie_len = min(info_element->len + 2, 1072 network->rsn_ie_len = min(info_element->len + 2,
946 MAX_WPA_IE_LEN); 1073 MAX_WPA_IE_LEN);
@@ -948,18 +1075,127 @@ static inline int ieee80211_network_init(struct ieee80211_device *ieee,
948 network->rsn_ie_len); 1075 network->rsn_ie_len);
949 break; 1076 break;
950 1077
1078 case MFIE_TYPE_QOS_PARAMETER:
1079 printk(KERN_ERR
1080 "QoS Error need to parse QOS_PARAMETER IE\n");
1081 break;
1082
951 default: 1083 default:
952 IEEE80211_DEBUG_SCAN("unsupported IE %d\n", 1084 IEEE80211_DEBUG_MGMT("unsupported IE %d\n",
953 info_element->id); 1085 info_element->id);
954 break; 1086 break;
955 } 1087 }
956 1088
957 left -= sizeof(struct ieee80211_info_element_hdr) + 1089 length -= sizeof(*info_element) + info_element->len;
958 info_element->len; 1090 info_element =
959 info_element = (struct ieee80211_info_element *) 1091 (struct ieee80211_info_element *)&info_element->
960 &info_element->data[info_element->len]; 1092 data[info_element->len];
1093 }
1094
1095 return 0;
1096}
1097
1098static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct ieee80211_assoc_response
1099 *frame, struct ieee80211_rx_stats *stats)
1100{
1101 struct ieee80211_network network_resp;
1102 struct ieee80211_network *network = &network_resp;
1103 struct net_device *dev = ieee->dev;
1104
1105 network->flags = 0;
1106 network->qos_data.active = 0;
1107 network->qos_data.supported = 0;
1108 network->qos_data.param_count = 0;
1109 network->qos_data.old_param_count = 0;
1110
1111 //network->atim_window = le16_to_cpu(frame->aid) & (0x3FFF);
1112 network->atim_window = le16_to_cpu(frame->aid);
1113 network->listen_interval = le16_to_cpu(frame->status);
1114 memcpy(network->bssid, frame->header.addr3, ETH_ALEN);
1115 network->capability = le16_to_cpu(frame->capability);
1116 network->last_scanned = jiffies;
1117 network->rates_len = network->rates_ex_len = 0;
1118 network->last_associate = 0;
1119 network->ssid_len = 0;
1120 network->erp_value =
1121 (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
1122
1123 if (stats->freq == IEEE80211_52GHZ_BAND) {
1124 /* for A band (No DS info) */
1125 network->channel = stats->received_channel;
1126 } else
1127 network->flags |= NETWORK_HAS_CCK;
1128
1129 network->wpa_ie_len = 0;
1130 network->rsn_ie_len = 0;
1131
1132 if (ieee80211_parse_info_param
1133 (frame->info_element, stats->len - sizeof(*frame), network))
1134 return 1;
1135
1136 network->mode = 0;
1137 if (stats->freq == IEEE80211_52GHZ_BAND)
1138 network->mode = IEEE_A;
1139 else {
1140 if (network->flags & NETWORK_HAS_OFDM)
1141 network->mode |= IEEE_G;
1142 if (network->flags & NETWORK_HAS_CCK)
1143 network->mode |= IEEE_B;
961 } 1144 }
962 1145
1146 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
1147 network->flags |= NETWORK_EMPTY_ESSID;
1148
1149 memcpy(&network->stats, stats, sizeof(network->stats));
1150
1151 if (ieee->handle_assoc_response != NULL)
1152 ieee->handle_assoc_response(dev, frame, network);
1153
1154 return 0;
1155}
1156
1157/***************************************************/
1158
1159static inline int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee80211_probe_response
1160 *beacon,
1161 struct ieee80211_network *network,
1162 struct ieee80211_rx_stats *stats)
1163{
1164 network->qos_data.active = 0;
1165 network->qos_data.supported = 0;
1166 network->qos_data.param_count = 0;
1167 network->qos_data.old_param_count = 0;
1168
1169 /* Pull out fixed field data */
1170 memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
1171 network->capability = le16_to_cpu(beacon->capability);
1172 network->last_scanned = jiffies;
1173 network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
1174 network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
1175 network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
1176 /* Where to pull this? beacon->listen_interval; */
1177 network->listen_interval = 0x0A;
1178 network->rates_len = network->rates_ex_len = 0;
1179 network->last_associate = 0;
1180 network->ssid_len = 0;
1181 network->flags = 0;
1182 network->atim_window = 0;
1183 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
1184 0x3 : 0x0;
1185
1186 if (stats->freq == IEEE80211_52GHZ_BAND) {
1187 /* for A band (No DS info) */
1188 network->channel = stats->received_channel;
1189 } else
1190 network->flags |= NETWORK_HAS_CCK;
1191
1192 network->wpa_ie_len = 0;
1193 network->rsn_ie_len = 0;
1194
1195 if (ieee80211_parse_info_param
1196 (beacon->info_element, stats->len - sizeof(*beacon), network))
1197 return 1;
1198
963 network->mode = 0; 1199 network->mode = 0;
964 if (stats->freq == IEEE80211_52GHZ_BAND) 1200 if (stats->freq == IEEE80211_52GHZ_BAND)
965 network->mode = IEEE_A; 1201 network->mode = IEEE_A;
@@ -1002,6 +1238,9 @@ static inline int is_same_network(struct ieee80211_network *src,
1002static inline void update_network(struct ieee80211_network *dst, 1238static inline void update_network(struct ieee80211_network *dst,
1003 struct ieee80211_network *src) 1239 struct ieee80211_network *src)
1004{ 1240{
1241 int qos_active;
1242 u8 old_param;
1243
1005 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats)); 1244 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
1006 dst->capability = src->capability; 1245 dst->capability = src->capability;
1007 memcpy(dst->rates, src->rates, src->rates_len); 1246 memcpy(dst->rates, src->rates, src->rates_len);
@@ -1017,6 +1256,7 @@ static inline void update_network(struct ieee80211_network *dst,
1017 dst->beacon_interval = src->beacon_interval; 1256 dst->beacon_interval = src->beacon_interval;
1018 dst->listen_interval = src->listen_interval; 1257 dst->listen_interval = src->listen_interval;
1019 dst->atim_window = src->atim_window; 1258 dst->atim_window = src->atim_window;
1259 dst->erp_value = src->erp_value;
1020 1260
1021 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len); 1261 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
1022 dst->wpa_ie_len = src->wpa_ie_len; 1262 dst->wpa_ie_len = src->wpa_ie_len;
@@ -1024,22 +1264,48 @@ static inline void update_network(struct ieee80211_network *dst,
1024 dst->rsn_ie_len = src->rsn_ie_len; 1264 dst->rsn_ie_len = src->rsn_ie_len;
1025 1265
1026 dst->last_scanned = jiffies; 1266 dst->last_scanned = jiffies;
1267 qos_active = src->qos_data.active;
1268 old_param = dst->qos_data.old_param_count;
1269 if (dst->flags & NETWORK_HAS_QOS_MASK)
1270 memcpy(&dst->qos_data, &src->qos_data,
1271 sizeof(struct ieee80211_qos_data));
1272 else {
1273 dst->qos_data.supported = src->qos_data.supported;
1274 dst->qos_data.param_count = src->qos_data.param_count;
1275 }
1276
1277 if (dst->qos_data.supported == 1) {
1278 if (dst->ssid_len)
1279 IEEE80211_DEBUG_QOS
1280 ("QoS the network %s is QoS supported\n",
1281 dst->ssid);
1282 else
1283 IEEE80211_DEBUG_QOS
1284 ("QoS the network is QoS supported\n");
1285 }
1286 dst->qos_data.active = qos_active;
1287 dst->qos_data.old_param_count = old_param;
1288
1027 /* dst->last_associate is not overwritten */ 1289 /* dst->last_associate is not overwritten */
1028} 1290}
1029 1291
1292static inline int is_beacon(int fc)
1293{
1294 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
1295}
1296
1030static inline void ieee80211_process_probe_response(struct ieee80211_device 1297static inline void ieee80211_process_probe_response(struct ieee80211_device
1031 *ieee, 1298 *ieee, struct
1032 struct
1033 ieee80211_probe_response 1299 ieee80211_probe_response
1034 *beacon, 1300 *beacon, struct ieee80211_rx_stats
1035 struct ieee80211_rx_stats
1036 *stats) 1301 *stats)
1037{ 1302{
1303 struct net_device *dev = ieee->dev;
1038 struct ieee80211_network network; 1304 struct ieee80211_network network;
1039 struct ieee80211_network *target; 1305 struct ieee80211_network *target;
1040 struct ieee80211_network *oldest = NULL; 1306 struct ieee80211_network *oldest = NULL;
1041#ifdef CONFIG_IEEE80211_DEBUG 1307#ifdef CONFIG_IEEE80211_DEBUG
1042 struct ieee80211_info_element *info_element = &beacon->info_element; 1308 struct ieee80211_info_element *info_element = beacon->info_element;
1043#endif 1309#endif
1044 unsigned long flags; 1310 unsigned long flags;
1045 1311
@@ -1070,10 +1336,10 @@ static inline void ieee80211_process_probe_response(struct ieee80211_device
1070 escape_essid(info_element->data, 1336 escape_essid(info_element->data,
1071 info_element->len), 1337 info_element->len),
1072 MAC_ARG(beacon->header.addr3), 1338 MAC_ARG(beacon->header.addr3),
1073 WLAN_FC_GET_STYPE(beacon->header. 1339 is_beacon(le16_to_cpu
1074 frame_ctl) == 1340 (beacon->header.
1075 IEEE80211_STYPE_PROBE_RESP ? 1341 frame_ctl)) ?
1076 "PROBE RESPONSE" : "BEACON"); 1342 "BEACON" : "PROBE RESPONSE");
1077 return; 1343 return;
1078 } 1344 }
1079 1345
@@ -1122,10 +1388,10 @@ static inline void ieee80211_process_probe_response(struct ieee80211_device
1122 escape_essid(network.ssid, 1388 escape_essid(network.ssid,
1123 network.ssid_len), 1389 network.ssid_len),
1124 MAC_ARG(network.bssid), 1390 MAC_ARG(network.bssid),
1125 WLAN_FC_GET_STYPE(beacon->header. 1391 is_beacon(le16_to_cpu
1126 frame_ctl) == 1392 (beacon->header.
1127 IEEE80211_STYPE_PROBE_RESP ? 1393 frame_ctl)) ?
1128 "PROBE RESPONSE" : "BEACON"); 1394 "BEACON" : "PROBE RESPONSE");
1129#endif 1395#endif
1130 memcpy(target, &network, sizeof(*target)); 1396 memcpy(target, &network, sizeof(*target));
1131 list_add_tail(&target->list, &ieee->network_list); 1397 list_add_tail(&target->list, &ieee->network_list);
@@ -1134,34 +1400,60 @@ static inline void ieee80211_process_probe_response(struct ieee80211_device
1134 escape_essid(target->ssid, 1400 escape_essid(target->ssid,
1135 target->ssid_len), 1401 target->ssid_len),
1136 MAC_ARG(target->bssid), 1402 MAC_ARG(target->bssid),
1137 WLAN_FC_GET_STYPE(beacon->header. 1403 is_beacon(le16_to_cpu
1138 frame_ctl) == 1404 (beacon->header.
1139 IEEE80211_STYPE_PROBE_RESP ? 1405 frame_ctl)) ?
1140 "PROBE RESPONSE" : "BEACON"); 1406 "BEACON" : "PROBE RESPONSE");
1141 update_network(target, &network); 1407 update_network(target, &network);
1142 } 1408 }
1143 1409
1144 spin_unlock_irqrestore(&ieee->lock, flags); 1410 spin_unlock_irqrestore(&ieee->lock, flags);
1411
1412 if (is_beacon(le16_to_cpu(beacon->header.frame_ctl))) {
1413 if (ieee->handle_beacon != NULL)
1414 ieee->handle_beacon(dev, beacon, &network);
1415 } else {
1416 if (ieee->handle_probe_response != NULL)
1417 ieee->handle_probe_response(dev, beacon, &network);
1418 }
1145} 1419}
1146 1420
1147void ieee80211_rx_mgt(struct ieee80211_device *ieee, 1421void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1148 struct ieee80211_hdr *header, 1422 struct ieee80211_hdr_4addr *header,
1149 struct ieee80211_rx_stats *stats) 1423 struct ieee80211_rx_stats *stats)
1150{ 1424{
1151 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { 1425 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
1152 case IEEE80211_STYPE_ASSOC_RESP: 1426 case IEEE80211_STYPE_ASSOC_RESP:
1153 IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n", 1427 IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
1154 WLAN_FC_GET_STYPE(header->frame_ctl)); 1428 WLAN_FC_GET_STYPE(le16_to_cpu
1429 (header->frame_ctl)));
1430 ieee80211_handle_assoc_resp(ieee,
1431 (struct ieee80211_assoc_response *)
1432 header, stats);
1155 break; 1433 break;
1156 1434
1157 case IEEE80211_STYPE_REASSOC_RESP: 1435 case IEEE80211_STYPE_REASSOC_RESP:
1158 IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n", 1436 IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
1159 WLAN_FC_GET_STYPE(header->frame_ctl)); 1437 WLAN_FC_GET_STYPE(le16_to_cpu
1438 (header->frame_ctl)));
1439 break;
1440
1441 case IEEE80211_STYPE_PROBE_REQ:
1442 IEEE80211_DEBUG_MGMT("recieved auth (%d)\n",
1443 WLAN_FC_GET_STYPE(le16_to_cpu
1444 (header->frame_ctl)));
1445
1446 if (ieee->handle_probe_request != NULL)
1447 ieee->handle_probe_request(ieee->dev,
1448 (struct
1449 ieee80211_probe_request *)
1450 header, stats);
1160 break; 1451 break;
1161 1452
1162 case IEEE80211_STYPE_PROBE_RESP: 1453 case IEEE80211_STYPE_PROBE_RESP:
1163 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n", 1454 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
1164 WLAN_FC_GET_STYPE(header->frame_ctl)); 1455 WLAN_FC_GET_STYPE(le16_to_cpu
1456 (header->frame_ctl)));
1165 IEEE80211_DEBUG_SCAN("Probe response\n"); 1457 IEEE80211_DEBUG_SCAN("Probe response\n");
1166 ieee80211_process_probe_response(ieee, 1458 ieee80211_process_probe_response(ieee,
1167 (struct 1459 (struct
@@ -1171,20 +1463,46 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1171 1463
1172 case IEEE80211_STYPE_BEACON: 1464 case IEEE80211_STYPE_BEACON:
1173 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", 1465 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
1174 WLAN_FC_GET_STYPE(header->frame_ctl)); 1466 WLAN_FC_GET_STYPE(le16_to_cpu
1467 (header->frame_ctl)));
1175 IEEE80211_DEBUG_SCAN("Beacon\n"); 1468 IEEE80211_DEBUG_SCAN("Beacon\n");
1176 ieee80211_process_probe_response(ieee, 1469 ieee80211_process_probe_response(ieee,
1177 (struct 1470 (struct
1178 ieee80211_probe_response *) 1471 ieee80211_probe_response *)
1179 header, stats); 1472 header, stats);
1180 break; 1473 break;
1474 case IEEE80211_STYPE_AUTH:
1181 1475
1476 IEEE80211_DEBUG_MGMT("recieved auth (%d)\n",
1477 WLAN_FC_GET_STYPE(le16_to_cpu
1478 (header->frame_ctl)));
1479
1480 if (ieee->handle_auth != NULL)
1481 ieee->handle_auth(ieee->dev,
1482 (struct ieee80211_auth *)header);
1483 break;
1484
1485 case IEEE80211_STYPE_DISASSOC:
1486 if (ieee->handle_disassoc != NULL)
1487 ieee->handle_disassoc(ieee->dev,
1488 (struct ieee80211_disassoc *)
1489 header);
1490 break;
1491
1492 case IEEE80211_STYPE_DEAUTH:
1493 printk("DEAUTH from AP\n");
1494 if (ieee->handle_deauth != NULL)
1495 ieee->handle_deauth(ieee->dev, (struct ieee80211_auth *)
1496 header);
1497 break;
1182 default: 1498 default:
1183 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n", 1499 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
1184 WLAN_FC_GET_STYPE(header->frame_ctl)); 1500 WLAN_FC_GET_STYPE(le16_to_cpu
1501 (header->frame_ctl)));
1185 IEEE80211_WARNING("%s: Unknown management packet: %d\n", 1502 IEEE80211_WARNING("%s: Unknown management packet: %d\n",
1186 ieee->dev->name, 1503 ieee->dev->name,
1187 WLAN_FC_GET_STYPE(header->frame_ctl)); 1504 WLAN_FC_GET_STYPE(le16_to_cpu
1505 (header->frame_ctl)));
1188 break; 1506 break;
1189 } 1507 }
1190} 1508}
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index eed07bbbe6b6..95ccbadbf55b 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved. 3 Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
4 4
5 This program is free software; you can redistribute it and/or modify it 5 This program is free software; you can redistribute it and/or modify it
6 under the terms of version 2 of the GNU General Public License as 6 under the terms of version 2 of the GNU General Public License as
@@ -128,7 +128,7 @@ payload of each frame is reduced to 492 bytes.
128static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; 128static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
129static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; 129static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
130 130
131static inline int ieee80211_put_snap(u8 * data, u16 h_proto) 131static inline int ieee80211_copy_snap(u8 * data, u16 h_proto)
132{ 132{
133 struct ieee80211_snap_hdr *snap; 133 struct ieee80211_snap_hdr *snap;
134 u8 *oui; 134 u8 *oui;
@@ -157,31 +157,14 @@ static inline int ieee80211_encrypt_fragment(struct ieee80211_device *ieee,
157 struct ieee80211_crypt_data *crypt = ieee->crypt[ieee->tx_keyidx]; 157 struct ieee80211_crypt_data *crypt = ieee->crypt[ieee->tx_keyidx];
158 int res; 158 int res;
159 159
160#ifdef CONFIG_IEEE80211_CRYPT_TKIP 160 if (crypt == NULL)
161 struct ieee80211_hdr *header;
162
163 if (ieee->tkip_countermeasures &&
164 crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
165 header = (struct ieee80211_hdr *)frag->data;
166 if (net_ratelimit()) {
167 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
168 "TX packet to " MAC_FMT "\n",
169 ieee->dev->name, MAC_ARG(header->addr1));
170 }
171 return -1; 161 return -1;
172 } 162
173#endif
174 /* To encrypt, frame format is: 163 /* To encrypt, frame format is:
175 * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */ 164 * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
176
177 // PR: FIXME: Copied from hostap. Check fragmentation/MSDU/MPDU encryption.
178 /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
179 * call both MSDU and MPDU encryption functions from here. */
180 atomic_inc(&crypt->refcnt); 165 atomic_inc(&crypt->refcnt);
181 res = 0; 166 res = 0;
182 if (crypt->ops->encrypt_msdu) 167 if (crypt->ops && crypt->ops->encrypt_mpdu)
183 res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv);
184 if (res == 0 && crypt->ops->encrypt_mpdu)
185 res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv); 168 res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv);
186 169
187 atomic_dec(&crypt->refcnt); 170 atomic_dec(&crypt->refcnt);
@@ -207,7 +190,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb)
207} 190}
208 191
209static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, 192static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
210 gfp_t gfp_mask) 193 int headroom, gfp_t gfp_mask)
211{ 194{
212 struct ieee80211_txb *txb; 195 struct ieee80211_txb *txb;
213 int i; 196 int i;
@@ -221,11 +204,13 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
221 txb->frag_size = txb_size; 204 txb->frag_size = txb_size;
222 205
223 for (i = 0; i < nr_frags; i++) { 206 for (i = 0; i < nr_frags; i++) {
224 txb->fragments[i] = dev_alloc_skb(txb_size); 207 txb->fragments[i] = __dev_alloc_skb(txb_size + headroom,
208 gfp_mask);
225 if (unlikely(!txb->fragments[i])) { 209 if (unlikely(!txb->fragments[i])) {
226 i--; 210 i--;
227 break; 211 break;
228 } 212 }
213 skb_reserve(txb->fragments[i], headroom);
229 } 214 }
230 if (unlikely(i != nr_frags)) { 215 if (unlikely(i != nr_frags)) {
231 while (i >= 0) 216 while (i >= 0)
@@ -236,25 +221,31 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
236 return txb; 221 return txb;
237} 222}
238 223
239/* SKBs are added to the ieee->tx_queue. */ 224/* Incoming skb is converted to a txb which consists of
225 * a block of 802.11 fragment packets (stored as skbs) */
240int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) 226int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
241{ 227{
242 struct ieee80211_device *ieee = netdev_priv(dev); 228 struct ieee80211_device *ieee = netdev_priv(dev);
243 struct ieee80211_txb *txb = NULL; 229 struct ieee80211_txb *txb = NULL;
244 struct ieee80211_hdr *frag_hdr; 230 struct ieee80211_hdr_3addr *frag_hdr;
245 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; 231 int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size,
232 rts_required;
246 unsigned long flags; 233 unsigned long flags;
247 struct net_device_stats *stats = &ieee->stats; 234 struct net_device_stats *stats = &ieee->stats;
248 int ether_type, encrypt; 235 int ether_type, encrypt, host_encrypt, host_encrypt_msdu, host_build_iv;
249 int bytes, fc, hdr_len; 236 int bytes, fc, hdr_len;
250 struct sk_buff *skb_frag; 237 struct sk_buff *skb_frag;
251 struct ieee80211_hdr header = { /* Ensure zero initialized */ 238 struct ieee80211_hdr_3addr header = { /* Ensure zero initialized */
252 .duration_id = 0, 239 .duration_id = 0,
253 .seq_ctl = 0 240 .seq_ctl = 0
254 }; 241 };
255 u8 dest[ETH_ALEN], src[ETH_ALEN]; 242 u8 dest[ETH_ALEN], src[ETH_ALEN];
256
257 struct ieee80211_crypt_data *crypt; 243 struct ieee80211_crypt_data *crypt;
244 int priority = skb->priority;
245 int snapped = 0;
246
247 if (ieee->is_queue_full && (*ieee->is_queue_full) (dev, priority))
248 return NETDEV_TX_BUSY;
258 249
259 spin_lock_irqsave(&ieee->lock, flags); 250 spin_lock_irqsave(&ieee->lock, flags);
260 251
@@ -276,7 +267,11 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
276 crypt = ieee->crypt[ieee->tx_keyidx]; 267 crypt = ieee->crypt[ieee->tx_keyidx];
277 268
278 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && 269 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
279 ieee->host_encrypt && crypt && crypt->ops; 270 ieee->sec.encrypt;
271
272 host_encrypt = ieee->host_encrypt && encrypt && crypt;
273 host_encrypt_msdu = ieee->host_encrypt_msdu && encrypt && crypt;
274 host_build_iv = ieee->host_build_iv && encrypt && crypt;
280 275
281 if (!encrypt && ieee->ieee802_1x && 276 if (!encrypt && ieee->ieee802_1x &&
282 ieee->drop_unencrypted && ether_type != ETH_P_PAE) { 277 ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
@@ -285,8 +280,8 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
285 } 280 }
286 281
287 /* Save source and destination addresses */ 282 /* Save source and destination addresses */
288 memcpy(&dest, skb->data, ETH_ALEN); 283 memcpy(dest, skb->data, ETH_ALEN);
289 memcpy(&src, skb->data + ETH_ALEN, ETH_ALEN); 284 memcpy(src, skb->data + ETH_ALEN, ETH_ALEN);
290 285
291 /* Advance the SKB to the start of the payload */ 286 /* Advance the SKB to the start of the payload */
292 skb_pull(skb, sizeof(struct ethhdr)); 287 skb_pull(skb, sizeof(struct ethhdr));
@@ -294,7 +289,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
294 /* Determine total amount of storage required for TXB packets */ 289 /* Determine total amount of storage required for TXB packets */
295 bytes = skb->len + SNAP_SIZE + sizeof(u16); 290 bytes = skb->len + SNAP_SIZE + sizeof(u16);
296 291
297 if (encrypt) 292 if (host_encrypt)
298 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | 293 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
299 IEEE80211_FCTL_PROTECTED; 294 IEEE80211_FCTL_PROTECTED;
300 else 295 else
@@ -302,70 +297,144 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
302 297
303 if (ieee->iw_mode == IW_MODE_INFRA) { 298 if (ieee->iw_mode == IW_MODE_INFRA) {
304 fc |= IEEE80211_FCTL_TODS; 299 fc |= IEEE80211_FCTL_TODS;
305 /* To DS: Addr1 = BSSID, Addr2 = SA, 300 /* To DS: Addr1 = BSSID, Addr2 = SA, Addr3 = DA */
306 Addr3 = DA */ 301 memcpy(header.addr1, ieee->bssid, ETH_ALEN);
307 memcpy(&header.addr1, ieee->bssid, ETH_ALEN); 302 memcpy(header.addr2, src, ETH_ALEN);
308 memcpy(&header.addr2, &src, ETH_ALEN); 303 memcpy(header.addr3, dest, ETH_ALEN);
309 memcpy(&header.addr3, &dest, ETH_ALEN);
310 } else if (ieee->iw_mode == IW_MODE_ADHOC) { 304 } else if (ieee->iw_mode == IW_MODE_ADHOC) {
311 /* not From/To DS: Addr1 = DA, Addr2 = SA, 305 /* not From/To DS: Addr1 = DA, Addr2 = SA, Addr3 = BSSID */
312 Addr3 = BSSID */ 306 memcpy(header.addr1, dest, ETH_ALEN);
313 memcpy(&header.addr1, dest, ETH_ALEN); 307 memcpy(header.addr2, src, ETH_ALEN);
314 memcpy(&header.addr2, src, ETH_ALEN); 308 memcpy(header.addr3, ieee->bssid, ETH_ALEN);
315 memcpy(&header.addr3, ieee->bssid, ETH_ALEN);
316 } 309 }
317 header.frame_ctl = cpu_to_le16(fc); 310 header.frame_ctl = cpu_to_le16(fc);
318 hdr_len = IEEE80211_3ADDR_LEN; 311 hdr_len = IEEE80211_3ADDR_LEN;
319 312
320 /* Determine fragmentation size based on destination (multicast 313 /* Encrypt msdu first on the whole data packet. */
321 * and broadcast are not fragmented) */ 314 if ((host_encrypt || host_encrypt_msdu) &&
322 if (is_multicast_ether_addr(dest) || is_broadcast_ether_addr(dest)) 315 crypt && crypt->ops && crypt->ops->encrypt_msdu) {
323 frag_size = MAX_FRAG_THRESHOLD; 316 int res = 0;
324 else 317 int len = bytes + hdr_len + crypt->ops->extra_msdu_prefix_len +
325 frag_size = ieee->fts; 318 crypt->ops->extra_msdu_postfix_len;
319 struct sk_buff *skb_new = dev_alloc_skb(len);
320
321 if (unlikely(!skb_new))
322 goto failed;
323
324 skb_reserve(skb_new, crypt->ops->extra_msdu_prefix_len);
325 memcpy(skb_put(skb_new, hdr_len), &header, hdr_len);
326 snapped = 1;
327 ieee80211_copy_snap(skb_put(skb_new, SNAP_SIZE + sizeof(u16)),
328 ether_type);
329 memcpy(skb_put(skb_new, skb->len), skb->data, skb->len);
330 res = crypt->ops->encrypt_msdu(skb_new, hdr_len, crypt->priv);
331 if (res < 0) {
332 IEEE80211_ERROR("msdu encryption failed\n");
333 dev_kfree_skb_any(skb_new);
334 goto failed;
335 }
336 dev_kfree_skb_any(skb);
337 skb = skb_new;
338 bytes += crypt->ops->extra_msdu_prefix_len +
339 crypt->ops->extra_msdu_postfix_len;
340 skb_pull(skb, hdr_len);
341 }
326 342
327 /* Determine amount of payload per fragment. Regardless of if 343 if (host_encrypt || ieee->host_open_frag) {
328 * this stack is providing the full 802.11 header, one will 344 /* Determine fragmentation size based on destination (multicast
329 * eventually be affixed to this fragment -- so we must account for 345 * and broadcast are not fragmented) */
330 * it when determining the amount of payload space. */ 346 if (is_multicast_ether_addr(dest) ||
331 bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN; 347 is_broadcast_ether_addr(dest))
332 if (ieee->config & 348 frag_size = MAX_FRAG_THRESHOLD;
333 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 349 else
334 bytes_per_frag -= IEEE80211_FCS_LEN; 350 frag_size = ieee->fts;
335 351
336 /* Each fragment may need to have room for encryptiong pre/postfix */ 352 /* Determine amount of payload per fragment. Regardless of if
337 if (encrypt) 353 * this stack is providing the full 802.11 header, one will
338 bytes_per_frag -= crypt->ops->extra_prefix_len + 354 * eventually be affixed to this fragment -- so we must account
339 crypt->ops->extra_postfix_len; 355 * for it when determining the amount of payload space. */
340 356 bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN;
341 /* Number of fragments is the total bytes_per_frag / 357 if (ieee->config &
342 * payload_per_fragment */ 358 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
343 nr_frags = bytes / bytes_per_frag; 359 bytes_per_frag -= IEEE80211_FCS_LEN;
344 bytes_last_frag = bytes % bytes_per_frag; 360
345 if (bytes_last_frag) 361 /* Each fragment may need to have room for encryptiong
362 * pre/postfix */
363 if (host_encrypt)
364 bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len +
365 crypt->ops->extra_mpdu_postfix_len;
366
367 /* Number of fragments is the total
368 * bytes_per_frag / payload_per_fragment */
369 nr_frags = bytes / bytes_per_frag;
370 bytes_last_frag = bytes % bytes_per_frag;
371 if (bytes_last_frag)
372 nr_frags++;
373 else
374 bytes_last_frag = bytes_per_frag;
375 } else {
376 nr_frags = 1;
377 bytes_per_frag = bytes_last_frag = bytes;
378 frag_size = bytes + IEEE80211_3ADDR_LEN;
379 }
380
381 rts_required = (frag_size > ieee->rts
382 && ieee->config & CFG_IEEE80211_RTS);
383 if (rts_required)
346 nr_frags++; 384 nr_frags++;
347 else
348 bytes_last_frag = bytes_per_frag;
349 385
350 /* When we allocate the TXB we allocate enough space for the reserve 386 /* When we allocate the TXB we allocate enough space for the reserve
351 * and full fragment bytes (bytes_per_frag doesn't include prefix, 387 * and full fragment bytes (bytes_per_frag doesn't include prefix,
352 * postfix, header, FCS, etc.) */ 388 * postfix, header, FCS, etc.) */
353 txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC); 389 txb = ieee80211_alloc_txb(nr_frags, frag_size,
390 ieee->tx_headroom, GFP_ATOMIC);
354 if (unlikely(!txb)) { 391 if (unlikely(!txb)) {
355 printk(KERN_WARNING "%s: Could not allocate TXB\n", 392 printk(KERN_WARNING "%s: Could not allocate TXB\n",
356 ieee->dev->name); 393 ieee->dev->name);
357 goto failed; 394 goto failed;
358 } 395 }
359 txb->encrypted = encrypt; 396 txb->encrypted = encrypt;
360 txb->payload_size = bytes; 397 if (host_encrypt)
398 txb->payload_size = frag_size * (nr_frags - 1) +
399 bytes_last_frag;
400 else
401 txb->payload_size = bytes;
402
403 if (rts_required) {
404 skb_frag = txb->fragments[0];
405 frag_hdr =
406 (struct ieee80211_hdr_3addr *)skb_put(skb_frag, hdr_len);
407
408 /*
409 * Set header frame_ctl to the RTS.
410 */
411 header.frame_ctl =
412 cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS);
413 memcpy(frag_hdr, &header, hdr_len);
361 414
362 for (i = 0; i < nr_frags; i++) { 415 /*
416 * Restore header frame_ctl to the original data setting.
417 */
418 header.frame_ctl = cpu_to_le16(fc);
419
420 if (ieee->config &
421 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
422 skb_put(skb_frag, 4);
423
424 txb->rts_included = 1;
425 i = 1;
426 } else
427 i = 0;
428
429 for (; i < nr_frags; i++) {
363 skb_frag = txb->fragments[i]; 430 skb_frag = txb->fragments[i];
364 431
365 if (encrypt) 432 if (host_encrypt || host_build_iv)
366 skb_reserve(skb_frag, crypt->ops->extra_prefix_len); 433 skb_reserve(skb_frag,
434 crypt->ops->extra_mpdu_prefix_len);
367 435
368 frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len); 436 frag_hdr =
437 (struct ieee80211_hdr_3addr *)skb_put(skb_frag, hdr_len);
369 memcpy(frag_hdr, &header, hdr_len); 438 memcpy(frag_hdr, &header, hdr_len);
370 439
371 /* If this is not the last fragment, then add the MOREFRAGS 440 /* If this is not the last fragment, then add the MOREFRAGS
@@ -379,11 +448,10 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
379 bytes = bytes_last_frag; 448 bytes = bytes_last_frag;
380 } 449 }
381 450
382 /* Put a SNAP header on the first fragment */ 451 if (i == 0 && !snapped) {
383 if (i == 0) { 452 ieee80211_copy_snap(skb_put
384 ieee80211_put_snap(skb_put 453 (skb_frag, SNAP_SIZE + sizeof(u16)),
385 (skb_frag, SNAP_SIZE + sizeof(u16)), 454 ether_type);
386 ether_type);
387 bytes -= SNAP_SIZE + sizeof(u16); 455 bytes -= SNAP_SIZE + sizeof(u16);
388 } 456 }
389 457
@@ -394,8 +462,19 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
394 462
395 /* Encryption routine will move the header forward in order 463 /* Encryption routine will move the header forward in order
396 * to insert the IV between the header and the payload */ 464 * to insert the IV between the header and the payload */
397 if (encrypt) 465 if (host_encrypt)
398 ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len); 466 ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
467 else if (host_build_iv) {
468 struct ieee80211_crypt_data *crypt;
469
470 crypt = ieee->crypt[ieee->tx_keyidx];
471 atomic_inc(&crypt->refcnt);
472 if (crypt->ops->build_iv)
473 crypt->ops->build_iv(skb_frag, hdr_len,
474 crypt->priv);
475 atomic_dec(&crypt->refcnt);
476 }
477
399 if (ieee->config & 478 if (ieee->config &
400 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 479 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
401 skb_put(skb_frag, 4); 480 skb_put(skb_frag, 4);
@@ -407,11 +486,20 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
407 dev_kfree_skb_any(skb); 486 dev_kfree_skb_any(skb);
408 487
409 if (txb) { 488 if (txb) {
410 if ((*ieee->hard_start_xmit) (txb, dev) == 0) { 489 int ret = (*ieee->hard_start_xmit) (txb, dev, priority);
490 if (ret == 0) {
411 stats->tx_packets++; 491 stats->tx_packets++;
412 stats->tx_bytes += txb->payload_size; 492 stats->tx_bytes += txb->payload_size;
413 return 0; 493 return 0;
414 } 494 }
495
496 if (ret == NETDEV_TX_BUSY) {
497 printk(KERN_ERR "%s: NETDEV_TX_BUSY returned; "
498 "driver should report queue full via "
499 "ieee_device->is_queue_full.\n",
500 ieee->dev->name);
501 }
502
415 ieee80211_txb_free(txb); 503 ieee80211_txb_free(txb);
416 } 504 }
417 505
@@ -422,7 +510,72 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
422 netif_stop_queue(dev); 510 netif_stop_queue(dev);
423 stats->tx_errors++; 511 stats->tx_errors++;
424 return 1; 512 return 1;
513}
514
515/* Incoming 802.11 strucure is converted to a TXB
516 * a block of 802.11 fragment packets (stored as skbs) */
517int ieee80211_tx_frame(struct ieee80211_device *ieee,
518 struct ieee80211_hdr *frame, int len)
519{
520 struct ieee80211_txb *txb = NULL;
521 unsigned long flags;
522 struct net_device_stats *stats = &ieee->stats;
523 struct sk_buff *skb_frag;
524 int priority = -1;
525
526 spin_lock_irqsave(&ieee->lock, flags);
425 527
528 /* If there is no driver handler to take the TXB, dont' bother
529 * creating it... */
530 if (!ieee->hard_start_xmit) {
531 printk(KERN_WARNING "%s: No xmit handler.\n", ieee->dev->name);
532 goto success;
533 }
534
535 if (unlikely(len < 24)) {
536 printk(KERN_WARNING "%s: skb too small (%d).\n",
537 ieee->dev->name, len);
538 goto success;
539 }
540
541 /* When we allocate the TXB we allocate enough space for the reserve
542 * and full fragment bytes (bytes_per_frag doesn't include prefix,
543 * postfix, header, FCS, etc.) */
544 txb = ieee80211_alloc_txb(1, len, ieee->tx_headroom, GFP_ATOMIC);
545 if (unlikely(!txb)) {
546 printk(KERN_WARNING "%s: Could not allocate TXB\n",
547 ieee->dev->name);
548 goto failed;
549 }
550 txb->encrypted = 0;
551 txb->payload_size = len;
552
553 skb_frag = txb->fragments[0];
554
555 memcpy(skb_put(skb_frag, len), frame, len);
556
557 if (ieee->config &
558 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
559 skb_put(skb_frag, 4);
560
561 success:
562 spin_unlock_irqrestore(&ieee->lock, flags);
563
564 if (txb) {
565 if ((*ieee->hard_start_xmit) (txb, ieee->dev, priority) == 0) {
566 stats->tx_packets++;
567 stats->tx_bytes += txb->payload_size;
568 return 0;
569 }
570 ieee80211_txb_free(txb);
571 }
572 return 0;
573
574 failed:
575 spin_unlock_irqrestore(&ieee->lock, flags);
576 stats->tx_errors++;
577 return 1;
426} 578}
427 579
580EXPORT_SYMBOL(ieee80211_tx_frame);
428EXPORT_SYMBOL(ieee80211_txb_free); 581EXPORT_SYMBOL(ieee80211_txb_free);
diff --git a/net/ieee80211/ieee80211_wx.c b/net/ieee80211/ieee80211_wx.c
index 94882f39b072..1ce7af9bec35 100644
--- a/net/ieee80211/ieee80211_wx.c
+++ b/net/ieee80211/ieee80211_wx.c
@@ -1,6 +1,6 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 Copyright(c) 2004 Intel Corporation. All rights reserved. 3 Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
4 4
5 Portions of this file are based on the WEP enablement code provided by the 5 Portions of this file are based on the WEP enablement code provided by the
6 Host AP project hostap-drivers v0.1.3 6 Host AP project hostap-drivers v0.1.3
@@ -32,6 +32,7 @@
32 32
33#include <linux/kmod.h> 33#include <linux/kmod.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/jiffies.h>
35 36
36#include <net/ieee80211.h> 37#include <net/ieee80211.h>
37#include <linux/wireless.h> 38#include <linux/wireless.h>
@@ -140,18 +141,41 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
140 start = iwe_stream_add_point(start, stop, &iwe, custom); 141 start = iwe_stream_add_point(start, stop, &iwe, custom);
141 142
142 /* Add quality statistics */ 143 /* Add quality statistics */
143 /* TODO: Fix these values... */
144 iwe.cmd = IWEVQUAL; 144 iwe.cmd = IWEVQUAL;
145 iwe.u.qual.qual = network->stats.signal; 145 iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
146 iwe.u.qual.level = network->stats.rssi; 146 IW_QUAL_NOISE_UPDATED;
147 iwe.u.qual.noise = network->stats.noise; 147
148 iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK; 148 if (!(network->stats.mask & IEEE80211_STATMASK_RSSI)) {
149 if (!(network->stats.mask & IEEE80211_STATMASK_RSSI)) 149 iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID |
150 iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID; 150 IW_QUAL_LEVEL_INVALID;
151 if (!(network->stats.mask & IEEE80211_STATMASK_NOISE)) 151 iwe.u.qual.qual = 0;
152 iwe.u.qual.level = 0;
153 } else {
154 iwe.u.qual.level = network->stats.rssi;
155 if (ieee->perfect_rssi == ieee->worst_rssi)
156 iwe.u.qual.qual = 100;
157 else
158 iwe.u.qual.qual =
159 (100 *
160 (ieee->perfect_rssi - ieee->worst_rssi) *
161 (ieee->perfect_rssi - ieee->worst_rssi) -
162 (ieee->perfect_rssi - network->stats.rssi) *
163 (15 * (ieee->perfect_rssi - ieee->worst_rssi) +
164 62 * (ieee->perfect_rssi - network->stats.rssi))) /
165 ((ieee->perfect_rssi - ieee->worst_rssi) *
166 (ieee->perfect_rssi - ieee->worst_rssi));
167 if (iwe.u.qual.qual > 100)
168 iwe.u.qual.qual = 100;
169 else if (iwe.u.qual.qual < 1)
170 iwe.u.qual.qual = 0;
171 }
172
173 if (!(network->stats.mask & IEEE80211_STATMASK_NOISE)) {
152 iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID; 174 iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
153 if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL)) 175 iwe.u.qual.noise = 0;
154 iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID; 176 } else {
177 iwe.u.qual.noise = network->stats.noise;
178 }
155 179
156 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); 180 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
157 181
@@ -162,7 +186,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
162 if (iwe.u.data.length) 186 if (iwe.u.data.length)
163 start = iwe_stream_add_point(start, stop, &iwe, custom); 187 start = iwe_stream_add_point(start, stop, &iwe, custom);
164 188
165 if (ieee->wpa_enabled && network->wpa_ie_len) { 189 if (network->wpa_ie_len) {
166 char buf[MAX_WPA_IE_LEN * 2 + 30]; 190 char buf[MAX_WPA_IE_LEN * 2 + 30];
167 191
168 u8 *p = buf; 192 u8 *p = buf;
@@ -177,7 +201,7 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
177 start = iwe_stream_add_point(start, stop, &iwe, buf); 201 start = iwe_stream_add_point(start, stop, &iwe, buf);
178 } 202 }
179 203
180 if (ieee->wpa_enabled && network->rsn_ie_len) { 204 if (network->rsn_ie_len) {
181 char buf[MAX_WPA_IE_LEN * 2 + 30]; 205 char buf[MAX_WPA_IE_LEN * 2 + 30];
182 206
183 u8 *p = buf; 207 u8 *p = buf;
@@ -197,8 +221,8 @@ static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
197 iwe.cmd = IWEVCUSTOM; 221 iwe.cmd = IWEVCUSTOM;
198 p = custom; 222 p = custom;
199 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), 223 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
200 " Last beacon: %lums ago", 224 " Last beacon: %dms ago",
201 (jiffies - network->last_scanned) / (HZ / 100)); 225 jiffies_to_msecs(jiffies - network->last_scanned));
202 iwe.u.data.length = p - custom; 226 iwe.u.data.length = p - custom;
203 if (iwe.u.data.length) 227 if (iwe.u.data.length)
204 start = iwe_stream_add_point(start, stop, &iwe, custom); 228 start = iwe_stream_add_point(start, stop, &iwe, custom);
@@ -228,13 +252,13 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
228 ev = ipw2100_translate_scan(ieee, ev, stop, network); 252 ev = ipw2100_translate_scan(ieee, ev, stop, network);
229 else 253 else
230 IEEE80211_DEBUG_SCAN("Not showing network '%s (" 254 IEEE80211_DEBUG_SCAN("Not showing network '%s ("
231 MAC_FMT ")' due to age (%lums).\n", 255 MAC_FMT ")' due to age (%dms).\n",
232 escape_essid(network->ssid, 256 escape_essid(network->ssid,
233 network->ssid_len), 257 network->ssid_len),
234 MAC_ARG(network->bssid), 258 MAC_ARG(network->bssid),
235 (jiffies - 259 jiffies_to_msecs(jiffies -
236 network->last_scanned) / (HZ / 260 network->
237 100)); 261 last_scanned));
238 } 262 }
239 263
240 spin_unlock_irqrestore(&ieee->lock, flags); 264 spin_unlock_irqrestore(&ieee->lock, flags);
@@ -258,6 +282,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
258 }; 282 };
259 int i, key, key_provided, len; 283 int i, key, key_provided, len;
260 struct ieee80211_crypt_data **crypt; 284 struct ieee80211_crypt_data **crypt;
285 int host_crypto = ieee->host_encrypt || ieee->host_decrypt;
261 286
262 IEEE80211_DEBUG_WX("SET_ENCODE\n"); 287 IEEE80211_DEBUG_WX("SET_ENCODE\n");
263 288
@@ -298,15 +323,17 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
298 323
299 if (i == WEP_KEYS) { 324 if (i == WEP_KEYS) {
300 sec.enabled = 0; 325 sec.enabled = 0;
326 sec.encrypt = 0;
301 sec.level = SEC_LEVEL_0; 327 sec.level = SEC_LEVEL_0;
302 sec.flags |= SEC_ENABLED | SEC_LEVEL; 328 sec.flags |= SEC_ENABLED | SEC_LEVEL | SEC_ENCRYPT;
303 } 329 }
304 330
305 goto done; 331 goto done;
306 } 332 }
307 333
308 sec.enabled = 1; 334 sec.enabled = 1;
309 sec.flags |= SEC_ENABLED; 335 sec.encrypt = 1;
336 sec.flags |= SEC_ENABLED | SEC_ENCRYPT;
310 337
311 if (*crypt != NULL && (*crypt)->ops != NULL && 338 if (*crypt != NULL && (*crypt)->ops != NULL &&
312 strcmp((*crypt)->ops->name, "WEP") != 0) { 339 strcmp((*crypt)->ops->name, "WEP") != 0) {
@@ -315,7 +342,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
315 ieee80211_crypt_delayed_deinit(ieee, crypt); 342 ieee80211_crypt_delayed_deinit(ieee, crypt);
316 } 343 }
317 344
318 if (*crypt == NULL) { 345 if (*crypt == NULL && host_crypto) {
319 struct ieee80211_crypt_data *new_crypt; 346 struct ieee80211_crypt_data *new_crypt;
320 347
321 /* take WEP into use */ 348 /* take WEP into use */
@@ -355,49 +382,56 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
355 key, escape_essid(sec.keys[key], len), 382 key, escape_essid(sec.keys[key], len),
356 erq->length, len); 383 erq->length, len);
357 sec.key_sizes[key] = len; 384 sec.key_sizes[key] = len;
358 (*crypt)->ops->set_key(sec.keys[key], len, NULL, 385 if (*crypt)
359 (*crypt)->priv); 386 (*crypt)->ops->set_key(sec.keys[key], len, NULL,
387 (*crypt)->priv);
360 sec.flags |= (1 << key); 388 sec.flags |= (1 << key);
361 /* This ensures a key will be activated if no key is 389 /* This ensures a key will be activated if no key is
362 * explicitely set */ 390 * explicitely set */
363 if (key == sec.active_key) 391 if (key == sec.active_key)
364 sec.flags |= SEC_ACTIVE_KEY; 392 sec.flags |= SEC_ACTIVE_KEY;
393
365 } else { 394 } else {
366 len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN, 395 if (host_crypto) {
367 NULL, (*crypt)->priv); 396 len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN,
368 if (len == 0) { 397 NULL, (*crypt)->priv);
369 /* Set a default key of all 0 */ 398 if (len == 0) {
370 IEEE80211_DEBUG_WX("Setting key %d to all zero.\n", 399 /* Set a default key of all 0 */
371 key); 400 IEEE80211_DEBUG_WX("Setting key %d to all "
372 memset(sec.keys[key], 0, 13); 401 "zero.\n", key);
373 (*crypt)->ops->set_key(sec.keys[key], 13, NULL, 402 memset(sec.keys[key], 0, 13);
374 (*crypt)->priv); 403 (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
375 sec.key_sizes[key] = 13; 404 (*crypt)->priv);
376 sec.flags |= (1 << key); 405 sec.key_sizes[key] = 13;
406 sec.flags |= (1 << key);
407 }
377 } 408 }
378
379 /* No key data - just set the default TX key index */ 409 /* No key data - just set the default TX key index */
380 if (key_provided) { 410 if (key_provided) {
381 IEEE80211_DEBUG_WX 411 IEEE80211_DEBUG_WX("Setting key %d to default Tx "
382 ("Setting key %d to default Tx key.\n", key); 412 "key.\n", key);
383 ieee->tx_keyidx = key; 413 ieee->tx_keyidx = key;
384 sec.active_key = key; 414 sec.active_key = key;
385 sec.flags |= SEC_ACTIVE_KEY; 415 sec.flags |= SEC_ACTIVE_KEY;
386 } 416 }
387 } 417 }
388 418 if (erq->flags & (IW_ENCODE_OPEN | IW_ENCODE_RESTRICTED)) {
389 done: 419 ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED);
390 ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED); 420 sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN :
391 sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY; 421 WLAN_AUTH_SHARED_KEY;
392 sec.flags |= SEC_AUTH_MODE; 422 sec.flags |= SEC_AUTH_MODE;
393 IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ? 423 IEEE80211_DEBUG_WX("Auth: %s\n",
394 "OPEN" : "SHARED KEY"); 424 sec.auth_mode == WLAN_AUTH_OPEN ?
425 "OPEN" : "SHARED KEY");
426 }
395 427
396 /* For now we just support WEP, so only set that security level... 428 /* For now we just support WEP, so only set that security level...
397 * TODO: When WPA is added this is one place that needs to change */ 429 * TODO: When WPA is added this is one place that needs to change */
398 sec.flags |= SEC_LEVEL; 430 sec.flags |= SEC_LEVEL;
399 sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */ 431 sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
432 sec.encode_alg[key] = SEC_ALG_WEP;
400 433
434 done:
401 if (ieee->set_security) 435 if (ieee->set_security)
402 ieee->set_security(dev, &sec); 436 ieee->set_security(dev, &sec);
403 437
@@ -422,6 +456,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
422 struct iw_point *erq = &(wrqu->encoding); 456 struct iw_point *erq = &(wrqu->encoding);
423 int len, key; 457 int len, key;
424 struct ieee80211_crypt_data *crypt; 458 struct ieee80211_crypt_data *crypt;
459 struct ieee80211_security *sec = &ieee->sec;
425 460
426 IEEE80211_DEBUG_WX("GET_ENCODE\n"); 461 IEEE80211_DEBUG_WX("GET_ENCODE\n");
427 462
@@ -436,23 +471,16 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
436 crypt = ieee->crypt[key]; 471 crypt = ieee->crypt[key];
437 erq->flags = key + 1; 472 erq->flags = key + 1;
438 473
439 if (crypt == NULL || crypt->ops == NULL) { 474 if (!sec->enabled) {
440 erq->length = 0; 475 erq->length = 0;
441 erq->flags |= IW_ENCODE_DISABLED; 476 erq->flags |= IW_ENCODE_DISABLED;
442 return 0; 477 return 0;
443 } 478 }
444 479
445 if (strcmp(crypt->ops->name, "WEP") != 0) { 480 len = sec->key_sizes[key];
446 /* only WEP is supported with wireless extensions, so just 481 memcpy(keybuf, sec->keys[key], len);
447 * report that encryption is used */
448 erq->length = 0;
449 erq->flags |= IW_ENCODE_ENABLED;
450 return 0;
451 }
452 482
453 len = crypt->ops->get_key(keybuf, WEP_KEY_LEN, NULL, crypt->priv);
454 erq->length = (len >= 0 ? len : 0); 483 erq->length = (len >= 0 ? len : 0);
455
456 erq->flags |= IW_ENCODE_ENABLED; 484 erq->flags |= IW_ENCODE_ENABLED;
457 485
458 if (ieee->open_wep) 486 if (ieee->open_wep)
@@ -463,6 +491,240 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
463 return 0; 491 return 0;
464} 492}
465 493
494int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
495 struct iw_request_info *info,
496 union iwreq_data *wrqu, char *extra)
497{
498 struct net_device *dev = ieee->dev;
499 struct iw_point *encoding = &wrqu->encoding;
500 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
501 int i, idx, ret = 0;
502 int group_key = 0;
503 const char *alg, *module;
504 struct ieee80211_crypto_ops *ops;
505 struct ieee80211_crypt_data **crypt;
506
507 struct ieee80211_security sec = {
508 .flags = 0,
509 };
510
511 idx = encoding->flags & IW_ENCODE_INDEX;
512 if (idx) {
513 if (idx < 1 || idx > WEP_KEYS)
514 return -EINVAL;
515 idx--;
516 } else
517 idx = ieee->tx_keyidx;
518
519 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
520 crypt = &ieee->crypt[idx];
521 group_key = 1;
522 } else {
523 if (idx != 0)
524 return -EINVAL;
525 if (ieee->iw_mode == IW_MODE_INFRA)
526 crypt = &ieee->crypt[idx];
527 else
528 return -EINVAL;
529 }
530
531 sec.flags |= SEC_ENABLED | SEC_ENCRYPT;
532 if ((encoding->flags & IW_ENCODE_DISABLED) ||
533 ext->alg == IW_ENCODE_ALG_NONE) {
534 if (*crypt)
535 ieee80211_crypt_delayed_deinit(ieee, crypt);
536
537 for (i = 0; i < WEP_KEYS; i++)
538 if (ieee->crypt[i] != NULL)
539 break;
540
541 if (i == WEP_KEYS) {
542 sec.enabled = 0;
543 sec.encrypt = 0;
544 sec.level = SEC_LEVEL_0;
545 sec.flags |= SEC_LEVEL;
546 }
547 goto done;
548 }
549
550 sec.enabled = 1;
551 sec.encrypt = 1;
552
553 if (group_key ? !ieee->host_mc_decrypt :
554 !(ieee->host_encrypt || ieee->host_decrypt ||
555 ieee->host_encrypt_msdu))
556 goto skip_host_crypt;
557
558 switch (ext->alg) {
559 case IW_ENCODE_ALG_WEP:
560 alg = "WEP";
561 module = "ieee80211_crypt_wep";
562 break;
563 case IW_ENCODE_ALG_TKIP:
564 alg = "TKIP";
565 module = "ieee80211_crypt_tkip";
566 break;
567 case IW_ENCODE_ALG_CCMP:
568 alg = "CCMP";
569 module = "ieee80211_crypt_ccmp";
570 break;
571 default:
572 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
573 dev->name, ext->alg);
574 ret = -EINVAL;
575 goto done;
576 }
577
578 ops = ieee80211_get_crypto_ops(alg);
579 if (ops == NULL) {
580 request_module(module);
581 ops = ieee80211_get_crypto_ops(alg);
582 }
583 if (ops == NULL) {
584 IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
585 dev->name, ext->alg);
586 ret = -EINVAL;
587 goto done;
588 }
589
590 if (*crypt == NULL || (*crypt)->ops != ops) {
591 struct ieee80211_crypt_data *new_crypt;
592
593 ieee80211_crypt_delayed_deinit(ieee, crypt);
594
595 new_crypt = (struct ieee80211_crypt_data *)
596 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
597 if (new_crypt == NULL) {
598 ret = -ENOMEM;
599 goto done;
600 }
601 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
602 new_crypt->ops = ops;
603 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
604 new_crypt->priv = new_crypt->ops->init(idx);
605 if (new_crypt->priv == NULL) {
606 kfree(new_crypt);
607 ret = -EINVAL;
608 goto done;
609 }
610 *crypt = new_crypt;
611 }
612
613 if (ext->key_len > 0 && (*crypt)->ops->set_key &&
614 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
615 (*crypt)->priv) < 0) {
616 IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name);
617 ret = -EINVAL;
618 goto done;
619 }
620
621 skip_host_crypt:
622 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
623 ieee->tx_keyidx = idx;
624 sec.active_key = idx;
625 sec.flags |= SEC_ACTIVE_KEY;
626 }
627
628 if (ext->alg != IW_ENCODE_ALG_NONE) {
629 memcpy(sec.keys[idx], ext->key, ext->key_len);
630 sec.key_sizes[idx] = ext->key_len;
631 sec.flags |= (1 << idx);
632 if (ext->alg == IW_ENCODE_ALG_WEP) {
633 sec.encode_alg[idx] = SEC_ALG_WEP;
634 sec.flags |= SEC_LEVEL;
635 sec.level = SEC_LEVEL_1;
636 } else if (ext->alg == IW_ENCODE_ALG_TKIP) {
637 sec.encode_alg[idx] = SEC_ALG_TKIP;
638 sec.flags |= SEC_LEVEL;
639 sec.level = SEC_LEVEL_2;
640 } else if (ext->alg == IW_ENCODE_ALG_CCMP) {
641 sec.encode_alg[idx] = SEC_ALG_CCMP;
642 sec.flags |= SEC_LEVEL;
643 sec.level = SEC_LEVEL_3;
644 }
645 /* Don't set sec level for group keys. */
646 if (group_key)
647 sec.flags &= ~SEC_LEVEL;
648 }
649 done:
650 if (ieee->set_security)
651 ieee->set_security(ieee->dev, &sec);
652
653 /*
654 * Do not reset port if card is in Managed mode since resetting will
655 * generate new IEEE 802.11 authentication which may end up in looping
656 * with IEEE 802.1X. If your hardware requires a reset after WEP
657 * configuration (for example... Prism2), implement the reset_port in
658 * the callbacks structures used to initialize the 802.11 stack.
659 */
660 if (ieee->reset_on_keychange &&
661 ieee->iw_mode != IW_MODE_INFRA &&
662 ieee->reset_port && ieee->reset_port(dev)) {
663 IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
664 return -EINVAL;
665 }
666
667 return ret;
668}
669
670int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee,
671 struct iw_request_info *info,
672 union iwreq_data *wrqu, char *extra)
673{
674 struct iw_point *encoding = &wrqu->encoding;
675 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
676 struct ieee80211_security *sec = &ieee->sec;
677 int idx, max_key_len;
678
679 max_key_len = encoding->length - sizeof(*ext);
680 if (max_key_len < 0)
681 return -EINVAL;
682
683 idx = encoding->flags & IW_ENCODE_INDEX;
684 if (idx) {
685 if (idx < 1 || idx > WEP_KEYS)
686 return -EINVAL;
687 idx--;
688 } else
689 idx = ieee->tx_keyidx;
690
691 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
692 if (idx != 0 || ieee->iw_mode != IW_MODE_INFRA)
693 return -EINVAL;
694
695 encoding->flags = idx + 1;
696 memset(ext, 0, sizeof(*ext));
697
698 if (!sec->enabled) {
699 ext->alg = IW_ENCODE_ALG_NONE;
700 ext->key_len = 0;
701 encoding->flags |= IW_ENCODE_DISABLED;
702 } else {
703 if (sec->encode_alg[idx] == SEC_ALG_WEP)
704 ext->alg = IW_ENCODE_ALG_WEP;
705 else if (sec->encode_alg[idx] == SEC_ALG_TKIP)
706 ext->alg = IW_ENCODE_ALG_TKIP;
707 else if (sec->encode_alg[idx] == SEC_ALG_CCMP)
708 ext->alg = IW_ENCODE_ALG_CCMP;
709 else
710 return -EINVAL;
711
712 ext->key_len = sec->key_sizes[idx];
713 memcpy(ext->key, sec->keys[idx], ext->key_len);
714 encoding->flags |= IW_ENCODE_ENABLED;
715 if (ext->key_len &&
716 (ext->alg == IW_ENCODE_ALG_TKIP ||
717 ext->alg == IW_ENCODE_ALG_CCMP))
718 ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID;
719
720 }
721
722 return 0;
723}
724
725EXPORT_SYMBOL(ieee80211_wx_set_encodeext);
726EXPORT_SYMBOL(ieee80211_wx_get_encodeext);
727
466EXPORT_SYMBOL(ieee80211_wx_get_scan); 728EXPORT_SYMBOL(ieee80211_wx_get_scan);
467EXPORT_SYMBOL(ieee80211_wx_set_encode); 729EXPORT_SYMBOL(ieee80211_wx_set_encode);
468EXPORT_SYMBOL(ieee80211_wx_get_encode); 730EXPORT_SYMBOL(ieee80211_wx_get_encode);
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 74f2207e131a..4ec4b2ca6ab1 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -715,6 +715,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
715 break; 715 break;
716 ret = 0; 716 ret = 0;
717 if (ifa->ifa_mask != sin->sin_addr.s_addr) { 717 if (ifa->ifa_mask != sin->sin_addr.s_addr) {
718 u32 old_mask = ifa->ifa_mask;
718 inet_del_ifa(in_dev, ifap, 0); 719 inet_del_ifa(in_dev, ifap, 0);
719 ifa->ifa_mask = sin->sin_addr.s_addr; 720 ifa->ifa_mask = sin->sin_addr.s_addr;
720 ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask); 721 ifa->ifa_prefixlen = inet_mask_len(ifa->ifa_mask);
@@ -728,7 +729,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg)
728 if ((dev->flags & IFF_BROADCAST) && 729 if ((dev->flags & IFF_BROADCAST) &&
729 (ifa->ifa_prefixlen < 31) && 730 (ifa->ifa_prefixlen < 31) &&
730 (ifa->ifa_broadcast == 731 (ifa->ifa_broadcast ==
731 (ifa->ifa_local|~ifa->ifa_mask))) { 732 (ifa->ifa_local|~old_mask))) {
732 ifa->ifa_broadcast = (ifa->ifa_local | 733 ifa->ifa_broadcast = (ifa->ifa_local |
733 ~sin->sin_addr.s_addr); 734 ~sin->sin_addr.s_addr);
734 } 735 }
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 0093ea08c7f5..66247f38b371 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2404,7 +2404,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2404 prefix = htonl(l->key); 2404 prefix = htonl(l->key);
2405 2405
2406 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2406 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2407 const struct fib_info *fi = rcu_dereference(fa->fa_info); 2407 const struct fib_info *fi = fa->fa_info;
2408 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); 2408 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi);
2409 2409
2410 if (fa->fa_type == RTN_BROADCAST 2410 if (fa->fa_type == RTN_BROADCAST
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 90dca711ac9f..175e093ec564 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -1108,12 +1108,9 @@ void __init icmp_init(struct net_proto_family *ops)
1108 struct inet_sock *inet; 1108 struct inet_sock *inet;
1109 int i; 1109 int i;
1110 1110
1111 for (i = 0; i < NR_CPUS; i++) { 1111 for_each_cpu(i) {
1112 int err; 1112 int err;
1113 1113
1114 if (!cpu_possible(i))
1115 continue;
1116
1117 err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP, 1114 err = sock_create_kern(PF_INET, SOCK_RAW, IPPROTO_ICMP,
1118 &per_cpu(__icmp_socket, i)); 1115 &per_cpu(__icmp_socket, i));
1119 1116
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1ad5202e556b..17758234a3e3 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -275,7 +275,8 @@ int ip_output(struct sk_buff *skb)
275{ 275{
276 IP_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 276 IP_INC_STATS(IPSTATS_MIB_OUTREQUESTS);
277 277
278 if (skb->len > dst_mtu(skb->dst) && !skb_shinfo(skb)->tso_size) 278 if (skb->len > dst_mtu(skb->dst) &&
279 !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size))
279 return ip_fragment(skb, ip_finish_output); 280 return ip_fragment(skb, ip_finish_output);
280 else 281 else
281 return ip_finish_output(skb); 282 return ip_finish_output(skb);
@@ -688,6 +689,60 @@ csum_page(struct page *page, int offset, int copy)
688 return csum; 689 return csum;
689} 690}
690 691
692inline int ip_ufo_append_data(struct sock *sk,
693 int getfrag(void *from, char *to, int offset, int len,
694 int odd, struct sk_buff *skb),
695 void *from, int length, int hh_len, int fragheaderlen,
696 int transhdrlen, int mtu,unsigned int flags)
697{
698 struct sk_buff *skb;
699 int err;
700
701 /* There is support for UDP fragmentation offload by network
702 * device, so create one single skb packet containing complete
703 * udp datagram
704 */
705 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
706 skb = sock_alloc_send_skb(sk,
707 hh_len + fragheaderlen + transhdrlen + 20,
708 (flags & MSG_DONTWAIT), &err);
709
710 if (skb == NULL)
711 return err;
712
713 /* reserve space for Hardware header */
714 skb_reserve(skb, hh_len);
715
716 /* create space for UDP/IP header */
717 skb_put(skb,fragheaderlen + transhdrlen);
718
719 /* initialize network header pointer */
720 skb->nh.raw = skb->data;
721
722 /* initialize protocol header pointer */
723 skb->h.raw = skb->data + fragheaderlen;
724
725 skb->ip_summed = CHECKSUM_HW;
726 skb->csum = 0;
727 sk->sk_sndmsg_off = 0;
728 }
729
730 err = skb_append_datato_frags(sk,skb, getfrag, from,
731 (length - transhdrlen));
732 if (!err) {
733 /* specify the length of each IP datagram fragment*/
734 skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen);
735 __skb_queue_tail(&sk->sk_write_queue, skb);
736
737 return 0;
738 }
739 /* There is not enough support do UFO ,
740 * so follow normal path
741 */
742 kfree_skb(skb);
743 return err;
744}
745
691/* 746/*
692 * ip_append_data() and ip_append_page() can make one large IP datagram 747 * ip_append_data() and ip_append_page() can make one large IP datagram
693 * from many pieces of data. Each pieces will be holded on the socket 748 * from many pieces of data. Each pieces will be holded on the socket
@@ -777,6 +832,15 @@ int ip_append_data(struct sock *sk,
777 csummode = CHECKSUM_HW; 832 csummode = CHECKSUM_HW;
778 833
779 inet->cork.length += length; 834 inet->cork.length += length;
835 if (((length > mtu) && (sk->sk_protocol == IPPROTO_UDP)) &&
836 (rt->u.dst.dev->features & NETIF_F_UFO)) {
837
838 if(ip_ufo_append_data(sk, getfrag, from, length, hh_len,
839 fragheaderlen, transhdrlen, mtu, flags))
840 goto error;
841
842 return 0;
843 }
780 844
781 /* So, what's going on in the loop below? 845 /* So, what's going on in the loop below?
782 * 846 *
@@ -1008,14 +1072,23 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
1008 return -EINVAL; 1072 return -EINVAL;
1009 1073
1010 inet->cork.length += size; 1074 inet->cork.length += size;
1075 if ((sk->sk_protocol == IPPROTO_UDP) &&
1076 (rt->u.dst.dev->features & NETIF_F_UFO))
1077 skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen);
1078
1011 1079
1012 while (size > 0) { 1080 while (size > 0) {
1013 int i; 1081 int i;
1014 1082
1015 /* Check if the remaining data fits into current packet. */ 1083 if (skb_shinfo(skb)->ufo_size)
1016 len = mtu - skb->len; 1084 len = size;
1017 if (len < size) 1085 else {
1018 len = maxfraglen - skb->len; 1086
1087 /* Check if the remaining data fits into current packet. */
1088 len = mtu - skb->len;
1089 if (len < size)
1090 len = maxfraglen - skb->len;
1091 }
1019 if (len <= 0) { 1092 if (len <= 0) {
1020 struct sk_buff *skb_prev; 1093 struct sk_buff *skb_prev;
1021 char *data; 1094 char *data;
@@ -1023,10 +1096,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
1023 int alloclen; 1096 int alloclen;
1024 1097
1025 skb_prev = skb; 1098 skb_prev = skb;
1026 if (skb_prev) 1099 fraggap = skb_prev->len - maxfraglen;
1027 fraggap = skb_prev->len - maxfraglen;
1028 else
1029 fraggap = 0;
1030 1100
1031 alloclen = fragheaderlen + hh_len + fraggap + 15; 1101 alloclen = fragheaderlen + hh_len + fraggap + 15;
1032 skb = sock_wmalloc(sk, alloclen, 1, sk->sk_allocation); 1102 skb = sock_wmalloc(sk, alloclen, 1, sk->sk_allocation);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 07a80b56e8dc..422ab68ee7fb 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -50,7 +50,7 @@
50#include <linux/netfilter_ipv4/ip_conntrack_core.h> 50#include <linux/netfilter_ipv4/ip_conntrack_core.h>
51#include <linux/netfilter_ipv4/listhelp.h> 51#include <linux/netfilter_ipv4/listhelp.h>
52 52
53#define IP_CONNTRACK_VERSION "2.3" 53#define IP_CONNTRACK_VERSION "2.4"
54 54
55#if 0 55#if 0
56#define DEBUGP printk 56#define DEBUGP printk
@@ -148,16 +148,20 @@ DEFINE_PER_CPU(struct ip_conntrack_stat, ip_conntrack_stat);
148static int ip_conntrack_hash_rnd_initted; 148static int ip_conntrack_hash_rnd_initted;
149static unsigned int ip_conntrack_hash_rnd; 149static unsigned int ip_conntrack_hash_rnd;
150 150
151static u_int32_t 151static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple,
152hash_conntrack(const struct ip_conntrack_tuple *tuple) 152 unsigned int size, unsigned int rnd)
153{ 153{
154#if 0
155 dump_tuple(tuple);
156#endif
157 return (jhash_3words(tuple->src.ip, 154 return (jhash_3words(tuple->src.ip,
158 (tuple->dst.ip ^ tuple->dst.protonum), 155 (tuple->dst.ip ^ tuple->dst.protonum),
159 (tuple->src.u.all | (tuple->dst.u.all << 16)), 156 (tuple->src.u.all | (tuple->dst.u.all << 16)),
160 ip_conntrack_hash_rnd) % ip_conntrack_htable_size); 157 rnd) % size);
158}
159
160static u_int32_t
161hash_conntrack(const struct ip_conntrack_tuple *tuple)
162{
163 return __hash_conntrack(tuple, ip_conntrack_htable_size,
164 ip_conntrack_hash_rnd);
161} 165}
162 166
163int 167int
@@ -1341,14 +1345,13 @@ static int kill_all(struct ip_conntrack *i, void *data)
1341 return 1; 1345 return 1;
1342} 1346}
1343 1347
1344static void free_conntrack_hash(void) 1348static void free_conntrack_hash(struct list_head *hash, int vmalloced,int size)
1345{ 1349{
1346 if (ip_conntrack_vmalloc) 1350 if (vmalloced)
1347 vfree(ip_conntrack_hash); 1351 vfree(hash);
1348 else 1352 else
1349 free_pages((unsigned long)ip_conntrack_hash, 1353 free_pages((unsigned long)hash,
1350 get_order(sizeof(struct list_head) 1354 get_order(sizeof(struct list_head) * size));
1351 * ip_conntrack_htable_size));
1352} 1355}
1353 1356
1354void ip_conntrack_flush() 1357void ip_conntrack_flush()
@@ -1378,12 +1381,83 @@ void ip_conntrack_cleanup(void)
1378 ip_conntrack_flush(); 1381 ip_conntrack_flush();
1379 kmem_cache_destroy(ip_conntrack_cachep); 1382 kmem_cache_destroy(ip_conntrack_cachep);
1380 kmem_cache_destroy(ip_conntrack_expect_cachep); 1383 kmem_cache_destroy(ip_conntrack_expect_cachep);
1381 free_conntrack_hash(); 1384 free_conntrack_hash(ip_conntrack_hash, ip_conntrack_vmalloc,
1385 ip_conntrack_htable_size);
1382 nf_unregister_sockopt(&so_getorigdst); 1386 nf_unregister_sockopt(&so_getorigdst);
1383} 1387}
1384 1388
1385static int hashsize; 1389static struct list_head *alloc_hashtable(int size, int *vmalloced)
1386module_param(hashsize, int, 0400); 1390{
1391 struct list_head *hash;
1392 unsigned int i;
1393
1394 *vmalloced = 0;
1395 hash = (void*)__get_free_pages(GFP_KERNEL,
1396 get_order(sizeof(struct list_head)
1397 * size));
1398 if (!hash) {
1399 *vmalloced = 1;
1400 printk(KERN_WARNING"ip_conntrack: falling back to vmalloc.\n");
1401 hash = vmalloc(sizeof(struct list_head) * size);
1402 }
1403
1404 if (hash)
1405 for (i = 0; i < size; i++)
1406 INIT_LIST_HEAD(&hash[i]);
1407
1408 return hash;
1409}
1410
1411int set_hashsize(const char *val, struct kernel_param *kp)
1412{
1413 int i, bucket, hashsize, vmalloced;
1414 int old_vmalloced, old_size;
1415 int rnd;
1416 struct list_head *hash, *old_hash;
1417 struct ip_conntrack_tuple_hash *h;
1418
1419 /* On boot, we can set this without any fancy locking. */
1420 if (!ip_conntrack_htable_size)
1421 return param_set_int(val, kp);
1422
1423 hashsize = simple_strtol(val, NULL, 0);
1424 if (!hashsize)
1425 return -EINVAL;
1426
1427 hash = alloc_hashtable(hashsize, &vmalloced);
1428 if (!hash)
1429 return -ENOMEM;
1430
1431 /* We have to rehash for the new table anyway, so we also can
1432 * use a new random seed */
1433 get_random_bytes(&rnd, 4);
1434
1435 write_lock_bh(&ip_conntrack_lock);
1436 for (i = 0; i < ip_conntrack_htable_size; i++) {
1437 while (!list_empty(&ip_conntrack_hash[i])) {
1438 h = list_entry(ip_conntrack_hash[i].next,
1439 struct ip_conntrack_tuple_hash, list);
1440 list_del(&h->list);
1441 bucket = __hash_conntrack(&h->tuple, hashsize, rnd);
1442 list_add_tail(&h->list, &hash[bucket]);
1443 }
1444 }
1445 old_size = ip_conntrack_htable_size;
1446 old_vmalloced = ip_conntrack_vmalloc;
1447 old_hash = ip_conntrack_hash;
1448
1449 ip_conntrack_htable_size = hashsize;
1450 ip_conntrack_vmalloc = vmalloced;
1451 ip_conntrack_hash = hash;
1452 ip_conntrack_hash_rnd = rnd;
1453 write_unlock_bh(&ip_conntrack_lock);
1454
1455 free_conntrack_hash(old_hash, old_vmalloced, old_size);
1456 return 0;
1457}
1458
1459module_param_call(hashsize, set_hashsize, param_get_uint,
1460 &ip_conntrack_htable_size, 0600);
1387 1461
1388int __init ip_conntrack_init(void) 1462int __init ip_conntrack_init(void)
1389{ 1463{
@@ -1392,9 +1466,7 @@ int __init ip_conntrack_init(void)
1392 1466
1393 /* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB 1467 /* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB
1394 * machine has 256 buckets. >= 1GB machines have 8192 buckets. */ 1468 * machine has 256 buckets. >= 1GB machines have 8192 buckets. */
1395 if (hashsize) { 1469 if (!ip_conntrack_htable_size) {
1396 ip_conntrack_htable_size = hashsize;
1397 } else {
1398 ip_conntrack_htable_size 1470 ip_conntrack_htable_size
1399 = (((num_physpages << PAGE_SHIFT) / 16384) 1471 = (((num_physpages << PAGE_SHIFT) / 16384)
1400 / sizeof(struct list_head)); 1472 / sizeof(struct list_head));
@@ -1416,20 +1488,8 @@ int __init ip_conntrack_init(void)
1416 return ret; 1488 return ret;
1417 } 1489 }
1418 1490
1419 /* AK: the hash table is twice as big than needed because it 1491 ip_conntrack_hash = alloc_hashtable(ip_conntrack_htable_size,
1420 uses list_head. it would be much nicer to caches to use a 1492 &ip_conntrack_vmalloc);
1421 single pointer list head here. */
1422 ip_conntrack_vmalloc = 0;
1423 ip_conntrack_hash
1424 =(void*)__get_free_pages(GFP_KERNEL,
1425 get_order(sizeof(struct list_head)
1426 *ip_conntrack_htable_size));
1427 if (!ip_conntrack_hash) {
1428 ip_conntrack_vmalloc = 1;
1429 printk(KERN_WARNING "ip_conntrack: falling back to vmalloc.\n");
1430 ip_conntrack_hash = vmalloc(sizeof(struct list_head)
1431 * ip_conntrack_htable_size);
1432 }
1433 if (!ip_conntrack_hash) { 1493 if (!ip_conntrack_hash) {
1434 printk(KERN_ERR "Unable to create ip_conntrack_hash\n"); 1494 printk(KERN_ERR "Unable to create ip_conntrack_hash\n");
1435 goto err_unreg_sockopt; 1495 goto err_unreg_sockopt;
@@ -1461,9 +1521,6 @@ int __init ip_conntrack_init(void)
1461 ip_ct_protos[IPPROTO_ICMP] = &ip_conntrack_protocol_icmp; 1521 ip_ct_protos[IPPROTO_ICMP] = &ip_conntrack_protocol_icmp;
1462 write_unlock_bh(&ip_conntrack_lock); 1522 write_unlock_bh(&ip_conntrack_lock);
1463 1523
1464 for (i = 0; i < ip_conntrack_htable_size; i++)
1465 INIT_LIST_HEAD(&ip_conntrack_hash[i]);
1466
1467 /* For use by ipt_REJECT */ 1524 /* For use by ipt_REJECT */
1468 ip_ct_attach = ip_conntrack_attach; 1525 ip_ct_attach = ip_conntrack_attach;
1469 1526
@@ -1478,7 +1535,8 @@ int __init ip_conntrack_init(void)
1478err_free_conntrack_slab: 1535err_free_conntrack_slab:
1479 kmem_cache_destroy(ip_conntrack_cachep); 1536 kmem_cache_destroy(ip_conntrack_cachep);
1480err_free_hash: 1537err_free_hash:
1481 free_conntrack_hash(); 1538 free_conntrack_hash(ip_conntrack_hash, ip_conntrack_vmalloc,
1539 ip_conntrack_htable_size);
1482err_unreg_sockopt: 1540err_unreg_sockopt:
1483 nf_unregister_sockopt(&so_getorigdst); 1541 nf_unregister_sockopt(&so_getorigdst);
1484 1542
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index f7943ba1f43c..a65e508fbd40 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -90,9 +90,7 @@ fold_field(void *mib[], int offt)
90 unsigned long res = 0; 90 unsigned long res = 0;
91 int i; 91 int i;
92 92
93 for (i = 0; i < NR_CPUS; i++) { 93 for_each_cpu(i) {
94 if (!cpu_possible(i))
95 continue;
96 res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt); 94 res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt);
97 res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt); 95 res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt);
98 } 96 }
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index b7185fb3377c..23e540365a14 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -700,10 +700,7 @@ int __init icmpv6_init(struct net_proto_family *ops)
700 struct sock *sk; 700 struct sock *sk;
701 int err, i, j; 701 int err, i, j;
702 702
703 for (i = 0; i < NR_CPUS; i++) { 703 for_each_cpu(i) {
704 if (!cpu_possible(i))
705 continue;
706
707 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, 704 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6,
708 &per_cpu(__icmpv6_socket, i)); 705 &per_cpu(__icmpv6_socket, i));
709 if (err < 0) { 706 if (err < 0) {
@@ -749,9 +746,7 @@ void icmpv6_cleanup(void)
749{ 746{
750 int i; 747 int i;
751 748
752 for (i = 0; i < NR_CPUS; i++) { 749 for_each_cpu(i) {
753 if (!cpu_possible(i))
754 continue;
755 sock_release(per_cpu(__icmpv6_socket, i)); 750 sock_release(per_cpu(__icmpv6_socket, i));
756 } 751 }
757 inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6); 752 inet6_del_protocol(&icmpv6_protocol, IPPROTO_ICMPV6);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 563b442ffab8..614296a920c6 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -147,7 +147,8 @@ static int ip6_output2(struct sk_buff *skb)
147 147
148int ip6_output(struct sk_buff *skb) 148int ip6_output(struct sk_buff *skb)
149{ 149{
150 if (skb->len > dst_mtu(skb->dst) || dst_allfrag(skb->dst)) 150 if ((skb->len > dst_mtu(skb->dst) && !skb_shinfo(skb)->ufo_size) ||
151 dst_allfrag(skb->dst))
151 return ip6_fragment(skb, ip6_output2); 152 return ip6_fragment(skb, ip6_output2);
152 else 153 else
153 return ip6_output2(skb); 154 return ip6_output2(skb);
@@ -768,6 +769,65 @@ out_err_release:
768 *dst = NULL; 769 *dst = NULL;
769 return err; 770 return err;
770} 771}
772inline int ip6_ufo_append_data(struct sock *sk,
773 int getfrag(void *from, char *to, int offset, int len,
774 int odd, struct sk_buff *skb),
775 void *from, int length, int hh_len, int fragheaderlen,
776 int transhdrlen, int mtu,unsigned int flags)
777
778{
779 struct sk_buff *skb;
780 int err;
781
782 /* There is support for UDP large send offload by network
783 * device, so create one single skb packet containing complete
784 * udp datagram
785 */
786 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
787 skb = sock_alloc_send_skb(sk,
788 hh_len + fragheaderlen + transhdrlen + 20,
789 (flags & MSG_DONTWAIT), &err);
790 if (skb == NULL)
791 return -ENOMEM;
792
793 /* reserve space for Hardware header */
794 skb_reserve(skb, hh_len);
795
796 /* create space for UDP/IP header */
797 skb_put(skb,fragheaderlen + transhdrlen);
798
799 /* initialize network header pointer */
800 skb->nh.raw = skb->data;
801
802 /* initialize protocol header pointer */
803 skb->h.raw = skb->data + fragheaderlen;
804
805 skb->ip_summed = CHECKSUM_HW;
806 skb->csum = 0;
807 sk->sk_sndmsg_off = 0;
808 }
809
810 err = skb_append_datato_frags(sk,skb, getfrag, from,
811 (length - transhdrlen));
812 if (!err) {
813 struct frag_hdr fhdr;
814
815 /* specify the length of each IP datagram fragment*/
816 skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen) -
817 sizeof(struct frag_hdr);
818 ipv6_select_ident(skb, &fhdr);
819 skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
820 __skb_queue_tail(&sk->sk_write_queue, skb);
821
822 return 0;
823 }
824 /* There is not enough support do UPD LSO,
825 * so follow normal path
826 */
827 kfree_skb(skb);
828
829 return err;
830}
771 831
772int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, 832int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
773 int offset, int len, int odd, struct sk_buff *skb), 833 int offset, int len, int odd, struct sk_buff *skb),
@@ -860,6 +920,15 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
860 */ 920 */
861 921
862 inet->cork.length += length; 922 inet->cork.length += length;
923 if (((length > mtu) && (sk->sk_protocol == IPPROTO_UDP)) &&
924 (rt->u.dst.dev->features & NETIF_F_UFO)) {
925
926 if(ip6_ufo_append_data(sk, getfrag, from, length, hh_len,
927 fragheaderlen, transhdrlen, mtu, flags))
928 goto error;
929
930 return 0;
931 }
863 932
864 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) 933 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
865 goto alloc_new_skb; 934 goto alloc_new_skb;
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 39a96c768102..c4f2a0ef7489 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -164,7 +164,7 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
164#define MLDV2_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value)) 164#define MLDV2_MASK(value, nb) ((nb)>=32 ? (value) : ((1<<(nb))-1) & (value))
165#define MLDV2_EXP(thresh, nbmant, nbexp, value) \ 165#define MLDV2_EXP(thresh, nbmant, nbexp, value) \
166 ((value) < (thresh) ? (value) : \ 166 ((value) < (thresh) ? (value) : \
167 ((MLDV2_MASK(value, nbmant) | (1<<(nbmant+nbexp))) << \ 167 ((MLDV2_MASK(value, nbmant) | (1<<(nbmant))) << \
168 (MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp)))) 168 (MLDV2_MASK((value) >> (nbmant), nbexp) + (nbexp))))
169 169
170#define MLDV2_QQIC(value) MLDV2_EXP(0x80, 4, 3, value) 170#define MLDV2_QQIC(value) MLDV2_EXP(0x80, 4, 3, value)
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 334a5967831e..50a13e75d70e 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -140,9 +140,7 @@ fold_field(void *mib[], int offt)
140 unsigned long res = 0; 140 unsigned long res = 0;
141 int i; 141 int i;
142 142
143 for (i = 0; i < NR_CPUS; i++) { 143 for_each_cpu(i) {
144 if (!cpu_possible(i))
145 continue;
146 res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt); 144 res += *(((unsigned long *)per_cpu_ptr(mib[0], i)) + offt);
147 res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt); 145 res += *(((unsigned long *)per_cpu_ptr(mib[1], i)) + offt);
148 } 146 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 678c3f2c0d0b..5ca283537bc6 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -740,11 +740,8 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, long t
740 740
741int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol) 741int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol)
742{ 742{
743 struct netlink_sock *nlk;
744 int len = skb->len; 743 int len = skb->len;
745 744
746 nlk = nlk_sk(sk);
747
748 skb_queue_tail(&sk->sk_receive_queue, skb); 745 skb_queue_tail(&sk->sk_receive_queue, skb);
749 sk->sk_data_ready(sk, len); 746 sk->sk_data_ready(sk, len);
750 sock_put(sk); 747 sock_put(sk);
@@ -827,7 +824,7 @@ struct netlink_broadcast_data {
827 int failure; 824 int failure;
828 int congested; 825 int congested;
829 int delivered; 826 int delivered;
830 unsigned int allocation; 827 gfp_t allocation;
831 struct sk_buff *skb, *skb2; 828 struct sk_buff *skb, *skb2;
832}; 829};
833 830
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index e556d92c0bc4..b18fe5043019 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -727,7 +727,7 @@ int rose_rt_ioctl(unsigned int cmd, void __user *arg)
727 } 727 }
728 if (rose_route.mask > 10) /* Mask can't be more than 10 digits */ 728 if (rose_route.mask > 10) /* Mask can't be more than 10 digits */
729 return -EINVAL; 729 return -EINVAL;
730 if (rose_route.ndigis > 8) /* No more than 8 digipeats */ 730 if (rose_route.ndigis > AX25_MAX_DIGIS)
731 return -EINVAL; 731 return -EINVAL;
732 err = rose_add_node(&rose_route, dev); 732 err = rose_add_node(&rose_route, dev);
733 dev_put(dev); 733 dev_put(dev);
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index b74f7772b576..6e4dc28874d7 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -69,9 +69,7 @@ fold_field(void *mib[], int nr)
69 unsigned long res = 0; 69 unsigned long res = 0;
70 int i; 70 int i;
71 71
72 for (i = 0; i < NR_CPUS; i++) { 72 for_each_cpu(i) {
73 if (!cpu_possible(i))
74 continue;
75 res += 73 res +=
76 *((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) + 74 *((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) +
77 sizeof (unsigned long) * nr)); 75 sizeof (unsigned long) * nr));
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 10e82ec2ebd3..660c61bdf164 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -554,7 +554,7 @@ struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc,
554 dp.ppid = sinfo->sinfo_ppid; 554 dp.ppid = sinfo->sinfo_ppid;
555 555
556 /* Set the flags for an unordered send. */ 556 /* Set the flags for an unordered send. */
557 if (sinfo->sinfo_flags & MSG_UNORDERED) { 557 if (sinfo->sinfo_flags & SCTP_UNORDERED) {
558 flags |= SCTP_DATA_UNORDERED; 558 flags |= SCTP_DATA_UNORDERED;
559 dp.ssn = 0; 559 dp.ssn = 0;
560 } else 560 } else
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 02e068d3450d..b529af5e6f2a 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1010,6 +1010,19 @@ static int __sctp_connect(struct sock* sk,
1010 err = -EAGAIN; 1010 err = -EAGAIN;
1011 goto out_free; 1011 goto out_free;
1012 } 1012 }
1013 } else {
1014 /*
1015 * If an unprivileged user inherits a 1-many
1016 * style socket with open associations on a
1017 * privileged port, it MAY be permitted to
1018 * accept new associations, but it SHOULD NOT
1019 * be permitted to open new associations.
1020 */
1021 if (ep->base.bind_addr.port < PROT_SOCK &&
1022 !capable(CAP_NET_BIND_SERVICE)) {
1023 err = -EACCES;
1024 goto out_free;
1025 }
1013 } 1026 }
1014 1027
1015 scope = sctp_scope(&to); 1028 scope = sctp_scope(&to);
@@ -1389,27 +1402,27 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1389 SCTP_DEBUG_PRINTK("msg_len: %zu, sinfo_flags: 0x%x\n", 1402 SCTP_DEBUG_PRINTK("msg_len: %zu, sinfo_flags: 0x%x\n",
1390 msg_len, sinfo_flags); 1403 msg_len, sinfo_flags);
1391 1404
1392 /* MSG_EOF or MSG_ABORT cannot be set on a TCP-style socket. */ 1405 /* SCTP_EOF or SCTP_ABORT cannot be set on a TCP-style socket. */
1393 if (sctp_style(sk, TCP) && (sinfo_flags & (MSG_EOF | MSG_ABORT))) { 1406 if (sctp_style(sk, TCP) && (sinfo_flags & (SCTP_EOF | SCTP_ABORT))) {
1394 err = -EINVAL; 1407 err = -EINVAL;
1395 goto out_nounlock; 1408 goto out_nounlock;
1396 } 1409 }
1397 1410
1398 /* If MSG_EOF is set, no data can be sent. Disallow sending zero 1411 /* If SCTP_EOF is set, no data can be sent. Disallow sending zero
1399 * length messages when MSG_EOF|MSG_ABORT is not set. 1412 * length messages when SCTP_EOF|SCTP_ABORT is not set.
1400 * If MSG_ABORT is set, the message length could be non zero with 1413 * If SCTP_ABORT is set, the message length could be non zero with
1401 * the msg_iov set to the user abort reason. 1414 * the msg_iov set to the user abort reason.
1402 */ 1415 */
1403 if (((sinfo_flags & MSG_EOF) && (msg_len > 0)) || 1416 if (((sinfo_flags & SCTP_EOF) && (msg_len > 0)) ||
1404 (!(sinfo_flags & (MSG_EOF|MSG_ABORT)) && (msg_len == 0))) { 1417 (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len == 0))) {
1405 err = -EINVAL; 1418 err = -EINVAL;
1406 goto out_nounlock; 1419 goto out_nounlock;
1407 } 1420 }
1408 1421
1409 /* If MSG_ADDR_OVER is set, there must be an address 1422 /* If SCTP_ADDR_OVER is set, there must be an address
1410 * specified in msg_name. 1423 * specified in msg_name.
1411 */ 1424 */
1412 if ((sinfo_flags & MSG_ADDR_OVER) && (!msg->msg_name)) { 1425 if ((sinfo_flags & SCTP_ADDR_OVER) && (!msg->msg_name)) {
1413 err = -EINVAL; 1426 err = -EINVAL;
1414 goto out_nounlock; 1427 goto out_nounlock;
1415 } 1428 }
@@ -1458,14 +1471,14 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1458 goto out_unlock; 1471 goto out_unlock;
1459 } 1472 }
1460 1473
1461 if (sinfo_flags & MSG_EOF) { 1474 if (sinfo_flags & SCTP_EOF) {
1462 SCTP_DEBUG_PRINTK("Shutting down association: %p\n", 1475 SCTP_DEBUG_PRINTK("Shutting down association: %p\n",
1463 asoc); 1476 asoc);
1464 sctp_primitive_SHUTDOWN(asoc, NULL); 1477 sctp_primitive_SHUTDOWN(asoc, NULL);
1465 err = 0; 1478 err = 0;
1466 goto out_unlock; 1479 goto out_unlock;
1467 } 1480 }
1468 if (sinfo_flags & MSG_ABORT) { 1481 if (sinfo_flags & SCTP_ABORT) {
1469 SCTP_DEBUG_PRINTK("Aborting association: %p\n", asoc); 1482 SCTP_DEBUG_PRINTK("Aborting association: %p\n", asoc);
1470 sctp_primitive_ABORT(asoc, msg); 1483 sctp_primitive_ABORT(asoc, msg);
1471 err = 0; 1484 err = 0;
@@ -1477,7 +1490,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1477 if (!asoc) { 1490 if (!asoc) {
1478 SCTP_DEBUG_PRINTK("There is no association yet.\n"); 1491 SCTP_DEBUG_PRINTK("There is no association yet.\n");
1479 1492
1480 if (sinfo_flags & (MSG_EOF | MSG_ABORT)) { 1493 if (sinfo_flags & (SCTP_EOF | SCTP_ABORT)) {
1481 err = -EINVAL; 1494 err = -EINVAL;
1482 goto out_unlock; 1495 goto out_unlock;
1483 } 1496 }
@@ -1515,6 +1528,19 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1515 err = -EAGAIN; 1528 err = -EAGAIN;
1516 goto out_unlock; 1529 goto out_unlock;
1517 } 1530 }
1531 } else {
1532 /*
1533 * If an unprivileged user inherits a one-to-many
1534 * style socket with open associations on a privileged
1535 * port, it MAY be permitted to accept new associations,
1536 * but it SHOULD NOT be permitted to open new
1537 * associations.
1538 */
1539 if (ep->base.bind_addr.port < PROT_SOCK &&
1540 !capable(CAP_NET_BIND_SERVICE)) {
1541 err = -EACCES;
1542 goto out_unlock;
1543 }
1518 } 1544 }
1519 1545
1520 scope = sctp_scope(&to); 1546 scope = sctp_scope(&to);
@@ -1611,10 +1637,10 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1611 1637
1612 /* If an address is passed with the sendto/sendmsg call, it is used 1638 /* If an address is passed with the sendto/sendmsg call, it is used
1613 * to override the primary destination address in the TCP model, or 1639 * to override the primary destination address in the TCP model, or
1614 * when MSG_ADDR_OVER flag is set in the UDP model. 1640 * when SCTP_ADDR_OVER flag is set in the UDP model.
1615 */ 1641 */
1616 if ((sctp_style(sk, TCP) && msg_name) || 1642 if ((sctp_style(sk, TCP) && msg_name) ||
1617 (sinfo_flags & MSG_ADDR_OVER)) { 1643 (sinfo_flags & SCTP_ADDR_OVER)) {
1618 chunk_tp = sctp_assoc_lookup_paddr(asoc, &to); 1644 chunk_tp = sctp_assoc_lookup_paddr(asoc, &to);
1619 if (!chunk_tp) { 1645 if (!chunk_tp) {
1620 err = -EINVAL; 1646 err = -EINVAL;
@@ -2306,16 +2332,14 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optl
2306 return -EINVAL; 2332 return -EINVAL;
2307 if (get_user(val, (int __user *)optval)) 2333 if (get_user(val, (int __user *)optval))
2308 return -EFAULT; 2334 return -EFAULT;
2309 if ((val < 8) || (val > SCTP_MAX_CHUNK_LEN)) 2335 if ((val != 0) && ((val < 8) || (val > SCTP_MAX_CHUNK_LEN)))
2310 return -EINVAL; 2336 return -EINVAL;
2311 sp->user_frag = val; 2337 sp->user_frag = val;
2312 2338
2313 if (val) { 2339 /* Update the frag_point of the existing associations. */
2314 /* Update the frag_point of the existing associations. */ 2340 list_for_each(pos, &(sp->ep->asocs)) {
2315 list_for_each(pos, &(sp->ep->asocs)) { 2341 asoc = list_entry(pos, struct sctp_association, asocs);
2316 asoc = list_entry(pos, struct sctp_association, asocs); 2342 asoc->frag_point = sctp_frag_point(sp, asoc->pmtu);
2317 asoc->frag_point = sctp_frag_point(sp, asoc->pmtu);
2318 }
2319 } 2343 }
2320 2344
2321 return 0; 2345 return 0;
@@ -2384,14 +2408,14 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
2384static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval, 2408static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval,
2385 int optlen) 2409 int optlen)
2386{ 2410{
2387 __u32 val; 2411 struct sctp_setadaption adaption;
2388 2412
2389 if (optlen < sizeof(__u32)) 2413 if (optlen != sizeof(struct sctp_setadaption))
2390 return -EINVAL; 2414 return -EINVAL;
2391 if (copy_from_user(&val, optval, sizeof(__u32))) 2415 if (copy_from_user(&adaption, optval, optlen))
2392 return -EFAULT; 2416 return -EFAULT;
2393 2417
2394 sctp_sk(sk)->adaption_ind = val; 2418 sctp_sk(sk)->adaption_ind = adaption.ssb_adaption_ind;
2395 2419
2396 return 0; 2420 return 0;
2397} 2421}
@@ -3672,17 +3696,15 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len,
3672static int sctp_getsockopt_adaption_layer(struct sock *sk, int len, 3696static int sctp_getsockopt_adaption_layer(struct sock *sk, int len,
3673 char __user *optval, int __user *optlen) 3697 char __user *optval, int __user *optlen)
3674{ 3698{
3675 __u32 val; 3699 struct sctp_setadaption adaption;
3676 3700
3677 if (len < sizeof(__u32)) 3701 if (len != sizeof(struct sctp_setadaption))
3678 return -EINVAL; 3702 return -EINVAL;
3679 3703
3680 len = sizeof(__u32); 3704 adaption.ssb_adaption_ind = sctp_sk(sk)->adaption_ind;
3681 val = sctp_sk(sk)->adaption_ind; 3705 if (copy_to_user(optval, &adaption, len))
3682 if (put_user(len, optlen))
3683 return -EFAULT;
3684 if (copy_to_user(optval, &val, len))
3685 return -EFAULT; 3706 return -EFAULT;
3707
3686 return 0; 3708 return 0;
3687} 3709}
3688 3710
@@ -4640,8 +4662,8 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg,
4640 4662
4641 /* Minimally, validate the sinfo_flags. */ 4663 /* Minimally, validate the sinfo_flags. */
4642 if (cmsgs->info->sinfo_flags & 4664 if (cmsgs->info->sinfo_flags &
4643 ~(MSG_UNORDERED | MSG_ADDR_OVER | 4665 ~(SCTP_UNORDERED | SCTP_ADDR_OVER |
4644 MSG_ABORT | MSG_EOF)) 4666 SCTP_ABORT | SCTP_EOF))
4645 return -EINVAL; 4667 return -EINVAL;
4646 break; 4668 break;
4647 4669
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 057e7fac3af0..e049f41faa47 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -698,7 +698,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
698 event->ssn = ntohs(chunk->subh.data_hdr->ssn); 698 event->ssn = ntohs(chunk->subh.data_hdr->ssn);
699 event->ppid = chunk->subh.data_hdr->ppid; 699 event->ppid = chunk->subh.data_hdr->ppid;
700 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { 700 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) {
701 event->flags |= MSG_UNORDERED; 701 event->flags |= SCTP_UNORDERED;
702 event->cumtsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map); 702 event->cumtsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
703 } 703 }
704 event->tsn = ntohl(chunk->subh.data_hdr->tsn); 704 event->tsn = ntohl(chunk->subh.data_hdr->tsn);
@@ -824,7 +824,7 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
824 * 824 *
825 * recvmsg() flags: 825 * recvmsg() flags:
826 * 826 *
827 * MSG_UNORDERED - This flag is present when the message was sent 827 * SCTP_UNORDERED - This flag is present when the message was sent
828 * non-ordered. 828 * non-ordered.
829 */ 829 */
830 sinfo.sinfo_flags = event->flags; 830 sinfo.sinfo_flags = event->flags;
@@ -839,7 +839,7 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
839 * This field will hold the current cumulative TSN as 839 * This field will hold the current cumulative TSN as
840 * known by the underlying SCTP layer. Note this field is 840 * known by the underlying SCTP layer. Note this field is
841 * ignored when sending and only valid for a receive 841 * ignored when sending and only valid for a receive
842 * operation when sinfo_flags are set to MSG_UNORDERED. 842 * operation when sinfo_flags are set to SCTP_UNORDERED.
843 */ 843 */
844 sinfo.sinfo_cumtsn = event->cumtsn; 844 sinfo.sinfo_cumtsn = event->cumtsn;
845 /* sinfo_assoc_id: sizeof (sctp_assoc_t) 845 /* sinfo_assoc_id: sizeof (sctp_assoc_t)
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile
index 46a2ce00a29b..cdcab9ca4c60 100644
--- a/net/sunrpc/Makefile
+++ b/net/sunrpc/Makefile
@@ -6,7 +6,7 @@
6obj-$(CONFIG_SUNRPC) += sunrpc.o 6obj-$(CONFIG_SUNRPC) += sunrpc.o
7obj-$(CONFIG_SUNRPC_GSS) += auth_gss/ 7obj-$(CONFIG_SUNRPC_GSS) += auth_gss/
8 8
9sunrpc-y := clnt.o xprt.o sched.o \ 9sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \
10 auth.o auth_null.o auth_unix.o \ 10 auth.o auth_null.o auth_unix.o \
11 svc.o svcsock.o svcauth.o svcauth_unix.o \ 11 svc.o svcsock.o svcauth.o svcauth_unix.o \
12 pmap_clnt.o timer.o xdr.o \ 12 pmap_clnt.o timer.o xdr.o \
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 505e2d4b3d62..a415d99c394d 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -11,7 +11,6 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/socket.h>
15#include <linux/sunrpc/clnt.h> 14#include <linux/sunrpc/clnt.h>
16#include <linux/spinlock.h> 15#include <linux/spinlock.h>
17 16
diff --git a/net/sunrpc/auth_gss/Makefile b/net/sunrpc/auth_gss/Makefile
index fe1b874084bc..f3431a7e33da 100644
--- a/net/sunrpc/auth_gss/Makefile
+++ b/net/sunrpc/auth_gss/Makefile
@@ -10,7 +10,7 @@ auth_rpcgss-objs := auth_gss.o gss_generic_token.o \
10obj-$(CONFIG_RPCSEC_GSS_KRB5) += rpcsec_gss_krb5.o 10obj-$(CONFIG_RPCSEC_GSS_KRB5) += rpcsec_gss_krb5.o
11 11
12rpcsec_gss_krb5-objs := gss_krb5_mech.o gss_krb5_seal.o gss_krb5_unseal.o \ 12rpcsec_gss_krb5-objs := gss_krb5_mech.o gss_krb5_seal.o gss_krb5_unseal.o \
13 gss_krb5_seqnum.o 13 gss_krb5_seqnum.o gss_krb5_wrap.o
14 14
15obj-$(CONFIG_RPCSEC_GSS_SPKM3) += rpcsec_gss_spkm3.o 15obj-$(CONFIG_RPCSEC_GSS_SPKM3) += rpcsec_gss_spkm3.o
16 16
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 2f7b867161d2..f44f46f1d8e0 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -42,9 +42,8 @@
42#include <linux/init.h> 42#include <linux/init.h>
43#include <linux/types.h> 43#include <linux/types.h>
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/socket.h>
46#include <linux/in.h>
47#include <linux/sched.h> 45#include <linux/sched.h>
46#include <linux/pagemap.h>
48#include <linux/sunrpc/clnt.h> 47#include <linux/sunrpc/clnt.h>
49#include <linux/sunrpc/auth.h> 48#include <linux/sunrpc/auth.h>
50#include <linux/sunrpc/auth_gss.h> 49#include <linux/sunrpc/auth_gss.h>
@@ -846,10 +845,8 @@ gss_marshal(struct rpc_task *task, u32 *p)
846 845
847 /* We compute the checksum for the verifier over the xdr-encoded bytes 846 /* We compute the checksum for the verifier over the xdr-encoded bytes
848 * starting with the xid and ending at the end of the credential: */ 847 * starting with the xid and ending at the end of the credential: */
849 iov.iov_base = req->rq_snd_buf.head[0].iov_base; 848 iov.iov_base = xprt_skip_transport_header(task->tk_xprt,
850 if (task->tk_client->cl_xprt->stream) 849 req->rq_snd_buf.head[0].iov_base);
851 /* See clnt.c:call_header() */
852 iov.iov_base += 4;
853 iov.iov_len = (u8 *)p - (u8 *)iov.iov_base; 850 iov.iov_len = (u8 *)p - (u8 *)iov.iov_base;
854 xdr_buf_from_iov(&iov, &verf_buf); 851 xdr_buf_from_iov(&iov, &verf_buf);
855 852
@@ -857,9 +854,7 @@ gss_marshal(struct rpc_task *task, u32 *p)
857 *p++ = htonl(RPC_AUTH_GSS); 854 *p++ = htonl(RPC_AUTH_GSS);
858 855
859 mic.data = (u8 *)(p + 1); 856 mic.data = (u8 *)(p + 1);
860 maj_stat = gss_get_mic(ctx->gc_gss_ctx, 857 maj_stat = gss_get_mic(ctx->gc_gss_ctx, &verf_buf, &mic);
861 GSS_C_QOP_DEFAULT,
862 &verf_buf, &mic);
863 if (maj_stat == GSS_S_CONTEXT_EXPIRED) { 858 if (maj_stat == GSS_S_CONTEXT_EXPIRED) {
864 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; 859 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
865 } else if (maj_stat != 0) { 860 } else if (maj_stat != 0) {
@@ -890,10 +885,8 @@ static u32 *
890gss_validate(struct rpc_task *task, u32 *p) 885gss_validate(struct rpc_task *task, u32 *p)
891{ 886{
892 struct rpc_cred *cred = task->tk_msg.rpc_cred; 887 struct rpc_cred *cred = task->tk_msg.rpc_cred;
893 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
894 gc_base);
895 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); 888 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
896 u32 seq, qop_state; 889 u32 seq;
897 struct kvec iov; 890 struct kvec iov;
898 struct xdr_buf verf_buf; 891 struct xdr_buf verf_buf;
899 struct xdr_netobj mic; 892 struct xdr_netobj mic;
@@ -914,23 +907,14 @@ gss_validate(struct rpc_task *task, u32 *p)
914 mic.data = (u8 *)p; 907 mic.data = (u8 *)p;
915 mic.len = len; 908 mic.len = len;
916 909
917 maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &verf_buf, &mic, &qop_state); 910 maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &verf_buf, &mic);
918 if (maj_stat == GSS_S_CONTEXT_EXPIRED) 911 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
919 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; 912 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
920 if (maj_stat) 913 if (maj_stat)
921 goto out_bad; 914 goto out_bad;
922 switch (gss_cred->gc_service) { 915 /* We leave it to unwrap to calculate au_rslack. For now we just
923 case RPC_GSS_SVC_NONE: 916 * calculate the length of the verifier: */
924 /* verifier data, flavor, length: */ 917 task->tk_auth->au_verfsize = XDR_QUADLEN(len) + 2;
925 task->tk_auth->au_rslack = XDR_QUADLEN(len) + 2;
926 break;
927 case RPC_GSS_SVC_INTEGRITY:
928 /* verifier data, flavor, length, length, sequence number: */
929 task->tk_auth->au_rslack = XDR_QUADLEN(len) + 4;
930 break;
931 case RPC_GSS_SVC_PRIVACY:
932 goto out_bad;
933 }
934 gss_put_ctx(ctx); 918 gss_put_ctx(ctx);
935 dprintk("RPC: %4u GSS gss_validate: gss_verify_mic succeeded.\n", 919 dprintk("RPC: %4u GSS gss_validate: gss_verify_mic succeeded.\n",
936 task->tk_pid); 920 task->tk_pid);
@@ -975,8 +959,7 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
975 p = iov->iov_base + iov->iov_len; 959 p = iov->iov_base + iov->iov_len;
976 mic.data = (u8 *)(p + 1); 960 mic.data = (u8 *)(p + 1);
977 961
978 maj_stat = gss_get_mic(ctx->gc_gss_ctx, 962 maj_stat = gss_get_mic(ctx->gc_gss_ctx, &integ_buf, &mic);
979 GSS_C_QOP_DEFAULT, &integ_buf, &mic);
980 status = -EIO; /* XXX? */ 963 status = -EIO; /* XXX? */
981 if (maj_stat == GSS_S_CONTEXT_EXPIRED) 964 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
982 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; 965 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
@@ -990,6 +973,113 @@ gss_wrap_req_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
990 return 0; 973 return 0;
991} 974}
992 975
976static void
977priv_release_snd_buf(struct rpc_rqst *rqstp)
978{
979 int i;
980
981 for (i=0; i < rqstp->rq_enc_pages_num; i++)
982 __free_page(rqstp->rq_enc_pages[i]);
983 kfree(rqstp->rq_enc_pages);
984}
985
986static int
987alloc_enc_pages(struct rpc_rqst *rqstp)
988{
989 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
990 int first, last, i;
991
992 if (snd_buf->page_len == 0) {
993 rqstp->rq_enc_pages_num = 0;
994 return 0;
995 }
996
997 first = snd_buf->page_base >> PAGE_CACHE_SHIFT;
998 last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_CACHE_SHIFT;
999 rqstp->rq_enc_pages_num = last - first + 1 + 1;
1000 rqstp->rq_enc_pages
1001 = kmalloc(rqstp->rq_enc_pages_num * sizeof(struct page *),
1002 GFP_NOFS);
1003 if (!rqstp->rq_enc_pages)
1004 goto out;
1005 for (i=0; i < rqstp->rq_enc_pages_num; i++) {
1006 rqstp->rq_enc_pages[i] = alloc_page(GFP_NOFS);
1007 if (rqstp->rq_enc_pages[i] == NULL)
1008 goto out_free;
1009 }
1010 rqstp->rq_release_snd_buf = priv_release_snd_buf;
1011 return 0;
1012out_free:
1013 for (i--; i >= 0; i--) {
1014 __free_page(rqstp->rq_enc_pages[i]);
1015 }
1016out:
1017 return -EAGAIN;
1018}
1019
1020static inline int
1021gss_wrap_req_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1022 kxdrproc_t encode, struct rpc_rqst *rqstp, u32 *p, void *obj)
1023{
1024 struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
1025 u32 offset;
1026 u32 maj_stat;
1027 int status;
1028 u32 *opaque_len;
1029 struct page **inpages;
1030 int first;
1031 int pad;
1032 struct kvec *iov;
1033 char *tmp;
1034
1035 opaque_len = p++;
1036 offset = (u8 *)p - (u8 *)snd_buf->head[0].iov_base;
1037 *p++ = htonl(rqstp->rq_seqno);
1038
1039 status = encode(rqstp, p, obj);
1040 if (status)
1041 return status;
1042
1043 status = alloc_enc_pages(rqstp);
1044 if (status)
1045 return status;
1046 first = snd_buf->page_base >> PAGE_CACHE_SHIFT;
1047 inpages = snd_buf->pages + first;
1048 snd_buf->pages = rqstp->rq_enc_pages;
1049 snd_buf->page_base -= first << PAGE_CACHE_SHIFT;
1050 /* Give the tail its own page, in case we need extra space in the
1051 * head when wrapping: */
1052 if (snd_buf->page_len || snd_buf->tail[0].iov_len) {
1053 tmp = page_address(rqstp->rq_enc_pages[rqstp->rq_enc_pages_num - 1]);
1054 memcpy(tmp, snd_buf->tail[0].iov_base, snd_buf->tail[0].iov_len);
1055 snd_buf->tail[0].iov_base = tmp;
1056 }
1057 maj_stat = gss_wrap(ctx->gc_gss_ctx, offset, snd_buf, inpages);
1058 /* RPC_SLACK_SPACE should prevent this ever happening: */
1059 BUG_ON(snd_buf->len > snd_buf->buflen);
1060 status = -EIO;
1061 /* We're assuming that when GSS_S_CONTEXT_EXPIRED, the encryption was
1062 * done anyway, so it's safe to put the request on the wire: */
1063 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
1064 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
1065 else if (maj_stat)
1066 return status;
1067
1068 *opaque_len = htonl(snd_buf->len - offset);
1069 /* guess whether we're in the head or the tail: */
1070 if (snd_buf->page_len || snd_buf->tail[0].iov_len)
1071 iov = snd_buf->tail;
1072 else
1073 iov = snd_buf->head;
1074 p = iov->iov_base + iov->iov_len;
1075 pad = 3 - ((snd_buf->len - offset - 1) & 3);
1076 memset(p, 0, pad);
1077 iov->iov_len += pad;
1078 snd_buf->len += pad;
1079
1080 return 0;
1081}
1082
993static int 1083static int
994gss_wrap_req(struct rpc_task *task, 1084gss_wrap_req(struct rpc_task *task,
995 kxdrproc_t encode, void *rqstp, u32 *p, void *obj) 1085 kxdrproc_t encode, void *rqstp, u32 *p, void *obj)
@@ -1017,6 +1107,8 @@ gss_wrap_req(struct rpc_task *task,
1017 rqstp, p, obj); 1107 rqstp, p, obj);
1018 break; 1108 break;
1019 case RPC_GSS_SVC_PRIVACY: 1109 case RPC_GSS_SVC_PRIVACY:
1110 status = gss_wrap_req_priv(cred, ctx, encode,
1111 rqstp, p, obj);
1020 break; 1112 break;
1021 } 1113 }
1022out: 1114out:
@@ -1054,8 +1146,7 @@ gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1054 if (xdr_buf_read_netobj(rcv_buf, &mic, mic_offset)) 1146 if (xdr_buf_read_netobj(rcv_buf, &mic, mic_offset))
1055 return status; 1147 return status;
1056 1148
1057 maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &integ_buf, 1149 maj_stat = gss_verify_mic(ctx->gc_gss_ctx, &integ_buf, &mic);
1058 &mic, NULL);
1059 if (maj_stat == GSS_S_CONTEXT_EXPIRED) 1150 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
1060 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; 1151 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
1061 if (maj_stat != GSS_S_COMPLETE) 1152 if (maj_stat != GSS_S_COMPLETE)
@@ -1063,6 +1154,35 @@ gss_unwrap_resp_integ(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1063 return 0; 1154 return 0;
1064} 1155}
1065 1156
1157static inline int
1158gss_unwrap_resp_priv(struct rpc_cred *cred, struct gss_cl_ctx *ctx,
1159 struct rpc_rqst *rqstp, u32 **p)
1160{
1161 struct xdr_buf *rcv_buf = &rqstp->rq_rcv_buf;
1162 u32 offset;
1163 u32 opaque_len;
1164 u32 maj_stat;
1165 int status = -EIO;
1166
1167 opaque_len = ntohl(*(*p)++);
1168 offset = (u8 *)(*p) - (u8 *)rcv_buf->head[0].iov_base;
1169 if (offset + opaque_len > rcv_buf->len)
1170 return status;
1171 /* remove padding: */
1172 rcv_buf->len = offset + opaque_len;
1173
1174 maj_stat = gss_unwrap(ctx->gc_gss_ctx, offset, rcv_buf);
1175 if (maj_stat == GSS_S_CONTEXT_EXPIRED)
1176 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
1177 if (maj_stat != GSS_S_COMPLETE)
1178 return status;
1179 if (ntohl(*(*p)++) != rqstp->rq_seqno)
1180 return status;
1181
1182 return 0;
1183}
1184
1185
1066static int 1186static int
1067gss_unwrap_resp(struct rpc_task *task, 1187gss_unwrap_resp(struct rpc_task *task,
1068 kxdrproc_t decode, void *rqstp, u32 *p, void *obj) 1188 kxdrproc_t decode, void *rqstp, u32 *p, void *obj)
@@ -1071,6 +1191,9 @@ gss_unwrap_resp(struct rpc_task *task,
1071 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, 1191 struct gss_cred *gss_cred = container_of(cred, struct gss_cred,
1072 gc_base); 1192 gc_base);
1073 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred); 1193 struct gss_cl_ctx *ctx = gss_cred_get_ctx(cred);
1194 u32 *savedp = p;
1195 struct kvec *head = ((struct rpc_rqst *)rqstp)->rq_rcv_buf.head;
1196 int savedlen = head->iov_len;
1074 int status = -EIO; 1197 int status = -EIO;
1075 1198
1076 if (ctx->gc_proc != RPC_GSS_PROC_DATA) 1199 if (ctx->gc_proc != RPC_GSS_PROC_DATA)
@@ -1084,8 +1207,14 @@ gss_unwrap_resp(struct rpc_task *task,
1084 goto out; 1207 goto out;
1085 break; 1208 break;
1086 case RPC_GSS_SVC_PRIVACY: 1209 case RPC_GSS_SVC_PRIVACY:
1210 status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p);
1211 if (status)
1212 goto out;
1087 break; 1213 break;
1088 } 1214 }
1215 /* take into account extra slack for integrity and privacy cases: */
1216 task->tk_auth->au_rslack = task->tk_auth->au_verfsize + (p - savedp)
1217 + (savedlen - head->iov_len);
1089out_decode: 1218out_decode:
1090 status = decode(rqstp, p, obj); 1219 status = decode(rqstp, p, obj);
1091out: 1220out:
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index ee6ae74cd1b2..3f3d5437f02d 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -139,17 +139,91 @@ buf_to_sg(struct scatterlist *sg, char *ptr, int len) {
139 sg->length = len; 139 sg->length = len;
140} 140}
141 141
142static int
143process_xdr_buf(struct xdr_buf *buf, int offset, int len,
144 int (*actor)(struct scatterlist *, void *), void *data)
145{
146 int i, page_len, thislen, page_offset, ret = 0;
147 struct scatterlist sg[1];
148
149 if (offset >= buf->head[0].iov_len) {
150 offset -= buf->head[0].iov_len;
151 } else {
152 thislen = buf->head[0].iov_len - offset;
153 if (thislen > len)
154 thislen = len;
155 buf_to_sg(sg, buf->head[0].iov_base + offset, thislen);
156 ret = actor(sg, data);
157 if (ret)
158 goto out;
159 offset = 0;
160 len -= thislen;
161 }
162 if (len == 0)
163 goto out;
164
165 if (offset >= buf->page_len) {
166 offset -= buf->page_len;
167 } else {
168 page_len = buf->page_len - offset;
169 if (page_len > len)
170 page_len = len;
171 len -= page_len;
172 page_offset = (offset + buf->page_base) & (PAGE_CACHE_SIZE - 1);
173 i = (offset + buf->page_base) >> PAGE_CACHE_SHIFT;
174 thislen = PAGE_CACHE_SIZE - page_offset;
175 do {
176 if (thislen > page_len)
177 thislen = page_len;
178 sg->page = buf->pages[i];
179 sg->offset = page_offset;
180 sg->length = thislen;
181 ret = actor(sg, data);
182 if (ret)
183 goto out;
184 page_len -= thislen;
185 i++;
186 page_offset = 0;
187 thislen = PAGE_CACHE_SIZE;
188 } while (page_len != 0);
189 offset = 0;
190 }
191 if (len == 0)
192 goto out;
193
194 if (offset < buf->tail[0].iov_len) {
195 thislen = buf->tail[0].iov_len - offset;
196 if (thislen > len)
197 thislen = len;
198 buf_to_sg(sg, buf->tail[0].iov_base + offset, thislen);
199 ret = actor(sg, data);
200 len -= thislen;
201 }
202 if (len != 0)
203 ret = -EINVAL;
204out:
205 return ret;
206}
207
208static int
209checksummer(struct scatterlist *sg, void *data)
210{
211 struct crypto_tfm *tfm = (struct crypto_tfm *)data;
212
213 crypto_digest_update(tfm, sg, 1);
214
215 return 0;
216}
217
142/* checksum the plaintext data and hdrlen bytes of the token header */ 218/* checksum the plaintext data and hdrlen bytes of the token header */
143s32 219s32
144make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body, 220make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
145 struct xdr_netobj *cksum) 221 int body_offset, struct xdr_netobj *cksum)
146{ 222{
147 char *cksumname; 223 char *cksumname;
148 struct crypto_tfm *tfm = NULL; /* XXX add to ctx? */ 224 struct crypto_tfm *tfm = NULL; /* XXX add to ctx? */
149 struct scatterlist sg[1]; 225 struct scatterlist sg[1];
150 u32 code = GSS_S_FAILURE; 226 u32 code = GSS_S_FAILURE;
151 int len, thislen, offset;
152 int i;
153 227
154 switch (cksumtype) { 228 switch (cksumtype) {
155 case CKSUMTYPE_RSA_MD5: 229 case CKSUMTYPE_RSA_MD5:
@@ -169,33 +243,8 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
169 crypto_digest_init(tfm); 243 crypto_digest_init(tfm);
170 buf_to_sg(sg, header, hdrlen); 244 buf_to_sg(sg, header, hdrlen);
171 crypto_digest_update(tfm, sg, 1); 245 crypto_digest_update(tfm, sg, 1);
172 if (body->head[0].iov_len) { 246 process_xdr_buf(body, body_offset, body->len - body_offset,
173 buf_to_sg(sg, body->head[0].iov_base, body->head[0].iov_len); 247 checksummer, tfm);
174 crypto_digest_update(tfm, sg, 1);
175 }
176
177 len = body->page_len;
178 if (len != 0) {
179 offset = body->page_base & (PAGE_CACHE_SIZE - 1);
180 i = body->page_base >> PAGE_CACHE_SHIFT;
181 thislen = PAGE_CACHE_SIZE - offset;
182 do {
183 if (thislen > len)
184 thislen = len;
185 sg->page = body->pages[i];
186 sg->offset = offset;
187 sg->length = thislen;
188 crypto_digest_update(tfm, sg, 1);
189 len -= thislen;
190 i++;
191 offset = 0;
192 thislen = PAGE_CACHE_SIZE;
193 } while(len != 0);
194 }
195 if (body->tail[0].iov_len) {
196 buf_to_sg(sg, body->tail[0].iov_base, body->tail[0].iov_len);
197 crypto_digest_update(tfm, sg, 1);
198 }
199 crypto_digest_final(tfm, cksum->data); 248 crypto_digest_final(tfm, cksum->data);
200 code = 0; 249 code = 0;
201out: 250out:
@@ -204,3 +253,154 @@ out:
204} 253}
205 254
206EXPORT_SYMBOL(make_checksum); 255EXPORT_SYMBOL(make_checksum);
256
257struct encryptor_desc {
258 u8 iv[8]; /* XXX hard-coded blocksize */
259 struct crypto_tfm *tfm;
260 int pos;
261 struct xdr_buf *outbuf;
262 struct page **pages;
263 struct scatterlist infrags[4];
264 struct scatterlist outfrags[4];
265 int fragno;
266 int fraglen;
267};
268
269static int
270encryptor(struct scatterlist *sg, void *data)
271{
272 struct encryptor_desc *desc = data;
273 struct xdr_buf *outbuf = desc->outbuf;
274 struct page *in_page;
275 int thislen = desc->fraglen + sg->length;
276 int fraglen, ret;
277 int page_pos;
278
279 /* Worst case is 4 fragments: head, end of page 1, start
280 * of page 2, tail. Anything more is a bug. */
281 BUG_ON(desc->fragno > 3);
282 desc->infrags[desc->fragno] = *sg;
283 desc->outfrags[desc->fragno] = *sg;
284
285 page_pos = desc->pos - outbuf->head[0].iov_len;
286 if (page_pos >= 0 && page_pos < outbuf->page_len) {
287 /* pages are not in place: */
288 int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT;
289 in_page = desc->pages[i];
290 } else {
291 in_page = sg->page;
292 }
293 desc->infrags[desc->fragno].page = in_page;
294 desc->fragno++;
295 desc->fraglen += sg->length;
296 desc->pos += sg->length;
297
298 fraglen = thislen & 7; /* XXX hardcoded blocksize */
299 thislen -= fraglen;
300
301 if (thislen == 0)
302 return 0;
303
304 ret = crypto_cipher_encrypt_iv(desc->tfm, desc->outfrags, desc->infrags,
305 thislen, desc->iv);
306 if (ret)
307 return ret;
308 if (fraglen) {
309 desc->outfrags[0].page = sg->page;
310 desc->outfrags[0].offset = sg->offset + sg->length - fraglen;
311 desc->outfrags[0].length = fraglen;
312 desc->infrags[0] = desc->outfrags[0];
313 desc->infrags[0].page = in_page;
314 desc->fragno = 1;
315 desc->fraglen = fraglen;
316 } else {
317 desc->fragno = 0;
318 desc->fraglen = 0;
319 }
320 return 0;
321}
322
323int
324gss_encrypt_xdr_buf(struct crypto_tfm *tfm, struct xdr_buf *buf, int offset,
325 struct page **pages)
326{
327 int ret;
328 struct encryptor_desc desc;
329
330 BUG_ON((buf->len - offset) % crypto_tfm_alg_blocksize(tfm) != 0);
331
332 memset(desc.iv, 0, sizeof(desc.iv));
333 desc.tfm = tfm;
334 desc.pos = offset;
335 desc.outbuf = buf;
336 desc.pages = pages;
337 desc.fragno = 0;
338 desc.fraglen = 0;
339
340 ret = process_xdr_buf(buf, offset, buf->len - offset, encryptor, &desc);
341 return ret;
342}
343
344EXPORT_SYMBOL(gss_encrypt_xdr_buf);
345
346struct decryptor_desc {
347 u8 iv[8]; /* XXX hard-coded blocksize */
348 struct crypto_tfm *tfm;
349 struct scatterlist frags[4];
350 int fragno;
351 int fraglen;
352};
353
354static int
355decryptor(struct scatterlist *sg, void *data)
356{
357 struct decryptor_desc *desc = data;
358 int thislen = desc->fraglen + sg->length;
359 int fraglen, ret;
360
361 /* Worst case is 4 fragments: head, end of page 1, start
362 * of page 2, tail. Anything more is a bug. */
363 BUG_ON(desc->fragno > 3);
364 desc->frags[desc->fragno] = *sg;
365 desc->fragno++;
366 desc->fraglen += sg->length;
367
368 fraglen = thislen & 7; /* XXX hardcoded blocksize */
369 thislen -= fraglen;
370
371 if (thislen == 0)
372 return 0;
373
374 ret = crypto_cipher_decrypt_iv(desc->tfm, desc->frags, desc->frags,
375 thislen, desc->iv);
376 if (ret)
377 return ret;
378 if (fraglen) {
379 desc->frags[0].page = sg->page;
380 desc->frags[0].offset = sg->offset + sg->length - fraglen;
381 desc->frags[0].length = fraglen;
382 desc->fragno = 1;
383 desc->fraglen = fraglen;
384 } else {
385 desc->fragno = 0;
386 desc->fraglen = 0;
387 }
388 return 0;
389}
390
391int
392gss_decrypt_xdr_buf(struct crypto_tfm *tfm, struct xdr_buf *buf, int offset)
393{
394 struct decryptor_desc desc;
395
396 /* XXXJBF: */
397 BUG_ON((buf->len - offset) % crypto_tfm_alg_blocksize(tfm) != 0);
398
399 memset(desc.iv, 0, sizeof(desc.iv));
400 desc.tfm = tfm;
401 desc.fragno = 0;
402 desc.fraglen = 0;
403 return process_xdr_buf(buf, offset, buf->len - offset, decryptor, &desc);
404}
405
406EXPORT_SYMBOL(gss_decrypt_xdr_buf);
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 606a8a82cafb..5f1f806a0b11 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -39,7 +39,6 @@
39#include <linux/types.h> 39#include <linux/types.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/sunrpc/auth.h> 41#include <linux/sunrpc/auth.h>
42#include <linux/in.h>
43#include <linux/sunrpc/gss_krb5.h> 42#include <linux/sunrpc/gss_krb5.h>
44#include <linux/sunrpc/xdr.h> 43#include <linux/sunrpc/xdr.h>
45#include <linux/crypto.h> 44#include <linux/crypto.h>
@@ -191,43 +190,12 @@ gss_delete_sec_context_kerberos(void *internal_ctx) {
191 kfree(kctx); 190 kfree(kctx);
192} 191}
193 192
194static u32
195gss_verify_mic_kerberos(struct gss_ctx *ctx,
196 struct xdr_buf *message,
197 struct xdr_netobj *mic_token,
198 u32 *qstate) {
199 u32 maj_stat = 0;
200 int qop_state;
201 struct krb5_ctx *kctx = ctx->internal_ctx_id;
202
203 maj_stat = krb5_read_token(kctx, mic_token, message, &qop_state,
204 KG_TOK_MIC_MSG);
205 if (!maj_stat && qop_state)
206 *qstate = qop_state;
207
208 dprintk("RPC: gss_verify_mic_kerberos returning %d\n", maj_stat);
209 return maj_stat;
210}
211
212static u32
213gss_get_mic_kerberos(struct gss_ctx *ctx,
214 u32 qop,
215 struct xdr_buf *message,
216 struct xdr_netobj *mic_token) {
217 u32 err = 0;
218 struct krb5_ctx *kctx = ctx->internal_ctx_id;
219
220 err = krb5_make_token(kctx, qop, message, mic_token, KG_TOK_MIC_MSG);
221
222 dprintk("RPC: gss_get_mic_kerberos returning %d\n",err);
223
224 return err;
225}
226
227static struct gss_api_ops gss_kerberos_ops = { 193static struct gss_api_ops gss_kerberos_ops = {
228 .gss_import_sec_context = gss_import_sec_context_kerberos, 194 .gss_import_sec_context = gss_import_sec_context_kerberos,
229 .gss_get_mic = gss_get_mic_kerberos, 195 .gss_get_mic = gss_get_mic_kerberos,
230 .gss_verify_mic = gss_verify_mic_kerberos, 196 .gss_verify_mic = gss_verify_mic_kerberos,
197 .gss_wrap = gss_wrap_kerberos,
198 .gss_unwrap = gss_unwrap_kerberos,
231 .gss_delete_sec_context = gss_delete_sec_context_kerberos, 199 .gss_delete_sec_context = gss_delete_sec_context_kerberos,
232}; 200};
233 201
@@ -242,6 +210,11 @@ static struct pf_desc gss_kerberos_pfs[] = {
242 .service = RPC_GSS_SVC_INTEGRITY, 210 .service = RPC_GSS_SVC_INTEGRITY,
243 .name = "krb5i", 211 .name = "krb5i",
244 }, 212 },
213 [2] = {
214 .pseudoflavor = RPC_AUTH_GSS_KRB5P,
215 .service = RPC_GSS_SVC_PRIVACY,
216 .name = "krb5p",
217 },
245}; 218};
246 219
247static struct gss_api_mech gss_kerberos_mech = { 220static struct gss_api_mech gss_kerberos_mech = {
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index afeeb8715a77..13f8ae979454 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -70,22 +70,13 @@
70# define RPCDBG_FACILITY RPCDBG_AUTH 70# define RPCDBG_FACILITY RPCDBG_AUTH
71#endif 71#endif
72 72
73static inline int
74gss_krb5_padding(int blocksize, int length) {
75 /* Most of the code is block-size independent but in practice we
76 * use only 8: */
77 BUG_ON(blocksize != 8);
78 return 8 - (length & 7);
79}
80
81u32 73u32
82krb5_make_token(struct krb5_ctx *ctx, int qop_req, 74gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
83 struct xdr_buf *text, struct xdr_netobj *token, 75 struct xdr_netobj *token)
84 int toktype)
85{ 76{
77 struct krb5_ctx *ctx = gss_ctx->internal_ctx_id;
86 s32 checksum_type; 78 s32 checksum_type;
87 struct xdr_netobj md5cksum = {.len = 0, .data = NULL}; 79 struct xdr_netobj md5cksum = {.len = 0, .data = NULL};
88 int blocksize = 0, tmsglen;
89 unsigned char *ptr, *krb5_hdr, *msg_start; 80 unsigned char *ptr, *krb5_hdr, *msg_start;
90 s32 now; 81 s32 now;
91 82
@@ -93,9 +84,6 @@ krb5_make_token(struct krb5_ctx *ctx, int qop_req,
93 84
94 now = get_seconds(); 85 now = get_seconds();
95 86
96 if (qop_req != 0)
97 goto out_err;
98
99 switch (ctx->signalg) { 87 switch (ctx->signalg) {
100 case SGN_ALG_DES_MAC_MD5: 88 case SGN_ALG_DES_MAC_MD5:
101 checksum_type = CKSUMTYPE_RSA_MD5; 89 checksum_type = CKSUMTYPE_RSA_MD5;
@@ -111,21 +99,13 @@ krb5_make_token(struct krb5_ctx *ctx, int qop_req,
111 goto out_err; 99 goto out_err;
112 } 100 }
113 101
114 if (toktype == KG_TOK_WRAP_MSG) { 102 token->len = g_token_size(&ctx->mech_used, 22);
115 blocksize = crypto_tfm_alg_blocksize(ctx->enc);
116 tmsglen = blocksize + text->len
117 + gss_krb5_padding(blocksize, blocksize + text->len);
118 } else {
119 tmsglen = 0;
120 }
121
122 token->len = g_token_size(&ctx->mech_used, 22 + tmsglen);
123 103
124 ptr = token->data; 104 ptr = token->data;
125 g_make_token_header(&ctx->mech_used, 22 + tmsglen, &ptr); 105 g_make_token_header(&ctx->mech_used, 22, &ptr);
126 106
127 *ptr++ = (unsigned char) ((toktype>>8)&0xff); 107 *ptr++ = (unsigned char) ((KG_TOK_MIC_MSG>>8)&0xff);
128 *ptr++ = (unsigned char) (toktype&0xff); 108 *ptr++ = (unsigned char) (KG_TOK_MIC_MSG&0xff);
129 109
130 /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */ 110 /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */
131 krb5_hdr = ptr - 2; 111 krb5_hdr = ptr - 2;
@@ -133,17 +113,9 @@ krb5_make_token(struct krb5_ctx *ctx, int qop_req,
133 113
134 *(u16 *)(krb5_hdr + 2) = htons(ctx->signalg); 114 *(u16 *)(krb5_hdr + 2) = htons(ctx->signalg);
135 memset(krb5_hdr + 4, 0xff, 4); 115 memset(krb5_hdr + 4, 0xff, 4);
136 if (toktype == KG_TOK_WRAP_MSG)
137 *(u16 *)(krb5_hdr + 4) = htons(ctx->sealalg);
138 116
139 if (toktype == KG_TOK_WRAP_MSG) { 117 if (make_checksum(checksum_type, krb5_hdr, 8, text, 0, &md5cksum))
140 /* XXX removing support for now */
141 goto out_err;
142 } else { /* Sign only. */
143 if (make_checksum(checksum_type, krb5_hdr, 8, text,
144 &md5cksum))
145 goto out_err; 118 goto out_err;
146 }
147 119
148 switch (ctx->signalg) { 120 switch (ctx->signalg) {
149 case SGN_ALG_DES_MAC_MD5: 121 case SGN_ALG_DES_MAC_MD5:
diff --git a/net/sunrpc/auth_gss/gss_krb5_unseal.c b/net/sunrpc/auth_gss/gss_krb5_unseal.c
index 8767fc53183d..2030475d98ed 100644
--- a/net/sunrpc/auth_gss/gss_krb5_unseal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_unseal.c
@@ -68,21 +68,14 @@
68#endif 68#endif
69 69
70 70
71/* message_buffer is an input if toktype is MIC and an output if it is WRAP: 71/* read_token is a mic token, and message_buffer is the data that the mic was
72 * If toktype is MIC: read_token is a mic token, and message_buffer is the 72 * supposedly taken over. */
73 * data that the mic was supposedly taken over.
74 * If toktype is WRAP: read_token is a wrap token, and message_buffer is used
75 * to return the decrypted data.
76 */
77 73
78/* XXX will need to change prototype and/or just split into a separate function
79 * when we add privacy (because read_token will be in pages too). */
80u32 74u32
81krb5_read_token(struct krb5_ctx *ctx, 75gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,
82 struct xdr_netobj *read_token, 76 struct xdr_buf *message_buffer, struct xdr_netobj *read_token)
83 struct xdr_buf *message_buffer,
84 int *qop_state, int toktype)
85{ 77{
78 struct krb5_ctx *ctx = gss_ctx->internal_ctx_id;
86 int signalg; 79 int signalg;
87 int sealalg; 80 int sealalg;
88 s32 checksum_type; 81 s32 checksum_type;
@@ -100,16 +93,12 @@ krb5_read_token(struct krb5_ctx *ctx,
100 read_token->len)) 93 read_token->len))
101 goto out; 94 goto out;
102 95
103 if ((*ptr++ != ((toktype>>8)&0xff)) || (*ptr++ != (toktype&0xff))) 96 if ((*ptr++ != ((KG_TOK_MIC_MSG>>8)&0xff)) ||
97 (*ptr++ != ( KG_TOK_MIC_MSG &0xff)) )
104 goto out; 98 goto out;
105 99
106 /* XXX sanity-check bodysize?? */ 100 /* XXX sanity-check bodysize?? */
107 101
108 if (toktype == KG_TOK_WRAP_MSG) {
109 /* XXX gone */
110 goto out;
111 }
112
113 /* get the sign and seal algorithms */ 102 /* get the sign and seal algorithms */
114 103
115 signalg = ptr[0] + (ptr[1] << 8); 104 signalg = ptr[0] + (ptr[1] << 8);
@@ -120,14 +109,7 @@ krb5_read_token(struct krb5_ctx *ctx,
120 if ((ptr[4] != 0xff) || (ptr[5] != 0xff)) 109 if ((ptr[4] != 0xff) || (ptr[5] != 0xff))
121 goto out; 110 goto out;
122 111
123 if (((toktype != KG_TOK_WRAP_MSG) && (sealalg != 0xffff)) || 112 if (sealalg != 0xffff)
124 ((toktype == KG_TOK_WRAP_MSG) && (sealalg == 0xffff)))
125 goto out;
126
127 /* in the current spec, there is only one valid seal algorithm per
128 key type, so a simple comparison is ok */
129
130 if ((toktype == KG_TOK_WRAP_MSG) && !(sealalg == ctx->sealalg))
131 goto out; 113 goto out;
132 114
133 /* there are several mappings of seal algorithms to sign algorithms, 115 /* there are several mappings of seal algorithms to sign algorithms,
@@ -154,7 +136,7 @@ krb5_read_token(struct krb5_ctx *ctx,
154 switch (signalg) { 136 switch (signalg) {
155 case SGN_ALG_DES_MAC_MD5: 137 case SGN_ALG_DES_MAC_MD5:
156 ret = make_checksum(checksum_type, ptr - 2, 8, 138 ret = make_checksum(checksum_type, ptr - 2, 8,
157 message_buffer, &md5cksum); 139 message_buffer, 0, &md5cksum);
158 if (ret) 140 if (ret)
159 goto out; 141 goto out;
160 142
@@ -175,9 +157,6 @@ krb5_read_token(struct krb5_ctx *ctx,
175 157
176 /* it got through unscathed. Make sure the context is unexpired */ 158 /* it got through unscathed. Make sure the context is unexpired */
177 159
178 if (qop_state)
179 *qop_state = GSS_C_QOP_DEFAULT;
180
181 now = get_seconds(); 160 now = get_seconds();
182 161
183 ret = GSS_S_CONTEXT_EXPIRED; 162 ret = GSS_S_CONTEXT_EXPIRED;
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c
new file mode 100644
index 000000000000..af777cf9f251
--- /dev/null
+++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
@@ -0,0 +1,363 @@
1#include <linux/types.h>
2#include <linux/slab.h>
3#include <linux/jiffies.h>
4#include <linux/sunrpc/gss_krb5.h>
5#include <linux/random.h>
6#include <linux/pagemap.h>
7#include <asm/scatterlist.h>
8#include <linux/crypto.h>
9
10#ifdef RPC_DEBUG
11# define RPCDBG_FACILITY RPCDBG_AUTH
12#endif
13
14static inline int
15gss_krb5_padding(int blocksize, int length)
16{
17 /* Most of the code is block-size independent but currently we
18 * use only 8: */
19 BUG_ON(blocksize != 8);
20 return 8 - (length & 7);
21}
22
23static inline void
24gss_krb5_add_padding(struct xdr_buf *buf, int offset, int blocksize)
25{
26 int padding = gss_krb5_padding(blocksize, buf->len - offset);
27 char *p;
28 struct kvec *iov;
29
30 if (buf->page_len || buf->tail[0].iov_len)
31 iov = &buf->tail[0];
32 else
33 iov = &buf->head[0];
34 p = iov->iov_base + iov->iov_len;
35 iov->iov_len += padding;
36 buf->len += padding;
37 memset(p, padding, padding);
38}
39
40static inline int
41gss_krb5_remove_padding(struct xdr_buf *buf, int blocksize)
42{
43 u8 *ptr;
44 u8 pad;
45 int len = buf->len;
46
47 if (len <= buf->head[0].iov_len) {
48 pad = *(u8 *)(buf->head[0].iov_base + len - 1);
49 if (pad > buf->head[0].iov_len)
50 return -EINVAL;
51 buf->head[0].iov_len -= pad;
52 goto out;
53 } else
54 len -= buf->head[0].iov_len;
55 if (len <= buf->page_len) {
56 int last = (buf->page_base + len - 1)
57 >>PAGE_CACHE_SHIFT;
58 int offset = (buf->page_base + len - 1)
59 & (PAGE_CACHE_SIZE - 1);
60 ptr = kmap_atomic(buf->pages[last], KM_SKB_SUNRPC_DATA);
61 pad = *(ptr + offset);
62 kunmap_atomic(ptr, KM_SKB_SUNRPC_DATA);
63 goto out;
64 } else
65 len -= buf->page_len;
66 BUG_ON(len > buf->tail[0].iov_len);
67 pad = *(u8 *)(buf->tail[0].iov_base + len - 1);
68out:
69 /* XXX: NOTE: we do not adjust the page lengths--they represent
70 * a range of data in the real filesystem page cache, and we need
71 * to know that range so the xdr code can properly place read data.
72 * However adjusting the head length, as we do above, is harmless.
73 * In the case of a request that fits into a single page, the server
74 * also uses length and head length together to determine the original
75 * start of the request to copy the request for deferal; so it's
76 * easier on the server if we adjust head and tail length in tandem.
77 * It's not really a problem that we don't fool with the page and
78 * tail lengths, though--at worst badly formed xdr might lead the
79 * server to attempt to parse the padding.
80 * XXX: Document all these weird requirements for gss mechanism
81 * wrap/unwrap functions. */
82 if (pad > blocksize)
83 return -EINVAL;
84 if (buf->len > pad)
85 buf->len -= pad;
86 else
87 return -EINVAL;
88 return 0;
89}
90
91static inline void
92make_confounder(char *p, int blocksize)
93{
94 static u64 i = 0;
95 u64 *q = (u64 *)p;
96
97 /* rfc1964 claims this should be "random". But all that's really
98 * necessary is that it be unique. And not even that is necessary in
99 * our case since our "gssapi" implementation exists only to support
100 * rpcsec_gss, so we know that the only buffers we will ever encrypt
101 * already begin with a unique sequence number. Just to hedge my bets
102 * I'll make a half-hearted attempt at something unique, but ensuring
103 * uniqueness would mean worrying about atomicity and rollover, and I
104 * don't care enough. */
105
106 BUG_ON(blocksize != 8);
107 *q = i++;
108}
109
110/* Assumptions: the head and tail of inbuf are ours to play with.
111 * The pages, however, may be real pages in the page cache and we replace
112 * them with scratch pages from **pages before writing to them. */
113/* XXX: obviously the above should be documentation of wrap interface,
114 * and shouldn't be in this kerberos-specific file. */
115
116/* XXX factor out common code with seal/unseal. */
117
118u32
119gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
120 struct xdr_buf *buf, struct page **pages)
121{
122 struct krb5_ctx *kctx = ctx->internal_ctx_id;
123 s32 checksum_type;
124 struct xdr_netobj md5cksum = {.len = 0, .data = NULL};
125 int blocksize = 0, plainlen;
126 unsigned char *ptr, *krb5_hdr, *msg_start;
127 s32 now;
128 int headlen;
129 struct page **tmp_pages;
130
131 dprintk("RPC: gss_wrap_kerberos\n");
132
133 now = get_seconds();
134
135 switch (kctx->signalg) {
136 case SGN_ALG_DES_MAC_MD5:
137 checksum_type = CKSUMTYPE_RSA_MD5;
138 break;
139 default:
140 dprintk("RPC: gss_krb5_seal: kctx->signalg %d not"
141 " supported\n", kctx->signalg);
142 goto out_err;
143 }
144 if (kctx->sealalg != SEAL_ALG_NONE && kctx->sealalg != SEAL_ALG_DES) {
145 dprintk("RPC: gss_krb5_seal: kctx->sealalg %d not supported\n",
146 kctx->sealalg);
147 goto out_err;
148 }
149
150 blocksize = crypto_tfm_alg_blocksize(kctx->enc);
151 gss_krb5_add_padding(buf, offset, blocksize);
152 BUG_ON((buf->len - offset) % blocksize);
153 plainlen = blocksize + buf->len - offset;
154
155 headlen = g_token_size(&kctx->mech_used, 22 + plainlen) -
156 (buf->len - offset);
157
158 ptr = buf->head[0].iov_base + offset;
159 /* shift data to make room for header. */
160 /* XXX Would be cleverer to encrypt while copying. */
161 /* XXX bounds checking, slack, etc. */
162 memmove(ptr + headlen, ptr, buf->head[0].iov_len - offset);
163 buf->head[0].iov_len += headlen;
164 buf->len += headlen;
165 BUG_ON((buf->len - offset - headlen) % blocksize);
166
167 g_make_token_header(&kctx->mech_used, 22 + plainlen, &ptr);
168
169
170 *ptr++ = (unsigned char) ((KG_TOK_WRAP_MSG>>8)&0xff);
171 *ptr++ = (unsigned char) (KG_TOK_WRAP_MSG&0xff);
172
173 /* ptr now at byte 2 of header described in rfc 1964, section 1.2.1: */
174 krb5_hdr = ptr - 2;
175 msg_start = krb5_hdr + 24;
176 /* XXXJBF: */ BUG_ON(buf->head[0].iov_base + offset + headlen != msg_start + blocksize);
177
178 *(u16 *)(krb5_hdr + 2) = htons(kctx->signalg);
179 memset(krb5_hdr + 4, 0xff, 4);
180 *(u16 *)(krb5_hdr + 4) = htons(kctx->sealalg);
181
182 make_confounder(msg_start, blocksize);
183
184 /* XXXJBF: UGH!: */
185 tmp_pages = buf->pages;
186 buf->pages = pages;
187 if (make_checksum(checksum_type, krb5_hdr, 8, buf,
188 offset + headlen - blocksize, &md5cksum))
189 goto out_err;
190 buf->pages = tmp_pages;
191
192 switch (kctx->signalg) {
193 case SGN_ALG_DES_MAC_MD5:
194 if (krb5_encrypt(kctx->seq, NULL, md5cksum.data,
195 md5cksum.data, md5cksum.len))
196 goto out_err;
197 memcpy(krb5_hdr + 16,
198 md5cksum.data + md5cksum.len - KRB5_CKSUM_LENGTH,
199 KRB5_CKSUM_LENGTH);
200
201 dprintk("RPC: make_seal_token: cksum data: \n");
202 print_hexl((u32 *) (krb5_hdr + 16), KRB5_CKSUM_LENGTH, 0);
203 break;
204 default:
205 BUG();
206 }
207
208 kfree(md5cksum.data);
209
210 /* XXX would probably be more efficient to compute checksum
211 * and encrypt at the same time: */
212 if ((krb5_make_seq_num(kctx->seq, kctx->initiate ? 0 : 0xff,
213 kctx->seq_send, krb5_hdr + 16, krb5_hdr + 8)))
214 goto out_err;
215
216 if (gss_encrypt_xdr_buf(kctx->enc, buf, offset + headlen - blocksize,
217 pages))
218 goto out_err;
219
220 kctx->seq_send++;
221
222 return ((kctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE);
223out_err:
224 if (md5cksum.data) kfree(md5cksum.data);
225 return GSS_S_FAILURE;
226}
227
228u32
229gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
230{
231 struct krb5_ctx *kctx = ctx->internal_ctx_id;
232 int signalg;
233 int sealalg;
234 s32 checksum_type;
235 struct xdr_netobj md5cksum = {.len = 0, .data = NULL};
236 s32 now;
237 int direction;
238 s32 seqnum;
239 unsigned char *ptr;
240 int bodysize;
241 u32 ret = GSS_S_DEFECTIVE_TOKEN;
242 void *data_start, *orig_start;
243 int data_len;
244 int blocksize;
245
246 dprintk("RPC: gss_unwrap_kerberos\n");
247
248 ptr = (u8 *)buf->head[0].iov_base + offset;
249 if (g_verify_token_header(&kctx->mech_used, &bodysize, &ptr,
250 buf->len - offset))
251 goto out;
252
253 if ((*ptr++ != ((KG_TOK_WRAP_MSG>>8)&0xff)) ||
254 (*ptr++ != (KG_TOK_WRAP_MSG &0xff)) )
255 goto out;
256
257 /* XXX sanity-check bodysize?? */
258
259 /* get the sign and seal algorithms */
260
261 signalg = ptr[0] + (ptr[1] << 8);
262 sealalg = ptr[2] + (ptr[3] << 8);
263
264 /* Sanity checks */
265
266 if ((ptr[4] != 0xff) || (ptr[5] != 0xff))
267 goto out;
268
269 if (sealalg == 0xffff)
270 goto out;
271
272 /* in the current spec, there is only one valid seal algorithm per
273 key type, so a simple comparison is ok */
274
275 if (sealalg != kctx->sealalg)
276 goto out;
277
278 /* there are several mappings of seal algorithms to sign algorithms,
279 but few enough that we can try them all. */
280
281 if ((kctx->sealalg == SEAL_ALG_NONE && signalg > 1) ||
282 (kctx->sealalg == SEAL_ALG_1 && signalg != SGN_ALG_3) ||
283 (kctx->sealalg == SEAL_ALG_DES3KD &&
284 signalg != SGN_ALG_HMAC_SHA1_DES3_KD))
285 goto out;
286
287 if (gss_decrypt_xdr_buf(kctx->enc, buf,
288 ptr + 22 - (unsigned char *)buf->head[0].iov_base))
289 goto out;
290
291 /* compute the checksum of the message */
292
293 /* initialize the the cksum */
294 switch (signalg) {
295 case SGN_ALG_DES_MAC_MD5:
296 checksum_type = CKSUMTYPE_RSA_MD5;
297 break;
298 default:
299 ret = GSS_S_DEFECTIVE_TOKEN;
300 goto out;
301 }
302
303 switch (signalg) {
304 case SGN_ALG_DES_MAC_MD5:
305 ret = make_checksum(checksum_type, ptr - 2, 8, buf,
306 ptr + 22 - (unsigned char *)buf->head[0].iov_base, &md5cksum);
307 if (ret)
308 goto out;
309
310 ret = krb5_encrypt(kctx->seq, NULL, md5cksum.data,
311 md5cksum.data, md5cksum.len);
312 if (ret)
313 goto out;
314
315 if (memcmp(md5cksum.data + 8, ptr + 14, 8)) {
316 ret = GSS_S_BAD_SIG;
317 goto out;
318 }
319 break;
320 default:
321 ret = GSS_S_DEFECTIVE_TOKEN;
322 goto out;
323 }
324
325 /* it got through unscathed. Make sure the context is unexpired */
326
327 now = get_seconds();
328
329 ret = GSS_S_CONTEXT_EXPIRED;
330 if (now > kctx->endtime)
331 goto out;
332
333 /* do sequencing checks */
334
335 ret = GSS_S_BAD_SIG;
336 if ((ret = krb5_get_seq_num(kctx->seq, ptr + 14, ptr + 6, &direction,
337 &seqnum)))
338 goto out;
339
340 if ((kctx->initiate && direction != 0xff) ||
341 (!kctx->initiate && direction != 0))
342 goto out;
343
344 /* Copy the data back to the right position. XXX: Would probably be
345 * better to copy and encrypt at the same time. */
346
347 blocksize = crypto_tfm_alg_blocksize(kctx->enc);
348 data_start = ptr + 22 + blocksize;
349 orig_start = buf->head[0].iov_base + offset;
350 data_len = (buf->head[0].iov_base + buf->head[0].iov_len) - data_start;
351 memmove(orig_start, data_start, data_len);
352 buf->head[0].iov_len -= (data_start - orig_start);
353 buf->len -= (data_start - orig_start);
354
355 ret = GSS_S_DEFECTIVE_TOKEN;
356 if (gss_krb5_remove_padding(buf, blocksize))
357 goto out;
358
359 ret = GSS_S_COMPLETE;
360out:
361 if (md5cksum.data) kfree(md5cksum.data);
362 return ret;
363}
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
index 9dfb68377d69..b048bf672da2 100644
--- a/net/sunrpc/auth_gss/gss_mech_switch.c
+++ b/net/sunrpc/auth_gss/gss_mech_switch.c
@@ -35,7 +35,6 @@
35 35
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/socket.h>
39#include <linux/module.h> 38#include <linux/module.h>
40#include <linux/sunrpc/msg_prot.h> 39#include <linux/sunrpc/msg_prot.h>
41#include <linux/sunrpc/gss_asn1.h> 40#include <linux/sunrpc/gss_asn1.h>
@@ -251,13 +250,11 @@ gss_import_sec_context(const void *input_token, size_t bufsize,
251 250
252u32 251u32
253gss_get_mic(struct gss_ctx *context_handle, 252gss_get_mic(struct gss_ctx *context_handle,
254 u32 qop,
255 struct xdr_buf *message, 253 struct xdr_buf *message,
256 struct xdr_netobj *mic_token) 254 struct xdr_netobj *mic_token)
257{ 255{
258 return context_handle->mech_type->gm_ops 256 return context_handle->mech_type->gm_ops
259 ->gss_get_mic(context_handle, 257 ->gss_get_mic(context_handle,
260 qop,
261 message, 258 message,
262 mic_token); 259 mic_token);
263} 260}
@@ -267,16 +264,34 @@ gss_get_mic(struct gss_ctx *context_handle,
267u32 264u32
268gss_verify_mic(struct gss_ctx *context_handle, 265gss_verify_mic(struct gss_ctx *context_handle,
269 struct xdr_buf *message, 266 struct xdr_buf *message,
270 struct xdr_netobj *mic_token, 267 struct xdr_netobj *mic_token)
271 u32 *qstate)
272{ 268{
273 return context_handle->mech_type->gm_ops 269 return context_handle->mech_type->gm_ops
274 ->gss_verify_mic(context_handle, 270 ->gss_verify_mic(context_handle,
275 message, 271 message,
276 mic_token, 272 mic_token);
277 qstate);
278} 273}
279 274
275u32
276gss_wrap(struct gss_ctx *ctx_id,
277 int offset,
278 struct xdr_buf *buf,
279 struct page **inpages)
280{
281 return ctx_id->mech_type->gm_ops
282 ->gss_wrap(ctx_id, offset, buf, inpages);
283}
284
285u32
286gss_unwrap(struct gss_ctx *ctx_id,
287 int offset,
288 struct xdr_buf *buf)
289{
290 return ctx_id->mech_type->gm_ops
291 ->gss_unwrap(ctx_id, offset, buf);
292}
293
294
280/* gss_delete_sec_context: free all resources associated with context_handle. 295/* gss_delete_sec_context: free all resources associated with context_handle.
281 * Note this differs from the RFC 2744-specified prototype in that we don't 296 * Note this differs from the RFC 2744-specified prototype in that we don't
282 * bother returning an output token, since it would never be used anyway. */ 297 * bother returning an output token, since it would never be used anyway. */
diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c
index 6c97d61baa9b..39b3edc14694 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_mech.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c
@@ -224,18 +224,13 @@ gss_delete_sec_context_spkm3(void *internal_ctx) {
224static u32 224static u32
225gss_verify_mic_spkm3(struct gss_ctx *ctx, 225gss_verify_mic_spkm3(struct gss_ctx *ctx,
226 struct xdr_buf *signbuf, 226 struct xdr_buf *signbuf,
227 struct xdr_netobj *checksum, 227 struct xdr_netobj *checksum)
228 u32 *qstate) { 228{
229 u32 maj_stat = 0; 229 u32 maj_stat = 0;
230 int qop_state = 0;
231 struct spkm3_ctx *sctx = ctx->internal_ctx_id; 230 struct spkm3_ctx *sctx = ctx->internal_ctx_id;
232 231
233 dprintk("RPC: gss_verify_mic_spkm3 calling spkm3_read_token\n"); 232 dprintk("RPC: gss_verify_mic_spkm3 calling spkm3_read_token\n");
234 maj_stat = spkm3_read_token(sctx, checksum, signbuf, &qop_state, 233 maj_stat = spkm3_read_token(sctx, checksum, signbuf, SPKM_MIC_TOK);
235 SPKM_MIC_TOK);
236
237 if (!maj_stat && qop_state)
238 *qstate = qop_state;
239 234
240 dprintk("RPC: gss_verify_mic_spkm3 returning %d\n", maj_stat); 235 dprintk("RPC: gss_verify_mic_spkm3 returning %d\n", maj_stat);
241 return maj_stat; 236 return maj_stat;
@@ -243,15 +238,15 @@ gss_verify_mic_spkm3(struct gss_ctx *ctx,
243 238
244static u32 239static u32
245gss_get_mic_spkm3(struct gss_ctx *ctx, 240gss_get_mic_spkm3(struct gss_ctx *ctx,
246 u32 qop,
247 struct xdr_buf *message_buffer, 241 struct xdr_buf *message_buffer,
248 struct xdr_netobj *message_token) { 242 struct xdr_netobj *message_token)
243{
249 u32 err = 0; 244 u32 err = 0;
250 struct spkm3_ctx *sctx = ctx->internal_ctx_id; 245 struct spkm3_ctx *sctx = ctx->internal_ctx_id;
251 246
252 dprintk("RPC: gss_get_mic_spkm3\n"); 247 dprintk("RPC: gss_get_mic_spkm3\n");
253 248
254 err = spkm3_make_token(sctx, qop, message_buffer, 249 err = spkm3_make_token(sctx, message_buffer,
255 message_token, SPKM_MIC_TOK); 250 message_token, SPKM_MIC_TOK);
256 return err; 251 return err;
257} 252}
@@ -264,8 +259,8 @@ static struct gss_api_ops gss_spkm3_ops = {
264}; 259};
265 260
266static struct pf_desc gss_spkm3_pfs[] = { 261static struct pf_desc gss_spkm3_pfs[] = {
267 {RPC_AUTH_GSS_SPKM, 0, RPC_GSS_SVC_NONE, "spkm3"}, 262 {RPC_AUTH_GSS_SPKM, RPC_GSS_SVC_NONE, "spkm3"},
268 {RPC_AUTH_GSS_SPKMI, 0, RPC_GSS_SVC_INTEGRITY, "spkm3i"}, 263 {RPC_AUTH_GSS_SPKMI, RPC_GSS_SVC_INTEGRITY, "spkm3i"},
269}; 264};
270 265
271static struct gss_api_mech gss_spkm3_mech = { 266static struct gss_api_mech gss_spkm3_mech = {
diff --git a/net/sunrpc/auth_gss/gss_spkm3_seal.c b/net/sunrpc/auth_gss/gss_spkm3_seal.c
index 25339868d462..148201e929d0 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_seal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_seal.c
@@ -51,7 +51,7 @@
51 */ 51 */
52 52
53u32 53u32
54spkm3_make_token(struct spkm3_ctx *ctx, int qop_req, 54spkm3_make_token(struct spkm3_ctx *ctx,
55 struct xdr_buf * text, struct xdr_netobj * token, 55 struct xdr_buf * text, struct xdr_netobj * token,
56 int toktype) 56 int toktype)
57{ 57{
@@ -68,8 +68,6 @@ spkm3_make_token(struct spkm3_ctx *ctx, int qop_req,
68 dprintk("RPC: spkm3_make_token\n"); 68 dprintk("RPC: spkm3_make_token\n");
69 69
70 now = jiffies; 70 now = jiffies;
71 if (qop_req != 0)
72 goto out_err;
73 71
74 if (ctx->ctx_id.len != 16) { 72 if (ctx->ctx_id.len != 16) {
75 dprintk("RPC: spkm3_make_token BAD ctx_id.len %d\n", 73 dprintk("RPC: spkm3_make_token BAD ctx_id.len %d\n",
diff --git a/net/sunrpc/auth_gss/gss_spkm3_unseal.c b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
index 65ce81bf0bc4..c3c0d9586103 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_unseal.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_unseal.c
@@ -52,7 +52,7 @@ u32
52spkm3_read_token(struct spkm3_ctx *ctx, 52spkm3_read_token(struct spkm3_ctx *ctx,
53 struct xdr_netobj *read_token, /* checksum */ 53 struct xdr_netobj *read_token, /* checksum */
54 struct xdr_buf *message_buffer, /* signbuf */ 54 struct xdr_buf *message_buffer, /* signbuf */
55 int *qop_state, int toktype) 55 int toktype)
56{ 56{
57 s32 code; 57 s32 code;
58 struct xdr_netobj wire_cksum = {.len =0, .data = NULL}; 58 struct xdr_netobj wire_cksum = {.len =0, .data = NULL};
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index e3308195374e..e4ada15ed856 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -566,8 +566,7 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
566 566
567 if (rqstp->rq_deferred) /* skip verification of revisited request */ 567 if (rqstp->rq_deferred) /* skip verification of revisited request */
568 return SVC_OK; 568 return SVC_OK;
569 if (gss_verify_mic(ctx_id, &rpchdr, &checksum, NULL) 569 if (gss_verify_mic(ctx_id, &rpchdr, &checksum) != GSS_S_COMPLETE) {
570 != GSS_S_COMPLETE) {
571 *authp = rpcsec_gsserr_credproblem; 570 *authp = rpcsec_gsserr_credproblem;
572 return SVC_DENIED; 571 return SVC_DENIED;
573 } 572 }
@@ -604,7 +603,7 @@ gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq)
604 xdr_buf_from_iov(&iov, &verf_data); 603 xdr_buf_from_iov(&iov, &verf_data);
605 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len; 604 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len;
606 mic.data = (u8 *)(p + 1); 605 mic.data = (u8 *)(p + 1);
607 maj_stat = gss_get_mic(ctx_id, 0, &verf_data, &mic); 606 maj_stat = gss_get_mic(ctx_id, &verf_data, &mic);
608 if (maj_stat != GSS_S_COMPLETE) 607 if (maj_stat != GSS_S_COMPLETE)
609 return -1; 608 return -1;
610 *p++ = htonl(mic.len); 609 *p++ = htonl(mic.len);
@@ -710,7 +709,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
710 goto out; 709 goto out;
711 if (read_bytes_from_xdr_buf(buf, integ_len + 4, mic.data, mic.len)) 710 if (read_bytes_from_xdr_buf(buf, integ_len + 4, mic.data, mic.len))
712 goto out; 711 goto out;
713 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic, NULL); 712 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
714 if (maj_stat != GSS_S_COMPLETE) 713 if (maj_stat != GSS_S_COMPLETE)
715 goto out; 714 goto out;
716 if (ntohl(svc_getu32(&buf->head[0])) != seq) 715 if (ntohl(svc_getu32(&buf->head[0])) != seq)
@@ -1012,7 +1011,7 @@ svcauth_gss_release(struct svc_rqst *rqstp)
1012 resv = &resbuf->tail[0]; 1011 resv = &resbuf->tail[0];
1013 } 1012 }
1014 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4; 1013 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
1015 if (gss_get_mic(gsd->rsci->mechctx, 0, &integ_buf, &mic)) 1014 if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
1016 goto out_err; 1015 goto out_err;
1017 svc_putu32(resv, htonl(mic.len)); 1016 svc_putu32(resv, htonl(mic.len));
1018 memset(mic.data + mic.len, 0, 1017 memset(mic.data + mic.len, 0,
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c
index 9b72d3abf823..f56767aaa927 100644
--- a/net/sunrpc/auth_null.c
+++ b/net/sunrpc/auth_null.c
@@ -7,9 +7,7 @@
7 */ 7 */
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/socket.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/in.h>
13#include <linux/utsname.h> 11#include <linux/utsname.h>
14#include <linux/sunrpc/clnt.h> 12#include <linux/sunrpc/clnt.h>
15#include <linux/sched.h> 13#include <linux/sched.h>
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 4ff297a9b15b..890fb5ea0dcb 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -9,8 +9,6 @@
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/socket.h>
13#include <linux/in.h>
14#include <linux/sunrpc/clnt.h> 12#include <linux/sunrpc/clnt.h>
15#include <linux/sunrpc/auth.h> 13#include <linux/sunrpc/auth.h>
16 14
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index f17e6153b688..702ede309b06 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/net/sunrpc/rpcclnt.c 2 * linux/net/sunrpc/clnt.c
3 * 3 *
4 * This file contains the high-level RPC interface. 4 * This file contains the high-level RPC interface.
5 * It is modeled as a finite state machine to support both synchronous 5 * It is modeled as a finite state machine to support both synchronous
@@ -27,7 +27,6 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/in.h>
31#include <linux/utsname.h> 30#include <linux/utsname.h>
32 31
33#include <linux/sunrpc/clnt.h> 32#include <linux/sunrpc/clnt.h>
@@ -53,6 +52,7 @@ static void call_allocate(struct rpc_task *task);
53static void call_encode(struct rpc_task *task); 52static void call_encode(struct rpc_task *task);
54static void call_decode(struct rpc_task *task); 53static void call_decode(struct rpc_task *task);
55static void call_bind(struct rpc_task *task); 54static void call_bind(struct rpc_task *task);
55static void call_bind_status(struct rpc_task *task);
56static void call_transmit(struct rpc_task *task); 56static void call_transmit(struct rpc_task *task);
57static void call_status(struct rpc_task *task); 57static void call_status(struct rpc_task *task);
58static void call_refresh(struct rpc_task *task); 58static void call_refresh(struct rpc_task *task);
@@ -517,15 +517,8 @@ void
517rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize) 517rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize)
518{ 518{
519 struct rpc_xprt *xprt = clnt->cl_xprt; 519 struct rpc_xprt *xprt = clnt->cl_xprt;
520 520 if (xprt->ops->set_buffer_size)
521 xprt->sndsize = 0; 521 xprt->ops->set_buffer_size(xprt, sndsize, rcvsize);
522 if (sndsize)
523 xprt->sndsize = sndsize + RPC_SLACK_SPACE;
524 xprt->rcvsize = 0;
525 if (rcvsize)
526 xprt->rcvsize = rcvsize + RPC_SLACK_SPACE;
527 if (xprt_connected(xprt))
528 xprt_sock_setbufsize(xprt);
529} 522}
530 523
531/* 524/*
@@ -685,13 +678,11 @@ call_allocate(struct rpc_task *task)
685static void 678static void
686call_encode(struct rpc_task *task) 679call_encode(struct rpc_task *task)
687{ 680{
688 struct rpc_clnt *clnt = task->tk_client;
689 struct rpc_rqst *req = task->tk_rqstp; 681 struct rpc_rqst *req = task->tk_rqstp;
690 struct xdr_buf *sndbuf = &req->rq_snd_buf; 682 struct xdr_buf *sndbuf = &req->rq_snd_buf;
691 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 683 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
692 unsigned int bufsiz; 684 unsigned int bufsiz;
693 kxdrproc_t encode; 685 kxdrproc_t encode;
694 int status;
695 u32 *p; 686 u32 *p;
696 687
697 dprintk("RPC: %4d call_encode (status %d)\n", 688 dprintk("RPC: %4d call_encode (status %d)\n",
@@ -719,11 +710,15 @@ call_encode(struct rpc_task *task)
719 rpc_exit(task, -EIO); 710 rpc_exit(task, -EIO);
720 return; 711 return;
721 } 712 }
722 if (encode && (status = rpcauth_wrap_req(task, encode, req, p, 713 if (encode == NULL)
723 task->tk_msg.rpc_argp)) < 0) { 714 return;
724 printk(KERN_WARNING "%s: can't encode arguments: %d\n", 715
725 clnt->cl_protname, -status); 716 task->tk_status = rpcauth_wrap_req(task, encode, req, p,
726 rpc_exit(task, status); 717 task->tk_msg.rpc_argp);
718 if (task->tk_status == -ENOMEM) {
719 /* XXX: Is this sane? */
720 rpc_delay(task, 3*HZ);
721 task->tk_status = -EAGAIN;
727 } 722 }
728} 723}
729 724
@@ -734,43 +729,95 @@ static void
734call_bind(struct rpc_task *task) 729call_bind(struct rpc_task *task)
735{ 730{
736 struct rpc_clnt *clnt = task->tk_client; 731 struct rpc_clnt *clnt = task->tk_client;
737 struct rpc_xprt *xprt = clnt->cl_xprt;
738
739 dprintk("RPC: %4d call_bind xprt %p %s connected\n", task->tk_pid,
740 xprt, (xprt_connected(xprt) ? "is" : "is not"));
741 732
742 task->tk_action = (xprt_connected(xprt)) ? call_transmit : call_connect; 733 dprintk("RPC: %4d call_bind (status %d)\n",
734 task->tk_pid, task->tk_status);
743 735
736 task->tk_action = call_connect;
744 if (!clnt->cl_port) { 737 if (!clnt->cl_port) {
745 task->tk_action = call_connect; 738 task->tk_action = call_bind_status;
746 task->tk_timeout = RPC_CONNECT_TIMEOUT; 739 task->tk_timeout = task->tk_xprt->bind_timeout;
747 rpc_getport(task, clnt); 740 rpc_getport(task, clnt);
748 } 741 }
749} 742}
750 743
751/* 744/*
752 * 4a. Connect to the RPC server (TCP case) 745 * 4a. Sort out bind result
746 */
747static void
748call_bind_status(struct rpc_task *task)
749{
750 int status = -EACCES;
751
752 if (task->tk_status >= 0) {
753 dprintk("RPC: %4d call_bind_status (status %d)\n",
754 task->tk_pid, task->tk_status);
755 task->tk_status = 0;
756 task->tk_action = call_connect;
757 return;
758 }
759
760 switch (task->tk_status) {
761 case -EACCES:
762 dprintk("RPC: %4d remote rpcbind: RPC program/version unavailable\n",
763 task->tk_pid);
764 rpc_delay(task, 3*HZ);
765 goto retry_bind;
766 case -ETIMEDOUT:
767 dprintk("RPC: %4d rpcbind request timed out\n",
768 task->tk_pid);
769 if (RPC_IS_SOFT(task)) {
770 status = -EIO;
771 break;
772 }
773 goto retry_bind;
774 case -EPFNOSUPPORT:
775 dprintk("RPC: %4d remote rpcbind service unavailable\n",
776 task->tk_pid);
777 break;
778 case -EPROTONOSUPPORT:
779 dprintk("RPC: %4d remote rpcbind version 2 unavailable\n",
780 task->tk_pid);
781 break;
782 default:
783 dprintk("RPC: %4d unrecognized rpcbind error (%d)\n",
784 task->tk_pid, -task->tk_status);
785 status = -EIO;
786 break;
787 }
788
789 rpc_exit(task, status);
790 return;
791
792retry_bind:
793 task->tk_status = 0;
794 task->tk_action = call_bind;
795 return;
796}
797
798/*
799 * 4b. Connect to the RPC server
753 */ 800 */
754static void 801static void
755call_connect(struct rpc_task *task) 802call_connect(struct rpc_task *task)
756{ 803{
757 struct rpc_clnt *clnt = task->tk_client; 804 struct rpc_xprt *xprt = task->tk_xprt;
758 805
759 dprintk("RPC: %4d call_connect status %d\n", 806 dprintk("RPC: %4d call_connect xprt %p %s connected\n",
760 task->tk_pid, task->tk_status); 807 task->tk_pid, xprt,
808 (xprt_connected(xprt) ? "is" : "is not"));
761 809
762 if (xprt_connected(clnt->cl_xprt)) { 810 task->tk_action = call_transmit;
763 task->tk_action = call_transmit; 811 if (!xprt_connected(xprt)) {
764 return; 812 task->tk_action = call_connect_status;
813 if (task->tk_status < 0)
814 return;
815 xprt_connect(task);
765 } 816 }
766 task->tk_action = call_connect_status;
767 if (task->tk_status < 0)
768 return;
769 xprt_connect(task);
770} 817}
771 818
772/* 819/*
773 * 4b. Sort out connect result 820 * 4c. Sort out connect result
774 */ 821 */
775static void 822static void
776call_connect_status(struct rpc_task *task) 823call_connect_status(struct rpc_task *task)
@@ -778,6 +825,9 @@ call_connect_status(struct rpc_task *task)
778 struct rpc_clnt *clnt = task->tk_client; 825 struct rpc_clnt *clnt = task->tk_client;
779 int status = task->tk_status; 826 int status = task->tk_status;
780 827
828 dprintk("RPC: %5u call_connect_status (status %d)\n",
829 task->tk_pid, task->tk_status);
830
781 task->tk_status = 0; 831 task->tk_status = 0;
782 if (status >= 0) { 832 if (status >= 0) {
783 clnt->cl_stats->netreconn++; 833 clnt->cl_stats->netreconn++;
@@ -785,17 +835,19 @@ call_connect_status(struct rpc_task *task)
785 return; 835 return;
786 } 836 }
787 837
788 /* Something failed: we may have to rebind */ 838 /* Something failed: remote service port may have changed */
789 if (clnt->cl_autobind) 839 if (clnt->cl_autobind)
790 clnt->cl_port = 0; 840 clnt->cl_port = 0;
841
791 switch (status) { 842 switch (status) {
792 case -ENOTCONN: 843 case -ENOTCONN:
793 case -ETIMEDOUT: 844 case -ETIMEDOUT:
794 case -EAGAIN: 845 case -EAGAIN:
795 task->tk_action = (clnt->cl_port == 0) ? call_bind : call_connect; 846 task->tk_action = call_bind;
796 break; 847 break;
797 default: 848 default:
798 rpc_exit(task, -EIO); 849 rpc_exit(task, -EIO);
850 break;
799 } 851 }
800} 852}
801 853
@@ -815,10 +867,12 @@ call_transmit(struct rpc_task *task)
815 if (task->tk_status != 0) 867 if (task->tk_status != 0)
816 return; 868 return;
817 /* Encode here so that rpcsec_gss can use correct sequence number. */ 869 /* Encode here so that rpcsec_gss can use correct sequence number. */
818 if (!task->tk_rqstp->rq_bytes_sent) 870 if (task->tk_rqstp->rq_bytes_sent == 0) {
819 call_encode(task); 871 call_encode(task);
820 if (task->tk_status < 0) 872 /* Did the encode result in an error condition? */
821 return; 873 if (task->tk_status != 0)
874 goto out_nosend;
875 }
822 xprt_transmit(task); 876 xprt_transmit(task);
823 if (task->tk_status < 0) 877 if (task->tk_status < 0)
824 return; 878 return;
@@ -826,6 +880,10 @@ call_transmit(struct rpc_task *task)
826 task->tk_action = NULL; 880 task->tk_action = NULL;
827 rpc_wake_up_task(task); 881 rpc_wake_up_task(task);
828 } 882 }
883 return;
884out_nosend:
885 /* release socket write lock before attempting to handle error */
886 xprt_abort_transmit(task);
829} 887}
830 888
831/* 889/*
@@ -1020,13 +1078,12 @@ static u32 *
1020call_header(struct rpc_task *task) 1078call_header(struct rpc_task *task)
1021{ 1079{
1022 struct rpc_clnt *clnt = task->tk_client; 1080 struct rpc_clnt *clnt = task->tk_client;
1023 struct rpc_xprt *xprt = clnt->cl_xprt;
1024 struct rpc_rqst *req = task->tk_rqstp; 1081 struct rpc_rqst *req = task->tk_rqstp;
1025 u32 *p = req->rq_svec[0].iov_base; 1082 u32 *p = req->rq_svec[0].iov_base;
1026 1083
1027 /* FIXME: check buffer size? */ 1084 /* FIXME: check buffer size? */
1028 if (xprt->stream) 1085
1029 *p++ = 0; /* fill in later */ 1086 p = xprt_skip_transport_header(task->tk_xprt, p);
1030 *p++ = req->rq_xid; /* XID */ 1087 *p++ = req->rq_xid; /* XID */
1031 *p++ = htonl(RPC_CALL); /* CALL */ 1088 *p++ = htonl(RPC_CALL); /* CALL */
1032 *p++ = htonl(RPC_VERSION); /* RPC version */ 1089 *p++ = htonl(RPC_VERSION); /* RPC version */
diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c
index 4e81f2766923..a398575f94b8 100644
--- a/net/sunrpc/pmap_clnt.c
+++ b/net/sunrpc/pmap_clnt.c
@@ -26,7 +26,7 @@
26#define PMAP_GETPORT 3 26#define PMAP_GETPORT 3
27 27
28static struct rpc_procinfo pmap_procedures[]; 28static struct rpc_procinfo pmap_procedures[];
29static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int); 29static struct rpc_clnt * pmap_create(char *, struct sockaddr_in *, int, int);
30static void pmap_getport_done(struct rpc_task *); 30static void pmap_getport_done(struct rpc_task *);
31static struct rpc_program pmap_program; 31static struct rpc_program pmap_program;
32static DEFINE_SPINLOCK(pmap_lock); 32static DEFINE_SPINLOCK(pmap_lock);
@@ -65,7 +65,7 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt)
65 map->pm_binding = 1; 65 map->pm_binding = 1;
66 spin_unlock(&pmap_lock); 66 spin_unlock(&pmap_lock);
67 67
68 pmap_clnt = pmap_create(clnt->cl_server, sap, map->pm_prot); 68 pmap_clnt = pmap_create(clnt->cl_server, sap, map->pm_prot, 0);
69 if (IS_ERR(pmap_clnt)) { 69 if (IS_ERR(pmap_clnt)) {
70 task->tk_status = PTR_ERR(pmap_clnt); 70 task->tk_status = PTR_ERR(pmap_clnt);
71 goto bailout; 71 goto bailout;
@@ -112,7 +112,7 @@ rpc_getport_external(struct sockaddr_in *sin, __u32 prog, __u32 vers, int prot)
112 NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); 112 NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot);
113 113
114 sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr)); 114 sprintf(hostname, "%u.%u.%u.%u", NIPQUAD(sin->sin_addr.s_addr));
115 pmap_clnt = pmap_create(hostname, sin, prot); 115 pmap_clnt = pmap_create(hostname, sin, prot, 0);
116 if (IS_ERR(pmap_clnt)) 116 if (IS_ERR(pmap_clnt))
117 return PTR_ERR(pmap_clnt); 117 return PTR_ERR(pmap_clnt);
118 118
@@ -171,7 +171,7 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
171 171
172 sin.sin_family = AF_INET; 172 sin.sin_family = AF_INET;
173 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 173 sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
174 pmap_clnt = pmap_create("localhost", &sin, IPPROTO_UDP); 174 pmap_clnt = pmap_create("localhost", &sin, IPPROTO_UDP, 1);
175 if (IS_ERR(pmap_clnt)) { 175 if (IS_ERR(pmap_clnt)) {
176 error = PTR_ERR(pmap_clnt); 176 error = PTR_ERR(pmap_clnt);
177 dprintk("RPC: couldn't create pmap client. Error = %d\n", error); 177 dprintk("RPC: couldn't create pmap client. Error = %d\n", error);
@@ -198,7 +198,7 @@ rpc_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay)
198} 198}
199 199
200static struct rpc_clnt * 200static struct rpc_clnt *
201pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto) 201pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileged)
202{ 202{
203 struct rpc_xprt *xprt; 203 struct rpc_xprt *xprt;
204 struct rpc_clnt *clnt; 204 struct rpc_clnt *clnt;
@@ -208,6 +208,8 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto)
208 if (IS_ERR(xprt)) 208 if (IS_ERR(xprt))
209 return (struct rpc_clnt *)xprt; 209 return (struct rpc_clnt *)xprt;
210 xprt->addr.sin_port = htons(RPC_PMAP_PORT); 210 xprt->addr.sin_port = htons(RPC_PMAP_PORT);
211 if (!privileged)
212 xprt->resvport = 0;
211 213
212 /* printk("pmap: create clnt\n"); */ 214 /* printk("pmap: create clnt\n"); */
213 clnt = rpc_new_client(xprt, hostname, 215 clnt = rpc_new_client(xprt, hostname,
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index ded6c63f11ec..4f188d0a5d11 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -76,25 +76,35 @@ int
76rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg) 76rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
77{ 77{
78 struct rpc_inode *rpci = RPC_I(inode); 78 struct rpc_inode *rpci = RPC_I(inode);
79 int res = 0; 79 int res = -EPIPE;
80 80
81 down(&inode->i_sem); 81 down(&inode->i_sem);
82 if (rpci->ops == NULL)
83 goto out;
82 if (rpci->nreaders) { 84 if (rpci->nreaders) {
83 list_add_tail(&msg->list, &rpci->pipe); 85 list_add_tail(&msg->list, &rpci->pipe);
84 rpci->pipelen += msg->len; 86 rpci->pipelen += msg->len;
87 res = 0;
85 } else if (rpci->flags & RPC_PIPE_WAIT_FOR_OPEN) { 88 } else if (rpci->flags & RPC_PIPE_WAIT_FOR_OPEN) {
86 if (list_empty(&rpci->pipe)) 89 if (list_empty(&rpci->pipe))
87 schedule_delayed_work(&rpci->queue_timeout, 90 schedule_delayed_work(&rpci->queue_timeout,
88 RPC_UPCALL_TIMEOUT); 91 RPC_UPCALL_TIMEOUT);
89 list_add_tail(&msg->list, &rpci->pipe); 92 list_add_tail(&msg->list, &rpci->pipe);
90 rpci->pipelen += msg->len; 93 rpci->pipelen += msg->len;
91 } else 94 res = 0;
92 res = -EPIPE; 95 }
96out:
93 up(&inode->i_sem); 97 up(&inode->i_sem);
94 wake_up(&rpci->waitq); 98 wake_up(&rpci->waitq);
95 return res; 99 return res;
96} 100}
97 101
102static inline void
103rpc_inode_setowner(struct inode *inode, void *private)
104{
105 RPC_I(inode)->private = private;
106}
107
98static void 108static void
99rpc_close_pipes(struct inode *inode) 109rpc_close_pipes(struct inode *inode)
100{ 110{
@@ -111,15 +121,10 @@ rpc_close_pipes(struct inode *inode)
111 rpci->ops->release_pipe(inode); 121 rpci->ops->release_pipe(inode);
112 rpci->ops = NULL; 122 rpci->ops = NULL;
113 } 123 }
124 rpc_inode_setowner(inode, NULL);
114 up(&inode->i_sem); 125 up(&inode->i_sem);
115} 126}
116 127
117static inline void
118rpc_inode_setowner(struct inode *inode, void *private)
119{
120 RPC_I(inode)->private = private;
121}
122
123static struct inode * 128static struct inode *
124rpc_alloc_inode(struct super_block *sb) 129rpc_alloc_inode(struct super_block *sb)
125{ 130{
@@ -501,7 +506,6 @@ repeat:
501 dentry = dvec[--n]; 506 dentry = dvec[--n];
502 if (dentry->d_inode) { 507 if (dentry->d_inode) {
503 rpc_close_pipes(dentry->d_inode); 508 rpc_close_pipes(dentry->d_inode);
504 rpc_inode_setowner(dentry->d_inode, NULL);
505 simple_unlink(dir, dentry); 509 simple_unlink(dir, dentry);
506 } 510 }
507 dput(dentry); 511 dput(dentry);
@@ -576,10 +580,8 @@ __rpc_rmdir(struct inode *dir, struct dentry *dentry)
576 int error; 580 int error;
577 581
578 shrink_dcache_parent(dentry); 582 shrink_dcache_parent(dentry);
579 if (dentry->d_inode) { 583 if (dentry->d_inode)
580 rpc_close_pipes(dentry->d_inode); 584 rpc_close_pipes(dentry->d_inode);
581 rpc_inode_setowner(dentry->d_inode, NULL);
582 }
583 if ((error = simple_rmdir(dir, dentry)) != 0) 585 if ((error = simple_rmdir(dir, dentry)) != 0)
584 return error; 586 return error;
585 if (!error) { 587 if (!error) {
@@ -732,7 +734,6 @@ rpc_unlink(char *path)
732 d_drop(dentry); 734 d_drop(dentry);
733 if (dentry->d_inode) { 735 if (dentry->d_inode) {
734 rpc_close_pipes(dentry->d_inode); 736 rpc_close_pipes(dentry->d_inode);
735 rpc_inode_setowner(dentry->d_inode, NULL);
736 error = simple_unlink(dir, dentry); 737 error = simple_unlink(dir, dentry);
737 } 738 }
738 dput(dentry); 739 dput(dentry);
diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c
new file mode 100644
index 000000000000..8f97e90f36c8
--- /dev/null
+++ b/net/sunrpc/socklib.c
@@ -0,0 +1,175 @@
1/*
2 * linux/net/sunrpc/socklib.c
3 *
4 * Common socket helper routines for RPC client and server
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
8
9#include <linux/types.h>
10#include <linux/pagemap.h>
11#include <linux/udp.h>
12#include <linux/sunrpc/xdr.h>
13
14
15/**
16 * skb_read_bits - copy some data bits from skb to internal buffer
17 * @desc: sk_buff copy helper
18 * @to: copy destination
19 * @len: number of bytes to copy
20 *
21 * Possibly called several times to iterate over an sk_buff and copy
22 * data out of it.
23 */
24static size_t skb_read_bits(skb_reader_t *desc, void *to, size_t len)
25{
26 if (len > desc->count)
27 len = desc->count;
28 if (skb_copy_bits(desc->skb, desc->offset, to, len))
29 return 0;
30 desc->count -= len;
31 desc->offset += len;
32 return len;
33}
34
35/**
36 * skb_read_and_csum_bits - copy and checksum from skb to buffer
37 * @desc: sk_buff copy helper
38 * @to: copy destination
39 * @len: number of bytes to copy
40 *
41 * Same as skb_read_bits, but calculate a checksum at the same time.
42 */
43static size_t skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len)
44{
45 unsigned int csum2, pos;
46
47 if (len > desc->count)
48 len = desc->count;
49 pos = desc->offset;
50 csum2 = skb_copy_and_csum_bits(desc->skb, pos, to, len, 0);
51 desc->csum = csum_block_add(desc->csum, csum2, pos);
52 desc->count -= len;
53 desc->offset += len;
54 return len;
55}
56
57/**
58 * xdr_partial_copy_from_skb - copy data out of an skb
59 * @xdr: target XDR buffer
60 * @base: starting offset
61 * @desc: sk_buff copy helper
62 * @copy_actor: virtual method for copying data
63 *
64 */
65ssize_t xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base, skb_reader_t *desc, skb_read_actor_t copy_actor)
66{
67 struct page **ppage = xdr->pages;
68 unsigned int len, pglen = xdr->page_len;
69 ssize_t copied = 0;
70 int ret;
71
72 len = xdr->head[0].iov_len;
73 if (base < len) {
74 len -= base;
75 ret = copy_actor(desc, (char *)xdr->head[0].iov_base + base, len);
76 copied += ret;
77 if (ret != len || !desc->count)
78 goto out;
79 base = 0;
80 } else
81 base -= len;
82
83 if (unlikely(pglen == 0))
84 goto copy_tail;
85 if (unlikely(base >= pglen)) {
86 base -= pglen;
87 goto copy_tail;
88 }
89 if (base || xdr->page_base) {
90 pglen -= base;
91 base += xdr->page_base;
92 ppage += base >> PAGE_CACHE_SHIFT;
93 base &= ~PAGE_CACHE_MASK;
94 }
95 do {
96 char *kaddr;
97
98 /* ACL likes to be lazy in allocating pages - ACLs
99 * are small by default but can get huge. */
100 if (unlikely(*ppage == NULL)) {
101 *ppage = alloc_page(GFP_ATOMIC);
102 if (unlikely(*ppage == NULL)) {
103 if (copied == 0)
104 copied = -ENOMEM;
105 goto out;
106 }
107 }
108
109 len = PAGE_CACHE_SIZE;
110 kaddr = kmap_atomic(*ppage, KM_SKB_SUNRPC_DATA);
111 if (base) {
112 len -= base;
113 if (pglen < len)
114 len = pglen;
115 ret = copy_actor(desc, kaddr + base, len);
116 base = 0;
117 } else {
118 if (pglen < len)
119 len = pglen;
120 ret = copy_actor(desc, kaddr, len);
121 }
122 flush_dcache_page(*ppage);
123 kunmap_atomic(kaddr, KM_SKB_SUNRPC_DATA);
124 copied += ret;
125 if (ret != len || !desc->count)
126 goto out;
127 ppage++;
128 } while ((pglen -= len) != 0);
129copy_tail:
130 len = xdr->tail[0].iov_len;
131 if (base < len)
132 copied += copy_actor(desc, (char *)xdr->tail[0].iov_base + base, len - base);
133out:
134 return copied;
135}
136
137/**
138 * csum_partial_copy_to_xdr - checksum and copy data
139 * @xdr: target XDR buffer
140 * @skb: source skb
141 *
142 * We have set things up such that we perform the checksum of the UDP
143 * packet in parallel with the copies into the RPC client iovec. -DaveM
144 */
145int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
146{
147 skb_reader_t desc;
148
149 desc.skb = skb;
150 desc.offset = sizeof(struct udphdr);
151 desc.count = skb->len - desc.offset;
152
153 if (skb->ip_summed == CHECKSUM_UNNECESSARY)
154 goto no_checksum;
155
156 desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
157 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0)
158 return -1;
159 if (desc.offset != skb->len) {
160 unsigned int csum2;
161 csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
162 desc.csum = csum_block_add(desc.csum, csum2, desc.offset);
163 }
164 if (desc.count)
165 return -1;
166 if ((unsigned short)csum_fold(desc.csum))
167 return -1;
168 return 0;
169no_checksum:
170 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_bits) < 0)
171 return -1;
172 if (desc.count)
173 return -1;
174 return 0;
175}
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index ed48ff022d35..2387e7b823ff 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -10,7 +10,6 @@
10#include <linux/module.h> 10#include <linux/module.h>
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/socket.h>
14#include <linux/sched.h> 13#include <linux/sched.h>
15#include <linux/uio.h> 14#include <linux/uio.h>
16#include <linux/unistd.h> 15#include <linux/unistd.h>
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 691dea4a58e7..f16e7cdd6150 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -548,9 +548,6 @@ svc_write_space(struct sock *sk)
548/* 548/*
549 * Receive a datagram from a UDP socket. 549 * Receive a datagram from a UDP socket.
550 */ 550 */
551extern int
552csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb);
553
554static int 551static int
555svc_udp_recvfrom(struct svc_rqst *rqstp) 552svc_udp_recvfrom(struct svc_rqst *rqstp)
556{ 553{
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 1b9616a12e24..d0c9f460e411 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -119,8 +119,18 @@ done:
119 return 0; 119 return 0;
120} 120}
121 121
122unsigned int xprt_udp_slot_table_entries = RPC_DEF_SLOT_TABLE;
123unsigned int xprt_tcp_slot_table_entries = RPC_DEF_SLOT_TABLE;
124unsigned int xprt_min_resvport = RPC_DEF_MIN_RESVPORT;
125EXPORT_SYMBOL(xprt_min_resvport);
126unsigned int xprt_max_resvport = RPC_DEF_MAX_RESVPORT;
127EXPORT_SYMBOL(xprt_max_resvport);
128
129
122static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE; 130static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
123static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE; 131static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
132static unsigned int xprt_min_resvport_limit = RPC_MIN_RESVPORT;
133static unsigned int xprt_max_resvport_limit = RPC_MAX_RESVPORT;
124 134
125static ctl_table debug_table[] = { 135static ctl_table debug_table[] = {
126 { 136 {
@@ -177,6 +187,28 @@ static ctl_table debug_table[] = {
177 .extra1 = &min_slot_table_size, 187 .extra1 = &min_slot_table_size,
178 .extra2 = &max_slot_table_size 188 .extra2 = &max_slot_table_size
179 }, 189 },
190 {
191 .ctl_name = CTL_MIN_RESVPORT,
192 .procname = "min_resvport",
193 .data = &xprt_min_resvport,
194 .maxlen = sizeof(unsigned int),
195 .mode = 0644,
196 .proc_handler = &proc_dointvec_minmax,
197 .strategy = &sysctl_intvec,
198 .extra1 = &xprt_min_resvport_limit,
199 .extra2 = &xprt_max_resvport_limit
200 },
201 {
202 .ctl_name = CTL_MAX_RESVPORT,
203 .procname = "max_resvport",
204 .data = &xprt_max_resvport,
205 .maxlen = sizeof(unsigned int),
206 .mode = 0644,
207 .proc_handler = &proc_dointvec_minmax,
208 .strategy = &sysctl_intvec,
209 .extra1 = &xprt_min_resvport_limit,
210 .extra2 = &xprt_max_resvport_limit
211 },
180 { .ctl_name = 0 } 212 { .ctl_name = 0 }
181}; 213};
182 214
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index fde16f40a581..32df43372ee9 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -6,15 +6,12 @@
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */ 7 */
8 8
9#include <linux/module.h>
9#include <linux/types.h> 10#include <linux/types.h>
10#include <linux/socket.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/pagemap.h> 13#include <linux/pagemap.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/in.h>
16#include <linux/net.h>
17#include <net/sock.h>
18#include <linux/sunrpc/xdr.h> 15#include <linux/sunrpc/xdr.h>
19#include <linux/sunrpc/msg_prot.h> 16#include <linux/sunrpc/msg_prot.h>
20 17
@@ -176,178 +173,6 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset,
176 xdr->buflen += len; 173 xdr->buflen += len;
177} 174}
178 175
179ssize_t
180xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base,
181 skb_reader_t *desc,
182 skb_read_actor_t copy_actor)
183{
184 struct page **ppage = xdr->pages;
185 unsigned int len, pglen = xdr->page_len;
186 ssize_t copied = 0;
187 int ret;
188
189 len = xdr->head[0].iov_len;
190 if (base < len) {
191 len -= base;
192 ret = copy_actor(desc, (char *)xdr->head[0].iov_base + base, len);
193 copied += ret;
194 if (ret != len || !desc->count)
195 goto out;
196 base = 0;
197 } else
198 base -= len;
199
200 if (pglen == 0)
201 goto copy_tail;
202 if (base >= pglen) {
203 base -= pglen;
204 goto copy_tail;
205 }
206 if (base || xdr->page_base) {
207 pglen -= base;
208 base += xdr->page_base;
209 ppage += base >> PAGE_CACHE_SHIFT;
210 base &= ~PAGE_CACHE_MASK;
211 }
212 do {
213 char *kaddr;
214
215 /* ACL likes to be lazy in allocating pages - ACLs
216 * are small by default but can get huge. */
217 if (unlikely(*ppage == NULL)) {
218 *ppage = alloc_page(GFP_ATOMIC);
219 if (unlikely(*ppage == NULL)) {
220 if (copied == 0)
221 copied = -ENOMEM;
222 goto out;
223 }
224 }
225
226 len = PAGE_CACHE_SIZE;
227 kaddr = kmap_atomic(*ppage, KM_SKB_SUNRPC_DATA);
228 if (base) {
229 len -= base;
230 if (pglen < len)
231 len = pglen;
232 ret = copy_actor(desc, kaddr + base, len);
233 base = 0;
234 } else {
235 if (pglen < len)
236 len = pglen;
237 ret = copy_actor(desc, kaddr, len);
238 }
239 flush_dcache_page(*ppage);
240 kunmap_atomic(kaddr, KM_SKB_SUNRPC_DATA);
241 copied += ret;
242 if (ret != len || !desc->count)
243 goto out;
244 ppage++;
245 } while ((pglen -= len) != 0);
246copy_tail:
247 len = xdr->tail[0].iov_len;
248 if (base < len)
249 copied += copy_actor(desc, (char *)xdr->tail[0].iov_base + base, len - base);
250out:
251 return copied;
252}
253
254
255int
256xdr_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
257 struct xdr_buf *xdr, unsigned int base, int msgflags)
258{
259 struct page **ppage = xdr->pages;
260 unsigned int len, pglen = xdr->page_len;
261 int err, ret = 0;
262 ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
263
264 len = xdr->head[0].iov_len;
265 if (base < len || (addr != NULL && base == 0)) {
266 struct kvec iov = {
267 .iov_base = xdr->head[0].iov_base + base,
268 .iov_len = len - base,
269 };
270 struct msghdr msg = {
271 .msg_name = addr,
272 .msg_namelen = addrlen,
273 .msg_flags = msgflags,
274 };
275 if (xdr->len > len)
276 msg.msg_flags |= MSG_MORE;
277
278 if (iov.iov_len != 0)
279 err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
280 else
281 err = kernel_sendmsg(sock, &msg, NULL, 0, 0);
282 if (ret == 0)
283 ret = err;
284 else if (err > 0)
285 ret += err;
286 if (err != iov.iov_len)
287 goto out;
288 base = 0;
289 } else
290 base -= len;
291
292 if (pglen == 0)
293 goto copy_tail;
294 if (base >= pglen) {
295 base -= pglen;
296 goto copy_tail;
297 }
298 if (base || xdr->page_base) {
299 pglen -= base;
300 base += xdr->page_base;
301 ppage += base >> PAGE_CACHE_SHIFT;
302 base &= ~PAGE_CACHE_MASK;
303 }
304
305 sendpage = sock->ops->sendpage ? : sock_no_sendpage;
306 do {
307 int flags = msgflags;
308
309 len = PAGE_CACHE_SIZE;
310 if (base)
311 len -= base;
312 if (pglen < len)
313 len = pglen;
314
315 if (pglen != len || xdr->tail[0].iov_len != 0)
316 flags |= MSG_MORE;
317
318 /* Hmm... We might be dealing with highmem pages */
319 if (PageHighMem(*ppage))
320 sendpage = sock_no_sendpage;
321 err = sendpage(sock, *ppage, base, len, flags);
322 if (ret == 0)
323 ret = err;
324 else if (err > 0)
325 ret += err;
326 if (err != len)
327 goto out;
328 base = 0;
329 ppage++;
330 } while ((pglen -= len) != 0);
331copy_tail:
332 len = xdr->tail[0].iov_len;
333 if (base < len) {
334 struct kvec iov = {
335 .iov_base = xdr->tail[0].iov_base + base,
336 .iov_len = len - base,
337 };
338 struct msghdr msg = {
339 .msg_flags = msgflags,
340 };
341 err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
342 if (ret == 0)
343 ret = err;
344 else if (err > 0)
345 ret += err;
346 }
347out:
348 return ret;
349}
350
351 176
352/* 177/*
353 * Helper routines for doing 'memmove' like operations on a struct xdr_buf 178 * Helper routines for doing 'memmove' like operations on a struct xdr_buf
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 3c654e06b084..6dda3860351f 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -10,12 +10,12 @@
10 * one is available. Otherwise, it sleeps on the backlog queue 10 * one is available. Otherwise, it sleeps on the backlog queue
11 * (xprt_reserve). 11 * (xprt_reserve).
12 * - Next, the caller puts together the RPC message, stuffs it into 12 * - Next, the caller puts together the RPC message, stuffs it into
13 * the request struct, and calls xprt_call(). 13 * the request struct, and calls xprt_transmit().
14 * - xprt_call transmits the message and installs the caller on the 14 * - xprt_transmit sends the message and installs the caller on the
15 * socket's wait list. At the same time, it installs a timer that 15 * transport's wait list. At the same time, it installs a timer that
16 * is run after the packet's timeout has expired. 16 * is run after the packet's timeout has expired.
17 * - When a packet arrives, the data_ready handler walks the list of 17 * - When a packet arrives, the data_ready handler walks the list of
18 * pending requests for that socket. If a matching XID is found, the 18 * pending requests for that transport. If a matching XID is found, the
19 * caller is woken up, and the timer removed. 19 * caller is woken up, and the timer removed.
20 * - When no reply arrives within the timeout interval, the timer is 20 * - When no reply arrives within the timeout interval, the timer is
21 * fired by the kernel and runs xprt_timer(). It either adjusts the 21 * fired by the kernel and runs xprt_timer(). It either adjusts the
@@ -33,36 +33,17 @@
33 * 33 *
34 * Copyright (C) 1995-1997, Olaf Kirch <okir@monad.swb.de> 34 * Copyright (C) 1995-1997, Olaf Kirch <okir@monad.swb.de>
35 * 35 *
36 * TCP callback races fixes (C) 1998 Red Hat Software <alan@redhat.com> 36 * Transport switch API copyright (C) 2005, Chuck Lever <cel@netapp.com>
37 * TCP send fixes (C) 1998 Red Hat Software <alan@redhat.com>
38 * TCP NFS related read + write fixes
39 * (C) 1999 Dave Airlie, University of Limerick, Ireland <airlied@linux.ie>
40 *
41 * Rewrite of larges part of the code in order to stabilize TCP stuff.
42 * Fix behaviour when socket buffer is full.
43 * (C) 1999 Trond Myklebust <trond.myklebust@fys.uio.no>
44 */ 37 */
45 38
39#include <linux/module.h>
40
46#include <linux/types.h> 41#include <linux/types.h>
47#include <linux/slab.h> 42#include <linux/interrupt.h>
48#include <linux/capability.h>
49#include <linux/sched.h>
50#include <linux/errno.h>
51#include <linux/socket.h>
52#include <linux/in.h>
53#include <linux/net.h>
54#include <linux/mm.h>
55#include <linux/udp.h>
56#include <linux/tcp.h>
57#include <linux/sunrpc/clnt.h>
58#include <linux/file.h>
59#include <linux/workqueue.h> 43#include <linux/workqueue.h>
60#include <linux/random.h> 44#include <linux/random.h>
61 45
62#include <net/sock.h> 46#include <linux/sunrpc/clnt.h>
63#include <net/checksum.h>
64#include <net/udp.h>
65#include <net/tcp.h>
66 47
67/* 48/*
68 * Local variables 49 * Local variables
@@ -73,81 +54,90 @@
73# define RPCDBG_FACILITY RPCDBG_XPRT 54# define RPCDBG_FACILITY RPCDBG_XPRT
74#endif 55#endif
75 56
76#define XPRT_MAX_BACKOFF (8)
77#define XPRT_IDLE_TIMEOUT (5*60*HZ)
78#define XPRT_MAX_RESVPORT (800)
79
80/* 57/*
81 * Local functions 58 * Local functions
82 */ 59 */
83static void xprt_request_init(struct rpc_task *, struct rpc_xprt *); 60static void xprt_request_init(struct rpc_task *, struct rpc_xprt *);
84static inline void do_xprt_reserve(struct rpc_task *); 61static inline void do_xprt_reserve(struct rpc_task *);
85static void xprt_disconnect(struct rpc_xprt *);
86static void xprt_connect_status(struct rpc_task *task); 62static void xprt_connect_status(struct rpc_task *task);
87static struct rpc_xprt * xprt_setup(int proto, struct sockaddr_in *ap,
88 struct rpc_timeout *to);
89static struct socket *xprt_create_socket(struct rpc_xprt *, int, int);
90static void xprt_bind_socket(struct rpc_xprt *, struct socket *);
91static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *); 63static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *);
92 64
93static int xprt_clear_backlog(struct rpc_xprt *xprt);
94
95#ifdef RPC_DEBUG_DATA
96/* 65/*
97 * Print the buffer contents (first 128 bytes only--just enough for 66 * The transport code maintains an estimate on the maximum number of out-
98 * diropres return). 67 * standing RPC requests, using a smoothed version of the congestion
68 * avoidance implemented in 44BSD. This is basically the Van Jacobson
69 * congestion algorithm: If a retransmit occurs, the congestion window is
70 * halved; otherwise, it is incremented by 1/cwnd when
71 *
72 * - a reply is received and
73 * - a full number of requests are outstanding and
74 * - the congestion window hasn't been updated recently.
99 */ 75 */
100static void 76#define RPC_CWNDSHIFT (8U)
101xprt_pktdump(char *msg, u32 *packet, unsigned int count) 77#define RPC_CWNDSCALE (1U << RPC_CWNDSHIFT)
102{ 78#define RPC_INITCWND RPC_CWNDSCALE
103 u8 *buf = (u8 *) packet; 79#define RPC_MAXCWND(xprt) ((xprt)->max_reqs << RPC_CWNDSHIFT)
104 int j;
105
106 dprintk("RPC: %s\n", msg);
107 for (j = 0; j < count && j < 128; j += 4) {
108 if (!(j & 31)) {
109 if (j)
110 dprintk("\n");
111 dprintk("0x%04x ", j);
112 }
113 dprintk("%02x%02x%02x%02x ",
114 buf[j], buf[j+1], buf[j+2], buf[j+3]);
115 }
116 dprintk("\n");
117}
118#else
119static inline void
120xprt_pktdump(char *msg, u32 *packet, unsigned int count)
121{
122 /* NOP */
123}
124#endif
125 80
126/* 81#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
127 * Look up RPC transport given an INET socket 82
83/**
84 * xprt_reserve_xprt - serialize write access to transports
85 * @task: task that is requesting access to the transport
86 *
87 * This prevents mixing the payload of separate requests, and prevents
88 * transport connects from colliding with writes. No congestion control
89 * is provided.
128 */ 90 */
129static inline struct rpc_xprt * 91int xprt_reserve_xprt(struct rpc_task *task)
130xprt_from_sock(struct sock *sk)
131{ 92{
132 return (struct rpc_xprt *) sk->sk_user_data; 93 struct rpc_xprt *xprt = task->tk_xprt;
94 struct rpc_rqst *req = task->tk_rqstp;
95
96 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) {
97 if (task == xprt->snd_task)
98 return 1;
99 if (task == NULL)
100 return 0;
101 goto out_sleep;
102 }
103 xprt->snd_task = task;
104 if (req) {
105 req->rq_bytes_sent = 0;
106 req->rq_ntrans++;
107 }
108 return 1;
109
110out_sleep:
111 dprintk("RPC: %4d failed to lock transport %p\n",
112 task->tk_pid, xprt);
113 task->tk_timeout = 0;
114 task->tk_status = -EAGAIN;
115 if (req && req->rq_ntrans)
116 rpc_sleep_on(&xprt->resend, task, NULL, NULL);
117 else
118 rpc_sleep_on(&xprt->sending, task, NULL, NULL);
119 return 0;
133} 120}
134 121
135/* 122/*
136 * Serialize write access to sockets, in order to prevent different 123 * xprt_reserve_xprt_cong - serialize write access to transports
137 * requests from interfering with each other. 124 * @task: task that is requesting access to the transport
138 * Also prevents TCP socket connects from colliding with writes. 125 *
126 * Same as xprt_reserve_xprt, but Van Jacobson congestion control is
127 * integrated into the decision of whether a request is allowed to be
128 * woken up and given access to the transport.
139 */ 129 */
140static int 130int xprt_reserve_xprt_cong(struct rpc_task *task)
141__xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
142{ 131{
132 struct rpc_xprt *xprt = task->tk_xprt;
143 struct rpc_rqst *req = task->tk_rqstp; 133 struct rpc_rqst *req = task->tk_rqstp;
144 134
145 if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) { 135 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) {
146 if (task == xprt->snd_task) 136 if (task == xprt->snd_task)
147 return 1; 137 return 1;
148 goto out_sleep; 138 goto out_sleep;
149 } 139 }
150 if (xprt->nocong || __xprt_get_cong(xprt, task)) { 140 if (__xprt_get_cong(xprt, task)) {
151 xprt->snd_task = task; 141 xprt->snd_task = task;
152 if (req) { 142 if (req) {
153 req->rq_bytes_sent = 0; 143 req->rq_bytes_sent = 0;
@@ -156,10 +146,10 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
156 return 1; 146 return 1;
157 } 147 }
158 smp_mb__before_clear_bit(); 148 smp_mb__before_clear_bit();
159 clear_bit(XPRT_LOCKED, &xprt->sockstate); 149 clear_bit(XPRT_LOCKED, &xprt->state);
160 smp_mb__after_clear_bit(); 150 smp_mb__after_clear_bit();
161out_sleep: 151out_sleep:
162 dprintk("RPC: %4d failed to lock socket %p\n", task->tk_pid, xprt); 152 dprintk("RPC: %4d failed to lock transport %p\n", task->tk_pid, xprt);
163 task->tk_timeout = 0; 153 task->tk_timeout = 0;
164 task->tk_status = -EAGAIN; 154 task->tk_status = -EAGAIN;
165 if (req && req->rq_ntrans) 155 if (req && req->rq_ntrans)
@@ -169,26 +159,52 @@ out_sleep:
169 return 0; 159 return 0;
170} 160}
171 161
172static inline int 162static inline int xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
173xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
174{ 163{
175 int retval; 164 int retval;
176 165
177 spin_lock_bh(&xprt->sock_lock); 166 spin_lock_bh(&xprt->transport_lock);
178 retval = __xprt_lock_write(xprt, task); 167 retval = xprt->ops->reserve_xprt(task);
179 spin_unlock_bh(&xprt->sock_lock); 168 spin_unlock_bh(&xprt->transport_lock);
180 return retval; 169 return retval;
181} 170}
182 171
172static void __xprt_lock_write_next(struct rpc_xprt *xprt)
173{
174 struct rpc_task *task;
175 struct rpc_rqst *req;
183 176
184static void 177 if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
185__xprt_lock_write_next(struct rpc_xprt *xprt) 178 return;
179
180 task = rpc_wake_up_next(&xprt->resend);
181 if (!task) {
182 task = rpc_wake_up_next(&xprt->sending);
183 if (!task)
184 goto out_unlock;
185 }
186
187 req = task->tk_rqstp;
188 xprt->snd_task = task;
189 if (req) {
190 req->rq_bytes_sent = 0;
191 req->rq_ntrans++;
192 }
193 return;
194
195out_unlock:
196 smp_mb__before_clear_bit();
197 clear_bit(XPRT_LOCKED, &xprt->state);
198 smp_mb__after_clear_bit();
199}
200
201static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt)
186{ 202{
187 struct rpc_task *task; 203 struct rpc_task *task;
188 204
189 if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) 205 if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
190 return; 206 return;
191 if (!xprt->nocong && RPCXPRT_CONGESTED(xprt)) 207 if (RPCXPRT_CONGESTED(xprt))
192 goto out_unlock; 208 goto out_unlock;
193 task = rpc_wake_up_next(&xprt->resend); 209 task = rpc_wake_up_next(&xprt->resend);
194 if (!task) { 210 if (!task) {
@@ -196,7 +212,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt)
196 if (!task) 212 if (!task)
197 goto out_unlock; 213 goto out_unlock;
198 } 214 }
199 if (xprt->nocong || __xprt_get_cong(xprt, task)) { 215 if (__xprt_get_cong(xprt, task)) {
200 struct rpc_rqst *req = task->tk_rqstp; 216 struct rpc_rqst *req = task->tk_rqstp;
201 xprt->snd_task = task; 217 xprt->snd_task = task;
202 if (req) { 218 if (req) {
@@ -207,87 +223,52 @@ __xprt_lock_write_next(struct rpc_xprt *xprt)
207 } 223 }
208out_unlock: 224out_unlock:
209 smp_mb__before_clear_bit(); 225 smp_mb__before_clear_bit();
210 clear_bit(XPRT_LOCKED, &xprt->sockstate); 226 clear_bit(XPRT_LOCKED, &xprt->state);
211 smp_mb__after_clear_bit(); 227 smp_mb__after_clear_bit();
212} 228}
213 229
214/* 230/**
215 * Releases the socket for use by other requests. 231 * xprt_release_xprt - allow other requests to use a transport
232 * @xprt: transport with other tasks potentially waiting
233 * @task: task that is releasing access to the transport
234 *
235 * Note that "task" can be NULL. No congestion control is provided.
216 */ 236 */
217static void 237void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
218__xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
219{ 238{
220 if (xprt->snd_task == task) { 239 if (xprt->snd_task == task) {
221 xprt->snd_task = NULL; 240 xprt->snd_task = NULL;
222 smp_mb__before_clear_bit(); 241 smp_mb__before_clear_bit();
223 clear_bit(XPRT_LOCKED, &xprt->sockstate); 242 clear_bit(XPRT_LOCKED, &xprt->state);
224 smp_mb__after_clear_bit(); 243 smp_mb__after_clear_bit();
225 __xprt_lock_write_next(xprt); 244 __xprt_lock_write_next(xprt);
226 } 245 }
227} 246}
228 247
229static inline void 248/**
230xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task) 249 * xprt_release_xprt_cong - allow other requests to use a transport
231{ 250 * @xprt: transport with other tasks potentially waiting
232 spin_lock_bh(&xprt->sock_lock); 251 * @task: task that is releasing access to the transport
233 __xprt_release_write(xprt, task); 252 *
234 spin_unlock_bh(&xprt->sock_lock); 253 * Note that "task" can be NULL. Another task is awoken to use the
235} 254 * transport if the transport's congestion window allows it.
236
237/*
238 * Write data to socket.
239 */ 255 */
240static inline int 256void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task)
241xprt_sendmsg(struct rpc_xprt *xprt, struct rpc_rqst *req)
242{ 257{
243 struct socket *sock = xprt->sock; 258 if (xprt->snd_task == task) {
244 struct xdr_buf *xdr = &req->rq_snd_buf; 259 xprt->snd_task = NULL;
245 struct sockaddr *addr = NULL; 260 smp_mb__before_clear_bit();
246 int addrlen = 0; 261 clear_bit(XPRT_LOCKED, &xprt->state);
247 unsigned int skip; 262 smp_mb__after_clear_bit();
248 int result; 263 __xprt_lock_write_next_cong(xprt);
249
250 if (!sock)
251 return -ENOTCONN;
252
253 xprt_pktdump("packet data:",
254 req->rq_svec->iov_base,
255 req->rq_svec->iov_len);
256
257 /* For UDP, we need to provide an address */
258 if (!xprt->stream) {
259 addr = (struct sockaddr *) &xprt->addr;
260 addrlen = sizeof(xprt->addr);
261 } 264 }
262 /* Dont repeat bytes */ 265}
263 skip = req->rq_bytes_sent;
264
265 clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
266 result = xdr_sendpages(sock, addr, addrlen, xdr, skip, MSG_DONTWAIT);
267
268 dprintk("RPC: xprt_sendmsg(%d) = %d\n", xdr->len - skip, result);
269
270 if (result >= 0)
271 return result;
272 266
273 switch (result) { 267static inline void xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
274 case -ECONNREFUSED: 268{
275 /* When the server has died, an ICMP port unreachable message 269 spin_lock_bh(&xprt->transport_lock);
276 * prompts ECONNREFUSED. 270 xprt->ops->release_xprt(xprt, task);
277 */ 271 spin_unlock_bh(&xprt->transport_lock);
278 case -EAGAIN:
279 break;
280 case -ECONNRESET:
281 case -ENOTCONN:
282 case -EPIPE:
283 /* connection broken */
284 if (xprt->stream)
285 result = -ENOTCONN;
286 break;
287 default:
288 printk(KERN_NOTICE "RPC: sendmsg returned error %d\n", -result);
289 }
290 return result;
291} 272}
292 273
293/* 274/*
@@ -321,26 +302,40 @@ __xprt_put_cong(struct rpc_xprt *xprt, struct rpc_rqst *req)
321 return; 302 return;
322 req->rq_cong = 0; 303 req->rq_cong = 0;
323 xprt->cong -= RPC_CWNDSCALE; 304 xprt->cong -= RPC_CWNDSCALE;
324 __xprt_lock_write_next(xprt); 305 __xprt_lock_write_next_cong(xprt);
325} 306}
326 307
327/* 308/**
328 * Adjust RPC congestion window 309 * xprt_release_rqst_cong - housekeeping when request is complete
310 * @task: RPC request that recently completed
311 *
312 * Useful for transports that require congestion control.
313 */
314void xprt_release_rqst_cong(struct rpc_task *task)
315{
316 __xprt_put_cong(task->tk_xprt, task->tk_rqstp);
317}
318
319/**
320 * xprt_adjust_cwnd - adjust transport congestion window
321 * @task: recently completed RPC request used to adjust window
322 * @result: result code of completed RPC request
323 *
329 * We use a time-smoothed congestion estimator to avoid heavy oscillation. 324 * We use a time-smoothed congestion estimator to avoid heavy oscillation.
330 */ 325 */
331static void 326void xprt_adjust_cwnd(struct rpc_task *task, int result)
332xprt_adjust_cwnd(struct rpc_xprt *xprt, int result)
333{ 327{
334 unsigned long cwnd; 328 struct rpc_rqst *req = task->tk_rqstp;
329 struct rpc_xprt *xprt = task->tk_xprt;
330 unsigned long cwnd = xprt->cwnd;
335 331
336 cwnd = xprt->cwnd;
337 if (result >= 0 && cwnd <= xprt->cong) { 332 if (result >= 0 && cwnd <= xprt->cong) {
338 /* The (cwnd >> 1) term makes sure 333 /* The (cwnd >> 1) term makes sure
339 * the result gets rounded properly. */ 334 * the result gets rounded properly. */
340 cwnd += (RPC_CWNDSCALE * RPC_CWNDSCALE + (cwnd >> 1)) / cwnd; 335 cwnd += (RPC_CWNDSCALE * RPC_CWNDSCALE + (cwnd >> 1)) / cwnd;
341 if (cwnd > RPC_MAXCWND(xprt)) 336 if (cwnd > RPC_MAXCWND(xprt))
342 cwnd = RPC_MAXCWND(xprt); 337 cwnd = RPC_MAXCWND(xprt);
343 __xprt_lock_write_next(xprt); 338 __xprt_lock_write_next_cong(xprt);
344 } else if (result == -ETIMEDOUT) { 339 } else if (result == -ETIMEDOUT) {
345 cwnd >>= 1; 340 cwnd >>= 1;
346 if (cwnd < RPC_CWNDSCALE) 341 if (cwnd < RPC_CWNDSCALE)
@@ -349,11 +344,89 @@ xprt_adjust_cwnd(struct rpc_xprt *xprt, int result)
349 dprintk("RPC: cong %ld, cwnd was %ld, now %ld\n", 344 dprintk("RPC: cong %ld, cwnd was %ld, now %ld\n",
350 xprt->cong, xprt->cwnd, cwnd); 345 xprt->cong, xprt->cwnd, cwnd);
351 xprt->cwnd = cwnd; 346 xprt->cwnd = cwnd;
347 __xprt_put_cong(xprt, req);
348}
349
350/**
351 * xprt_wake_pending_tasks - wake all tasks on a transport's pending queue
352 * @xprt: transport with waiting tasks
353 * @status: result code to plant in each task before waking it
354 *
355 */
356void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status)
357{
358 if (status < 0)
359 rpc_wake_up_status(&xprt->pending, status);
360 else
361 rpc_wake_up(&xprt->pending);
362}
363
364/**
365 * xprt_wait_for_buffer_space - wait for transport output buffer to clear
366 * @task: task to be put to sleep
367 *
368 */
369void xprt_wait_for_buffer_space(struct rpc_task *task)
370{
371 struct rpc_rqst *req = task->tk_rqstp;
372 struct rpc_xprt *xprt = req->rq_xprt;
373
374 task->tk_timeout = req->rq_timeout;
375 rpc_sleep_on(&xprt->pending, task, NULL, NULL);
376}
377
378/**
379 * xprt_write_space - wake the task waiting for transport output buffer space
380 * @xprt: transport with waiting tasks
381 *
382 * Can be called in a soft IRQ context, so xprt_write_space never sleeps.
383 */
384void xprt_write_space(struct rpc_xprt *xprt)
385{
386 if (unlikely(xprt->shutdown))
387 return;
388
389 spin_lock_bh(&xprt->transport_lock);
390 if (xprt->snd_task) {
391 dprintk("RPC: write space: waking waiting task on xprt %p\n",
392 xprt);
393 rpc_wake_up_task(xprt->snd_task);
394 }
395 spin_unlock_bh(&xprt->transport_lock);
396}
397
398/**
399 * xprt_set_retrans_timeout_def - set a request's retransmit timeout
400 * @task: task whose timeout is to be set
401 *
402 * Set a request's retransmit timeout based on the transport's
403 * default timeout parameters. Used by transports that don't adjust
404 * the retransmit timeout based on round-trip time estimation.
405 */
406void xprt_set_retrans_timeout_def(struct rpc_task *task)
407{
408 task->tk_timeout = task->tk_rqstp->rq_timeout;
352} 409}
353 410
354/* 411/*
355 * Reset the major timeout value 412 * xprt_set_retrans_timeout_rtt - set a request's retransmit timeout
413 * @task: task whose timeout is to be set
414 *
415 * Set a request's retransmit timeout using the RTT estimator.
356 */ 416 */
417void xprt_set_retrans_timeout_rtt(struct rpc_task *task)
418{
419 int timer = task->tk_msg.rpc_proc->p_timer;
420 struct rpc_rtt *rtt = task->tk_client->cl_rtt;
421 struct rpc_rqst *req = task->tk_rqstp;
422 unsigned long max_timeout = req->rq_xprt->timeout.to_maxval;
423
424 task->tk_timeout = rpc_calc_rto(rtt, timer);
425 task->tk_timeout <<= rpc_ntimeo(rtt, timer) + req->rq_retries;
426 if (task->tk_timeout > max_timeout || task->tk_timeout == 0)
427 task->tk_timeout = max_timeout;
428}
429
357static void xprt_reset_majortimeo(struct rpc_rqst *req) 430static void xprt_reset_majortimeo(struct rpc_rqst *req)
358{ 431{
359 struct rpc_timeout *to = &req->rq_xprt->timeout; 432 struct rpc_timeout *to = &req->rq_xprt->timeout;
@@ -368,8 +441,10 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req)
368 req->rq_majortimeo += jiffies; 441 req->rq_majortimeo += jiffies;
369} 442}
370 443
371/* 444/**
372 * Adjust timeout values etc for next retransmit 445 * xprt_adjust_timeout - adjust timeout values for next retransmit
446 * @req: RPC request containing parameters to use for the adjustment
447 *
373 */ 448 */
374int xprt_adjust_timeout(struct rpc_rqst *req) 449int xprt_adjust_timeout(struct rpc_rqst *req)
375{ 450{
@@ -391,9 +466,9 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
391 req->rq_retries = 0; 466 req->rq_retries = 0;
392 xprt_reset_majortimeo(req); 467 xprt_reset_majortimeo(req);
393 /* Reset the RTT counters == "slow start" */ 468 /* Reset the RTT counters == "slow start" */
394 spin_lock_bh(&xprt->sock_lock); 469 spin_lock_bh(&xprt->transport_lock);
395 rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval); 470 rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval);
396 spin_unlock_bh(&xprt->sock_lock); 471 spin_unlock_bh(&xprt->transport_lock);
397 pprintk("RPC: %lu timeout\n", jiffies); 472 pprintk("RPC: %lu timeout\n", jiffies);
398 status = -ETIMEDOUT; 473 status = -ETIMEDOUT;
399 } 474 }
@@ -405,133 +480,52 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
405 return status; 480 return status;
406} 481}
407 482
408/* 483static void xprt_autoclose(void *args)
409 * Close down a transport socket
410 */
411static void
412xprt_close(struct rpc_xprt *xprt)
413{
414 struct socket *sock = xprt->sock;
415 struct sock *sk = xprt->inet;
416
417 if (!sk)
418 return;
419
420 write_lock_bh(&sk->sk_callback_lock);
421 xprt->inet = NULL;
422 xprt->sock = NULL;
423
424 sk->sk_user_data = NULL;
425 sk->sk_data_ready = xprt->old_data_ready;
426 sk->sk_state_change = xprt->old_state_change;
427 sk->sk_write_space = xprt->old_write_space;
428 write_unlock_bh(&sk->sk_callback_lock);
429
430 sk->sk_no_check = 0;
431
432 sock_release(sock);
433}
434
435static void
436xprt_socket_autoclose(void *args)
437{ 484{
438 struct rpc_xprt *xprt = (struct rpc_xprt *)args; 485 struct rpc_xprt *xprt = (struct rpc_xprt *)args;
439 486
440 xprt_disconnect(xprt); 487 xprt_disconnect(xprt);
441 xprt_close(xprt); 488 xprt->ops->close(xprt);
442 xprt_release_write(xprt, NULL); 489 xprt_release_write(xprt, NULL);
443} 490}
444 491
445/* 492/**
446 * Mark a transport as disconnected 493 * xprt_disconnect - mark a transport as disconnected
494 * @xprt: transport to flag for disconnect
495 *
447 */ 496 */
448static void 497void xprt_disconnect(struct rpc_xprt *xprt)
449xprt_disconnect(struct rpc_xprt *xprt)
450{ 498{
451 dprintk("RPC: disconnected transport %p\n", xprt); 499 dprintk("RPC: disconnected transport %p\n", xprt);
452 spin_lock_bh(&xprt->sock_lock); 500 spin_lock_bh(&xprt->transport_lock);
453 xprt_clear_connected(xprt); 501 xprt_clear_connected(xprt);
454 rpc_wake_up_status(&xprt->pending, -ENOTCONN); 502 xprt_wake_pending_tasks(xprt, -ENOTCONN);
455 spin_unlock_bh(&xprt->sock_lock); 503 spin_unlock_bh(&xprt->transport_lock);
456} 504}
457 505
458/*
459 * Used to allow disconnection when we've been idle
460 */
461static void 506static void
462xprt_init_autodisconnect(unsigned long data) 507xprt_init_autodisconnect(unsigned long data)
463{ 508{
464 struct rpc_xprt *xprt = (struct rpc_xprt *)data; 509 struct rpc_xprt *xprt = (struct rpc_xprt *)data;
465 510
466 spin_lock(&xprt->sock_lock); 511 spin_lock(&xprt->transport_lock);
467 if (!list_empty(&xprt->recv) || xprt->shutdown) 512 if (!list_empty(&xprt->recv) || xprt->shutdown)
468 goto out_abort; 513 goto out_abort;
469 if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) 514 if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
470 goto out_abort; 515 goto out_abort;
471 spin_unlock(&xprt->sock_lock); 516 spin_unlock(&xprt->transport_lock);
472 /* Let keventd close the socket */ 517 if (xprt_connecting(xprt))
473 if (test_bit(XPRT_CONNECTING, &xprt->sockstate) != 0)
474 xprt_release_write(xprt, NULL); 518 xprt_release_write(xprt, NULL);
475 else 519 else
476 schedule_work(&xprt->task_cleanup); 520 schedule_work(&xprt->task_cleanup);
477 return; 521 return;
478out_abort: 522out_abort:
479 spin_unlock(&xprt->sock_lock); 523 spin_unlock(&xprt->transport_lock);
480}
481
482static void xprt_socket_connect(void *args)
483{
484 struct rpc_xprt *xprt = (struct rpc_xprt *)args;
485 struct socket *sock = xprt->sock;
486 int status = -EIO;
487
488 if (xprt->shutdown || xprt->addr.sin_port == 0)
489 goto out;
490
491 /*
492 * Start by resetting any existing state
493 */
494 xprt_close(xprt);
495 sock = xprt_create_socket(xprt, xprt->prot, xprt->resvport);
496 if (sock == NULL) {
497 /* couldn't create socket or bind to reserved port;
498 * this is likely a permanent error, so cause an abort */
499 goto out;
500 }
501 xprt_bind_socket(xprt, sock);
502 xprt_sock_setbufsize(xprt);
503
504 status = 0;
505 if (!xprt->stream)
506 goto out;
507
508 /*
509 * Tell the socket layer to start connecting...
510 */
511 status = sock->ops->connect(sock, (struct sockaddr *) &xprt->addr,
512 sizeof(xprt->addr), O_NONBLOCK);
513 dprintk("RPC: %p connect status %d connected %d sock state %d\n",
514 xprt, -status, xprt_connected(xprt), sock->sk->sk_state);
515 if (status < 0) {
516 switch (status) {
517 case -EINPROGRESS:
518 case -EALREADY:
519 goto out_clear;
520 }
521 }
522out:
523 if (status < 0)
524 rpc_wake_up_status(&xprt->pending, status);
525 else
526 rpc_wake_up(&xprt->pending);
527out_clear:
528 smp_mb__before_clear_bit();
529 clear_bit(XPRT_CONNECTING, &xprt->sockstate);
530 smp_mb__after_clear_bit();
531} 524}
532 525
533/* 526/**
534 * Attempt to connect a TCP socket. 527 * xprt_connect - schedule a transport connect operation
528 * @task: RPC task that is requesting the connect
535 * 529 *
536 */ 530 */
537void xprt_connect(struct rpc_task *task) 531void xprt_connect(struct rpc_task *task)
@@ -552,37 +546,19 @@ void xprt_connect(struct rpc_task *task)
552 if (!xprt_lock_write(xprt, task)) 546 if (!xprt_lock_write(xprt, task))
553 return; 547 return;
554 if (xprt_connected(xprt)) 548 if (xprt_connected(xprt))
555 goto out_write; 549 xprt_release_write(xprt, task);
550 else {
551 if (task->tk_rqstp)
552 task->tk_rqstp->rq_bytes_sent = 0;
556 553
557 if (task->tk_rqstp) 554 task->tk_timeout = xprt->connect_timeout;
558 task->tk_rqstp->rq_bytes_sent = 0; 555 rpc_sleep_on(&xprt->pending, task, xprt_connect_status, NULL);
559 556 xprt->ops->connect(task);
560 task->tk_timeout = RPC_CONNECT_TIMEOUT;
561 rpc_sleep_on(&xprt->pending, task, xprt_connect_status, NULL);
562 if (!test_and_set_bit(XPRT_CONNECTING, &xprt->sockstate)) {
563 /* Note: if we are here due to a dropped connection
564 * we delay reconnecting by RPC_REESTABLISH_TIMEOUT/HZ
565 * seconds
566 */
567 if (xprt->sock != NULL)
568 schedule_delayed_work(&xprt->sock_connect,
569 RPC_REESTABLISH_TIMEOUT);
570 else {
571 schedule_work(&xprt->sock_connect);
572 if (!RPC_IS_ASYNC(task))
573 flush_scheduled_work();
574 }
575 } 557 }
576 return; 558 return;
577 out_write:
578 xprt_release_write(xprt, task);
579} 559}
580 560
581/* 561static void xprt_connect_status(struct rpc_task *task)
582 * We arrive here when awoken from waiting on connection establishment.
583 */
584static void
585xprt_connect_status(struct rpc_task *task)
586{ 562{
587 struct rpc_xprt *xprt = task->tk_xprt; 563 struct rpc_xprt *xprt = task->tk_xprt;
588 564
@@ -592,31 +568,42 @@ xprt_connect_status(struct rpc_task *task)
592 return; 568 return;
593 } 569 }
594 570
595 /* if soft mounted, just cause this RPC to fail */
596 if (RPC_IS_SOFT(task))
597 task->tk_status = -EIO;
598
599 switch (task->tk_status) { 571 switch (task->tk_status) {
600 case -ECONNREFUSED: 572 case -ECONNREFUSED:
601 case -ECONNRESET: 573 case -ECONNRESET:
574 dprintk("RPC: %4d xprt_connect_status: server %s refused connection\n",
575 task->tk_pid, task->tk_client->cl_server);
576 break;
602 case -ENOTCONN: 577 case -ENOTCONN:
603 return; 578 dprintk("RPC: %4d xprt_connect_status: connection broken\n",
579 task->tk_pid);
580 break;
604 case -ETIMEDOUT: 581 case -ETIMEDOUT:
605 dprintk("RPC: %4d xprt_connect_status: timed out\n", 582 dprintk("RPC: %4d xprt_connect_status: connect attempt timed out\n",
606 task->tk_pid); 583 task->tk_pid);
607 break; 584 break;
608 default: 585 default:
609 printk(KERN_ERR "RPC: error %d connecting to server %s\n", 586 dprintk("RPC: %4d xprt_connect_status: error %d connecting to server %s\n",
610 -task->tk_status, task->tk_client->cl_server); 587 task->tk_pid, -task->tk_status, task->tk_client->cl_server);
588 xprt_release_write(xprt, task);
589 task->tk_status = -EIO;
590 return;
591 }
592
593 /* if soft mounted, just cause this RPC to fail */
594 if (RPC_IS_SOFT(task)) {
595 xprt_release_write(xprt, task);
596 task->tk_status = -EIO;
611 } 597 }
612 xprt_release_write(xprt, task);
613} 598}
614 599
615/* 600/**
616 * Look up the RPC request corresponding to a reply, and then lock it. 601 * xprt_lookup_rqst - find an RPC request corresponding to an XID
602 * @xprt: transport on which the original request was transmitted
603 * @xid: RPC XID of incoming reply
604 *
617 */ 605 */
618static inline struct rpc_rqst * 606struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
619xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
620{ 607{
621 struct list_head *pos; 608 struct list_head *pos;
622 struct rpc_rqst *req = NULL; 609 struct rpc_rqst *req = NULL;
@@ -631,556 +618,68 @@ xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid)
631 return req; 618 return req;
632} 619}
633 620
634/* 621/**
635 * Complete reply received. 622 * xprt_update_rtt - update an RPC client's RTT state after receiving a reply
636 * The TCP code relies on us to remove the request from xprt->pending. 623 * @task: RPC request that recently completed
637 */ 624 *
638static void
639xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied)
640{
641 struct rpc_task *task = req->rq_task;
642 struct rpc_clnt *clnt = task->tk_client;
643
644 /* Adjust congestion window */
645 if (!xprt->nocong) {
646 unsigned timer = task->tk_msg.rpc_proc->p_timer;
647 xprt_adjust_cwnd(xprt, copied);
648 __xprt_put_cong(xprt, req);
649 if (timer) {
650 if (req->rq_ntrans == 1)
651 rpc_update_rtt(clnt->cl_rtt, timer,
652 (long)jiffies - req->rq_xtime);
653 rpc_set_timeo(clnt->cl_rtt, timer, req->rq_ntrans - 1);
654 }
655 }
656
657#ifdef RPC_PROFILE
658 /* Profile only reads for now */
659 if (copied > 1024) {
660 static unsigned long nextstat;
661 static unsigned long pkt_rtt, pkt_len, pkt_cnt;
662
663 pkt_cnt++;
664 pkt_len += req->rq_slen + copied;
665 pkt_rtt += jiffies - req->rq_xtime;
666 if (time_before(nextstat, jiffies)) {
667 printk("RPC: %lu %ld cwnd\n", jiffies, xprt->cwnd);
668 printk("RPC: %ld %ld %ld %ld stat\n",
669 jiffies, pkt_cnt, pkt_len, pkt_rtt);
670 pkt_rtt = pkt_len = pkt_cnt = 0;
671 nextstat = jiffies + 5 * HZ;
672 }
673 }
674#endif
675
676 dprintk("RPC: %4d has input (%d bytes)\n", task->tk_pid, copied);
677 list_del_init(&req->rq_list);
678 req->rq_received = req->rq_private_buf.len = copied;
679
680 /* ... and wake up the process. */
681 rpc_wake_up_task(task);
682 return;
683}
684
685static size_t
686skb_read_bits(skb_reader_t *desc, void *to, size_t len)
687{
688 if (len > desc->count)
689 len = desc->count;
690 if (skb_copy_bits(desc->skb, desc->offset, to, len))
691 return 0;
692 desc->count -= len;
693 desc->offset += len;
694 return len;
695}
696
697static size_t
698skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len)
699{
700 unsigned int csum2, pos;
701
702 if (len > desc->count)
703 len = desc->count;
704 pos = desc->offset;
705 csum2 = skb_copy_and_csum_bits(desc->skb, pos, to, len, 0);
706 desc->csum = csum_block_add(desc->csum, csum2, pos);
707 desc->count -= len;
708 desc->offset += len;
709 return len;
710}
711
712/*
713 * We have set things up such that we perform the checksum of the UDP
714 * packet in parallel with the copies into the RPC client iovec. -DaveM
715 */
716int
717csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
718{
719 skb_reader_t desc;
720
721 desc.skb = skb;
722 desc.offset = sizeof(struct udphdr);
723 desc.count = skb->len - desc.offset;
724
725 if (skb->ip_summed == CHECKSUM_UNNECESSARY)
726 goto no_checksum;
727
728 desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
729 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0)
730 return -1;
731 if (desc.offset != skb->len) {
732 unsigned int csum2;
733 csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
734 desc.csum = csum_block_add(desc.csum, csum2, desc.offset);
735 }
736 if (desc.count)
737 return -1;
738 if ((unsigned short)csum_fold(desc.csum))
739 return -1;
740 return 0;
741no_checksum:
742 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_bits) < 0)
743 return -1;
744 if (desc.count)
745 return -1;
746 return 0;
747}
748
749/*
750 * Input handler for RPC replies. Called from a bottom half and hence
751 * atomic.
752 */
753static void
754udp_data_ready(struct sock *sk, int len)
755{
756 struct rpc_task *task;
757 struct rpc_xprt *xprt;
758 struct rpc_rqst *rovr;
759 struct sk_buff *skb;
760 int err, repsize, copied;
761 u32 _xid, *xp;
762
763 read_lock(&sk->sk_callback_lock);
764 dprintk("RPC: udp_data_ready...\n");
765 if (!(xprt = xprt_from_sock(sk))) {
766 printk("RPC: udp_data_ready request not found!\n");
767 goto out;
768 }
769
770 dprintk("RPC: udp_data_ready client %p\n", xprt);
771
772 if ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL)
773 goto out;
774
775 if (xprt->shutdown)
776 goto dropit;
777
778 repsize = skb->len - sizeof(struct udphdr);
779 if (repsize < 4) {
780 printk("RPC: impossible RPC reply size %d!\n", repsize);
781 goto dropit;
782 }
783
784 /* Copy the XID from the skb... */
785 xp = skb_header_pointer(skb, sizeof(struct udphdr),
786 sizeof(_xid), &_xid);
787 if (xp == NULL)
788 goto dropit;
789
790 /* Look up and lock the request corresponding to the given XID */
791 spin_lock(&xprt->sock_lock);
792 rovr = xprt_lookup_rqst(xprt, *xp);
793 if (!rovr)
794 goto out_unlock;
795 task = rovr->rq_task;
796
797 dprintk("RPC: %4d received reply\n", task->tk_pid);
798
799 if ((copied = rovr->rq_private_buf.buflen) > repsize)
800 copied = repsize;
801
802 /* Suck it into the iovec, verify checksum if not done by hw. */
803 if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
804 goto out_unlock;
805
806 /* Something worked... */
807 dst_confirm(skb->dst);
808
809 xprt_complete_rqst(xprt, rovr, copied);
810
811 out_unlock:
812 spin_unlock(&xprt->sock_lock);
813 dropit:
814 skb_free_datagram(sk, skb);
815 out:
816 read_unlock(&sk->sk_callback_lock);
817}
818
819/*
820 * Copy from an skb into memory and shrink the skb.
821 */
822static inline size_t
823tcp_copy_data(skb_reader_t *desc, void *p, size_t len)
824{
825 if (len > desc->count)
826 len = desc->count;
827 if (skb_copy_bits(desc->skb, desc->offset, p, len)) {
828 dprintk("RPC: failed to copy %zu bytes from skb. %zu bytes remain\n",
829 len, desc->count);
830 return 0;
831 }
832 desc->offset += len;
833 desc->count -= len;
834 dprintk("RPC: copied %zu bytes from skb. %zu bytes remain\n",
835 len, desc->count);
836 return len;
837}
838
839/*
840 * TCP read fragment marker
841 */
842static inline void
843tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc)
844{
845 size_t len, used;
846 char *p;
847
848 p = ((char *) &xprt->tcp_recm) + xprt->tcp_offset;
849 len = sizeof(xprt->tcp_recm) - xprt->tcp_offset;
850 used = tcp_copy_data(desc, p, len);
851 xprt->tcp_offset += used;
852 if (used != len)
853 return;
854 xprt->tcp_reclen = ntohl(xprt->tcp_recm);
855 if (xprt->tcp_reclen & 0x80000000)
856 xprt->tcp_flags |= XPRT_LAST_FRAG;
857 else
858 xprt->tcp_flags &= ~XPRT_LAST_FRAG;
859 xprt->tcp_reclen &= 0x7fffffff;
860 xprt->tcp_flags &= ~XPRT_COPY_RECM;
861 xprt->tcp_offset = 0;
862 /* Sanity check of the record length */
863 if (xprt->tcp_reclen < 4) {
864 printk(KERN_ERR "RPC: Invalid TCP record fragment length\n");
865 xprt_disconnect(xprt);
866 }
867 dprintk("RPC: reading TCP record fragment of length %d\n",
868 xprt->tcp_reclen);
869}
870
871static void
872tcp_check_recm(struct rpc_xprt *xprt)
873{
874 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u, tcp_flags = %lx\n",
875 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen, xprt->tcp_flags);
876 if (xprt->tcp_offset == xprt->tcp_reclen) {
877 xprt->tcp_flags |= XPRT_COPY_RECM;
878 xprt->tcp_offset = 0;
879 if (xprt->tcp_flags & XPRT_LAST_FRAG) {
880 xprt->tcp_flags &= ~XPRT_COPY_DATA;
881 xprt->tcp_flags |= XPRT_COPY_XID;
882 xprt->tcp_copied = 0;
883 }
884 }
885}
886
887/*
888 * TCP read xid
889 */
890static inline void
891tcp_read_xid(struct rpc_xprt *xprt, skb_reader_t *desc)
892{
893 size_t len, used;
894 char *p;
895
896 len = sizeof(xprt->tcp_xid) - xprt->tcp_offset;
897 dprintk("RPC: reading XID (%Zu bytes)\n", len);
898 p = ((char *) &xprt->tcp_xid) + xprt->tcp_offset;
899 used = tcp_copy_data(desc, p, len);
900 xprt->tcp_offset += used;
901 if (used != len)
902 return;
903 xprt->tcp_flags &= ~XPRT_COPY_XID;
904 xprt->tcp_flags |= XPRT_COPY_DATA;
905 xprt->tcp_copied = 4;
906 dprintk("RPC: reading reply for XID %08x\n",
907 ntohl(xprt->tcp_xid));
908 tcp_check_recm(xprt);
909}
910
911/*
912 * TCP read and complete request
913 */
914static inline void
915tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
916{
917 struct rpc_rqst *req;
918 struct xdr_buf *rcvbuf;
919 size_t len;
920 ssize_t r;
921
922 /* Find and lock the request corresponding to this xid */
923 spin_lock(&xprt->sock_lock);
924 req = xprt_lookup_rqst(xprt, xprt->tcp_xid);
925 if (!req) {
926 xprt->tcp_flags &= ~XPRT_COPY_DATA;
927 dprintk("RPC: XID %08x request not found!\n",
928 ntohl(xprt->tcp_xid));
929 spin_unlock(&xprt->sock_lock);
930 return;
931 }
932
933 rcvbuf = &req->rq_private_buf;
934 len = desc->count;
935 if (len > xprt->tcp_reclen - xprt->tcp_offset) {
936 skb_reader_t my_desc;
937
938 len = xprt->tcp_reclen - xprt->tcp_offset;
939 memcpy(&my_desc, desc, sizeof(my_desc));
940 my_desc.count = len;
941 r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
942 &my_desc, tcp_copy_data);
943 desc->count -= r;
944 desc->offset += r;
945 } else
946 r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
947 desc, tcp_copy_data);
948
949 if (r > 0) {
950 xprt->tcp_copied += r;
951 xprt->tcp_offset += r;
952 }
953 if (r != len) {
954 /* Error when copying to the receive buffer,
955 * usually because we weren't able to allocate
956 * additional buffer pages. All we can do now
957 * is turn off XPRT_COPY_DATA, so the request
958 * will not receive any additional updates,
959 * and time out.
960 * Any remaining data from this record will
961 * be discarded.
962 */
963 xprt->tcp_flags &= ~XPRT_COPY_DATA;
964 dprintk("RPC: XID %08x truncated request\n",
965 ntohl(xprt->tcp_xid));
966 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
967 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
968 goto out;
969 }
970
971 dprintk("RPC: XID %08x read %Zd bytes\n",
972 ntohl(xprt->tcp_xid), r);
973 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
974 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
975
976 if (xprt->tcp_copied == req->rq_private_buf.buflen)
977 xprt->tcp_flags &= ~XPRT_COPY_DATA;
978 else if (xprt->tcp_offset == xprt->tcp_reclen) {
979 if (xprt->tcp_flags & XPRT_LAST_FRAG)
980 xprt->tcp_flags &= ~XPRT_COPY_DATA;
981 }
982
983out:
984 if (!(xprt->tcp_flags & XPRT_COPY_DATA)) {
985 dprintk("RPC: %4d received reply complete\n",
986 req->rq_task->tk_pid);
987 xprt_complete_rqst(xprt, req, xprt->tcp_copied);
988 }
989 spin_unlock(&xprt->sock_lock);
990 tcp_check_recm(xprt);
991}
992
993/*
994 * TCP discard extra bytes from a short read
995 */
996static inline void
997tcp_read_discard(struct rpc_xprt *xprt, skb_reader_t *desc)
998{
999 size_t len;
1000
1001 len = xprt->tcp_reclen - xprt->tcp_offset;
1002 if (len > desc->count)
1003 len = desc->count;
1004 desc->count -= len;
1005 desc->offset += len;
1006 xprt->tcp_offset += len;
1007 dprintk("RPC: discarded %Zu bytes\n", len);
1008 tcp_check_recm(xprt);
1009}
1010
1011/*
1012 * TCP record receive routine
1013 * We first have to grab the record marker, then the XID, then the data.
1014 */ 625 */
1015static int 626void xprt_update_rtt(struct rpc_task *task)
1016tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,
1017 unsigned int offset, size_t len)
1018{
1019 struct rpc_xprt *xprt = rd_desc->arg.data;
1020 skb_reader_t desc = {
1021 .skb = skb,
1022 .offset = offset,
1023 .count = len,
1024 .csum = 0
1025 };
1026
1027 dprintk("RPC: tcp_data_recv\n");
1028 do {
1029 /* Read in a new fragment marker if necessary */
1030 /* Can we ever really expect to get completely empty fragments? */
1031 if (xprt->tcp_flags & XPRT_COPY_RECM) {
1032 tcp_read_fraghdr(xprt, &desc);
1033 continue;
1034 }
1035 /* Read in the xid if necessary */
1036 if (xprt->tcp_flags & XPRT_COPY_XID) {
1037 tcp_read_xid(xprt, &desc);
1038 continue;
1039 }
1040 /* Read in the request data */
1041 if (xprt->tcp_flags & XPRT_COPY_DATA) {
1042 tcp_read_request(xprt, &desc);
1043 continue;
1044 }
1045 /* Skip over any trailing bytes on short reads */
1046 tcp_read_discard(xprt, &desc);
1047 } while (desc.count);
1048 dprintk("RPC: tcp_data_recv done\n");
1049 return len - desc.count;
1050}
1051
1052static void tcp_data_ready(struct sock *sk, int bytes)
1053{ 627{
1054 struct rpc_xprt *xprt; 628 struct rpc_rqst *req = task->tk_rqstp;
1055 read_descriptor_t rd_desc; 629 struct rpc_rtt *rtt = task->tk_client->cl_rtt;
1056 630 unsigned timer = task->tk_msg.rpc_proc->p_timer;
1057 read_lock(&sk->sk_callback_lock);
1058 dprintk("RPC: tcp_data_ready...\n");
1059 if (!(xprt = xprt_from_sock(sk))) {
1060 printk("RPC: tcp_data_ready socket info not found!\n");
1061 goto out;
1062 }
1063 if (xprt->shutdown)
1064 goto out;
1065
1066 /* We use rd_desc to pass struct xprt to tcp_data_recv */
1067 rd_desc.arg.data = xprt;
1068 rd_desc.count = 65536;
1069 tcp_read_sock(sk, &rd_desc, tcp_data_recv);
1070out:
1071 read_unlock(&sk->sk_callback_lock);
1072}
1073
1074static void
1075tcp_state_change(struct sock *sk)
1076{
1077 struct rpc_xprt *xprt;
1078 631
1079 read_lock(&sk->sk_callback_lock); 632 if (timer) {
1080 if (!(xprt = xprt_from_sock(sk))) 633 if (req->rq_ntrans == 1)
1081 goto out; 634 rpc_update_rtt(rtt, timer,
1082 dprintk("RPC: tcp_state_change client %p...\n", xprt); 635 (long)jiffies - req->rq_xtime);
1083 dprintk("RPC: state %x conn %d dead %d zapped %d\n", 636 rpc_set_timeo(rtt, timer, req->rq_ntrans - 1);
1084 sk->sk_state, xprt_connected(xprt),
1085 sock_flag(sk, SOCK_DEAD),
1086 sock_flag(sk, SOCK_ZAPPED));
1087
1088 switch (sk->sk_state) {
1089 case TCP_ESTABLISHED:
1090 spin_lock_bh(&xprt->sock_lock);
1091 if (!xprt_test_and_set_connected(xprt)) {
1092 /* Reset TCP record info */
1093 xprt->tcp_offset = 0;
1094 xprt->tcp_reclen = 0;
1095 xprt->tcp_copied = 0;
1096 xprt->tcp_flags = XPRT_COPY_RECM | XPRT_COPY_XID;
1097 rpc_wake_up(&xprt->pending);
1098 }
1099 spin_unlock_bh(&xprt->sock_lock);
1100 break;
1101 case TCP_SYN_SENT:
1102 case TCP_SYN_RECV:
1103 break;
1104 default:
1105 xprt_disconnect(xprt);
1106 break;
1107 } 637 }
1108 out:
1109 read_unlock(&sk->sk_callback_lock);
1110} 638}
1111 639
1112/* 640/**
1113 * Called when more output buffer space is available for this socket. 641 * xprt_complete_rqst - called when reply processing is complete
1114 * We try not to wake our writers until they can make "significant" 642 * @task: RPC request that recently completed
1115 * progress, otherwise we'll waste resources thrashing sock_sendmsg 643 * @copied: actual number of bytes received from the transport
1116 * with a bunch of small requests. 644 *
645 * Caller holds transport lock.
1117 */ 646 */
1118static void 647void xprt_complete_rqst(struct rpc_task *task, int copied)
1119xprt_write_space(struct sock *sk)
1120{ 648{
1121 struct rpc_xprt *xprt; 649 struct rpc_rqst *req = task->tk_rqstp;
1122 struct socket *sock;
1123
1124 read_lock(&sk->sk_callback_lock);
1125 if (!(xprt = xprt_from_sock(sk)) || !(sock = sk->sk_socket))
1126 goto out;
1127 if (xprt->shutdown)
1128 goto out;
1129
1130 /* Wait until we have enough socket memory */
1131 if (xprt->stream) {
1132 /* from net/core/stream.c:sk_stream_write_space */
1133 if (sk_stream_wspace(sk) < sk_stream_min_wspace(sk))
1134 goto out;
1135 } else {
1136 /* from net/core/sock.c:sock_def_write_space */
1137 if (!sock_writeable(sk))
1138 goto out;
1139 }
1140 650
1141 if (!test_and_clear_bit(SOCK_NOSPACE, &sock->flags)) 651 dprintk("RPC: %5u xid %08x complete (%d bytes received)\n",
1142 goto out; 652 task->tk_pid, ntohl(req->rq_xid), copied);
1143 653
1144 spin_lock_bh(&xprt->sock_lock); 654 list_del_init(&req->rq_list);
1145 if (xprt->snd_task) 655 req->rq_received = req->rq_private_buf.len = copied;
1146 rpc_wake_up_task(xprt->snd_task); 656 rpc_wake_up_task(task);
1147 spin_unlock_bh(&xprt->sock_lock);
1148out:
1149 read_unlock(&sk->sk_callback_lock);
1150} 657}
1151 658
1152/* 659static void xprt_timer(struct rpc_task *task)
1153 * RPC receive timeout handler.
1154 */
1155static void
1156xprt_timer(struct rpc_task *task)
1157{ 660{
1158 struct rpc_rqst *req = task->tk_rqstp; 661 struct rpc_rqst *req = task->tk_rqstp;
1159 struct rpc_xprt *xprt = req->rq_xprt; 662 struct rpc_xprt *xprt = req->rq_xprt;
1160 663
1161 spin_lock(&xprt->sock_lock); 664 dprintk("RPC: %4d xprt_timer\n", task->tk_pid);
1162 if (req->rq_received)
1163 goto out;
1164
1165 xprt_adjust_cwnd(req->rq_xprt, -ETIMEDOUT);
1166 __xprt_put_cong(xprt, req);
1167 665
1168 dprintk("RPC: %4d xprt_timer (%s request)\n", 666 spin_lock(&xprt->transport_lock);
1169 task->tk_pid, req ? "pending" : "backlogged"); 667 if (!req->rq_received) {
1170 668 if (xprt->ops->timer)
1171 task->tk_status = -ETIMEDOUT; 669 xprt->ops->timer(task);
1172out: 670 task->tk_status = -ETIMEDOUT;
671 }
1173 task->tk_timeout = 0; 672 task->tk_timeout = 0;
1174 rpc_wake_up_task(task); 673 rpc_wake_up_task(task);
1175 spin_unlock(&xprt->sock_lock); 674 spin_unlock(&xprt->transport_lock);
1176} 675}
1177 676
1178/* 677/**
1179 * Place the actual RPC call. 678 * xprt_prepare_transmit - reserve the transport before sending a request
1180 * We have to copy the iovec because sendmsg fiddles with its contents. 679 * @task: RPC task about to send a request
680 *
1181 */ 681 */
1182int 682int xprt_prepare_transmit(struct rpc_task *task)
1183xprt_prepare_transmit(struct rpc_task *task)
1184{ 683{
1185 struct rpc_rqst *req = task->tk_rqstp; 684 struct rpc_rqst *req = task->tk_rqstp;
1186 struct rpc_xprt *xprt = req->rq_xprt; 685 struct rpc_xprt *xprt = req->rq_xprt;
@@ -1191,12 +690,12 @@ xprt_prepare_transmit(struct rpc_task *task)
1191 if (xprt->shutdown) 690 if (xprt->shutdown)
1192 return -EIO; 691 return -EIO;
1193 692
1194 spin_lock_bh(&xprt->sock_lock); 693 spin_lock_bh(&xprt->transport_lock);
1195 if (req->rq_received && !req->rq_bytes_sent) { 694 if (req->rq_received && !req->rq_bytes_sent) {
1196 err = req->rq_received; 695 err = req->rq_received;
1197 goto out_unlock; 696 goto out_unlock;
1198 } 697 }
1199 if (!__xprt_lock_write(xprt, task)) { 698 if (!xprt->ops->reserve_xprt(task)) {
1200 err = -EAGAIN; 699 err = -EAGAIN;
1201 goto out_unlock; 700 goto out_unlock;
1202 } 701 }
@@ -1206,39 +705,42 @@ xprt_prepare_transmit(struct rpc_task *task)
1206 goto out_unlock; 705 goto out_unlock;
1207 } 706 }
1208out_unlock: 707out_unlock:
1209 spin_unlock_bh(&xprt->sock_lock); 708 spin_unlock_bh(&xprt->transport_lock);
1210 return err; 709 return err;
1211} 710}
1212 711
1213void 712void
1214xprt_transmit(struct rpc_task *task) 713xprt_abort_transmit(struct rpc_task *task)
714{
715 struct rpc_xprt *xprt = task->tk_xprt;
716
717 xprt_release_write(xprt, task);
718}
719
720/**
721 * xprt_transmit - send an RPC request on a transport
722 * @task: controlling RPC task
723 *
724 * We have to copy the iovec because sendmsg fiddles with its contents.
725 */
726void xprt_transmit(struct rpc_task *task)
1215{ 727{
1216 struct rpc_clnt *clnt = task->tk_client;
1217 struct rpc_rqst *req = task->tk_rqstp; 728 struct rpc_rqst *req = task->tk_rqstp;
1218 struct rpc_xprt *xprt = req->rq_xprt; 729 struct rpc_xprt *xprt = req->rq_xprt;
1219 int status, retry = 0; 730 int status;
1220
1221 731
1222 dprintk("RPC: %4d xprt_transmit(%u)\n", task->tk_pid, req->rq_slen); 732 dprintk("RPC: %4d xprt_transmit(%u)\n", task->tk_pid, req->rq_slen);
1223 733
1224 /* set up everything as needed. */
1225 /* Write the record marker */
1226 if (xprt->stream) {
1227 u32 *marker = req->rq_svec[0].iov_base;
1228
1229 *marker = htonl(0x80000000|(req->rq_slen-sizeof(*marker)));
1230 }
1231
1232 smp_rmb(); 734 smp_rmb();
1233 if (!req->rq_received) { 735 if (!req->rq_received) {
1234 if (list_empty(&req->rq_list)) { 736 if (list_empty(&req->rq_list)) {
1235 spin_lock_bh(&xprt->sock_lock); 737 spin_lock_bh(&xprt->transport_lock);
1236 /* Update the softirq receive buffer */ 738 /* Update the softirq receive buffer */
1237 memcpy(&req->rq_private_buf, &req->rq_rcv_buf, 739 memcpy(&req->rq_private_buf, &req->rq_rcv_buf,
1238 sizeof(req->rq_private_buf)); 740 sizeof(req->rq_private_buf));
1239 /* Add request to the receive list */ 741 /* Add request to the receive list */
1240 list_add_tail(&req->rq_list, &xprt->recv); 742 list_add_tail(&req->rq_list, &xprt->recv);
1241 spin_unlock_bh(&xprt->sock_lock); 743 spin_unlock_bh(&xprt->transport_lock);
1242 xprt_reset_majortimeo(req); 744 xprt_reset_majortimeo(req);
1243 /* Turn off autodisconnect */ 745 /* Turn off autodisconnect */
1244 del_singleshot_timer_sync(&xprt->timer); 746 del_singleshot_timer_sync(&xprt->timer);
@@ -1246,40 +748,19 @@ xprt_transmit(struct rpc_task *task)
1246 } else if (!req->rq_bytes_sent) 748 } else if (!req->rq_bytes_sent)
1247 return; 749 return;
1248 750
1249 /* Continue transmitting the packet/record. We must be careful 751 status = xprt->ops->send_request(task);
1250 * to cope with writespace callbacks arriving _after_ we have 752 if (status == 0) {
1251 * called xprt_sendmsg(). 753 dprintk("RPC: %4d xmit complete\n", task->tk_pid);
1252 */ 754 spin_lock_bh(&xprt->transport_lock);
1253 while (1) { 755 xprt->ops->set_retrans_timeout(task);
1254 req->rq_xtime = jiffies; 756 /* Don't race with disconnect */
1255 status = xprt_sendmsg(xprt, req); 757 if (!xprt_connected(xprt))
1256 758 task->tk_status = -ENOTCONN;
1257 if (status < 0) 759 else if (!req->rq_received)
1258 break; 760 rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer);
1259 761 xprt->ops->release_xprt(xprt, task);
1260 if (xprt->stream) { 762 spin_unlock_bh(&xprt->transport_lock);
1261 req->rq_bytes_sent += status; 763 return;
1262
1263 /* If we've sent the entire packet, immediately
1264 * reset the count of bytes sent. */
1265 if (req->rq_bytes_sent >= req->rq_slen) {
1266 req->rq_bytes_sent = 0;
1267 goto out_receive;
1268 }
1269 } else {
1270 if (status >= req->rq_slen)
1271 goto out_receive;
1272 status = -EAGAIN;
1273 break;
1274 }
1275
1276 dprintk("RPC: %4d xmit incomplete (%d left of %d)\n",
1277 task->tk_pid, req->rq_slen - req->rq_bytes_sent,
1278 req->rq_slen);
1279
1280 status = -EAGAIN;
1281 if (retry++ > 50)
1282 break;
1283 } 764 }
1284 765
1285 /* Note: at this point, task->tk_sleeping has not yet been set, 766 /* Note: at this point, task->tk_sleeping has not yet been set,
@@ -1289,60 +770,19 @@ xprt_transmit(struct rpc_task *task)
1289 task->tk_status = status; 770 task->tk_status = status;
1290 771
1291 switch (status) { 772 switch (status) {
1292 case -EAGAIN:
1293 if (test_bit(SOCK_ASYNC_NOSPACE, &xprt->sock->flags)) {
1294 /* Protect against races with xprt_write_space */
1295 spin_lock_bh(&xprt->sock_lock);
1296 /* Don't race with disconnect */
1297 if (!xprt_connected(xprt))
1298 task->tk_status = -ENOTCONN;
1299 else if (test_bit(SOCK_NOSPACE, &xprt->sock->flags)) {
1300 task->tk_timeout = req->rq_timeout;
1301 rpc_sleep_on(&xprt->pending, task, NULL, NULL);
1302 }
1303 spin_unlock_bh(&xprt->sock_lock);
1304 return;
1305 }
1306 /* Keep holding the socket if it is blocked */
1307 rpc_delay(task, HZ>>4);
1308 return;
1309 case -ECONNREFUSED: 773 case -ECONNREFUSED:
1310 task->tk_timeout = RPC_REESTABLISH_TIMEOUT;
1311 rpc_sleep_on(&xprt->sending, task, NULL, NULL); 774 rpc_sleep_on(&xprt->sending, task, NULL, NULL);
775 case -EAGAIN:
1312 case -ENOTCONN: 776 case -ENOTCONN:
1313 return; 777 return;
1314 default: 778 default:
1315 if (xprt->stream) 779 break;
1316 xprt_disconnect(xprt);
1317 } 780 }
1318 xprt_release_write(xprt, task); 781 xprt_release_write(xprt, task);
1319 return; 782 return;
1320 out_receive:
1321 dprintk("RPC: %4d xmit complete\n", task->tk_pid);
1322 /* Set the task's receive timeout value */
1323 spin_lock_bh(&xprt->sock_lock);
1324 if (!xprt->nocong) {
1325 int timer = task->tk_msg.rpc_proc->p_timer;
1326 task->tk_timeout = rpc_calc_rto(clnt->cl_rtt, timer);
1327 task->tk_timeout <<= rpc_ntimeo(clnt->cl_rtt, timer) + req->rq_retries;
1328 if (task->tk_timeout > xprt->timeout.to_maxval || task->tk_timeout == 0)
1329 task->tk_timeout = xprt->timeout.to_maxval;
1330 } else
1331 task->tk_timeout = req->rq_timeout;
1332 /* Don't race with disconnect */
1333 if (!xprt_connected(xprt))
1334 task->tk_status = -ENOTCONN;
1335 else if (!req->rq_received)
1336 rpc_sleep_on(&xprt->pending, task, NULL, xprt_timer);
1337 __xprt_release_write(xprt, task);
1338 spin_unlock_bh(&xprt->sock_lock);
1339} 783}
1340 784
1341/* 785static inline void do_xprt_reserve(struct rpc_task *task)
1342 * Reserve an RPC call slot.
1343 */
1344static inline void
1345do_xprt_reserve(struct rpc_task *task)
1346{ 786{
1347 struct rpc_xprt *xprt = task->tk_xprt; 787 struct rpc_xprt *xprt = task->tk_xprt;
1348 788
@@ -1362,22 +802,25 @@ do_xprt_reserve(struct rpc_task *task)
1362 rpc_sleep_on(&xprt->backlog, task, NULL, NULL); 802 rpc_sleep_on(&xprt->backlog, task, NULL, NULL);
1363} 803}
1364 804
1365void 805/**
1366xprt_reserve(struct rpc_task *task) 806 * xprt_reserve - allocate an RPC request slot
807 * @task: RPC task requesting a slot allocation
808 *
809 * If no more slots are available, place the task on the transport's
810 * backlog queue.
811 */
812void xprt_reserve(struct rpc_task *task)
1367{ 813{
1368 struct rpc_xprt *xprt = task->tk_xprt; 814 struct rpc_xprt *xprt = task->tk_xprt;
1369 815
1370 task->tk_status = -EIO; 816 task->tk_status = -EIO;
1371 if (!xprt->shutdown) { 817 if (!xprt->shutdown) {
1372 spin_lock(&xprt->xprt_lock); 818 spin_lock(&xprt->reserve_lock);
1373 do_xprt_reserve(task); 819 do_xprt_reserve(task);
1374 spin_unlock(&xprt->xprt_lock); 820 spin_unlock(&xprt->reserve_lock);
1375 } 821 }
1376} 822}
1377 823
1378/*
1379 * Allocate a 'unique' XID
1380 */
1381static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) 824static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt)
1382{ 825{
1383 return xprt->xid++; 826 return xprt->xid++;
@@ -1388,11 +831,7 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt)
1388 get_random_bytes(&xprt->xid, sizeof(xprt->xid)); 831 get_random_bytes(&xprt->xid, sizeof(xprt->xid));
1389} 832}
1390 833
1391/* 834static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
1392 * Initialize RPC request
1393 */
1394static void
1395xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
1396{ 835{
1397 struct rpc_rqst *req = task->tk_rqstp; 836 struct rpc_rqst *req = task->tk_rqstp;
1398 837
@@ -1400,128 +839,104 @@ xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
1400 req->rq_task = task; 839 req->rq_task = task;
1401 req->rq_xprt = xprt; 840 req->rq_xprt = xprt;
1402 req->rq_xid = xprt_alloc_xid(xprt); 841 req->rq_xid = xprt_alloc_xid(xprt);
842 req->rq_release_snd_buf = NULL;
1403 dprintk("RPC: %4d reserved req %p xid %08x\n", task->tk_pid, 843 dprintk("RPC: %4d reserved req %p xid %08x\n", task->tk_pid,
1404 req, ntohl(req->rq_xid)); 844 req, ntohl(req->rq_xid));
1405} 845}
1406 846
1407/* 847/**
1408 * Release an RPC call slot 848 * xprt_release - release an RPC request slot
849 * @task: task which is finished with the slot
850 *
1409 */ 851 */
1410void 852void xprt_release(struct rpc_task *task)
1411xprt_release(struct rpc_task *task)
1412{ 853{
1413 struct rpc_xprt *xprt = task->tk_xprt; 854 struct rpc_xprt *xprt = task->tk_xprt;
1414 struct rpc_rqst *req; 855 struct rpc_rqst *req;
1415 856
1416 if (!(req = task->tk_rqstp)) 857 if (!(req = task->tk_rqstp))
1417 return; 858 return;
1418 spin_lock_bh(&xprt->sock_lock); 859 spin_lock_bh(&xprt->transport_lock);
1419 __xprt_release_write(xprt, task); 860 xprt->ops->release_xprt(xprt, task);
1420 __xprt_put_cong(xprt, req); 861 if (xprt->ops->release_request)
862 xprt->ops->release_request(task);
1421 if (!list_empty(&req->rq_list)) 863 if (!list_empty(&req->rq_list))
1422 list_del(&req->rq_list); 864 list_del(&req->rq_list);
1423 xprt->last_used = jiffies; 865 xprt->last_used = jiffies;
1424 if (list_empty(&xprt->recv) && !xprt->shutdown) 866 if (list_empty(&xprt->recv) && !xprt->shutdown)
1425 mod_timer(&xprt->timer, xprt->last_used + XPRT_IDLE_TIMEOUT); 867 mod_timer(&xprt->timer,
1426 spin_unlock_bh(&xprt->sock_lock); 868 xprt->last_used + xprt->idle_timeout);
869 spin_unlock_bh(&xprt->transport_lock);
1427 task->tk_rqstp = NULL; 870 task->tk_rqstp = NULL;
871 if (req->rq_release_snd_buf)
872 req->rq_release_snd_buf(req);
1428 memset(req, 0, sizeof(*req)); /* mark unused */ 873 memset(req, 0, sizeof(*req)); /* mark unused */
1429 874
1430 dprintk("RPC: %4d release request %p\n", task->tk_pid, req); 875 dprintk("RPC: %4d release request %p\n", task->tk_pid, req);
1431 876
1432 spin_lock(&xprt->xprt_lock); 877 spin_lock(&xprt->reserve_lock);
1433 list_add(&req->rq_list, &xprt->free); 878 list_add(&req->rq_list, &xprt->free);
1434 xprt_clear_backlog(xprt); 879 rpc_wake_up_next(&xprt->backlog);
1435 spin_unlock(&xprt->xprt_lock); 880 spin_unlock(&xprt->reserve_lock);
1436}
1437
1438/*
1439 * Set default timeout parameters
1440 */
1441static void
1442xprt_default_timeout(struct rpc_timeout *to, int proto)
1443{
1444 if (proto == IPPROTO_UDP)
1445 xprt_set_timeout(to, 5, 5 * HZ);
1446 else
1447 xprt_set_timeout(to, 5, 60 * HZ);
1448} 881}
1449 882
1450/* 883/**
1451 * Set constant timeout 884 * xprt_set_timeout - set constant RPC timeout
885 * @to: RPC timeout parameters to set up
886 * @retr: number of retries
887 * @incr: amount of increase after each retry
888 *
1452 */ 889 */
1453void 890void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
1454xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr)
1455{ 891{
1456 to->to_initval = 892 to->to_initval =
1457 to->to_increment = incr; 893 to->to_increment = incr;
1458 to->to_maxval = incr * retr; 894 to->to_maxval = to->to_initval + (incr * retr);
1459 to->to_retries = retr; 895 to->to_retries = retr;
1460 to->to_exponential = 0; 896 to->to_exponential = 0;
1461} 897}
1462 898
1463unsigned int xprt_udp_slot_table_entries = RPC_DEF_SLOT_TABLE; 899static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
1464unsigned int xprt_tcp_slot_table_entries = RPC_DEF_SLOT_TABLE;
1465
1466/*
1467 * Initialize an RPC client
1468 */
1469static struct rpc_xprt *
1470xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
1471{ 900{
901 int result;
1472 struct rpc_xprt *xprt; 902 struct rpc_xprt *xprt;
1473 unsigned int entries;
1474 size_t slot_table_size;
1475 struct rpc_rqst *req; 903 struct rpc_rqst *req;
1476 904
1477 dprintk("RPC: setting up %s transport...\n",
1478 proto == IPPROTO_UDP? "UDP" : "TCP");
1479
1480 entries = (proto == IPPROTO_TCP)?
1481 xprt_tcp_slot_table_entries : xprt_udp_slot_table_entries;
1482
1483 if ((xprt = kmalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL) 905 if ((xprt = kmalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL)
1484 return ERR_PTR(-ENOMEM); 906 return ERR_PTR(-ENOMEM);
1485 memset(xprt, 0, sizeof(*xprt)); /* Nnnngh! */ 907 memset(xprt, 0, sizeof(*xprt)); /* Nnnngh! */
1486 xprt->max_reqs = entries;
1487 slot_table_size = entries * sizeof(xprt->slot[0]);
1488 xprt->slot = kmalloc(slot_table_size, GFP_KERNEL);
1489 if (xprt->slot == NULL) {
1490 kfree(xprt);
1491 return ERR_PTR(-ENOMEM);
1492 }
1493 memset(xprt->slot, 0, slot_table_size);
1494 908
1495 xprt->addr = *ap; 909 xprt->addr = *ap;
1496 xprt->prot = proto; 910
1497 xprt->stream = (proto == IPPROTO_TCP)? 1 : 0; 911 switch (proto) {
1498 if (xprt->stream) { 912 case IPPROTO_UDP:
1499 xprt->cwnd = RPC_MAXCWND(xprt); 913 result = xs_setup_udp(xprt, to);
1500 xprt->nocong = 1; 914 break;
1501 xprt->max_payload = (1U << 31) - 1; 915 case IPPROTO_TCP:
1502 } else { 916 result = xs_setup_tcp(xprt, to);
1503 xprt->cwnd = RPC_INITCWND; 917 break;
1504 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); 918 default:
919 printk(KERN_ERR "RPC: unrecognized transport protocol: %d\n",
920 proto);
921 result = -EIO;
922 break;
923 }
924 if (result) {
925 kfree(xprt);
926 return ERR_PTR(result);
1505 } 927 }
1506 spin_lock_init(&xprt->sock_lock); 928
1507 spin_lock_init(&xprt->xprt_lock); 929 spin_lock_init(&xprt->transport_lock);
1508 init_waitqueue_head(&xprt->cong_wait); 930 spin_lock_init(&xprt->reserve_lock);
1509 931
1510 INIT_LIST_HEAD(&xprt->free); 932 INIT_LIST_HEAD(&xprt->free);
1511 INIT_LIST_HEAD(&xprt->recv); 933 INIT_LIST_HEAD(&xprt->recv);
1512 INIT_WORK(&xprt->sock_connect, xprt_socket_connect, xprt); 934 INIT_WORK(&xprt->task_cleanup, xprt_autoclose, xprt);
1513 INIT_WORK(&xprt->task_cleanup, xprt_socket_autoclose, xprt);
1514 init_timer(&xprt->timer); 935 init_timer(&xprt->timer);
1515 xprt->timer.function = xprt_init_autodisconnect; 936 xprt->timer.function = xprt_init_autodisconnect;
1516 xprt->timer.data = (unsigned long) xprt; 937 xprt->timer.data = (unsigned long) xprt;
1517 xprt->last_used = jiffies; 938 xprt->last_used = jiffies;
1518 xprt->port = XPRT_MAX_RESVPORT; 939 xprt->cwnd = RPC_INITCWND;
1519
1520 /* Set timeout parameters */
1521 if (to) {
1522 xprt->timeout = *to;
1523 } else
1524 xprt_default_timeout(&xprt->timeout, xprt->prot);
1525 940
1526 rpc_init_wait_queue(&xprt->pending, "xprt_pending"); 941 rpc_init_wait_queue(&xprt->pending, "xprt_pending");
1527 rpc_init_wait_queue(&xprt->sending, "xprt_sending"); 942 rpc_init_wait_queue(&xprt->sending, "xprt_sending");
@@ -1529,139 +944,25 @@ xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to)
1529 rpc_init_priority_wait_queue(&xprt->backlog, "xprt_backlog"); 944 rpc_init_priority_wait_queue(&xprt->backlog, "xprt_backlog");
1530 945
1531 /* initialize free list */ 946 /* initialize free list */
1532 for (req = &xprt->slot[entries-1]; req >= &xprt->slot[0]; req--) 947 for (req = &xprt->slot[xprt->max_reqs-1]; req >= &xprt->slot[0]; req--)
1533 list_add(&req->rq_list, &xprt->free); 948 list_add(&req->rq_list, &xprt->free);
1534 949
1535 xprt_init_xid(xprt); 950 xprt_init_xid(xprt);
1536 951
1537 /* Check whether we want to use a reserved port */
1538 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1539
1540 dprintk("RPC: created transport %p with %u slots\n", xprt, 952 dprintk("RPC: created transport %p with %u slots\n", xprt,
1541 xprt->max_reqs); 953 xprt->max_reqs);
1542 954
1543 return xprt; 955 return xprt;
1544} 956}
1545 957
1546/* 958/**
1547 * Bind to a reserved port 959 * xprt_create_proto - create an RPC client transport
1548 */ 960 * @proto: requested transport protocol
1549static inline int xprt_bindresvport(struct rpc_xprt *xprt, struct socket *sock) 961 * @sap: remote peer's address
1550{ 962 * @to: timeout parameters for new transport
1551 struct sockaddr_in myaddr = { 963 *
1552 .sin_family = AF_INET,
1553 };
1554 int err, port;
1555
1556 /* Were we already bound to a given port? Try to reuse it */
1557 port = xprt->port;
1558 do {
1559 myaddr.sin_port = htons(port);
1560 err = sock->ops->bind(sock, (struct sockaddr *) &myaddr,
1561 sizeof(myaddr));
1562 if (err == 0) {
1563 xprt->port = port;
1564 return 0;
1565 }
1566 if (--port == 0)
1567 port = XPRT_MAX_RESVPORT;
1568 } while (err == -EADDRINUSE && port != xprt->port);
1569
1570 printk("RPC: Can't bind to reserved port (%d).\n", -err);
1571 return err;
1572}
1573
1574static void
1575xprt_bind_socket(struct rpc_xprt *xprt, struct socket *sock)
1576{
1577 struct sock *sk = sock->sk;
1578
1579 if (xprt->inet)
1580 return;
1581
1582 write_lock_bh(&sk->sk_callback_lock);
1583 sk->sk_user_data = xprt;
1584 xprt->old_data_ready = sk->sk_data_ready;
1585 xprt->old_state_change = sk->sk_state_change;
1586 xprt->old_write_space = sk->sk_write_space;
1587 if (xprt->prot == IPPROTO_UDP) {
1588 sk->sk_data_ready = udp_data_ready;
1589 sk->sk_no_check = UDP_CSUM_NORCV;
1590 xprt_set_connected(xprt);
1591 } else {
1592 tcp_sk(sk)->nonagle = 1; /* disable Nagle's algorithm */
1593 sk->sk_data_ready = tcp_data_ready;
1594 sk->sk_state_change = tcp_state_change;
1595 xprt_clear_connected(xprt);
1596 }
1597 sk->sk_write_space = xprt_write_space;
1598
1599 /* Reset to new socket */
1600 xprt->sock = sock;
1601 xprt->inet = sk;
1602 write_unlock_bh(&sk->sk_callback_lock);
1603
1604 return;
1605}
1606
1607/*
1608 * Set socket buffer length
1609 */
1610void
1611xprt_sock_setbufsize(struct rpc_xprt *xprt)
1612{
1613 struct sock *sk = xprt->inet;
1614
1615 if (xprt->stream)
1616 return;
1617 if (xprt->rcvsize) {
1618 sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
1619 sk->sk_rcvbuf = xprt->rcvsize * xprt->max_reqs * 2;
1620 }
1621 if (xprt->sndsize) {
1622 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
1623 sk->sk_sndbuf = xprt->sndsize * xprt->max_reqs * 2;
1624 sk->sk_write_space(sk);
1625 }
1626}
1627
1628/*
1629 * Datastream sockets are created here, but xprt_connect will create
1630 * and connect stream sockets.
1631 */
1632static struct socket * xprt_create_socket(struct rpc_xprt *xprt, int proto, int resvport)
1633{
1634 struct socket *sock;
1635 int type, err;
1636
1637 dprintk("RPC: xprt_create_socket(%s %d)\n",
1638 (proto == IPPROTO_UDP)? "udp" : "tcp", proto);
1639
1640 type = (proto == IPPROTO_UDP)? SOCK_DGRAM : SOCK_STREAM;
1641
1642 if ((err = sock_create_kern(PF_INET, type, proto, &sock)) < 0) {
1643 printk("RPC: can't create socket (%d).\n", -err);
1644 return NULL;
1645 }
1646
1647 /* If the caller has the capability, bind to a reserved port */
1648 if (resvport && xprt_bindresvport(xprt, sock) < 0) {
1649 printk("RPC: can't bind to reserved port.\n");
1650 goto failed;
1651 }
1652
1653 return sock;
1654
1655failed:
1656 sock_release(sock);
1657 return NULL;
1658}
1659
1660/*
1661 * Create an RPC client transport given the protocol and peer address.
1662 */ 964 */
1663struct rpc_xprt * 965struct rpc_xprt *xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
1664xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
1665{ 966{
1666 struct rpc_xprt *xprt; 967 struct rpc_xprt *xprt;
1667 968
@@ -1673,46 +974,26 @@ xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to)
1673 return xprt; 974 return xprt;
1674} 975}
1675 976
1676/* 977static void xprt_shutdown(struct rpc_xprt *xprt)
1677 * Prepare for transport shutdown.
1678 */
1679static void
1680xprt_shutdown(struct rpc_xprt *xprt)
1681{ 978{
1682 xprt->shutdown = 1; 979 xprt->shutdown = 1;
1683 rpc_wake_up(&xprt->sending); 980 rpc_wake_up(&xprt->sending);
1684 rpc_wake_up(&xprt->resend); 981 rpc_wake_up(&xprt->resend);
1685 rpc_wake_up(&xprt->pending); 982 xprt_wake_pending_tasks(xprt, -EIO);
1686 rpc_wake_up(&xprt->backlog); 983 rpc_wake_up(&xprt->backlog);
1687 wake_up(&xprt->cong_wait);
1688 del_timer_sync(&xprt->timer); 984 del_timer_sync(&xprt->timer);
1689
1690 /* synchronously wait for connect worker to finish */
1691 cancel_delayed_work(&xprt->sock_connect);
1692 flush_scheduled_work();
1693} 985}
1694 986
1695/* 987/**
1696 * Clear the xprt backlog queue 988 * xprt_destroy - destroy an RPC transport, killing off all requests.
1697 */ 989 * @xprt: transport to destroy
1698static int 990 *
1699xprt_clear_backlog(struct rpc_xprt *xprt) {
1700 rpc_wake_up_next(&xprt->backlog);
1701 wake_up(&xprt->cong_wait);
1702 return 1;
1703}
1704
1705/*
1706 * Destroy an RPC transport, killing off all requests.
1707 */ 991 */
1708int 992int xprt_destroy(struct rpc_xprt *xprt)
1709xprt_destroy(struct rpc_xprt *xprt)
1710{ 993{
1711 dprintk("RPC: destroying transport %p\n", xprt); 994 dprintk("RPC: destroying transport %p\n", xprt);
1712 xprt_shutdown(xprt); 995 xprt_shutdown(xprt);
1713 xprt_disconnect(xprt); 996 xprt->ops->destroy(xprt);
1714 xprt_close(xprt);
1715 kfree(xprt->slot);
1716 kfree(xprt); 997 kfree(xprt);
1717 998
1718 return 0; 999 return 0;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
new file mode 100644
index 000000000000..2e1529217e65
--- /dev/null
+++ b/net/sunrpc/xprtsock.c
@@ -0,0 +1,1252 @@
1/*
2 * linux/net/sunrpc/xprtsock.c
3 *
4 * Client-side transport implementation for sockets.
5 *
6 * TCP callback races fixes (C) 1998 Red Hat Software <alan@redhat.com>
7 * TCP send fixes (C) 1998 Red Hat Software <alan@redhat.com>
8 * TCP NFS related read + write fixes
9 * (C) 1999 Dave Airlie, University of Limerick, Ireland <airlied@linux.ie>
10 *
11 * Rewrite of larges part of the code in order to stabilize TCP stuff.
12 * Fix behaviour when socket buffer is full.
13 * (C) 1999 Trond Myklebust <trond.myklebust@fys.uio.no>
14 *
15 * IP socket transport implementation, (C) 2005 Chuck Lever <cel@netapp.com>
16 */
17
18#include <linux/types.h>
19#include <linux/slab.h>
20#include <linux/capability.h>
21#include <linux/sched.h>
22#include <linux/pagemap.h>
23#include <linux/errno.h>
24#include <linux/socket.h>
25#include <linux/in.h>
26#include <linux/net.h>
27#include <linux/mm.h>
28#include <linux/udp.h>
29#include <linux/tcp.h>
30#include <linux/sunrpc/clnt.h>
31#include <linux/file.h>
32
33#include <net/sock.h>
34#include <net/checksum.h>
35#include <net/udp.h>
36#include <net/tcp.h>
37
38/*
39 * How many times to try sending a request on a socket before waiting
40 * for the socket buffer to clear.
41 */
42#define XS_SENDMSG_RETRY (10U)
43
44/*
45 * Time out for an RPC UDP socket connect. UDP socket connects are
46 * synchronous, but we set a timeout anyway in case of resource
47 * exhaustion on the local host.
48 */
49#define XS_UDP_CONN_TO (5U * HZ)
50
51/*
52 * Wait duration for an RPC TCP connection to be established. Solaris
53 * NFS over TCP uses 60 seconds, for example, which is in line with how
54 * long a server takes to reboot.
55 */
56#define XS_TCP_CONN_TO (60U * HZ)
57
58/*
59 * Wait duration for a reply from the RPC portmapper.
60 */
61#define XS_BIND_TO (60U * HZ)
62
63/*
64 * Delay if a UDP socket connect error occurs. This is most likely some
65 * kind of resource problem on the local host.
66 */
67#define XS_UDP_REEST_TO (2U * HZ)
68
69/*
70 * The reestablish timeout allows clients to delay for a bit before attempting
71 * to reconnect to a server that just dropped our connection.
72 *
73 * We implement an exponential backoff when trying to reestablish a TCP
74 * transport connection with the server. Some servers like to drop a TCP
75 * connection when they are overworked, so we start with a short timeout and
76 * increase over time if the server is down or not responding.
77 */
78#define XS_TCP_INIT_REEST_TO (3U * HZ)
79#define XS_TCP_MAX_REEST_TO (5U * 60 * HZ)
80
81/*
82 * TCP idle timeout; client drops the transport socket if it is idle
83 * for this long. Note that we also timeout UDP sockets to prevent
84 * holding port numbers when there is no RPC traffic.
85 */
86#define XS_IDLE_DISC_TO (5U * 60 * HZ)
87
88#ifdef RPC_DEBUG
89# undef RPC_DEBUG_DATA
90# define RPCDBG_FACILITY RPCDBG_TRANS
91#endif
92
93#ifdef RPC_DEBUG_DATA
94static void xs_pktdump(char *msg, u32 *packet, unsigned int count)
95{
96 u8 *buf = (u8 *) packet;
97 int j;
98
99 dprintk("RPC: %s\n", msg);
100 for (j = 0; j < count && j < 128; j += 4) {
101 if (!(j & 31)) {
102 if (j)
103 dprintk("\n");
104 dprintk("0x%04x ", j);
105 }
106 dprintk("%02x%02x%02x%02x ",
107 buf[j], buf[j+1], buf[j+2], buf[j+3]);
108 }
109 dprintk("\n");
110}
111#else
112static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
113{
114 /* NOP */
115}
116#endif
117
118#define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL)
119
120static inline int xs_send_head(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, unsigned int len)
121{
122 struct kvec iov = {
123 .iov_base = xdr->head[0].iov_base + base,
124 .iov_len = len - base,
125 };
126 struct msghdr msg = {
127 .msg_name = addr,
128 .msg_namelen = addrlen,
129 .msg_flags = XS_SENDMSG_FLAGS,
130 };
131
132 if (xdr->len > len)
133 msg.msg_flags |= MSG_MORE;
134
135 if (likely(iov.iov_len))
136 return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
137 return kernel_sendmsg(sock, &msg, NULL, 0, 0);
138}
139
140static int xs_send_tail(struct socket *sock, struct xdr_buf *xdr, unsigned int base, unsigned int len)
141{
142 struct kvec iov = {
143 .iov_base = xdr->tail[0].iov_base + base,
144 .iov_len = len - base,
145 };
146 struct msghdr msg = {
147 .msg_flags = XS_SENDMSG_FLAGS,
148 };
149
150 return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
151}
152
153/**
154 * xs_sendpages - write pages directly to a socket
155 * @sock: socket to send on
156 * @addr: UDP only -- address of destination
157 * @addrlen: UDP only -- length of destination address
158 * @xdr: buffer containing this request
159 * @base: starting position in the buffer
160 *
161 */
162static inline int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
163{
164 struct page **ppage = xdr->pages;
165 unsigned int len, pglen = xdr->page_len;
166 int err, ret = 0;
167 ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
168
169 if (unlikely(!sock))
170 return -ENOTCONN;
171
172 clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
173
174 len = xdr->head[0].iov_len;
175 if (base < len || (addr != NULL && base == 0)) {
176 err = xs_send_head(sock, addr, addrlen, xdr, base, len);
177 if (ret == 0)
178 ret = err;
179 else if (err > 0)
180 ret += err;
181 if (err != (len - base))
182 goto out;
183 base = 0;
184 } else
185 base -= len;
186
187 if (unlikely(pglen == 0))
188 goto copy_tail;
189 if (unlikely(base >= pglen)) {
190 base -= pglen;
191 goto copy_tail;
192 }
193 if (base || xdr->page_base) {
194 pglen -= base;
195 base += xdr->page_base;
196 ppage += base >> PAGE_CACHE_SHIFT;
197 base &= ~PAGE_CACHE_MASK;
198 }
199
200 sendpage = sock->ops->sendpage ? : sock_no_sendpage;
201 do {
202 int flags = XS_SENDMSG_FLAGS;
203
204 len = PAGE_CACHE_SIZE;
205 if (base)
206 len -= base;
207 if (pglen < len)
208 len = pglen;
209
210 if (pglen != len || xdr->tail[0].iov_len != 0)
211 flags |= MSG_MORE;
212
213 /* Hmm... We might be dealing with highmem pages */
214 if (PageHighMem(*ppage))
215 sendpage = sock_no_sendpage;
216 err = sendpage(sock, *ppage, base, len, flags);
217 if (ret == 0)
218 ret = err;
219 else if (err > 0)
220 ret += err;
221 if (err != len)
222 goto out;
223 base = 0;
224 ppage++;
225 } while ((pglen -= len) != 0);
226copy_tail:
227 len = xdr->tail[0].iov_len;
228 if (base < len) {
229 err = xs_send_tail(sock, xdr, base, len);
230 if (ret == 0)
231 ret = err;
232 else if (err > 0)
233 ret += err;
234 }
235out:
236 return ret;
237}
238
239/**
240 * xs_nospace - place task on wait queue if transmit was incomplete
241 * @task: task to put to sleep
242 *
243 */
244static void xs_nospace(struct rpc_task *task)
245{
246 struct rpc_rqst *req = task->tk_rqstp;
247 struct rpc_xprt *xprt = req->rq_xprt;
248
249 dprintk("RPC: %4d xmit incomplete (%u left of %u)\n",
250 task->tk_pid, req->rq_slen - req->rq_bytes_sent,
251 req->rq_slen);
252
253 if (test_bit(SOCK_ASYNC_NOSPACE, &xprt->sock->flags)) {
254 /* Protect against races with write_space */
255 spin_lock_bh(&xprt->transport_lock);
256
257 /* Don't race with disconnect */
258 if (!xprt_connected(xprt))
259 task->tk_status = -ENOTCONN;
260 else if (test_bit(SOCK_NOSPACE, &xprt->sock->flags))
261 xprt_wait_for_buffer_space(task);
262
263 spin_unlock_bh(&xprt->transport_lock);
264 } else
265 /* Keep holding the socket if it is blocked */
266 rpc_delay(task, HZ>>4);
267}
268
269/**
270 * xs_udp_send_request - write an RPC request to a UDP socket
271 * @task: address of RPC task that manages the state of an RPC request
272 *
273 * Return values:
274 * 0: The request has been sent
275 * EAGAIN: The socket was blocked, please call again later to
276 * complete the request
277 * ENOTCONN: Caller needs to invoke connect logic then call again
278 * other: Some other error occured, the request was not sent
279 */
280static int xs_udp_send_request(struct rpc_task *task)
281{
282 struct rpc_rqst *req = task->tk_rqstp;
283 struct rpc_xprt *xprt = req->rq_xprt;
284 struct xdr_buf *xdr = &req->rq_snd_buf;
285 int status;
286
287 xs_pktdump("packet data:",
288 req->rq_svec->iov_base,
289 req->rq_svec->iov_len);
290
291 req->rq_xtime = jiffies;
292 status = xs_sendpages(xprt->sock, (struct sockaddr *) &xprt->addr,
293 sizeof(xprt->addr), xdr, req->rq_bytes_sent);
294
295 dprintk("RPC: xs_udp_send_request(%u) = %d\n",
296 xdr->len - req->rq_bytes_sent, status);
297
298 if (likely(status >= (int) req->rq_slen))
299 return 0;
300
301 /* Still some bytes left; set up for a retry later. */
302 if (status > 0)
303 status = -EAGAIN;
304
305 switch (status) {
306 case -ENETUNREACH:
307 case -EPIPE:
308 case -ECONNREFUSED:
309 /* When the server has died, an ICMP port unreachable message
310 * prompts ECONNREFUSED. */
311 break;
312 case -EAGAIN:
313 xs_nospace(task);
314 break;
315 default:
316 dprintk("RPC: sendmsg returned unrecognized error %d\n",
317 -status);
318 break;
319 }
320
321 return status;
322}
323
324static inline void xs_encode_tcp_record_marker(struct xdr_buf *buf)
325{
326 u32 reclen = buf->len - sizeof(rpc_fraghdr);
327 rpc_fraghdr *base = buf->head[0].iov_base;
328 *base = htonl(RPC_LAST_STREAM_FRAGMENT | reclen);
329}
330
331/**
332 * xs_tcp_send_request - write an RPC request to a TCP socket
333 * @task: address of RPC task that manages the state of an RPC request
334 *
335 * Return values:
336 * 0: The request has been sent
337 * EAGAIN: The socket was blocked, please call again later to
338 * complete the request
339 * ENOTCONN: Caller needs to invoke connect logic then call again
340 * other: Some other error occured, the request was not sent
341 *
342 * XXX: In the case of soft timeouts, should we eventually give up
343 * if sendmsg is not able to make progress?
344 */
345static int xs_tcp_send_request(struct rpc_task *task)
346{
347 struct rpc_rqst *req = task->tk_rqstp;
348 struct rpc_xprt *xprt = req->rq_xprt;
349 struct xdr_buf *xdr = &req->rq_snd_buf;
350 int status, retry = 0;
351
352 xs_encode_tcp_record_marker(&req->rq_snd_buf);
353
354 xs_pktdump("packet data:",
355 req->rq_svec->iov_base,
356 req->rq_svec->iov_len);
357
358 /* Continue transmitting the packet/record. We must be careful
359 * to cope with writespace callbacks arriving _after_ we have
360 * called sendmsg(). */
361 while (1) {
362 req->rq_xtime = jiffies;
363 status = xs_sendpages(xprt->sock, NULL, 0, xdr,
364 req->rq_bytes_sent);
365
366 dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
367 xdr->len - req->rq_bytes_sent, status);
368
369 if (unlikely(status < 0))
370 break;
371
372 /* If we've sent the entire packet, immediately
373 * reset the count of bytes sent. */
374 req->rq_bytes_sent += status;
375 if (likely(req->rq_bytes_sent >= req->rq_slen)) {
376 req->rq_bytes_sent = 0;
377 return 0;
378 }
379
380 status = -EAGAIN;
381 if (retry++ > XS_SENDMSG_RETRY)
382 break;
383 }
384
385 switch (status) {
386 case -EAGAIN:
387 xs_nospace(task);
388 break;
389 case -ECONNREFUSED:
390 case -ECONNRESET:
391 case -ENOTCONN:
392 case -EPIPE:
393 status = -ENOTCONN;
394 break;
395 default:
396 dprintk("RPC: sendmsg returned unrecognized error %d\n",
397 -status);
398 xprt_disconnect(xprt);
399 break;
400 }
401
402 return status;
403}
404
405/**
406 * xs_close - close a socket
407 * @xprt: transport
408 *
409 * This is used when all requests are complete; ie, no DRC state remains
410 * on the server we want to save.
411 */
412static void xs_close(struct rpc_xprt *xprt)
413{
414 struct socket *sock = xprt->sock;
415 struct sock *sk = xprt->inet;
416
417 if (!sk)
418 return;
419
420 dprintk("RPC: xs_close xprt %p\n", xprt);
421
422 write_lock_bh(&sk->sk_callback_lock);
423 xprt->inet = NULL;
424 xprt->sock = NULL;
425
426 sk->sk_user_data = NULL;
427 sk->sk_data_ready = xprt->old_data_ready;
428 sk->sk_state_change = xprt->old_state_change;
429 sk->sk_write_space = xprt->old_write_space;
430 write_unlock_bh(&sk->sk_callback_lock);
431
432 sk->sk_no_check = 0;
433
434 sock_release(sock);
435}
436
437/**
438 * xs_destroy - prepare to shutdown a transport
439 * @xprt: doomed transport
440 *
441 */
442static void xs_destroy(struct rpc_xprt *xprt)
443{
444 dprintk("RPC: xs_destroy xprt %p\n", xprt);
445
446 cancel_delayed_work(&xprt->connect_worker);
447 flush_scheduled_work();
448
449 xprt_disconnect(xprt);
450 xs_close(xprt);
451 kfree(xprt->slot);
452}
453
454static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
455{
456 return (struct rpc_xprt *) sk->sk_user_data;
457}
458
459/**
460 * xs_udp_data_ready - "data ready" callback for UDP sockets
461 * @sk: socket with data to read
462 * @len: how much data to read
463 *
464 */
465static void xs_udp_data_ready(struct sock *sk, int len)
466{
467 struct rpc_task *task;
468 struct rpc_xprt *xprt;
469 struct rpc_rqst *rovr;
470 struct sk_buff *skb;
471 int err, repsize, copied;
472 u32 _xid, *xp;
473
474 read_lock(&sk->sk_callback_lock);
475 dprintk("RPC: xs_udp_data_ready...\n");
476 if (!(xprt = xprt_from_sock(sk)))
477 goto out;
478
479 if ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL)
480 goto out;
481
482 if (xprt->shutdown)
483 goto dropit;
484
485 repsize = skb->len - sizeof(struct udphdr);
486 if (repsize < 4) {
487 dprintk("RPC: impossible RPC reply size %d!\n", repsize);
488 goto dropit;
489 }
490
491 /* Copy the XID from the skb... */
492 xp = skb_header_pointer(skb, sizeof(struct udphdr),
493 sizeof(_xid), &_xid);
494 if (xp == NULL)
495 goto dropit;
496
497 /* Look up and lock the request corresponding to the given XID */
498 spin_lock(&xprt->transport_lock);
499 rovr = xprt_lookup_rqst(xprt, *xp);
500 if (!rovr)
501 goto out_unlock;
502 task = rovr->rq_task;
503
504 if ((copied = rovr->rq_private_buf.buflen) > repsize)
505 copied = repsize;
506
507 /* Suck it into the iovec, verify checksum if not done by hw. */
508 if (csum_partial_copy_to_xdr(&rovr->rq_private_buf, skb))
509 goto out_unlock;
510
511 /* Something worked... */
512 dst_confirm(skb->dst);
513
514 xprt_adjust_cwnd(task, copied);
515 xprt_update_rtt(task);
516 xprt_complete_rqst(task, copied);
517
518 out_unlock:
519 spin_unlock(&xprt->transport_lock);
520 dropit:
521 skb_free_datagram(sk, skb);
522 out:
523 read_unlock(&sk->sk_callback_lock);
524}
525
526static inline size_t xs_tcp_copy_data(skb_reader_t *desc, void *p, size_t len)
527{
528 if (len > desc->count)
529 len = desc->count;
530 if (skb_copy_bits(desc->skb, desc->offset, p, len)) {
531 dprintk("RPC: failed to copy %zu bytes from skb. %zu bytes remain\n",
532 len, desc->count);
533 return 0;
534 }
535 desc->offset += len;
536 desc->count -= len;
537 dprintk("RPC: copied %zu bytes from skb. %zu bytes remain\n",
538 len, desc->count);
539 return len;
540}
541
542static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, skb_reader_t *desc)
543{
544 size_t len, used;
545 char *p;
546
547 p = ((char *) &xprt->tcp_recm) + xprt->tcp_offset;
548 len = sizeof(xprt->tcp_recm) - xprt->tcp_offset;
549 used = xs_tcp_copy_data(desc, p, len);
550 xprt->tcp_offset += used;
551 if (used != len)
552 return;
553
554 xprt->tcp_reclen = ntohl(xprt->tcp_recm);
555 if (xprt->tcp_reclen & RPC_LAST_STREAM_FRAGMENT)
556 xprt->tcp_flags |= XPRT_LAST_FRAG;
557 else
558 xprt->tcp_flags &= ~XPRT_LAST_FRAG;
559 xprt->tcp_reclen &= RPC_FRAGMENT_SIZE_MASK;
560
561 xprt->tcp_flags &= ~XPRT_COPY_RECM;
562 xprt->tcp_offset = 0;
563
564 /* Sanity check of the record length */
565 if (unlikely(xprt->tcp_reclen < 4)) {
566 dprintk("RPC: invalid TCP record fragment length\n");
567 xprt_disconnect(xprt);
568 return;
569 }
570 dprintk("RPC: reading TCP record fragment of length %d\n",
571 xprt->tcp_reclen);
572}
573
574static void xs_tcp_check_recm(struct rpc_xprt *xprt)
575{
576 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u, tcp_flags = %lx\n",
577 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen, xprt->tcp_flags);
578 if (xprt->tcp_offset == xprt->tcp_reclen) {
579 xprt->tcp_flags |= XPRT_COPY_RECM;
580 xprt->tcp_offset = 0;
581 if (xprt->tcp_flags & XPRT_LAST_FRAG) {
582 xprt->tcp_flags &= ~XPRT_COPY_DATA;
583 xprt->tcp_flags |= XPRT_COPY_XID;
584 xprt->tcp_copied = 0;
585 }
586 }
587}
588
589static inline void xs_tcp_read_xid(struct rpc_xprt *xprt, skb_reader_t *desc)
590{
591 size_t len, used;
592 char *p;
593
594 len = sizeof(xprt->tcp_xid) - xprt->tcp_offset;
595 dprintk("RPC: reading XID (%Zu bytes)\n", len);
596 p = ((char *) &xprt->tcp_xid) + xprt->tcp_offset;
597 used = xs_tcp_copy_data(desc, p, len);
598 xprt->tcp_offset += used;
599 if (used != len)
600 return;
601 xprt->tcp_flags &= ~XPRT_COPY_XID;
602 xprt->tcp_flags |= XPRT_COPY_DATA;
603 xprt->tcp_copied = 4;
604 dprintk("RPC: reading reply for XID %08x\n",
605 ntohl(xprt->tcp_xid));
606 xs_tcp_check_recm(xprt);
607}
608
609static inline void xs_tcp_read_request(struct rpc_xprt *xprt, skb_reader_t *desc)
610{
611 struct rpc_rqst *req;
612 struct xdr_buf *rcvbuf;
613 size_t len;
614 ssize_t r;
615
616 /* Find and lock the request corresponding to this xid */
617 spin_lock(&xprt->transport_lock);
618 req = xprt_lookup_rqst(xprt, xprt->tcp_xid);
619 if (!req) {
620 xprt->tcp_flags &= ~XPRT_COPY_DATA;
621 dprintk("RPC: XID %08x request not found!\n",
622 ntohl(xprt->tcp_xid));
623 spin_unlock(&xprt->transport_lock);
624 return;
625 }
626
627 rcvbuf = &req->rq_private_buf;
628 len = desc->count;
629 if (len > xprt->tcp_reclen - xprt->tcp_offset) {
630 skb_reader_t my_desc;
631
632 len = xprt->tcp_reclen - xprt->tcp_offset;
633 memcpy(&my_desc, desc, sizeof(my_desc));
634 my_desc.count = len;
635 r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
636 &my_desc, xs_tcp_copy_data);
637 desc->count -= r;
638 desc->offset += r;
639 } else
640 r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
641 desc, xs_tcp_copy_data);
642
643 if (r > 0) {
644 xprt->tcp_copied += r;
645 xprt->tcp_offset += r;
646 }
647 if (r != len) {
648 /* Error when copying to the receive buffer,
649 * usually because we weren't able to allocate
650 * additional buffer pages. All we can do now
651 * is turn off XPRT_COPY_DATA, so the request
652 * will not receive any additional updates,
653 * and time out.
654 * Any remaining data from this record will
655 * be discarded.
656 */
657 xprt->tcp_flags &= ~XPRT_COPY_DATA;
658 dprintk("RPC: XID %08x truncated request\n",
659 ntohl(xprt->tcp_xid));
660 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
661 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
662 goto out;
663 }
664
665 dprintk("RPC: XID %08x read %Zd bytes\n",
666 ntohl(xprt->tcp_xid), r);
667 dprintk("RPC: xprt = %p, tcp_copied = %lu, tcp_offset = %u, tcp_reclen = %u\n",
668 xprt, xprt->tcp_copied, xprt->tcp_offset, xprt->tcp_reclen);
669
670 if (xprt->tcp_copied == req->rq_private_buf.buflen)
671 xprt->tcp_flags &= ~XPRT_COPY_DATA;
672 else if (xprt->tcp_offset == xprt->tcp_reclen) {
673 if (xprt->tcp_flags & XPRT_LAST_FRAG)
674 xprt->tcp_flags &= ~XPRT_COPY_DATA;
675 }
676
677out:
678 if (!(xprt->tcp_flags & XPRT_COPY_DATA))
679 xprt_complete_rqst(req->rq_task, xprt->tcp_copied);
680 spin_unlock(&xprt->transport_lock);
681 xs_tcp_check_recm(xprt);
682}
683
684static inline void xs_tcp_read_discard(struct rpc_xprt *xprt, skb_reader_t *desc)
685{
686 size_t len;
687
688 len = xprt->tcp_reclen - xprt->tcp_offset;
689 if (len > desc->count)
690 len = desc->count;
691 desc->count -= len;
692 desc->offset += len;
693 xprt->tcp_offset += len;
694 dprintk("RPC: discarded %Zu bytes\n", len);
695 xs_tcp_check_recm(xprt);
696}
697
698static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, unsigned int offset, size_t len)
699{
700 struct rpc_xprt *xprt = rd_desc->arg.data;
701 skb_reader_t desc = {
702 .skb = skb,
703 .offset = offset,
704 .count = len,
705 .csum = 0
706 };
707
708 dprintk("RPC: xs_tcp_data_recv started\n");
709 do {
710 /* Read in a new fragment marker if necessary */
711 /* Can we ever really expect to get completely empty fragments? */
712 if (xprt->tcp_flags & XPRT_COPY_RECM) {
713 xs_tcp_read_fraghdr(xprt, &desc);
714 continue;
715 }
716 /* Read in the xid if necessary */
717 if (xprt->tcp_flags & XPRT_COPY_XID) {
718 xs_tcp_read_xid(xprt, &desc);
719 continue;
720 }
721 /* Read in the request data */
722 if (xprt->tcp_flags & XPRT_COPY_DATA) {
723 xs_tcp_read_request(xprt, &desc);
724 continue;
725 }
726 /* Skip over any trailing bytes on short reads */
727 xs_tcp_read_discard(xprt, &desc);
728 } while (desc.count);
729 dprintk("RPC: xs_tcp_data_recv done\n");
730 return len - desc.count;
731}
732
733/**
734 * xs_tcp_data_ready - "data ready" callback for TCP sockets
735 * @sk: socket with data to read
736 * @bytes: how much data to read
737 *
738 */
739static void xs_tcp_data_ready(struct sock *sk, int bytes)
740{
741 struct rpc_xprt *xprt;
742 read_descriptor_t rd_desc;
743
744 read_lock(&sk->sk_callback_lock);
745 dprintk("RPC: xs_tcp_data_ready...\n");
746 if (!(xprt = xprt_from_sock(sk)))
747 goto out;
748 if (xprt->shutdown)
749 goto out;
750
751 /* We use rd_desc to pass struct xprt to xs_tcp_data_recv */
752 rd_desc.arg.data = xprt;
753 rd_desc.count = 65536;
754 tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
755out:
756 read_unlock(&sk->sk_callback_lock);
757}
758
759/**
760 * xs_tcp_state_change - callback to handle TCP socket state changes
761 * @sk: socket whose state has changed
762 *
763 */
764static void xs_tcp_state_change(struct sock *sk)
765{
766 struct rpc_xprt *xprt;
767
768 read_lock(&sk->sk_callback_lock);
769 if (!(xprt = xprt_from_sock(sk)))
770 goto out;
771 dprintk("RPC: xs_tcp_state_change client %p...\n", xprt);
772 dprintk("RPC: state %x conn %d dead %d zapped %d\n",
773 sk->sk_state, xprt_connected(xprt),
774 sock_flag(sk, SOCK_DEAD),
775 sock_flag(sk, SOCK_ZAPPED));
776
777 switch (sk->sk_state) {
778 case TCP_ESTABLISHED:
779 spin_lock_bh(&xprt->transport_lock);
780 if (!xprt_test_and_set_connected(xprt)) {
781 /* Reset TCP record info */
782 xprt->tcp_offset = 0;
783 xprt->tcp_reclen = 0;
784 xprt->tcp_copied = 0;
785 xprt->tcp_flags = XPRT_COPY_RECM | XPRT_COPY_XID;
786 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
787 xprt_wake_pending_tasks(xprt, 0);
788 }
789 spin_unlock_bh(&xprt->transport_lock);
790 break;
791 case TCP_SYN_SENT:
792 case TCP_SYN_RECV:
793 break;
794 default:
795 xprt_disconnect(xprt);
796 break;
797 }
798 out:
799 read_unlock(&sk->sk_callback_lock);
800}
801
802/**
803 * xs_udp_write_space - callback invoked when socket buffer space
804 * becomes available
805 * @sk: socket whose state has changed
806 *
807 * Called when more output buffer space is available for this socket.
808 * We try not to wake our writers until they can make "significant"
809 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
810 * with a bunch of small requests.
811 */
812static void xs_udp_write_space(struct sock *sk)
813{
814 read_lock(&sk->sk_callback_lock);
815
816 /* from net/core/sock.c:sock_def_write_space */
817 if (sock_writeable(sk)) {
818 struct socket *sock;
819 struct rpc_xprt *xprt;
820
821 if (unlikely(!(sock = sk->sk_socket)))
822 goto out;
823 if (unlikely(!(xprt = xprt_from_sock(sk))))
824 goto out;
825 if (unlikely(!test_and_clear_bit(SOCK_NOSPACE, &sock->flags)))
826 goto out;
827
828 xprt_write_space(xprt);
829 }
830
831 out:
832 read_unlock(&sk->sk_callback_lock);
833}
834
835/**
836 * xs_tcp_write_space - callback invoked when socket buffer space
837 * becomes available
838 * @sk: socket whose state has changed
839 *
840 * Called when more output buffer space is available for this socket.
841 * We try not to wake our writers until they can make "significant"
842 * progress, otherwise we'll waste resources thrashing kernel_sendmsg
843 * with a bunch of small requests.
844 */
845static void xs_tcp_write_space(struct sock *sk)
846{
847 read_lock(&sk->sk_callback_lock);
848
849 /* from net/core/stream.c:sk_stream_write_space */
850 if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
851 struct socket *sock;
852 struct rpc_xprt *xprt;
853
854 if (unlikely(!(sock = sk->sk_socket)))
855 goto out;
856 if (unlikely(!(xprt = xprt_from_sock(sk))))
857 goto out;
858 if (unlikely(!test_and_clear_bit(SOCK_NOSPACE, &sock->flags)))
859 goto out;
860
861 xprt_write_space(xprt);
862 }
863
864 out:
865 read_unlock(&sk->sk_callback_lock);
866}
867
868static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt)
869{
870 struct sock *sk = xprt->inet;
871
872 if (xprt->rcvsize) {
873 sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
874 sk->sk_rcvbuf = xprt->rcvsize * xprt->max_reqs * 2;
875 }
876 if (xprt->sndsize) {
877 sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
878 sk->sk_sndbuf = xprt->sndsize * xprt->max_reqs * 2;
879 sk->sk_write_space(sk);
880 }
881}
882
883/**
884 * xs_udp_set_buffer_size - set send and receive limits
885 * @xprt: generic transport
886 * @sndsize: requested size of send buffer, in bytes
887 * @rcvsize: requested size of receive buffer, in bytes
888 *
889 * Set socket send and receive buffer size limits.
890 */
891static void xs_udp_set_buffer_size(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize)
892{
893 xprt->sndsize = 0;
894 if (sndsize)
895 xprt->sndsize = sndsize + 1024;
896 xprt->rcvsize = 0;
897 if (rcvsize)
898 xprt->rcvsize = rcvsize + 1024;
899
900 xs_udp_do_set_buffer_size(xprt);
901}
902
903/**
904 * xs_udp_timer - called when a retransmit timeout occurs on a UDP transport
905 * @task: task that timed out
906 *
907 * Adjust the congestion window after a retransmit timeout has occurred.
908 */
909static void xs_udp_timer(struct rpc_task *task)
910{
911 xprt_adjust_cwnd(task, -ETIMEDOUT);
912}
913
914static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
915{
916 struct sockaddr_in myaddr = {
917 .sin_family = AF_INET,
918 };
919 int err;
920 unsigned short port = xprt->port;
921
922 do {
923 myaddr.sin_port = htons(port);
924 err = sock->ops->bind(sock, (struct sockaddr *) &myaddr,
925 sizeof(myaddr));
926 if (err == 0) {
927 xprt->port = port;
928 dprintk("RPC: xs_bindresvport bound to port %u\n",
929 port);
930 return 0;
931 }
932 if (port <= xprt_min_resvport)
933 port = xprt_max_resvport;
934 else
935 port--;
936 } while (err == -EADDRINUSE && port != xprt->port);
937
938 dprintk("RPC: can't bind to reserved port (%d).\n", -err);
939 return err;
940}
941
942/**
943 * xs_udp_connect_worker - set up a UDP socket
944 * @args: RPC transport to connect
945 *
946 * Invoked by a work queue tasklet.
947 */
948static void xs_udp_connect_worker(void *args)
949{
950 struct rpc_xprt *xprt = (struct rpc_xprt *) args;
951 struct socket *sock = xprt->sock;
952 int err, status = -EIO;
953
954 if (xprt->shutdown || xprt->addr.sin_port == 0)
955 goto out;
956
957 dprintk("RPC: xs_udp_connect_worker for xprt %p\n", xprt);
958
959 /* Start by resetting any existing state */
960 xs_close(xprt);
961
962 if ((err = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
963 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
964 goto out;
965 }
966
967 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
968 sock_release(sock);
969 goto out;
970 }
971
972 if (!xprt->inet) {
973 struct sock *sk = sock->sk;
974
975 write_lock_bh(&sk->sk_callback_lock);
976
977 sk->sk_user_data = xprt;
978 xprt->old_data_ready = sk->sk_data_ready;
979 xprt->old_state_change = sk->sk_state_change;
980 xprt->old_write_space = sk->sk_write_space;
981 sk->sk_data_ready = xs_udp_data_ready;
982 sk->sk_write_space = xs_udp_write_space;
983 sk->sk_no_check = UDP_CSUM_NORCV;
984
985 xprt_set_connected(xprt);
986
987 /* Reset to new socket */
988 xprt->sock = sock;
989 xprt->inet = sk;
990
991 write_unlock_bh(&sk->sk_callback_lock);
992 }
993 xs_udp_do_set_buffer_size(xprt);
994 status = 0;
995out:
996 xprt_wake_pending_tasks(xprt, status);
997 xprt_clear_connecting(xprt);
998}
999
1000/*
1001 * We need to preserve the port number so the reply cache on the server can
1002 * find our cached RPC replies when we get around to reconnecting.
1003 */
1004static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
1005{
1006 int result;
1007 struct socket *sock = xprt->sock;
1008 struct sockaddr any;
1009
1010 dprintk("RPC: disconnecting xprt %p to reuse port\n", xprt);
1011
1012 /*
1013 * Disconnect the transport socket by doing a connect operation
1014 * with AF_UNSPEC. This should return immediately...
1015 */
1016 memset(&any, 0, sizeof(any));
1017 any.sa_family = AF_UNSPEC;
1018 result = sock->ops->connect(sock, &any, sizeof(any), 0);
1019 if (result)
1020 dprintk("RPC: AF_UNSPEC connect return code %d\n",
1021 result);
1022}
1023
1024/**
1025 * xs_tcp_connect_worker - connect a TCP socket to a remote endpoint
1026 * @args: RPC transport to connect
1027 *
1028 * Invoked by a work queue tasklet.
1029 */
1030static void xs_tcp_connect_worker(void *args)
1031{
1032 struct rpc_xprt *xprt = (struct rpc_xprt *)args;
1033 struct socket *sock = xprt->sock;
1034 int err, status = -EIO;
1035
1036 if (xprt->shutdown || xprt->addr.sin_port == 0)
1037 goto out;
1038
1039 dprintk("RPC: xs_tcp_connect_worker for xprt %p\n", xprt);
1040
1041 if (!xprt->sock) {
1042 /* start from scratch */
1043 if ((err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock)) < 0) {
1044 dprintk("RPC: can't create TCP transport socket (%d).\n", -err);
1045 goto out;
1046 }
1047
1048 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
1049 sock_release(sock);
1050 goto out;
1051 }
1052 } else
1053 /* "close" the socket, preserving the local port */
1054 xs_tcp_reuse_connection(xprt);
1055
1056 if (!xprt->inet) {
1057 struct sock *sk = sock->sk;
1058
1059 write_lock_bh(&sk->sk_callback_lock);
1060
1061 sk->sk_user_data = xprt;
1062 xprt->old_data_ready = sk->sk_data_ready;
1063 xprt->old_state_change = sk->sk_state_change;
1064 xprt->old_write_space = sk->sk_write_space;
1065 sk->sk_data_ready = xs_tcp_data_ready;
1066 sk->sk_state_change = xs_tcp_state_change;
1067 sk->sk_write_space = xs_tcp_write_space;
1068
1069 /* socket options */
1070 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
1071 sock_reset_flag(sk, SOCK_LINGER);
1072 tcp_sk(sk)->linger2 = 0;
1073 tcp_sk(sk)->nonagle |= TCP_NAGLE_OFF;
1074
1075 xprt_clear_connected(xprt);
1076
1077 /* Reset to new socket */
1078 xprt->sock = sock;
1079 xprt->inet = sk;
1080
1081 write_unlock_bh(&sk->sk_callback_lock);
1082 }
1083
1084 /* Tell the socket layer to start connecting... */
1085 status = sock->ops->connect(sock, (struct sockaddr *) &xprt->addr,
1086 sizeof(xprt->addr), O_NONBLOCK);
1087 dprintk("RPC: %p connect status %d connected %d sock state %d\n",
1088 xprt, -status, xprt_connected(xprt), sock->sk->sk_state);
1089 if (status < 0) {
1090 switch (status) {
1091 case -EINPROGRESS:
1092 case -EALREADY:
1093 goto out_clear;
1094 case -ECONNREFUSED:
1095 case -ECONNRESET:
1096 /* retry with existing socket, after a delay */
1097 break;
1098 default:
1099 /* get rid of existing socket, and retry */
1100 xs_close(xprt);
1101 break;
1102 }
1103 }
1104out:
1105 xprt_wake_pending_tasks(xprt, status);
1106out_clear:
1107 xprt_clear_connecting(xprt);
1108}
1109
1110/**
1111 * xs_connect - connect a socket to a remote endpoint
1112 * @task: address of RPC task that manages state of connect request
1113 *
1114 * TCP: If the remote end dropped the connection, delay reconnecting.
1115 *
1116 * UDP socket connects are synchronous, but we use a work queue anyway
1117 * to guarantee that even unprivileged user processes can set up a
1118 * socket on a privileged port.
1119 *
1120 * If a UDP socket connect fails, the delay behavior here prevents
1121 * retry floods (hard mounts).
1122 */
1123static void xs_connect(struct rpc_task *task)
1124{
1125 struct rpc_xprt *xprt = task->tk_xprt;
1126
1127 if (xprt_test_and_set_connecting(xprt))
1128 return;
1129
1130 if (xprt->sock != NULL) {
1131 dprintk("RPC: xs_connect delayed xprt %p for %lu seconds\n",
1132 xprt, xprt->reestablish_timeout / HZ);
1133 schedule_delayed_work(&xprt->connect_worker,
1134 xprt->reestablish_timeout);
1135 xprt->reestablish_timeout <<= 1;
1136 if (xprt->reestablish_timeout > XS_TCP_MAX_REEST_TO)
1137 xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO;
1138 } else {
1139 dprintk("RPC: xs_connect scheduled xprt %p\n", xprt);
1140 schedule_work(&xprt->connect_worker);
1141
1142 /* flush_scheduled_work can sleep... */
1143 if (!RPC_IS_ASYNC(task))
1144 flush_scheduled_work();
1145 }
1146}
1147
1148static struct rpc_xprt_ops xs_udp_ops = {
1149 .set_buffer_size = xs_udp_set_buffer_size,
1150 .reserve_xprt = xprt_reserve_xprt_cong,
1151 .release_xprt = xprt_release_xprt_cong,
1152 .connect = xs_connect,
1153 .send_request = xs_udp_send_request,
1154 .set_retrans_timeout = xprt_set_retrans_timeout_rtt,
1155 .timer = xs_udp_timer,
1156 .release_request = xprt_release_rqst_cong,
1157 .close = xs_close,
1158 .destroy = xs_destroy,
1159};
1160
1161static struct rpc_xprt_ops xs_tcp_ops = {
1162 .reserve_xprt = xprt_reserve_xprt,
1163 .release_xprt = xprt_release_xprt,
1164 .connect = xs_connect,
1165 .send_request = xs_tcp_send_request,
1166 .set_retrans_timeout = xprt_set_retrans_timeout_def,
1167 .close = xs_close,
1168 .destroy = xs_destroy,
1169};
1170
1171/**
1172 * xs_setup_udp - Set up transport to use a UDP socket
1173 * @xprt: transport to set up
1174 * @to: timeout parameters
1175 *
1176 */
1177int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1178{
1179 size_t slot_table_size;
1180
1181 dprintk("RPC: setting up udp-ipv4 transport...\n");
1182
1183 xprt->max_reqs = xprt_udp_slot_table_entries;
1184 slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]);
1185 xprt->slot = kmalloc(slot_table_size, GFP_KERNEL);
1186 if (xprt->slot == NULL)
1187 return -ENOMEM;
1188 memset(xprt->slot, 0, slot_table_size);
1189
1190 xprt->prot = IPPROTO_UDP;
1191 xprt->port = xprt_max_resvport;
1192 xprt->tsh_size = 0;
1193 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1194 /* XXX: header size can vary due to auth type, IPv6, etc. */
1195 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
1196
1197 INIT_WORK(&xprt->connect_worker, xs_udp_connect_worker, xprt);
1198 xprt->bind_timeout = XS_BIND_TO;
1199 xprt->connect_timeout = XS_UDP_CONN_TO;
1200 xprt->reestablish_timeout = XS_UDP_REEST_TO;
1201 xprt->idle_timeout = XS_IDLE_DISC_TO;
1202
1203 xprt->ops = &xs_udp_ops;
1204
1205 if (to)
1206 xprt->timeout = *to;
1207 else
1208 xprt_set_timeout(&xprt->timeout, 5, 5 * HZ);
1209
1210 return 0;
1211}
1212
1213/**
1214 * xs_setup_tcp - Set up transport to use a TCP socket
1215 * @xprt: transport to set up
1216 * @to: timeout parameters
1217 *
1218 */
1219int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1220{
1221 size_t slot_table_size;
1222
1223 dprintk("RPC: setting up tcp-ipv4 transport...\n");
1224
1225 xprt->max_reqs = xprt_tcp_slot_table_entries;
1226 slot_table_size = xprt->max_reqs * sizeof(xprt->slot[0]);
1227 xprt->slot = kmalloc(slot_table_size, GFP_KERNEL);
1228 if (xprt->slot == NULL)
1229 return -ENOMEM;
1230 memset(xprt->slot, 0, slot_table_size);
1231
1232 xprt->prot = IPPROTO_TCP;
1233 xprt->port = xprt_max_resvport;
1234 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
1235 xprt->resvport = capable(CAP_NET_BIND_SERVICE) ? 1 : 0;
1236 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
1237
1238 INIT_WORK(&xprt->connect_worker, xs_tcp_connect_worker, xprt);
1239 xprt->bind_timeout = XS_BIND_TO;
1240 xprt->connect_timeout = XS_TCP_CONN_TO;
1241 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
1242 xprt->idle_timeout = XS_IDLE_DISC_TO;
1243
1244 xprt->ops = &xs_tcp_ops;
1245
1246 if (to)
1247 xprt->timeout = *to;
1248 else
1249 xprt_set_timeout(&xprt->timeout, 2, 60 * HZ);
1250
1251 return 0;
1252}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index cbb0ba34a600..0db9e57013fd 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1192,46 +1192,6 @@ int xfrm_bundle_ok(struct xfrm_dst *first, struct flowi *fl, int family)
1192 1192
1193EXPORT_SYMBOL(xfrm_bundle_ok); 1193EXPORT_SYMBOL(xfrm_bundle_ok);
1194 1194
1195/* Well... that's _TASK_. We need to scan through transformation
1196 * list and figure out what mss tcp should generate in order to
1197 * final datagram fit to mtu. Mama mia... :-)
1198 *
1199 * Apparently, some easy way exists, but we used to choose the most
1200 * bizarre ones. :-) So, raising Kalashnikov... tra-ta-ta.
1201 *
1202 * Consider this function as something like dark humour. :-)
1203 */
1204static int xfrm_get_mss(struct dst_entry *dst, u32 mtu)
1205{
1206 int res = mtu - dst->header_len;
1207
1208 for (;;) {
1209 struct dst_entry *d = dst;
1210 int m = res;
1211
1212 do {
1213 struct xfrm_state *x = d->xfrm;
1214 if (x) {
1215 spin_lock_bh(&x->lock);
1216 if (x->km.state == XFRM_STATE_VALID &&
1217 x->type && x->type->get_max_size)
1218 m = x->type->get_max_size(d->xfrm, m);
1219 else
1220 m += x->props.header_len;
1221 spin_unlock_bh(&x->lock);
1222 }
1223 } while ((d = d->child) != NULL);
1224
1225 if (m <= mtu)
1226 break;
1227 res -= (m - mtu);
1228 if (res < 88)
1229 return mtu;
1230 }
1231
1232 return res + dst->header_len;
1233}
1234
1235int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) 1195int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
1236{ 1196{
1237 int err = 0; 1197 int err = 0;
@@ -1252,8 +1212,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
1252 dst_ops->negative_advice = xfrm_negative_advice; 1212 dst_ops->negative_advice = xfrm_negative_advice;
1253 if (likely(dst_ops->link_failure == NULL)) 1213 if (likely(dst_ops->link_failure == NULL))
1254 dst_ops->link_failure = xfrm_link_failure; 1214 dst_ops->link_failure = xfrm_link_failure;
1255 if (likely(dst_ops->get_mss == NULL))
1256 dst_ops->get_mss = xfrm_get_mss;
1257 if (likely(afinfo->garbage_collect == NULL)) 1215 if (likely(afinfo->garbage_collect == NULL))
1258 afinfo->garbage_collect = __xfrm_garbage_collect; 1216 afinfo->garbage_collect = __xfrm_garbage_collect;
1259 xfrm_policy_afinfo[afinfo->family] = afinfo; 1217 xfrm_policy_afinfo[afinfo->family] = afinfo;
@@ -1281,7 +1239,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
1281 dst_ops->check = NULL; 1239 dst_ops->check = NULL;
1282 dst_ops->negative_advice = NULL; 1240 dst_ops->negative_advice = NULL;
1283 dst_ops->link_failure = NULL; 1241 dst_ops->link_failure = NULL;
1284 dst_ops->get_mss = NULL;
1285 afinfo->garbage_collect = NULL; 1242 afinfo->garbage_collect = NULL;
1286 } 1243 }
1287 } 1244 }
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 9d206c282cf1..8b9a4747417d 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1026,6 +1026,12 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
1026} 1026}
1027EXPORT_SYMBOL(xfrm_state_delete_tunnel); 1027EXPORT_SYMBOL(xfrm_state_delete_tunnel);
1028 1028
1029/*
1030 * This function is NOT optimal. For example, with ESP it will give an
1031 * MTU that's usually two bytes short of being optimal. However, it will
1032 * usually give an answer that's a multiple of 4 provided the input is
1033 * also a multiple of 4.
1034 */
1029int xfrm_state_mtu(struct xfrm_state *x, int mtu) 1035int xfrm_state_mtu(struct xfrm_state *x, int mtu)
1030{ 1036{
1031 int res = mtu; 1037 int res = mtu;
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index f2ee673329a7..e3d144a3f10b 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -359,6 +359,13 @@ static int do_vio_entry(const char *filename, struct vio_device_id *vio,
359 return 1; 359 return 1;
360} 360}
361 361
362static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *alias)
363{
364 strcpy(alias, "i2c:");
365 ADD(alias, "id", 1, i2c->id);
366 return 1;
367}
368
362/* Ignore any prefix, eg. v850 prepends _ */ 369/* Ignore any prefix, eg. v850 prepends _ */
363static inline int sym_is(const char *symbol, const char *name) 370static inline int sym_is(const char *symbol, const char *name)
364{ 371{
@@ -443,6 +450,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
443 else if (sym_is(symname, "__mod_vio_device_table")) 450 else if (sym_is(symname, "__mod_vio_device_table"))
444 do_table(symval, sym->st_size, sizeof(struct vio_device_id), 451 do_table(symval, sym->st_size, sizeof(struct vio_device_id),
445 do_vio_entry, mod); 452 do_vio_entry, mod);
453 else if (sym_is(symname, "__mod_i2c_device_table"))
454 do_table(symval, sym->st_size, sizeof(struct i2c_device_id),
455 do_i2c_entry, mod);
446 456
447} 457}
448 458
diff --git a/security/dummy.c b/security/dummy.c
index 9623a61dfc76..3d34f3de7e82 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -768,7 +768,7 @@ static int dummy_socket_getpeersec(struct socket *sock, char __user *optval,
768 return -ENOPROTOOPT; 768 return -ENOPROTOOPT;
769} 769}
770 770
771static inline int dummy_sk_alloc_security (struct sock *sk, int family, int priority) 771static inline int dummy_sk_alloc_security (struct sock *sk, int family, gfp_t priority)
772{ 772{
773 return 0; 773 return 0;
774} 774}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index b13be15165f5..447a1e0f48cb 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -262,7 +262,7 @@ static void superblock_free_security(struct super_block *sb)
262} 262}
263 263
264#ifdef CONFIG_SECURITY_NETWORK 264#ifdef CONFIG_SECURITY_NETWORK
265static int sk_alloc_security(struct sock *sk, int family, int priority) 265static int sk_alloc_security(struct sock *sk, int family, gfp_t priority)
266{ 266{
267 struct sk_security_struct *ssec; 267 struct sk_security_struct *ssec;
268 268
@@ -3380,7 +3380,7 @@ out:
3380 return err; 3380 return err;
3381} 3381}
3382 3382
3383static int selinux_sk_alloc_security(struct sock *sk, int family, int priority) 3383static int selinux_sk_alloc_security(struct sock *sk, int family, gfp_t priority)
3384{ 3384{
3385 return sk_alloc_security(sk, family, priority); 3385 return sk_alloc_security(sk, family, priority);
3386} 3386}
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index b2d5db20ec8c..559ead6367da 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -20,6 +20,7 @@
20 20
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/irq.h> 22#include <asm/irq.h>
23#include <asm/sizes.h>
23#include <asm/hardware/amba.h> 24#include <asm/hardware/amba.h>
24 25
25#include <sound/driver.h> 26#include <sound/driver.h>
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index 38b20efc9c0b..877bb00d3295 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -275,23 +275,23 @@ static int pxa2xx_ac97_do_resume(snd_card_t *card)
275 return 0; 275 return 0;
276} 276}
277 277
278static int pxa2xx_ac97_suspend(struct device *_dev, pm_message_t state, u32 level) 278static int pxa2xx_ac97_suspend(struct device *_dev, pm_message_t state)
279{ 279{
280 snd_card_t *card = dev_get_drvdata(_dev); 280 snd_card_t *card = dev_get_drvdata(_dev);
281 int ret = 0; 281 int ret = 0;
282 282
283 if (card && level == SUSPEND_DISABLE) 283 if (card)
284 ret = pxa2xx_ac97_do_suspend(card, PMSG_SUSPEND); 284 ret = pxa2xx_ac97_do_suspend(card, PMSG_SUSPEND);
285 285
286 return ret; 286 return ret;
287} 287}
288 288
289static int pxa2xx_ac97_resume(struct device *_dev, u32 level) 289static int pxa2xx_ac97_resume(struct device *_dev)
290{ 290{
291 snd_card_t *card = dev_get_drvdata(_dev); 291 snd_card_t *card = dev_get_drvdata(_dev);
292 int ret = 0; 292 int ret = 0;
293 293
294 if (card && level == RESUME_ENABLE) 294 if (card)
295 ret = pxa2xx_ac97_do_resume(card); 295 ret = pxa2xx_ac97_do_resume(card);
296 296
297 return ret; 297 return ret;
diff --git a/sound/core/init.c b/sound/core/init.c
index c72a79115cca..59202de1d2ce 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -676,8 +676,8 @@ struct snd_generic_device {
676#define SND_GENERIC_NAME "snd_generic" 676#define SND_GENERIC_NAME "snd_generic"
677 677
678#ifdef CONFIG_PM 678#ifdef CONFIG_PM
679static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level); 679static int snd_generic_suspend(struct device *dev, pm_message_t state);
680static int snd_generic_resume(struct device *dev, u32 level); 680static int snd_generic_resume(struct device *dev);
681#endif 681#endif
682 682
683/* initialized in sound.c */ 683/* initialized in sound.c */
@@ -818,13 +818,10 @@ int snd_card_set_pm_callback(snd_card_t *card,
818 818
819#ifdef CONFIG_SND_GENERIC_DRIVER 819#ifdef CONFIG_SND_GENERIC_DRIVER
820/* suspend/resume callbacks for snd_generic platform device */ 820/* suspend/resume callbacks for snd_generic platform device */
821static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level) 821static int snd_generic_suspend(struct device *dev, pm_message_t state)
822{ 822{
823 snd_card_t *card; 823 snd_card_t *card;
824 824
825 if (level != SUSPEND_DISABLE)
826 return 0;
827
828 card = get_snd_generic_card(dev); 825 card = get_snd_generic_card(dev);
829 if (card->power_state == SNDRV_CTL_POWER_D3hot) 826 if (card->power_state == SNDRV_CTL_POWER_D3hot)
830 return 0; 827 return 0;
@@ -834,13 +831,10 @@ static int snd_generic_suspend(struct device *dev, pm_message_t state, u32 level
834 return 0; 831 return 0;
835} 832}
836 833
837static int snd_generic_resume(struct device *dev, u32 level) 834static int snd_generic_resume(struct device *dev)
838{ 835{
839 snd_card_t *card; 836 snd_card_t *card;
840 837
841 if (level != RESUME_ENABLE)
842 return 0;
843
844 card = get_snd_generic_card(dev); 838 card = get_snd_generic_card(dev);
845 if (card->power_state == SNDRV_CTL_POWER_D0) 839 if (card->power_state == SNDRV_CTL_POWER_D0)
846 return 0; 840 return 0;
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index e72cec77f0db..129abab5ce98 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -190,7 +190,7 @@ static void unmark_pages(struct page *page, int order)
190 * 190 *
191 * Returns the pointer of the buffer, or NULL if no enoguh memory. 191 * Returns the pointer of the buffer, or NULL if no enoguh memory.
192 */ 192 */
193void *snd_malloc_pages(size_t size, unsigned int gfp_flags) 193void *snd_malloc_pages(size_t size, gfp_t gfp_flags)
194{ 194{
195 int pg; 195 int pg;
196 void *res; 196 void *res;
@@ -235,7 +235,7 @@ static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *d
235{ 235{
236 int pg; 236 int pg;
237 void *res; 237 void *res;
238 unsigned int gfp_flags; 238 gfp_t gfp_flags;
239 239
240 snd_assert(size > 0, return NULL); 240 snd_assert(size > 0, return NULL);
241 snd_assert(dma != NULL, return NULL); 241 snd_assert(dma != NULL, return NULL);
diff --git a/sound/core/seq/instr/ainstr_gf1.c b/sound/core/seq/instr/ainstr_gf1.c
index 207c2c54bf1d..0e4df8826eed 100644
--- a/sound/core/seq/instr/ainstr_gf1.c
+++ b/sound/core/seq/instr/ainstr_gf1.c
@@ -51,7 +51,7 @@ static int snd_seq_gf1_copy_wave_from_stream(snd_gf1_ops_t *ops,
51 gf1_wave_t *wp, *prev; 51 gf1_wave_t *wp, *prev;
52 gf1_xwave_t xp; 52 gf1_xwave_t xp;
53 int err; 53 int err;
54 unsigned int gfp_mask; 54 gfp_t gfp_mask;
55 unsigned int real_size; 55 unsigned int real_size;
56 56
57 gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL; 57 gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
@@ -144,7 +144,8 @@ static int snd_seq_gf1_put(void *private_data, snd_seq_kinstr_t *instr,
144 snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data; 144 snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data;
145 gf1_instrument_t *ip; 145 gf1_instrument_t *ip;
146 gf1_xinstrument_t ix; 146 gf1_xinstrument_t ix;
147 int err, gfp_mask; 147 int err;
148 gfp_t gfp_mask;
148 149
149 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE) 150 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
150 return -EINVAL; 151 return -EINVAL;
diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c
index 67c24c8e8e7b..7c19fbbc5d0f 100644
--- a/sound/core/seq/instr/ainstr_iw.c
+++ b/sound/core/seq/instr/ainstr_iw.c
@@ -129,7 +129,7 @@ static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops,
129 iwffff_wave_t *wp, *prev; 129 iwffff_wave_t *wp, *prev;
130 iwffff_xwave_t xp; 130 iwffff_xwave_t xp;
131 int err; 131 int err;
132 unsigned int gfp_mask; 132 gfp_t gfp_mask;
133 unsigned int real_size; 133 unsigned int real_size;
134 134
135 gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL; 135 gfp_mask = atomic ? GFP_ATOMIC : GFP_KERNEL;
@@ -236,7 +236,7 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr,
236 iwffff_layer_t *lp, *prev_lp; 236 iwffff_layer_t *lp, *prev_lp;
237 iwffff_xlayer_t lx; 237 iwffff_xlayer_t lx;
238 int err; 238 int err;
239 unsigned int gfp_mask; 239 gfp_t gfp_mask;
240 240
241 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE) 241 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
242 return -EINVAL; 242 return -EINVAL;
diff --git a/sound/core/seq/instr/ainstr_simple.c b/sound/core/seq/instr/ainstr_simple.c
index 6183d2151034..17ab94e76073 100644
--- a/sound/core/seq/instr/ainstr_simple.c
+++ b/sound/core/seq/instr/ainstr_simple.c
@@ -57,7 +57,8 @@ static int snd_seq_simple_put(void *private_data, snd_seq_kinstr_t *instr,
57 snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data; 57 snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data;
58 simple_instrument_t *ip; 58 simple_instrument_t *ip;
59 simple_xinstrument_t ix; 59 simple_xinstrument_t ix;
60 int err, gfp_mask; 60 int err;
61 gfp_t gfp_mask;
61 unsigned int real_size; 62 unsigned int real_size;
62 63
63 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE) 64 if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE)
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 9e76bddb2c0b..b57519a3e3d9 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -231,7 +231,7 @@ int snd_register_device(int type, snd_card_t * card, int dev, snd_minor_t * reg,
231 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); 231 devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
232 if (card) 232 if (card)
233 device = card->dev; 233 device = card->dev;
234 class_device_create(sound_class, MKDEV(major, minor), device, "%s", name); 234 class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name);
235 235
236 up(&sound_mutex); 236 up(&sound_mutex);
237 return 0; 237 return 0;
diff --git a/sound/oss/dmasound/dmasound.h b/sound/oss/dmasound/dmasound.h
index 9a2f50f0b184..222014cafc1a 100644
--- a/sound/oss/dmasound/dmasound.h
+++ b/sound/oss/dmasound/dmasound.h
@@ -116,7 +116,7 @@ typedef struct {
116 const char *name; 116 const char *name;
117 const char *name2; 117 const char *name2;
118 struct module *owner; 118 struct module *owner;
119 void *(*dma_alloc)(unsigned int, int); 119 void *(*dma_alloc)(unsigned int, gfp_t);
120 void (*dma_free)(void *, unsigned int); 120 void (*dma_free)(void *, unsigned int);
121 int (*irqinit)(void); 121 int (*irqinit)(void);
122#ifdef MODULE 122#ifdef MODULE
diff --git a/sound/oss/dmasound/dmasound_atari.c b/sound/oss/dmasound/dmasound_atari.c
index 8daaf87664ba..59eb53f89318 100644
--- a/sound/oss/dmasound/dmasound_atari.c
+++ b/sound/oss/dmasound/dmasound_atari.c
@@ -114,7 +114,7 @@ static ssize_t ata_ctx_u16le(const u_char *userPtr, size_t userCount,
114/*** Low level stuff *********************************************************/ 114/*** Low level stuff *********************************************************/
115 115
116 116
117static void *AtaAlloc(unsigned int size, int flags); 117static void *AtaAlloc(unsigned int size, gfp_t flags);
118static void AtaFree(void *, unsigned int size); 118static void AtaFree(void *, unsigned int size);
119static int AtaIrqInit(void); 119static int AtaIrqInit(void);
120#ifdef MODULE 120#ifdef MODULE
@@ -810,7 +810,7 @@ static TRANS transFalconExpanding = {
810 * Atari (TT/Falcon) 810 * Atari (TT/Falcon)
811 */ 811 */
812 812
813static void *AtaAlloc(unsigned int size, int flags) 813static void *AtaAlloc(unsigned int size, gfp_t flags)
814{ 814{
815 return atari_stram_alloc(size, "dmasound"); 815 return atari_stram_alloc(size, "dmasound");
816} 816}
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 2ceb46f1d40f..b2bf8bac842d 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -271,7 +271,7 @@ int expand_read_bal; /* Balance factor for expanding reads (not volume!) */
271 271
272/*** Low level stuff *********************************************************/ 272/*** Low level stuff *********************************************************/
273 273
274static void *PMacAlloc(unsigned int size, int flags); 274static void *PMacAlloc(unsigned int size, gfp_t flags);
275static void PMacFree(void *ptr, unsigned int size); 275static void PMacFree(void *ptr, unsigned int size);
276static int PMacIrqInit(void); 276static int PMacIrqInit(void);
277#ifdef MODULE 277#ifdef MODULE
@@ -614,7 +614,7 @@ tas_init_frame_rates(unsigned int *prop, unsigned int l)
614/* 614/*
615 * PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA. 615 * PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA.
616 */ 616 */
617static void *PMacAlloc(unsigned int size, int flags) 617static void *PMacAlloc(unsigned int size, gfp_t flags)
618{ 618{
619 return kmalloc(size, flags); 619 return kmalloc(size, flags);
620} 620}
diff --git a/sound/oss/dmasound/dmasound_paula.c b/sound/oss/dmasound/dmasound_paula.c
index 558db5311e06..d59f60b26410 100644
--- a/sound/oss/dmasound/dmasound_paula.c
+++ b/sound/oss/dmasound/dmasound_paula.c
@@ -69,7 +69,7 @@ static int write_sq_block_size_half, write_sq_block_size_quarter;
69/*** Low level stuff *********************************************************/ 69/*** Low level stuff *********************************************************/
70 70
71 71
72static void *AmiAlloc(unsigned int size, int flags); 72static void *AmiAlloc(unsigned int size, gfp_t flags);
73static void AmiFree(void *obj, unsigned int size); 73static void AmiFree(void *obj, unsigned int size);
74static int AmiIrqInit(void); 74static int AmiIrqInit(void);
75#ifdef MODULE 75#ifdef MODULE
@@ -317,7 +317,7 @@ static inline void StopDMA(void)
317 enable_heartbeat(); 317 enable_heartbeat();
318} 318}
319 319
320static void *AmiAlloc(unsigned int size, int flags) 320static void *AmiAlloc(unsigned int size, gfp_t flags)
321{ 321{
322 return amiga_chip_alloc((long)size, "dmasound [Paula]"); 322 return amiga_chip_alloc((long)size, "dmasound [Paula]");
323} 323}
diff --git a/sound/oss/dmasound/dmasound_q40.c b/sound/oss/dmasound/dmasound_q40.c
index 92c25a0174db..1ddaa6284b08 100644
--- a/sound/oss/dmasound/dmasound_q40.c
+++ b/sound/oss/dmasound/dmasound_q40.c
@@ -36,7 +36,7 @@ static int expand_data; /* Data for expanding */
36/*** Low level stuff *********************************************************/ 36/*** Low level stuff *********************************************************/
37 37
38 38
39static void *Q40Alloc(unsigned int size, int flags); 39static void *Q40Alloc(unsigned int size, gfp_t flags);
40static void Q40Free(void *, unsigned int); 40static void Q40Free(void *, unsigned int);
41static int Q40IrqInit(void); 41static int Q40IrqInit(void);
42#ifdef MODULE 42#ifdef MODULE
@@ -358,7 +358,7 @@ static TRANS transQ40Compressing = {
358 358
359/*** Low level stuff *********************************************************/ 359/*** Low level stuff *********************************************************/
360 360
361static void *Q40Alloc(unsigned int size, int flags) 361static void *Q40Alloc(unsigned int size, gfp_t flags)
362{ 362{
363 return kmalloc(size, flags); /* change to vmalloc */ 363 return kmalloc(size, flags); /* change to vmalloc */
364} 364}
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 95fa81e26de2..d33bb464f70e 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -567,7 +567,7 @@ static int __init oss_init(void)
567 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor), 567 devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
568 S_IFCHR | dev_list[i].mode, 568 S_IFCHR | dev_list[i].mode,
569 "sound/%s", dev_list[i].name); 569 "sound/%s", dev_list[i].name);
570 class_device_create(sound_class, 570 class_device_create(sound_class, NULL,
571 MKDEV(SOUND_MAJOR, dev_list[i].minor), 571 MKDEV(SOUND_MAJOR, dev_list[i].minor),
572 NULL, "%s", dev_list[i].name); 572 NULL, "%s", dev_list[i].name);
573 573
@@ -579,7 +579,7 @@ static int __init oss_init(void)
579 dev_list[i].minor + (j*0x10)), 579 dev_list[i].minor + (j*0x10)),
580 S_IFCHR | dev_list[i].mode, 580 S_IFCHR | dev_list[i].mode,
581 "sound/%s%d", dev_list[i].name, j); 581 "sound/%s%d", dev_list[i].name, j);
582 class_device_create(sound_class, 582 class_device_create(sound_class, NULL,
583 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), 583 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
584 NULL, "%s%d", dev_list[i].name, j); 584 NULL, "%s%d", dev_list[i].name, j);
585 } 585 }
diff --git a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
index 05203ad523f7..8dae59bd05a2 100644
--- a/sound/oss/ymfpci.c
+++ b/sound/oss/ymfpci.c
@@ -107,14 +107,15 @@ static LIST_HEAD(ymf_devs);
107 */ 107 */
108 108
109static struct pci_device_id ymf_id_tbl[] = { 109static struct pci_device_id ymf_id_tbl[] = {
110#define DEV(v, d, data) \ 110#define DEV(dev, data) \
111 { PCI_VENDOR_ID_##v, PCI_DEVICE_ID_##v##_##d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long)data } 111 { PCI_VENDOR_ID_YAMAHA, dev, PCI_ANY_ID, PCI_ANY_ID, 0, 0, \
112 DEV (YAMAHA, 724, "YMF724"), 112 (unsigned long)data }
113 DEV (YAMAHA, 724F, "YMF724F"), 113 DEV (PCI_DEVICE_ID_YAMAHA_724, "YMF724"),
114 DEV (YAMAHA, 740, "YMF740"), 114 DEV (PCI_DEVICE_ID_YAMAHA_724F, "YMF724F"),
115 DEV (YAMAHA, 740C, "YMF740C"), 115 DEV (PCI_DEVICE_ID_YAMAHA_740, "YMF740"),
116 DEV (YAMAHA, 744, "YMF744"), 116 DEV (PCI_DEVICE_ID_YAMAHA_740C, "YMF740C"),
117 DEV (YAMAHA, 754, "YMF754"), 117 DEV (PCI_DEVICE_ID_YAMAHA_744, "YMF744"),
118 DEV (PCI_DEVICE_ID_YAMAHA_754, "YMF754"),
118#undef DEV 119#undef DEV
119 { } 120 { }
120}; 121};
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index f560dd8cdb90..d833349ed518 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -197,7 +197,7 @@ snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs)
197 spin_unlock(&h->lock); 197 spin_unlock(&h->lock);
198 198
199 if (dstatus & HARMONY_DSTATUS_PN) { 199 if (dstatus & HARMONY_DSTATUS_PN) {
200 if (h->psubs) { 200 if (h->psubs && h->st.playing) {
201 spin_lock(&h->lock); 201 spin_lock(&h->lock);
202 h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */ 202 h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */
203 h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */ 203 h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */
@@ -216,7 +216,7 @@ snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs)
216 } 216 }
217 217
218 if (dstatus & HARMONY_DSTATUS_RN) { 218 if (dstatus & HARMONY_DSTATUS_RN) {
219 if (h->csubs) { 219 if (h->csubs && h->st.capturing) {
220 spin_lock(&h->lock); 220 spin_lock(&h->lock);
221 h->cbuf.buf += h->cbuf.count; 221 h->cbuf.buf += h->cbuf.count;
222 h->cbuf.buf %= h->cbuf.size; 222 h->cbuf.buf %= h->cbuf.size;
@@ -316,6 +316,7 @@ snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd)
316 case SNDRV_PCM_TRIGGER_STOP: 316 case SNDRV_PCM_TRIGGER_STOP:
317 h->st.playing = 0; 317 h->st.playing = 0;
318 harmony_mute(h); 318 harmony_mute(h);
319 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr);
319 harmony_disable_interrupts(h); 320 harmony_disable_interrupts(h);
320 break; 321 break;
321 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 322 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -351,8 +352,9 @@ snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd)
351 break; 352 break;
352 case SNDRV_PCM_TRIGGER_STOP: 353 case SNDRV_PCM_TRIGGER_STOP:
353 h->st.capturing = 0; 354 h->st.capturing = 0;
354 harmony_mute(h); 355 harmony_mute(h);
355 harmony_disable_interrupts(h); 356 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr);
357 harmony_disable_interrupts(h);
356 break; 358 break;
357 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 359 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
358 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 360 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
@@ -408,7 +410,8 @@ snd_harmony_playback_prepare(snd_pcm_substream_t *ss)
408 410
409 h->pbuf.size = snd_pcm_lib_buffer_bytes(ss); 411 h->pbuf.size = snd_pcm_lib_buffer_bytes(ss);
410 h->pbuf.count = snd_pcm_lib_period_bytes(ss); 412 h->pbuf.count = snd_pcm_lib_period_bytes(ss);
411 h->pbuf.buf = 0; 413 if (h->pbuf.buf >= h->pbuf.size)
414 h->pbuf.buf = 0;
412 h->st.playing = 0; 415 h->st.playing = 0;
413 416
414 h->st.rate = snd_harmony_rate_bits(rt->rate); 417 h->st.rate = snd_harmony_rate_bits(rt->rate);
@@ -437,7 +440,8 @@ snd_harmony_capture_prepare(snd_pcm_substream_t *ss)
437 440
438 h->cbuf.size = snd_pcm_lib_buffer_bytes(ss); 441 h->cbuf.size = snd_pcm_lib_buffer_bytes(ss);
439 h->cbuf.count = snd_pcm_lib_period_bytes(ss); 442 h->cbuf.count = snd_pcm_lib_period_bytes(ss);
440 h->cbuf.buf = 0; 443 if (h->cbuf.buf >= h->cbuf.size)
444 h->cbuf.buf = 0;
441 h->st.capturing = 0; 445 h->st.capturing = 0;
442 446
443 h->st.rate = snd_harmony_rate_bits(rt->rate); 447 h->st.rate = snd_harmony_rate_bits(rt->rate);
@@ -712,13 +716,14 @@ snd_harmony_volume_get(snd_kcontrol_t *kc,
712 716
713 left = (h->st.gain >> shift_left) & mask; 717 left = (h->st.gain >> shift_left) & mask;
714 right = (h->st.gain >> shift_right) & mask; 718 right = (h->st.gain >> shift_right) & mask;
715
716 if (invert) { 719 if (invert) {
717 left = mask - left; 720 left = mask - left;
718 right = mask - right; 721 right = mask - right;
719 } 722 }
723
720 ucontrol->value.integer.value[0] = left; 724 ucontrol->value.integer.value[0] = left;
721 ucontrol->value.integer.value[1] = right; 725 if (shift_left != shift_right)
726 ucontrol->value.integer.value[1] = right;
722 727
723 spin_unlock_irqrestore(&h->mixer_lock, flags); 728 spin_unlock_irqrestore(&h->mixer_lock, flags);
724 729
@@ -738,22 +743,82 @@ snd_harmony_volume_put(snd_kcontrol_t *kc,
738 int old_gain = h->st.gain; 743 int old_gain = h->st.gain;
739 unsigned long flags; 744 unsigned long flags;
740 745
746 spin_lock_irqsave(&h->mixer_lock, flags);
747
741 left = ucontrol->value.integer.value[0] & mask; 748 left = ucontrol->value.integer.value[0] & mask;
742 right = ucontrol->value.integer.value[1] & mask; 749 if (invert)
743 if (invert) {
744 left = mask - left; 750 left = mask - left;
745 right = mask - right; 751 h->st.gain &= ~( (mask << shift_left ) );
752 h->st.gain |= (left << shift_left);
753
754 if (shift_left != shift_right) {
755 right = ucontrol->value.integer.value[1] & mask;
756 if (invert)
757 right = mask - right;
758 h->st.gain &= ~( (mask << shift_right) );
759 h->st.gain |= (right << shift_right);
746 } 760 }
761
762 snd_harmony_set_new_gain(h);
763
764 spin_unlock_irqrestore(&h->mixer_lock, flags);
765
766 return h->st.gain != old_gain;
767}
768
769static int
770snd_harmony_captureroute_info(snd_kcontrol_t *kc,
771 snd_ctl_elem_info_t *uinfo)
772{
773 static char *texts[2] = { "Line", "Mic" };
774 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
775 uinfo->count = 1;
776 uinfo->value.enumerated.items = 2;
777 if (uinfo->value.enumerated.item > 1)
778 uinfo->value.enumerated.item = 1;
779 strcpy(uinfo->value.enumerated.name,
780 texts[uinfo->value.enumerated.item]);
781 return 0;
782}
783
784static int
785snd_harmony_captureroute_get(snd_kcontrol_t *kc,
786 snd_ctl_elem_value_t *ucontrol)
787{
788 harmony_t *h = snd_kcontrol_chip(kc);
789 int value;
790 unsigned long flags;
791
792 spin_lock_irqsave(&h->mixer_lock, flags);
793
794 value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1;
795 ucontrol->value.enumerated.item[0] = value;
796
797 spin_unlock_irqrestore(&h->mixer_lock, flags);
798
799 return 0;
800}
801
802static int
803snd_harmony_captureroute_put(snd_kcontrol_t *kc,
804 snd_ctl_elem_value_t *ucontrol)
805{
806 harmony_t *h = snd_kcontrol_chip(kc);
807 int value;
808 int old_gain = h->st.gain;
809 unsigned long flags;
747 810
748 spin_lock_irqsave(&h->mixer_lock, flags); 811 spin_lock_irqsave(&h->mixer_lock, flags);
749 812
750 h->st.gain &= ~( (mask << shift_right) | (mask << shift_left) ); 813 value = ucontrol->value.enumerated.item[0] & 1;
751 h->st.gain |= ( (left << shift_left) | (right << shift_right) ); 814 h->st.gain &= ~HARMONY_GAIN_IS_MASK;
815 h->st.gain |= value << HARMONY_GAIN_IS_SHIFT;
816
752 snd_harmony_set_new_gain(h); 817 snd_harmony_set_new_gain(h);
753 818
754 spin_unlock_irqrestore(&h->mixer_lock, flags); 819 spin_unlock_irqrestore(&h->mixer_lock, flags);
755 820
756 return (old_gain - h->st.gain); 821 return h->st.gain != old_gain;
757} 822}
758 823
759#define HARMONY_CONTROLS (sizeof(snd_harmony_controls)/ \ 824#define HARMONY_CONTROLS (sizeof(snd_harmony_controls)/ \
@@ -767,10 +832,25 @@ snd_harmony_volume_put(snd_kcontrol_t *kc,
767 ((mask) << 16) | ((invert) << 24)) } 832 ((mask) << 16) | ((invert) << 24)) }
768 833
769static snd_kcontrol_new_t snd_harmony_controls[] = { 834static snd_kcontrol_new_t snd_harmony_controls[] = {
770 HARMONY_VOLUME("Playback Volume", HARMONY_GAIN_LO_SHIFT, 835 HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT,
771 HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), 836 HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1),
772 HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, 837 HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT,
773 HARMONY_GAIN_RI_SHIFT, HARMONY_GAIN_IN, 0), 838 HARMONY_GAIN_RI_SHIFT, HARMONY_GAIN_IN, 0),
839 HARMONY_VOLUME("Monitor Volume", HARMONY_GAIN_MA_SHIFT,
840 HARMONY_GAIN_MA_SHIFT, HARMONY_GAIN_MA, 1),
841 {
842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
843 .name = "Input Route",
844 .info = snd_harmony_captureroute_info,
845 .get = snd_harmony_captureroute_get,
846 .put = snd_harmony_captureroute_put
847 },
848 HARMONY_VOLUME("Internal Speaker Switch", HARMONY_GAIN_SE_SHIFT,
849 HARMONY_GAIN_SE_SHIFT, 1, 0),
850 HARMONY_VOLUME("Line-Out Switch", HARMONY_GAIN_LE_SHIFT,
851 HARMONY_GAIN_LE_SHIFT, 1, 0),
852 HARMONY_VOLUME("Headphones Switch", HARMONY_GAIN_HE_SHIFT,
853 HARMONY_GAIN_HE_SHIFT, 1, 0),
774}; 854};
775 855
776static void __init 856static void __init
@@ -852,14 +932,14 @@ snd_harmony_create(snd_card_t *card,
852 memset(&h->pbuf, 0, sizeof(h->pbuf)); 932 memset(&h->pbuf, 0, sizeof(h->pbuf));
853 memset(&h->cbuf, 0, sizeof(h->cbuf)); 933 memset(&h->cbuf, 0, sizeof(h->cbuf));
854 934
855 h->hpa = padev->hpa; 935 h->hpa = padev->hpa.start;
856 h->card = card; 936 h->card = card;
857 h->dev = padev; 937 h->dev = padev;
858 h->irq = padev->irq; 938 h->irq = padev->irq;
859 h->iobase = ioremap_nocache(padev->hpa, HARMONY_SIZE); 939 h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE);
860 if (h->iobase == NULL) { 940 if (h->iobase == NULL) {
861 printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", 941 printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n",
862 padev->hpa); 942 padev->hpa.start);
863 err = -EBUSY; 943 err = -EBUSY;
864 goto free_and_ret; 944 goto free_and_ret;
865 } 945 }
diff --git a/sound/parisc/harmony.h b/sound/parisc/harmony.h
index ef77f9a577d5..526c52389de2 100644
--- a/sound/parisc/harmony.h
+++ b/sound/parisc/harmony.h
@@ -61,7 +61,7 @@ typedef struct snd_card_harmony {
61#define HARMONY_SIZE 64 61#define HARMONY_SIZE 64
62 62
63#define BUF_SIZE PAGE_SIZE 63#define BUF_SIZE PAGE_SIZE
64#define MAX_BUFS 10 64#define MAX_BUFS 16
65#define MAX_BUF_SIZE (MAX_BUFS * BUF_SIZE) 65#define MAX_BUF_SIZE (MAX_BUFS * BUF_SIZE)
66 66
67#define PLAYBACK_BUFS MAX_BUFS 67#define PLAYBACK_BUFS MAX_BUFS
@@ -101,28 +101,31 @@ typedef struct snd_card_harmony {
101#define HARMONY_SS_MONO 0x00000000 101#define HARMONY_SS_MONO 0x00000000
102#define HARMONY_SS_STEREO 0x00000001 102#define HARMONY_SS_STEREO 0x00000001
103 103
104#define HARMONY_GAIN_SILENCE 0x00F00FFF 104#define HARMONY_GAIN_SILENCE 0x01F00FFF
105#define HARMONY_GAIN_DEFAULT 0x0FF00000 105#define HARMONY_GAIN_DEFAULT 0x01F00FFF
106 106
107#define HARMONY_GAIN_HE_SHIFT 27 107#define HARMONY_GAIN_HE_SHIFT 27 /* headphones enabled */
108#define HARMONY_GAIN_HE_MASK (1 << HARMONY_GAIN_HE_SHIFT) 108#define HARMONY_GAIN_HE_MASK (1 << HARMONY_GAIN_HE_SHIFT)
109#define HARMONY_GAIN_LE_SHIFT 26 109#define HARMONY_GAIN_LE_SHIFT 26 /* line-out enabled */
110#define HARMONY_GAIN_LE_MASK (1 << HARMONY_GAIN_LE_SHIFT) 110#define HARMONY_GAIN_LE_MASK (1 << HARMONY_GAIN_LE_SHIFT)
111#define HARMONY_GAIN_SE_SHIFT 25 111#define HARMONY_GAIN_SE_SHIFT 25 /* internal-speaker enabled */
112#define HARMONY_GAIN_SE_MASK (1 << HARMONY_GAIN_SE_SHIFT) 112#define HARMONY_GAIN_SE_MASK (1 << HARMONY_GAIN_SE_SHIFT)
113#define HARMONY_GAIN_IS_SHIFT 24 113#define HARMONY_GAIN_IS_SHIFT 24 /* input select - 0 for line, 1 for mic */
114#define HARMONY_GAIN_IS_MASK (1 << HARMONY_GAIN_IS_SHIFT) 114#define HARMONY_GAIN_IS_MASK (1 << HARMONY_GAIN_IS_SHIFT)
115 115
116/* monitor attenuation */
116#define HARMONY_GAIN_MA 0x0f 117#define HARMONY_GAIN_MA 0x0f
117#define HARMONY_GAIN_MA_SHIFT 20 118#define HARMONY_GAIN_MA_SHIFT 20
118#define HARMONY_GAIN_MA_MASK (HARMONY_GAIN_MA << HARMONY_GAIN_MA_SHIFT) 119#define HARMONY_GAIN_MA_MASK (HARMONY_GAIN_MA << HARMONY_GAIN_MA_SHIFT)
119 120
121/* input gain */
120#define HARMONY_GAIN_IN 0x0f 122#define HARMONY_GAIN_IN 0x0f
121#define HARMONY_GAIN_LI_SHIFT 16 123#define HARMONY_GAIN_LI_SHIFT 16
122#define HARMONY_GAIN_LI_MASK (HARMONY_GAIN_IN << HARMONY_GAIN_LI_SHIFT) 124#define HARMONY_GAIN_LI_MASK (HARMONY_GAIN_IN << HARMONY_GAIN_LI_SHIFT)
123#define HARMONY_GAIN_RI_SHIFT 12 125#define HARMONY_GAIN_RI_SHIFT 12
124#define HARMONY_GAIN_RI_MASK (HARMONY_GAIN_IN << HARMONY_GAIN_RI_SHIFT) 126#define HARMONY_GAIN_RI_MASK (HARMONY_GAIN_IN << HARMONY_GAIN_RI_SHIFT)
125 127
128/* output gain (master volume) */
126#define HARMONY_GAIN_OUT 0x3f 129#define HARMONY_GAIN_OUT 0x3f
127#define HARMONY_GAIN_LO_SHIFT 6 130#define HARMONY_GAIN_LO_SHIFT 6
128#define HARMONY_GAIN_LO_MASK (HARMONY_GAIN_OUT << HARMONY_GAIN_LO_SHIFT) 131#define HARMONY_GAIN_LO_MASK (HARMONY_GAIN_OUT << HARMONY_GAIN_LO_SHIFT)
diff --git a/sound/pci/ac97/ac97_bus.c b/sound/pci/ac97/ac97_bus.c
index becbc420ba41..ec70fadde7d9 100644
--- a/sound/pci/ac97/ac97_bus.c
+++ b/sound/pci/ac97/ac97_bus.c
@@ -31,7 +31,8 @@ static int ac97_bus_suspend(struct device *dev, pm_message_t state)
31 int ret = 0; 31 int ret = 0;
32 32
33 if (dev->driver && dev->driver->suspend) 33 if (dev->driver && dev->driver->suspend)
34 ret = dev->driver->suspend(dev, state, SUSPEND_POWER_DOWN); 34 ret = dev->driver->suspend(dev, state);
35
35 return ret; 36 return ret;
36} 37}
37 38
@@ -40,7 +41,8 @@ static int ac97_bus_resume(struct device *dev)
40 int ret = 0; 41 int ret = 0;
41 42
42 if (dev->driver && dev->driver->resume) 43 if (dev->driver && dev->driver->resume)
43 ret = dev->driver->resume(dev, RESUME_POWER_ON); 44 ret = dev->driver->resume(dev);
45
44 return ret; 46 return ret;
45} 47}
46 48
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 2236c958aec0..01d98eeb242e 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -761,15 +761,18 @@ static int __devinit snd_bt87x_create(snd_card_t *card,
761 761
762#define BT_DEVICE(chip, subvend, subdev, rate) \ 762#define BT_DEVICE(chip, subvend, subdev, rate) \
763 { .vendor = PCI_VENDOR_ID_BROOKTREE, \ 763 { .vendor = PCI_VENDOR_ID_BROOKTREE, \
764 .device = PCI_DEVICE_ID_BROOKTREE_##chip, \ 764 .device = chip, \
765 .subvendor = subvend, .subdevice = subdev, \ 765 .subvendor = subvend, .subdevice = subdev, \
766 .driver_data = rate } 766 .driver_data = rate }
767 767
768/* driver_data is the default digital_rate value for that device */ 768/* driver_data is the default digital_rate value for that device */
769static struct pci_device_id snd_bt87x_ids[] = { 769static struct pci_device_id snd_bt87x_ids[] = {
770 BT_DEVICE(878, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */ 770 /* Hauppauge WinTV series */
771 BT_DEVICE(879, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */ 771 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, 32000),
772 BT_DEVICE(878, 0x0070, 0xff01, 44100), /* Viewcast Osprey 200 */ 772 /* Hauppauge WinTV series */
773 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
774 /* Viewcast Osprey 200 */
775 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
773 { } 776 { }
774}; 777};
775MODULE_DEVICE_TABLE(pci, snd_bt87x_ids); 778MODULE_DEVICE_TABLE(pci, snd_bt87x_ids);
diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c
index 31ea7a4c069f..1681ee13efbb 100644
--- a/sound/ppc/beep.c
+++ b/sound/ppc/beep.c
@@ -31,14 +31,14 @@
31#include "pmac.h" 31#include "pmac.h"
32 32
33struct snd_pmac_beep { 33struct snd_pmac_beep {
34 int running; /* boolean */ 34 int running; /* boolean */
35 int volume; /* mixer volume: 0-100 */ 35 int volume; /* mixer volume: 0-100 */
36 int volume_play; /* currently playing volume */ 36 int volume_play; /* currently playing volume */
37 int hz; 37 int hz;
38 int nsamples; 38 int nsamples;
39 short *buf; /* allocated wave buffer */ 39 short *buf; /* allocated wave buffer */
40 dma_addr_t addr; /* physical address of buffer */ 40 dma_addr_t addr; /* physical address of buffer */
41 struct input_dev dev; 41 struct input_dev *dev;
42}; 42};
43 43
44/* 44/*
@@ -212,47 +212,55 @@ static snd_kcontrol_new_t snd_pmac_beep_mixer = {
212int __init snd_pmac_attach_beep(pmac_t *chip) 212int __init snd_pmac_attach_beep(pmac_t *chip)
213{ 213{
214 pmac_beep_t *beep; 214 pmac_beep_t *beep;
215 int err; 215 struct input_dev *input_dev;
216 void *dmabuf;
217 int err = -ENOMEM;
216 218
217 beep = kmalloc(sizeof(*beep), GFP_KERNEL); 219 beep = kzalloc(sizeof(*beep), GFP_KERNEL);
218 if (! beep) 220 dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
219 return -ENOMEM; 221 &beep->addr, GFP_KERNEL);
220 222 input_dev = input_allocate_device();
221 memset(beep, 0, sizeof(*beep)); 223 if (!beep || !dmabuf || !input_dev)
222 beep->buf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, 224 goto fail;
223 &beep->addr, GFP_KERNEL);
224
225 beep->dev.evbit[0] = BIT(EV_SND);
226 beep->dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
227 beep->dev.event = snd_pmac_beep_event;
228 beep->dev.private = chip;
229 225
230 /* FIXME: set more better values */ 226 /* FIXME: set more better values */
231 beep->dev.name = "PowerMac Beep"; 227 input_dev->name = "PowerMac Beep";
232 beep->dev.phys = "powermac/beep"; 228 input_dev->phys = "powermac/beep";
233 beep->dev.id.bustype = BUS_ADB; 229 input_dev->id.bustype = BUS_ADB;
234 beep->dev.id.vendor = 0x001f; 230 input_dev->id.vendor = 0x001f;
235 beep->dev.id.product = 0x0001; 231 input_dev->id.product = 0x0001;
236 beep->dev.id.version = 0x0100; 232 input_dev->id.version = 0x0100;
233
234 input_dev->evbit[0] = BIT(EV_SND);
235 input_dev->sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
236 input_dev->event = snd_pmac_beep_event;
237 input_dev->private = chip;
238 input_dev->cdev.dev = &chip->pdev->dev;
237 239
240 beep->dev = input_dev;
241 beep->buf = dmabuf;
238 beep->volume = BEEP_VOLUME; 242 beep->volume = BEEP_VOLUME;
239 beep->running = 0; 243 beep->running = 0;
240 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_beep_mixer, chip))) < 0) { 244
241 kfree(beep->buf); 245 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_pmac_beep_mixer, chip));
242 kfree(beep); 246 if (err < 0)
243 return err; 247 goto fail;
244 }
245 248
246 chip->beep = beep; 249 chip->beep = beep;
247 input_register_device(&beep->dev); 250 input_register_device(beep->dev);
248 251
249 return 0; 252 return 0;
253
254 fail: input_free_device(input_dev);
255 kfree(dmabuf);
256 kfree(beep);
257 return err;
250} 258}
251 259
252void snd_pmac_detach_beep(pmac_t *chip) 260void snd_pmac_detach_beep(pmac_t *chip)
253{ 261{
254 if (chip->beep) { 262 if (chip->beep) {
255 input_unregister_device(&chip->beep->dev); 263 input_unregister_device(chip->beep->dev);
256 dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4, 264 dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
257 chip->beep->buf, chip->beep->addr); 265 chip->beep->buf, chip->beep->addr);
258 kfree(chip->beep); 266 kfree(chip->beep);
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 954f994592ab..394b53e20cb8 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -174,7 +174,7 @@ static int sound_insert_unit(struct sound_unit **list, struct file_operations *f
174 174
175 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor), 175 devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
176 S_IFCHR | mode, s->name); 176 S_IFCHR | mode, s->name);
177 class_device_create(sound_class, MKDEV(SOUND_MAJOR, s->unit_minor), 177 class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor),
178 dev, s->name+6); 178 dev, s->name+6);
179 return r; 179 return r;
180 180
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index e0d0365453b3..f1a2e2c2e02f 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -163,7 +163,7 @@ static const uint8_t snd_usbmidi_cin_length[] = {
163/* 163/*
164 * Submits the URB, with error handling. 164 * Submits the URB, with error handling.
165 */ 165 */
166static int snd_usbmidi_submit_urb(struct urb* urb, int flags) 166static int snd_usbmidi_submit_urb(struct urb* urb, gfp_t flags)
167{ 167{
168 int err = usb_submit_urb(urb, flags); 168 int err = usb_submit_urb(urb, flags);
169 if (err < 0 && err != -ENODEV) 169 if (err < 0 && err != -ENODEV)